@catladder/pipeline 1.170.0 → 2.0.0
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/bash/BashExpression.d.ts +2 -6
- package/dist/bash/BashExpression.js +5 -15
- package/dist/bash/bashEscape.d.ts +34 -0
- package/dist/bash/bashEscape.js +114 -0
- package/dist/bash/bashYaml.js +25 -2
- package/dist/bash/getInjectVarsScript.js +4 -2
- package/dist/bash/index.d.ts +2 -0
- package/dist/bash/index.js +26 -0
- package/dist/build/base/createAppBuildJob.js +3 -3
- package/dist/build/base/writeDotEnv.js +6 -4
- package/dist/build/custom/testJob.js +12 -12
- package/dist/build/docker.d.ts +3 -3
- package/dist/build/node/buildJob.js +1 -1
- package/dist/build/node/cache.d.ts +2 -4
- package/dist/build/node/cache.js +3 -24
- package/dist/build/node/testJob.js +11 -11
- package/dist/build/rails/build.js +1 -1
- package/dist/build/rails/test.js +8 -8
- package/dist/build/types.d.ts +0 -10
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.js +0 -1
- package/dist/context/getEnvConfig.js +2 -1
- package/dist/context/getEnvironment.js +1 -2
- package/dist/context/getEnvironmentVariables.d.ts +5 -6
- package/dist/context/getEnvironmentVariables.js +50 -38
- package/dist/deploy/base/deploy.js +3 -3
- package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +2 -2
- package/dist/deploy/cloudRun/index.js +2 -2
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +2 -2
- package/dist/deploy/kubernetes/cloudSql/index.js +3 -14
- package/dist/deploy/kubernetes/deployJob.js +1 -3
- package/dist/deploy/kubernetes/index.js +2 -2
- package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -3
- package/dist/deploy/kubernetes/kubeValues.d.ts +3 -4
- package/dist/deploy/kubernetes/kubeValues.js +2 -3
- package/dist/deploy/types/base.d.ts +0 -6
- package/dist/deploy/types/kubernetes.d.ts +1 -34
- package/dist/globalScriptFunctions/index.d.ts +14 -0
- package/dist/globalScriptFunctions/index.js +37 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/pipeline/gitlab/createGitlabJobs.js +3 -5
- package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +1 -0
- package/dist/pipeline/gitlab/createGitlabPipeline.js +38 -2
- package/dist/pipeline/packageManager.js +1 -1
- package/dist/runner/index.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +6 -9
- package/dist/types/context.d.ts +2 -9
- package/dist/types/gitlab-types.d.ts +1 -0
- package/dist/types/jobs.d.ts +0 -8
- package/dist/utils/gitlab.js +4 -1
- package/dist/utils/writeFiles.js +1 -7
- package/dist/variables/VariableValue.d.ts +3 -0
- package/dist/variables/VariableValue.js +5 -0
- package/dist/variables/VariableValueContainingReferences.d.ts +24 -0
- package/dist/variables/VariableValueContainingReferences.js +97 -0
- package/dist/variables/__tests__/resolveAllReferences.test.js +219 -0
- package/dist/variables/__tests__/resolveAllReferencesOnce.test.d.ts +1 -0
- package/dist/variables/__tests__/resolveAllReferencesOnce.test.js +171 -0
- package/dist/variables/__tests__/resolveReferencesOnce.test.d.ts +1 -0
- package/dist/variables/__tests__/resolveReferencesOnce.test.js +202 -0
- package/dist/variables/__tests__/variableValue.test.d.ts +1 -0
- package/dist/variables/__tests__/variableValue.test.js +36 -0
- package/dist/variables/resolveAllReferences.d.ts +3 -0
- package/dist/{bash/replaceAsync.js → variables/resolveAllReferences.js} +60 -41
- package/dist/variables/resolveAllReferencesOnce.d.ts +5 -0
- package/dist/variables/resolveAllReferencesOnce.js +191 -0
- package/dist/variables/resolveReferencesOnce.d.ts +8 -0
- package/dist/variables/resolveReferencesOnce.js +22 -0
- package/examples/__snapshots__/cloud-run-http2.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +312 -222
- package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +1436 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +316 -238
- package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +313 -238
- package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +316 -238
- package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +294 -220
- package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +312 -238
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +652 -486
- package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +282 -288
- package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +312 -238
- package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +284 -194
- package/examples/__snapshots__/custom-build-job.test.ts.snap +278 -188
- package/examples/__snapshots__/custom-deploy.test.ts.snap +220 -154
- package/examples/__snapshots__/custom-envs.test.ts.snap +216 -126
- package/examples/__snapshots__/custom-sbom-java.test.ts.snap +278 -188
- package/examples/__snapshots__/git-submodule.test.ts.snap +312 -238
- package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +231 -253
- package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +240 -262
- package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +504 -506
- package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +239 -261
- package/examples/__snapshots__/local-dot-env.test.ts.snap +236 -238
- package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +236 -242
- package/examples/__snapshots__/multiline-var.test.ts.snap +1355 -973
- package/examples/__snapshots__/native-app.test.ts.snap +438 -392
- package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +312 -238
- package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +312 -238
- package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +186 -188
- package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +162 -164
- package/examples/__snapshots__/referencing-other-vars.test.ts.snap +4741 -0
- package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +330 -228
- package/examples/__snapshots__/{workspace-api-www-custom-cache.test.ts.snap → workspace-api-www-turbo-cache.test.ts.snap} +457 -499
- package/examples/__snapshots__/workspace-api-www.test.ts.snap +452 -482
- package/examples/{workspace-api-www-custom-cache.test.ts → cloud-run-nextjs.test.ts} +2 -2
- package/examples/cloud-run-nextjs.ts +28 -0
- package/examples/cloud-run-with-sql.ts +0 -1
- package/examples/kubernetes-application-customization.ts +1 -0
- package/examples/kubernetes-with-cloud-sql.ts +1 -0
- package/examples/kubernetes-with-jobs.ts +1 -0
- package/examples/kubernetes-with-mongodb.ts +1 -0
- package/examples/meteor-kubernetes.ts +1 -1
- package/examples/native-app.ts +10 -7
- package/examples/rails-k8s-with-worker.ts +7 -1
- package/examples/{kubernetes-with-cloud-sql-legacy.test.ts → referencing-other-vars.test.ts} +2 -2
- package/examples/referencing-other-vars.ts +83 -0
- package/examples/workspace-api-www-turbo-cache.test.ts +11 -0
- package/examples/{workspace-api-www-custom-cache.ts → workspace-api-www-turbo-cache.ts} +4 -3
- package/examples/workspace-api-www.ts +3 -2
- package/package.json +2 -6
- package/src/bash/BashExpression.ts +10 -13
- package/src/bash/bashEscape.ts +158 -0
- package/src/bash/bashYaml.ts +36 -2
- package/src/bash/getInjectVarsScript.ts +11 -2
- package/src/bash/index.ts +2 -0
- package/src/build/base/createAppBuildJob.ts +0 -1
- package/src/build/base/writeDotEnv.ts +6 -6
- package/src/build/custom/testJob.ts +0 -1
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +0 -29
- package/src/build/node/testJob.ts +0 -1
- package/src/build/rails/build.ts +0 -1
- package/src/build/rails/test.ts +0 -1
- package/src/build/types.ts +0 -13
- package/src/context/createComponentContext.ts +0 -1
- package/src/context/getEnvConfig.ts +2 -2
- package/src/context/getEnvironment.ts +1 -1
- package/src/context/getEnvironmentContext.ts +1 -1
- package/src/context/getEnvironmentVariables.ts +44 -51
- package/src/deploy/base/deploy.ts +1 -1
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +4 -12
- package/src/deploy/cloudRun/index.ts +2 -2
- package/src/deploy/kubernetes/cloudSql/index.ts +3 -16
- package/src/deploy/kubernetes/deployJob.ts +0 -2
- package/src/deploy/kubernetes/index.ts +2 -2
- package/src/deploy/kubernetes/kubeEnv.ts +3 -3
- package/src/deploy/kubernetes/kubeValues.ts +5 -8
- package/src/deploy/types/base.ts +0 -6
- package/src/deploy/types/kubernetes.ts +1 -36
- package/src/globalScriptFunctions/index.ts +30 -0
- package/src/index.ts +2 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +1 -4
- package/src/pipeline/gitlab/createGitlabPipeline.ts +8 -1
- package/src/pipeline/packageManager.ts +7 -5
- package/src/runner/index.ts +0 -1
- package/src/types/config.ts +6 -9
- package/src/types/context.ts +3 -9
- package/src/types/gitlab-types.ts +1 -0
- package/src/types/jobs.ts +0 -8
- package/src/utils/gitlab.ts +19 -2
- package/src/utils/writeFiles.ts +1 -2
- package/src/variables/VariableValue.ts +6 -0
- package/src/variables/VariableValueContainingReferences.ts +89 -0
- package/src/variables/__tests__/resolveAllReferences.test.ts +110 -0
- package/src/variables/__tests__/resolveAllReferencesOnce.test.ts +64 -0
- package/src/variables/__tests__/resolveReferencesOnce.test.ts +117 -0
- package/src/variables/__tests__/variableValue.test.ts +73 -0
- package/src/variables/resolveAllReferences.ts +46 -0
- package/src/variables/resolveAllReferencesOnce.ts +44 -0
- package/src/variables/resolveReferencesOnce.ts +29 -0
- package/bin/catladder-gitlab-dev.js +0 -3
- package/bin/catladder-gitlab.js +0 -3
- package/dist/bash/replaceAsync.d.ts +0 -2
- package/dist/bundles/catladder-gitlab/index.js +0 -15
- package/dist/context/__tests__/resolveReferences.test.js +0 -368
- package/dist/context/resolveReferences.d.ts +0 -6
- package/dist/context/resolveReferences.js +0 -286
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +0 -85
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +0 -33
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +0 -1795
- package/examples/kubernetes-with-cloud-sql-legacy.ts +0 -35
- package/scripts/bundle +0 -2
- package/src/bash/replaceAsync.ts +0 -54
- package/src/context/__tests__/resolveReferences.test.ts +0 -148
- package/src/context/resolveReferences.ts +0 -93
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +0 -35
- /package/dist/{context/__tests__/resolveReferences.test.d.ts → variables/__tests__/resolveAllReferences.test.d.ts} +0 -0
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) {
|
|
5
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
-
resolve(value);
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.next(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function step(result) {
|
|
25
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
-
}
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
-
var _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function () {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
},
|
|
40
|
-
f,
|
|
41
|
-
y,
|
|
42
|
-
t,
|
|
43
|
-
g;
|
|
44
|
-
return g = {
|
|
45
|
-
next: verb(0),
|
|
46
|
-
"throw": verb(1),
|
|
47
|
-
"return": verb(2)
|
|
48
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
-
return this;
|
|
50
|
-
}), g;
|
|
51
|
-
function verb(n) {
|
|
52
|
-
return function (v) {
|
|
53
|
-
return step([n, v]);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function step(op) {
|
|
57
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
60
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
-
switch (op[0]) {
|
|
62
|
-
case 0:
|
|
63
|
-
case 1:
|
|
64
|
-
t = op;
|
|
65
|
-
break;
|
|
66
|
-
case 4:
|
|
67
|
-
_.label++;
|
|
68
|
-
return {
|
|
69
|
-
value: op[1],
|
|
70
|
-
done: false
|
|
71
|
-
};
|
|
72
|
-
case 5:
|
|
73
|
-
_.label++;
|
|
74
|
-
y = op[1];
|
|
75
|
-
op = [0];
|
|
76
|
-
continue;
|
|
77
|
-
case 7:
|
|
78
|
-
op = _.ops.pop();
|
|
79
|
-
_.trys.pop();
|
|
80
|
-
continue;
|
|
81
|
-
default:
|
|
82
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
-
_ = 0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
-
_.label = op[1];
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
-
_.label = t[1];
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (t && _.label < t[2]) {
|
|
96
|
-
_.label = t[2];
|
|
97
|
-
_.ops.push(op);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (t[2]) _.ops.pop();
|
|
101
|
-
_.trys.pop();
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
op = body.call(thisArg, _);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
op = [6, e];
|
|
107
|
-
y = 0;
|
|
108
|
-
} finally {
|
|
109
|
-
f = t = 0;
|
|
110
|
-
}
|
|
111
|
-
if (op[0] & 5) throw op[1];
|
|
112
|
-
return {
|
|
113
|
-
value: op[0] ? op[1] : void 0,
|
|
114
|
-
done: true
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
var __read = this && this.__read || function (o, n) {
|
|
119
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
120
|
-
if (!m) return o;
|
|
121
|
-
var i = m.call(o),
|
|
122
|
-
r,
|
|
123
|
-
ar = [],
|
|
124
|
-
e;
|
|
125
|
-
try {
|
|
126
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
127
|
-
} catch (error) {
|
|
128
|
-
e = {
|
|
129
|
-
error: error
|
|
130
|
-
};
|
|
131
|
-
} finally {
|
|
132
|
-
try {
|
|
133
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
134
|
-
} finally {
|
|
135
|
-
if (e) throw e.error;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return ar;
|
|
139
|
-
};
|
|
140
|
-
Object.defineProperty(exports, "__esModule", {
|
|
141
|
-
value: true
|
|
142
|
-
});
|
|
143
|
-
var resolveReferences_1 = require("../resolveReferences");
|
|
144
|
-
var unpackBashExpressions = function (obj) {
|
|
145
|
-
return Object.fromEntries(Object.entries(obj).map(function (_a) {
|
|
146
|
-
var _b = __read(_a, 2),
|
|
147
|
-
key = _b[0],
|
|
148
|
-
value = _b[1];
|
|
149
|
-
return [key, value.toString()];
|
|
150
|
-
}));
|
|
151
|
-
};
|
|
152
|
-
describe("resolveReferences", function () {
|
|
153
|
-
it("replaces occurences of ${componentName:VARIABLE_NAME}", function () {
|
|
154
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
155
|
-
var variables, otherVariables, result;
|
|
156
|
-
return __generator(this, function (_a) {
|
|
157
|
-
switch (_a.label) {
|
|
158
|
-
case 0:
|
|
159
|
-
variables = {
|
|
160
|
-
a: "hello world",
|
|
161
|
-
b: "a replaced value looks like this: '${api:FOO}', nice!"
|
|
162
|
-
};
|
|
163
|
-
otherVariables = {
|
|
164
|
-
api: {
|
|
165
|
-
FOO: "foo from api"
|
|
166
|
-
},
|
|
167
|
-
frontend: {
|
|
168
|
-
FOO: "foo from frontend"
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
172
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
173
|
-
return __generator(this, function (_a) {
|
|
174
|
-
return [2 /*return*/, otherVariables[componentName]];
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
})];
|
|
178
|
-
case 1:
|
|
179
|
-
result = _a.sent();
|
|
180
|
-
expect(unpackBashExpressions(result)).toEqual({
|
|
181
|
-
a: "hello world",
|
|
182
|
-
b: "a replaced value looks like this: 'foo from api', nice!"
|
|
183
|
-
});
|
|
184
|
-
return [2 /*return*/];
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("replaces self references with structure ${VARIABLE_NAME}", function () {
|
|
191
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
192
|
-
var variables, result;
|
|
193
|
-
return __generator(this, function (_a) {
|
|
194
|
-
switch (_a.label) {
|
|
195
|
-
case 0:
|
|
196
|
-
variables = {
|
|
197
|
-
FOO: "hello world",
|
|
198
|
-
BAR: "this: ${FOO}!"
|
|
199
|
-
};
|
|
200
|
-
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables)];
|
|
201
|
-
case 1:
|
|
202
|
-
result = _a.sent();
|
|
203
|
-
expect(unpackBashExpressions(result)).toEqual({
|
|
204
|
-
FOO: "hello world",
|
|
205
|
-
BAR: "this: hello world!"
|
|
206
|
-
});
|
|
207
|
-
return [2 /*return*/];
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it("replaces self references mixed with other vars", function () {
|
|
214
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
215
|
-
var variables, otherVariables, result;
|
|
216
|
-
return __generator(this, function (_a) {
|
|
217
|
-
switch (_a.label) {
|
|
218
|
-
case 0:
|
|
219
|
-
variables = {
|
|
220
|
-
FOO: "hello from ${api:FOO}",
|
|
221
|
-
BAR: "this: ${FOO}!"
|
|
222
|
-
};
|
|
223
|
-
otherVariables = {
|
|
224
|
-
api: {
|
|
225
|
-
FOO: "foo from api"
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
229
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
230
|
-
return __generator(this, function (_a) {
|
|
231
|
-
return [2 /*return*/, otherVariables[componentName]];
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
})];
|
|
235
|
-
case 1:
|
|
236
|
-
result = _a.sent();
|
|
237
|
-
expect(unpackBashExpressions(result)).toEqual({
|
|
238
|
-
FOO: "hello from foo from api",
|
|
239
|
-
BAR: "this: hello from foo from api!"
|
|
240
|
-
});
|
|
241
|
-
return [2 /*return*/];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it("keeps variables as is if not found (when null is returned)", function () {
|
|
248
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
249
|
-
var variables, otherVariables, result;
|
|
250
|
-
return __generator(this, function (_a) {
|
|
251
|
-
switch (_a.label) {
|
|
252
|
-
case 0:
|
|
253
|
-
variables = {
|
|
254
|
-
a: "hello world",
|
|
255
|
-
b: "a not found value looks like this: '${api:FOO}'"
|
|
256
|
-
};
|
|
257
|
-
otherVariables = {};
|
|
258
|
-
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
259
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
260
|
-
return __generator(this, function (_a) {
|
|
261
|
-
return [2 /*return*/, otherVariables[componentName]];
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
})];
|
|
265
|
-
case 1:
|
|
266
|
-
result = _a.sent();
|
|
267
|
-
expect(unpackBashExpressions(result)).toEqual({
|
|
268
|
-
a: "hello world",
|
|
269
|
-
b: "a not found value looks like this: '${api:FOO}'"
|
|
270
|
-
});
|
|
271
|
-
return [2 /*return*/];
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it("replaces mulitple levels deep", function () {
|
|
278
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
279
|
-
var variables, otherVariables, result;
|
|
280
|
-
return __generator(this, function (_a) {
|
|
281
|
-
switch (_a.label) {
|
|
282
|
-
case 0:
|
|
283
|
-
variables = {
|
|
284
|
-
a: "value is ${frontend:FOO}!"
|
|
285
|
-
};
|
|
286
|
-
otherVariables = {
|
|
287
|
-
api: {
|
|
288
|
-
FOO: "foo from api"
|
|
289
|
-
},
|
|
290
|
-
frontend: {
|
|
291
|
-
FOO: "hi, ${api:FOO}"
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
295
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
296
|
-
return __generator(this, function (_a) {
|
|
297
|
-
return [2 /*return*/, otherVariables[componentName]];
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
})];
|
|
301
|
-
case 1:
|
|
302
|
-
result = _a.sent();
|
|
303
|
-
expect(unpackBashExpressions(result)).toEqual({
|
|
304
|
-
a: "value is hi, foo from api!"
|
|
305
|
-
});
|
|
306
|
-
return [2 /*return*/];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it("prevents endless loops", function () {
|
|
313
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
314
|
-
var variables, otherVariables, result;
|
|
315
|
-
return __generator(this, function (_a) {
|
|
316
|
-
switch (_a.label) {
|
|
317
|
-
case 0:
|
|
318
|
-
variables = {
|
|
319
|
-
a: "value is ${frontend:FOO}!"
|
|
320
|
-
};
|
|
321
|
-
otherVariables = {
|
|
322
|
-
api: {
|
|
323
|
-
FOO: "api ${frontend:FOO}"
|
|
324
|
-
},
|
|
325
|
-
frontend: {
|
|
326
|
-
FOO: "frontend ${api:FOO}"
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
330
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
331
|
-
return __generator(this, function (_a) {
|
|
332
|
-
return [2 /*return*/, otherVariables[componentName]];
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
})];
|
|
336
|
-
case 1:
|
|
337
|
-
result = _a.sent();
|
|
338
|
-
expect(unpackBashExpressions(result)).toEqual({
|
|
339
|
-
a: "value is frontend api ${frontend:FOO}!"
|
|
340
|
-
});
|
|
341
|
-
return [2 /*return*/];
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
describe("translateLegacyFromComponents", function () {
|
|
349
|
-
it("translatetes the old `fromComponents` approach to ${componentName:variableName}", function () {
|
|
350
|
-
var fromComponents = {
|
|
351
|
-
api: {
|
|
352
|
-
API_FOO: "FOO",
|
|
353
|
-
API_BAR: "BAR"
|
|
354
|
-
},
|
|
355
|
-
www: {
|
|
356
|
-
WWW_X: "X",
|
|
357
|
-
WWW_Y: "Y"
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
var result = (0, resolveReferences_1.translateLegacyFromComponents)(fromComponents);
|
|
361
|
-
expect(result).toEqual({
|
|
362
|
-
API_FOO: "${api:FOO}",
|
|
363
|
-
API_BAR: "${api:BAR}",
|
|
364
|
-
WWW_X: "${www:X}",
|
|
365
|
-
WWW_Y: "${www:Y}"
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BashExpression } from "../bash/BashExpression";
|
|
2
|
-
import type { UnspecifiedEnvVars } from "..";
|
|
3
|
-
export declare const resolveReferences: (vars: Record<string, string | BashExpression | undefined | null>, getOtherVariables?: (componentName: string, alreadyVisited: Record<string, Record<string, boolean>>) => Promise<UnspecifiedEnvVars>, alreadyVisitedBase?: Record<string, Record<string, boolean>>) => Promise<Record<string, BashExpression>>;
|
|
4
|
-
export declare const translateLegacyFromComponents: (fromComponents: Record<string, Record<string, string>>) => {
|
|
5
|
-
[k: string]: string;
|
|
6
|
-
};
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) {
|
|
5
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
-
resolve(value);
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.next(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function step(result) {
|
|
25
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
-
}
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
-
var _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function () {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
},
|
|
40
|
-
f,
|
|
41
|
-
y,
|
|
42
|
-
t,
|
|
43
|
-
g;
|
|
44
|
-
return g = {
|
|
45
|
-
next: verb(0),
|
|
46
|
-
"throw": verb(1),
|
|
47
|
-
"return": verb(2)
|
|
48
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
-
return this;
|
|
50
|
-
}), g;
|
|
51
|
-
function verb(n) {
|
|
52
|
-
return function (v) {
|
|
53
|
-
return step([n, v]);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function step(op) {
|
|
57
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
60
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
-
switch (op[0]) {
|
|
62
|
-
case 0:
|
|
63
|
-
case 1:
|
|
64
|
-
t = op;
|
|
65
|
-
break;
|
|
66
|
-
case 4:
|
|
67
|
-
_.label++;
|
|
68
|
-
return {
|
|
69
|
-
value: op[1],
|
|
70
|
-
done: false
|
|
71
|
-
};
|
|
72
|
-
case 5:
|
|
73
|
-
_.label++;
|
|
74
|
-
y = op[1];
|
|
75
|
-
op = [0];
|
|
76
|
-
continue;
|
|
77
|
-
case 7:
|
|
78
|
-
op = _.ops.pop();
|
|
79
|
-
_.trys.pop();
|
|
80
|
-
continue;
|
|
81
|
-
default:
|
|
82
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
-
_ = 0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
-
_.label = op[1];
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
-
_.label = t[1];
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (t && _.label < t[2]) {
|
|
96
|
-
_.label = t[2];
|
|
97
|
-
_.ops.push(op);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (t[2]) _.ops.pop();
|
|
101
|
-
_.trys.pop();
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
op = body.call(thisArg, _);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
op = [6, e];
|
|
107
|
-
y = 0;
|
|
108
|
-
} finally {
|
|
109
|
-
f = t = 0;
|
|
110
|
-
}
|
|
111
|
-
if (op[0] & 5) throw op[1];
|
|
112
|
-
return {
|
|
113
|
-
value: op[0] ? op[1] : void 0,
|
|
114
|
-
done: true
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
var __read = this && this.__read || function (o, n) {
|
|
119
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
120
|
-
if (!m) return o;
|
|
121
|
-
var i = m.call(o),
|
|
122
|
-
r,
|
|
123
|
-
ar = [],
|
|
124
|
-
e;
|
|
125
|
-
try {
|
|
126
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
127
|
-
} catch (error) {
|
|
128
|
-
e = {
|
|
129
|
-
error: error
|
|
130
|
-
};
|
|
131
|
-
} finally {
|
|
132
|
-
try {
|
|
133
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
134
|
-
} finally {
|
|
135
|
-
if (e) throw e.error;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return ar;
|
|
139
|
-
};
|
|
140
|
-
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
141
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
142
|
-
if (ar || !(i in from)) {
|
|
143
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
144
|
-
ar[i] = from[i];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
148
|
-
};
|
|
149
|
-
var __importDefault = this && this.__importDefault || function (mod) {
|
|
150
|
-
return mod && mod.__esModule ? mod : {
|
|
151
|
-
"default": mod
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
Object.defineProperty(exports, "__esModule", {
|
|
155
|
-
value: true
|
|
156
|
-
});
|
|
157
|
-
exports.translateLegacyFromComponents = exports.resolveReferences = void 0;
|
|
158
|
-
var lodash_1 = require("lodash");
|
|
159
|
-
var replaceAsync_1 = __importDefault(require("../bash/replaceAsync"));
|
|
160
|
-
// regex to resolve references in catladder variables
|
|
161
|
-
// those expressions have the pattern ${componentName:variableName}
|
|
162
|
-
var REGEX = /\$\{(([^:}]+):)?([^}]+)}/gm;
|
|
163
|
-
var resolveReferences = function (vars_1, getOtherVariables_1) {
|
|
164
|
-
var args_1 = [];
|
|
165
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
166
|
-
args_1[_i - 2] = arguments[_i];
|
|
167
|
-
}
|
|
168
|
-
return __awaiter(void 0, __spreadArray([vars_1, getOtherVariables_1], __read(args_1), false), void 0, function (vars, getOtherVariables, alreadyVisitedBase) {
|
|
169
|
-
var replaceSingleValue, _a, _b;
|
|
170
|
-
if (alreadyVisitedBase === void 0) {
|
|
171
|
-
alreadyVisitedBase = {};
|
|
172
|
-
}
|
|
173
|
-
return __generator(this, function (_c) {
|
|
174
|
-
switch (_c.label) {
|
|
175
|
-
case 0:
|
|
176
|
-
replaceSingleValue = function (value_1) {
|
|
177
|
-
var args_1 = [];
|
|
178
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
179
|
-
args_1[_i - 1] = arguments[_i];
|
|
180
|
-
}
|
|
181
|
-
return __awaiter(void 0, __spreadArray([value_1], __read(args_1), false), void 0, function (value, alreadyVisited) {
|
|
182
|
-
if (alreadyVisited === void 0) {
|
|
183
|
-
alreadyVisited = alreadyVisitedBase;
|
|
184
|
-
}
|
|
185
|
-
return __generator(this, function (_a) {
|
|
186
|
-
switch (_a.label) {
|
|
187
|
-
case 0:
|
|
188
|
-
if (!REGEX.test(value.toString())) return [3 /*break*/, 2];
|
|
189
|
-
return [4 /*yield*/, (0, replaceAsync_1.default)(value, REGEX, function (match, _, componentName, variableName) {
|
|
190
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
191
|
-
var newAlreadyVisited, result, _a, replaced, _b;
|
|
192
|
-
var _c, _d;
|
|
193
|
-
var _e, _f;
|
|
194
|
-
return __generator(this, function (_g) {
|
|
195
|
-
switch (_g.label) {
|
|
196
|
-
case 0:
|
|
197
|
-
if ((_e = alreadyVisited[componentName]) === null || _e === void 0 ? void 0 : _e[variableName]) {
|
|
198
|
-
return [2 /*return*/, match]; // prevent endless loop
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
newAlreadyVisited = (0, lodash_1.merge)({}, alreadyVisited, (_c = {}, _c[componentName] = (_d = {}, _d[variableName] = true, _d), _c));
|
|
202
|
-
if (!componentName) return [3 /*break*/, 2];
|
|
203
|
-
return [4 /*yield*/, getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, newAlreadyVisited).then(function (r) {
|
|
204
|
-
return r === null || r === void 0 ? void 0 : r[variableName];
|
|
205
|
-
})];
|
|
206
|
-
case 1:
|
|
207
|
-
_a = (_f = _g.sent()) !== null && _f !== void 0 ? _f : null;
|
|
208
|
-
return [3 /*break*/, 3];
|
|
209
|
-
case 2:
|
|
210
|
-
_a = vars[variableName];
|
|
211
|
-
_g.label = 3;
|
|
212
|
-
case 3:
|
|
213
|
-
result = _a;
|
|
214
|
-
if (!(result !== null && result !== undefined)) return [3 /*break*/, 5];
|
|
215
|
-
return [4 /*yield*/, replaceSingleValue(result, newAlreadyVisited)];
|
|
216
|
-
case 4:
|
|
217
|
-
_b = _g.sent();
|
|
218
|
-
return [3 /*break*/, 6];
|
|
219
|
-
case 5:
|
|
220
|
-
_b = match;
|
|
221
|
-
_g.label = 6;
|
|
222
|
-
case 6:
|
|
223
|
-
replaced = _b;
|
|
224
|
-
return [2 /*return*/, replaced];
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
})];
|
|
229
|
-
case 1:
|
|
230
|
-
// we consider variables that got references in it BashExpressions, because the replacement may be one
|
|
231
|
-
return [2 /*return*/, _a.sent()];
|
|
232
|
-
case 2:
|
|
233
|
-
return [2 /*return*/, value];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
_b = (_a = Object).fromEntries;
|
|
239
|
-
return [4 /*yield*/, Promise.all(Object.entries(vars).map(function (_a) {
|
|
240
|
-
return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
241
|
-
var _c, _d;
|
|
242
|
-
var _e = __read(_b, 2),
|
|
243
|
-
key = _e[0],
|
|
244
|
-
value = _e[1];
|
|
245
|
-
return __generator(this, function (_f) {
|
|
246
|
-
switch (_f.label) {
|
|
247
|
-
case 0:
|
|
248
|
-
if (value === null || value === undefined) {
|
|
249
|
-
return [2 /*return*/, [key, null]];
|
|
250
|
-
}
|
|
251
|
-
_c = [key];
|
|
252
|
-
if (!(value !== null && value !== undefined)) return [3 /*break*/, 2];
|
|
253
|
-
return [4 /*yield*/, replaceSingleValue(value)];
|
|
254
|
-
case 1:
|
|
255
|
-
_d = _f.sent();
|
|
256
|
-
return [3 /*break*/, 3];
|
|
257
|
-
case 2:
|
|
258
|
-
_d = null;
|
|
259
|
-
_f.label = 3;
|
|
260
|
-
case 3:
|
|
261
|
-
return [2 /*return*/, _c.concat([_d])];
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
}))];
|
|
266
|
-
case 1:
|
|
267
|
-
return [2 /*return*/, _b.apply(_a, [_c.sent()])];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
exports.resolveReferences = resolveReferences;
|
|
273
|
-
var translateLegacyFromComponents = function (fromComponents) {
|
|
274
|
-
return Object.fromEntries(Object.entries(fromComponents).flatMap(function (_a) {
|
|
275
|
-
var _b = __read(_a, 2),
|
|
276
|
-
componentName = _b[0],
|
|
277
|
-
variables = _b[1];
|
|
278
|
-
return Object.entries(variables).map(function (_a) {
|
|
279
|
-
var _b = __read(_a, 2),
|
|
280
|
-
ourName = _b[0],
|
|
281
|
-
otherName = _b[1];
|
|
282
|
-
return [ourName, "${" + componentName + ":" + otherName + "}"];
|
|
283
|
-
});
|
|
284
|
-
}));
|
|
285
|
-
};
|
|
286
|
-
exports.translateLegacyFromComponents = translateLegacyFromComponents;
|