🌳
pt0/deployF/cliF/buildScopeCmdHelpAI.mts
1import * as _ from 'lodash-es'
5export const buildScopeCmdHelp = ({actionName, cliDescript, scriptPath}: {
6 actionName: string, cliDescript: Record<string, unknown> | undefined, scriptPath: string,
7}) => {
8 const explainStr = (cliDescript?.cliExplain || '') as string
9 const defaultOpt = (cliDescript?.cliDefaultOpt || epScopes.deployjs) as string
11 const description = explainStr && !explainStr.startsWith('[')
12 ? explainStr
13 : `Run ${actionName} on entrypoints`
15 const cmd = `node ${scriptPath} ${actionName}`
16 let examples: string
17 if (actionName === 'howimports') {
18 examples = ` # Show how deploy entrypoints import a file (default)
19 ${cmd} path/to/file.mjs
21 # Show how all entrypoints import a file
22 ${cmd} path/to/file.mjs --${epScopeKey}=${epScopes.alljs}
24 # Show how docker-only entrypoints import a file
25 ${cmd} path/to/file.mjs --${epScopeKey}=${epScopes.dockerjs}`
26 } else if (actionName === 'diff' || actionName === 'gitlog') {
27 const verb = actionName === 'gitlog' ? 'git log' : 'diff'
28 examples = ` # ${verb} from deployed git sha to HEAD (default)
29 ${cmd}
31 # ${verb} specific range
32 ${cmd} a1b2c3d..HEAD~1
34 # ${verb} only docker entrypoints
35 ${cmd} --${epScopeKey}=${epScopes.dockerjs}`
36 } else {
37 examples = ` # Run with default scope (${defaultOpt})
38 ${cmd}
40 # Run on all entrypoints
41 ${cmd} --${epScopeKey}=${epScopes.alljs}
43 # Run on docker entrypoints only
44 ${cmd} --${epScopeKey}=${epScopes.dockerjs}`
45 }
47 const cliOptA = _.isFunction(cliDescript?.cliOptA) ? (cliDescript!.cliOptA as () => string[])() : cliDescript?.cliOptA as string[] | undefined
48 const optsStr = (cliOptA || getEpScopeOptA()).join(' | ')
50 return `${description}
52Examples:
53${examples}
55Options:
56 --${epScopeKey} ${optsStr} (default: ${defaultOpt})