From 29a0eee85445b52da4c5e88d2825bd0113213c27 Mon Sep 17 00:00:00 2001 From: chick Date: Mon, 7 Sep 2026 01:59:24 +0800 Subject: [PATCH] style: apply prettier to the repo's declared format surface --- .../connections/instance-credential-resolver.ts | 4 ++-- .../notifications/central-notification-service.ts | 2 +- .../application/system/console-update-service.test.ts | 5 ++++- .../api/src/application/system/console-update-service.ts | 6 +++++- apps/api/src/infrastructure/database/backup.test.ts | 3 +-- apps/api/src/infrastructure/database/database.test.ts | 3 +-- .../src/infrastructure/secrets/keychain-secret-store.ts | 6 +----- .../src/infrastructure/secrets/secret-backend.test.ts | 9 ++++++--- apps/api/src/infrastructure/secrets/secret-reference.ts | 6 +++--- apps/api/src/production-control-plane.ts | 6 +++++- apps/api/src/production-gateway.test.ts | 3 +-- 11 files changed, 30 insertions(+), 23 deletions(-) diff --git a/apps/api/src/application/connections/instance-credential-resolver.ts b/apps/api/src/application/connections/instance-credential-resolver.ts index 1d7108e..af34118 100644 --- a/apps/api/src/application/connections/instance-credential-resolver.ts +++ b/apps/api/src/application/connections/instance-credential-resolver.ts @@ -24,8 +24,8 @@ export class InstanceCredentialResolver { 'SELECT external_reference FROM secret_references WHERE instance_id=? AND purpose=? AND provider=?', ) .get(instanceId, PURPOSE, this.options.store.provider) as - | { external_reference: string } - | undefined; + | { external_reference: string } + | undefined; if (!row) throw new CredentialResolverError('CREDENTIAL_UNAVAILABLE'); try { const parsed = parseSecretReference(row.external_reference); diff --git a/apps/api/src/application/notifications/central-notification-service.ts b/apps/api/src/application/notifications/central-notification-service.ts index 174a570..6ff9d1e 100644 --- a/apps/api/src/application/notifications/central-notification-service.ts +++ b/apps/api/src/application/notifications/central-notification-service.ts @@ -1232,7 +1232,7 @@ export class CentralNotificationService { SET status='pending',updated_at=? WHERE status='sending'`, ) - .run(this.#now(), ).changes, + .run(this.#now()).changes, ); } diff --git a/apps/api/src/application/system/console-update-service.test.ts b/apps/api/src/application/system/console-update-service.test.ts index 5388c6a..f81255a 100644 --- a/apps/api/src/application/system/console-update-service.test.ts +++ b/apps/api/src/application/system/console-update-service.test.ts @@ -499,7 +499,10 @@ describe('createSystemdRestartLauncher', () => { it('supports the system scope and surfaces systemctl failures', async () => { const calls: string[][] = []; const launcher = createSystemdRestartLauncher({ - env: { MULTI_SIMADMIN_SYSTEMD_UNIT: 'multi-simadmin-api.service', MULTI_SIMADMIN_SYSTEMD_SCOPE: 'system' }, + env: { + MULTI_SIMADMIN_SYSTEMD_UNIT: 'multi-simadmin-api.service', + MULTI_SIMADMIN_SYSTEMD_SCOPE: 'system', + }, runner: { run: async (command, args) => { calls.push([command, ...args]); diff --git a/apps/api/src/application/system/console-update-service.ts b/apps/api/src/application/system/console-update-service.ts index 20ac80e..4578e7d 100644 --- a/apps/api/src/application/system/console-update-service.ts +++ b/apps/api/src/application/system/console-update-service.ts @@ -258,7 +258,11 @@ export function createSystemdRestartLauncher(input: { supported, async restart() { if (!supported) - throw new UpdateError('NOT_SUPPORTED', '未配置 systemd 服务单元(MULTI_SIMADMIN_SYSTEMD_UNIT)。', 501); + throw new UpdateError( + 'NOT_SUPPORTED', + '未配置 systemd 服务单元(MULTI_SIMADMIN_SYSTEMD_UNIT)。', + 501, + ); const result = await input.runner.run('systemctl', [scope, 'restart', unit]); if (result.code !== 0) throw new UpdateError( diff --git a/apps/api/src/infrastructure/database/backup.test.ts b/apps/api/src/infrastructure/database/backup.test.ts index ae3dd4d..1e3946f 100644 --- a/apps/api/src/infrastructure/database/backup.test.ts +++ b/apps/api/src/infrastructure/database/backup.test.ts @@ -48,8 +48,7 @@ describe('verified backup, restore, and rollback foundation', () => { ]); copy.close(); expect(snapshot.sha256).toMatch(/^[a-f0-9]{64}$/); - if (process.platform !== 'win32') - expect((await stat(backupPath)).mode & 0o777).toBe(0o600); + if (process.platform !== 'win32') expect((await stat(backupPath)).mode & 0o777).toBe(0o600); }); // Activation renames a WAL file that a live connection still holds open; diff --git a/apps/api/src/infrastructure/database/database.test.ts b/apps/api/src/infrastructure/database/database.test.ts index 8da5db3..fdfc2fd 100644 --- a/apps/api/src/infrastructure/database/database.test.ts +++ b/apps/api/src/infrastructure/database/database.test.ts @@ -363,8 +363,7 @@ describe('database backup and restore', () => { const backupPath = join(directory, 'backup.sqlite'); await backupDatabase(database, backupPath); // Windows keeps no POSIX mode bits; the 0600 guarantee is POSIX-only. - if (process.platform !== 'win32') - expect((await lstat(backupPath)).mode & 0o777).toBe(0o600); + if (process.platform !== 'win32') expect((await lstat(backupPath)).mode & 0o777).toBe(0o600); database.close(); }); diff --git a/apps/api/src/infrastructure/secrets/keychain-secret-store.ts b/apps/api/src/infrastructure/secrets/keychain-secret-store.ts index f957a0a..3da20ee 100644 --- a/apps/api/src/infrastructure/secrets/keychain-secret-store.ts +++ b/apps/api/src/infrastructure/secrets/keychain-secret-store.ts @@ -1,9 +1,5 @@ import { spawn } from 'node:child_process'; -import { - accountFor, - parseSecretAccount, - SecretReferenceError, -} from './secret-reference.js'; +import { accountFor, parseSecretAccount, SecretReferenceError } from './secret-reference.js'; import type { SecretKey, SecretStore } from './secret-store.js'; const SECURITY_PATH = '/usr/bin/security'; diff --git a/apps/api/src/infrastructure/secrets/secret-backend.test.ts b/apps/api/src/infrastructure/secrets/secret-backend.test.ts index f6ff24e..b1ace82 100644 --- a/apps/api/src/infrastructure/secrets/secret-backend.test.ts +++ b/apps/api/src/infrastructure/secrets/secret-backend.test.ts @@ -62,8 +62,7 @@ describe('FileSecretStore', () => { const path = join(directory, 'nested', 'secrets.json'); const store = new FileSecretStore(path); const reference = await store.set({ instanceId: 'x', purpose: 'p', slot: 's' }, 'secret'); - if (process.platform !== 'win32') - expect((await stat(path)).mode & 0o777).toBe(0o600); + if (process.platform !== 'win32') expect((await stat(path)).mode & 0o777).toBe(0o600); expect(await readdir(join(directory, 'nested'))).toEqual(['secrets.json']); const raw = await readFile(path, 'utf8'); expect(JSON.parse(raw)).toEqual({ @@ -126,7 +125,11 @@ describe('secret backend selection', () => { it('builds the matching store and refuses keychain off macOS', () => { const directory = join(tmpdir(), 'msa-backend-selection'); expect( - createDefaultSecretStore({ env: {}, secretFilePath: join(directory, 's.json'), platform: 'linux' }), + createDefaultSecretStore({ + env: {}, + secretFilePath: join(directory, 's.json'), + platform: 'linux', + }), ).toBeInstanceOf(FileSecretStore); expect( createDefaultSecretStore({ diff --git a/apps/api/src/infrastructure/secrets/secret-reference.ts b/apps/api/src/infrastructure/secrets/secret-reference.ts index f42eafd..e32afe9 100644 --- a/apps/api/src/infrastructure/secrets/secret-reference.ts +++ b/apps/api/src/infrastructure/secrets/secret-reference.ts @@ -97,8 +97,8 @@ export function parseSecretReference(reference: string): ParsedSecretReference { if (!match?.[1] || !match[2]) throw new SecretReferenceError('INVALID_REFERENCE', 'Secret reference is invalid'); const scheme = match[1]; - const provider = scheme === 'keychain' ? 'macos-keychain' : scheme === 'secret-file' ? 'secret-file' : undefined; - if (!provider) - throw new SecretReferenceError('INVALID_REFERENCE', 'Secret reference is invalid'); + const provider = + scheme === 'keychain' ? 'macos-keychain' : scheme === 'secret-file' ? 'secret-file' : undefined; + if (!provider) throw new SecretReferenceError('INVALID_REFERENCE', 'Secret reference is invalid'); return parseSecretAccount(match[2], provider); } diff --git a/apps/api/src/production-control-plane.ts b/apps/api/src/production-control-plane.ts index 1b3ec3a..1c74fe1 100644 --- a/apps/api/src/production-control-plane.ts +++ b/apps/api/src/production-control-plane.ts @@ -10,7 +10,11 @@ import { } from './application/system/console-update-service.js'; import { openDatabase } from './infrastructure/database/database.js'; import { migrateDatabase } from './infrastructure/database/migrations.js'; -import { createDefaultSecretStore, resolveSecretBackend, defaultSecretFileMetadataCheck } from './infrastructure/secrets/secret-backend.js'; +import { + createDefaultSecretStore, + resolveSecretBackend, + defaultSecretFileMetadataCheck, +} from './infrastructure/secrets/secret-backend.js'; import type { SecretStore } from './infrastructure/secrets/secret-store.js'; import { createProductionUpstream } from './infrastructure/transport/production-upstream.js'; import { createProductionReadiness, defaultKeychainMetadataCheck } from './production-readiness.js'; diff --git a/apps/api/src/production-gateway.test.ts b/apps/api/src/production-gateway.test.ts index b9e46c6..5e43a69 100644 --- a/apps/api/src/production-gateway.test.ts +++ b/apps/api/src/production-gateway.test.ts @@ -130,8 +130,7 @@ describe('cutover validation and reversible orchestration', () => { expect(signals).toEqual([41]); expect(starts[0]?.environment?.MULTI_SIMADMIN_GATEWAY_TOKEN).toBe(token); const statePath = join(plan.stateDir, 'cutover-state.json'); - if (process.platform !== 'win32') - expect((await lstat(statePath)).mode & 0o777).toBe(0o600); + if (process.platform !== 'win32') expect((await lstat(statePath)).mode & 0o777).toBe(0o600); expect(await readFile(statePath, 'utf8')).not.toContain(token); expect(await rollback(plan, system)).toBe(43); expect(signals).toEqual([41, 42]);