Change loadConfig to load all yaml files in the config directory

This commit is contained in:
trivernis 2023-12-24 17:16:24 +01:00
parent fd57c7e24c
commit 64d34f595c
No known key found for this signature in database
GPG key ID: DFFFCC2C7A02DB45
4 changed files with 38 additions and 104 deletions

View file

@ -45,8 +45,8 @@
"lodash": "4.17.21"
},
"dependencies": {
"execa": "8.0.1",
"cssnano": "6.0.2",
"execa": "8.0.1",
"js-yaml": "4.1.0",
"postcss": "8.4.32",
"terser": "5.26.0",
@ -58,7 +58,7 @@
"cross-env": "7.0.3",
"cypress": "13.6.1",
"eslint": "8.56.0",
"start-server-and-test": "2.0.3",
"ncp": "2.0.0"
"ncp": "2.0.0",
"start-server-and-test": "2.0.3"
}
}

View file

@ -109,6 +109,7 @@
"file-type": "18.7.0",
"fluent-ffmpeg": "2.1.2",
"form-data": "4.0.0",
"glob": "^10.3.10",
"got": "14.0.0",
"happy-dom": "10.0.3",
"hpagent": "1.2.0",
@ -122,8 +123,8 @@
"json5": "2.2.3",
"jsonld": "8.3.2",
"jsrsasign": "10.9.0",
"meilisearch": "0.36.0",
"megalodon": "workspace:*",
"meilisearch": "0.36.0",
"microformats-parser": "2.0.2",
"mime-types": "2.1.35",
"misskey-js": "workspace:*",

View file

@ -8,6 +8,7 @@ import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
import * as yaml from 'js-yaml';
import type { RedisOptions } from 'ioredis';
import { globSync } from 'glob';
type RedisOptionsSource = Partial<RedisOptions> & {
host: string;
@ -185,19 +186,26 @@ const dir = `${_dirname}/../../../.config`;
/**
* Path of configuration file
*/
const path = process.env.MISSKEY_CONFIG_YML
? resolve(dir, process.env.MISSKEY_CONFIG_YML)
const cfgDir = process.env.MISSKEY_CONFIG_DIR
? resolve(dir, process.env.MISSKEY_CONFIG_DIR)
: process.env.NODE_ENV === 'test'
? resolve(dir, 'test.yml')
: resolve(dir, 'default.yml');
? resolve(dir, './test/')
: dir;
export function loadConfig(): Config {
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
const clientManifestExists = fs.existsSync(_dirname + '/../../../built/_vite_/manifest.json');
const clientManifest = clientManifestExists ?
JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_vite_/manifest.json`, 'utf-8'))
const clientManifestExists = fs.existsSync(`${_dirname}/../../../built/_vite_/manifest.json`);
const clientManifest = clientManifestExists
? JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_vite_/manifest.json`, 'utf-8'))
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' } };
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
const config = globSync(`${cfgDir}/*.{yaml,yml}`)
.map(path => fs.readFileSync(path, 'utf-8'))
.map(contents => yaml.load(contents) as Source)
.reduce(
(acc: Source, cur: Source) => Object.assign(acc, cur),
{} as Source,
) as Source;
const url = tryCreateUrl(config.url);
const version = meta.version;

View file

@ -208,6 +208,9 @@ importers:
form-data:
specifier: 4.0.0
version: 4.0.0
glob:
specifier: ^10.3.10
version: 10.3.10
got:
specifier: 14.0.0
version: 14.0.0
@ -870,10 +873,10 @@ importers:
version: 7.6.5
'@storybook/vue3':
specifier: 7.6.5
version: 7.6.5(@vue/compiler-core@3.3.8)(vue@3.3.12)
version: 7.6.5(@vue/compiler-core@3.3.12)(vue@3.3.12)
'@storybook/vue3-vite':
specifier: 7.6.5
version: 7.6.5(@vue/compiler-core@3.3.8)(typescript@5.3.3)(vite@5.0.10)(vue@3.3.12)
version: 7.6.5(@vue/compiler-core@3.3.12)(typescript@5.3.3)(vite@5.0.10)(vue@3.3.12)
'@testing-library/vue':
specifier: 8.0.1
version: 8.0.1(@vue/compiler-sfc@3.3.12)(vue@3.3.12)
@ -978,7 +981,7 @@ importers:
version: 7.6.5
storybook-addon-misskey-theme:
specifier: github:misskey-dev/storybook-addon-misskey-theme
version: github.com/misskey-dev/storybook-addon-misskey-theme/cf583db098365b2ccc81a82f63ca9c93bc32b640(@storybook/blocks@7.6.5)(@storybook/components@7.5.3)(@storybook/core-events@7.6.5)(@storybook/manager-api@7.6.5)(@storybook/preview-api@7.6.5)(@storybook/theming@7.6.5)(@storybook/types@7.6.5)(react-dom@18.2.0)(react@18.2.0)
version: github.com/misskey-dev/storybook-addon-misskey-theme/cf583db098365b2ccc81a82f63ca9c93bc32b640(@storybook/blocks@7.6.5)(@storybook/components@7.6.5)(@storybook/core-events@7.6.5)(@storybook/manager-api@7.6.5)(@storybook/preview-api@7.6.5)(@storybook/theming@7.6.5)(@storybook/types@7.6.5)(react-dom@18.2.0)(react@18.2.0)
summaly:
specifier: github:misskey-dev/summaly
version: github.com/misskey-dev/summaly/d2a3e07205c3c9769bc5a7b42031c8884b5a25c8
@ -6691,17 +6694,6 @@ packages:
- supports-color
dev: true
/@storybook/channels@7.5.3:
resolution: {integrity: sha512-dhWuV2o2lmxH0RKuzND8jxYzvSQTSmpE13P0IT/k8+I1up/rSNYOBQJT6SalakcNWXFAMXguo/8E7ApmnKKcEw==}
dependencies:
'@storybook/client-logger': 7.5.3
'@storybook/core-events': 7.5.3
'@storybook/global': 5.0.0
qs: 6.11.1
telejson: 7.2.0
tiny-invariant: 1.3.1
dev: true
/@storybook/channels@7.6.5:
resolution: {integrity: sha512-FIlNkyfQy9uHoJfAFL2/wO3ASGJELFvBzURBE2rcEF/TS7GcUiqWnBfiDxAbwSEjSOm2F0eEq3UXhaZEjpJHDw==}
dependencies:
@ -6765,12 +6757,6 @@ packages:
- utf-8-validate
dev: true
/@storybook/client-logger@7.5.3:
resolution: {integrity: sha512-vUFYALypjix5FoJ5M/XUP6KmyTnQJNW1poHdW7WXUVSg+lBM6E5eAtjTm0hdxNNDH8KSrdy24nCLra5h0X0BWg==}
dependencies:
'@storybook/global': 5.0.0
dev: true
/@storybook/client-logger@7.6.5:
resolution: {integrity: sha512-S5aROWgssqg7tcs9lgW5wmCAz4SxMAtioiyVj5oFecmPCbQtFVIAREYzeoxE4GfJL+plrfRkum4BzziANn8EhQ==}
dependencies:
@ -6798,29 +6784,6 @@ packages:
- supports-color
dev: true
/@storybook/components@7.5.3(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-M3+cjvEsDGLUx8RvK5wyF6/13LNlUnKbMgiDE8Sxk/v/WPpyhOAIh/B8VmrU1psahS61Jd4MTkFmLf1cWau1vw==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
dependencies:
'@radix-ui/react-select': 1.2.2(react-dom@18.2.0)(react@18.2.0)
'@radix-ui/react-toolbar': 1.0.4(react-dom@18.2.0)(react@18.2.0)
'@storybook/client-logger': 7.5.3
'@storybook/csf': 0.1.0
'@storybook/global': 5.0.0
'@storybook/theming': 7.5.3(react-dom@18.2.0)(react@18.2.0)
'@storybook/types': 7.5.3
memoizerific: 1.11.3
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
use-resize-observer: 9.1.0(react-dom@18.2.0)(react@18.2.0)
util-deprecate: 1.0.2
transitivePeerDependencies:
- '@types/react'
- '@types/react-dom'
dev: true
/@storybook/components@7.6.5(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-w4ZucbBBZ+NKMWlJKVj2I/bMBBq7gzDp9lzc4+8QaQ3vUPXKqc1ilIPYo/7UR5oxwDVMZocmMSgl9L8lvf7+Mw==}
peerDependencies:
@ -6882,12 +6845,6 @@ packages:
- supports-color
dev: true
/@storybook/core-events@7.5.3:
resolution: {integrity: sha512-DFOpyQ22JD5C1oeOFzL8wlqSWZzrqgDfDbUGP8xdO4wJu+FVTxnnWN6ZYLdTPB1u27DOhd7TzjQMfLDHLu7kbQ==}
dependencies:
ts-dedent: 2.2.0
dev: true
/@storybook/core-events@7.6.5:
resolution: {integrity: sha512-zk2q/qicYXAzHA4oV3GDbIql+Kd4TOHUgDE8e4jPCOPp856z2ScqEKUAbiJizs6eEJOH4nW9Db1kuzgrBVEykQ==}
dependencies:
@ -6970,12 +6927,6 @@ packages:
- supports-color
dev: true
/@storybook/csf@0.1.0:
resolution: {integrity: sha512-uk+jMXCZ8t38jSTHk2o5btI+aV2Ksbvl6DoOv3r6VaCM1KZqeuMwtwywIQdflkA8/6q/dKT8z8L+g8hC4GC3VQ==}
dependencies:
type-fest: 2.19.0
dev: true
/@storybook/csf@0.1.2:
resolution: {integrity: sha512-ePrvE/pS1vsKR9Xr+o+YwdqNgHUyXvg+1Xjx0h9LrVx7Zq4zNe06pd63F5EvzTbCbJsHj7GHr9tkiaqm7U8WRA==}
dependencies:
@ -7205,20 +7156,6 @@ packages:
ts-dedent: 2.2.0
dev: true
/@storybook/theming@7.5.3(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-Cjmthe1MAk0z4RKCZ7m72gAD8YD0zTAH97z5ryM1Qv84QXjiCQ143fGOmYz1xEQdNFpOThPcwW6FEccLHTkVcg==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
dependencies:
'@emotion/use-insertion-effect-with-fallbacks': 1.0.0(react@18.2.0)
'@storybook/client-logger': 7.5.3
'@storybook/global': 5.0.0
memoizerific: 1.11.3
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: true
/@storybook/theming@7.6.5(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-RpcWT0YEgiobO41McVPDfQQHHFnjyr1sJnNTPJIvOUgSfURdgSj17mQVxtD5xcXcPWUdle5UhIOrCixHbL/NNw==}
peerDependencies:
@ -7233,15 +7170,6 @@ packages:
react-dom: 18.2.0(react@18.2.0)
dev: true
/@storybook/types@7.5.3:
resolution: {integrity: sha512-iu5W0Kdd6nysN5CPkY4GRl+0BpxRTdSfBIJak7mb6xCIHSB5t1tw4BOuqMQ5EgpikRY3MWJ4gY647QkWBX3MNQ==}
dependencies:
'@storybook/channels': 7.5.3
'@types/babel__core': 7.20.5
'@types/express': 4.17.17
file-system-cache: 2.3.0
dev: true
/@storybook/types@7.6.5:
resolution: {integrity: sha512-Q757v+fYZZSaEpks/zDL5YgXRozxkgKakXFc+BoQHK5q5sVhJ+0jvpLJiAQAniIIaMIkqY/G24Kd6Uo6UdKBCg==}
dependencies:
@ -7251,7 +7179,7 @@ packages:
file-system-cache: 2.3.0
dev: true
/@storybook/vue3-vite@7.6.5(@vue/compiler-core@3.3.8)(typescript@5.3.3)(vite@5.0.10)(vue@3.3.12):
/@storybook/vue3-vite@7.6.5(@vue/compiler-core@3.3.12)(typescript@5.3.3)(vite@5.0.10)(vue@3.3.12):
resolution: {integrity: sha512-7wUCq2Lrjlekftd5ha3hG0GSGbbzuc370cKkBqSmwFuOfI38z5+VeYt7nDtAlncxcpVSH7DejTGRuKTlC7NyYg==}
engines: {node: ^14.18 || >=16}
peerDependencies:
@ -7259,7 +7187,7 @@ packages:
dependencies:
'@storybook/builder-vite': 7.6.5(typescript@5.3.3)(vite@5.0.10)
'@storybook/core-server': 7.6.5
'@storybook/vue3': 7.6.5(@vue/compiler-core@3.3.8)(vue@3.3.12)
'@storybook/vue3': 7.6.5(@vue/compiler-core@3.3.12)(vue@3.3.12)
'@vitejs/plugin-vue': 4.5.2(vite@5.0.10)(vue@3.3.12)
magic-string: 0.30.5
vite: 5.0.10(@types/node@20.10.5)(sass@1.69.5)(terser@5.26.0)
@ -7276,7 +7204,7 @@ packages:
- vue
dev: true
/@storybook/vue3@7.6.5(@vue/compiler-core@3.3.8)(vue@3.3.12):
/@storybook/vue3@7.6.5(@vue/compiler-core@3.3.12)(vue@3.3.12):
resolution: {integrity: sha512-tv/9rVc3XXDOJu5hfZtKhrhM8x4GTLKon62Rmaxlq06weqkGlfBi/V/g1EZ7OE71Pi+woKS/TX7p9qbRrvgahg==}
engines: {node: '>=16.0.0'}
peerDependencies:
@ -7288,7 +7216,7 @@ packages:
'@storybook/global': 5.0.0
'@storybook/preview-api': 7.6.5
'@storybook/types': 7.6.5
'@vue/compiler-core': 3.3.8
'@vue/compiler-core': 3.3.12
lodash: 4.17.21
ts-dedent: 2.2.0
type-fest: 2.19.0
@ -8048,6 +7976,7 @@ packages:
/@types/node@20.10.5:
resolution: {integrity: sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==}
requiresBuild: true
dependencies:
undici-types: 5.26.5
@ -12799,7 +12728,7 @@ packages:
fs.realpath: 1.0.0
inflight: 1.0.6
inherits: 2.0.4
minimatch: 5.1.2
minimatch: 5.1.6
once: 1.4.0
/global-dirs@3.0.1:
@ -15060,12 +14989,6 @@ packages:
dependencies:
brace-expansion: 1.1.11
/minimatch@5.1.2:
resolution: {integrity: sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==}
engines: {node: '>=10'}
dependencies:
brace-expansion: 2.0.1
/minimatch@5.1.6:
resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==}
engines: {node: '>=10'}
@ -17304,7 +17227,7 @@ packages:
/readdir-glob@1.1.2:
resolution: {integrity: sha512-6RLVvwJtVwEDfPdn6X6Ille4/lxGl0ATOY4FN/B9nxQcgOazvvI0nodiD19ScKq0PvA/29VpaOQML36o5IzZWA==}
dependencies:
minimatch: 5.1.2
minimatch: 5.1.6
dev: false
/readdirp@3.6.0:
@ -18888,6 +18811,7 @@ packages:
/ts-case-convert@2.0.2:
resolution: {integrity: sha512-vdKfx1VAdpvEBOBv5OpVu5ZFqRg9HdTI4sYt6qqMeICBeNyXvitrarCnFWNDAki51IKwCyx+ZssY46Q9jH5otA==}
dev: true
bundledDependencies: []
/ts-dedent@2.2.0:
resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==}
@ -19256,6 +19180,7 @@ packages:
/undici-types@5.26.5:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
requiresBuild: true
/undici@5.22.1:
resolution: {integrity: sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw==}
@ -20281,7 +20206,7 @@ packages:
sharp: 0.31.3
dev: false
github.com/misskey-dev/storybook-addon-misskey-theme/cf583db098365b2ccc81a82f63ca9c93bc32b640(@storybook/blocks@7.6.5)(@storybook/components@7.5.3)(@storybook/core-events@7.6.5)(@storybook/manager-api@7.6.5)(@storybook/preview-api@7.6.5)(@storybook/theming@7.6.5)(@storybook/types@7.6.5)(react-dom@18.2.0)(react@18.2.0):
github.com/misskey-dev/storybook-addon-misskey-theme/cf583db098365b2ccc81a82f63ca9c93bc32b640(@storybook/blocks@7.6.5)(@storybook/components@7.6.5)(@storybook/core-events@7.6.5)(@storybook/manager-api@7.6.5)(@storybook/preview-api@7.6.5)(@storybook/theming@7.6.5)(@storybook/types@7.6.5)(react-dom@18.2.0)(react@18.2.0):
resolution: {tarball: https://codeload.github.com/misskey-dev/storybook-addon-misskey-theme/tar.gz/cf583db098365b2ccc81a82f63ca9c93bc32b640}
id: github.com/misskey-dev/storybook-addon-misskey-theme/cf583db098365b2ccc81a82f63ca9c93bc32b640
name: storybook-addon-misskey-theme
@ -20303,7 +20228,7 @@ packages:
optional: true
dependencies:
'@storybook/blocks': 7.6.5(react-dom@18.2.0)(react@18.2.0)
'@storybook/components': 7.5.3(react-dom@18.2.0)(react@18.2.0)
'@storybook/components': 7.6.5(react-dom@18.2.0)(react@18.2.0)
'@storybook/core-events': 7.6.5
'@storybook/manager-api': 7.6.5(react-dom@18.2.0)(react@18.2.0)
'@storybook/preview-api': 7.6.5