@catladder/cli 0.0.0-new-cli-52525b58 → 0.0.0-new-cli-51a5f8b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/catenv/index.js +103 -66
- package/dist/bundles/cli/index.js +43454 -43373
- package/dist/cli/src/adapters/baseContext.d.ts +2 -2
- package/dist/cli/src/adapters/baseContext.js +10 -1
- package/dist/cli/src/adapters/baseContext.js.map +1 -1
- package/dist/cli/src/catenv.js +4 -3
- package/dist/cli/src/catenv.js.map +1 -1
- package/dist/cli/src/cli.js +3 -3
- package/dist/cli/src/cli.js.map +1 -1
- package/dist/cli/src/commands/cloudSQL/commandRestoreDb.d.ts +2 -2
- package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js +9 -9
- package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js.map +1 -1
- package/dist/cli/src/commands/project/commandConfigSecrets.d.ts +1 -0
- package/dist/cli/src/commands/project/commandConfigSecrets.js +1 -0
- package/dist/cli/src/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/cli/src/commands/project/commandSetup.d.ts +1 -0
- package/dist/cli/src/commands/project/commandSetup.js +2 -1
- package/dist/cli/src/commands/project/commandSetup.js.map +1 -1
- package/dist/cli/src/completion.d.ts +2 -2
- package/dist/cli/src/completion.js +40 -6
- package/dist/cli/src/completion.js.map +1 -1
- package/dist/cli/src/core/types.d.ts +7 -2
- package/dist/cli/src/core/types.js.map +1 -1
- package/dist/pipeline/src/build/index.d.ts +2 -2
- package/dist/pipeline/src/build/index.js.map +1 -1
- package/dist/pipeline/src/build/node/buildJob.d.ts +3 -3
- package/dist/pipeline/src/build/node/buildJob.js +13 -12
- package/dist/pipeline/src/build/node/buildJob.js.map +1 -1
- package/dist/pipeline/src/build/node/cache.d.ts +3 -3
- package/dist/pipeline/src/build/node/cache.js +12 -9
- package/dist/pipeline/src/build/node/cache.js.map +1 -1
- package/dist/pipeline/src/build/node/index.d.ts +3 -3
- package/dist/pipeline/src/build/node/index.js +8 -6
- package/dist/pipeline/src/build/node/index.js.map +1 -1
- package/dist/pipeline/src/build/node/meteor.d.ts +1 -1
- package/dist/pipeline/src/build/node/meteor.js +8 -7
- package/dist/pipeline/src/build/node/meteor.js.map +1 -1
- package/dist/pipeline/src/build/node/testJob.d.ts +1 -1
- package/dist/pipeline/src/build/node/testJob.js +5 -5
- package/dist/pipeline/src/build/node/testJob.js.map +1 -1
- package/dist/pipeline/src/build/node/yarn.d.ts +2 -2
- package/dist/pipeline/src/build/node/yarn.js +10 -8
- package/dist/pipeline/src/build/node/yarn.js.map +1 -1
- package/dist/pipeline/src/constants.js +1 -1
- package/dist/pipeline/src/context/createComponentContext.js +3 -3
- package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
- package/dist/pipeline/src/context/createWorkspaceContext.js +1 -1
- package/dist/pipeline/src/context/createWorkspaceContext.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
- package/dist/pipeline/src/deploy/custom/deployJob.d.ts +1 -1
- package/dist/pipeline/src/deploy/custom/deployJob.js +2 -2
- package/dist/pipeline/src/deploy/custom/deployJob.js.map +1 -1
- package/dist/pipeline/src/deploy/index.d.ts +1 -1
- package/dist/pipeline/src/pipeline/createAllJobs.js +4 -4
- package/dist/pipeline/src/pipeline/createAllJobs.js.map +1 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.d.ts +1 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.js +2 -3
- package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
- package/dist/pipeline/src/pipeline/createJobsForWorkspace.d.ts +1 -1
- package/dist/pipeline/src/pipeline/createJobsForWorkspace.js +2 -2
- package/dist/pipeline/src/pipeline/createJobsForWorkspace.js.map +1 -1
- package/dist/pipeline/src/types/context.d.ts +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/adapters/baseContext.ts +15 -2
- package/src/catenv.ts +15 -8
- package/src/cli.ts +7 -2
- package/src/commands/cloudSQL/commandRestoreDb.ts +9 -9
- package/src/commands/project/commandConfigSecrets.ts +1 -0
- package/src/commands/project/commandSetup.ts +6 -1
- package/src/completion.ts +43 -6
- package/src/core/types.ts +8 -2
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
InputDef,
|
|
5
5
|
InputResultType,
|
|
6
6
|
InputsSchema,
|
|
7
|
+
OptionalInput,
|
|
7
8
|
} from "../core/types";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -32,7 +33,7 @@ export abstract class BaseContext<TInputs extends InputsSchema>
|
|
|
32
33
|
|
|
33
34
|
get<K extends keyof TInputs & string>(
|
|
34
35
|
name: K,
|
|
35
|
-
): Promise<
|
|
36
|
+
): Promise<OptionalInput<TInputs[K]>> {
|
|
36
37
|
if (!this.cache.has(name)) {
|
|
37
38
|
const spec = this.command.inputs[name];
|
|
38
39
|
if (!spec) {
|
|
@@ -42,7 +43,19 @@ export abstract class BaseContext<TInputs extends InputsSchema>
|
|
|
42
43
|
),
|
|
43
44
|
);
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
// For optional inputs (required: false), catch MissingInputError
|
|
47
|
+
// and return undefined instead of prompting
|
|
48
|
+
if (spec.required === false) {
|
|
49
|
+
this.cache.set(
|
|
50
|
+
name,
|
|
51
|
+
this.resolveInput(name, spec).catch((err) => {
|
|
52
|
+
if (err?.name === "MissingInputError") return undefined;
|
|
53
|
+
throw err;
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
this.cache.set(name, this.resolveInput(name, spec));
|
|
58
|
+
}
|
|
46
59
|
}
|
|
47
60
|
return this.cache.get(name)!;
|
|
48
61
|
}
|
package/src/catenv.ts
CHANGED
|
@@ -11,13 +11,20 @@ program
|
|
|
11
11
|
.version(packageInfos.version)
|
|
12
12
|
.argument("[envComponent]", "env or env:component")
|
|
13
13
|
.option("-v, --verbose", "verbose output")
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
.option("-p, --print-variables", "print variables")
|
|
15
|
+
.action(
|
|
16
|
+
(
|
|
17
|
+
envComponent: string | undefined,
|
|
18
|
+
opts: { verbose?: boolean; printVariables?: boolean },
|
|
19
|
+
) => {
|
|
20
|
+
catenv(envComponent ? parseChoice(envComponent) : null, {
|
|
21
|
+
verbose: opts.verbose ?? false,
|
|
22
|
+
printVariables: opts.printVariables ?? false,
|
|
23
|
+
}).then(() => {
|
|
24
|
+
// we have to exit manually, because we have some file watches
|
|
25
|
+
process.exit();
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
);
|
|
22
29
|
|
|
23
30
|
program.parse();
|
package/src/cli.ts
CHANGED
|
@@ -188,8 +188,13 @@ const completionCmd = program
|
|
|
188
188
|
completionCmd
|
|
189
189
|
.command("zsh")
|
|
190
190
|
.description("output zsh completion script")
|
|
191
|
-
.
|
|
192
|
-
|
|
191
|
+
.option(
|
|
192
|
+
"--command <cmd>",
|
|
193
|
+
"command used to invoke the CLI (e.g. 'yarn catladder')",
|
|
194
|
+
)
|
|
195
|
+
.action((opts: { command?: string }) => {
|
|
196
|
+
const binaryName =
|
|
197
|
+
opts.command ?? process.argv[1].split("/").pop() ?? "catladder";
|
|
193
198
|
console.log(generateZshCompletionScript(binaryName));
|
|
194
199
|
});
|
|
195
200
|
|
|
@@ -8,7 +8,7 @@ export const commandRestoreDb = defineCommand({
|
|
|
8
8
|
description: "restore a db from one source to another target",
|
|
9
9
|
group: "cloudSQL",
|
|
10
10
|
inputs: {
|
|
11
|
-
|
|
11
|
+
source: {
|
|
12
12
|
type: "string",
|
|
13
13
|
message: "Source instance (connection string or 'local')? 🤔 ",
|
|
14
14
|
},
|
|
@@ -24,7 +24,7 @@ export const commandRestoreDb = defineCommand({
|
|
|
24
24
|
},
|
|
25
25
|
sourcePassword: { type: "string", message: "Source Password? 🤔 " },
|
|
26
26
|
sourceDbName: { type: "string", message: "Source DB name? 🤔 " },
|
|
27
|
-
|
|
27
|
+
target: {
|
|
28
28
|
type: "string",
|
|
29
29
|
message: "Target INSTANCE (connection string or 'local')? 🤔 ",
|
|
30
30
|
},
|
|
@@ -42,19 +42,19 @@ export const commandRestoreDb = defineCommand({
|
|
|
42
42
|
targetDbName: { type: "string", message: "Target DB name? 🤔 " },
|
|
43
43
|
},
|
|
44
44
|
execute: async (ctx) => {
|
|
45
|
-
const
|
|
45
|
+
const source = await ctx.get("source");
|
|
46
46
|
|
|
47
47
|
let sourceProxy: CloudSqlBackgroundProxy;
|
|
48
48
|
let targetProxy: CloudSqlBackgroundProxy;
|
|
49
49
|
let sourcePort: number;
|
|
50
50
|
let targetPort: number;
|
|
51
51
|
|
|
52
|
-
if (
|
|
52
|
+
if (source === "local") {
|
|
53
53
|
sourcePort = await ctx.get("sourceLocalPort");
|
|
54
54
|
} else {
|
|
55
55
|
sourcePort = 54399;
|
|
56
56
|
sourceProxy = await startCloudSqlProxyInBackground({
|
|
57
|
-
instanceName:
|
|
57
|
+
instanceName: source,
|
|
58
58
|
localPort: sourcePort,
|
|
59
59
|
});
|
|
60
60
|
}
|
|
@@ -63,14 +63,14 @@ export const commandRestoreDb = defineCommand({
|
|
|
63
63
|
const sourcePassword = await ctx.get("sourcePassword");
|
|
64
64
|
const sourceDbName = await ctx.get("sourceDbName");
|
|
65
65
|
|
|
66
|
-
const
|
|
66
|
+
const target = await ctx.get("target");
|
|
67
67
|
|
|
68
|
-
if (
|
|
68
|
+
if (target === "local") {
|
|
69
69
|
targetPort = await ctx.get("targetLocalPort");
|
|
70
70
|
} else {
|
|
71
71
|
targetPort = 54499;
|
|
72
72
|
targetProxy = await startCloudSqlProxyInBackground({
|
|
73
|
-
instanceName:
|
|
73
|
+
instanceName: target,
|
|
74
74
|
localPort: targetPort,
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -80,7 +80,7 @@ export const commandRestoreDb = defineCommand({
|
|
|
80
80
|
const targetDbName = await ctx.get("targetDbName");
|
|
81
81
|
|
|
82
82
|
const shouldContinue = await ctx.confirm(
|
|
83
|
-
`This will drop ${
|
|
83
|
+
`This will drop ${target}/${targetDbName} and replace it with ${source}/${sourceDbName}. Continue? 🤔 `,
|
|
84
84
|
);
|
|
85
85
|
if (!shouldContinue) {
|
|
86
86
|
return;
|
|
@@ -7,7 +7,12 @@ export const commandSetup = defineCommand({
|
|
|
7
7
|
"Initializes all environments and creates required resources, service accounts, etc.",
|
|
8
8
|
group: "project",
|
|
9
9
|
inputs: {
|
|
10
|
-
component: {
|
|
10
|
+
component: {
|
|
11
|
+
type: "string",
|
|
12
|
+
message: "component name",
|
|
13
|
+
positional: true,
|
|
14
|
+
required: false,
|
|
15
|
+
},
|
|
11
16
|
},
|
|
12
17
|
execute: async (ctx) => {
|
|
13
18
|
const component = await ctx.get("component");
|
package/src/completion.ts
CHANGED
|
@@ -142,11 +142,15 @@ async function resolveChoicesForCompletion(
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Generate the zsh completion script.
|
|
145
|
-
*
|
|
145
|
+
* Supports both direct invocation (`catladder`) and prefixed (`yarn catladder`).
|
|
146
146
|
*/
|
|
147
|
-
export function generateZshCompletionScript(
|
|
148
|
-
const
|
|
149
|
-
|
|
147
|
+
export function generateZshCompletionScript(command: string): string {
|
|
148
|
+
const parts = command.split(" ");
|
|
149
|
+
const funcName = command.replace(/[- ]/g, "_");
|
|
150
|
+
|
|
151
|
+
if (parts.length === 1) {
|
|
152
|
+
// Direct binary: catladder
|
|
153
|
+
return `
|
|
150
154
|
###-begin-${funcName}-completions-###
|
|
151
155
|
_${funcName}_completions() {
|
|
152
156
|
local -a completions
|
|
@@ -156,14 +160,47 @@ _${funcName}_completions() {
|
|
|
156
160
|
local -a cmd_words=(\${words:1:$((CURRENT-2))})
|
|
157
161
|
|
|
158
162
|
# Call the CLI's __complete command
|
|
159
|
-
completions=(\${(f)"$(${
|
|
163
|
+
completions=(\${(f)"$(${command} __complete -- "\${cmd_words[*]}" "$current_word" 2>/dev/null)"})
|
|
164
|
+
|
|
165
|
+
if [[ \${#completions[@]} -gt 0 ]]; then
|
|
166
|
+
compadd -a completions
|
|
167
|
+
fi
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
compdef _${funcName}_completions ${command}
|
|
171
|
+
###-end-${funcName}-completions-###
|
|
172
|
+
`.trim();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Multi-word command (e.g., "yarn catladder")
|
|
176
|
+
// Register on the first word (e.g., "yarn") but only activate
|
|
177
|
+
// when the subcommand matches (e.g., "catladder")
|
|
178
|
+
const prefix = parts[0];
|
|
179
|
+
const subcommand = parts.slice(1).join(" ");
|
|
180
|
+
const skipWords = parts.length; // how many words to skip before CLI args
|
|
181
|
+
|
|
182
|
+
return `
|
|
183
|
+
###-begin-${funcName}-completions-###
|
|
184
|
+
_${funcName}_completions() {
|
|
185
|
+
# Only activate when subcommand is "${subcommand}"
|
|
186
|
+
if [[ $CURRENT -le ${skipWords} ]] || [[ "\${words[2,${skipWords}]}" != "${subcommand}" ]]; then
|
|
187
|
+
return
|
|
188
|
+
fi
|
|
189
|
+
|
|
190
|
+
local -a completions
|
|
191
|
+
local current_word="\${words[$CURRENT]}"
|
|
192
|
+
|
|
193
|
+
# Words after "${command}", excluding the current word being completed
|
|
194
|
+
local -a cmd_words=(\${words:${skipWords}:$((CURRENT-${skipWords}-1))})
|
|
195
|
+
|
|
196
|
+
completions=(\${(f)"$(${command} __complete -- "\${cmd_words[*]}" "$current_word" 2>/dev/null)"})
|
|
160
197
|
|
|
161
198
|
if [[ \${#completions[@]} -gt 0 ]]; then
|
|
162
199
|
compadd -a completions
|
|
163
200
|
fi
|
|
164
201
|
}
|
|
165
202
|
|
|
166
|
-
compdef _${funcName}_completions ${
|
|
203
|
+
compdef _${funcName}_completions ${prefix}
|
|
167
204
|
###-end-${funcName}-completions-###
|
|
168
205
|
`.trim();
|
|
169
206
|
}
|
package/src/core/types.ts
CHANGED
|
@@ -103,13 +103,19 @@ export interface CommandContext<TInputs extends InputsSchema> extends IO {
|
|
|
103
103
|
* Consume a declared input by name.
|
|
104
104
|
* - Compile error if `name` is not in TInputs
|
|
105
105
|
* - Return type matches the input's type (string, number, boolean, string[])
|
|
106
|
-
* -
|
|
106
|
+
* - If `required: false`, returns `undefined` when not provided (no prompt)
|
|
107
|
+
* - Otherwise: pre-supplied value > choices function + interactive prompt > default > throw
|
|
107
108
|
*/
|
|
108
109
|
get<K extends keyof TInputs & string>(
|
|
109
110
|
name: K,
|
|
110
|
-
): Promise<
|
|
111
|
+
): Promise<OptionalInput<TInputs[K]>>;
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
/** If the input has `required: false`, the result can be undefined */
|
|
115
|
+
export type OptionalInput<T extends InputDef> = T extends { required: false }
|
|
116
|
+
? InputResultType<T> | undefined
|
|
117
|
+
: InputResultType<T>;
|
|
118
|
+
|
|
113
119
|
// ─── Command Definition ──────────────────────────────────────────────
|
|
114
120
|
|
|
115
121
|
export interface CommandDef<TInputs extends InputsSchema = InputsSchema> {
|