🌳
pt0/deployF/ptDeployActions/zipsecretsActionAI.mts
12export const doZipSecrets = async ({secretNameA, name = 'pt', zipPassword}: {
13 secretNameA: string[], name?: string, zipPassword?: string,
14}) => {
15 const secretPaths = secretNameA.map(secretName => pathDownJoin(secretsRelDir, secretName))
16 const zipName = pathDownJoin(ptDir, `${[name, 'secrets'].filter(Boolean).join('_')}.zip`)
17 console.log(`zipping ${secretNameA.length} secret(s) -> ${zipName}:`, secretNameA)
18 const pwArg = zipPassword ? `-P '${zipPassword}'` : ''
19 await execAsyncR(`zip ${zipName} ${pwArg} -j ${secretPaths.join(' ')}`)
22export const zipsecrets: PtAction = async () => {
23 const {secretNames, name} = getReqAppCfg()
24 assertDefined(secretNames, {name})
25 const requestedA = getProcArgv().slice(3).filter(a => !a.startsWith('-'))
26 const invalidA = requestedA.filter(s => !secretNames.includes(s))
27 throwIf(() => invalidA.length > 0, {invalidA, secretNames})
28 const zipPassword = process.env.ZIP_PASSWORD ?? await doPrompt('ZIP_PASSWORD (blank for no password): ')
29 await doZipSecrets({secretNameA: requestedA.length ? requestedA : secretNames, name, zipPassword})
31zipsecrets.cliSchema = {}
32zipsecrets.cliAcceptsPositional = true
33zipsecrets.cliDescript = `zip all ref'd secretNames for distribution to another dev (optional: list specific secrets to include only those)`