@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
@@ -982,61 +982,30 @@ exports["default"] = async (vorpal) => vorpal
982
982
  /***/ }),
983
983
 
984
984
  /***/ 102:
985
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
985
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
986
986
 
987
987
  "use strict";
988
988
 
989
+ var __importDefault = (this && this.__importDefault) || function (mod) {
990
+ return (mod && mod.__esModule) ? mod : { "default": mod };
991
+ };
989
992
  Object.defineProperty(exports, "__esModule", ({ value: true }));
990
993
  const pipeline_1 = __nccwpck_require__(10603);
994
+ const clipboardy_1 = __importDefault(__nccwpck_require__(89881));
991
995
  const getProjectConfig_1 = __nccwpck_require__(12145);
992
996
  const autocompletions_1 = __nccwpck_require__(39855);
993
997
  const startProxy_1 = __nccwpck_require__(90742);
994
- exports["default"] = async (vorpal) => vorpal
995
- .command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db")
996
- .autocomplete(await (0, autocompletions_1.envAndComponents)())
997
- .action(async function ({ envComponent }) {
998
- var _a, _b;
999
- const { env, componentName } = (0, getProjectConfig_1.parseChoice)(envComponent);
1000
- if (!componentName) {
1001
- this.log("need componentName");
1002
- return;
1003
- }
1004
- const context = await (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName);
1005
- let proxyInfo;
1006
- if (env === "review") {
1007
- vorpal.log("⚠️ connection string does not include mr information on review environments");
1008
- }
998
+ const log_1 = __nccwpck_require__(66921);
999
+ const getProxyInfo = (context) => {
1000
+ var _a, _b, _c, _d;
1009
1001
  if ((0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) {
1010
- proxyInfo = await getProxyInfoForKubernetes(this, context);
1002
+ return getProxyInfoForKubernetes(this, context);
1011
1003
  }
1012
1004
  else if ((0, pipeline_1.isOfDeployType)((_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config, "google-cloudrun")) {
1013
- proxyInfo = await getProxyInfoForCloudRun(this, context);
1005
+ return getProxyInfoForCloudRun(this, context);
1014
1006
  }
1015
- else {
1016
- throw new Error("unsupported environment");
1017
- }
1018
- // skynet-164509:europe-west6:pvl-cyclomania-review=tcp:5432
1019
- const { DB_PASSWORD, DB_NAME, DB_USER, instanceName } = proxyInfo;
1020
- const { localPort } = await this.prompt({
1021
- type: "number",
1022
- name: "localPort",
1023
- default: "54320",
1024
- message: "Local port: ",
1025
- });
1026
- this.log("");
1027
- this.log(`postgres-PW: ${DB_PASSWORD}`);
1028
- this.log("");
1029
- this.log("connection strings:");
1030
- this.log("");
1031
- this.log(`DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${localPort}/${DB_NAME}?schema=public`);
1032
- this.log("");
1033
- this.log(`DATABASE_JDBC_URL=jdbc:postgresql://localhost:${localPort}/${DB_NAME}?schema=public&user=${DB_USER}&password=${DB_PASSWORD}`);
1034
- this.log("");
1035
- await (0, startProxy_1.startCloudSqlProxyInCurrentShell)({
1036
- instanceName,
1037
- localPort,
1038
- });
1039
- });
1007
+ throw new Error(`unsupported environment: ${(_d = (_c = context.deploy) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.type}`);
1008
+ };
1040
1009
  const getProxyInfoForKubernetes = async (vorpal, context) => {
1041
1010
  var _a, _b;
1042
1011
  if (!(0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) {
@@ -1056,22 +1025,86 @@ const getProxyInfoForKubernetes = async (vorpal, context) => {
1056
1025
  };
1057
1026
  };
1058
1027
  const getProxyInfoForCloudRun = async (vorpal, context) => {
1059
- var _a, _b, _c, _d, _e;
1028
+ var _a, _b, _c, _d, _e, _f;
1060
1029
  if (!(0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "google-cloudrun") ||
1061
1030
  !((_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config.cloudSql)) {
1062
- throw new Error("unsupported");
1031
+ const deployType = (0, pipeline_1.getDeployConfigType)((_c = context.deploy) === null || _c === void 0 ? void 0 : _c.config);
1032
+ const errorMessage = deployType === "google-cloudrun"
1033
+ ? `DeployConfig is missing the cloudSql property`
1034
+ : `Unsupported DeployConfig type: ${deployType}`;
1035
+ (0, log_1.logError)(vorpal, errorMessage);
1036
+ throw new Error(errorMessage);
1063
1037
  }
1064
1038
  const envVars = await (0, getProjectConfig_1.getEnvVarsResolved)(vorpal, context.env, context.name);
1065
- const DB_PASSWORD = (_c = envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD) === null || _c === void 0 ? void 0 : _c.toString();
1066
- const DB_USER = (_d = envVars === null || envVars === void 0 ? void 0 : envVars.DB_USER) === null || _d === void 0 ? void 0 : _d.toString();
1067
- const DB_NAME = context.environment.envVars.DB_NAME.toString();
1068
1039
  return {
1069
- instanceName: (_e = context.deploy) === null || _e === void 0 ? void 0 : _e.config.cloudSql.instanceConnectionName,
1070
- DB_PASSWORD,
1071
- DB_NAME,
1072
- DB_USER,
1040
+ instanceName: (_d = context.deploy) === null || _d === void 0 ? void 0 : _d.config.cloudSql.instanceConnectionName,
1041
+ DB_PASSWORD: (_e = envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD) === null || _e === void 0 ? void 0 : _e.toString(),
1042
+ DB_NAME: context.environment.envVars.DB_NAME.toString(),
1043
+ DB_USER: (_f = envVars === null || envVars === void 0 ? void 0 : envVars.DB_USER) === null || _f === void 0 ? void 0 : _f.toString(),
1073
1044
  };
1074
1045
  };
1046
+ const getDbUrl = ({ DB_PASSWORD, DB_NAME, DB_USER }, localPort, additional = "") => `DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${localPort}/${DB_NAME}${additional}"`;
1047
+ const getJdbcUrl = ({ DB_PASSWORD, DB_NAME, DB_USER }, localPort) => `DATABASE_JDBC_URL="jdbc:postgresql://localhost:${localPort}/${DB_NAME}?schema=public&user=${DB_USER}&password=${DB_PASSWORD}"`;
1048
+ exports["default"] = async (vorpal) => vorpal
1049
+ .command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db")
1050
+ .autocomplete(await (0, autocompletions_1.envAndComponents)())
1051
+ .action(async function ({ envComponent }) {
1052
+ const { env, componentName } = (0, getProjectConfig_1.parseChoice)(envComponent);
1053
+ if (!componentName) {
1054
+ (0, log_1.logWarning)(this, "need componentName");
1055
+ return;
1056
+ }
1057
+ const context = await (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName);
1058
+ if (env === "review") {
1059
+ (0, log_1.logWarning)(this, "connection string does not include mr information on review environments");
1060
+ }
1061
+ const { localPort } = await this.prompt({
1062
+ type: "number",
1063
+ name: "localPort",
1064
+ default: "54320",
1065
+ message: "Local port: ",
1066
+ });
1067
+ const proxyInfo = await getProxyInfo(context);
1068
+ /**
1069
+ * Env variables for libpq (e.g. psql client)
1070
+ * https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS
1071
+ */
1072
+ const psqlEnvVars = {
1073
+ PGPASSWORD: proxyInfo.DB_PASSWORD,
1074
+ PGUSER: proxyInfo.DB_USER,
1075
+ PGDATABASE: proxyInfo.DB_NAME,
1076
+ PGHOST: "localhost",
1077
+ PGPORT: localPort,
1078
+ };
1079
+ const lipbqEnvVarDeclarations = Object.entries(psqlEnvVars).map(([key, value]) => `${key}="${value}"`);
1080
+ const dbUrl = getDbUrl(proxyInfo, localPort);
1081
+ const jdbcUrl = getJdbcUrl(proxyInfo, localPort);
1082
+ clipboardy_1.default.writeSync([
1083
+ "",
1084
+ "## CloudSQL proxy connection .env variables",
1085
+ dbUrl,
1086
+ jdbcUrl,
1087
+ "## DATABASE_URL with schema=public parameter (e. g. Prisma requires this):",
1088
+ `# ${getDbUrl(proxyInfo, localPort, `?schema=public`)}`,
1089
+ "## Env variables for libpq (e.g. psql client https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS)",
1090
+ ...lipbqEnvVarDeclarations,
1091
+ "",
1092
+ ].join("\n"));
1093
+ (0, log_1.logLines)(this, null, "Connection strings env variables DATABASE_URL and those for the 'psql' client (copied to your clipboard for .env file):", dbUrl, jdbcUrl, ...lipbqEnvVarDeclarations, null, "DATABASE_URL with schema=public parameter (e. g. Prisma requires this):", getDbUrl(proxyInfo, localPort, `?schema=public`), null);
1094
+ try {
1095
+ await (0, startProxy_1.startCloudSqlProxyInCurrentShell)({
1096
+ instanceName: proxyInfo.instanceName,
1097
+ localPort,
1098
+ });
1099
+ }
1100
+ catch (error) {
1101
+ if (!(error instanceof Error))
1102
+ throw error;
1103
+ if (error.message !== startProxy_1.ERROR_NOT_INSTALLED)
1104
+ throw error;
1105
+ (0, log_1.logError)(this, error.message, null, "Please install the Cloud SQL Auth Proxy from:", `https://cloud.google.com/sql/docs/postgres/connect-auth-proxy#install`, null);
1106
+ }
1107
+ });
1075
1108
  //# sourceMappingURL=commandCloudSqlProxy.js.map
1076
1109
 
1077
1110
  /***/ }),
@@ -3528,17 +3561,75 @@ exports.upsertAllVariables = upsertAllVariables;
3528
3561
  "use strict";
3529
3562
 
3530
3563
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3531
- exports.logError = void 0;
3532
- const logError = (cmd, message, additionalMessage) => {
3533
- cmd.log("");
3534
- cmd.log(`[ERROR] 🙀 :${message}`);
3535
- cmd.log("");
3536
- if (additionalMessage) {
3537
- cmd.log(additionalMessage);
3538
- cmd.log("");
3564
+ exports.logWarning = exports.logError = exports.logLines = void 0;
3565
+ /**
3566
+ * Logs multiple lines using the log method of the provided {@link LoggerCmdInstance}.
3567
+ *
3568
+ * Line items that are `null` or `undefined` are logged as empty lines.
3569
+ *
3570
+ * @param cmd - The logger instance to use. If `null` or `undefined`, `console` will be used.
3571
+ *
3572
+ * @example
3573
+ * ```ts
3574
+ * logLines(cmd, "line 1", "line 2", null, "line 3");
3575
+ * logLines(cmd, ...linesArray); // arrays can be spread into the function
3576
+ * logLines(cmd, linesArray); // but it will flatten the plain array for convenience
3577
+ * ```
3578
+ */
3579
+ function logLines(cmd = console, ...lines) {
3580
+ const logger = cmd !== null && cmd !== void 0 ? cmd : console;
3581
+ for (const line of lines.flat()) {
3582
+ if (line === null || line === undefined) {
3583
+ logger.log("");
3584
+ }
3585
+ else {
3586
+ logger.log(line);
3587
+ }
3588
+ }
3589
+ }
3590
+ exports.logLines = logLines;
3591
+ /**
3592
+ * Logs an error message using the log method of the provided {@link LoggerCmdInstance}.
3593
+ *
3594
+ * Line items that are `null` or `undefined` are logged as empty lines.
3595
+ *
3596
+ * @example
3597
+ * ```ts
3598
+ * logError(cmd, "Message");
3599
+ * logError(cmd, "Message", "Additional message");
3600
+ * logError(cmd, "Message", "Additional message", "Another additional message line");
3601
+ * logError(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
3602
+ * logError(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
3603
+ * ```
3604
+ */
3605
+ const logError = (cmd = console, message, ...additionalMessages) => {
3606
+ logLines(cmd, null, `[ERROR] 🙀 :${message}`, null);
3607
+ if (additionalMessages === null || additionalMessages === void 0 ? void 0 : additionalMessages.length) {
3608
+ logLines(cmd, ...additionalMessages.flat(), null);
3539
3609
  }
3540
3610
  };
3541
3611
  exports.logError = logError;
3612
+ /**
3613
+ * Logs a warning message using the log method of the provided {@link LoggerCmdInstance}.
3614
+ *
3615
+ * Line items that are `null` or `undefined` are logged as empty lines.
3616
+ *
3617
+ * @example
3618
+ * ```ts
3619
+ * logWarning(cmd, "Message");
3620
+ * logWarning(cmd, "Message", "Additional message");
3621
+ * logWarning(cmd, "Message", "Additional message", "Another additional message line");
3622
+ * logWarning(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
3623
+ * logWarning(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
3624
+ * ```
3625
+ */
3626
+ const logWarning = (cmd = console, message, ...additionalMessages) => {
3627
+ logLines(cmd, `[WARNING] ⚠️ : ${message}`);
3628
+ if (additionalMessages === null || additionalMessages === void 0 ? void 0 : additionalMessages.length) {
3629
+ logLines(cmd, ...additionalMessages.flat(), null);
3630
+ }
3631
+ };
3632
+ exports.logWarning = logWarning;
3542
3633
  //# sourceMappingURL=log.js.map
3543
3634
 
3544
3635
  /***/ }),
@@ -3896,14 +3987,16 @@ exports.escapeSingleQuotes = escapeSingleQuotes;
3896
3987
  *
3897
3988
  * - other languages are currently only partially supported, since most .env implementations are slightly different
3898
3989
  */
3899
- const escapeForDotEnv = (value) => {
3990
+ const escapeForDotEnv = (value, options = {
3991
+ quoteMode: "auto",
3992
+ }) => {
3900
3993
  if (value === undefined || value === null) {
3901
3994
  return "";
3902
3995
  }
3903
3996
  if (typeof value === "string") {
3904
3997
  // if string contains newlines, we need to wrap it in quotes
3905
3998
  // we additionaly escape newlines, that give best compatibility
3906
- if (value.includes("\n")) {
3999
+ if (options.quoteMode === "always" || value.includes("\n")) {
3907
4000
  const newlinesReplaces = value.replace(/\n/g, "\\n");
3908
4001
  // default to ", but if this is not possible, we try to use ' or `
3909
4002
  const quote = value.includes(`"`)
@@ -5932,7 +6025,7 @@ exports.getBuildInfoVariables = getBuildInfoVariables;
5932
6025
 
5933
6026
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5934
6027
  exports.getEnvConfig = void 0;
5935
- const utils_1 = __nccwpck_require__(32497);
6028
+ const lodash_1 = __nccwpck_require__(23255);
5936
6029
  const getEnvConfig = (config, componentName, env) => {
5937
6030
  var _a, _b;
5938
6031
  const defaultConfig = config.components[componentName];
@@ -5944,7 +6037,19 @@ const getEnvConfig = (config, componentName, env) => {
5944
6037
  // env is disabled, still return the default config
5945
6038
  return defaultConfig;
5946
6039
  }
5947
- return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
6040
+ /**
6041
+ * env config is merged with default. Arrays are not merged.
6042
+ * you can customize this by providing a function that takes the default value as argument
6043
+ */
6044
+ return (0, lodash_1.mergeWith)({}, defaultConfig, envCustomizations, (defaultValue, customValue) => {
6045
+ // check if custom value is a function (and default is not),
6046
+ // we currently don't have config options that are functions, but we might in the future
6047
+ if (typeof customValue === "function" &&
6048
+ typeof defaultValue !== "function") {
6049
+ return customValue(defaultValue);
6050
+ }
6051
+ return undefined;
6052
+ });
5948
6053
  };
5949
6054
  exports.getEnvConfig = getEnvConfig;
5950
6055
  //# sourceMappingURL=getEnvConfig.js.map
@@ -6778,69 +6883,35 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
6778
6883
  "use strict";
6779
6884
 
6780
6885
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6781
- exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
6886
+ exports.getCloudRunJobsWithNames = exports.getJobCreateScripts = exports.getDeleteJobsScripts = void 0;
6887
+ const getLabels_1 = __nccwpck_require__(30920);
6888
+ const utils_1 = __nccwpck_require__(32497);
6782
6889
  const createArgsString_1 = __nccwpck_require__(49598);
6783
6890
  const jobName_1 = __nccwpck_require__(9626);
6784
6891
  const common_1 = __nccwpck_require__(73325);
6785
- const getLabels_1 = __nccwpck_require__(30920);
6786
- const volumes_1 = __nccwpck_require__(60847);
6787
6892
  const constants_1 = __nccwpck_require__(38865);
6788
- const utils_1 = __nccwpck_require__(32497);
6789
- const getJobRunScriptForJob = (context, jobName, wait) => {
6790
- const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
6791
- const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
6792
- return `${(0, common_1.gcloudRunCmd)()} jobs execute ${jobName.toString()} ${commonArgsString}${wait ? " --wait" : ""}`;
6793
- };
6794
- const getDeleteSchedulesScripts = (context) => {
6795
- const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
6796
- const schedules = getSchedules(context);
6797
- const argsString = (0, createArgsString_1.createArgsString)({
6798
- project: deployConfig.projectId,
6799
- location: deployConfig.region,
6800
- });
6801
- return schedules
6802
- .map(({ name }) => {
6803
- return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${name} ${argsString}`];
6804
- })
6805
- .flat();
6806
- };
6807
- exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
6893
+ const volumes_1 = __nccwpck_require__(60847);
6894
+ const onDeploy_1 = __nccwpck_require__(2358);
6808
6895
  const getDeleteJobsScripts = (context) => {
6809
6896
  const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
6810
6897
  const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
6811
- const jobsWithNames = getCloudRunJobsWithNames(context);
6812
- return jobsWithNames.flatMap(({ jobName }) => [
6898
+ const jobsWithNames = (0, exports.getCloudRunJobsWithNames)(context);
6899
+ return jobsWithNames.flatMap(({ fullJobName }) => [
6813
6900
  // first delete all job executions. Otherwise delete might fail if one of those is still running
6814
- `${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${jobName} --format="value(name)" | xargs -I {} ${(0, common_1.gcloudRunCmd)()} jobs executions delete {} --quiet ${commonArgsString}`,
6815
- `${(0, common_1.gcloudRunCmd)()} jobs delete ${jobName} ${commonArgsString}`,
6901
+ `${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${fullJobName} --format="value(name)" | xargs -I {} ${(0, common_1.gcloudRunCmd)()} jobs executions delete {} --quiet ${commonArgsString}`,
6902
+ `${(0, common_1.gcloudRunCmd)()} jobs delete ${fullJobName} ${commonArgsString}`,
6816
6903
  ]);
6817
6904
  };
6818
6905
  exports.getDeleteJobsScripts = getDeleteJobsScripts;
6819
- const getJobRunScripts = (context, when) => {
6820
- const jobsWithNames = getCloudRunJobsWithNames(context);
6821
- return jobsWithNames
6822
- .filter(({ job }) => job.when === when)
6823
- .map(({ jobName, job }) => {
6824
- var _a;
6825
- // always wait for completion for preStop and postStop jobs
6826
- // since stop will delete the jobs afterwards, so they will fail
6827
- const waitForCompletion = ["preStop", "postStop"].includes(when)
6828
- ? true
6829
- : "waitForCompletion" in job
6830
- ? ((_a = job.waitForCompletion) !== null && _a !== void 0 ? _a : false)
6831
- : false;
6832
- return getJobRunScriptForJob(context, jobName, waitForCompletion);
6833
- });
6834
- };
6835
- exports.getJobRunScripts = getJobRunScripts;
6836
- const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job, jobName }, jobIndex) => {
6837
- var _a, _b, _c, _d;
6906
+ const getJobCreateScripts = (context) => (0, exports.getCloudRunJobsWithNames)(context).map(({ job, fullJobName }, jobIndex) => {
6907
+ var _a, _b, _c, _d, _e;
6838
6908
  const commandArray = Array.isArray(job.command)
6839
6909
  ? job.command
6840
6910
  : job.command.split(" ");
6841
6911
  const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
6842
6912
  const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
6843
6913
  command: `"${commandArray.join(",")}"`,
6914
+ args: (0, onDeploy_1.getCloudRunJobArgsArg)(job.args),
6844
6915
  labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
6845
6916
  image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
6846
6917
  project,
@@ -6850,7 +6921,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6850
6921
  parallelism: (_c = job.parallelism) !== null && _c !== void 0 ? _c : 1,
6851
6922
  "task-timeout": (_d = job.timeout) !== null && _d !== void 0 ? _d : "10m",
6852
6923
  "env-vars-file": constants_1.ENV_VARS_FILENAME,
6853
- "max-retries": 0,
6924
+ "max-retries": (_e = job.maxRetries) !== null && _e !== void 0 ? _e : 0,
6854
6925
  ...deployArgs,
6855
6926
  // network
6856
6927
  "vpc-connector": job === null || job === void 0 ? void 0 : job.vpcConnector,
@@ -6862,7 +6933,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6862
6933
  jobIndex === 0
6863
6934
  ? `exist_job_names="$(\n ${(0, common_1.gcloudRunCmd)()} jobs list --filter='metadata.name ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --project='${project}' --region='${region}'\n)"`
6864
6935
  : null,
6865
- `current_job_name="${jobName}"`,
6936
+ `current_job_name="${fullJobName}"`,
6866
6937
  'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then',
6867
6938
  ` ${(0, common_1.gcloudRunCmd)()} jobs update "$current_job_name" ${commonDeployArgsString}`,
6868
6939
  "else",
@@ -6873,75 +6944,20 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6873
6944
  .join("\n");
6874
6945
  });
6875
6946
  exports.getJobCreateScripts = getJobCreateScripts;
6876
- const getCreateScheduleScripts = (context) => {
6877
- const schedules = getSchedules(context);
6878
- const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
6879
- return schedules.map((scheduler, jobIndex) => {
6880
- var _a;
6881
- const uri = getSchedulerUrl(scheduler, context);
6882
- const argsString = (0, createArgsString_1.createArgsString)({
6883
- project,
6884
- location,
6885
- uri: `"$current_job_uri"`,
6886
- "http-method": "POST",
6887
- "oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
6888
- schedule: `"${scheduler.schedule}"`,
6889
- "max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
6890
- });
6891
- return [
6892
- jobIndex === 0
6893
- ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"`
6894
- : null,
6895
- `current_job_uri="${uri}"`,
6896
- `current_scheduler_name="${scheduler.name}"`,
6897
- `if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
6898
- ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
6899
- `else`,
6900
- ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
6901
- `fi`,
6902
- ]
6903
- .filter(utils_1.notNil)
6904
- .join("\n");
6905
- });
6906
- };
6907
- exports.getCreateScheduleScripts = getCreateScheduleScripts;
6908
- const getSchedulerUrl = (scheduler, context) => {
6909
- if (scheduler.type === "cloudRunJob") {
6910
- const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
6911
- const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
6912
- return `${uriBase}/${scheduler.jobName}:run`;
6913
- }
6914
- throw new Error(`Unknown scheduler type: ${scheduler.type}`);
6915
- };
6916
- const getSchedules = (context) => {
6917
- const jobsWithNames = getCloudRunJobsWithNames(context);
6918
- return jobsWithNames
6919
- .filter((entry) => entry.job.when === "schedule")
6920
- .map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
6921
- const schedulerName = jobName.concat("-scheduler");
6922
- return {
6923
- name: schedulerName,
6924
- maxRetryAttempts,
6925
- schedule,
6926
- type: "cloudRunJob",
6927
- jobName,
6928
- };
6929
- });
6930
- };
6931
6947
  const getCloudRunJobsWithNames = (context) => {
6932
6948
  var _a;
6933
6949
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
6934
- const getFullJobName = (name) => (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
6935
6950
  const jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
6936
6951
  // filter out disabled jobs
6937
6952
  .filter((entry) => Boolean(entry[1]))
6938
- .map(([jobKey, job]) => ({
6939
- jobName: getFullJobName(jobKey),
6953
+ .map(([jobName, job]) => ({
6954
+ fullJobName: (0, jobName_1.getFullJobName)(context, jobName),
6940
6955
  job,
6941
- jobKey,
6956
+ jobName,
6942
6957
  }));
6943
6958
  return jobsWithNames;
6944
6959
  };
6960
+ exports.getCloudRunJobsWithNames = getCloudRunJobsWithNames;
6945
6961
  //# sourceMappingURL=cloudRunJobs.js.map
6946
6962
 
6947
6963
  /***/ }),
@@ -7093,6 +7109,241 @@ exports.ENV_VARS_FILENAME = "____envvars.yaml";
7093
7109
 
7094
7110
  /***/ }),
7095
7111
 
7112
+ /***/ 2358:
7113
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7114
+
7115
+ "use strict";
7116
+
7117
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7118
+ exports.getCloudRunJobArgsArg = exports.getOnDeployExecuteScript = void 0;
7119
+ const createArgsString_1 = __nccwpck_require__(49598);
7120
+ const jobName_1 = __nccwpck_require__(9626);
7121
+ const cloudRunJobs_1 = __nccwpck_require__(61224);
7122
+ const common_1 = __nccwpck_require__(73325);
7123
+ const getOnDeployExecuteScript = (context, when) => {
7124
+ const executes = getExecutes(context);
7125
+ return executes
7126
+ .filter(({ config }) => config.when === when)
7127
+ .map((execute) => {
7128
+ return getJobRunScriptForExecute(context, execute);
7129
+ });
7130
+ };
7131
+ exports.getOnDeployExecuteScript = getOnDeployExecuteScript;
7132
+ const getExecutes = (context) => {
7133
+ var _a;
7134
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7135
+ return [
7136
+ ...getLegacyExecutes(context),
7137
+ ...Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
7138
+ if (!value || (value.when !== "schedule" && value.type !== "job")) {
7139
+ return [];
7140
+ }
7141
+ return [
7142
+ {
7143
+ jobName: key,
7144
+ config: value,
7145
+ },
7146
+ ];
7147
+ }),
7148
+ ];
7149
+ };
7150
+ const getLegacyExecutes = (context) => {
7151
+ const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
7152
+ return jobsWithNames.flatMap(({ jobName, job }) => {
7153
+ if (!job.when ||
7154
+ !["preDeploy", "postDeploy", "preStop", "postStop"].includes(job.when)) {
7155
+ return [];
7156
+ }
7157
+ return [
7158
+ {
7159
+ jobName,
7160
+ config: {
7161
+ job: jobName,
7162
+ type: "job",
7163
+ when: job.when,
7164
+ ...(job.when === "preDeploy" || job.when === "postDeploy"
7165
+ ? {
7166
+ waitForCompletion: job.waitForCompletion,
7167
+ }
7168
+ : {}),
7169
+ },
7170
+ },
7171
+ ];
7172
+ });
7173
+ };
7174
+ const getJobRunScriptForExecute = (context, { jobName, config }) => {
7175
+ var _a;
7176
+ const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
7177
+ // always wait for completion for preStop and postStop jobs
7178
+ // since stop will delete the jobs afterwards, so they will fail
7179
+ const waitForCompletion = ["preStop", "postStop"].includes(config.when)
7180
+ ? true // always
7181
+ : "waitForCompletion" in config
7182
+ ? ((_a = config.waitForCompletion) !== null && _a !== void 0 ? _a : false) // depends on config
7183
+ : false;
7184
+ const argString = (0, createArgsString_1.createArgsString)({
7185
+ ...commonArgs,
7186
+ wait: waitForCompletion === true ? true : undefined,
7187
+ args: (0, exports.getCloudRunJobArgsArg)(config.args),
7188
+ });
7189
+ const fullJobName = (0, jobName_1.getFullJobName)(context, jobName);
7190
+ return `${(0, common_1.gcloudRunCmd)()} jobs execute ${fullJobName.toString()} ${argString}`;
7191
+ };
7192
+ const getCloudRunJobArgsArg = (args) => {
7193
+ return args !== undefined
7194
+ ? args.length > 0
7195
+ ? args === null || args === void 0 ? void 0 : args.map((arg) => `"${arg}"`).join(",")
7196
+ : ""
7197
+ : undefined;
7198
+ };
7199
+ exports.getCloudRunJobArgsArg = getCloudRunJobArgsArg;
7200
+ //# sourceMappingURL=onDeploy.js.map
7201
+
7202
+ /***/ }),
7203
+
7204
+ /***/ 3697:
7205
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7206
+
7207
+ "use strict";
7208
+
7209
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7210
+ exports.getCreateScheduleScript = exports.getDeleteSchedulesScript = void 0;
7211
+ const bash_1 = __nccwpck_require__(22990);
7212
+ const utils_1 = __nccwpck_require__(32497);
7213
+ const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
7214
+ const createArgsString_1 = __nccwpck_require__(49598);
7215
+ const jobName_1 = __nccwpck_require__(9626);
7216
+ const cloudRunJobs_1 = __nccwpck_require__(61224);
7217
+ const common_1 = __nccwpck_require__(73325);
7218
+ const getDeleteSchedulesScript = (context) => {
7219
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7220
+ const schedules = getSchedules(context);
7221
+ const argsString = (0, createArgsString_1.createArgsString)({
7222
+ project: deployConfig.projectId,
7223
+ location: deployConfig.region,
7224
+ });
7225
+ return schedules
7226
+ .map(({ fullName }) => {
7227
+ return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${fullName} ${argsString}`];
7228
+ })
7229
+ .flat();
7230
+ };
7231
+ exports.getDeleteSchedulesScript = getDeleteSchedulesScript;
7232
+ const getCreateScheduleScript = (context) => {
7233
+ const schedules = getSchedules(context);
7234
+ const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
7235
+ return schedules.map(({ fullName, config }, jobIndex) => {
7236
+ var _a;
7237
+ const { uri, ...args } = getSchedulerArgs(config, context);
7238
+ const argsString = (0, createArgsString_1.createArgsString)({
7239
+ project,
7240
+ location,
7241
+ uri: `"$current_job_uri"`,
7242
+ ...args,
7243
+ schedule: `"${config.schedule}"`,
7244
+ "max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
7245
+ });
7246
+ return [
7247
+ jobIndex === 0
7248
+ ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"`
7249
+ : null,
7250
+ `current_job_uri="${uri}"`,
7251
+ `current_scheduler_name="${fullName}"`,
7252
+ `if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
7253
+ ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
7254
+ `else`,
7255
+ ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
7256
+ `fi`,
7257
+ ]
7258
+ .filter(utils_1.notNil)
7259
+ .join("\n");
7260
+ });
7261
+ };
7262
+ exports.getCreateScheduleScript = getCreateScheduleScript;
7263
+ const getSchedulerArgs = (scheduler, context) => {
7264
+ var _a;
7265
+ if (scheduler.type === "job") {
7266
+ const { projectId, region } = (0, common_1.getCloudRunDeployConfig)(context);
7267
+ const body = scheduler.args !== undefined
7268
+ ? {
7269
+ overrides: {
7270
+ containerOverrides: [
7271
+ ((_a = scheduler.args) === null || _a === void 0 ? void 0 : _a.length) > 0
7272
+ ? {
7273
+ args: scheduler.args,
7274
+ }
7275
+ : {
7276
+ args: [],
7277
+ clearArgs: true, // not sure why this is neeeded, but it is
7278
+ },
7279
+ ],
7280
+ },
7281
+ }
7282
+ : null;
7283
+ return {
7284
+ uri: (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(scheduler.job, {
7285
+ appFullName: context.environment.fullName,
7286
+ projectId,
7287
+ region,
7288
+ }),
7289
+ "message-body": body
7290
+ ? '"' + (0, bash_1.bashEscape)(JSON.stringify(body)) + '"'
7291
+ : undefined,
7292
+ "http-method": "POST",
7293
+ "oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
7294
+ };
7295
+ }
7296
+ if (scheduler.type === "http") {
7297
+ return {
7298
+ uri: scheduler.url,
7299
+ "message-body": scheduler.body,
7300
+ "http-method": scheduler.method,
7301
+ "oidc-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
7302
+ };
7303
+ }
7304
+ throw new Error(`Unknown scheduler type: ${scheduler.type}`);
7305
+ };
7306
+ const getSchedules = (context) => {
7307
+ const legacyScheduleJobs = getLegacyJobSchedules(context);
7308
+ const schedules = getScheduledExecutes(context);
7309
+ return Object.entries({ ...legacyScheduleJobs, ...schedules }).map(([name, config]) => ({
7310
+ name,
7311
+ fullName: (0, jobName_1.getFullSchedulerName)(context, name),
7312
+ config,
7313
+ }));
7314
+ };
7315
+ const getLegacyJobSchedules = (context) => {
7316
+ const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
7317
+ return Object.fromEntries(jobsWithNames
7318
+ .filter((entry) => entry.job.when === "schedule")
7319
+ .map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
7320
+ const schedulerName = jobName.concat("-scheduler");
7321
+ return [
7322
+ schedulerName,
7323
+ {
7324
+ type: "job",
7325
+ job: jobName,
7326
+ maxRetryAttempts,
7327
+ schedule,
7328
+ when: "schedule",
7329
+ },
7330
+ ];
7331
+ }));
7332
+ };
7333
+ const getScheduledExecutes = (context) => {
7334
+ var _a;
7335
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7336
+ return Object.fromEntries(Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
7337
+ if (!value || value.when !== "schedule") {
7338
+ return [];
7339
+ }
7340
+ return [[key, value]];
7341
+ }));
7342
+ };
7343
+ //# sourceMappingURL=schedules.js.map
7344
+
7345
+ /***/ }),
7346
+
7096
7347
  /***/ 53695:
7097
7348
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7098
7349
 
@@ -7109,9 +7360,11 @@ const cleanup_1 = __nccwpck_require__(67888);
7109
7360
  const database_1 = __nccwpck_require__(28206);
7110
7361
  const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
7111
7362
  const cloudRunJobs_1 = __nccwpck_require__(61224);
7363
+ const onDeploy_1 = __nccwpck_require__(2358);
7112
7364
  const cloudRunServices_1 = __nccwpck_require__(17334);
7113
7365
  const common_1 = __nccwpck_require__(73325);
7114
7366
  const constants_1 = __nccwpck_require__(38865);
7367
+ const schedules_1 = __nccwpck_require__(3697);
7115
7368
  function getCloudRunDeployScripts(context) {
7116
7369
  var _a;
7117
7370
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
@@ -7126,14 +7379,14 @@ function getCloudRunDeployScripts(context) {
7126
7379
  ...(deployConfig.cloudSql
7127
7380
  ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
7128
7381
  : []),
7129
- ...(0, cloudRunJobs_1.getCreateScheduleScripts)(context),
7382
+ ...(0, schedules_1.getCreateScheduleScript)(context),
7130
7383
  ...(0, cloudRunJobs_1.getJobCreateScripts)(context),
7131
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "preDeploy"),
7384
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preDeploy"),
7132
7385
  ...(deployConfig.service !== false
7133
7386
  ? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)]
7134
7387
  : []),
7135
7388
  ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).map(([name, service]) => (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name)),
7136
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "postDeploy"),
7389
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postDeploy"),
7137
7390
  ]),
7138
7391
  ...(0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy")),
7139
7392
  ...(0, sbom_1.getDependencyTrackUploadScript)(context),
@@ -7156,6 +7409,8 @@ const cleanup_1 = __nccwpck_require__(67888);
7156
7409
  const database_1 = __nccwpck_require__(28206);
7157
7410
  const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
7158
7411
  const cloudRunJobs_1 = __nccwpck_require__(61224);
7412
+ const onDeploy_1 = __nccwpck_require__(2358);
7413
+ const schedules_1 = __nccwpck_require__(3697);
7159
7414
  const cloudRunServices_1 = __nccwpck_require__(17334);
7160
7415
  const common_1 = __nccwpck_require__(73325);
7161
7416
  function getCloudRunStopScripts(context) {
@@ -7163,11 +7418,11 @@ function getCloudRunStopScripts(context) {
7163
7418
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7164
7419
  return [
7165
7420
  ...(0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context),
7166
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "preStop"),
7421
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop"),
7167
7422
  ...(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []),
7168
7423
  ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).flatMap(([name]) => (0, cloudRunServices_1.getServiceDeleteScript)(context, name)),
7169
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "postStop"),
7170
- ...(0, cloudRunJobs_1.getDeleteSchedulesScripts)(context),
7424
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postStop"),
7425
+ ...(0, schedules_1.getDeleteSchedulesScript)(context),
7171
7426
  ...(0, cloudRunJobs_1.getDeleteJobsScripts)(context),
7172
7427
  ...(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop
7173
7428
  ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig)
@@ -7272,8 +7527,8 @@ const context_1 = __nccwpck_require__(5875);
7272
7527
  const gitlab_1 = __nccwpck_require__(38490);
7273
7528
  const utils_1 = __nccwpck_require__(62089);
7274
7529
  const createJobs_1 = __nccwpck_require__(34069);
7530
+ const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
7275
7531
  const database_1 = __nccwpck_require__(28206);
7276
- const jobName_1 = __nccwpck_require__(9626);
7277
7532
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
7278
7533
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
7279
7534
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
@@ -7329,7 +7584,11 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
7329
7584
  const jobTriggers = deployConfigRaw && deployConfigRaw.jobs
7330
7585
  ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(([name, job]) => [
7331
7586
  "CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name),
7332
- `https://${deployConfigRaw.region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${deployConfigRaw.projectId}/jobs/${(0, jobName_1.getCloudRunJobName)(fullName, name)}:run`,
7587
+ (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(name, {
7588
+ appFullName: fullName,
7589
+ projectId: deployConfigRaw.projectId,
7590
+ region: deployConfigRaw.region,
7591
+ }),
7333
7592
  ]))
7334
7593
  : {};
7335
7594
  return {
@@ -7349,6 +7608,24 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
7349
7608
 
7350
7609
  /***/ }),
7351
7610
 
7611
+ /***/ 24856:
7612
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7613
+
7614
+ "use strict";
7615
+
7616
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7617
+ exports.getCloudRunJobExecuteUrl = void 0;
7618
+ const jobName_1 = __nccwpck_require__(9626);
7619
+ function getCloudRunJobExecuteUrl(jobName, { region, projectId, appFullName, }) {
7620
+ const uriBase = `https://${region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${projectId}/jobs`;
7621
+ const fullJobName = (0, jobName_1.getCloudRunJobName)(appFullName, jobName);
7622
+ return `${uriBase}/${fullJobName}:run`;
7623
+ }
7624
+ exports.getCloudRunJobExecuteUrl = getCloudRunJobExecuteUrl;
7625
+ //# sourceMappingURL=cloudRunExecutionUrl.js.map
7626
+
7627
+ /***/ }),
7628
+
7352
7629
  /***/ 49598:
7353
7630
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7354
7631
 
@@ -7483,9 +7760,15 @@ exports.getServiceName = getServiceName;
7483
7760
  "use strict";
7484
7761
 
7485
7762
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7486
- exports.getCloudRunJobName = void 0;
7763
+ exports.getFullSchedulerName = exports.getCloudRunSchedulerName = exports.getFullJobName = exports.getCloudRunJobName = void 0;
7487
7764
  const getCloudRunJobName = (fullAppName, jobName) => fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
7488
7765
  exports.getCloudRunJobName = getCloudRunJobName;
7766
+ const getFullJobName = (context, name) => (0, exports.getCloudRunJobName)(context.environment.fullName, name);
7767
+ exports.getFullJobName = getFullJobName;
7768
+ const getCloudRunSchedulerName = (fullAppName, schedulerName) => fullAppName.toLowerCase().concat("-" + schedulerName.toLowerCase());
7769
+ exports.getCloudRunSchedulerName = getCloudRunSchedulerName;
7770
+ const getFullSchedulerName = (context, name) => (0, exports.getCloudRunSchedulerName)(context.environment.fullName, name);
7771
+ exports.getFullSchedulerName = getFullSchedulerName;
7489
7772
  //# sourceMappingURL=jobName.js.map
7490
7773
 
7491
7774
  /***/ }),
@@ -8256,7 +8539,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
8256
8539
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
8257
8540
  };
8258
8541
  Object.defineProperty(exports, "__esModule", ({ value: true }));
8259
- exports.isOfDeployType = void 0;
8542
+ exports.getDeployConfigType = exports.isOfDeployType = void 0;
8260
8543
  __exportStar(__nccwpck_require__(30461), exports);
8261
8544
  __exportStar(__nccwpck_require__(66938), exports);
8262
8545
  __exportStar(__nccwpck_require__(60835), exports);
@@ -8265,6 +8548,12 @@ const isOfDeployType = (t, ...types) => {
8265
8548
  return t && types.includes(t.type) ? true : false;
8266
8549
  };
8267
8550
  exports.isOfDeployType = isOfDeployType;
8551
+ const getDeployConfigType = (t) => {
8552
+ if (!t)
8553
+ return undefined;
8554
+ return t.type;
8555
+ };
8556
+ exports.getDeployConfigType = getDeployConfigType;
8268
8557
  //# sourceMappingURL=index.js.map
8269
8558
 
8270
8559
  /***/ }),