@catladder/cli 0.0.0-next-c3a49baf → 0.0.0-next-5f70052e

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.
@@ -774,6 +774,9 @@ class BashExpression {
774
774
  toString() {
775
775
  return this.value.toString();
776
776
  }
777
+ replace(searchValue, replacer) {
778
+ return new BashExpression(this.value.toString().replace(searchValue, replacer));
779
+ }
777
780
  /**
778
781
  *
779
782
  * @returns a bash expression to lowercase the string
@@ -941,15 +944,12 @@ const BashExpression_1 = __nccwpck_require__(2376);
941
944
  // and adjusted a bit
942
945
  async function replaceAsync(string, searchValue, replacer) {
943
946
  const wasBashExpression = string instanceof BashExpression_1.BashExpression;
944
- const stringRepresentation = wasBashExpression
945
- ? string.toString()
946
- : (0, BashExpression_1.bashEscape)(string);
947
947
  try {
948
948
  // 1. Run fake pass of `replace`, collect values from `replacer` calls
949
949
  // 2. Resolve them with `Promise.all`
950
950
  // 3. Run `replace` with resolved values
951
951
  const values = [];
952
- String.prototype.replace.call(stringRepresentation, searchValue, function (...args) {
952
+ String.prototype.replace.call(string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string), searchValue, function (...args) {
953
953
  // eslint-disable-next-line prefer-spread
954
954
  const result = replacer.apply(undefined, args);
955
955
  values.push(result);
@@ -957,7 +957,7 @@ async function replaceAsync(string, searchValue, replacer) {
957
957
  });
958
958
  const resolvedValues = await Promise.all(values);
959
959
  const containsBashExpression = resolvedValues.some((value) => value instanceof BashExpression_1.BashExpression);
960
- const result = String.prototype.replace.call(stringRepresentation, searchValue, function () {
960
+ const result = (string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string)).replace(searchValue, function () {
961
961
  var _a, _b;
962
962
  return (_b = (_a = resolvedValues.shift()) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "";
963
963
  });
@@ -5219,6 +5219,38 @@ exports.contextIsStoppable = contextIsStoppable;
5219
5219
 
5220
5220
  /***/ }),
5221
5221
 
5222
+ /***/ 2912:
5223
+ /***/ ((__unused_webpack_module, exports) => {
5224
+
5225
+ "use strict";
5226
+
5227
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5228
+ exports.COLLAPSEABLE_SECTION_END = exports.COLLAPSEABLE_SECTION_START = void 0;
5229
+ class GlobalScriptFunction {
5230
+ constructor(name, script) {
5231
+ this.name = name;
5232
+ this.script = script;
5233
+ }
5234
+ toBashFunction() {
5235
+ return `function ${this.name} () {
5236
+ ${this.script}
5237
+ }`;
5238
+ }
5239
+ invoke(...args) {
5240
+ return `${this.name} ${args.join(" ")}`;
5241
+ }
5242
+ }
5243
+ exports.COLLAPSEABLE_SECTION_START = new GlobalScriptFunction("collapseable_section_start", `local section_title="\${1}"
5244
+ local section_description="\${2:-$section_title}"
5245
+ echo -e "section_start:\`date +%s\`:\${section_title}[collapsed=true]\\r\\e[0K$\{section_description}"
5246
+ `);
5247
+ exports.COLLAPSEABLE_SECTION_END = new GlobalScriptFunction("collapseable_section_end", `local section_title="\${1}"
5248
+ echo -e "section_end:\`date +%s\`:\${section_title}\\r\\e[0K"
5249
+ `);
5250
+ //# sourceMappingURL=index.js.map
5251
+
5252
+ /***/ }),
5253
+
5222
5254
  /***/ 603:
5223
5255
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5224
5256
 
@@ -5838,14 +5870,38 @@ function getGitlabNeedsForWorkspaceJob(context, { needsStages, needs }, allJobs)
5838
5870
  /***/ }),
5839
5871
 
5840
5872
  /***/ 6551:
5841
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5873
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5842
5874
 
5843
5875
  "use strict";
5844
5876
 
5877
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5878
+ if (k2 === undefined) k2 = k;
5879
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5880
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5881
+ desc = { enumerable: true, get: function() { return m[k]; } };
5882
+ }
5883
+ Object.defineProperty(o, k2, desc);
5884
+ }) : (function(o, m, k, k2) {
5885
+ if (k2 === undefined) k2 = k;
5886
+ o[k2] = m[k];
5887
+ }));
5888
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
5889
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
5890
+ }) : function(o, v) {
5891
+ o["default"] = v;
5892
+ });
5893
+ var __importStar = (this && this.__importStar) || function (mod) {
5894
+ if (mod && mod.__esModule) return mod;
5895
+ var result = {};
5896
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
5897
+ __setModuleDefault(result, mod);
5898
+ return result;
5899
+ };
5845
5900
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5846
5901
  exports.createGitlabPipelineWithDefaults = void 0;
5847
5902
  const runner_1 = __nccwpck_require__(4058);
5848
- const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
5903
+ const GLOBAL_SCRIPTS = __importStar(__nccwpck_require__(2912));
5904
+ const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...config }) => {
5849
5905
  return {
5850
5906
  image: image !== null && image !== void 0 ? image : (0, runner_1.getRunnerImage)("jobs-default"), // default image
5851
5907
  variables: {
@@ -5856,6 +5912,10 @@ const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
5856
5912
  GIT_DEPTH: "1", // no need the full depth
5857
5913
  ...(variables !== null && variables !== void 0 ? variables : {}),
5858
5914
  },
5915
+ before_script: [
5916
+ ...Object.values(GLOBAL_SCRIPTS).map((script) => script.toBashFunction()),
5917
+ ...(before_script !== null && before_script !== void 0 ? before_script : []),
5918
+ ],
5859
5919
  ...config,
5860
5920
  };
5861
5921
  };
@@ -6388,12 +6448,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
6388
6448
  /***/ }),
6389
6449
 
6390
6450
  /***/ 8490:
6391
- /***/ ((__unused_webpack_module, exports) => {
6451
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6392
6452
 
6393
6453
  "use strict";
6394
6454
 
6395
6455
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6396
6456
  exports.collapseableSection = exports.repeatOnFailure = exports.sanitizeForBashVariable = exports.allowFailureInScripts = void 0;
6457
+ const globalScriptFunctions_1 = __nccwpck_require__(2912);
6397
6458
  const allowFailureInScripts = (script) => [
6398
6459
  "set +e", // disable fail job on error
6399
6460
  ...script,
@@ -6414,9 +6475,9 @@ const repeatOnFailure = (command, options) => {
6414
6475
  exports.repeatOnFailure = repeatOnFailure;
6415
6476
  const collapseableSection = (name, header) => (commands) => {
6416
6477
  return [
6417
- `echo -e "\\e[0Ksection_start:$(date +%s):${name}[collapsed=true]\\r\\e[0K${header}"`,
6478
+ globalScriptFunctions_1.COLLAPSEABLE_SECTION_START.invoke(`"${name}"`, `"${header}"`),
6418
6479
  ...commands,
6419
- `echo -e "\\e[0Ksection_end:$(date +%s):${name}\\r\\e[0K"`,
6480
+ globalScriptFunctions_1.COLLAPSEABLE_SECTION_END.invoke(`"${name}"`),
6420
6481
  ];
6421
6482
  };
6422
6483
  exports.collapseableSection = collapseableSection;
@@ -3940,6 +3940,9 @@ class BashExpression {
3940
3940
  toString() {
3941
3941
  return this.value.toString();
3942
3942
  }
3943
+ replace(searchValue, replacer) {
3944
+ return new BashExpression(this.value.toString().replace(searchValue, replacer));
3945
+ }
3943
3946
  /**
3944
3947
  *
3945
3948
  * @returns a bash expression to lowercase the string
@@ -4107,15 +4110,12 @@ const BashExpression_1 = __nccwpck_require__(42376);
4107
4110
  // and adjusted a bit
4108
4111
  async function replaceAsync(string, searchValue, replacer) {
4109
4112
  const wasBashExpression = string instanceof BashExpression_1.BashExpression;
4110
- const stringRepresentation = wasBashExpression
4111
- ? string.toString()
4112
- : (0, BashExpression_1.bashEscape)(string);
4113
4113
  try {
4114
4114
  // 1. Run fake pass of `replace`, collect values from `replacer` calls
4115
4115
  // 2. Resolve them with `Promise.all`
4116
4116
  // 3. Run `replace` with resolved values
4117
4117
  const values = [];
4118
- String.prototype.replace.call(stringRepresentation, searchValue, function (...args) {
4118
+ String.prototype.replace.call(string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string), searchValue, function (...args) {
4119
4119
  // eslint-disable-next-line prefer-spread
4120
4120
  const result = replacer.apply(undefined, args);
4121
4121
  values.push(result);
@@ -4123,7 +4123,7 @@ async function replaceAsync(string, searchValue, replacer) {
4123
4123
  });
4124
4124
  const resolvedValues = await Promise.all(values);
4125
4125
  const containsBashExpression = resolvedValues.some((value) => value instanceof BashExpression_1.BashExpression);
4126
- const result = String.prototype.replace.call(stringRepresentation, searchValue, function () {
4126
+ const result = (string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string)).replace(searchValue, function () {
4127
4127
  var _a, _b;
4128
4128
  return (_b = (_a = resolvedValues.shift()) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "";
4129
4129
  });
@@ -8385,6 +8385,38 @@ exports.contextIsStoppable = contextIsStoppable;
8385
8385
 
8386
8386
  /***/ }),
8387
8387
 
8388
+ /***/ 12912:
8389
+ /***/ ((__unused_webpack_module, exports) => {
8390
+
8391
+ "use strict";
8392
+
8393
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
8394
+ exports.COLLAPSEABLE_SECTION_END = exports.COLLAPSEABLE_SECTION_START = void 0;
8395
+ class GlobalScriptFunction {
8396
+ constructor(name, script) {
8397
+ this.name = name;
8398
+ this.script = script;
8399
+ }
8400
+ toBashFunction() {
8401
+ return `function ${this.name} () {
8402
+ ${this.script}
8403
+ }`;
8404
+ }
8405
+ invoke(...args) {
8406
+ return `${this.name} ${args.join(" ")}`;
8407
+ }
8408
+ }
8409
+ exports.COLLAPSEABLE_SECTION_START = new GlobalScriptFunction("collapseable_section_start", `local section_title="\${1}"
8410
+ local section_description="\${2:-$section_title}"
8411
+ echo -e "section_start:\`date +%s\`:\${section_title}[collapsed=true]\\r\\e[0K$\{section_description}"
8412
+ `);
8413
+ exports.COLLAPSEABLE_SECTION_END = new GlobalScriptFunction("collapseable_section_end", `local section_title="\${1}"
8414
+ echo -e "section_end:\`date +%s\`:\${section_title}\\r\\e[0K"
8415
+ `);
8416
+ //# sourceMappingURL=index.js.map
8417
+
8418
+ /***/ }),
8419
+
8388
8420
  /***/ 10603:
8389
8421
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
8390
8422
 
@@ -9004,14 +9036,38 @@ function getGitlabNeedsForWorkspaceJob(context, { needsStages, needs }, allJobs)
9004
9036
  /***/ }),
9005
9037
 
9006
9038
  /***/ 66551:
9007
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
9039
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
9008
9040
 
9009
9041
  "use strict";
9010
9042
 
9043
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9044
+ if (k2 === undefined) k2 = k;
9045
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9046
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9047
+ desc = { enumerable: true, get: function() { return m[k]; } };
9048
+ }
9049
+ Object.defineProperty(o, k2, desc);
9050
+ }) : (function(o, m, k, k2) {
9051
+ if (k2 === undefined) k2 = k;
9052
+ o[k2] = m[k];
9053
+ }));
9054
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
9055
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
9056
+ }) : function(o, v) {
9057
+ o["default"] = v;
9058
+ });
9059
+ var __importStar = (this && this.__importStar) || function (mod) {
9060
+ if (mod && mod.__esModule) return mod;
9061
+ var result = {};
9062
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
9063
+ __setModuleDefault(result, mod);
9064
+ return result;
9065
+ };
9011
9066
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9012
9067
  exports.createGitlabPipelineWithDefaults = void 0;
9013
9068
  const runner_1 = __nccwpck_require__(4058);
9014
- const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
9069
+ const GLOBAL_SCRIPTS = __importStar(__nccwpck_require__(12912));
9070
+ const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...config }) => {
9015
9071
  return {
9016
9072
  image: image !== null && image !== void 0 ? image : (0, runner_1.getRunnerImage)("jobs-default"), // default image
9017
9073
  variables: {
@@ -9022,6 +9078,10 @@ const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
9022
9078
  GIT_DEPTH: "1", // no need the full depth
9023
9079
  ...(variables !== null && variables !== void 0 ? variables : {}),
9024
9080
  },
9081
+ before_script: [
9082
+ ...Object.values(GLOBAL_SCRIPTS).map((script) => script.toBashFunction()),
9083
+ ...(before_script !== null && before_script !== void 0 ? before_script : []),
9084
+ ],
9025
9085
  ...config,
9026
9086
  };
9027
9087
  };
@@ -9554,12 +9614,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
9554
9614
  /***/ }),
9555
9615
 
9556
9616
  /***/ 38490:
9557
- /***/ ((__unused_webpack_module, exports) => {
9617
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
9558
9618
 
9559
9619
  "use strict";
9560
9620
 
9561
9621
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9562
9622
  exports.collapseableSection = exports.repeatOnFailure = exports.sanitizeForBashVariable = exports.allowFailureInScripts = void 0;
9623
+ const globalScriptFunctions_1 = __nccwpck_require__(12912);
9563
9624
  const allowFailureInScripts = (script) => [
9564
9625
  "set +e", // disable fail job on error
9565
9626
  ...script,
@@ -9580,9 +9641,9 @@ const repeatOnFailure = (command, options) => {
9580
9641
  exports.repeatOnFailure = repeatOnFailure;
9581
9642
  const collapseableSection = (name, header) => (commands) => {
9582
9643
  return [
9583
- `echo -e "\\e[0Ksection_start:$(date +%s):${name}[collapsed=true]\\r\\e[0K${header}"`,
9644
+ globalScriptFunctions_1.COLLAPSEABLE_SECTION_START.invoke(`"${name}"`, `"${header}"`),
9584
9645
  ...commands,
9585
- `echo -e "\\e[0Ksection_end:$(date +%s):${name}\\r\\e[0K"`,
9646
+ globalScriptFunctions_1.COLLAPSEABLE_SECTION_END.invoke(`"${name}"`),
9586
9647
  ];
9587
9648
  };
9588
9649
  exports.collapseableSection = collapseableSection;
@@ -8,6 +8,7 @@ export declare class BashExpression {
8
8
  constructor(value: string | BashExpression);
9
9
  toJSON(): string;
10
10
  toString(): string;
11
+ replace(searchValue: any, replacer: (substring: string, ...args: any[]) => string): BashExpression;
11
12
  /**
12
13
  *
13
14
  * @returns a bash expression to lowercase the string
@@ -16,6 +16,9 @@ class BashExpression {
16
16
  toString() {
17
17
  return this.value.toString();
18
18
  }
19
+ replace(searchValue, replacer) {
20
+ return new BashExpression(this.value.toString().replace(searchValue, replacer));
21
+ }
19
22
  /**
20
23
  *
21
24
  * @returns a bash expression to lowercase the string
@@ -1 +1 @@
1
- {"version":3,"file":"BashExpression.js","sourceRoot":"","sources":["../../../../../pipeline/src/bash/BashExpression.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,cAAc;IACzB,YAAoB,KAA8B;QAA9B,UAAK,GAAL,KAAK,CAAyB;IAAG,CAAC;IAC/C,MAAM;QACX,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IACM,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,CAAC;IAChE,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,GAAG,MAAsC;QACrD,OAAO,IAAI,cAAc,CACvB,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,C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,cAAc,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AAAnE,QAAA,eAAe,mBAAoD;AAEhF;;;;;;;;GAQG;AACI,MAAM,mBAAmB,GAAG,CACjC,KAAoC,EACpC,MAAM,GAAG,EAAE,EACa,EAAE;IAC1B,MAAM,mBAAmB,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,cAAc,CAAC,CAAC;IAC3E,IAAI,mBAAmB,EAAE,CAAC;QACxB,OAAO,IAAI,cAAc,CACvB,KAAK;aACF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5D,IAAI,CAAC,MAAM,CAAC,CAChB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B;AAEF;;;GAGG;AACI,MAAM,UAAU,GAAG,CAAC,KAAmC,EAAE,EAAE;IAChE,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,kEAAkE;IAC7F,CAAC;IACD,yDAAyD;IACzD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjE,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAPW,QAAA,UAAU,cAOrB"}
@@ -5,15 +5,12 @@ const BashExpression_1 = require("./BashExpression");
5
5
  // and adjusted a bit
6
6
  async function replaceAsync(string, searchValue, replacer) {
7
7
  const wasBashExpression = string instanceof BashExpression_1.BashExpression;
8
- const stringRepresentation = wasBashExpression
9
- ? string.toString()
10
- : (0, BashExpression_1.bashEscape)(string);
11
8
  try {
12
9
  // 1. Run fake pass of `replace`, collect values from `replacer` calls
13
10
  // 2. Resolve them with `Promise.all`
14
11
  // 3. Run `replace` with resolved values
15
12
  const values = [];
16
- String.prototype.replace.call(stringRepresentation, searchValue, function (...args) {
13
+ String.prototype.replace.call(string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string), searchValue, function (...args) {
17
14
  // eslint-disable-next-line prefer-spread
18
15
  const result = replacer.apply(undefined, args);
19
16
  values.push(result);
@@ -21,7 +18,7 @@ async function replaceAsync(string, searchValue, replacer) {
21
18
  });
22
19
  const resolvedValues = await Promise.all(values);
23
20
  const containsBashExpression = resolvedValues.some((value) => value instanceof BashExpression_1.BashExpression);
24
- const result = String.prototype.replace.call(stringRepresentation, searchValue, function () {
21
+ const result = (string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string)).replace(searchValue, function () {
25
22
  var _a, _b;
26
23
  return (_b = (_a = resolvedValues.shift()) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "";
27
24
  });
@@ -1 +1 @@
1
- {"version":3,"file":"replaceAsync.js","sourceRoot":"","sources":["../../../../../pipeline/src/bash/replaceAsync.ts"],"names":[],"mappings":";;AAAA,qDAA8D;AAE9D,wEAAwE;AACxE,qBAAqB;AACN,KAAK,UAAU,YAAY,CACxC,MAA+B,EAC/B,WAAgB,EAChB,QAGqC;IAErC,MAAM,iBAAiB,GAAG,MAAM,YAAY,+BAAc,CAAC;IAE3D,MAAM,oBAAoB,GAAG,iBAAiB;QAC5C,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;QACnB,CAAC,CAAC,IAAA,2BAAU,EAAC,MAAM,CAAC,CAAC;IACvB,IAAI,CAAC;QACH,sEAAsE;QACtE,qCAAqC;QACrC,wCAAwC;QACxC,MAAM,MAAM,GAA4C,EAAE,CAAC;QAC3D,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAC3B,oB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string);
5
+ toBashFunction(): string;
6
+ invoke(...args: string[]): string;
7
+ }
8
+ export declare const COLLAPSEABLE_SECTION_START: GlobalScriptFunction;
9
+ export declare const COLLAPSEABLE_SECTION_END: GlobalScriptFunction;
10
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COLLAPSEABLE_SECTION_END = exports.COLLAPSEABLE_SECTION_START = void 0;
4
+ class GlobalScriptFunction {
5
+ constructor(name, script) {
6
+ this.name = name;
7
+ this.script = script;
8
+ }
9
+ toBashFunction() {
10
+ return `function ${this.name} () {
11
+ ${this.script}
12
+ }`;
13
+ }
14
+ invoke(...args) {
15
+ return `${this.name} ${args.join(" ")}`;
16
+ }
17
+ }
18
+ exports.COLLAPSEABLE_SECTION_START = new GlobalScriptFunction("collapseable_section_start", `local section_title="\${1}"
19
+ local section_description="\${2:-$section_title}"
20
+ echo -e "section_start:\`date +%s\`:\${section_title}[collapsed=true]\\r\\e[0K$\{section_description}"
21
+ `);
22
+ exports.COLLAPSEABLE_SECTION_END = new GlobalScriptFunction("collapseable_section_end", `local section_title="\${1}"
23
+ echo -e "section_end:\`date +%s\`:\${section_title}\\r\\e[0K"
24
+ `);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../pipeline/src/globalScriptFunctions/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB;IACxB,YACS,IAAY,EACZ,MAAc;QADd,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;IACpB,CAAC;IAEJ,cAAc;QACZ,OAAO,YAAY,IAAI,CAAC,IAAI;cAClB,IAAI,CAAC,MAAM;UACf,CAAC;IACT,CAAC;IACD,MAAM,CAAC,GAAG,IAAc;QACtB,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1C,CAAC;CACF;AAEY,QAAA,0BAA0B,GAAG,IAAI,oBAAoB,CAChE,4BAA4B,EAC5B;;;CAGD,CACA,CAAC;AAEW,QAAA,wBAAwB,GAAG,IAAI,oBAAoB,CAC9D,0BAA0B,EAC1B;;CAED,CACA,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { Pipeline } from "../../types";
2
2
  type PickRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
3
- export declare const createGitlabPipelineWithDefaults: ({ image, variables, ...config }: PickRequired<Partial<Pipeline<"gitlab">>, "stages" | "jobs">) => Pipeline<"gitlab">;
3
+ export declare const createGitlabPipelineWithDefaults: ({ image, variables, before_script, ...config }: PickRequired<Partial<Pipeline<"gitlab">>, "stages" | "jobs">) => Pipeline<"gitlab">;
4
4
  export {};
@@ -1,8 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.createGitlabPipelineWithDefaults = void 0;
4
27
  const runner_1 = require("../../runner");
5
- const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
28
+ const GLOBAL_SCRIPTS = __importStar(require("../../globalScriptFunctions"));
29
+ const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...config }) => {
6
30
  return {
7
31
  image: image !== null && image !== void 0 ? image : (0, runner_1.getRunnerImage)("jobs-default"), // default image
8
32
  variables: {
@@ -13,6 +37,10 @@ const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
13
37
  GIT_DEPTH: "1", // no need the full depth
14
38
  ...(variables !== null && variables !== void 0 ? variables : {}),
15
39
  },
40
+ before_script: [
41
+ ...Object.values(GLOBAL_SCRIPTS).map((script) => script.toBashFunction()),
42
+ ...(before_script !== null && before_script !== void 0 ? before_script : []),
43
+ ],
16
44
  ...config,
17
45
  };
18
46
  };
@@ -1 +1 @@
1
- {"version":3,"file":"createGitlabPipeline.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/gitlab/createGitlabPipeline.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAKvC,MAAM,gCAAgC,GAAG,CAAC,EAC/C,KAAK,EACL,SAAS,EACT,GAAG,MAAM,EAIV,EAAsB,EAAE;IACvB,OAAO;QACL,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAA,uBAAc,EAAC,cAAc,CAAC,EAAE,gBAAgB;QAChE,SAAS,EAAE;YACT,cAAc,EAAE,MAAM,EAAE,uFAAuF;YAC/G,0BAA0B,EAAE,MAAM,EAAE,kCAAkC;YACtE,uBAAuB,EAAE,MAAM,EAAE,gCAAgC;YACjE,wBAAwB,EAAE,IAAI,EAAE,0EAA0E;YAE1G,SAAS,EAAE,GAAG,EAAE,yBAAyB;YACzC,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;SACrB;QAED,GAAG,MAAM;KACV,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,gCAAgC,oCAsB3C"}
1
+ {"version":3,"file":"createGitlabPipeline.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/gitlab/createGitlabPipeline.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA8C;AAE9C,4EAA8D;AAGvD,MAAM,gCAAgC,GAAG,CAAC,EAC/C,KAAK,EACL,SAAS,EACT,aAAa,EACb,GAAG,MAAM,EAIV,EAAsB,EAAE;IACvB,OAAO;QACL,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAA,uBAAc,EAAC,cAAc,CAAC,EAAE,gBAAgB;QAChE,SAAS,EAAE;YACT,cAAc,EAAE,MAAM,EAAE,uFAAuF;YAC/G,0BAA0B,EAAE,MAAM,EAAE,kCAAkC;YACtE,uBAAuB,EAAE,MAAM,EAAE,gCAAgC;YACjE,wBAAwB,EAAE,IAAI,EAAE,0EAA0E;YAE1G,SAAS,EAAE,GAAG,EAAE,yBAAyB;YACzC,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;SACrB;QACD,aAAa,EAAE;YACb,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YACzE,GAAG,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,CAAC;SACzB;QAED,GAAG,MAAM;KACV,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,gCAAgC,oCA2B3C"}
@@ -23,4 +23,5 @@ export interface GitlabPipeline extends Pick<JobTemplate, "variables"> {
23
23
  };
24
24
  stages: string[];
25
25
  jobs: Record<string, GitlabJobDef>;
26
+ before_script?: string[];
26
27
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.collapseableSection = exports.repeatOnFailure = exports.sanitizeForBashVariable = exports.allowFailureInScripts = void 0;
4
+ const globalScriptFunctions_1 = require("../globalScriptFunctions");
4
5
  const allowFailureInScripts = (script) => [
5
6
  "set +e", // disable fail job on error
6
7
  ...script,
@@ -21,9 +22,9 @@ const repeatOnFailure = (command, options) => {
21
22
  exports.repeatOnFailure = repeatOnFailure;
22
23
  const collapseableSection = (name, header) => (commands) => {
23
24
  return [
24
- `echo -e "\\e[0Ksection_start:$(date +%s):${name}[collapsed=true]\\r\\e[0K${header}"`,
25
+ globalScriptFunctions_1.COLLAPSEABLE_SECTION_START.invoke(`"${name}"`, `"${header}"`),
25
26
  ...commands,
26
- `echo -e "\\e[0Ksection_end:$(date +%s):${name}\\r\\e[0K"`,
27
+ globalScriptFunctions_1.COLLAPSEABLE_SECTION_END.invoke(`"${name}"`),
27
28
  ];
28
29
  };
29
30
  exports.collapseableSection = collapseableSection;
@@ -1 +1 @@
1
- {"version":3,"file":"gitlab.js","sourceRoot":"","sources":["../../../../../pipeline/src/utils/gitlab.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CAAC,MAAgB,EAAY,EAAE,CAAC;IACnE,QAAQ,EAAE,4BAA4B;IACtC,GAAG,MAAM;IACT,QAAQ,EAAE,WAAW;CACtB,CAAC;AAJW,QAAA,qBAAqB,yBAIhC;AAEK,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAE,EAAE,CACtD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AADb,QAAA,uBAAuB,2BACV;AAEnB,MAAM,eAAe,GAAG,CAC7B,OAAe,EACf,OAEC,EACO,EAAE;IACV,OAAO;YACG,OAAO;;;cAGL,OAAO,CAAC,cAAc;;GAEjC,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,eAAe,mBAa1B;AAEK,MAAM,mBAAmB,GAC9B,CAAC,IAAY,EAAE,MAAc,EAAE,EAAE,CACjC,CAAC,QAAkB,EAAY,EAAE;IAC/B,OAAO;QACL,4CAA4C,IAAI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