22const parseStepsArg = () => { 23 const stepsArg = getProcArgv().find(a => a.startsWith('--steps=')) 24 return stepsArg ? stepsArg.slice(8).split(',') : null 27export const eptClusterSync = async ({importMetaUrl, steps, extraActionsH, ...klusterCfg}: {importMetaUrl: importMetaUrlType, steps: Record<string, () => Promise<unknown>>, extraActionsH?: Record<string, (...a: any[]) => any>, cluster_name: string, [k: string]: unknown}) => { 28 importMetaUrlCtx.enterWith({importMetaUrl}) // ctx:clear 32 availActionsCtx.enterWith({...availActionsCtx.getStore(), ...extraActionsH}) 35 if (klusterCfg.cfApiKeySecretName) { 36 availActionsCtx.enterWith({...availActionsCtx.getStore(), overwriteextdnsowner, listcfdnsrecords, cfensuressl, ensurewcdnsrecords}) 40 const stepNames = Object.keys(steps) 41 const requestedSteps = parseStepsArg() ?? (action === 'delete' || action === 'help' ? null : stepNames) 44 if (action === 'runtests') { 46 allSuites: ['clitests'], 47 localAppCfg: {importMetaUrl}, 48 suiteConfigs: [{name: 'clitests', runner: runClusterCliTestsSuite, deps: []}], 55 // help --steps=X shows step-specific help, help alone lists steps 56 if (action === 'help') { 57 if (!requestedSteps) { 59 console.log(`[action] --steps=step1,step2\n\nAvailable steps: ${stepNames.join(', ')}`) 62 const invalidSteps = requestedSteps.filter(s => !steps[s]) 63 if (invalidSteps.length) { 64 throPtErr('unknown steps', {invalidSteps, available: stepNames}) 66 for (const name of requestedSteps) { 67 console.log(`\n--- ${name} ---`) 73 const coreActions = ['apply', 'delete', 'info', 'help', 'runtests'] 74 const isCustomAction = !coreActions.includes(action) 77 const customActionsH = availActionsCtx.getStore() || {} 78 const customAction = customActionsH[action] 81 cliValidatedCtx.enterWith({validated: true}) // ctx:clear 82 if (typeof customAction === 'function') await customAction() 87 exitOnUnknownArgs({cliSchema: {steps: {}, ...applyCli}, cliAcceptsPositional: isCustomAction}) 89 cliValidatedCtx.enterWith({validated: true}) // ctx:clear 91 if (!requestedSteps) { 92 console.log(`Usage: ${ptnodeBin} ${epPath} ${action} --steps=step1,step2`) 93 console.log(`Available: ${stepNames.join(', ')}`) 97 const invalidSteps = requestedSteps.filter(s => !steps[s]) 98 if (invalidSteps.length) { 99 throPtErr('unknown steps', {invalidSteps, available: stepNames}) 102 for (const [name, fn] of Object.entries(steps)) { 103 if (requestedSteps.includes(name)) { 104 console.log(`\n--- ${name} ---`)