@catladder/pipeline 1.170.1 → 2.0.1
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 +1 -6
- package/dist/bash/BashExpression.js +2 -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 -40
- 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 +971 -765
- 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 → workspace-api-www-turbo-cache.test.ts} +2 -2
- 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/scripts/generate-examples-test.ts +0 -7
- package/src/bash/BashExpression.ts +0 -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 -49
- 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
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", {
|
|
119
|
+
value: true
|
|
120
|
+
});
|
|
121
|
+
var VariableValueContainingReferences_1 = require("../VariableValueContainingReferences");
|
|
122
|
+
var resolveReferencesOnce_1 = require("../resolveReferencesOnce");
|
|
123
|
+
describe("resolveReferencesOnce", function () {
|
|
124
|
+
it("should replace a reference to another component", function () {
|
|
125
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
+
var value, result;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
value = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)("the other component has ${otherComponent:variableName}, isn't that cool?", {
|
|
129
|
+
componentName: "myComponent"
|
|
130
|
+
});
|
|
131
|
+
result = (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, function (_a) {
|
|
132
|
+
var componentName = _a.componentName,
|
|
133
|
+
variableName = _a.variableName;
|
|
134
|
+
return (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)("replaced ".concat(componentName, ":").concat(variableName), {
|
|
135
|
+
componentName: componentName
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
expect(result.parts).toEqual(["the other component has ", "replaced otherComponent:variableName", ", isn't that cool?"]);
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("should keep references in replacement", function () {
|
|
145
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var value, result;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
value = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)("the other component has ${otherComponent:variableName}, isn't that cool?", {
|
|
149
|
+
componentName: "myComponent"
|
|
150
|
+
});
|
|
151
|
+
result = (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, function (_a) {
|
|
152
|
+
var componentName = _a.componentName,
|
|
153
|
+
variableName = _a.variableName;
|
|
154
|
+
return (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)("replaced ".concat(componentName, ":").concat(variableName, ", contains reference to ${thirdComponent:x}"), {
|
|
155
|
+
componentName: componentName
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
expect(result.parts).toEqual(["the other component has ", "replaced otherComponent:variableName, contains reference to ", new VariableValueContainingReferences_1.VariableReference("thirdComponent", "x"), ", isn't that cool?"]);
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("can be run multiple times", function () {
|
|
165
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
166
|
+
var value, replacer, result;
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
value = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)("the other component has ${otherComponent:variableName}, isn't that cool?", {
|
|
169
|
+
componentName: "myComponent"
|
|
170
|
+
});
|
|
171
|
+
replacer = function (_a) {
|
|
172
|
+
var componentName = _a.componentName,
|
|
173
|
+
variableName = _a.variableName;
|
|
174
|
+
return (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(componentName === "thirdComponent" ? "value from third component" : "replaced ".concat(componentName, ":").concat(variableName, ", contains reference to ${thirdComponent:x}"), {
|
|
175
|
+
componentName: componentName
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
result = (0, resolveReferencesOnce_1.resolveReferencesOnce)((0, resolveReferencesOnce_1.resolveReferencesOnce)(value, replacer), replacer);
|
|
179
|
+
expect(result.parts).toEqual(["the other component has ", "replaced otherComponent:variableName, contains reference to ", "value from third component", ", isn't that cool?"]);
|
|
180
|
+
return [2 /*return*/];
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("flags unresolveable", function () {
|
|
186
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
+
var value, result;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
value = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)("the other component has ${otherComponent:variableName}, isn't that cool?", {
|
|
190
|
+
componentName: "myComponent"
|
|
191
|
+
});
|
|
192
|
+
result = (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, function (_a) {
|
|
193
|
+
var componentName = _a.componentName,
|
|
194
|
+
variableName = _a.variableName;
|
|
195
|
+
return null;
|
|
196
|
+
});
|
|
197
|
+
expect(result.parts).toEqual(["the other component has ", new VariableValueContainingReferences_1.UnresolvableReference(new VariableValueContainingReferences_1.VariableReference("otherComponent", "variableName")), ", isn't that cool?"]);
|
|
198
|
+
return [2 /*return*/];
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var VariableValueContainingReferences_1 = require("../VariableValueContainingReferences");
|
|
7
|
+
describe("createVarialeValueFromString", function () {
|
|
8
|
+
it("should create a VariableValue from a simple string", function () {
|
|
9
|
+
var stringValue = "hello world";
|
|
10
|
+
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
|
|
11
|
+
componentName: "myComponent"
|
|
12
|
+
});
|
|
13
|
+
expect(result.parts).toEqual([stringValue]);
|
|
14
|
+
});
|
|
15
|
+
it("extracts references to other components", function () {
|
|
16
|
+
var stringValue = "the other component has ${otherComponent:variableName}, isn't that cool?";
|
|
17
|
+
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
|
|
18
|
+
componentName: "myComponent"
|
|
19
|
+
});
|
|
20
|
+
expect(result.parts).toEqual(["the other component has ", new VariableValueContainingReferences_1.VariableReference("otherComponent", "variableName"), ", isn't that cool?"]);
|
|
21
|
+
});
|
|
22
|
+
it("extracts self references", function () {
|
|
23
|
+
var stringValue = "my component has ${variableName}!";
|
|
24
|
+
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
|
|
25
|
+
componentName: "myComponent"
|
|
26
|
+
});
|
|
27
|
+
expect(result.parts).toEqual(["my component has ", new VariableValueContainingReferences_1.VariableReference("myComponent", "variableName"), "!"]);
|
|
28
|
+
});
|
|
29
|
+
it("extracts multiple references", function () {
|
|
30
|
+
var stringValue = "my component has ${variableName} and the other component has ${otherComponent:variableName}!";
|
|
31
|
+
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
|
|
32
|
+
componentName: "myComponent"
|
|
33
|
+
});
|
|
34
|
+
expect(result.parts).toEqual(["my component has ", new VariableValueContainingReferences_1.VariableReference("myComponent", "variableName"), " and the other component has ", new VariableValueContainingReferences_1.VariableReference("otherComponent", "variableName"), "!"]);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { VariableValue } from "./VariableValue";
|
|
2
|
+
import type { VariableValueContainingReferences } from "./VariableValueContainingReferences";
|
|
3
|
+
export declare const resolveAllReferences: (values: Record<string, VariableValueContainingReferences>, getEnvVars: (componentName: string) => Promise<Record<string, VariableValue | null | undefined>>) => Promise<Record<string, VariableValueContainingReferences>>;
|
|
@@ -115,57 +115,77 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
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
|
+
};
|
|
118
140
|
Object.defineProperty(exports, "__esModule", {
|
|
119
141
|
value: true
|
|
120
142
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
function
|
|
125
|
-
return __awaiter(
|
|
126
|
-
var
|
|
143
|
+
exports.resolveAllReferences = void 0;
|
|
144
|
+
var VariableValueContainingReferences_1 = require("./VariableValueContainingReferences");
|
|
145
|
+
var resolveAllReferencesOnce_1 = require("./resolveAllReferencesOnce");
|
|
146
|
+
var resolveAllReferences = function (values, getEnvVars) {
|
|
147
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
var result, i, replaced, unresolved;
|
|
127
149
|
return __generator(this, function (_a) {
|
|
128
150
|
switch (_a.label) {
|
|
129
151
|
case 0:
|
|
130
|
-
|
|
152
|
+
result = values;
|
|
153
|
+
i = 0;
|
|
131
154
|
_a.label = 1;
|
|
132
155
|
case 1:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
// eslint-disable-next-line prefer-spread
|
|
141
|
-
var result = replacer.apply(undefined, args);
|
|
142
|
-
values_1.push(result);
|
|
143
|
-
return "";
|
|
144
|
-
});
|
|
145
|
-
return [4 /*yield*/, Promise.all(values_1)];
|
|
156
|
+
if (!Object.values(result).some(function (value) {
|
|
157
|
+
return value.parts.some(function (part) {
|
|
158
|
+
return part instanceof VariableValueContainingReferences_1.VariableReference;
|
|
159
|
+
});
|
|
160
|
+
})) return [3 /*break*/, 3];
|
|
161
|
+
return [4 /*yield*/, (0, resolveAllReferencesOnce_1.resolveAllReferencesOnce)(result, getEnvVars)];
|
|
146
162
|
case 2:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
replaced = _a.sent();
|
|
164
|
+
result = replaced;
|
|
165
|
+
i++;
|
|
166
|
+
if (i > 1000) {
|
|
167
|
+
unresolved = Object.entries(result).filter(function (_a) {
|
|
168
|
+
var _b = __read(_a, 2),
|
|
169
|
+
key = _b[0],
|
|
170
|
+
value = _b[1];
|
|
171
|
+
return value.parts.some(function (part) {
|
|
172
|
+
return part instanceof VariableValueContainingReferences_1.VariableReference;
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
throw new Error("Infinite loop detected in these variables: " + unresolved.map(function (_a) {
|
|
176
|
+
var _b = __read(_a, 2),
|
|
177
|
+
key = _b[0],
|
|
178
|
+
value = _b[1];
|
|
179
|
+
return "".concat(key, " (last reference: ").concat(value.parts.find(function (part) {
|
|
180
|
+
return part instanceof VariableValueContainingReferences_1.VariableReference;
|
|
181
|
+
}), ")");
|
|
182
|
+
}).join(", "));
|
|
159
183
|
}
|
|
160
|
-
return [3 /*break*/,
|
|
184
|
+
return [3 /*break*/, 1];
|
|
161
185
|
case 3:
|
|
162
|
-
|
|
163
|
-
return [2 /*return*/, Promise.reject(error_1)];
|
|
164
|
-
case 4:
|
|
165
|
-
return [2 /*return*/];
|
|
186
|
+
return [2 /*return*/, result];
|
|
166
187
|
}
|
|
167
188
|
});
|
|
168
189
|
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
exports.default = replaceAsync;
|
|
190
|
+
};
|
|
191
|
+
exports.resolveAllReferences = resolveAllReferences;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { VariableValue } from "./VariableValue";
|
|
2
|
+
import type { VariableValueContainingReferences } from "./VariableValueContainingReferences";
|
|
3
|
+
export declare const resolveAllReferencesOnce: (values: Record<string, VariableValueContainingReferences>, getEnvVars: (componentName: string) => Promise<Record<string, VariableValue | undefined | null>>) => Promise<{
|
|
4
|
+
[k: string]: VariableValueContainingReferences;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
exports.resolveAllReferencesOnce = void 0;
|
|
144
|
+
var VariableValueContainingReferences_1 = require("./VariableValueContainingReferences");
|
|
145
|
+
var resolveReferencesOnce_1 = require("./resolveReferencesOnce");
|
|
146
|
+
var resolveAllReferencesOnce = function (values, getEnvVars) {
|
|
147
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
var allReferences, allComponentsUnique, allEnvVarsInComponents, _a, _b;
|
|
149
|
+
return __generator(this, function (_c) {
|
|
150
|
+
switch (_c.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
allReferences = Object.values(values).flatMap(function (value) {
|
|
153
|
+
return value === null || value === void 0 ? void 0 : value.parts.filter(function (part) {
|
|
154
|
+
return part instanceof VariableValueContainingReferences_1.VariableReference;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
allComponentsUnique = Array.from(new Set(allReferences.map(function (reference) {
|
|
158
|
+
return reference.componentName;
|
|
159
|
+
})));
|
|
160
|
+
_b = (_a = Object).fromEntries;
|
|
161
|
+
return [4 /*yield*/, Promise.all(allComponentsUnique.map(function (componentName) {
|
|
162
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
163
|
+
var _a;
|
|
164
|
+
return __generator(this, function (_b) {
|
|
165
|
+
switch (_b.label) {
|
|
166
|
+
case 0:
|
|
167
|
+
_a = [componentName];
|
|
168
|
+
return [4 /*yield*/, getEnvVars(componentName)];
|
|
169
|
+
case 1:
|
|
170
|
+
return [2 /*return*/, _a.concat([_b.sent()])];
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}))];
|
|
175
|
+
case 1:
|
|
176
|
+
allEnvVarsInComponents = _b.apply(_a, [_c.sent()]);
|
|
177
|
+
return [2 /*return*/, Object.fromEntries(Object.entries(values).map(function (_a) {
|
|
178
|
+
var _b = __read(_a, 2),
|
|
179
|
+
key = _b[0],
|
|
180
|
+
value = _b[1];
|
|
181
|
+
return [key, value !== null && value !== undefined ? (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, function (_a) {
|
|
182
|
+
var componentName = _a.componentName,
|
|
183
|
+
variableName = _a.variableName;
|
|
184
|
+
return allEnvVarsInComponents[componentName][variableName];
|
|
185
|
+
}) : value];
|
|
186
|
+
}))];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
exports.resolveAllReferencesOnce = resolveAllReferencesOnce;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VariableValue } from "./VariableValue";
|
|
2
|
+
import { VariableValueContainingReferences } from "./VariableValueContainingReferences";
|
|
3
|
+
type Resolver = (args: {
|
|
4
|
+
componentName: string;
|
|
5
|
+
variableName: string;
|
|
6
|
+
}) => VariableValue | null | undefined;
|
|
7
|
+
export declare const resolveReferencesOnce: (value: VariableValueContainingReferences, resolver: Resolver) => VariableValueContainingReferences;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveReferencesOnce = void 0;
|
|
7
|
+
var VariableValueContainingReferences_1 = require("./VariableValueContainingReferences");
|
|
8
|
+
var resolveReferencesOnce = function (value, resolver) {
|
|
9
|
+
var replacedParts = value.parts.map(function (part) {
|
|
10
|
+
if (part instanceof VariableValueContainingReferences_1.VariableReference) {
|
|
11
|
+
var result = resolver({
|
|
12
|
+
componentName: part.componentName,
|
|
13
|
+
variableName: part.variableName
|
|
14
|
+
});
|
|
15
|
+
return result !== null && result !== void 0 ? result : new VariableValueContainingReferences_1.UnresolvableReference(part);
|
|
16
|
+
} else {
|
|
17
|
+
return part;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return new VariableValueContainingReferences_1.VariableValueContainingReferences(replacedParts);
|
|
21
|
+
};
|
|
22
|
+
exports.resolveReferencesOnce = resolveReferencesOnce;
|