@catladder/cli 0.0.0-refactor-resolve-references-next-9ba75040 → 0.0.0-refactor-resolve-references-next-c8f614f7
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.
- package/dist/bundles/catenv/index.js +106 -42
- package/dist/bundles/cli/index.js +106 -42
- package/dist/pipeline/src/bash/bashEscape.d.ts +2 -3
- package/dist/pipeline/src/bash/bashEscape.js +45 -33
- package/dist/pipeline/src/bash/bashEscape.js.map +1 -1
- package/dist/pipeline/src/bash/bashYaml.js +2 -1
- package/dist/pipeline/src/bash/bashYaml.js.map +1 -1
- package/dist/pipeline/src/build/base/writeDotEnv.js +3 -3
- package/dist/pipeline/src/build/base/writeDotEnv.js.map +1 -1
- package/dist/pipeline/src/globalScriptFunctions/index.d.ts +14 -0
- package/dist/pipeline/src/globalScriptFunctions/index.js +32 -0
- package/dist/pipeline/src/globalScriptFunctions/index.js.map +1 -0
- package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.d.ts +1 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js +6 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js.map +1 -1
- package/dist/pipeline/src/types/gitlab-types.d.ts +1 -0
- package/dist/pipeline/src/utils/gitlab.js +10 -2
- package/dist/pipeline/src/utils/gitlab.js.map +1 -1
- package/dist/pipeline/src/variables/VariableValueContainingReferences.js +0 -1
- package/dist/pipeline/src/variables/VariableValueContainingReferences.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -825,7 +825,8 @@ exports.joinBashExpressions = joinBashExpressions;
|
|
|
825
825
|
"use strict";
|
|
826
826
|
|
|
827
827
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
828
|
-
exports.escapeForDotEnv = exports.
|
|
828
|
+
exports.escapeForDotEnv = exports.escapeSingleQuotes = exports.escapeDoubleQuotes = exports.escapeBashExpression = exports.escapeString = exports.bashEscape = void 0;
|
|
829
|
+
const globalScriptFunctions_1 = __nccwpck_require__(2912);
|
|
829
830
|
const VariableValueContainingReferences_1 = __nccwpck_require__(1592);
|
|
830
831
|
const BashExpression_1 = __nccwpck_require__(2376);
|
|
831
832
|
/**
|
|
@@ -833,10 +834,10 @@ const BashExpression_1 = __nccwpck_require__(2376);
|
|
|
833
834
|
* it either can escape single or double quotes (double is default)
|
|
834
835
|
*/
|
|
835
836
|
const bashEscape = (value, options = {
|
|
836
|
-
quotes:
|
|
837
|
-
newlines: false,
|
|
837
|
+
quotes: "double",
|
|
838
838
|
}) => {
|
|
839
839
|
if (value instanceof BashExpression_1.BashExpression) {
|
|
840
|
+
// no need to escape
|
|
840
841
|
return (0, exports.escapeBashExpression)(value, options);
|
|
841
842
|
}
|
|
842
843
|
if (value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences) {
|
|
@@ -845,30 +846,26 @@ const bashEscape = (value, options = {
|
|
|
845
846
|
return (0, exports.escapeString)(value, options);
|
|
846
847
|
};
|
|
847
848
|
exports.bashEscape = bashEscape;
|
|
848
|
-
const escapeString = (value, { quotes
|
|
849
|
+
const escapeString = (value, { quotes } = {
|
|
850
|
+
quotes: "double",
|
|
851
|
+
}) => {
|
|
849
852
|
const quoteEscaped = quotes
|
|
850
|
-
? quotes === "
|
|
851
|
-
? (0, exports.
|
|
852
|
-
: (0, exports.
|
|
853
|
+
? quotes === "single"
|
|
854
|
+
? (0, exports.escapeSingleQuotes)(value)
|
|
855
|
+
: (0, exports.escapeDoubleQuotes)(value)
|
|
853
856
|
: value;
|
|
854
|
-
if (newlines) {
|
|
855
|
-
return quoteEscaped === null || quoteEscaped === void 0 ? void 0 : quoteEscaped.replace(/\n/g, "\\n");
|
|
856
|
-
}
|
|
857
857
|
return quoteEscaped;
|
|
858
858
|
};
|
|
859
859
|
exports.escapeString = escapeString;
|
|
860
|
-
const escapeDoubleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/"/g, '\\"');
|
|
861
|
-
exports.escapeDoubleQuotes = escapeDoubleQuotes;
|
|
862
|
-
const escapeSingleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/'/g, "\\'");
|
|
863
|
-
exports.escapeSingleQuotes = escapeSingleQuotes;
|
|
864
860
|
const escapeBashExpression = (value, options) => {
|
|
865
|
-
//
|
|
866
|
-
if (options.newlines) {
|
|
867
|
-
return value.transformWithCommand("sed '$!s/$/\\n/'");
|
|
868
|
-
}
|
|
861
|
+
// no need to escape, we just return the string
|
|
869
862
|
return value;
|
|
870
863
|
};
|
|
871
864
|
exports.escapeBashExpression = escapeBashExpression;
|
|
865
|
+
const escapeDoubleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/"/g, '\\"');
|
|
866
|
+
exports.escapeDoubleQuotes = escapeDoubleQuotes;
|
|
867
|
+
const escapeSingleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/'/g, "\\'");
|
|
868
|
+
exports.escapeSingleQuotes = escapeSingleQuotes;
|
|
872
869
|
/**
|
|
873
870
|
*
|
|
874
871
|
* what an absolute nightmare.
|
|
@@ -892,17 +889,17 @@ const escapeForDotEnv = (value) => {
|
|
|
892
889
|
// we additionaly escape newlines, that give best compatibility
|
|
893
890
|
if (value.includes("\n")) {
|
|
894
891
|
const newlinesReplaces = value.replace(/\n/g, "\\n");
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
892
|
+
// default to ", but if this is not possible, we try to use ' or `
|
|
893
|
+
const quote = value.includes(`"`)
|
|
894
|
+
? value.includes(`'`)
|
|
895
|
+
? value.includes("`")
|
|
896
|
+
? // If all quote types are present, default to no
|
|
897
|
+
""
|
|
898
|
+
: "`"
|
|
899
|
+
: "'"
|
|
900
|
+
: '"';
|
|
898
901
|
// if we found a quote, we can wrap the string in it
|
|
899
|
-
|
|
900
|
-
return `${quote}${newlinesReplaces}${quote}`;
|
|
901
|
-
}
|
|
902
|
-
else {
|
|
903
|
-
// we can't do really much here, so we just wrap it in double quotes
|
|
904
|
-
return `"${newlinesReplaces}"`;
|
|
905
|
-
}
|
|
902
|
+
return `${quote}${newlinesReplaces}${quote}`;
|
|
906
903
|
}
|
|
907
904
|
else {
|
|
908
905
|
// otherwise we can return as is
|
|
@@ -932,12 +929,27 @@ const escapeForDotEnv = (value) => {
|
|
|
932
929
|
}
|
|
933
930
|
};
|
|
934
931
|
exports.escapeForDotEnv = escapeForDotEnv;
|
|
932
|
+
// basically the same thing as above for bash
|
|
933
|
+
// thx chatgpt for this
|
|
934
|
+
const escapeForDotEnvScript = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("escapeForDotEnv", `
|
|
935
|
+
input="\${1:-$(cat)}"
|
|
936
|
+
input="\${input//$'\\n'/\\\\n}"
|
|
937
|
+
if [[ "$input" == *\\\\n* ]]; then
|
|
938
|
+
if [[ "$input" == *\\"* && "$input" == *\\'* && "$input" == *\\\`* ]]; then
|
|
939
|
+
printf "%s\\n" "$input"
|
|
940
|
+
elif [[ "$input" == *\\"* && "$input" == *\\'* ]]; then
|
|
941
|
+
printf "\`%s\`\\n" "$input"
|
|
942
|
+
elif [[ "$input" == *\\"* ]]; then
|
|
943
|
+
printf "'%s'\\n" "$input"
|
|
944
|
+
else
|
|
945
|
+
printf "\\"%s\\"\\n" "$input"
|
|
946
|
+
fi
|
|
947
|
+
else
|
|
948
|
+
printf "%s\\n" "$input"
|
|
949
|
+
fi
|
|
950
|
+
`);
|
|
935
951
|
const escapeBashExpressionForDotEnv = (value) => {
|
|
936
|
-
|
|
937
|
-
// we optimize that later to make it shorter or create a script for it (either pre-script or bake it into the pipeline job)
|
|
938
|
-
// thx chatgpt for this
|
|
939
|
-
const awkCommand = 'awk \'{output = output (NR == 1 ? "" : "\\\\n") $0} END {if (output ~ /"/ && output ~ /\'\\\'\'/ && output ~ //) print "\\"" output "\\""; else if (output !~ /"/) print "\\"" output "\\""; else if (output !~ /\'\\\'\'/) print "\'"\'"\'" output "\'"\'"\'"; else print "" output ""}\'';
|
|
940
|
-
return value.transformWithCommand(awkCommand).toString();
|
|
952
|
+
return value.transformWithCommand(escapeForDotEnvScript.name).toString();
|
|
941
953
|
};
|
|
942
954
|
//# sourceMappingURL=bashEscape.js.map
|
|
943
955
|
|
|
@@ -1000,7 +1012,8 @@ const variableContainingReferences = {
|
|
|
1000
1012
|
const stringified = value.parts
|
|
1001
1013
|
.map((part) => part instanceof BashExpression_1.BashExpression
|
|
1002
1014
|
? indentNewlinesInBashExpression(part, ctx.indent)
|
|
1003
|
-
:
|
|
1015
|
+
: // indent every new line
|
|
1016
|
+
part.toString().replace(/\n/g, `\n${ctx.indent}`))
|
|
1004
1017
|
.join("");
|
|
1005
1018
|
return "|-\n" + ctx.indent + stringified;
|
|
1006
1019
|
},
|
|
@@ -1379,9 +1392,9 @@ exports.writeBuildInfo = writeBuildInfo;
|
|
|
1379
1392
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1380
1393
|
exports.componentContextNeedsBuildTimeDotEnv = exports.writeDotEnv = void 0;
|
|
1381
1394
|
const lodash_1 = __nccwpck_require__(3255);
|
|
1382
|
-
const gitlab_1 = __nccwpck_require__(8490);
|
|
1383
|
-
const getBuildInfoVariables_1 = __nccwpck_require__(7827);
|
|
1384
1395
|
const bashEscape_1 = __nccwpck_require__(2463);
|
|
1396
|
+
const getBuildInfoVariables_1 = __nccwpck_require__(7827);
|
|
1397
|
+
const gitlab_1 = __nccwpck_require__(8490);
|
|
1385
1398
|
/**
|
|
1386
1399
|
* writes a .env file in the components folder
|
|
1387
1400
|
* @param context
|
|
@@ -1398,7 +1411,7 @@ const writeDotEnv = (context) => {
|
|
|
1398
1411
|
.filter(([key]) => !getBuildInfoVariables_1.ALL_BUILD_VARIABLES.includes(key))
|
|
1399
1412
|
.map(([key, value]) => `${key}=${(0, bashEscape_1.escapeForDotEnv)(value)}`)
|
|
1400
1413
|
.join("\n");
|
|
1401
|
-
return (0, gitlab_1.collapseableSection)("write-dotenv-" + context.name, "write dot env")([
|
|
1414
|
+
return (0, gitlab_1.collapseableSection)("write-dotenv-" + context.name, "write dot env for " + context.name)([
|
|
1402
1415
|
`cat <<EOF > ${context.build.dir}/.env
|
|
1403
1416
|
${keyValueString}
|
|
1404
1417
|
EOF`,
|
|
@@ -5280,6 +5293,45 @@ exports.contextIsStoppable = contextIsStoppable;
|
|
|
5280
5293
|
|
|
5281
5294
|
/***/ }),
|
|
5282
5295
|
|
|
5296
|
+
/***/ 2912:
|
|
5297
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
5298
|
+
|
|
5299
|
+
"use strict";
|
|
5300
|
+
|
|
5301
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5302
|
+
exports.registerGlobalScriptFunction = exports.globalScriptFunctions = void 0;
|
|
5303
|
+
class GlobalScriptFunction {
|
|
5304
|
+
constructor(name, script) {
|
|
5305
|
+
this.name = name;
|
|
5306
|
+
this.script = script;
|
|
5307
|
+
}
|
|
5308
|
+
toBashFunction() {
|
|
5309
|
+
return `function ${this.name} () {
|
|
5310
|
+
${this.script.trim()}
|
|
5311
|
+
}`.trim();
|
|
5312
|
+
}
|
|
5313
|
+
invoke(...args) {
|
|
5314
|
+
return `${this.name} ${args.join(" ")}`;
|
|
5315
|
+
}
|
|
5316
|
+
}
|
|
5317
|
+
exports.globalScriptFunctions = new Map();
|
|
5318
|
+
/**
|
|
5319
|
+
* registers a global script function
|
|
5320
|
+
* only use that in top-level scopes as it will attach the function to the global scope
|
|
5321
|
+
*/
|
|
5322
|
+
const registerGlobalScriptFunction = (name, script) => {
|
|
5323
|
+
if (exports.globalScriptFunctions.has(name)) {
|
|
5324
|
+
throw new Error(`Global script function ${name} already exists`);
|
|
5325
|
+
}
|
|
5326
|
+
const scriptFunction = new GlobalScriptFunction(name, script);
|
|
5327
|
+
exports.globalScriptFunctions.set(name, scriptFunction);
|
|
5328
|
+
return scriptFunction;
|
|
5329
|
+
};
|
|
5330
|
+
exports.registerGlobalScriptFunction = registerGlobalScriptFunction;
|
|
5331
|
+
//# sourceMappingURL=index.js.map
|
|
5332
|
+
|
|
5333
|
+
/***/ }),
|
|
5334
|
+
|
|
5283
5335
|
/***/ 603:
|
|
5284
5336
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
5285
5337
|
|
|
@@ -5908,7 +5960,8 @@ function getGitlabNeedsForWorkspaceJob(context, { needsStages, needs }, allJobs)
|
|
|
5908
5960
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5909
5961
|
exports.createGitlabPipelineWithDefaults = void 0;
|
|
5910
5962
|
const runner_1 = __nccwpck_require__(4058);
|
|
5911
|
-
const
|
|
5963
|
+
const globalScriptFunctions_1 = __nccwpck_require__(2912);
|
|
5964
|
+
const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...config }) => {
|
|
5912
5965
|
return {
|
|
5913
5966
|
image: image !== null && image !== void 0 ? image : (0, runner_1.getRunnerImage)("jobs-default"), // default image
|
|
5914
5967
|
variables: {
|
|
@@ -5919,6 +5972,10 @@ const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
|
|
|
5919
5972
|
GIT_DEPTH: "1", // no need the full depth
|
|
5920
5973
|
...(variables !== null && variables !== void 0 ? variables : {}),
|
|
5921
5974
|
},
|
|
5975
|
+
before_script: [
|
|
5976
|
+
...[...globalScriptFunctions_1.globalScriptFunctions.values()].map((script) => script.toBashFunction()),
|
|
5977
|
+
...(before_script !== null && before_script !== void 0 ? before_script : []),
|
|
5978
|
+
],
|
|
5922
5979
|
...config,
|
|
5923
5980
|
};
|
|
5924
5981
|
};
|
|
@@ -6451,12 +6508,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
6451
6508
|
/***/ }),
|
|
6452
6509
|
|
|
6453
6510
|
/***/ 8490:
|
|
6454
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
6511
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
6455
6512
|
|
|
6456
6513
|
"use strict";
|
|
6457
6514
|
|
|
6458
6515
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6459
6516
|
exports.collapseableSection = exports.repeatOnFailure = exports.sanitizeForBashVariable = exports.allowFailureInScripts = void 0;
|
|
6517
|
+
const globalScriptFunctions_1 = __nccwpck_require__(2912);
|
|
6460
6518
|
const allowFailureInScripts = (script) => [
|
|
6461
6519
|
"set +e", // disable fail job on error
|
|
6462
6520
|
...script,
|
|
@@ -6475,11 +6533,18 @@ const repeatOnFailure = (command, options) => {
|
|
|
6475
6533
|
`;
|
|
6476
6534
|
};
|
|
6477
6535
|
exports.repeatOnFailure = repeatOnFailure;
|
|
6536
|
+
const start = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("collapseable_section_start", `local section_title="\${1}"
|
|
6537
|
+
local section_description="\${2:-$section_title}"
|
|
6538
|
+
echo -e "section_start:\`date +%s\`:\${section_title}[collapsed=true]\\r\\e[0K$\{section_description}"
|
|
6539
|
+
`);
|
|
6540
|
+
const end = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("collapseable_section_end", `local section_title="\${1}"
|
|
6541
|
+
echo -e "section_end:\`date +%s\`:\${section_title}\\r\\e[0K"
|
|
6542
|
+
`);
|
|
6478
6543
|
const collapseableSection = (name, header) => (commands) => {
|
|
6479
6544
|
return [
|
|
6480
|
-
`
|
|
6545
|
+
start.invoke(`"${name}"`, `"${header}"`),
|
|
6481
6546
|
...commands,
|
|
6482
|
-
`
|
|
6547
|
+
end.invoke(`"${name}"`),
|
|
6483
6548
|
];
|
|
6484
6549
|
};
|
|
6485
6550
|
exports.collapseableSection = collapseableSection;
|
|
@@ -6642,7 +6707,6 @@ class VariableValueContainingReferences {
|
|
|
6642
6707
|
}
|
|
6643
6708
|
toString(options = {
|
|
6644
6709
|
quotes: false,
|
|
6645
|
-
newlines: false,
|
|
6646
6710
|
}) {
|
|
6647
6711
|
return this.parts
|
|
6648
6712
|
.map((part) => {
|
|
@@ -3998,7 +3998,8 @@ exports.joinBashExpressions = joinBashExpressions;
|
|
|
3998
3998
|
"use strict";
|
|
3999
3999
|
|
|
4000
4000
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4001
|
-
exports.escapeForDotEnv = exports.
|
|
4001
|
+
exports.escapeForDotEnv = exports.escapeSingleQuotes = exports.escapeDoubleQuotes = exports.escapeBashExpression = exports.escapeString = exports.bashEscape = void 0;
|
|
4002
|
+
const globalScriptFunctions_1 = __nccwpck_require__(12912);
|
|
4002
4003
|
const VariableValueContainingReferences_1 = __nccwpck_require__(84474);
|
|
4003
4004
|
const BashExpression_1 = __nccwpck_require__(42376);
|
|
4004
4005
|
/**
|
|
@@ -4006,10 +4007,10 @@ const BashExpression_1 = __nccwpck_require__(42376);
|
|
|
4006
4007
|
* it either can escape single or double quotes (double is default)
|
|
4007
4008
|
*/
|
|
4008
4009
|
const bashEscape = (value, options = {
|
|
4009
|
-
quotes:
|
|
4010
|
-
newlines: false,
|
|
4010
|
+
quotes: "double",
|
|
4011
4011
|
}) => {
|
|
4012
4012
|
if (value instanceof BashExpression_1.BashExpression) {
|
|
4013
|
+
// no need to escape
|
|
4013
4014
|
return (0, exports.escapeBashExpression)(value, options);
|
|
4014
4015
|
}
|
|
4015
4016
|
if (value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences) {
|
|
@@ -4018,30 +4019,26 @@ const bashEscape = (value, options = {
|
|
|
4018
4019
|
return (0, exports.escapeString)(value, options);
|
|
4019
4020
|
};
|
|
4020
4021
|
exports.bashEscape = bashEscape;
|
|
4021
|
-
const escapeString = (value, { quotes
|
|
4022
|
+
const escapeString = (value, { quotes } = {
|
|
4023
|
+
quotes: "double",
|
|
4024
|
+
}) => {
|
|
4022
4025
|
const quoteEscaped = quotes
|
|
4023
|
-
? quotes === "
|
|
4024
|
-
? (0, exports.
|
|
4025
|
-
: (0, exports.
|
|
4026
|
+
? quotes === "single"
|
|
4027
|
+
? (0, exports.escapeSingleQuotes)(value)
|
|
4028
|
+
: (0, exports.escapeDoubleQuotes)(value)
|
|
4026
4029
|
: value;
|
|
4027
|
-
if (newlines) {
|
|
4028
|
-
return quoteEscaped === null || quoteEscaped === void 0 ? void 0 : quoteEscaped.replace(/\n/g, "\\n");
|
|
4029
|
-
}
|
|
4030
4030
|
return quoteEscaped;
|
|
4031
4031
|
};
|
|
4032
4032
|
exports.escapeString = escapeString;
|
|
4033
|
-
const escapeDoubleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/"/g, '\\"');
|
|
4034
|
-
exports.escapeDoubleQuotes = escapeDoubleQuotes;
|
|
4035
|
-
const escapeSingleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/'/g, "\\'");
|
|
4036
|
-
exports.escapeSingleQuotes = escapeSingleQuotes;
|
|
4037
4033
|
const escapeBashExpression = (value, options) => {
|
|
4038
|
-
//
|
|
4039
|
-
if (options.newlines) {
|
|
4040
|
-
return value.transformWithCommand("sed '$!s/$/\\n/'");
|
|
4041
|
-
}
|
|
4034
|
+
// no need to escape, we just return the string
|
|
4042
4035
|
return value;
|
|
4043
4036
|
};
|
|
4044
4037
|
exports.escapeBashExpression = escapeBashExpression;
|
|
4038
|
+
const escapeDoubleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/"/g, '\\"');
|
|
4039
|
+
exports.escapeDoubleQuotes = escapeDoubleQuotes;
|
|
4040
|
+
const escapeSingleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/'/g, "\\'");
|
|
4041
|
+
exports.escapeSingleQuotes = escapeSingleQuotes;
|
|
4045
4042
|
/**
|
|
4046
4043
|
*
|
|
4047
4044
|
* what an absolute nightmare.
|
|
@@ -4065,17 +4062,17 @@ const escapeForDotEnv = (value) => {
|
|
|
4065
4062
|
// we additionaly escape newlines, that give best compatibility
|
|
4066
4063
|
if (value.includes("\n")) {
|
|
4067
4064
|
const newlinesReplaces = value.replace(/\n/g, "\\n");
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4065
|
+
// default to ", but if this is not possible, we try to use ' or `
|
|
4066
|
+
const quote = value.includes(`"`)
|
|
4067
|
+
? value.includes(`'`)
|
|
4068
|
+
? value.includes("`")
|
|
4069
|
+
? // If all quote types are present, default to no
|
|
4070
|
+
""
|
|
4071
|
+
: "`"
|
|
4072
|
+
: "'"
|
|
4073
|
+
: '"';
|
|
4071
4074
|
// if we found a quote, we can wrap the string in it
|
|
4072
|
-
|
|
4073
|
-
return `${quote}${newlinesReplaces}${quote}`;
|
|
4074
|
-
}
|
|
4075
|
-
else {
|
|
4076
|
-
// we can't do really much here, so we just wrap it in double quotes
|
|
4077
|
-
return `"${newlinesReplaces}"`;
|
|
4078
|
-
}
|
|
4075
|
+
return `${quote}${newlinesReplaces}${quote}`;
|
|
4079
4076
|
}
|
|
4080
4077
|
else {
|
|
4081
4078
|
// otherwise we can return as is
|
|
@@ -4105,12 +4102,27 @@ const escapeForDotEnv = (value) => {
|
|
|
4105
4102
|
}
|
|
4106
4103
|
};
|
|
4107
4104
|
exports.escapeForDotEnv = escapeForDotEnv;
|
|
4105
|
+
// basically the same thing as above for bash
|
|
4106
|
+
// thx chatgpt for this
|
|
4107
|
+
const escapeForDotEnvScript = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("escapeForDotEnv", `
|
|
4108
|
+
input="\${1:-$(cat)}"
|
|
4109
|
+
input="\${input//$'\\n'/\\\\n}"
|
|
4110
|
+
if [[ "$input" == *\\\\n* ]]; then
|
|
4111
|
+
if [[ "$input" == *\\"* && "$input" == *\\'* && "$input" == *\\\`* ]]; then
|
|
4112
|
+
printf "%s\\n" "$input"
|
|
4113
|
+
elif [[ "$input" == *\\"* && "$input" == *\\'* ]]; then
|
|
4114
|
+
printf "\`%s\`\\n" "$input"
|
|
4115
|
+
elif [[ "$input" == *\\"* ]]; then
|
|
4116
|
+
printf "'%s'\\n" "$input"
|
|
4117
|
+
else
|
|
4118
|
+
printf "\\"%s\\"\\n" "$input"
|
|
4119
|
+
fi
|
|
4120
|
+
else
|
|
4121
|
+
printf "%s\\n" "$input"
|
|
4122
|
+
fi
|
|
4123
|
+
`);
|
|
4108
4124
|
const escapeBashExpressionForDotEnv = (value) => {
|
|
4109
|
-
|
|
4110
|
-
// we optimize that later to make it shorter or create a script for it (either pre-script or bake it into the pipeline job)
|
|
4111
|
-
// thx chatgpt for this
|
|
4112
|
-
const awkCommand = 'awk \'{output = output (NR == 1 ? "" : "\\\\n") $0} END {if (output ~ /"/ && output ~ /\'\\\'\'/ && output ~ //) print "\\"" output "\\""; else if (output !~ /"/) print "\\"" output "\\""; else if (output !~ /\'\\\'\'/) print "\'"\'"\'" output "\'"\'"\'"; else print "" output ""}\'';
|
|
4113
|
-
return value.transformWithCommand(awkCommand).toString();
|
|
4125
|
+
return value.transformWithCommand(escapeForDotEnvScript.name).toString();
|
|
4114
4126
|
};
|
|
4115
4127
|
//# sourceMappingURL=bashEscape.js.map
|
|
4116
4128
|
|
|
@@ -4173,7 +4185,8 @@ const variableContainingReferences = {
|
|
|
4173
4185
|
const stringified = value.parts
|
|
4174
4186
|
.map((part) => part instanceof BashExpression_1.BashExpression
|
|
4175
4187
|
? indentNewlinesInBashExpression(part, ctx.indent)
|
|
4176
|
-
:
|
|
4188
|
+
: // indent every new line
|
|
4189
|
+
part.toString().replace(/\n/g, `\n${ctx.indent}`))
|
|
4177
4190
|
.join("");
|
|
4178
4191
|
return "|-\n" + ctx.indent + stringified;
|
|
4179
4192
|
},
|
|
@@ -4552,9 +4565,9 @@ exports.writeBuildInfo = writeBuildInfo;
|
|
|
4552
4565
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4553
4566
|
exports.componentContextNeedsBuildTimeDotEnv = exports.writeDotEnv = void 0;
|
|
4554
4567
|
const lodash_1 = __nccwpck_require__(23255);
|
|
4555
|
-
const gitlab_1 = __nccwpck_require__(38490);
|
|
4556
|
-
const getBuildInfoVariables_1 = __nccwpck_require__(17827);
|
|
4557
4568
|
const bashEscape_1 = __nccwpck_require__(12463);
|
|
4569
|
+
const getBuildInfoVariables_1 = __nccwpck_require__(17827);
|
|
4570
|
+
const gitlab_1 = __nccwpck_require__(38490);
|
|
4558
4571
|
/**
|
|
4559
4572
|
* writes a .env file in the components folder
|
|
4560
4573
|
* @param context
|
|
@@ -4571,7 +4584,7 @@ const writeDotEnv = (context) => {
|
|
|
4571
4584
|
.filter(([key]) => !getBuildInfoVariables_1.ALL_BUILD_VARIABLES.includes(key))
|
|
4572
4585
|
.map(([key, value]) => `${key}=${(0, bashEscape_1.escapeForDotEnv)(value)}`)
|
|
4573
4586
|
.join("\n");
|
|
4574
|
-
return (0, gitlab_1.collapseableSection)("write-dotenv-" + context.name, "write dot env")([
|
|
4587
|
+
return (0, gitlab_1.collapseableSection)("write-dotenv-" + context.name, "write dot env for " + context.name)([
|
|
4575
4588
|
`cat <<EOF > ${context.build.dir}/.env
|
|
4576
4589
|
${keyValueString}
|
|
4577
4590
|
EOF`,
|
|
@@ -8453,6 +8466,45 @@ exports.contextIsStoppable = contextIsStoppable;
|
|
|
8453
8466
|
|
|
8454
8467
|
/***/ }),
|
|
8455
8468
|
|
|
8469
|
+
/***/ 12912:
|
|
8470
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
8471
|
+
|
|
8472
|
+
"use strict";
|
|
8473
|
+
|
|
8474
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8475
|
+
exports.registerGlobalScriptFunction = exports.globalScriptFunctions = void 0;
|
|
8476
|
+
class GlobalScriptFunction {
|
|
8477
|
+
constructor(name, script) {
|
|
8478
|
+
this.name = name;
|
|
8479
|
+
this.script = script;
|
|
8480
|
+
}
|
|
8481
|
+
toBashFunction() {
|
|
8482
|
+
return `function ${this.name} () {
|
|
8483
|
+
${this.script.trim()}
|
|
8484
|
+
}`.trim();
|
|
8485
|
+
}
|
|
8486
|
+
invoke(...args) {
|
|
8487
|
+
return `${this.name} ${args.join(" ")}`;
|
|
8488
|
+
}
|
|
8489
|
+
}
|
|
8490
|
+
exports.globalScriptFunctions = new Map();
|
|
8491
|
+
/**
|
|
8492
|
+
* registers a global script function
|
|
8493
|
+
* only use that in top-level scopes as it will attach the function to the global scope
|
|
8494
|
+
*/
|
|
8495
|
+
const registerGlobalScriptFunction = (name, script) => {
|
|
8496
|
+
if (exports.globalScriptFunctions.has(name)) {
|
|
8497
|
+
throw new Error(`Global script function ${name} already exists`);
|
|
8498
|
+
}
|
|
8499
|
+
const scriptFunction = new GlobalScriptFunction(name, script);
|
|
8500
|
+
exports.globalScriptFunctions.set(name, scriptFunction);
|
|
8501
|
+
return scriptFunction;
|
|
8502
|
+
};
|
|
8503
|
+
exports.registerGlobalScriptFunction = registerGlobalScriptFunction;
|
|
8504
|
+
//# sourceMappingURL=index.js.map
|
|
8505
|
+
|
|
8506
|
+
/***/ }),
|
|
8507
|
+
|
|
8456
8508
|
/***/ 10603:
|
|
8457
8509
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
8458
8510
|
|
|
@@ -9081,7 +9133,8 @@ function getGitlabNeedsForWorkspaceJob(context, { needsStages, needs }, allJobs)
|
|
|
9081
9133
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9082
9134
|
exports.createGitlabPipelineWithDefaults = void 0;
|
|
9083
9135
|
const runner_1 = __nccwpck_require__(4058);
|
|
9084
|
-
const
|
|
9136
|
+
const globalScriptFunctions_1 = __nccwpck_require__(12912);
|
|
9137
|
+
const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...config }) => {
|
|
9085
9138
|
return {
|
|
9086
9139
|
image: image !== null && image !== void 0 ? image : (0, runner_1.getRunnerImage)("jobs-default"), // default image
|
|
9087
9140
|
variables: {
|
|
@@ -9092,6 +9145,10 @@ const createGitlabPipelineWithDefaults = ({ image, variables, ...config }) => {
|
|
|
9092
9145
|
GIT_DEPTH: "1", // no need the full depth
|
|
9093
9146
|
...(variables !== null && variables !== void 0 ? variables : {}),
|
|
9094
9147
|
},
|
|
9148
|
+
before_script: [
|
|
9149
|
+
...[...globalScriptFunctions_1.globalScriptFunctions.values()].map((script) => script.toBashFunction()),
|
|
9150
|
+
...(before_script !== null && before_script !== void 0 ? before_script : []),
|
|
9151
|
+
],
|
|
9095
9152
|
...config,
|
|
9096
9153
|
};
|
|
9097
9154
|
};
|
|
@@ -9624,12 +9681,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
9624
9681
|
/***/ }),
|
|
9625
9682
|
|
|
9626
9683
|
/***/ 38490:
|
|
9627
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
9684
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
9628
9685
|
|
|
9629
9686
|
"use strict";
|
|
9630
9687
|
|
|
9631
9688
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9632
9689
|
exports.collapseableSection = exports.repeatOnFailure = exports.sanitizeForBashVariable = exports.allowFailureInScripts = void 0;
|
|
9690
|
+
const globalScriptFunctions_1 = __nccwpck_require__(12912);
|
|
9633
9691
|
const allowFailureInScripts = (script) => [
|
|
9634
9692
|
"set +e", // disable fail job on error
|
|
9635
9693
|
...script,
|
|
@@ -9648,11 +9706,18 @@ const repeatOnFailure = (command, options) => {
|
|
|
9648
9706
|
`;
|
|
9649
9707
|
};
|
|
9650
9708
|
exports.repeatOnFailure = repeatOnFailure;
|
|
9709
|
+
const start = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("collapseable_section_start", `local section_title="\${1}"
|
|
9710
|
+
local section_description="\${2:-$section_title}"
|
|
9711
|
+
echo -e "section_start:\`date +%s\`:\${section_title}[collapsed=true]\\r\\e[0K$\{section_description}"
|
|
9712
|
+
`);
|
|
9713
|
+
const end = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("collapseable_section_end", `local section_title="\${1}"
|
|
9714
|
+
echo -e "section_end:\`date +%s\`:\${section_title}\\r\\e[0K"
|
|
9715
|
+
`);
|
|
9651
9716
|
const collapseableSection = (name, header) => (commands) => {
|
|
9652
9717
|
return [
|
|
9653
|
-
`
|
|
9718
|
+
start.invoke(`"${name}"`, `"${header}"`),
|
|
9654
9719
|
...commands,
|
|
9655
|
-
`
|
|
9720
|
+
end.invoke(`"${name}"`),
|
|
9656
9721
|
];
|
|
9657
9722
|
};
|
|
9658
9723
|
exports.collapseableSection = collapseableSection;
|
|
@@ -9815,7 +9880,6 @@ class VariableValueContainingReferences {
|
|
|
9815
9880
|
}
|
|
9816
9881
|
toString(options = {
|
|
9817
9882
|
quotes: false,
|
|
9818
|
-
newlines: false,
|
|
9819
9883
|
}) {
|
|
9820
9884
|
return this.parts
|
|
9821
9885
|
.map((part) => {
|
|
@@ -3,17 +3,16 @@ import { BashExpression } from "./BashExpression";
|
|
|
3
3
|
export type QuotesEscapeMode = "single" | "double";
|
|
4
4
|
export type EscapeOptions = {
|
|
5
5
|
quotes?: QuotesEscapeMode | false;
|
|
6
|
-
newlines?: boolean;
|
|
7
6
|
};
|
|
8
7
|
/**
|
|
9
8
|
* escapes a string or bash expression for bash
|
|
10
9
|
* it either can escape single or double quotes (double is default)
|
|
11
10
|
*/
|
|
12
11
|
export declare const bashEscape: (value: VariableValue | any, options?: EscapeOptions) => string | BashExpression;
|
|
13
|
-
export declare const escapeString: (value: string | null | undefined, { quotes
|
|
12
|
+
export declare const escapeString: (value: string | null | undefined, { quotes }?: EscapeOptions) => string;
|
|
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 declare const escapeBashExpression: (value: BashExpression, options: EscapeOptions) => BashExpression;
|
|
17
16
|
/**
|
|
18
17
|
*
|
|
19
18
|
* what an absolute nightmare.
|