优化
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { resolve } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { parseGrayPoolArguments } from './fleet-capacity-pool-gray.mjs'
|
||||
import { privateCredentialsPath, runGrayUiFixture } from './fleet-capacity-pool-ui-fixture-test-env.mjs'
|
||||
|
||||
export function parseGrayUiFixtureArguments(args) {
|
||||
const ordinary = []; let privateFile
|
||||
for (let index = 0; index < args.length; index++) {
|
||||
if (args[index] !== '--private-credentials-file') { ordinary.push(args[index]); continue }
|
||||
if (privateFile !== undefined || !args[index + 1] || args[index + 1].startsWith('--')) throw Error('One explicit private credential file required')
|
||||
privateFile = privateCredentialsPath(args[++index])
|
||||
}
|
||||
const config = parseGrayPoolArguments(ordinary)
|
||||
if (config.execute && !privateFile) throw Error('Exclusive private credentials file required for GRAY UI execution')
|
||||
return { ...config, privateCredentialsFile: privateFile || null }
|
||||
}
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
||||
try {
|
||||
const config = parseGrayUiFixtureArguments(process.argv.slice(2)), result = await runGrayUiFixture(config)
|
||||
console.log(JSON.stringify(config.execute ? { success: result.success, fixtureReady: result.fixtureReady, environment: result.environment,
|
||||
runtimeProfile: result.runtimeProfile, fullAcceptance: false, error: result.error, summary: result.summary,
|
||||
retainedPda: result.retainedPda, output: result.output, privateCredentialsFile: result.privateCredentialsFile } : result, null, 2))
|
||||
if (config.execute && !result.success) process.exitCode = 1
|
||||
} catch { console.error('GRAY UI fixture preparation failed; preserve existing private credentials and report for review.'); process.exitCode = 1 }
|
||||
}
|
||||
Reference in New Issue
Block a user