@catladder/pipeline 1.159.0 → 1.160.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/examples/.test-gen-ignore +1 -0
- package/examples/__snapshots__/{cloud-run-memory-limit.ts.snap → cloud-run-memory-limit.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-meteor-with-worker.ts.snap → cloud-run-meteor-with-worker.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-no-cpu-throttling.ts.snap → cloud-run-no-cpu-throttling.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-no-service.ts.snap → cloud-run-no-service.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-non-public.ts.snap → cloud-run-non-public.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-post-stop-job.ts.snap → cloud-run-post-stop-job.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-service-gen2.ts.snap → cloud-run-service-gen2.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-service-increase-timout.ts.snap → cloud-run-service-increase-timout.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-service-with-volumes.ts.snap → cloud-run-service-with-volumes.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-storybook.ts.snap → cloud-run-storybook.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-with-ngnix.ts.snap → cloud-run-with-ngnix.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-with-sql-reuse-db.ts.snap → cloud-run-with-sql-reuse-db.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-with-sql.ts.snap → cloud-run-with-sql.test.ts.snap} +1 -1
- package/examples/__snapshots__/{cloud-run-with-worker.ts.snap → cloud-run-with-worker.test.ts.snap} +1 -1
- package/examples/__snapshots__/{custom-build-job-with-tests.ts.snap → custom-build-job-with-tests.test.ts.snap} +1 -1
- package/examples/__snapshots__/{custom-build-job.ts.snap → custom-build-job.test.ts.snap} +1 -1
- package/examples/__snapshots__/{custom-deploy.ts.snap → custom-deploy.test.ts.snap} +1 -1
- package/examples/__snapshots__/{custom-envs.ts.snap → custom-envs.test.ts.snap} +1 -1
- package/examples/__snapshots__/{custom-sbom-java.ts.snap → custom-sbom-java.test.ts.snap} +1 -1
- package/examples/__snapshots__/{git-submodule.ts.snap → git-submodule.test.ts.snap} +1 -1
- package/examples/__snapshots__/{kubernetes-application-customization.ts.snap → kubernetes-application-customization.test.ts.snap} +1 -1
- package/examples/__snapshots__/{kubernetes-with-cloud-sql-legacy.ts.snap → kubernetes-with-cloud-sql-legacy.test.ts.snap} +1 -1
- package/examples/__snapshots__/{kubernetes-with-cloud-sql.ts.snap → kubernetes-with-cloud-sql.test.ts.snap} +1 -1
- package/examples/__snapshots__/{kubernetes-with-jobs.ts.snap → kubernetes-with-jobs.test.ts.snap} +1 -1
- package/examples/__snapshots__/{kubernetes-with-mongodb.ts.snap → kubernetes-with-mongodb.test.ts.snap} +1 -1
- package/examples/__snapshots__/{local-dot-env.ts.snap → local-dot-env.test.ts.snap} +1 -1
- package/examples/__snapshots__/{meteor-kubernetes.ts.snap → meteor-kubernetes.test.ts.snap} +1 -1
- package/examples/__snapshots__/{multiline-var.ts.snap → multiline-var.test.ts.snap} +1 -1
- package/examples/__snapshots__/{native-app.ts.snap → native-app.test.ts.snap} +1 -1
- package/examples/__snapshots__/{node-build-with-custom-image.ts.snap → node-build-with-custom-image.test.ts.snap} +1 -1
- package/examples/__snapshots__/{node-build-with-docker-additions.ts.snap → node-build-with-docker-additions.test.ts.snap} +1 -1
- package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +2011 -0
- package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +1995 -0
- package/examples/__snapshots__/{wait-for-other-deploy.ts.snap → wait-for-other-deploy.test.ts.snap} +1 -1
- package/examples/cloud-run-memory-limit.test.ts +10 -0
- package/examples/cloud-run-memory-limit.ts +2 -4
- package/examples/cloud-run-meteor-with-worker.test.ts +10 -0
- package/examples/cloud-run-meteor-with-worker.ts +2 -4
- package/examples/cloud-run-no-cpu-throttling.test.ts +10 -0
- package/examples/cloud-run-no-cpu-throttling.ts +2 -4
- package/examples/cloud-run-no-service.test.ts +10 -0
- package/examples/cloud-run-no-service.ts +1 -4
- package/examples/cloud-run-non-public.test.ts +10 -0
- package/examples/cloud-run-non-public.ts +1 -4
- package/examples/cloud-run-post-stop-job.test.ts +10 -0
- package/examples/cloud-run-post-stop-job.ts +2 -4
- package/examples/cloud-run-service-gen2.test.ts +10 -0
- package/examples/cloud-run-service-gen2.ts +2 -4
- package/examples/cloud-run-service-increase-timout.test.ts +10 -0
- package/examples/cloud-run-service-increase-timout.ts +2 -4
- package/examples/cloud-run-service-with-volumes.test.ts +10 -0
- package/examples/cloud-run-service-with-volumes.ts +2 -4
- package/examples/cloud-run-storybook.test.ts +10 -0
- package/examples/cloud-run-storybook.ts +1 -4
- package/examples/cloud-run-with-ngnix.test.ts +10 -0
- package/examples/cloud-run-with-ngnix.ts +1 -4
- package/examples/cloud-run-with-sql-reuse-db.test.ts +10 -0
- package/examples/cloud-run-with-sql-reuse-db.ts +1 -4
- package/examples/cloud-run-with-sql.test.ts +10 -0
- package/examples/cloud-run-with-sql.ts +2 -4
- package/examples/cloud-run-with-worker.test.ts +10 -0
- package/examples/cloud-run-with-worker.ts +2 -4
- package/examples/custom-build-job-with-tests.test.ts +10 -0
- package/examples/custom-build-job-with-tests.ts +1 -4
- package/examples/custom-build-job.test.ts +10 -0
- package/examples/custom-build-job.ts +1 -4
- package/examples/custom-deploy.test.ts +10 -0
- package/examples/custom-deploy.ts +1 -4
- package/examples/custom-envs.test.ts +10 -0
- package/examples/custom-envs.ts +1 -4
- package/examples/custom-sbom-java.test.ts +10 -0
- package/examples/custom-sbom-java.ts +1 -4
- package/examples/git-submodule.test.ts +10 -0
- package/examples/git-submodule.ts +1 -4
- package/examples/kubernetes-application-customization.test.ts +10 -0
- package/examples/kubernetes-application-customization.ts +2 -4
- package/examples/kubernetes-with-cloud-sql-legacy.test.ts +10 -0
- package/examples/kubernetes-with-cloud-sql-legacy.ts +2 -4
- package/examples/kubernetes-with-cloud-sql.test.ts +10 -0
- package/examples/kubernetes-with-cloud-sql.ts +2 -4
- package/examples/kubernetes-with-jobs.test.ts +10 -0
- package/examples/kubernetes-with-jobs.ts +2 -4
- package/examples/kubernetes-with-mongodb.test.ts +10 -0
- package/examples/kubernetes-with-mongodb.ts +2 -4
- package/examples/local-dot-env.test.ts +10 -0
- package/examples/local-dot-env.ts +2 -4
- package/examples/meteor-kubernetes.test.ts +10 -0
- package/examples/meteor-kubernetes.ts +0 -5
- package/examples/multiline-var.test.ts +10 -0
- package/examples/multiline-var.ts +1 -4
- package/examples/native-app.test.ts +10 -0
- package/examples/native-app.ts +2 -4
- package/examples/node-build-with-custom-image.test.ts +10 -0
- package/examples/node-build-with-custom-image.ts +1 -4
- package/examples/node-build-with-docker-additions.test.ts +10 -0
- package/examples/node-build-with-docker-additions.ts +1 -4
- package/examples/rails-k8s-with-worker-dockerfile.test.ts +9 -0
- package/examples/rails-k8s-with-worker.test.ts +10 -0
- package/examples/rails-k8s-with-worker.ts +1 -11
- package/examples/wait-for-other-deploy.test.ts +10 -0
- package/examples/wait-for-other-deploy.ts +1 -4
- package/package.json +5 -2
- package/scripts/generate-examples-test.ts +91 -0
- package/scripts/tsconfig.json +7 -0
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +0 -4005
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
const config: Config = {
|
|
4
4
|
appName: "test-app",
|
|
5
5
|
customerName: "pan",
|
|
@@ -63,6 +63,4 @@ const config: Config = {
|
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
68
|
-
});
|
|
66
|
+
export default config;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./kubernetes-with-mongodb";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for kubernetes-with-mongodb", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
const config: Config = {
|
|
4
4
|
appName: "test-app",
|
|
5
5
|
customerName: "pan",
|
|
@@ -44,6 +44,4 @@ const config: Config = {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
49
|
-
});
|
|
47
|
+
export default config;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./local-dot-env";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for local-dot-env", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
const config: Config = {
|
|
4
4
|
appName: "test-app",
|
|
5
5
|
customerName: "pan",
|
|
@@ -20,6 +20,4 @@ const config: Config = {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
25
|
-
});
|
|
23
|
+
export default config;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./meteor-kubernetes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for meteor-kubernetes", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
2
|
|
|
4
3
|
const config: Config = {
|
|
5
4
|
customerName: "pan",
|
|
@@ -59,7 +58,3 @@ const config: Config = {
|
|
|
59
58
|
};
|
|
60
59
|
|
|
61
60
|
export default config;
|
|
62
|
-
|
|
63
|
-
it("matches snapshot", async () => {
|
|
64
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
65
|
-
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./multiline-var";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for multiline-var", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
2
|
|
|
4
3
|
const config: Config = {
|
|
5
4
|
appName: "test-app",
|
|
@@ -59,6 +58,4 @@ doouble quote: "
|
|
|
59
58
|
},
|
|
60
59
|
};
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
64
|
-
});
|
|
61
|
+
export default config;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./native-app";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for native-app", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
package/examples/native-app.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
2
|
import type { CatladderJob } from "../src/types/jobs";
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
const APP_GEM_CACHE: CatladderJob["cache"] = [
|
|
5
5
|
{
|
|
6
6
|
key: {
|
|
@@ -76,6 +76,4 @@ const config: Config = {
|
|
|
76
76
|
},
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
81
|
-
});
|
|
79
|
+
export default config;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./node-build-with-custom-image";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for node-build-with-custom-image", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
2
|
|
|
4
3
|
const config: Config = {
|
|
5
4
|
appName: "test-app",
|
|
@@ -20,6 +19,4 @@ const config: Config = {
|
|
|
20
19
|
},
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
25
|
-
});
|
|
22
|
+
export default config;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./node-build-with-docker-additions";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for node-build-with-docker-additions", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
2
|
|
|
4
3
|
const config: Config = {
|
|
5
4
|
appName: "test-app",
|
|
@@ -23,6 +22,4 @@ const config: Config = {
|
|
|
23
22
|
},
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
28
|
-
});
|
|
25
|
+
export default config;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { rmSync, writeFileSync } from "fs";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
import config from "./rails-k8s-with-worker";
|
|
4
|
+
|
|
5
|
+
it("matches snapshot with a Dockerfile", async () => {
|
|
6
|
+
writeFileSync("Dockerfile", "");
|
|
7
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
8
|
+
rmSync("Dockerfile");
|
|
9
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./rails-k8s-with-worker";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for rails-k8s-with-worker", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { rmSync, writeFileSync } from "fs";
|
|
2
1
|
import type { Config } from "../src";
|
|
3
|
-
import { createAllPipelines } from "./__utils__/helpers";
|
|
4
2
|
|
|
5
3
|
// the image version should match your `.ruby-version`
|
|
6
4
|
const RAILS_TEST_STAGE_IMAGE = "ruby:3.2.1";
|
|
@@ -90,12 +88,4 @@ const config: Config = {
|
|
|
90
88
|
},
|
|
91
89
|
};
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("matches snapshot with a Dockerfile", async () => {
|
|
98
|
-
writeFileSync("Dockerfile", "");
|
|
99
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
100
|
-
rmSync("Dockerfile");
|
|
101
|
-
});
|
|
91
|
+
export default config;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
2
|
+
import config from "./wait-for-other-deploy";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This test is auto-generated.
|
|
6
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
7
|
+
*/
|
|
8
|
+
it("matches snapshot for wait-for-other-deploy", async () => {
|
|
9
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
10
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Config } from "../src";
|
|
2
|
-
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
2
|
|
|
4
3
|
const config: Config<{ CustomEnvs: "asdf" | "bla" }> = {
|
|
5
4
|
appName: "test-app",
|
|
@@ -31,6 +30,4 @@ const config: Config<{ CustomEnvs: "asdf" | "bla" }> = {
|
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
36
|
-
});
|
|
33
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
],
|
|
54
54
|
"license": "MIT",
|
|
55
|
-
"version": "1.
|
|
55
|
+
"version": "1.160.0",
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build:tsc": "yarn tsc",
|
|
58
58
|
"build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"build:watch": "yarn tsc -w",
|
|
63
63
|
"lint": "eslint \"src/**/*.ts\"",
|
|
64
64
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
65
|
-
"generate:gitlab-ci-yml-types": "
|
|
65
|
+
"generate:gitlab-ci-yml-types": "ts-node ./scripts/generate-gitlab-ci-types.ts",
|
|
66
|
+
"generate:examples-test": "tsx scripts/generate-examples-test.ts"
|
|
66
67
|
},
|
|
67
68
|
"types": "dist/index.d.ts",
|
|
68
69
|
"main": "dist/index.js",
|
|
@@ -82,11 +83,13 @@
|
|
|
82
83
|
"@types/node": "^20.14.2",
|
|
83
84
|
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
|
84
85
|
"child-process-promise": "^2.2.1",
|
|
86
|
+
"glob": "^10.4.2",
|
|
85
87
|
"json-schema-to-typescript": "^13.0.2",
|
|
86
88
|
"lodash": "^4.17.21",
|
|
87
89
|
"memoizee": "^0.4.15",
|
|
88
90
|
"path-equal": "1.1.3",
|
|
89
91
|
"slugify": "^1.6.3",
|
|
92
|
+
"tsx": "^4.16.2",
|
|
90
93
|
"typescript": "^5.4.5",
|
|
91
94
|
"yaml": "^2.4.5"
|
|
92
95
|
},
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { glob } from "glob";
|
|
2
|
+
import { resolve, join, basename } from "path";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { readFile, writeFile, rm } from "fs/promises";
|
|
5
|
+
import { format } from "prettier";
|
|
6
|
+
|
|
7
|
+
const pipelineWorkspaceRoot = resolve(__dirname, "..");
|
|
8
|
+
const examplesPath = join(pipelineWorkspaceRoot, "examples");
|
|
9
|
+
const exampleIgnoresPath = join(examplesPath, ".test-gen-ignore");
|
|
10
|
+
|
|
11
|
+
const defaultExampleIgnores = ["*.test.ts"];
|
|
12
|
+
|
|
13
|
+
async function getExampleIgnores(): Promise<string[]> {
|
|
14
|
+
if (!existsSync(exampleIgnoresPath)) {
|
|
15
|
+
await writeFile(exampleIgnoresPath, defaultExampleIgnores.join("\n"));
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const ignoresFile = await readFile(exampleIgnoresPath, {
|
|
19
|
+
encoding: "utf-8",
|
|
20
|
+
});
|
|
21
|
+
return [
|
|
22
|
+
...new Set([
|
|
23
|
+
...defaultExampleIgnores,
|
|
24
|
+
...ignoresFile
|
|
25
|
+
.split("\n")
|
|
26
|
+
.filter((line) => !line.match(/^\s*# [\s\w]*/))
|
|
27
|
+
.map((line) => line.trim())
|
|
28
|
+
.filter(Boolean),
|
|
29
|
+
]),
|
|
30
|
+
];
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(
|
|
33
|
+
`Error reading example ignores file: ${exampleIgnoresPath}`,
|
|
34
|
+
error,
|
|
35
|
+
);
|
|
36
|
+
return defaultExampleIgnores;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type ExampleTestLines = {
|
|
41
|
+
importLine: string;
|
|
42
|
+
testString: string;
|
|
43
|
+
kebabName: string;
|
|
44
|
+
camelName: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
async function main() {
|
|
48
|
+
const exampleIgnores = await getExampleIgnores();
|
|
49
|
+
const [exampleFiles, existingTestFiles] = await Promise.all([
|
|
50
|
+
glob("*.ts", {
|
|
51
|
+
ignore: exampleIgnores,
|
|
52
|
+
cwd: examplesPath,
|
|
53
|
+
}),
|
|
54
|
+
glob("*.test.ts", {
|
|
55
|
+
ignore: ["rails-k8s-with-worker-dockerfile.test.ts"],
|
|
56
|
+
cwd: examplesPath,
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
await Promise.all(
|
|
60
|
+
existingTestFiles.map((testFile) => rm(join(examplesPath, testFile))),
|
|
61
|
+
);
|
|
62
|
+
await Promise.all(
|
|
63
|
+
exampleFiles.map(async (exampleFile) => {
|
|
64
|
+
const kebabName = basename(exampleFile, ".ts");
|
|
65
|
+
const testFileContent = [
|
|
66
|
+
`import { createAllPipelines } from "./__utils__/helpers";`,
|
|
67
|
+
`import config from "./${kebabName}";`,
|
|
68
|
+
``,
|
|
69
|
+
`/**`,
|
|
70
|
+
` * This test is auto-generated.`,
|
|
71
|
+
` * Modifications will be overwritten on every \`yarn test\` run!`,
|
|
72
|
+
` */`,
|
|
73
|
+
`it("matches snapshot for ${kebabName}", async () => {`,
|
|
74
|
+
` expect(await createAllPipelines(config)).toMatchSnapshot();`,
|
|
75
|
+
`});`,
|
|
76
|
+
].join("\n");
|
|
77
|
+
const formattedTest = await format(testFileContent, {
|
|
78
|
+
parser: "typescript",
|
|
79
|
+
});
|
|
80
|
+
await writeFile(
|
|
81
|
+
join(examplesPath, `${kebabName}.test.ts`),
|
|
82
|
+
formattedTest,
|
|
83
|
+
{
|
|
84
|
+
encoding: "utf-8",
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
main().catch(console.error);
|