@catladder/pipeline 0.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.
Files changed (80) hide show
  1. package/Dockerfile +84 -0
  2. package/dist/scripts/magic/createChildPipeline/index.d.ts +5 -0
  3. package/dist/scripts/magic/createChildPipeline/index.js +141 -0
  4. package/dist/scripts/magic/createPipeline.d.ts +14 -0
  5. package/dist/scripts/magic/createPipeline.js +80 -0
  6. package/dist/scripts/magic/index.d.ts +2 -0
  7. package/dist/scripts/magic/index.js +16 -0
  8. package/dist/scripts/magic/sample-config.d.ts +3 -0
  9. package/dist/scripts/magic/sample-config.js +77 -0
  10. package/dist/scripts/magic/types/build/docker.d.ts +2 -0
  11. package/dist/scripts/magic/types/build/docker.js +63 -0
  12. package/dist/scripts/magic/types/build/index.d.ts +6 -0
  13. package/dist/scripts/magic/types/build/index.js +8 -0
  14. package/dist/scripts/magic/types/build/node.d.ts +3 -0
  15. package/dist/scripts/magic/types/build/node.js +118 -0
  16. package/dist/scripts/magic/types/build/types.d.ts +7 -0
  17. package/dist/scripts/magic/types/build/types.js +2 -0
  18. package/dist/scripts/magic/types/config.d.ts +49 -0
  19. package/dist/scripts/magic/types/config.js +17 -0
  20. package/dist/scripts/magic/types/context.d.ts +12 -0
  21. package/dist/scripts/magic/types/context.js +2 -0
  22. package/dist/scripts/magic/types/deploy/index.d.ts +6 -0
  23. package/dist/scripts/magic/types/deploy/index.js +8 -0
  24. package/dist/scripts/magic/types/deploy/kubernetes.d.ts +3 -0
  25. package/dist/scripts/magic/types/deploy/kubernetes.js +46 -0
  26. package/dist/scripts/magic/types/deploy/types.d.ts +41 -0
  27. package/dist/scripts/magic/types/deploy/types.js +7 -0
  28. package/dist/scripts/magic/types/gitlab-types.d.ts +63 -0
  29. package/dist/scripts/magic/types/gitlab-types.js +2 -0
  30. package/dist/scripts/magic/types/index.d.ts +3 -0
  31. package/dist/scripts/magic/types/index.js +15 -0
  32. package/dist/scripts/magic.d.ts +2 -0
  33. package/dist/scripts/magic.js +43 -0
  34. package/dist/scripts/monorepoGenerate.d.ts +2 -0
  35. package/dist/scripts/monorepoGenerate.js +164 -0
  36. package/dist/scripts/printAllValues.d.ts +2 -0
  37. package/dist/scripts/printAllValues.js +58 -0
  38. package/dist/scripts/printBuildEnv.d.ts +2 -0
  39. package/dist/scripts/printBuildEnv.js +77 -0
  40. package/dist/scripts/utils/extractAllValues.d.ts +1 -0
  41. package/dist/scripts/utils/extractAllValues.js +78 -0
  42. package/dist/scripts/utils/extractBuildEnv.d.ts +5 -0
  43. package/dist/scripts/utils/extractBuildEnv.js +152 -0
  44. package/dist/scripts/utils/extractValuesFromEnvVars.d.ts +2 -0
  45. package/dist/scripts/utils/extractValuesFromEnvVars.js +63 -0
  46. package/dist/scripts/utils/extractValuesFromMr.d.ts +2 -0
  47. package/dist/scripts/utils/extractValuesFromMr.js +86 -0
  48. package/dist/tests/extractValuesFromMr.test.d.ts +1 -0
  49. package/dist/tests/extractValuesFromMr.test.js +68 -0
  50. package/package.json +21 -0
  51. package/scripts/getCommitInfo +11 -0
  52. package/scripts/kubernetesCreateSecret +8 -0
  53. package/scripts/kubernetesDelete +4 -0
  54. package/scripts/kubernetesDeploy +57 -0
  55. package/scripts/kubernetesEnsureNamespace +3 -0
  56. package/scripts/magic/createChildPipeline/index.ts +163 -0
  57. package/scripts/magic/createPipeline.ts +48 -0
  58. package/scripts/magic/index.ts +2 -0
  59. package/scripts/magic/sample-config.ts +78 -0
  60. package/scripts/magic/types/build/docker.ts +36 -0
  61. package/scripts/magic/types/build/index.ts +11 -0
  62. package/scripts/magic/types/build/node.ts +107 -0
  63. package/scripts/magic/types/build/types.ts +9 -0
  64. package/scripts/magic/types/config.ts +54 -0
  65. package/scripts/magic/types/context.ts +13 -0
  66. package/scripts/magic/types/deploy/index.ts +11 -0
  67. package/scripts/magic/types/deploy/kubernetes.ts +38 -0
  68. package/scripts/magic/types/deploy/types.ts +29 -0
  69. package/scripts/magic/types/gitlab-types.ts +77 -0
  70. package/scripts/magic/types/index.ts +3 -0
  71. package/scripts/magic.ts +51 -0
  72. package/scripts/monorepoGenerate.ts +104 -0
  73. package/scripts/printAllValues.ts +17 -0
  74. package/scripts/printBuildEnv.ts +22 -0
  75. package/scripts/utils/extractAllValues.ts +32 -0
  76. package/scripts/utils/extractBuildEnv.ts +92 -0
  77. package/scripts/utils/extractValuesFromEnvVars.ts +21 -0
  78. package/scripts/utils/extractValuesFromMr.ts +39 -0
  79. package/tests/extractValuesFromMr.test.ts +156 -0
  80. package/tsconfig.json +10 -0
@@ -0,0 +1,49 @@
1
+ import { BuildConfig } from "./build/types";
2
+ import { DeployConfig } from "./deploy/types";
3
+ export declare type PipelineTrigger = "mainBranch" | "mr" | "taggedRelease";
4
+ export declare const ENV_TYPES: {
5
+ readonly dev: {
6
+ readonly trigger: "mainBranch";
7
+ };
8
+ readonly review: {
9
+ readonly trigger: "mr";
10
+ };
11
+ readonly prod: {
12
+ readonly trigger: "taggedRelease";
13
+ };
14
+ readonly stage: {
15
+ readonly trigger: "taggedRelease";
16
+ };
17
+ };
18
+ declare type EnvType = keyof typeof ENV_TYPES;
19
+ declare type DefaultEnvConfig = {
20
+ deploy: DeployConfig;
21
+ build: BuildConfig;
22
+ vars?: {
23
+ public?: Record<string, any>;
24
+ secret?: Record<string, string>;
25
+ fromComponents?: {
26
+ [otherApp: string]: Record<string, string>;
27
+ };
28
+ };
29
+ };
30
+ declare type EnvConfig<E extends EnvType = EnvType> = {
31
+ type?: E;
32
+ hostname?: string;
33
+ } & Partial<DefaultEnvConfig>;
34
+ export declare type Env = {
35
+ dev?: EnvConfig<"dev">;
36
+ stage?: EnvConfig<"stage">;
37
+ review?: EnvConfig<"review">;
38
+ prod?: EnvConfig<"prod">;
39
+ } & Record<string, EnvConfig>;
40
+ export declare type ComponentConfig = {
41
+ env?: Env;
42
+ dir: string;
43
+ } & DefaultEnvConfig;
44
+ export declare type Config = {
45
+ customerName: string;
46
+ appName: string;
47
+ components: Record<string, ComponentConfig>;
48
+ };
49
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.ENV_TYPES = void 0;
4
+ exports.ENV_TYPES = {
5
+ dev: {
6
+ trigger: "mainBranch"
7
+ },
8
+ review: {
9
+ trigger: "mr"
10
+ },
11
+ prod: {
12
+ trigger: "taggedRelease"
13
+ },
14
+ stage: {
15
+ trigger: "taggedRelease"
16
+ }
17
+ };
@@ -0,0 +1,12 @@
1
+ import { ComponentConfig, Config } from "./config";
2
+ export declare type Environment = {
3
+ fullName: string;
4
+ shortName: string;
5
+ url: string;
6
+ variables: Record<string, string>;
7
+ };
8
+ export declare type Context = {
9
+ componentConfig: ComponentConfig;
10
+ componentName: string;
11
+ fullConfig: Config;
12
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -0,0 +1,6 @@
1
+ import { GitlabJobs } from "../gitlab-types";
2
+ import { ComponentConfig } from "../config";
3
+ import { Context } from "../context";
4
+ export declare const deployJobCreators: {
5
+ [type in ComponentConfig["deploy"]["type"]]: (context: Context) => GitlabJobs;
6
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.deployJobCreators = void 0;
4
+ var kubernetes_1 = require("./kubernetes");
5
+ exports.deployJobCreators = {
6
+ kubernetes: kubernetes_1.createKubernetesDeployJobs,
7
+ serverless: function () { return []; }
8
+ };
@@ -0,0 +1,3 @@
1
+ import { GitlabJobs } from "../gitlab-types";
2
+ import { Context } from "../context";
3
+ export declare const createKubernetesDeployJobs: (context: Context) => GitlabJobs;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ exports.__esModule = true;
14
+ exports.createKubernetesDeployJobs = void 0;
15
+ var types_1 = require("./types");
16
+ var createKubernetesDeployJobs = function (context) {
17
+ var deployConfig = context.componentConfig.deploy;
18
+ if (!types_1.isOfType(deployConfig, "kubernetes")) {
19
+ // should not happen
20
+ throw new Error("deploy config is not kubernetes");
21
+ }
22
+ return [
23
+ {
24
+ name: "deploy-to-kubernetes",
25
+ env: true,
26
+ job: function (environment) { return ({
27
+ variables: __assign(__assign({}, environment.variables), { RELEASE_NAME: "${CUSTOMER_NAME}-${APP_NAME}-${CI_ENVIRONMENT_SLUG}" }),
28
+ stage: "deploy",
29
+ dependencies: [],
30
+ script: [
31
+ "kubernetesEnsureNamespace",
32
+ "kubernetesCreateSecret",
33
+ "kubernetesDeploy",
34
+ ],
35
+ environment: {
36
+ name: environment.fullName,
37
+ url: environment.url,
38
+ kubernetes: {
39
+ namespace: environment.variables.KUBE_NAMESPACE
40
+ }
41
+ }
42
+ }); }
43
+ },
44
+ ];
45
+ };
46
+ exports.createKubernetesDeployJobs = createKubernetesDeployJobs;
@@ -0,0 +1,41 @@
1
+ export declare type DeployConfigBase = {};
2
+ export declare type DeployConfigKubernetes = {
3
+ type: "kubernetes";
4
+ additionalHelmArgs?: string[];
5
+ values?: {
6
+ application?: {
7
+ resources?: {
8
+ limits?: {
9
+ cpu?: any;
10
+ };
11
+ requests?: {
12
+ cpu?: any;
13
+ };
14
+ };
15
+ } & Record<string, any>;
16
+ } & Record<string, any>;
17
+ } & DeployConfigBase;
18
+ export declare type DeployConfigServerless = {
19
+ type: "serverless";
20
+ };
21
+ export declare type DeployConfig = DeployConfigKubernetes | DeployConfigServerless;
22
+ export declare const isOfType: <T extends "kubernetes" | "serverless">(t: DeployConfig, type: T) => t is Extract<{
23
+ type: "kubernetes";
24
+ additionalHelmArgs?: string[] | undefined;
25
+ values?: ({
26
+ application?: ({
27
+ resources?: {
28
+ limits?: {
29
+ cpu?: any;
30
+ } | undefined;
31
+ requests?: {
32
+ cpu?: any;
33
+ } | undefined;
34
+ } | undefined;
35
+ } & Record<string, any>) | undefined;
36
+ } & Record<string, any>) | undefined;
37
+ }, {
38
+ type: T;
39
+ }> | Extract<DeployConfigServerless, {
40
+ type: T;
41
+ }>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.isOfType = void 0;
4
+ var isOfType = function (t, type) {
5
+ return t.type === type;
6
+ };
7
+ exports.isOfType = isOfType;
@@ -0,0 +1,63 @@
1
+ import { Environment } from "./context";
2
+ export declare type GitlabStage = "setup" | "test" | "build" | "deploy" | "verify" | "actions";
3
+ export declare type Artifacts = {
4
+ paths: string[];
5
+ };
6
+ export declare type GitlabJobCache = {
7
+ key: string;
8
+ policy?: string;
9
+ paths: string[];
10
+ };
11
+ export declare type GitlabRule = {
12
+ if: string;
13
+ when?: "always" | "on_success" | "manual" | "never";
14
+ };
15
+ export declare type Retry = {
16
+ max: number;
17
+ when: string[];
18
+ };
19
+ export declare type Service = {
20
+ name: string;
21
+ command: string[];
22
+ };
23
+ export declare type GitlabEnvironment = {
24
+ url: string;
25
+ name: string;
26
+ kubernetes?: {
27
+ namespace?: string;
28
+ };
29
+ };
30
+ export declare type GitlabJobDef = {
31
+ stage: GitlabStage;
32
+ before_script?: string[];
33
+ script: string[];
34
+ interruptible?: boolean;
35
+ needs?: string[];
36
+ rules?: GitlabRule[];
37
+ cache?: GitlabJobCache | GitlabJobCache[];
38
+ artifacts?: Artifacts;
39
+ retry?: Retry;
40
+ services?: Service[];
41
+ image?: string;
42
+ variables?: GitlabVariables;
43
+ dependencies?: string[];
44
+ environment?: GitlabEnvironment;
45
+ };
46
+ export declare type GitlabVariables = Record<string, string | undefined>;
47
+ export declare type JobEnvDependent = {
48
+ name: string;
49
+ env: true;
50
+ job: (environment: Environment) => GitlabJobDef;
51
+ };
52
+ export declare type JobNonEnv = {
53
+ name: string;
54
+ env: false;
55
+ job: () => GitlabJobDef;
56
+ };
57
+ export declare type GitlabJob = JobEnvDependent | JobNonEnv;
58
+ export declare type GitlabJobs = GitlabJob[];
59
+ export declare type GitlabPipeline = {
60
+ variables: GitlabVariables;
61
+ stages: GitlabStage[];
62
+ jobs: GitlabJobs;
63
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ exports.__esModule = true;
@@ -0,0 +1,3 @@
1
+ export * from "./config";
2
+ export * from "./gitlab-types";
3
+ export * from "./context";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ exports.__esModule = true;
13
+ __exportStar(require("./config"), exports);
14
+ __exportStar(require("./gitlab-types"), exports);
15
+ __exportStar(require("./context"), exports);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ts-node
2
+ "use strict";
3
+ exports.__esModule = true;
4
+ var fs_1 = require("fs");
5
+ var yaml_1 = require("yaml");
6
+ var createPipeline_1 = require("./magic/createPipeline");
7
+ var _a = process.env, CI_MERGE_REQUEST_ID = _a.CI_MERGE_REQUEST_ID, CI_COMMIT_TAG = _a.CI_COMMIT_TAG, CI_COMMIT_BRANCH = _a.CI_COMMIT_BRANCH, CI_DEFAULT_BRANCH = _a.CI_DEFAULT_BRANCH;
8
+ var isDefaultBranch = CI_COMMIT_BRANCH == CI_DEFAULT_BRANCH;
9
+ var isHotfixBranch = false; // TODO: $CI_COMMIT_BRANCH =~ /^[0-9]+\.([0-9]+|x)\.x$/
10
+ var isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
11
+ var isTaggedRelease = Boolean(CI_COMMIT_TAG);
12
+ var fullName = function (ext) { return "catladder." + ext; };
13
+ var readConfig = function () {
14
+ var found = ["ts", "js", "yml", "yaml"].find(function (extension) {
15
+ return fs_1.existsSync(fullName(extension));
16
+ });
17
+ if (found) {
18
+ if (found === "ts" || found === "js") {
19
+ return require(fullName(found));
20
+ }
21
+ else {
22
+ return yaml_1.parse(fullName(found));
23
+ }
24
+ }
25
+ };
26
+ var trigger = isMergeRequest || isHotfixBranch
27
+ ? "mr"
28
+ : isDefaultBranch
29
+ ? "mainBranch"
30
+ : isTaggedRelease
31
+ ? "taggedRelease"
32
+ : null;
33
+ if (trigger) {
34
+ var config = readConfig();
35
+ createPipeline_1.createPipeline(trigger, config).then(function (mainPipeline) {
36
+ fs_1.writeFileSync("__pipeline.yml", JSON.stringify(mainPipeline, null, 2), {
37
+ encoding: "utf-8"
38
+ });
39
+ });
40
+ }
41
+ else {
42
+ throw new Error("no matching trigger");
43
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env ts-node
2
+ "use strict";
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ 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;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ var __importDefault = (this && this.__importDefault) || function (mod) {
51
+ return (mod && mod.__esModule) ? mod : { "default": mod };
52
+ };
53
+ exports.__esModule = true;
54
+ var fs_1 = require("fs");
55
+ var path_1 = require("path");
56
+ var yaml_1 = require("yaml");
57
+ var yargs_1 = __importDefault(require("yargs"));
58
+ var helpers_1 = require("yargs/helpers");
59
+ var extractBuildEnv_1 = require("./utils/extractBuildEnv");
60
+ var args = yargs_1["default"](helpers_1.hideBin(process.argv)).array("env").argv;
61
+ var thisGitlabCi = yaml_1.parse(fs_1.readFileSync(".gitlab-ci.yml", { encoding: "utf-8" }));
62
+ var subcis = fs_1.readdirSync(".")
63
+ .filter(function (file) { return fs_1.lstatSync(file).isDirectory(); })
64
+ .map(function (dir) { return ({
65
+ dirname: dir,
66
+ ci: path_1.join(dir, ".gitlab-ci.yml")
67
+ }); })
68
+ .filter(function (_a) {
69
+ var ci = _a.ci;
70
+ return fs_1.existsSync(ci);
71
+ });
72
+ var makeConfig = function (_a) {
73
+ var subapp = _a.subapp, type = _a.type, ci = _a.ci, env = _a.env;
74
+ return __awaiter(void 0, void 0, void 0, function () {
75
+ var changes, rules, _b;
76
+ var _c, _d;
77
+ return __generator(this, function (_e) {
78
+ switch (_e.label) {
79
+ case 0:
80
+ changes = [subapp + "/**/*"];
81
+ rules = [
82
+ // same as rules "always", but with `changes` to only trigger changed branches
83
+ { "if": "$CI_COMMIT_TAG" },
84
+ {
85
+ "if": "$CI_COMMIT_MESSAGE =~ /^chore(release).*/",
86
+ when: "never"
87
+ },
88
+ { "if": "$CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/" },
89
+ {
90
+ "if": "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH",
91
+ changes: changes
92
+ },
93
+ // add it manually when no changes
94
+ {
95
+ "if": "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH",
96
+ when: "manual"
97
+ },
98
+ { "if": "$CI_MERGE_REQUEST_ID", changes: changes },
99
+ // add it manually when no changes
100
+ { "if": "$CI_MERGE_REQUEST_ID", when: "manual" },
101
+ ];
102
+ _c = {};
103
+ _b = [__assign(__assign({}, thisGitlabCi.variables), (_d = { APP_DIR: subapp, VALUES_DIR: subapp, COMPONENT_NAME: subapp, PARENT_PIPELINE_ID: "$CI_PIPELINE_ID" }, _d[type.toUpperCase() + "_ONLY"] = "1", _d))];
104
+ return [4 /*yield*/, extractBuildEnv_1.extractBuildEnv(subapp, env)];
105
+ case 1: return [2 /*return*/, (_c.variables = __assign.apply(void 0, _b.concat([(_e.sent())])),
106
+ _c.stage = type,
107
+ _c.rules = rules,
108
+ _c.trigger = {
109
+ include: ci,
110
+ strategy: "depend"
111
+ },
112
+ _c)];
113
+ }
114
+ });
115
+ });
116
+ };
117
+ var generateSubPipeline = function (type, envs) { return __awaiter(void 0, void 0, void 0, function () {
118
+ return __generator(this, function (_a) {
119
+ switch (_a.label) {
120
+ case 0: return [4 /*yield*/, envs.reduce(function (acc, env) { return __awaiter(void 0, void 0, void 0, function () {
121
+ var _a, _b;
122
+ return __generator(this, function (_c) {
123
+ switch (_c.label) {
124
+ case 0:
125
+ _a = [{}];
126
+ return [4 /*yield*/, acc];
127
+ case 1:
128
+ _b = [__assign.apply(void 0, _a.concat([(_c.sent())]))];
129
+ return [4 /*yield*/, subcis.reduce(function (inneracc, _a) {
130
+ var dirname = _a.dirname, ci = _a.ci;
131
+ return __awaiter(void 0, void 0, void 0, function () {
132
+ var _b, _c, _d;
133
+ var _e;
134
+ return __generator(this, function (_f) {
135
+ switch (_f.label) {
136
+ case 0:
137
+ _b = [{}];
138
+ return [4 /*yield*/, inneracc];
139
+ case 1:
140
+ _c = [__assign.apply(void 0, _b.concat([(_f.sent())]))];
141
+ _e = {};
142
+ _d = env + "-" + dirname + " " + type;
143
+ return [4 /*yield*/, makeConfig({
144
+ subapp: dirname,
145
+ ci: ci,
146
+ type: type,
147
+ env: env
148
+ })];
149
+ case 2: return [2 /*return*/, (__assign.apply(void 0, _c.concat([(_e[_d] = _f.sent(), _e)])))];
150
+ }
151
+ });
152
+ });
153
+ }, {})];
154
+ case 2: return [2 /*return*/, __assign.apply(void 0, _b.concat([(_c.sent())]))];
155
+ }
156
+ });
157
+ }); }, {})];
158
+ case 1: return [2 /*return*/, _a.sent()];
159
+ }
160
+ });
161
+ }); };
162
+ generateSubPipeline(args.t, args.env).then(function (p) {
163
+ return console.log(JSON.stringify(p, null, 2));
164
+ });
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ts-node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (_) try {
19
+ 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;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ var __importDefault = (this && this.__importDefault) || function (mod) {
40
+ return (mod && mod.__esModule) ? mod : { "default": mod };
41
+ };
42
+ exports.__esModule = true;
43
+ var yargs_1 = __importDefault(require("yargs"));
44
+ var helpers_1 = require("yargs/helpers");
45
+ var extractAllValues_1 = require("./utils/extractAllValues");
46
+ var args = yargs_1["default"](helpers_1.hideBin(process.argv)).argv;
47
+ extractAllValues_1.extractAllValues(args.d, args.e)
48
+ .then(function (values) { return __awaiter(void 0, void 0, void 0, function () {
49
+ var _a;
50
+ return __generator(this, function (_b) {
51
+ console.log((_a = JSON.stringify(values, null, 2)) !== null && _a !== void 0 ? _a : "");
52
+ return [2 /*return*/];
53
+ });
54
+ }); })["catch"](function (e) {
55
+ console.error("could not extract values", {
56
+ error: e
57
+ });
58
+ });
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ts-node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (_) try {
19
+ 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;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ var __read = (this && this.__read) || function (o, n) {
40
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
41
+ if (!m) return o;
42
+ var i = m.call(o), r, ar = [], e;
43
+ try {
44
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
+ }
46
+ catch (error) { e = { error: error }; }
47
+ finally {
48
+ try {
49
+ if (r && !r.done && (m = i["return"])) m.call(i);
50
+ }
51
+ finally { if (e) throw e.error; }
52
+ }
53
+ return ar;
54
+ };
55
+ var __importDefault = (this && this.__importDefault) || function (mod) {
56
+ return (mod && mod.__esModule) ? mod : { "default": mod };
57
+ };
58
+ exports.__esModule = true;
59
+ var lodash_1 = require("lodash");
60
+ var yargs_1 = __importDefault(require("yargs"));
61
+ var helpers_1 = require("yargs/helpers");
62
+ var extractBuildEnv_1 = require("./utils/extractBuildEnv");
63
+ var args = yargs_1["default"](helpers_1.hideBin(process.argv)).argv;
64
+ extractBuildEnv_1.extractBuildEnv(args.d, args.e)
65
+ .then(function (values) { return __awaiter(void 0, void 0, void 0, function () {
66
+ return __generator(this, function (_a) {
67
+ Object.entries(values).forEach(function (_a) {
68
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
69
+ return console.log(key + ": \"" + (lodash_1.isObject(value) ? JSON.stringify(value) : value) + "\"");
70
+ });
71
+ return [2 /*return*/];
72
+ });
73
+ }); })["catch"](function (e) {
74
+ console.error("could not extract values", {
75
+ error: e
76
+ });
77
+ });
@@ -0,0 +1 @@
1
+ export declare const extractAllValues: (appDirectory: string, env: string | null) => Promise<any>;