@catladder/cli 0.0.0-new-cli-52525b58 → 0.0.0-new-cli-b2300dd6

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.
Files changed (65) hide show
  1. package/dist/bundles/catenv/index.js +103 -66
  2. package/dist/bundles/cli/index.js +43415 -43368
  3. package/dist/cli/src/adapters/baseContext.d.ts +2 -2
  4. package/dist/cli/src/adapters/baseContext.js +10 -1
  5. package/dist/cli/src/adapters/baseContext.js.map +1 -1
  6. package/dist/cli/src/catenv.js +4 -3
  7. package/dist/cli/src/catenv.js.map +1 -1
  8. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.d.ts +2 -2
  9. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js +9 -9
  10. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js.map +1 -1
  11. package/dist/cli/src/commands/project/commandConfigSecrets.d.ts +1 -0
  12. package/dist/cli/src/commands/project/commandConfigSecrets.js +1 -0
  13. package/dist/cli/src/commands/project/commandConfigSecrets.js.map +1 -1
  14. package/dist/cli/src/commands/project/commandSetup.d.ts +1 -0
  15. package/dist/cli/src/commands/project/commandSetup.js +2 -1
  16. package/dist/cli/src/commands/project/commandSetup.js.map +1 -1
  17. package/dist/cli/src/core/types.d.ts +7 -2
  18. package/dist/cli/src/core/types.js.map +1 -1
  19. package/dist/pipeline/src/build/index.d.ts +2 -2
  20. package/dist/pipeline/src/build/index.js.map +1 -1
  21. package/dist/pipeline/src/build/node/buildJob.d.ts +3 -3
  22. package/dist/pipeline/src/build/node/buildJob.js +13 -12
  23. package/dist/pipeline/src/build/node/buildJob.js.map +1 -1
  24. package/dist/pipeline/src/build/node/cache.d.ts +3 -3
  25. package/dist/pipeline/src/build/node/cache.js +12 -9
  26. package/dist/pipeline/src/build/node/cache.js.map +1 -1
  27. package/dist/pipeline/src/build/node/index.d.ts +3 -3
  28. package/dist/pipeline/src/build/node/index.js +8 -6
  29. package/dist/pipeline/src/build/node/index.js.map +1 -1
  30. package/dist/pipeline/src/build/node/meteor.d.ts +1 -1
  31. package/dist/pipeline/src/build/node/meteor.js +8 -7
  32. package/dist/pipeline/src/build/node/meteor.js.map +1 -1
  33. package/dist/pipeline/src/build/node/testJob.d.ts +1 -1
  34. package/dist/pipeline/src/build/node/testJob.js +5 -5
  35. package/dist/pipeline/src/build/node/testJob.js.map +1 -1
  36. package/dist/pipeline/src/build/node/yarn.d.ts +2 -2
  37. package/dist/pipeline/src/build/node/yarn.js +10 -8
  38. package/dist/pipeline/src/build/node/yarn.js.map +1 -1
  39. package/dist/pipeline/src/constants.js +1 -1
  40. package/dist/pipeline/src/context/createComponentContext.js +3 -3
  41. package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
  42. package/dist/pipeline/src/context/createWorkspaceContext.js +1 -1
  43. package/dist/pipeline/src/context/createWorkspaceContext.js.map +1 -1
  44. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
  45. package/dist/pipeline/src/deploy/custom/deployJob.d.ts +1 -1
  46. package/dist/pipeline/src/deploy/custom/deployJob.js +2 -2
  47. package/dist/pipeline/src/deploy/custom/deployJob.js.map +1 -1
  48. package/dist/pipeline/src/deploy/index.d.ts +1 -1
  49. package/dist/pipeline/src/pipeline/createAllJobs.js +4 -4
  50. package/dist/pipeline/src/pipeline/createAllJobs.js.map +1 -1
  51. package/dist/pipeline/src/pipeline/createJobsForComponent.d.ts +1 -1
  52. package/dist/pipeline/src/pipeline/createJobsForComponent.js +2 -3
  53. package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
  54. package/dist/pipeline/src/pipeline/createJobsForWorkspace.d.ts +1 -1
  55. package/dist/pipeline/src/pipeline/createJobsForWorkspace.js +2 -2
  56. package/dist/pipeline/src/pipeline/createJobsForWorkspace.js.map +1 -1
  57. package/dist/pipeline/src/types/context.d.ts +3 -3
  58. package/dist/tsconfig.tsbuildinfo +1 -1
  59. package/package.json +1 -1
  60. package/src/adapters/baseContext.ts +15 -2
  61. package/src/catenv.ts +15 -8
  62. package/src/commands/cloudSQL/commandRestoreDb.ts +9 -9
  63. package/src/commands/project/commandConfigSecrets.ts +1 -0
  64. package/src/commands/project/commandSetup.ts +6 -1
  65. package/src/core/types.ts +8 -2
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "0.0.0-new-cli-52525b58",
56
+ "version": "0.0.0-new-cli-b2300dd6",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -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<InputResultType<TInputs[K]>> {
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
- this.cache.set(name, this.resolveInput(name, spec));
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
- .action((envComponent: string | undefined, opts: { verbose?: boolean }) => {
15
- catenv(envComponent ? parseChoice(envComponent) : null, {
16
- verbose: opts.verbose ?? false,
17
- }).then(() => {
18
- // we have to exit manually, because we have some file watches
19
- process.exit();
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();
@@ -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
- sourceInstance: {
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
- targetInstance: {
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 sourceInstance = await ctx.get("sourceInstance");
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 (sourceInstance === "local") {
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: sourceInstance,
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 targetInstance = await ctx.get("targetInstance");
66
+ const target = await ctx.get("target");
67
67
 
68
- if (targetInstance === "local") {
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: targetInstance,
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 ${targetInstance}/${targetDbName} and replace it with ${sourceInstance}/${sourceDbName}. Continue? 🤔 `,
83
+ `This will drop ${target}/${targetDbName} and replace it with ${source}/${sourceDbName}. Continue? 🤔 `,
84
84
  );
85
85
  if (!shouldContinue) {
86
86
  return;
@@ -15,6 +15,7 @@ export const commandConfigSecrets = defineCommand({
15
15
  type: "string",
16
16
  message: "environment:component",
17
17
  positional: true,
18
+ required: false,
18
19
  choices: async () => envAndComponents(),
19
20
  },
20
21
  },
@@ -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: { type: "string", message: "component name", positional: true },
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/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
- * - Resolution: pre-supplied value > choices function + interactive prompt > default > throw
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<InputResultType<TInputs[K]>>;
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> {