071faa482c
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口 完成项目 TypeScript/Prettier 与 Rust 全量格式化 修复 Pingora expected executable 门禁的空白敏感误报 同步开发运维文档与 AGC skill pack 格式化忽略规则
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import {
|
|
callSpacetimeProcedure,
|
|
callSpacetimeProcedureViaCli,
|
|
ensureProcedureOk,
|
|
parseArgs,
|
|
resolveBootstrapSecret,
|
|
} from './spacetime-migration-common.mjs';
|
|
|
|
try {
|
|
const options = parseArgs(process.argv.slice(2));
|
|
if (!options.operatorIdentity) {
|
|
throw new Error('必须传入 --operator-identity。');
|
|
}
|
|
|
|
const input = {
|
|
bootstrap_secret: await resolveBootstrapSecret(options),
|
|
operator_identity_hex: options.operatorIdentity,
|
|
note: options.note || '',
|
|
};
|
|
if (options.useHttp && !options.token) {
|
|
throw new Error('--use-http 需要同时传入 --token。');
|
|
}
|
|
const result = options.useHttp
|
|
? await callSpacetimeProcedure(
|
|
options,
|
|
'authorize_database_migration_operator',
|
|
input,
|
|
)
|
|
: await callSpacetimeProcedureViaCli(
|
|
options,
|
|
'authorize_database_migration_operator',
|
|
input,
|
|
);
|
|
ensureProcedureOk(result);
|
|
|
|
console.log(
|
|
`[spacetime:migration:operator] 已授权 ${result.operator_identity_hex ?? options.operatorIdentity}`,
|
|
);
|
|
} catch (error) {
|
|
console.error(
|
|
`[spacetime:migration:operator] ${error instanceof Error ? error.message : String(error)}`,
|
|
);
|
|
process.exit(1);
|
|
}
|