1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-22 12:54:06 +02:00

Remove js-yaml from runtime dependencies, use pre-compiled JSON instead

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-01 02:11:02 +00:00
parent 5e6fe5bef6
commit 69c8d8e102
8 changed files with 83 additions and 40 deletions

View File

@@ -6,7 +6,6 @@
import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
import * as yaml from 'js-yaml';
import { type FastifyServerOptions } from 'fastify';
import type * as Sentry from '@sentry/node';
import type * as SentryVue from '@sentry/vue';
@@ -223,14 +222,19 @@ const _dirname = dirname(_filename);
const dir = `${_dirname}/../../../.config`;
/**
* Path of configuration file
* Path of configuration file (YAML)
*/
export const path = process.env.MISSKEY_CONFIG_YML
const configYmlPath = process.env.MISSKEY_CONFIG_YML
? resolve(dir, process.env.MISSKEY_CONFIG_YML)
: process.env.NODE_ENV === 'test'
? resolve(dir, 'test.yml')
: resolve(dir, 'default.yml');
/**
* Path of configuration file (JSON, pre-compiled from YAML)
*/
export const path = configYmlPath.replace(/\.yml$/, '.json');
export function loadConfig(): Config {
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
@@ -243,7 +247,7 @@ export function loadConfig(): Config {
JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_frontend_embed_vite_/manifest.json`, 'utf-8'))
: { 'src/boot.ts': { file: null } };
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
const config = JSON.parse(fs.readFileSync(path, 'utf-8')) as Source;
const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
const version = meta.version;