@catladder/cli 0.0.0-fix-config-move-not-working-again-bf012644 → 0.0.0-fix-handle-missing-cloud-sql-proxy-command-error-and-show-nice-4dbbecce

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 (49) hide show
  1. package/dist/bundles/catenv/index.js +327 -124
  2. package/dist/bundles/cli/index.js +470 -181
  3. package/dist/cli/src/apps/catenv/printVariables.js +4 -1
  4. package/dist/cli/src/apps/catenv/printVariables.js.map +1 -1
  5. package/dist/cli/src/apps/catenv/utils.d.ts +6 -2
  6. package/dist/cli/src/apps/catenv/utils.js +4 -2
  7. package/dist/cli/src/apps/catenv/utils.js.map +1 -1
  8. package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js +84 -51
  9. package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
  10. package/dist/cli/src/utils/log.d.ts +65 -1
  11. package/dist/cli/src/utils/log.js +66 -8
  12. package/dist/cli/src/utils/log.js.map +1 -1
  13. package/dist/pipeline/src/bash/bashEscape.d.ts +4 -1
  14. package/dist/pipeline/src/bash/bashEscape.js +4 -2
  15. package/dist/pipeline/src/bash/bashEscape.js.map +1 -1
  16. package/dist/pipeline/src/context/getEnvConfig.js +14 -2
  17. package/dist/pipeline/src/context/getEnvConfig.js.map +1 -1
  18. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +5 -3
  19. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +18 -107
  20. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
  21. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +4 -0
  22. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js +85 -0
  23. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js.map +1 -0
  24. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.d.ts +3 -0
  25. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +136 -0
  26. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -0
  27. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +5 -3
  28. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
  29. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +5 -3
  30. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js.map +1 -1
  31. package/dist/pipeline/src/deploy/cloudRun/index.js +6 -2
  32. package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
  33. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.d.ts +6 -0
  34. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js +11 -0
  35. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js.map +1 -0
  36. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.d.ts +5 -1
  37. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js +7 -1
  38. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js.map +1 -1
  39. package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +99 -1
  40. package/dist/pipeline/src/deploy/types/index.d.ts +1 -0
  41. package/dist/pipeline/src/deploy/types/index.js +7 -1
  42. package/dist/pipeline/src/deploy/types/index.js.map +1 -1
  43. package/dist/pipeline/src/types/config.d.ts +11 -6
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +1 -1
  46. package/src/apps/catenv/printVariables.ts +4 -1
  47. package/src/apps/catenv/utils.ts +12 -3
  48. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +130 -66
  49. package/src/utils/log.ts +104 -8
@@ -137,6 +137,10 @@ export type DeployConfigCloudRunJobBase = {
137
137
  * command
138
138
  */
139
139
  command: string | string[];
140
+ /**
141
+ * optional, specify args. Those get overwritten by job executions if specified there
142
+ */
143
+ args?: string[];
140
144
  /**
141
145
  * custom image to use. Defaults to the image from the build
142
146
  */
@@ -159,6 +163,10 @@ export type DeployConfigCloudRunJobBase = {
159
163
  * number of tasks that may run concurrently, defaults to 1
160
164
  */
161
165
  parallelism?: number;
166
+ /**
167
+ * max number of retries of the job. Defaults to 0
168
+ */
169
+ maxRetries?: number;
162
170
  } & DeployConfigCloudRunWithVolumes & DeployConfigCloudRunNetworkConfig;
163
171
  type Minute = string;
164
172
  type Hour = string;
@@ -166,24 +174,38 @@ type DayOfMonth = string;
166
174
  type DayOfWeek = string;
167
175
  type Month = string;
168
176
  export type DeployConfigCloudRunJobWithSchedule = DeployConfigCloudRunJobBase & {
177
+ /**
178
+ * @deprecated use `execute` instead
179
+ */
169
180
  when: "schedule";
181
+ /**
182
+ * @deprecated use `run` instead
183
+ */
170
184
  schedule: `${Minute} ${Hour} ${DayOfMonth} ${Month} ${DayOfWeek}`;
171
185
  /**
172
186
  * Max number of retries of the cloud scheduler.
173
187
  * Note: the task itself is never retried.
174
188
  *
175
189
  * defaults to 0 (no retries)
190
+ *
191
+ * @deprecated use `run` instead
176
192
  */
177
193
  maxRetryAttempts?: 0 | 1 | 2 | 3 | 4 | 5;
178
194
  };
179
195
  export type DeployConfigCloudRunJobNormal = DeployConfigCloudRunJobBase & {
180
- when: "manual" | "preDeploy" | "postDeploy" | "preStop" | "postStop";
181
196
  /**
182
197
  * wait for completion of the job on preDeploy and postDeploy
183
198
  *
184
199
  * has no effect on preStop and postStop (which always wait for completion)
200
+ *
201
+ *
202
+ * @deprecated use `run` instead
185
203
  */
186
204
  waitForCompletion?: boolean;
205
+ /**
206
+ * @deprecated use `run` instead
207
+ */
208
+ when?: "manual" | "preDeploy" | "postDeploy" | "preStop" | "postStop";
187
209
  };
188
210
  export type DeployConfigCloudRunWithVolumes = {
189
211
  /**
@@ -227,6 +249,10 @@ export type DeployConfigCloudRun = {
227
249
  * add cloudSql
228
250
  */
229
251
  cloudSql?: DeployConfigCloudRunCloudSql | false;
252
+ /**
253
+ * execute jobs on deploy or execute jobs and http requests on a schedule
254
+ */
255
+ execute?: Record<string, DeployConfigCloudRunExecute | null>;
230
256
  debug?: boolean;
231
257
  } & DeployConfigBase;
232
258
  export type DeployConfigCloudRunVolumes = Record<string, DeployConfigCloudRunVolume>;
@@ -236,4 +262,76 @@ export type DeployConfigCloudRunVolume = {
236
262
  mountPath: string;
237
263
  readonly?: boolean;
238
264
  };
265
+ export type DeployConfigCloudRunExecuteJobBase = {
266
+ /**
267
+ * set to "job" to run a cloud run job
268
+ */
269
+ type: "job";
270
+ /**
271
+ * the cloud run job to run
272
+ */
273
+ job: string;
274
+ /**
275
+ * additional args to pass to the job
276
+ */
277
+ args?: string[];
278
+ };
279
+ type WithSchedule = {
280
+ /**
281
+ * run the job on a schedule
282
+ */
283
+ when: "schedule";
284
+ /**
285
+ * the cron schedule. See https://crontab.guru/
286
+ */
287
+ schedule: `${Minute} ${Hour} ${DayOfMonth} ${Month} ${DayOfWeek}`;
288
+ /**
289
+ * Max number of retries of the cloud scheduler.
290
+ * Note: the task itself is never retried.
291
+ *
292
+ * defaults to 0 (no retries)
293
+ */
294
+ maxRetryAttempts?: 0 | 1 | 2 | 3 | 4 | 5;
295
+ };
296
+ export type DeployConfigCloudRunExecuteJobScheduled = DeployConfigCloudRunExecuteJobBase & WithSchedule;
297
+ export type DeployConfigCloudRunExecuteOnDeploy = DeployConfigCloudRunExecuteJobBase & ({
298
+ /**
299
+ * run the job before or after the deploy
300
+ */
301
+ when: "preDeploy" | "postDeploy";
302
+ /**
303
+ * whether to wait for completion of the job
304
+ */
305
+ waitForCompletion?: boolean;
306
+ } | {
307
+ /**
308
+ * run the job before or after the environment is stopped
309
+ */
310
+ when: "preStop" | "postStop";
311
+ });
312
+ export type DeployConfigCloudRunExecuteJob = DeployConfigCloudRunExecuteJobScheduled | DeployConfigCloudRunExecuteOnDeploy;
313
+ export type DeployConfigCloudRunExecuteHttp = {
314
+ /**
315
+ * set to "http" to run a http request
316
+ */
317
+ type: "http";
318
+ /**
319
+ * the url to call
320
+ */
321
+ url: string;
322
+ /**
323
+ * the http-method to use. Defaults to "POST" (as specified by google cloud scheduler)
324
+ */
325
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
326
+ /**
327
+ * the body to send
328
+ */
329
+ body?: string;
330
+ /**
331
+ * the headers to send
332
+ */
333
+ headers?: Record<string, string>;
334
+ } & WithSchedule;
335
+ export type DeployConfigCloudRunExecute = DeployConfigCloudRunExecuteJob | DeployConfigCloudRunExecuteHttp;
336
+ export type DeployConfigCloudRunExecuteWithSchedule = Extract<DeployConfigCloudRunExecute, WithSchedule>;
239
337
  export {};
@@ -20,3 +20,4 @@ export declare const isOfDeployType: <T extends ("custom" | "kubernetes" | "dock
20
20
  }> | Extract<DeployConfigKubernetes, {
21
21
  type: T[number];
22
22
  }>;
23
+ export declare const getDeployConfigType: (t: DeployConfig | false | null | undefined) => "custom" | "kubernetes" | "dockerTag" | "google-cloudrun";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isOfDeployType = void 0;
17
+ exports.getDeployConfigType = exports.isOfDeployType = void 0;
18
18
  __exportStar(require("./custom"), exports);
19
19
  __exportStar(require("./googleCloudRun"), exports);
20
20
  __exportStar(require("./kubernetes"), exports);
@@ -23,4 +23,10 @@ const isOfDeployType = (t, ...types) => {
23
23
  return t && types.includes(t.type) ? true : false;
24
24
  };
25
25
  exports.isOfDeployType = isOfDeployType;
26
+ const getDeployConfigType = (t) => {
27
+ if (!t)
28
+ return undefined;
29
+ return t.type;
30
+ };
31
+ exports.getDeployConfigType = getDeployConfigType;
26
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../pipeline/src/deploy/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,2CAAyB;AACzB,mDAAiC;AACjC,+CAA6B;AAC7B,8CAA4B;AAcrB,MAAM,cAAc,GAAG,CAC5B,CAA0C,EAC1C,GAAG,KAAQ,EACsC,EAAE;IACnD,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../pipeline/src/deploy/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,2CAAyB;AACzB,mDAAiC;AACjC,+CAA6B;AAC7B,8CAA4B;AAcrB,MAAM,cAAc,GAAG,CAC5B,CAA0C,EAC1C,GAAG,KAAQ,EACsC,EAAE;IACnD,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEK,MAAM,mBAAmB,GAAG,CACjC,CAA0C,EAC1C,EAAE;IACF,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,OAAO,CAAC,CAAC,IAAI,CAAC;AAChB,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B"}
@@ -73,6 +73,10 @@ export type DevLocalEnvConfig = {
73
73
  vars?: EnvVars;
74
74
  port?: number;
75
75
  };
76
+ type AddOverrideFunction<T> = {
77
+ [K in keyof T]: T[K] | ((defaultValue: T[K]) => T[K]) | (T[K] extends Record<string, unknown> | undefined ? AddOverrideFunction<T[K]> : never);
78
+ };
79
+ type EnvConfigWithOverride<E extends EnvType = EnvType> = AddOverrideFunction<EnvConfig<E>>;
76
80
  export type EnvConfig<E extends EnvType = EnvType> = {
77
81
  /**
78
82
  * type of the env (stage, prod, review, dev)
@@ -84,18 +88,18 @@ export type EnvConfig<E extends EnvType = EnvType> = {
84
88
  host?: string;
85
89
  } & PartialDeep<DefaultEnvConfig>;
86
90
  export type EnvConfigWithComponent = EnvConfig<EnvType> & ComponentConfig;
87
- export type CustomEnv = EnvConfig & {
91
+ export type CustomEnv = EnvConfigWithOverride & {
88
92
  type: EnvType;
89
93
  };
90
94
  export type Env<C extends ConfigProps = never> = {
91
95
  /**
92
96
  * local is a special env that is only used in local development
93
97
  */
94
- local?: DevLocalEnvConfig;
95
- dev?: EnvConfig<"dev"> | false;
96
- stage?: EnvConfig<"stage"> | false;
97
- review?: EnvConfig<"review"> | false;
98
- prod?: EnvConfig<"prod"> | false;
98
+ local?: AddOverrideFunction<DevLocalEnvConfig>;
99
+ dev?: EnvConfigWithOverride<"dev"> | false;
100
+ stage?: EnvConfigWithOverride<"stage"> | false;
101
+ review?: EnvConfigWithOverride<"review"> | false;
102
+ prod?: EnvConfigWithOverride<"prod"> | false;
99
103
  } & Record<C["CustomEnvs"], CustomEnv> & Record<string, any>;
100
104
  export type ComponentConfig<C extends ConfigProps = never> = {
101
105
  /**
@@ -178,3 +182,4 @@ export type Config<C extends ConfigProps = never> = {
178
182
  */
179
183
  runnerVariables?: Record<string, string>;
180
184
  };
185
+ export {};