summaryrefslogtreecommitdiff
path: root/packages/backend/scripts
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-12-04 16:49:25 +0900
committerGitHub <noreply@github.com>2025-12-04 16:49:25 +0900
commit24bd1509677023ddd8a749bb7fbfe876c7627b48 (patch)
treec3c65a5cf9091e434ad3ba83b087ffd952728caf /packages/backend/scripts
parentfix(frontend): stacking router viewで連続して戻る操作を行うと何... (diff)
downloadmisskey-24bd1509677023ddd8a749bb7fbfe876c7627b48.tar.gz
misskey-24bd1509677023ddd8a749bb7fbfe876c7627b48.tar.bz2
misskey-24bd1509677023ddd8a749bb7fbfe876c7627b48.zip
refactor(backend): 変換後.config.jsonに統一するように+修正など (#16929)
* wip * Update config.ts * wip * convertは元ファイルを変更するようなニュアンスを若干感じるのでcompileに改名 * wip * Update package.json * Revert "Update package.json" This reverts commit e5c28023168f4631dc6b36a14b35cfddbad1fac0. * wip * wip * 謎 * clean up * wip * wip * Revert "wip" This reverts commit 3aa25ac7cf337d57412308e63d8f54e2536b0f7f. * wip * wip * Update dummy.yml * wip * Update compile_config.js * Update compile_config.js * wip * Revert "wip" This reverts commit fd78e097c65f747962e7a411938a0e67538ed347. * Update dummy.yml * Update compile_config.js
Diffstat (limited to 'packages/backend/scripts')
-rw-r--r--packages/backend/scripts/compile_config.js (renamed from packages/backend/scripts/convert_config.js)35
1 files changed, 15 insertions, 20 deletions
diff --git a/packages/backend/scripts/convert_config.js b/packages/backend/scripts/compile_config.js
index e93baa409a..e78fa3dc9f 100644
--- a/packages/backend/scripts/convert_config.js
+++ b/packages/backend/scripts/compile_config.js
@@ -17,43 +17,38 @@ const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
const configDir = resolve(_dirname, '../../../.config');
+const OUTPUT_PATH = resolve(_dirname, '../../../built/.config.json');
+
+// TODO: yamlのパースに失敗したときのエラーハンドリング
/**
* YAMLファイルをJSONファイルに変換
* @param {string} ymlPath - YAMLファイルのパス
- * @param {string} jsonPath - JSONファイルの出力パス
*/
-function convertYamlToJson(ymlPath, jsonPath) {
+function yamlToJson(ymlPath) {
if (!fs.existsSync(ymlPath)) {
- console.log(`skipped: ${ymlPath} is not found`);
+ console.warn(`YAML file not found: ${ymlPath}`);
return;
}
+ console.log(`${ymlPath} → ${OUTPUT_PATH}`);
+
const yamlContent = fs.readFileSync(ymlPath, 'utf-8');
const jsonContent = yaml.load(yamlContent);
- fs.writeFileSync(jsonPath, JSON.stringify({
+ if (!fs.existsSync(dirname(OUTPUT_PATH))) {
+ fs.mkdirSync(dirname(OUTPUT_PATH), { recursive: true });
+ }
+ fs.writeFileSync(OUTPUT_PATH, JSON.stringify({
'_NOTE_': 'This file is auto-generated from YAML file. DO NOT EDIT.',
...jsonContent,
}), 'utf-8');
- console.log(`✓ ${ymlPath} → ${jsonPath}`);
}
-// default.yml と test.yml を変換
-convertYamlToJson(
- resolve(configDir, 'default.yml'),
- resolve(configDir, 'default.json'),
-);
-
-convertYamlToJson(
- resolve(configDir, 'test.yml'),
- resolve(configDir, 'test.json'),
-);
-
-// MISSKEY_CONFIG_YML 環境変数が指定されている場合も変換
if (process.env.MISSKEY_CONFIG_YML) {
const customYmlPath = resolve(configDir, process.env.MISSKEY_CONFIG_YML);
- const customJsonPath = customYmlPath.replace(/\.ya?ml$/i, '.json');
- convertYamlToJson(customYmlPath, customJsonPath);
+ yamlToJson(customYmlPath);
+} else {
+ yamlToJson(resolve(configDir, process.env.NODE_ENV === 'test' ? 'test.yml' : 'default.yml'));
}
-console.log('Configuration compiled');
+console.log('Configuration compiled ✓');