サーバー管理コマンド (#15882)
* wip * Update cli.ts * Update cli.ts * wip * Update CHANGELOG.md * Delete cli.mjs
This commit is contained in:
parent
bdfe709319
commit
b07bf838e3
|
|
@ -54,6 +54,10 @@
|
||||||
- Fix: メンションとしての条件を満たしていても、特定の条件(`-`が含まれる場合など)で正しくサジェストされない問題を一部修正
|
- Fix: メンションとしての条件を満たしていても、特定の条件(`-`が含まれる場合など)で正しくサジェストされない問題を一部修正
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
|
- Feat: サーバー管理コマンド
|
||||||
|
- `pnpm cli foo` の形式で実行可能です
|
||||||
|
- 現在以下のコマンドが利用可能です
|
||||||
|
- `reset-captcha` - CAPTCHA設定をリセットします
|
||||||
- Enhance: ノートの削除処理の効率化
|
- Enhance: ノートの削除処理の効率化
|
||||||
- Enhance: 全体的なパフォーマンスの向上
|
- Enhance: 全体的なパフォーマンスの向上
|
||||||
- Enhance: 依存ソフトウェアの更新
|
- Enhance: 依存ソフトウェアの更新
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
"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",
|
"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": "pnpm check:connect && cd packages/backend && node ./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:test": "ncp ./.github/misskey/test.yml ./.config/test.yml && cd packages/backend && cross-env NODE_ENV=test node ./built/boot/entry.js",
|
||||||
|
"cli": "cd packages/backend && pnpm cli",
|
||||||
"init": "pnpm migrate",
|
"init": "pnpm migrate",
|
||||||
"migrate": "cd packages/backend && pnpm migrate",
|
"migrate": "cd packages/backend && pnpm migrate",
|
||||||
"revert": "cd packages/backend && pnpm revert",
|
"revert": "cd packages/backend && pnpm revert",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
"start:test": "cross-env NODE_ENV=test node ./built/boot/entry.js",
|
"start:test": "cross-env NODE_ENV=test node ./built/boot/entry.js",
|
||||||
"migrate": "pnpm typeorm migration:run -d ormconfig.js",
|
"migrate": "pnpm typeorm migration:run -d ormconfig.js",
|
||||||
"revert": "pnpm typeorm migration:revert -d ormconfig.js",
|
"revert": "pnpm typeorm migration:revert -d ormconfig.js",
|
||||||
|
"cli": "node ./built/boot/cli.js",
|
||||||
"check:connect": "node ./scripts/check_connect.js",
|
"check:connect": "node ./scripts/check_connect.js",
|
||||||
"build": "swc src -d built -D --strip-leading-paths",
|
"build": "swc src -d built -D --strip-leading-paths",
|
||||||
"build:test": "swc test-server -d built-test -D --config-file test-server/.swcrc --strip-leading-paths",
|
"build:test": "swc test-server -d built-test -D --config-file test-server/.swcrc --strip-leading-paths",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import 'reflect-metadata';
|
||||||
|
import { EventEmitter } from 'node:events';
|
||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { CommandModule } from '@/cli/CommandModule.js';
|
||||||
|
import { NestLogger } from '@/NestLogger.js';
|
||||||
|
import { CommandService } from '@/cli/CommandService.js';
|
||||||
|
|
||||||
|
process.title = 'Misskey Cli';
|
||||||
|
|
||||||
|
Error.stackTraceLimit = Infinity;
|
||||||
|
EventEmitter.defaultMaxListeners = 128;
|
||||||
|
|
||||||
|
const app = await NestFactory.createApplicationContext(CommandModule, {
|
||||||
|
logger: new NestLogger(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const commandService = app.get(CommandService);
|
||||||
|
|
||||||
|
const command = process.argv[2] ?? 'help';
|
||||||
|
|
||||||
|
switch (command) {
|
||||||
|
case 'help': {
|
||||||
|
console.log('Available commands:');
|
||||||
|
console.log(' help - Displays this help message');
|
||||||
|
console.log(' reset-captcha - Resets the captcha');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'ping': {
|
||||||
|
await commandService.ping();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'reset-captcha': {
|
||||||
|
await commandService.resetCaptcha();
|
||||||
|
console.log('Captcha has been reset.');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
console.error(`Unrecognized command: ${command}`);
|
||||||
|
console.error('Use "help" to see available commands.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(0);
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CoreModule } from '@/core/CoreModule.js';
|
||||||
|
import { GlobalModule } from '@/GlobalModule.js';
|
||||||
|
import { CommandService } from './CommandService.js';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
GlobalModule,
|
||||||
|
CoreModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
CommandService,
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
CommandService,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class CommandModule {}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import type { Config } from '@/config.js';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import type Logger from '@/logger.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CommandService {
|
||||||
|
private logger: Logger;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.config)
|
||||||
|
private config: Config,
|
||||||
|
|
||||||
|
private metaService: MetaService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async ping() {
|
||||||
|
console.log('pong');
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async resetCaptcha() {
|
||||||
|
await this.metaService.update({
|
||||||
|
enableHcaptcha: false,
|
||||||
|
hcaptchaSiteKey: null,
|
||||||
|
hcaptchaSecretKey: null,
|
||||||
|
enableMcaptcha: false,
|
||||||
|
mcaptchaSitekey: null,
|
||||||
|
mcaptchaSecretKey: null,
|
||||||
|
mcaptchaInstanceUrl: null,
|
||||||
|
enableRecaptcha: false,
|
||||||
|
recaptchaSiteKey: null,
|
||||||
|
recaptchaSecretKey: null,
|
||||||
|
enableTurnstile: false,
|
||||||
|
turnstileSiteKey: null,
|
||||||
|
turnstileSecretKey: null,
|
||||||
|
enableTestcaptcha: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue