style: apply prettier to the repo's declared format surface

This commit is contained in:
chick
2026-09-07 01:59:24 +08:00
parent 2977f75129
commit 29a0eee854
11 changed files with 30 additions and 23 deletions
@@ -1232,7 +1232,7 @@ export class CentralNotificationService {
SET status='pending',updated_at=? SET status='pending',updated_at=?
WHERE status='sending'`, WHERE status='sending'`,
) )
.run(this.#now(), ).changes, .run(this.#now()).changes,
); );
} }
@@ -499,7 +499,10 @@ describe('createSystemdRestartLauncher', () => {
it('supports the system scope and surfaces systemctl failures', async () => { it('supports the system scope and surfaces systemctl failures', async () => {
const calls: string[][] = []; const calls: string[][] = [];
const launcher = createSystemdRestartLauncher({ 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: { runner: {
run: async (command, args) => { run: async (command, args) => {
calls.push([command, ...args]); calls.push([command, ...args]);
@@ -258,7 +258,11 @@ export function createSystemdRestartLauncher(input: {
supported, supported,
async restart() { async restart() {
if (!supported) 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]); const result = await input.runner.run('systemctl', [scope, 'restart', unit]);
if (result.code !== 0) if (result.code !== 0)
throw new UpdateError( throw new UpdateError(
@@ -48,8 +48,7 @@ describe('verified backup, restore, and rollback foundation', () => {
]); ]);
copy.close(); copy.close();
expect(snapshot.sha256).toMatch(/^[a-f0-9]{64}$/); expect(snapshot.sha256).toMatch(/^[a-f0-9]{64}$/);
if (process.platform !== 'win32') if (process.platform !== 'win32') expect((await stat(backupPath)).mode & 0o777).toBe(0o600);
expect((await stat(backupPath)).mode & 0o777).toBe(0o600);
}); });
// Activation renames a WAL file that a live connection still holds open; // Activation renames a WAL file that a live connection still holds open;
@@ -363,8 +363,7 @@ describe('database backup and restore', () => {
const backupPath = join(directory, 'backup.sqlite'); const backupPath = join(directory, 'backup.sqlite');
await backupDatabase(database, backupPath); await backupDatabase(database, backupPath);
// Windows keeps no POSIX mode bits; the 0600 guarantee is POSIX-only. // Windows keeps no POSIX mode bits; the 0600 guarantee is POSIX-only.
if (process.platform !== 'win32') if (process.platform !== 'win32') expect((await lstat(backupPath)).mode & 0o777).toBe(0o600);
expect((await lstat(backupPath)).mode & 0o777).toBe(0o600);
database.close(); database.close();
}); });
@@ -1,9 +1,5 @@
import { spawn } from 'node:child_process'; import { spawn } from 'node:child_process';
import { import { accountFor, parseSecretAccount, SecretReferenceError } from './secret-reference.js';
accountFor,
parseSecretAccount,
SecretReferenceError,
} from './secret-reference.js';
import type { SecretKey, SecretStore } from './secret-store.js'; import type { SecretKey, SecretStore } from './secret-store.js';
const SECURITY_PATH = '/usr/bin/security'; const SECURITY_PATH = '/usr/bin/security';
@@ -62,8 +62,7 @@ describe('FileSecretStore', () => {
const path = join(directory, 'nested', 'secrets.json'); const path = join(directory, 'nested', 'secrets.json');
const store = new FileSecretStore(path); const store = new FileSecretStore(path);
const reference = await store.set({ instanceId: 'x', purpose: 'p', slot: 's' }, 'secret'); const reference = await store.set({ instanceId: 'x', purpose: 'p', slot: 's' }, 'secret');
if (process.platform !== 'win32') if (process.platform !== 'win32') expect((await stat(path)).mode & 0o777).toBe(0o600);
expect((await stat(path)).mode & 0o777).toBe(0o600);
expect(await readdir(join(directory, 'nested'))).toEqual(['secrets.json']); expect(await readdir(join(directory, 'nested'))).toEqual(['secrets.json']);
const raw = await readFile(path, 'utf8'); const raw = await readFile(path, 'utf8');
expect(JSON.parse(raw)).toEqual({ expect(JSON.parse(raw)).toEqual({
@@ -126,7 +125,11 @@ describe('secret backend selection', () => {
it('builds the matching store and refuses keychain off macOS', () => { it('builds the matching store and refuses keychain off macOS', () => {
const directory = join(tmpdir(), 'msa-backend-selection'); const directory = join(tmpdir(), 'msa-backend-selection');
expect( expect(
createDefaultSecretStore({ env: {}, secretFilePath: join(directory, 's.json'), platform: 'linux' }), createDefaultSecretStore({
env: {},
secretFilePath: join(directory, 's.json'),
platform: 'linux',
}),
).toBeInstanceOf(FileSecretStore); ).toBeInstanceOf(FileSecretStore);
expect( expect(
createDefaultSecretStore({ createDefaultSecretStore({
@@ -97,8 +97,8 @@ export function parseSecretReference(reference: string): ParsedSecretReference {
if (!match?.[1] || !match[2]) if (!match?.[1] || !match[2])
throw new SecretReferenceError('INVALID_REFERENCE', 'Secret reference is invalid'); throw new SecretReferenceError('INVALID_REFERENCE', 'Secret reference is invalid');
const scheme = match[1]; const scheme = match[1];
const provider = scheme === 'keychain' ? 'macos-keychain' : scheme === 'secret-file' ? 'secret-file' : undefined; const provider =
if (!provider) scheme === 'keychain' ? 'macos-keychain' : scheme === 'secret-file' ? 'secret-file' : undefined;
throw new SecretReferenceError('INVALID_REFERENCE', 'Secret reference is invalid'); if (!provider) throw new SecretReferenceError('INVALID_REFERENCE', 'Secret reference is invalid');
return parseSecretAccount(match[2], provider); return parseSecretAccount(match[2], provider);
} }
+5 -1
View File
@@ -10,7 +10,11 @@ import {
} from './application/system/console-update-service.js'; } from './application/system/console-update-service.js';
import { openDatabase } from './infrastructure/database/database.js'; import { openDatabase } from './infrastructure/database/database.js';
import { migrateDatabase } from './infrastructure/database/migrations.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 type { SecretStore } from './infrastructure/secrets/secret-store.js';
import { createProductionUpstream } from './infrastructure/transport/production-upstream.js'; import { createProductionUpstream } from './infrastructure/transport/production-upstream.js';
import { createProductionReadiness, defaultKeychainMetadataCheck } from './production-readiness.js'; import { createProductionReadiness, defaultKeychainMetadataCheck } from './production-readiness.js';
+1 -2
View File
@@ -130,8 +130,7 @@ describe('cutover validation and reversible orchestration', () => {
expect(signals).toEqual([41]); expect(signals).toEqual([41]);
expect(starts[0]?.environment?.MULTI_SIMADMIN_GATEWAY_TOKEN).toBe(token); expect(starts[0]?.environment?.MULTI_SIMADMIN_GATEWAY_TOKEN).toBe(token);
const statePath = join(plan.stateDir, 'cutover-state.json'); const statePath = join(plan.stateDir, 'cutover-state.json');
if (process.platform !== 'win32') if (process.platform !== 'win32') expect((await lstat(statePath)).mode & 0o777).toBe(0o600);
expect((await lstat(statePath)).mode & 0o777).toBe(0o600);
expect(await readFile(statePath, 'utf8')).not.toContain(token); expect(await readFile(statePath, 'utf8')).not.toContain(token);
expect(await rollback(plan, system)).toBe(43); expect(await rollback(plan, system)).toBe(43);
expect(signals).toEqual([41, 42]); expect(signals).toEqual([41, 42]);