Compare commits
12 Commits
develop
...
copilot/re
| Author | SHA1 | Date |
|---|---|---|
|
|
1f8d6b286b | |
|
|
731a1daaf2 | |
|
|
791684efc0 | |
|
|
570a795785 | |
|
|
36bec1cadb | |
|
|
811d6dc8b3 | |
|
|
a7e4518131 | |
|
|
d6d5606d68 | |
|
|
bf50e2ddde | |
|
|
ffdc78b354 | |
|
|
69c8d8e102 | |
|
|
5e6fe5bef6 |
25
package.json
25
package.json
|
|
@ -22,31 +22,32 @@
|
|||
],
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"compile-config": "node ./scripts/compile_config.js",
|
||||
"build-pre": "node ./scripts/build-pre.js",
|
||||
"build-assets": "node ./scripts/build-assets.mjs",
|
||||
"build": "pnpm build-pre && pnpm -r build && pnpm build-assets",
|
||||
"build-storybook": "pnpm --filter frontend build-storybook",
|
||||
"build-misskey-js-with-types": "pnpm build-pre && pnpm --filter backend... --filter=!misskey-js build && pnpm --filter backend generate-api-json --no-build && ncp packages/backend/built/api.json packages/misskey-js/generator/api.json && pnpm --filter misskey-js update-autogen-code && pnpm --filter misskey-js build && pnpm --filter misskey-js api",
|
||||
"start": "pnpm check:connect && cd packages/backend && node ./built/boot/entry.js",
|
||||
"start:inspect": "cd packages/backend && node --inspect ./built/boot/entry.js",
|
||||
"start:test": "ncp ./.github/misskey/test.yml ./.config/test.yml && cd packages/backend && cross-env NODE_ENV=test node ./built/boot/entry.js",
|
||||
"start": "pnpm compile-config && pnpm check:connect && cd packages/backend && pnpm start",
|
||||
"start:inspect": "cd packages/backend && pnpm start:inspect",
|
||||
"start:test": "ncp ./.github/misskey/test.yml ./.config/test.yml && cross-env NODE_ENV=test pnpm compile-config && cd packages/backend && pnpm start:test",
|
||||
"cli": "cd packages/backend && pnpm cli",
|
||||
"init": "pnpm migrate",
|
||||
"migrate": "cd packages/backend && pnpm migrate",
|
||||
"revert": "cd packages/backend && pnpm revert",
|
||||
"check:connect": "cd packages/backend && pnpm check:connect",
|
||||
"migrate": "pnpm compile-config && cd packages/backend && pnpm migrate",
|
||||
"revert": "pnpm compile-config && cd packages/backend && pnpm revert",
|
||||
"check:connect": "pnpm compile-config && cd packages/backend && pnpm check:connect",
|
||||
"migrateandstart": "pnpm migrate && pnpm start",
|
||||
"watch": "pnpm dev",
|
||||
"dev": "node scripts/dev.mjs",
|
||||
"lint": "pnpm -r lint",
|
||||
"cy:open": "pnpm cypress open --config-file=cypress.config.ts",
|
||||
"cy:run": "pnpm cypress run",
|
||||
"e2e": "pnpm start-server-and-test start:test http://localhost:61812 cy:run",
|
||||
"e2e-dev-container": "ncp ./.config/cypress-devcontainer.yml ./.config/test.yml && pnpm start-server-and-test start:test http://localhost:61812 cy:run",
|
||||
"jest": "cd packages/backend && pnpm jest",
|
||||
"jest-and-coverage": "cd packages/backend && pnpm jest-and-coverage",
|
||||
"test": "pnpm -r test",
|
||||
"test-and-coverage": "pnpm -r test-and-coverage",
|
||||
"e2e": "cross-env NODE_ENV=test pnpm compile-config && pnpm start-server-and-test start:test http://localhost:61812 cy:run",
|
||||
"e2e-dev-container": "ncp ./.config/cypress-devcontainer.yml ./.config/test.yml && cross-env NODE_ENV=test pnpm compile-config && pnpm start-server-and-test start:test http://localhost:61812 cy:run",
|
||||
"jest": "cross-env NODE_ENV=test pnpm compile-config && cd packages/backend && pnpm jest",
|
||||
"jest-and-coverage": "cross-env NODE_ENV=test pnpm compile-config && cd packages/backend && pnpm jest-and-coverage",
|
||||
"test": "cross-env NODE_ENV=test pnpm compile-config && pnpm -r test",
|
||||
"test-and-coverage": "cross-env NODE_ENV=test pnpm compile-config && pnpm -r test-and-coverage",
|
||||
"clean": "node ./scripts/clean.js",
|
||||
"clean-all": "node ./scripts/clean-all.js",
|
||||
"cleanall": "pnpm clean-all"
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { path as configYamlPath } from '../../built/config.js';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { path as configJsonPath } from '../../built/config.js';
|
||||
import fs from "node:fs";
|
||||
|
||||
export function isConcurrentIndexMigrationEnabled() {
|
||||
|
|
@ -14,7 +13,7 @@ export function isConcurrentIndexMigrationEnabled() {
|
|||
let loadedConfigCache = undefined;
|
||||
|
||||
function loadConfigInternal() {
|
||||
const config = yaml.load(fs.readFileSync(configYamlPath, 'utf-8'));
|
||||
const config = JSON.parse(fs.readFileSync(configJsonPath, 'utf-8'));
|
||||
|
||||
return {
|
||||
disallowExternalApRedirect: Boolean(config.disallowExternalApRedirect ?? false),
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@
|
|||
"ip-cidr": "4.0.2",
|
||||
"ipaddr.js": "2.2.0",
|
||||
"is-svg": "6.1.0",
|
||||
"js-yaml": "4.1.1",
|
||||
"json5": "2.2.3",
|
||||
"jsonld": "9.0.0",
|
||||
"jsrsasign": "11.1.0",
|
||||
|
|
@ -198,7 +197,6 @@
|
|||
"@types/fluent-ffmpeg": "2.1.28",
|
||||
"@types/http-link-header": "1.0.7",
|
||||
"@types/jest": "29.5.14",
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/jsonld": "1.5.15",
|
||||
"@types/jsrsasign": "10.5.15",
|
||||
"@types/mime-types": "3.0.1",
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
@ -226,11 +225,7 @@ const dir = `${_dirname}/../../../.config`;
|
|||
/**
|
||||
* Path of configuration file
|
||||
*/
|
||||
export const path = 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');
|
||||
export const path = resolve(dir, 'config.json');
|
||||
|
||||
export function loadConfig(): Config {
|
||||
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
|
||||
|
|
@ -244,7 +239,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;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import * as esbuild from 'esbuild';
|
|||
import { build } from 'esbuild';
|
||||
import { execa } from 'execa';
|
||||
import { globSync } from 'glob';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { generateLocaleInterface } from './scripts/generateLocaleInterface.js';
|
||||
import type { BuildOptions, BuildResult, Plugin, PluginBuild } from 'esbuild';
|
||||
|
||||
|
|
@ -49,7 +50,18 @@ if (args.includes('--watch')) {
|
|||
await buildSrc();
|
||||
}
|
||||
|
||||
function copyLocales(): void {
|
||||
/**
|
||||
* 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く
|
||||
*/
|
||||
function clean(text: string) {
|
||||
return text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert locale YAML files to JSON during build
|
||||
* This allows runtime to avoid loading js-yaml
|
||||
*/
|
||||
function compileLocales(): void {
|
||||
const srcDir = _localesDir;
|
||||
const destDir = resolve(_dirname, 'built/locales');
|
||||
|
||||
|
|
@ -57,9 +69,12 @@ function copyLocales(): void {
|
|||
|
||||
const files = fs.readdirSync(srcDir).filter(f => f.endsWith('.yml'));
|
||||
for (const file of files) {
|
||||
fs.copyFileSync(resolve(srcDir, file), resolve(destDir, file));
|
||||
const yamlContent = clean(fs.readFileSync(resolve(srcDir, file), 'utf-8'));
|
||||
const jsonContent = yaml.load(yamlContent, { schema: yaml.JSON_SCHEMA });
|
||||
const jsonFile = file.replace(/\.yml$/, '.json');
|
||||
fs.writeFileSync(resolve(destDir, jsonFile), JSON.stringify(jsonContent), 'utf-8');
|
||||
}
|
||||
console.log(`[${_package.name}] locales copied (${files.length} files).`);
|
||||
console.log(`[${_package.name}] locales compiled to JSON (${files.length} files).`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,7 +102,7 @@ async function buildSrc(): Promise<void> {
|
|||
process.exit(1);
|
||||
});
|
||||
|
||||
copyLocales();
|
||||
compileLocales();
|
||||
await writeFrontendLocalesJson();
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
|
|
@ -123,7 +138,7 @@ async function watchSrc(): Promise<void> {
|
|||
localesWatcher.on('all', async (event, path) => {
|
||||
if (!path.endsWith('.yml')) return;
|
||||
console.log(`[${_package.name}] locales changed: ${event} ${path}`);
|
||||
copyLocales();
|
||||
compileLocales();
|
||||
await writeFrontendLocalesJson();
|
||||
await generateLocaleInterface(_localesDir);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,11 +36,9 @@
|
|||
"esbuild": "0.27.0",
|
||||
"execa": "9.6.0",
|
||||
"glob": "11.1.0",
|
||||
"js-yaml": "4.1.1",
|
||||
"nodemon": "3.1.11",
|
||||
"tsx": "4.20.6",
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": "4.1.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ function createMembers(record: LocaleRecord): ts.TypeElement[] {
|
|||
}
|
||||
|
||||
export async function generateLocaleInterface(localesDir: string): Promise<void> {
|
||||
const locale = yaml.load(fs.readFileSync(`${localesDir}/ja-JP.yml`, 'utf-8').toString()) as LocaleRecord;
|
||||
const locale = yaml.load(fs.readFileSync(`${localesDir}/ja-JP.yml`, 'utf-8').toString(), { schema: yaml.JSON_SCHEMA }) as LocaleRecord;
|
||||
const members = createMembers(locale);
|
||||
|
||||
const elements: ts.Statement[] = [
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
import * as fs from 'node:fs';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { languages, primaries } from './const.js';
|
||||
import type { Locale } from './autogen/locale.js';
|
||||
import type { ILocale, ParameterizedString } from './types.js';
|
||||
|
|
@ -35,13 +34,6 @@ function merge<T extends ILocale>(...args: (T | ILocale | undefined)[]): T {
|
|||
}), {} as ILocale) as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く
|
||||
*/
|
||||
function clean (text: string) {
|
||||
return text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 空文字列が入ることがあり、フォールバックが動作しなくなるのでプロパティごと消す
|
||||
*/
|
||||
|
|
@ -62,7 +54,7 @@ function build(): Record<Language, Locale> {
|
|||
// https://github.com/misskey-dev/misskey/pull/14057#issuecomment-2192833785
|
||||
const metaUrl = import.meta.url;
|
||||
const locales = languages.reduce<Locales>((a, lang) => {
|
||||
a[lang] = (yaml.load(clean(fs.readFileSync(new URL(`./locales/${lang}.yml`, metaUrl), 'utf-8'))) ?? {}) as ILocale;
|
||||
a[lang] = (JSON.parse(fs.readFileSync(new URL(`./locales/${lang}.json`, metaUrl), 'utf-8')) ?? {}) as ILocale;
|
||||
return a;
|
||||
}, {} as Locales);
|
||||
|
||||
|
|
|
|||
|
|
@ -267,9 +267,6 @@ importers:
|
|||
is-svg:
|
||||
specifier: 6.1.0
|
||||
version: 6.1.0
|
||||
js-yaml:
|
||||
specifier: 4.1.1
|
||||
version: 4.1.1
|
||||
json5:
|
||||
specifier: 2.2.3
|
||||
version: 2.2.3
|
||||
|
|
@ -472,9 +469,6 @@ importers:
|
|||
'@types/jest':
|
||||
specifier: 29.5.14
|
||||
version: 29.5.14
|
||||
'@types/js-yaml':
|
||||
specifier: 4.0.9
|
||||
version: 4.0.9
|
||||
'@types/jsonld':
|
||||
specifier: 1.5.15
|
||||
version: 1.5.15
|
||||
|
|
@ -1331,10 +1325,6 @@ importers:
|
|||
version: 10.2.0(eslint@9.39.1)
|
||||
|
||||
packages/i18n:
|
||||
dependencies:
|
||||
js-yaml:
|
||||
specifier: 4.1.1
|
||||
version: 4.1.1
|
||||
devDependencies:
|
||||
'@types/js-yaml':
|
||||
specifier: 4.0.9
|
||||
|
|
@ -1360,6 +1350,9 @@ importers:
|
|||
glob:
|
||||
specifier: 11.1.0
|
||||
version: 11.1.0
|
||||
js-yaml:
|
||||
specifier: 4.1.1
|
||||
version: 4.1.1
|
||||
nodemon:
|
||||
specifier: 3.1.11
|
||||
version: 3.1.11
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as fs from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import * as yaml from 'js-yaml';
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url);
|
||||
const _dirname = dirname(_filename);
|
||||
|
||||
const dir = `${_dirname}/../.config`;
|
||||
|
||||
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');
|
||||
|
||||
const configJsonPath = resolve(dir, 'config.json');
|
||||
|
||||
if (!fs.existsSync(configYmlPath)) {
|
||||
console.error(`Configuration file not found: ${configYmlPath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const yamlContent = fs.readFileSync(configYmlPath, 'utf-8');
|
||||
const config = yaml.load(yamlContent, { schema: yaml.JSON_SCHEMA });
|
||||
fs.writeFileSync(configJsonPath, JSON.stringify(config), 'utf-8');
|
||||
|
||||
console.log(`Compiled config: ${configYmlPath} -> ${configJsonPath}`);
|
||||
Loading…
Reference in New Issue