mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-26 14:03:09 +02:00
merge: Add support for glob-syntax in the config file environment variables (#257)
Reviewed-on: https://git.joinsharkey.org/Sharkey/Sharkey/pulls/257
This commit is contained in:
commit
947823f6ec
3 changed files with 18 additions and 10 deletions
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
@ -193,11 +194,18 @@ const path = process.env.MISSKEY_CONFIG_YML
|
|||
|
||||
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 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(path)
|
||||
.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;
|
||||
|
|
|
@ -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
|
||||
|
@ -7976,6 +7979,7 @@ packages:
|
|||
|
||||
/@types/node@20.10.5:
|
||||
resolution: {integrity: sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==}
|
||||
requiresBuild: true
|
||||
dependencies:
|
||||
undici-types: 5.26.5
|
||||
|
||||
|
@ -12732,7 +12736,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:
|
||||
|
@ -15000,12 +15004,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'}
|
||||
|
@ -17244,7 +17242,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:
|
||||
|
@ -19197,6 +19195,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==}
|
||||
|
|
Loading…
Reference in a new issue