@catladder/pipeline 0.0.0-node16-ddfae617 → 0.0.0-prettier-cbceeed9
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/bin/catladder-gitlab-dev.js +3 -0
- package/bin/catladder-gitlab.js +1 -1
- package/dist/build/base/createBuildJob.d.ts +2 -2
- package/dist/build/base/createBuildJob.js +15 -30
- package/dist/build/base/writeBuildInfo.d.ts +2 -0
- package/dist/build/base/{getBuildInfo.js → writeBuildInfo.js} +3 -6
- package/dist/build/custom/buildJob.d.ts +3 -0
- package/dist/build/custom/buildJob.js +83 -0
- package/dist/build/custom/index.d.ts +3 -0
- package/dist/build/custom/index.js +40 -0
- package/dist/build/docker.d.ts +33 -9
- package/dist/build/docker.js +51 -54
- package/dist/build/index.d.ts +6 -5
- package/dist/build/index.js +20 -6
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +3 -25
- package/dist/build/node/cache.d.ts +2 -2
- package/dist/build/node/cache.js +19 -22
- package/dist/build/node/index.d.ts +1 -1
- package/dist/build/node/index.js +3 -16
- package/dist/build/node/meteor.d.ts +1 -1
- package/dist/build/node/meteor.js +9 -20
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +7 -21
- package/dist/build/node/yarn.d.ts +1 -1
- package/dist/build/node/yarn.js +14 -15
- package/dist/build/rails/build.d.ts +3 -0
- package/dist/build/rails/build.js +51 -0
- package/dist/build/rails/index.d.ts +3 -0
- package/dist/build/rails/index.js +41 -0
- package/dist/build/rails/test.d.ts +3 -0
- package/dist/build/rails/test.js +94 -0
- package/dist/build/types.d.ts +84 -9
- package/dist/build/types.js +0 -4
- package/dist/bundles/catladder-gitlab/index.js +32979 -0
- package/dist/catladder-gitlab.js +7 -26
- package/dist/config/{configruedEnvs.test.d.ts → __tests__/configruedEnvs.test.d.ts} +0 -0
- package/dist/config/{configruedEnvs.test.js → __tests__/configruedEnvs.test.js} +10 -12
- package/dist/config/configruedEnvs.d.ts +1 -1
- package/dist/config/configruedEnvs.js +7 -22
- package/dist/config/index.js +0 -4
- package/dist/config/readConfig.d.ts +1 -1
- package/dist/config/readConfig.js +2 -13
- package/dist/constants.js +1 -1
- package/dist/context/{resolveReferences.test.d.ts → __tests__/resolveReferences.test.d.ts} +0 -0
- package/dist/context/__tests__/resolveReferences.test.js +336 -0
- package/dist/context/getEnvConfig.d.ts +2 -0
- package/dist/context/getEnvConfig.js +18 -0
- package/dist/context/getEnvType.d.ts +4 -0
- package/dist/context/getEnvType.js +13 -0
- package/dist/context/getEnvironment.d.ts +3 -0
- package/dist/{pipeline/createChildPipeline.test.js → context/getEnvironment.js} +42 -84
- package/dist/context/getEnvironmentContext.d.ts +4 -0
- package/dist/context/getEnvironmentContext.js +33 -0
- package/dist/context/getEnvironmentVariables.d.ts +10 -0
- package/dist/context/getEnvironmentVariables.js +260 -0
- package/dist/context/getLabels.d.ts +8 -0
- package/dist/context/getLabels.js +38 -0
- package/dist/context/index.d.ts +5 -6
- package/dist/context/index.js +158 -208
- package/dist/context/resolveReferences.d.ts +1 -3
- package/dist/context/resolveReferences.js +213 -52
- package/dist/defaults/index.d.ts +1 -1
- package/dist/deploy/base.d.ts +4 -2
- package/dist/deploy/base.js +38 -33
- package/dist/deploy/cloudRun/deployJob.d.ts +3 -0
- package/dist/deploy/cloudRun/deployJob.js +238 -0
- package/dist/deploy/cloudRun/index.d.ts +4 -0
- package/dist/deploy/cloudRun/index.js +112 -0
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +11 -0
- package/dist/deploy/cloudRun/utils/createArgsString.js +55 -0
- package/dist/deploy/cloudRun/utils/database.d.ts +4 -0
- package/dist/deploy/cloudRun/utils/database.js +64 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +10 -0
- package/dist/deploy/cloudRun/utils/jobName.d.ts +1 -0
- package/dist/deploy/cloudRun/utils/jobName.js +8 -0
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +10 -16
- package/dist/deploy/custom/index.d.ts +2 -1
- package/dist/deploy/custom/index.js +14 -19
- package/dist/deploy/dockerTag/deployJob.d.ts +3 -0
- package/dist/deploy/dockerTag/deployJob.js +24 -0
- package/dist/deploy/dockerTag/index.d.ts +2 -0
- package/dist/deploy/dockerTag/index.js +17 -0
- package/dist/deploy/index.d.ts +12 -8
- package/dist/deploy/index.js +7 -20
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +4 -0
- package/dist/deploy/kubernetes/additionalSecretKeys.js +24 -0
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +13 -0
- package/dist/deploy/kubernetes/cloudSql/index.js +30 -0
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +17 -91
- package/dist/deploy/kubernetes/index.d.ts +3 -1
- package/dist/deploy/kubernetes/index.js +42 -4
- package/dist/deploy/kubernetes/kubeEnv.d.ts +9 -0
- package/dist/deploy/kubernetes/kubeEnv.js +72 -0
- package/dist/deploy/kubernetes/kubeValues.d.ts +97 -0
- package/dist/deploy/kubernetes/kubeValues.js +124 -0
- package/dist/deploy/kubernetes/mongodb.d.ts +18 -5
- package/dist/deploy/kubernetes/mongodb.js +96 -10
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +25 -21
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +2 -10
- package/dist/deploy/types/base.d.ts +14 -0
- package/dist/deploy/types/base.js +3 -0
- package/dist/deploy/types/custom.d.ts +33 -0
- package/dist/deploy/types/custom.js +3 -0
- package/dist/deploy/types/dockerTag.d.ts +10 -0
- package/dist/deploy/types/dockerTag.js +3 -0
- package/dist/deploy/types/googleCloudRun.d.ts +121 -0
- package/dist/deploy/types/googleCloudRun.js +3 -0
- package/dist/deploy/types/index.d.ts +22 -0
- package/dist/deploy/types/index.js +31 -0
- package/dist/deploy/types/kubernetes.d.ts +276 -0
- package/dist/deploy/types/kubernetes.js +3 -0
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/deploy/utils.js +3 -10
- package/dist/index.js +0 -10
- package/dist/pipeline/commitInfo/getBuildId.d.ts +1 -0
- package/dist/pipeline/commitInfo/getBuildId.js +135 -0
- package/dist/pipeline/commitInfo/getCommitInfo.d.ts +2 -0
- package/dist/pipeline/commitInfo/getCommitInfo.js +140 -0
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/{build/tests/storybook.test.js → pipeline/createAllJobs.js} +54 -104
- package/dist/pipeline/createChildPipeline.d.ts +2 -2
- package/dist/pipeline/createChildPipeline.js +40 -121
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +33 -192
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -5
- package/dist/pipeline/packageManager.d.ts +1 -1
- package/dist/pipeline/packageManager.js +20 -173
- package/dist/pipeline/yarn/yarnUtils.d.ts +4 -0
- package/dist/pipeline/yarn/yarnUtils.js +193 -0
- package/dist/rules/index.d.ts +3 -1
- package/dist/rules/index.js +7 -6
- package/dist/runner/index.d.ts +2 -3
- package/dist/runner/index.js +0 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +19 -25
- package/dist/types/config.js +6 -16
- package/dist/types/context.d.ts +16 -3
- package/dist/types/environmentContext.d.ts +28 -0
- package/dist/types/environmentContext.js +3 -0
- package/dist/types/gitlab-types.d.ts +39 -7
- package/dist/types/index.js +0 -6
- package/dist/types/jobs.d.ts +25 -17
- package/dist/types/jobs.js +1 -1
- package/dist/types/pipeline.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.js +3 -0
- package/dist/utils/gitlab.d.ts +5 -0
- package/dist/utils/gitlab.js +48 -0
- package/dist/utils/index.js +5 -15
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3092 -0
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +3103 -0
- package/examples/__snapshots__/custom-build-job.ts.snap +1162 -0
- package/examples/__snapshots__/custom-envs.ts.snap +261 -0
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +4077 -0
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +1626 -0
- package/examples/__utils__/helpers.ts +14 -0
- package/examples/cloud-run-memory-limit.ts +28 -0
- package/examples/cloud-run-no-cpu-throttling.ts +33 -0
- package/examples/cloud-run-non-public.ts +27 -0
- package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
- package/examples/cloud-run-with-sql.ts +61 -0
- package/examples/custom-build-job.ts +28 -0
- package/examples/custom-envs.ts +31 -0
- package/examples/kubernetes-application-customization.ts +57 -0
- package/examples/kubernetes-with-jobs.ts +68 -0
- package/examples/rails-k8s-with-worker.ts +95 -0
- package/examples/wait-for-other-deploy.ts +36 -0
- package/package.json +16 -13
- package/scripts/bundle +2 -0
- package/src/build/base/createBuildJob.ts +12 -5
- package/src/build/base/{getBuildInfo.ts → writeBuildInfo.ts} +2 -2
- package/src/build/custom/buildJob.ts +64 -0
- package/src/build/custom/index.ts +7 -0
- package/src/build/docker.ts +58 -33
- package/src/build/index.ts +24 -5
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +19 -8
- package/src/build/node/index.ts +1 -1
- package/src/build/node/meteor.ts +8 -2
- package/src/build/node/testJob.ts +4 -2
- package/src/build/node/yarn.ts +21 -10
- package/src/build/rails/build.ts +38 -0
- package/src/build/rails/index.ts +8 -0
- package/src/build/rails/test.ts +86 -0
- package/src/build/types.ts +97 -2
- package/src/catladder-gitlab.ts +4 -2
- package/src/config/{configruedEnvs.test.ts → __tests__/configruedEnvs.test.ts} +3 -3
- package/src/config/configruedEnvs.ts +2 -7
- package/src/config/readConfig.ts +1 -1
- package/src/context/{resolveReferences.test.ts → __tests__/resolveReferences.test.ts} +23 -38
- package/src/context/getEnvConfig.ts +21 -0
- package/src/context/getEnvType.ts +17 -0
- package/src/context/getEnvironment.ts +40 -0
- package/src/context/getEnvironmentContext.ts +57 -0
- package/src/context/getEnvironmentVariables.ts +155 -0
- package/src/context/getLabels.ts +20 -0
- package/src/context/index.ts +28 -193
- package/src/context/resolveReferences.ts +35 -31
- package/src/defaults/index.ts +1 -1
- package/src/deploy/base.ts +43 -19
- package/src/deploy/cloudRun/deployJob.ts +276 -0
- package/src/deploy/cloudRun/index.ts +95 -0
- package/src/deploy/cloudRun/utils/createArgsString.ts +26 -0
- package/src/deploy/cloudRun/utils/database.ts +55 -0
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +14 -0
- package/src/deploy/cloudRun/utils/jobName.ts +2 -0
- package/src/deploy/custom/deployJob.ts +13 -3
- package/src/deploy/custom/index.ts +9 -1
- package/src/deploy/dockerTag/deployJob.ts +31 -0
- package/src/deploy/dockerTag/index.ts +9 -0
- package/src/deploy/index.ts +26 -17
- package/src/deploy/kubernetes/additionalSecretKeys.ts +23 -0
- package/src/deploy/kubernetes/cloudSql/index.ts +28 -0
- package/src/deploy/kubernetes/deployJob.ts +21 -78
- package/src/deploy/kubernetes/index.ts +42 -1
- package/src/deploy/kubernetes/kubeEnv.ts +48 -0
- package/src/deploy/kubernetes/kubeValues.ts +96 -0
- package/src/deploy/kubernetes/mongodb.ts +104 -7
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +1 -1
- package/src/deploy/types/base.ts +17 -0
- package/src/deploy/types/custom.ts +36 -0
- package/src/deploy/types/dockerTag.ts +12 -0
- package/src/deploy/types/googleCloudRun.ts +179 -0
- package/src/deploy/types/index.ts +28 -0
- package/src/deploy/types/kubernetes.ts +301 -0
- package/src/deploy/utils.ts +6 -2
- package/src/pipeline/commitInfo/getBuildId.ts +6 -0
- package/src/pipeline/commitInfo/getCommitInfo.ts +12 -0
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +9 -20
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/src/pipeline/packageManager.ts +4 -38
- package/src/pipeline/yarn/yarnUtils.ts +37 -0
- package/src/rules/index.ts +9 -6
- package/src/runner/index.ts +2 -1
- package/src/types/config.ts +26 -13
- package/src/types/context.ts +23 -2
- package/src/types/environmentContext.ts +33 -0
- package/src/types/gitlab-types.ts +36 -6
- package/src/types/jobs.ts +30 -6
- package/src/types/pipeline.ts +1 -1
- package/src/types/utils.ts +7 -0
- package/src/utils/gitlab.ts +23 -0
- package/tsconfig.json +3 -1
- package/dist/build/base/getBuildInfo.d.ts +0 -2
- package/dist/build/tests/storybook.test.d.ts +0 -1
- package/dist/context/resolveReferences.test.js +0 -141
- package/dist/deploy/kubernetes/cloudsql.d.ts +0 -6
- package/dist/deploy/kubernetes/cloudsql.js +0 -16
- package/dist/deploy/types.d.ts +0 -196
- package/dist/deploy/types.js +0 -16
- package/dist/pipeline/createChildPipeline.test.d.ts +0 -1
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -8
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -45
- package/src/build/tests/storybook.test.ts +0 -54
- package/src/deploy/kubernetes/cloudsql.ts +0 -12
- package/src/deploy/types.ts +0 -189
- package/src/pipeline/createChildPipeline.test.ts +0 -49
- package/src/pipeline/createJobs.ts +0 -195
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -16
package/dist/catladder-gitlab.js
CHANGED
|
@@ -4,66 +4,47 @@ var __assign = this && this.__assign || function () {
|
|
|
4
4
|
__assign = Object.assign || function (t) {
|
|
5
5
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
6
|
s = arguments[i];
|
|
7
|
-
|
|
8
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return t;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
return __assign.apply(this, arguments);
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
var __rest = this && this.__rest || function (s, e) {
|
|
18
14
|
var t = {};
|
|
19
|
-
|
|
20
15
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
21
|
-
|
|
22
16
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
17
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
24
18
|
}
|
|
25
19
|
return t;
|
|
26
20
|
};
|
|
27
|
-
|
|
28
21
|
var _a;
|
|
29
|
-
|
|
30
22
|
exports.__esModule = true;
|
|
31
|
-
|
|
32
23
|
var fs_1 = require("fs");
|
|
33
|
-
|
|
34
24
|
var js_yaml_1 = require("js-yaml");
|
|
35
|
-
|
|
36
25
|
var config_1 = require("./config");
|
|
37
|
-
|
|
38
26
|
var constants_1 = require("./constants");
|
|
39
|
-
|
|
40
27
|
var pipeline_1 = require("./pipeline");
|
|
41
|
-
|
|
42
28
|
var _b = process.env,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
CI_MERGE_REQUEST_ID = _b.CI_MERGE_REQUEST_ID,
|
|
30
|
+
CI_COMMIT_TAG = _b.CI_COMMIT_TAG,
|
|
31
|
+
CI_COMMIT_BRANCH = _b.CI_COMMIT_BRANCH,
|
|
32
|
+
CI_DEFAULT_BRANCH = _b.CI_DEFAULT_BRANCH;
|
|
47
33
|
var isDefaultBranch = Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
|
|
48
|
-
var isHotfixBranch =
|
|
49
|
-
|
|
34
|
+
var isHotfixBranch = CI_COMMIT_BRANCH ? /^[0-9]+\.([0-9]+|x)\.x$/.test(CI_COMMIT_BRANCH) : false;
|
|
50
35
|
var isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
|
|
51
36
|
var isTaggedRelease = Boolean(CI_COMMIT_TAG);
|
|
52
37
|
console.info("catladder version ".concat(constants_1.PIPELINE_IMAGE_TAG));
|
|
53
38
|
var trigger = isMergeRequest || isHotfixBranch ? "mr" : isDefaultBranch ? "mainBranch" : isTaggedRelease ? "taggedRelease" : null;
|
|
54
|
-
|
|
55
39
|
if (trigger) {
|
|
56
40
|
var config = (_a = (0, config_1.readConfigSync)()) === null || _a === void 0 ? void 0 : _a.config;
|
|
57
|
-
|
|
58
41
|
if (!config) {
|
|
59
42
|
throw new Error("no catladder config found");
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
(0, pipeline_1.createChildPipeline)("gitlab", trigger, config).then(function (_a) {
|
|
63
45
|
var jobs = _a.jobs,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
mainPipeline = __rest(_a, ["jobs"]);
|
|
47
|
+
// need to spread out the jobs
|
|
67
48
|
(0, fs_1.writeFileSync)("__pipeline.yml", (0, js_yaml_1.dump)(__assign(__assign({}, jobs), mainPipeline)), {
|
|
68
49
|
encoding: "utf-8"
|
|
69
50
|
});
|
|
File without changes
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
|
|
5
|
-
var _1 = require(".");
|
|
6
|
-
|
|
4
|
+
var __1 = require("..");
|
|
7
5
|
describe("getAllEnvsByTrigger", function () {
|
|
8
6
|
var cluster = {
|
|
9
7
|
type: "gcloud",
|
|
@@ -69,43 +67,43 @@ describe("getAllEnvsByTrigger", function () {
|
|
|
69
67
|
};
|
|
70
68
|
describe("mainBranch", function () {
|
|
71
69
|
it("always includes dev if not disabled", function () {
|
|
72
|
-
var envs = (0,
|
|
70
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app1", "mainBranch");
|
|
73
71
|
expect(envs).toEqual(["dev"]);
|
|
74
72
|
});
|
|
75
73
|
it("returns additional dev environments", function () {
|
|
76
|
-
var envs = (0,
|
|
74
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app2", "mainBranch");
|
|
77
75
|
expect(envs).toEqual(["dev", "dev2"]);
|
|
78
76
|
});
|
|
79
77
|
it("does not include disabled envs", function () {
|
|
80
|
-
var envs = (0,
|
|
78
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app3", "mainBranch");
|
|
81
79
|
expect(envs).toEqual([]);
|
|
82
80
|
});
|
|
83
81
|
});
|
|
84
82
|
describe("mr", function () {
|
|
85
83
|
it("always includes review if not disabled", function () {
|
|
86
|
-
var envs = (0,
|
|
84
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app1", "mr");
|
|
87
85
|
expect(envs).toEqual(["review"]);
|
|
88
86
|
});
|
|
89
87
|
it("returns additional dev environments", function () {
|
|
90
|
-
var envs = (0,
|
|
88
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app2", "mr");
|
|
91
89
|
expect(envs).toEqual(["review", "review2"]);
|
|
92
90
|
});
|
|
93
91
|
it("does not include disabled envs", function () {
|
|
94
|
-
var envs = (0,
|
|
92
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app3", "mr");
|
|
95
93
|
expect(envs).toEqual([]);
|
|
96
94
|
});
|
|
97
95
|
});
|
|
98
96
|
describe("taggedRelease", function () {
|
|
99
97
|
it("always includes review if not disabled", function () {
|
|
100
|
-
var envs = (0,
|
|
98
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app1", "taggedRelease");
|
|
101
99
|
expect(envs).toEqual(["stage", "prod"]);
|
|
102
100
|
});
|
|
103
101
|
it("returns additional dev environments", function () {
|
|
104
|
-
var envs = (0,
|
|
102
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app2", "taggedRelease");
|
|
105
103
|
expect(envs).toEqual(["stage", "prod", "stage2", "prod2"]);
|
|
106
104
|
});
|
|
107
105
|
it("does not include disabled envs", function () {
|
|
108
|
-
var envs = (0,
|
|
106
|
+
var envs = (0, __1.getAllEnvsByTrigger)(SIMPLE_CONFIG, "app3", "taggedRelease");
|
|
109
107
|
expect(envs).toEqual([]);
|
|
110
108
|
});
|
|
111
109
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, PipelineTrigger } from "../types";
|
|
1
|
+
import type { Config, PipelineTrigger } from "../types";
|
|
2
2
|
export declare const getAllEnvs: (config: Config, componentName: string) => string[];
|
|
3
3
|
export declare const getAllEnvsInAllComponents: (config: Config) => string[];
|
|
4
4
|
export declare const getAllEnvsByTrigger: (config: Config, componentName: string, trigger: PipelineTrigger) => string[];
|
|
@@ -4,10 +4,9 @@ var __read = this && this.__read || function (o, n) {
|
|
|
4
4
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
5
|
if (!m) return o;
|
|
6
6
|
var i = m.call(o),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
11
10
|
try {
|
|
12
11
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
12
|
} catch (error) {
|
|
@@ -21,10 +20,8 @@ var __read = this && this.__read || function (o, n) {
|
|
|
21
20
|
if (e) throw e.error;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
return ar;
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
29
26
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
27
|
if (ar || !(i in from)) {
|
|
@@ -34,53 +31,41 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
34
31
|
}
|
|
35
32
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
33
|
};
|
|
37
|
-
|
|
38
34
|
exports.__esModule = true;
|
|
39
35
|
exports.getAllEnvsByTrigger = exports.getAllEnvsInAllComponents = exports.getAllEnvs = void 0;
|
|
40
|
-
|
|
41
36
|
var types_1 = require("../types");
|
|
42
|
-
|
|
43
37
|
var getConfiguredAndDefaultEnvs = function (config, componentName, envTypes) {
|
|
44
38
|
var _a, _b;
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
var configuredEnvs = (_a = config.components[componentName].env) !== null && _a !== void 0 ? _a : {};
|
|
40
|
+
// the default envs have the same name as the env types
|
|
47
41
|
// these can be disabled with settimg them to `false`
|
|
48
42
|
// this is the list of all not disabled envs. These are always returned
|
|
49
|
-
|
|
50
43
|
var enabledDefaultEnvs = envTypes.filter(function (e) {
|
|
51
44
|
return configuredEnvs[e] !== false;
|
|
52
45
|
});
|
|
53
46
|
var configuredCustomEnvs = Object.entries((_b = config.components[componentName].env) !== null && _b !== void 0 ? _b : {}).filter(function (_a) {
|
|
54
47
|
var _b = __read(_a, 2),
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
config = _b[1];
|
|
57
49
|
return config && "type" in config && config.type && envTypes.includes(config.type);
|
|
58
50
|
}).map(function (_a) {
|
|
59
51
|
var _b = __read(_a, 1),
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
envName = _b[0];
|
|
62
53
|
return envName;
|
|
63
54
|
});
|
|
64
55
|
return __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(enabledDefaultEnvs), false), __read(configuredCustomEnvs), false))), false);
|
|
65
56
|
};
|
|
66
|
-
|
|
67
57
|
var getAllEnvs = function (config, componentName) {
|
|
68
58
|
return getConfiguredAndDefaultEnvs(config, componentName, types_1.DEFAULT_ENV_TYPES);
|
|
69
59
|
};
|
|
70
|
-
|
|
71
60
|
exports.getAllEnvs = getAllEnvs;
|
|
72
|
-
|
|
73
61
|
var getAllEnvsInAllComponents = function (config) {
|
|
74
62
|
return __spreadArray([], __read(new Set(Object.keys(config.components).flatMap(function (c) {
|
|
75
63
|
return (0, exports.getAllEnvs)(config, c);
|
|
76
64
|
}))), false);
|
|
77
65
|
};
|
|
78
|
-
|
|
79
66
|
exports.getAllEnvsInAllComponents = getAllEnvsInAllComponents;
|
|
80
|
-
|
|
81
67
|
var getAllEnvsByTrigger = function (config, componentName, trigger) {
|
|
82
68
|
var envTypesByTrigger = (0, types_1.getEnvTypesByTrigger)(trigger);
|
|
83
69
|
return getConfiguredAndDefaultEnvs(config, componentName, envTypesByTrigger);
|
|
84
70
|
};
|
|
85
|
-
|
|
86
71
|
exports.getAllEnvsByTrigger = getAllEnvsByTrigger;
|
package/dist/config/index.js
CHANGED
|
@@ -12,13 +12,9 @@ var __createBinding = this && this.__createBinding || (Object.create ? function
|
|
|
12
12
|
if (k2 === undefined) k2 = k;
|
|
13
13
|
o[k2] = m[k];
|
|
14
14
|
});
|
|
15
|
-
|
|
16
15
|
var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
17
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
17
|
};
|
|
19
|
-
|
|
20
18
|
exports.__esModule = true;
|
|
21
|
-
|
|
22
19
|
__exportStar(require("./configruedEnvs"), exports);
|
|
23
|
-
|
|
24
20
|
__exportStar(require("./readConfig"), exports);
|
|
@@ -2,28 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.readConfigSync = void 0;
|
|
5
|
-
|
|
6
5
|
var fs_1 = require("fs");
|
|
7
|
-
|
|
8
6
|
var ts_node_1 = require("ts-node");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
var js_yaml_1 = require("js-yaml");
|
|
8
|
+
// allows us to load ts files
|
|
13
9
|
var fullPath = function (directory, ext) {
|
|
14
10
|
return directory + "/catladder." + ext;
|
|
15
11
|
};
|
|
16
|
-
|
|
17
12
|
function requireUncached(module) {
|
|
18
13
|
delete require.cache[require.resolve(module)];
|
|
19
14
|
return require(module);
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
var readConfigSync = function (directory) {
|
|
23
17
|
if (directory === void 0) {
|
|
24
18
|
directory = process.cwd();
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
(0, ts_node_1.register)({
|
|
28
21
|
cwd: directory,
|
|
29
22
|
transpileOnly: true,
|
|
@@ -34,10 +27,8 @@ var readConfigSync = function (directory) {
|
|
|
34
27
|
var found = ["ts", "js", "yml", "yaml"].find(function (extension) {
|
|
35
28
|
return (0, fs_1.existsSync)(fullPath(directory, extension));
|
|
36
29
|
});
|
|
37
|
-
|
|
38
30
|
if (found) {
|
|
39
31
|
var filePath = fullPath(directory, found);
|
|
40
|
-
|
|
41
32
|
if (found === "ts" || found === "js") {
|
|
42
33
|
return {
|
|
43
34
|
path: filePath,
|
|
@@ -55,8 +46,6 @@ var readConfigSync = function (directory) {
|
|
|
55
46
|
};
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
return null;
|
|
60
50
|
};
|
|
61
|
-
|
|
62
51
|
exports.readConfigSync = readConfigSync;
|
package/dist/constants.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
5
|
-
exports.PIPELINE_IMAGE_TAG = "
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "prettier-cbceeed9" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
File without changes
|
|
@@ -0,0 +1,336 @@
|
|
|
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 (_) 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
|
+
exports.__esModule = true;
|
|
119
|
+
var resolveReferences_1 = require("../resolveReferences");
|
|
120
|
+
describe("resolveReferences", function () {
|
|
121
|
+
it("replaces occurences of ${componentName:VARIABLE_NAME}", function () {
|
|
122
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var variables, otherVariables, result;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
variables = {
|
|
128
|
+
a: "hello world",
|
|
129
|
+
b: "a replaced value looks like this: '${api:FOO}', nice!"
|
|
130
|
+
};
|
|
131
|
+
otherVariables = {
|
|
132
|
+
api: {
|
|
133
|
+
FOO: "foo from api"
|
|
134
|
+
},
|
|
135
|
+
frontend: {
|
|
136
|
+
FOO: "foo from frontend"
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
140
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
return [2 /*return*/, otherVariables[componentName]];
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
})];
|
|
146
|
+
case 1:
|
|
147
|
+
result = _a.sent();
|
|
148
|
+
expect(result).toEqual({
|
|
149
|
+
a: "hello world",
|
|
150
|
+
b: "a replaced value looks like this: 'foo from api', nice!"
|
|
151
|
+
});
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("replaces self references with structure ${VARIABLE_NAME}", function () {
|
|
159
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
160
|
+
var variables, result;
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
switch (_a.label) {
|
|
163
|
+
case 0:
|
|
164
|
+
variables = {
|
|
165
|
+
FOO: "hello world",
|
|
166
|
+
BAR: "this: ${FOO}!"
|
|
167
|
+
};
|
|
168
|
+
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables)];
|
|
169
|
+
case 1:
|
|
170
|
+
result = _a.sent();
|
|
171
|
+
expect(result).toEqual({
|
|
172
|
+
FOO: "hello world",
|
|
173
|
+
BAR: "this: hello world!"
|
|
174
|
+
});
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("replaces self references mixed with other vars", function () {
|
|
182
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
183
|
+
var variables, otherVariables, result;
|
|
184
|
+
return __generator(this, function (_a) {
|
|
185
|
+
switch (_a.label) {
|
|
186
|
+
case 0:
|
|
187
|
+
variables = {
|
|
188
|
+
FOO: "hello from ${api:FOO}",
|
|
189
|
+
BAR: "this: ${FOO}!"
|
|
190
|
+
};
|
|
191
|
+
otherVariables = {
|
|
192
|
+
api: {
|
|
193
|
+
FOO: "foo from api"
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
197
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
return [2 /*return*/, otherVariables[componentName]];
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
})];
|
|
203
|
+
case 1:
|
|
204
|
+
result = _a.sent();
|
|
205
|
+
expect(result).toEqual({
|
|
206
|
+
FOO: "hello from foo from api",
|
|
207
|
+
BAR: "this: hello from foo from api!"
|
|
208
|
+
});
|
|
209
|
+
return [2 /*return*/];
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("keeps variables as is if not found (when null is returned)", function () {
|
|
216
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
217
|
+
var variables, otherVariables, result;
|
|
218
|
+
return __generator(this, function (_a) {
|
|
219
|
+
switch (_a.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
variables = {
|
|
222
|
+
a: "hello world",
|
|
223
|
+
b: "a not found value looks like this: '${api:FOO}'"
|
|
224
|
+
};
|
|
225
|
+
otherVariables = {};
|
|
226
|
+
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
227
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
return [2 /*return*/, otherVariables[componentName]];
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
})];
|
|
233
|
+
case 1:
|
|
234
|
+
result = _a.sent();
|
|
235
|
+
expect(result).toEqual({
|
|
236
|
+
a: "hello world",
|
|
237
|
+
b: "a not found value looks like this: '${api:FOO}'"
|
|
238
|
+
});
|
|
239
|
+
return [2 /*return*/];
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("replaces mulitple levels deep", function () {
|
|
246
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
247
|
+
var variables, otherVariables, result;
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
variables = {
|
|
252
|
+
a: "value is ${frontend:FOO}!"
|
|
253
|
+
};
|
|
254
|
+
otherVariables = {
|
|
255
|
+
api: {
|
|
256
|
+
FOO: "foo from api"
|
|
257
|
+
},
|
|
258
|
+
frontend: {
|
|
259
|
+
FOO: "hi, ${api:FOO}"
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
263
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
264
|
+
return __generator(this, function (_a) {
|
|
265
|
+
return [2 /*return*/, otherVariables[componentName]];
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
})];
|
|
269
|
+
case 1:
|
|
270
|
+
result = _a.sent();
|
|
271
|
+
expect(result).toEqual({
|
|
272
|
+
a: "value is hi, foo from api!"
|
|
273
|
+
});
|
|
274
|
+
return [2 /*return*/];
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it("prevents endless loops", function () {
|
|
281
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
282
|
+
var variables, otherVariables, result;
|
|
283
|
+
return __generator(this, function (_a) {
|
|
284
|
+
switch (_a.label) {
|
|
285
|
+
case 0:
|
|
286
|
+
variables = {
|
|
287
|
+
a: "value is ${frontend:FOO}!"
|
|
288
|
+
};
|
|
289
|
+
otherVariables = {
|
|
290
|
+
api: {
|
|
291
|
+
FOO: "api ${frontend:FOO}"
|
|
292
|
+
},
|
|
293
|
+
frontend: {
|
|
294
|
+
FOO: "frontend ${api:FOO}"
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
|
|
298
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
299
|
+
return __generator(this, function (_a) {
|
|
300
|
+
return [2 /*return*/, otherVariables[componentName]];
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
})];
|
|
304
|
+
case 1:
|
|
305
|
+
result = _a.sent();
|
|
306
|
+
expect(result).toEqual({
|
|
307
|
+
a: "value is frontend api ${frontend:FOO}!"
|
|
308
|
+
});
|
|
309
|
+
return [2 /*return*/];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
describe("translateLegacyFromComponents", function () {
|
|
317
|
+
it("translatetes the old `fromComponents` approach to ${componentName:variableName}", function () {
|
|
318
|
+
var fromComponents = {
|
|
319
|
+
api: {
|
|
320
|
+
API_FOO: "FOO",
|
|
321
|
+
API_BAR: "BAR"
|
|
322
|
+
},
|
|
323
|
+
www: {
|
|
324
|
+
WWW_X: "X",
|
|
325
|
+
WWW_Y: "Y"
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
var result = (0, resolveReferences_1.translateLegacyFromComponents)(fromComponents);
|
|
329
|
+
expect(result).toEqual({
|
|
330
|
+
API_FOO: "${api:FOO}",
|
|
331
|
+
API_BAR: "${api:BAR}",
|
|
332
|
+
WWW_X: "${www:X}",
|
|
333
|
+
WWW_Y: "${www:Y}"
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.getEnvConfig = void 0;
|
|
5
|
+
var utils_1 = require("../utils");
|
|
6
|
+
var getEnvConfig = function (config, componentName, env) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
var defaultConfig = config.components[componentName];
|
|
9
|
+
if (!defaultConfig) {
|
|
10
|
+
throw new Error("unknown component " + componentName);
|
|
11
|
+
}
|
|
12
|
+
var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
|
|
13
|
+
if (envCustomizations === false) {
|
|
14
|
+
throw new Error("env is disabled: " + env + ":" + componentName);
|
|
15
|
+
}
|
|
16
|
+
return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
|
|
17
|
+
};
|
|
18
|
+
exports.getEnvConfig = getEnvConfig;
|