@catladder/cli 0.0.0-main-99d0da33 → 0.0.0-main-ca4b8550

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 (36) hide show
  1. package/dist/bundles/catenv/index.js +304 -119
  2. package/dist/bundles/cli/index.js +296 -116
  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/pipeline/src/bash/bashEscape.d.ts +4 -1
  9. package/dist/pipeline/src/bash/bashEscape.js +4 -2
  10. package/dist/pipeline/src/bash/bashEscape.js.map +1 -1
  11. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +5 -3
  12. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +16 -105
  13. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
  14. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +4 -0
  15. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js +85 -0
  16. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js.map +1 -0
  17. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.d.ts +3 -0
  18. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +136 -0
  19. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -0
  20. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +5 -3
  21. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
  22. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +5 -3
  23. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js.map +1 -1
  24. package/dist/pipeline/src/deploy/cloudRun/index.js +6 -2
  25. package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
  26. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.d.ts +6 -0
  27. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js +11 -0
  28. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js.map +1 -0
  29. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.d.ts +5 -1
  30. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js +7 -1
  31. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js.map +1 -1
  32. package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +95 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +1 -1
  35. package/src/apps/catenv/printVariables.ts +4 -1
  36. package/src/apps/catenv/utils.ts +12 -3
@@ -3896,14 +3896,16 @@ exports.escapeSingleQuotes = escapeSingleQuotes;
3896
3896
  *
3897
3897
  * - other languages are currently only partially supported, since most .env implementations are slightly different
3898
3898
  */
3899
- const escapeForDotEnv = (value) => {
3899
+ const escapeForDotEnv = (value, options = {
3900
+ quoteMode: "auto",
3901
+ }) => {
3900
3902
  if (value === undefined || value === null) {
3901
3903
  return "";
3902
3904
  }
3903
3905
  if (typeof value === "string") {
3904
3906
  // if string contains newlines, we need to wrap it in quotes
3905
3907
  // we additionaly escape newlines, that give best compatibility
3906
- if (value.includes("\n")) {
3908
+ if (options.quoteMode === "always" || value.includes("\n")) {
3907
3909
  const newlinesReplaces = value.replace(/\n/g, "\\n");
3908
3910
  // default to ", but if this is not possible, we try to use ' or `
3909
3911
  const quote = value.includes(`"`)
@@ -6778,62 +6780,27 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
6778
6780
  "use strict";
6779
6781
 
6780
6782
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6781
- exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
6783
+ exports.getCloudRunJobsWithNames = exports.getJobCreateScripts = exports.getDeleteJobsScripts = void 0;
6784
+ const getLabels_1 = __nccwpck_require__(30920);
6785
+ const utils_1 = __nccwpck_require__(32497);
6782
6786
  const createArgsString_1 = __nccwpck_require__(49598);
6783
6787
  const jobName_1 = __nccwpck_require__(9626);
6784
6788
  const common_1 = __nccwpck_require__(73325);
6785
- const getLabels_1 = __nccwpck_require__(30920);
6786
- const volumes_1 = __nccwpck_require__(60847);
6787
6789
  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;
6790
+ const volumes_1 = __nccwpck_require__(60847);
6791
+ const onDeploy_1 = __nccwpck_require__(2358);
6808
6792
  const getDeleteJobsScripts = (context) => {
6809
6793
  const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
6810
6794
  const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
6811
- const jobsWithNames = getCloudRunJobsWithNames(context);
6812
- return jobsWithNames.flatMap(({ jobName }) => [
6795
+ const jobsWithNames = (0, exports.getCloudRunJobsWithNames)(context);
6796
+ return jobsWithNames.flatMap(({ fullJobName }) => [
6813
6797
  // 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}`,
6798
+ `${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${fullJobName} --format="value(name)" | xargs -I {} ${(0, common_1.gcloudRunCmd)()} jobs executions delete {} --quiet ${commonArgsString}`,
6799
+ `${(0, common_1.gcloudRunCmd)()} jobs delete ${fullJobName} ${commonArgsString}`,
6816
6800
  ]);
6817
6801
  };
6818
6802
  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) => {
6803
+ const getJobCreateScripts = (context) => (0, exports.getCloudRunJobsWithNames)(context).map(({ job, fullJobName }, jobIndex) => {
6837
6804
  var _a, _b, _c, _d;
6838
6805
  const commandArray = Array.isArray(job.command)
6839
6806
  ? job.command
@@ -6841,6 +6808,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6841
6808
  const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
6842
6809
  const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
6843
6810
  command: `"${commandArray.join(",")}"`,
6811
+ args: (0, onDeploy_1.getCloudRunJobArgsArg)(job.args),
6844
6812
  labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
6845
6813
  image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
6846
6814
  project,
@@ -6862,7 +6830,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6862
6830
  jobIndex === 0
6863
6831
  ? `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
6832
  : null,
6865
- `current_job_name="${jobName}"`,
6833
+ `current_job_name="${fullJobName}"`,
6866
6834
  'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then',
6867
6835
  ` ${(0, common_1.gcloudRunCmd)()} jobs update "$current_job_name" ${commonDeployArgsString}`,
6868
6836
  "else",
@@ -6873,75 +6841,20 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6873
6841
  .join("\n");
6874
6842
  });
6875
6843
  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
6844
  const getCloudRunJobsWithNames = (context) => {
6932
6845
  var _a;
6933
6846
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
6934
- const getFullJobName = (name) => (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
6935
6847
  const jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
6936
6848
  // filter out disabled jobs
6937
6849
  .filter((entry) => Boolean(entry[1]))
6938
- .map(([jobKey, job]) => ({
6939
- jobName: getFullJobName(jobKey),
6850
+ .map(([jobName, job]) => ({
6851
+ fullJobName: (0, jobName_1.getFullJobName)(context, jobName),
6940
6852
  job,
6941
- jobKey,
6853
+ jobName,
6942
6854
  }));
6943
6855
  return jobsWithNames;
6944
6856
  };
6857
+ exports.getCloudRunJobsWithNames = getCloudRunJobsWithNames;
6945
6858
  //# sourceMappingURL=cloudRunJobs.js.map
6946
6859
 
6947
6860
  /***/ }),
@@ -7093,6 +7006,241 @@ exports.ENV_VARS_FILENAME = "____envvars.yaml";
7093
7006
 
7094
7007
  /***/ }),
7095
7008
 
7009
+ /***/ 2358:
7010
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7011
+
7012
+ "use strict";
7013
+
7014
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7015
+ exports.getCloudRunJobArgsArg = exports.getOnDeployExecuteScript = void 0;
7016
+ const createArgsString_1 = __nccwpck_require__(49598);
7017
+ const jobName_1 = __nccwpck_require__(9626);
7018
+ const cloudRunJobs_1 = __nccwpck_require__(61224);
7019
+ const common_1 = __nccwpck_require__(73325);
7020
+ const getOnDeployExecuteScript = (context, when) => {
7021
+ const executes = getExecutes(context);
7022
+ return executes
7023
+ .filter(({ config }) => config.when === when)
7024
+ .map((execute) => {
7025
+ return getJobRunScriptForExecute(context, execute);
7026
+ });
7027
+ };
7028
+ exports.getOnDeployExecuteScript = getOnDeployExecuteScript;
7029
+ const getExecutes = (context) => {
7030
+ var _a;
7031
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7032
+ return [
7033
+ ...getLegacyExecutes(context),
7034
+ ...Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
7035
+ if (!value || (value.when !== "schedule" && value.type !== "job")) {
7036
+ return [];
7037
+ }
7038
+ return [
7039
+ {
7040
+ jobName: key,
7041
+ config: value,
7042
+ },
7043
+ ];
7044
+ }),
7045
+ ];
7046
+ };
7047
+ const getLegacyExecutes = (context) => {
7048
+ const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
7049
+ return jobsWithNames.flatMap(({ jobName, job }) => {
7050
+ if (!job.when ||
7051
+ !["preDeploy", "postDeploy", "preStop", "postStop"].includes(job.when)) {
7052
+ return [];
7053
+ }
7054
+ return [
7055
+ {
7056
+ jobName,
7057
+ config: {
7058
+ job: jobName,
7059
+ type: "job",
7060
+ when: job.when,
7061
+ ...(job.when === "preDeploy" || job.when === "postDeploy"
7062
+ ? {
7063
+ waitForCompletion: job.waitForCompletion,
7064
+ }
7065
+ : {}),
7066
+ },
7067
+ },
7068
+ ];
7069
+ });
7070
+ };
7071
+ const getJobRunScriptForExecute = (context, { jobName, config }) => {
7072
+ var _a;
7073
+ const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
7074
+ // always wait for completion for preStop and postStop jobs
7075
+ // since stop will delete the jobs afterwards, so they will fail
7076
+ const waitForCompletion = ["preStop", "postStop"].includes(config.when)
7077
+ ? true // always
7078
+ : "waitForCompletion" in config
7079
+ ? ((_a = config.waitForCompletion) !== null && _a !== void 0 ? _a : false) // depends on config
7080
+ : false;
7081
+ const argString = (0, createArgsString_1.createArgsString)({
7082
+ ...commonArgs,
7083
+ wait: waitForCompletion === true ? true : undefined,
7084
+ args: (0, exports.getCloudRunJobArgsArg)(config.args),
7085
+ });
7086
+ const fullJobName = (0, jobName_1.getFullJobName)(context, jobName);
7087
+ return `${(0, common_1.gcloudRunCmd)()} jobs execute ${fullJobName.toString()} ${argString}`;
7088
+ };
7089
+ const getCloudRunJobArgsArg = (args) => {
7090
+ return args !== undefined
7091
+ ? args.length > 0
7092
+ ? args === null || args === void 0 ? void 0 : args.map((arg) => `"${arg}"`).join(",")
7093
+ : ""
7094
+ : undefined;
7095
+ };
7096
+ exports.getCloudRunJobArgsArg = getCloudRunJobArgsArg;
7097
+ //# sourceMappingURL=onDeploy.js.map
7098
+
7099
+ /***/ }),
7100
+
7101
+ /***/ 3697:
7102
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7103
+
7104
+ "use strict";
7105
+
7106
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7107
+ exports.getCreateScheduleScript = exports.getDeleteSchedulesScript = void 0;
7108
+ const bash_1 = __nccwpck_require__(22990);
7109
+ const utils_1 = __nccwpck_require__(32497);
7110
+ const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
7111
+ const createArgsString_1 = __nccwpck_require__(49598);
7112
+ const jobName_1 = __nccwpck_require__(9626);
7113
+ const cloudRunJobs_1 = __nccwpck_require__(61224);
7114
+ const common_1 = __nccwpck_require__(73325);
7115
+ const getDeleteSchedulesScript = (context) => {
7116
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7117
+ const schedules = getSchedules(context);
7118
+ const argsString = (0, createArgsString_1.createArgsString)({
7119
+ project: deployConfig.projectId,
7120
+ location: deployConfig.region,
7121
+ });
7122
+ return schedules
7123
+ .map(({ fullName }) => {
7124
+ return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${fullName} ${argsString}`];
7125
+ })
7126
+ .flat();
7127
+ };
7128
+ exports.getDeleteSchedulesScript = getDeleteSchedulesScript;
7129
+ const getCreateScheduleScript = (context) => {
7130
+ const schedules = getSchedules(context);
7131
+ const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
7132
+ return schedules.map(({ fullName, config }, jobIndex) => {
7133
+ var _a;
7134
+ const { uri, ...args } = getSchedulerArgs(config, context);
7135
+ const argsString = (0, createArgsString_1.createArgsString)({
7136
+ project,
7137
+ location,
7138
+ uri: `"$current_job_uri"`,
7139
+ ...args,
7140
+ schedule: `"${config.schedule}"`,
7141
+ "max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
7142
+ });
7143
+ return [
7144
+ jobIndex === 0
7145
+ ? `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)"`
7146
+ : null,
7147
+ `current_job_uri="${uri}"`,
7148
+ `current_scheduler_name="${fullName}"`,
7149
+ `if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
7150
+ ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
7151
+ `else`,
7152
+ ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
7153
+ `fi`,
7154
+ ]
7155
+ .filter(utils_1.notNil)
7156
+ .join("\n");
7157
+ });
7158
+ };
7159
+ exports.getCreateScheduleScript = getCreateScheduleScript;
7160
+ const getSchedulerArgs = (scheduler, context) => {
7161
+ var _a;
7162
+ if (scheduler.type === "job") {
7163
+ const { projectId, region } = (0, common_1.getCloudRunDeployConfig)(context);
7164
+ const body = scheduler.args !== undefined
7165
+ ? {
7166
+ overrides: {
7167
+ containerOverrides: [
7168
+ ((_a = scheduler.args) === null || _a === void 0 ? void 0 : _a.length) > 0
7169
+ ? {
7170
+ args: scheduler.args,
7171
+ }
7172
+ : {
7173
+ args: [],
7174
+ clearArgs: true, // not sure why this is neeeded, but it is
7175
+ },
7176
+ ],
7177
+ },
7178
+ }
7179
+ : null;
7180
+ return {
7181
+ uri: (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(scheduler.job, {
7182
+ appFullName: context.environment.fullName,
7183
+ projectId,
7184
+ region,
7185
+ }),
7186
+ "message-body": body
7187
+ ? '"' + (0, bash_1.bashEscape)(JSON.stringify(body)) + '"'
7188
+ : undefined,
7189
+ "http-method": "POST",
7190
+ "oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
7191
+ };
7192
+ }
7193
+ if (scheduler.type === "http") {
7194
+ return {
7195
+ uri: scheduler.url,
7196
+ "message-body": scheduler.body,
7197
+ "http-method": scheduler.method,
7198
+ "oidc-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
7199
+ };
7200
+ }
7201
+ throw new Error(`Unknown scheduler type: ${scheduler.type}`);
7202
+ };
7203
+ const getSchedules = (context) => {
7204
+ const legacyScheduleJobs = getLegacyJobSchedules(context);
7205
+ const schedules = getScheduledExecutes(context);
7206
+ return Object.entries({ ...legacyScheduleJobs, ...schedules }).map(([name, config]) => ({
7207
+ name,
7208
+ fullName: (0, jobName_1.getFullSchedulerName)(context, name),
7209
+ config,
7210
+ }));
7211
+ };
7212
+ const getLegacyJobSchedules = (context) => {
7213
+ const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
7214
+ return Object.fromEntries(jobsWithNames
7215
+ .filter((entry) => entry.job.when === "schedule")
7216
+ .map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
7217
+ const schedulerName = jobName.concat("-scheduler");
7218
+ return [
7219
+ schedulerName,
7220
+ {
7221
+ type: "job",
7222
+ job: jobName,
7223
+ maxRetryAttempts,
7224
+ schedule,
7225
+ when: "schedule",
7226
+ },
7227
+ ];
7228
+ }));
7229
+ };
7230
+ const getScheduledExecutes = (context) => {
7231
+ var _a;
7232
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7233
+ return Object.fromEntries(Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
7234
+ if (!value || value.when !== "schedule") {
7235
+ return [];
7236
+ }
7237
+ return [[key, value]];
7238
+ }));
7239
+ };
7240
+ //# sourceMappingURL=schedules.js.map
7241
+
7242
+ /***/ }),
7243
+
7096
7244
  /***/ 53695:
7097
7245
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7098
7246
 
@@ -7109,9 +7257,11 @@ const cleanup_1 = __nccwpck_require__(67888);
7109
7257
  const database_1 = __nccwpck_require__(28206);
7110
7258
  const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
7111
7259
  const cloudRunJobs_1 = __nccwpck_require__(61224);
7260
+ const onDeploy_1 = __nccwpck_require__(2358);
7112
7261
  const cloudRunServices_1 = __nccwpck_require__(17334);
7113
7262
  const common_1 = __nccwpck_require__(73325);
7114
7263
  const constants_1 = __nccwpck_require__(38865);
7264
+ const schedules_1 = __nccwpck_require__(3697);
7115
7265
  function getCloudRunDeployScripts(context) {
7116
7266
  var _a;
7117
7267
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
@@ -7126,14 +7276,14 @@ function getCloudRunDeployScripts(context) {
7126
7276
  ...(deployConfig.cloudSql
7127
7277
  ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
7128
7278
  : []),
7129
- ...(0, cloudRunJobs_1.getCreateScheduleScripts)(context),
7279
+ ...(0, schedules_1.getCreateScheduleScript)(context),
7130
7280
  ...(0, cloudRunJobs_1.getJobCreateScripts)(context),
7131
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "preDeploy"),
7281
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preDeploy"),
7132
7282
  ...(deployConfig.service !== false
7133
7283
  ? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)]
7134
7284
  : []),
7135
7285
  ...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"),
7286
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postDeploy"),
7137
7287
  ]),
7138
7288
  ...(0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy")),
7139
7289
  ...(0, sbom_1.getDependencyTrackUploadScript)(context),
@@ -7156,6 +7306,8 @@ const cleanup_1 = __nccwpck_require__(67888);
7156
7306
  const database_1 = __nccwpck_require__(28206);
7157
7307
  const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
7158
7308
  const cloudRunJobs_1 = __nccwpck_require__(61224);
7309
+ const onDeploy_1 = __nccwpck_require__(2358);
7310
+ const schedules_1 = __nccwpck_require__(3697);
7159
7311
  const cloudRunServices_1 = __nccwpck_require__(17334);
7160
7312
  const common_1 = __nccwpck_require__(73325);
7161
7313
  function getCloudRunStopScripts(context) {
@@ -7163,11 +7315,11 @@ function getCloudRunStopScripts(context) {
7163
7315
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7164
7316
  return [
7165
7317
  ...(0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context),
7166
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "preStop"),
7318
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop"),
7167
7319
  ...(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []),
7168
7320
  ...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),
7321
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postStop"),
7322
+ ...(0, schedules_1.getDeleteSchedulesScript)(context),
7171
7323
  ...(0, cloudRunJobs_1.getDeleteJobsScripts)(context),
7172
7324
  ...(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop
7173
7325
  ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig)
@@ -7272,8 +7424,8 @@ const context_1 = __nccwpck_require__(5875);
7272
7424
  const gitlab_1 = __nccwpck_require__(38490);
7273
7425
  const utils_1 = __nccwpck_require__(62089);
7274
7426
  const createJobs_1 = __nccwpck_require__(34069);
7427
+ const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
7275
7428
  const database_1 = __nccwpck_require__(28206);
7276
- const jobName_1 = __nccwpck_require__(9626);
7277
7429
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
7278
7430
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
7279
7431
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
@@ -7329,7 +7481,11 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
7329
7481
  const jobTriggers = deployConfigRaw && deployConfigRaw.jobs
7330
7482
  ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(([name, job]) => [
7331
7483
  "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`,
7484
+ (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(name, {
7485
+ appFullName: fullName,
7486
+ projectId: deployConfigRaw.projectId,
7487
+ region: deployConfigRaw.region,
7488
+ }),
7333
7489
  ]))
7334
7490
  : {};
7335
7491
  return {
@@ -7349,6 +7505,24 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
7349
7505
 
7350
7506
  /***/ }),
7351
7507
 
7508
+ /***/ 24856:
7509
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7510
+
7511
+ "use strict";
7512
+
7513
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7514
+ exports.getCloudRunJobExecuteUrl = void 0;
7515
+ const jobName_1 = __nccwpck_require__(9626);
7516
+ function getCloudRunJobExecuteUrl(jobName, { region, projectId, appFullName, }) {
7517
+ const uriBase = `https://${region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${projectId}/jobs`;
7518
+ const fullJobName = (0, jobName_1.getCloudRunJobName)(appFullName, jobName);
7519
+ return `${uriBase}/${fullJobName}:run`;
7520
+ }
7521
+ exports.getCloudRunJobExecuteUrl = getCloudRunJobExecuteUrl;
7522
+ //# sourceMappingURL=cloudRunExecutionUrl.js.map
7523
+
7524
+ /***/ }),
7525
+
7352
7526
  /***/ 49598:
7353
7527
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7354
7528
 
@@ -7483,9 +7657,15 @@ exports.getServiceName = getServiceName;
7483
7657
  "use strict";
7484
7658
 
7485
7659
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7486
- exports.getCloudRunJobName = void 0;
7660
+ exports.getFullSchedulerName = exports.getCloudRunSchedulerName = exports.getFullJobName = exports.getCloudRunJobName = void 0;
7487
7661
  const getCloudRunJobName = (fullAppName, jobName) => fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
7488
7662
  exports.getCloudRunJobName = getCloudRunJobName;
7663
+ const getFullJobName = (context, name) => (0, exports.getCloudRunJobName)(context.environment.fullName, name);
7664
+ exports.getFullJobName = getFullJobName;
7665
+ const getCloudRunSchedulerName = (fullAppName, schedulerName) => fullAppName.toLowerCase().concat("-" + schedulerName.toLowerCase());
7666
+ exports.getCloudRunSchedulerName = getCloudRunSchedulerName;
7667
+ const getFullSchedulerName = (context, name) => (0, exports.getCloudRunSchedulerName)(context.environment.fullName, name);
7668
+ exports.getFullSchedulerName = getFullSchedulerName;
7489
7669
  //# sourceMappingURL=jobName.js.map
7490
7670
 
7491
7671
  /***/ }),
@@ -42,5 +42,8 @@ const printVariables = async (config, choice) => {
42
42
  console.log(makeExportKeyValuestring(variables));
43
43
  };
44
44
  exports.printVariables = printVariables;
45
- const makeExportKeyValuestring = (variables) => (0, utils_1.makeKeyValueString)(variables, "export ");
45
+ const makeExportKeyValuestring = (variables) => (0, utils_1.makeKeyValueString)(variables, {
46
+ keyPrefix: "export ",
47
+ escapeOptions: { quoteMode: "always" },
48
+ });
46
49
  //# sourceMappingURL=printVariables.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"printVariables.js","sourceRoot":"","sources":["../../../../../src/apps/catenv/printVariables.ts"],"names":[],"mappings":";;;AACA,oEAAmE;AAEnE,mCAIiB;AAEjB,MAAM,sBAAsB,GAAG,KAAK,EAAE,MAAc,EAAE,MAAe,EAAE,EAAE;;IACvE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,2CAAmC,EACzE,MAAM,EACN,MAAM,CACP,CAAC;IAEF,IAAI,gBAAgB,EAAE,CAAC;QACrB,wCAAwC;QACxC,IAAI,MAAA,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,MAAM,mCAAI,IAAI,EAAE,CAAC;YACvD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,MAAM,IAAA,qCAAkB,EAAC,IAAI,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,6DAA6D;QAC7D,0EAA0E;QAC1E,mCAAmC;QACnC,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAChD,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE;;YAC3B,wCAAwC;YACxC,IAAI,MAAA,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,MAAM,mCAAI,IAAI,EAAE,CAAC;gBACpD,OAAO,MAAM,GAAG,CAAC;YACnB,CAAC;YACD,MAAM,UAAU,GAAG,MAAM,IAAA,qCAAkB,EAAC,IAAI,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;YACtE,OAAO,UAAU,CAAC,mBAAmB,CAAC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,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB;AAEF,MAAM,wBAAwB,GAAG,CAAC,SAAiC,EAAE,EAAE,CACrE,IAAA,0BAAkB,EAAC,SAAS,EAAE;IAC5B,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;CACvC,CAAC,CAAC"}
@@ -1,9 +1,13 @@
1
- import type { Config } from "../../../../pipeline/src/index.js";
1
+ import type { Config, EscapeForDotEnvOptions } from "../../../../pipeline/src/index.js";
2
2
  import type { Choice } from "./types";
3
3
  export declare const getComponentFullPath: (gitRoot: string, config: Config, componentName: string) => string;
4
4
  export declare const getCurrentComponentAndEnvFromChoice: (config: Config, choice?: Choice) => Promise<{
5
5
  currentComponent: string;
6
6
  env: string;
7
7
  }>;
8
- export declare const makeKeyValueString: (variables: Record<string, string>, keyPrefix?: string) => string;
8
+ export type MakeKeyValueStringOptions = {
9
+ keyPrefix?: string;
10
+ escapeOptions?: EscapeForDotEnvOptions;
11
+ };
12
+ export declare const makeKeyValueString: (variables: Record<string, string>, { keyPrefix, escapeOptions }?: MakeKeyValueStringOptions) => string;
9
13
  export declare const sanitizeEnvVarName: (name: string) => string;
@@ -23,9 +23,11 @@ const getCurrentComponentAndEnvFromChoice = async (config, choice) => {
23
23
  };
24
24
  };
25
25
  exports.getCurrentComponentAndEnvFromChoice = getCurrentComponentAndEnvFromChoice;
26
- const makeKeyValueString = (variables, keyPrefix = "") => Object.entries(variables)
26
+ const makeKeyValueString = (variables, { keyPrefix, escapeOptions } = {
27
+ keyPrefix: "",
28
+ }) => Object.entries(variables)
27
29
  // quotes are important, otherwise line breaks don't work properly
28
- .map(([key, value]) => `${keyPrefix}${key}=${(0, pipeline_1.escapeForDotEnv)(value)}`)
30
+ .map(([key, value]) => `${keyPrefix}${key}=${(0, pipeline_1.escapeForDotEnv)(value, escapeOptions)}`)
29
31
  .join("\n");
30
32
  exports.makeKeyValueString = makeKeyValueString;
31
33
  const sanitizeEnvVarName = (name) => name.replace(/[\s\-.]+/g, "_");
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/apps/catenv/utils.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAC5B,mDAAkD;AAElD,kDAAsD;AAC/C,MAAM,oBAAoB,GAAG,CAClC,OAAe,EACf,MAAc,EACd,aAAqB,EACrB,EAAE;IACF,OAAO,IAAA,WAAI,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC;AAC7D,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B;AACF,MAAM,uBAAuB,GAAG,KAAK,EAAE,MAAc,EAAE,EAAE;IACvD,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAU,GAAE,CAAC;IACnC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/C,UAAU,CAAC,UAAU,CAAC,IAAA,4BAAoB,EAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAChE,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,mCAAmC,GAAG,KAAK,EACtD,MAAc,EACd,MAAe,EACf,EAAE;;IACF,MAAM,GAAG,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,OAAO,CAAC;IACnC,MAAM,gBAAgB,GACpB,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,mCAAI,CAAC,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnE,OAAO;QACL,gBAAgB;QAChB,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,mCAAmC,uCAY9C;AAEK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AG,KAAK,EACtD,MAAc,EACd,MAAe,EACf,EAAE;;IACF,MAAM,GAAG,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,OAAO,CAAC;IACnC,MAAM,gBAAgB,GACpB,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,mCAAI,CAAC,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnE,OAAO;QACL,gBAAgB;QAChB,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,mCAAmC,uCAY9C;AAMK,MAAM,kBAAkB,GAAG,CAChC,SAAiC,EACjC,EAAE,SAAS,EAAE,aAAa,KAAgC;IACxD,SAAS,EAAE,EAAE;CACd,EACD,EAAE,CACF,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,kEAAkE;KACjE,GAAG,CACF,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,GAAG,SAAS,GAAG,GAAG,IAAI,IAAA,0BAAe,EAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAChE;KACA,IAAI,CAAC,IAAI,CAAC,CAAC;AAZH,QAAA,kBAAkB,sBAYf;AAET,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CACjD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AADpB,QAAA,kBAAkB,sBACE"}
@@ -13,6 +13,9 @@ export declare const escapeString: (value: string | null | undefined, { quotes }
13
13
  export declare const escapeBashExpression: (value: BashExpression, options: EscapeOptions) => BashExpression;
14
14
  export declare const escapeDoubleQuotes: (value: string | null | undefined) => string;
15
15
  export declare const escapeSingleQuotes: (value: string | null | undefined) => string;
16
+ export type EscapeForDotEnvOptions = {
17
+ quoteMode: "auto" | "always";
18
+ };
16
19
  /**
17
20
  *
18
21
  * escape env vars for .env files.
@@ -29,4 +32,4 @@ export declare const escapeSingleQuotes: (value: string | null | undefined) => s
29
32
  *
30
33
  * - other languages are currently only partially supported, since most .env implementations are slightly different
31
34
  */
32
- export declare const escapeForDotEnv: (value: VariableValue | undefined | null) => string;
35
+ export declare const escapeForDotEnv: (value: VariableValue | undefined | null, options?: EscapeForDotEnvOptions) => string;
@@ -57,14 +57,16 @@ exports.escapeSingleQuotes = escapeSingleQuotes;
57
57
  *
58
58
  * - other languages are currently only partially supported, since most .env implementations are slightly different
59
59
  */
60
- const escapeForDotEnv = (value) => {
60
+ const escapeForDotEnv = (value, options = {
61
+ quoteMode: "auto",
62
+ }) => {
61
63
  if (value === undefined || value === null) {
62
64
  return "";
63
65
  }
64
66
  if (typeof value === "string") {
65
67
  // if string contains newlines, we need to wrap it in quotes
66
68
  // we additionaly escape newlines, that give best compatibility
67
- if (value.includes("\n")) {
69
+ if (options.quoteMode === "always" || value.includes("\n")) {
68
70
  const newlinesReplaces = value.replace(/\n/g, "\\n");
69
71
  // default to ", but if this is not possible, we try to use ' or `
70
72
  const quote = value.includes(`"`)