75 lines
2.4 KiB
JavaScript
75 lines
2.4 KiB
JavaScript
import {
|
|
prepareVerifiedReleasePublication,
|
|
releaseBoundaryFail,
|
|
} from './mobile-release-evidence-lib.mjs'
|
|
|
|
function parseArguments(argv) {
|
|
const allowed = new Set([
|
|
'aab',
|
|
'apk',
|
|
'destination-dir',
|
|
'evidence',
|
|
'expected-admob-app-id',
|
|
'expected-bundletool-sha256',
|
|
'expected-commit-sha',
|
|
'expected-git-ref',
|
|
'expected-repository',
|
|
'expected-run-attempt',
|
|
'expected-run-id',
|
|
'expected-runner-identity',
|
|
'expected-tree-sha',
|
|
'expected-upload-cert-sha256',
|
|
'expected-verifier-sha256',
|
|
'expected-version-code',
|
|
'expected-version-name',
|
|
'expected-workflow-identity',
|
|
'public-key',
|
|
'source-root',
|
|
])
|
|
const result = {}
|
|
for (let index = 0; index < argv.length; index += 2) {
|
|
const flag = argv[index]
|
|
const value = argv[index + 1]
|
|
if (!flag?.startsWith('--') || !value || value.startsWith('--')) {
|
|
releaseBoundaryFail('prepare_publication_arguments_invalid')
|
|
}
|
|
const name = flag.slice(2)
|
|
if (!allowed.has(name) || Object.hasOwn(result, name)) {
|
|
releaseBoundaryFail(`prepare_publication_argument_rejected_${name}`)
|
|
}
|
|
result[name] = value
|
|
}
|
|
for (const name of allowed) {
|
|
if (!result[name]) releaseBoundaryFail(`prepare_publication_argument_missing_${name}`)
|
|
}
|
|
return result
|
|
}
|
|
|
|
const options = parseArguments(process.argv.slice(2))
|
|
const result = prepareVerifiedReleasePublication({
|
|
sourceRoot: options['source-root'],
|
|
apkPath: options.apk,
|
|
aabPath: options.aab,
|
|
evidencePath: options.evidence,
|
|
publicKeyPath: options['public-key'],
|
|
destinationDirectory: options['destination-dir'],
|
|
expected: {
|
|
versionName: options['expected-version-name'],
|
|
versionCode: options['expected-version-code'],
|
|
adMobAppId: options['expected-admob-app-id'],
|
|
signerSha256: options['expected-upload-cert-sha256'],
|
|
provenance: {
|
|
repository: options['expected-repository'],
|
|
commitSha: options['expected-commit-sha'],
|
|
treeSha: options['expected-tree-sha'],
|
|
gitRef: options['expected-git-ref'],
|
|
workflowIdentity: options['expected-workflow-identity'],
|
|
runId: options['expected-run-id'],
|
|
runAttempt: options['expected-run-attempt'],
|
|
runnerIdentity: options['expected-runner-identity'],
|
|
verifierSha256: options['expected-verifier-sha256'],
|
|
bundletoolSha256: options['expected-bundletool-sha256'],
|
|
},
|
|
},
|
|
})
|
|
process.stdout.write(`${JSON.stringify({ ok: true, ...result })}\n`)
|