@catladder/pipeline 1.163.0 → 1.163.2

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 (78) hide show
  1. package/README.md +15 -1
  2. package/dist/bundles/catladder-gitlab/index.js +2 -2
  3. package/dist/constants.js +1 -1
  4. package/dist/pipeline/generatePipelineFiles.d.ts +38 -0
  5. package/dist/pipeline/generatePipelineFiles.js +44 -23
  6. package/dist/tsconfig.tsbuildinfo +1 -1
  7. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +1335 -1952
  8. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +1319 -1928
  9. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +1335 -1952
  10. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +1387 -2004
  11. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +1335 -1952
  12. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +1346 -1963
  13. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +1335 -1952
  14. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +1335 -1952
  15. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +1379 -1996
  16. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +1219 -1668
  17. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +1335 -1952
  18. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +2815 -3924
  19. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +2562 -3447
  20. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +1343 -1960
  21. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +1190 -1780
  22. package/examples/__snapshots__/custom-build-job.test.ts.snap +1079 -1480
  23. package/examples/__snapshots__/custom-deploy.test.ts.snap +1101 -1718
  24. package/examples/__snapshots__/custom-envs.test.ts.snap +707 -1172
  25. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +1087 -1488
  26. package/examples/__snapshots__/git-submodule.test.ts.snap +1336 -1955
  27. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +1772 -2443
  28. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +1784 -2455
  29. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +1792 -2463
  30. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +3342 -4547
  31. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +1896 -2567
  32. package/examples/__snapshots__/local-dot-env.test.ts.snap +1335 -1952
  33. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +1833 -2496
  34. package/examples/__snapshots__/multiline-var.test.ts.snap +3295 -4406
  35. package/examples/__snapshots__/native-app.test.ts.snap +2143 -3160
  36. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +1335 -1952
  37. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +1343 -1960
  38. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +1479 -2003
  39. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +1464 -1988
  40. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +1273 -2102
  41. package/examples/__utils__/helpers.ts +14 -1
  42. package/examples/cloud-run-memory-limit.test.ts +4 -3
  43. package/examples/cloud-run-meteor-with-worker.test.ts +4 -3
  44. package/examples/cloud-run-no-cpu-throttling.test.ts +4 -3
  45. package/examples/cloud-run-no-service.test.ts +4 -3
  46. package/examples/cloud-run-non-public.test.ts +4 -3
  47. package/examples/cloud-run-post-stop-job.test.ts +4 -3
  48. package/examples/cloud-run-service-gen2.test.ts +4 -3
  49. package/examples/cloud-run-service-increase-timout.test.ts +4 -3
  50. package/examples/cloud-run-service-with-volumes.test.ts +4 -3
  51. package/examples/cloud-run-storybook.test.ts +4 -3
  52. package/examples/cloud-run-with-ngnix.test.ts +4 -3
  53. package/examples/cloud-run-with-sql-reuse-db.test.ts +4 -3
  54. package/examples/cloud-run-with-sql.test.ts +4 -3
  55. package/examples/cloud-run-with-worker.test.ts +4 -3
  56. package/examples/custom-build-job-with-tests.test.ts +4 -3
  57. package/examples/custom-build-job.test.ts +4 -3
  58. package/examples/custom-deploy.test.ts +4 -3
  59. package/examples/custom-envs.test.ts +4 -3
  60. package/examples/custom-sbom-java.test.ts +4 -3
  61. package/examples/git-submodule.test.ts +4 -3
  62. package/examples/kubernetes-application-customization.test.ts +4 -3
  63. package/examples/kubernetes-with-cloud-sql-legacy.test.ts +4 -3
  64. package/examples/kubernetes-with-cloud-sql.test.ts +4 -3
  65. package/examples/kubernetes-with-jobs.test.ts +4 -3
  66. package/examples/kubernetes-with-mongodb.test.ts +4 -3
  67. package/examples/local-dot-env.test.ts +4 -3
  68. package/examples/meteor-kubernetes.test.ts +4 -3
  69. package/examples/multiline-var.test.ts +4 -3
  70. package/examples/native-app.test.ts +4 -3
  71. package/examples/node-build-with-custom-image.test.ts +4 -3
  72. package/examples/node-build-with-docker-additions.test.ts +4 -3
  73. package/examples/rails-k8s-with-worker-dockerfile.test.ts +2 -2
  74. package/examples/rails-k8s-with-worker.test.ts +4 -3
  75. package/examples/wait-for-other-deploy.test.ts +4 -3
  76. package/package.json +4 -3
  77. package/scripts/generate-examples-test.ts +7 -7
  78. package/src/pipeline/generatePipelineFiles.ts +61 -36
@@ -4,48 +4,73 @@ import { createChildPipeline } from "./createChildPipeline";
4
4
  import { createMainPipeline } from "./createMainPipeline";
5
5
  import { getPipelineTriggerForGitlabChildPipeline } from "./gitlab/getPipelineTriggerForGitlabChildPipeline";
6
6
  import { sortGitLabJobDefProps } from "./gitlab/sortGitLabJobDefProps";
7
+
8
+ export async function generateChildPipelineContent<T extends PipelineType>(
9
+ config: Config,
10
+ pipelineType: T,
11
+ ) {
12
+ const trigger = getPipelineTriggerForGitlabChildPipeline();
13
+ const { jobs, image, stages, variables, workflow, ...pipelineRest } =
14
+ await createChildPipeline(pipelineType, trigger, config);
15
+
16
+ const jobsWithSortedProps = Object.fromEntries(
17
+ Object.entries(jobs).map(([jobName, job]) => [
18
+ jobName,
19
+ sortGitLabJobDefProps(job),
20
+ ]),
21
+ );
22
+
23
+ return {
24
+ image,
25
+ stages,
26
+ variables,
27
+ workflow,
28
+ ...pipelineRest,
29
+ // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
30
+ ...jobsWithSortedProps,
31
+ };
32
+ }
33
+
34
+ export async function generateLocalPipelineContent<T extends PipelineType>(
35
+ config: Config,
36
+ pipelineType: T,
37
+ ) {
38
+ const { jobs, image, stages, variables, workflow, ...pipelineRest } =
39
+ await createMainPipeline(pipelineType, config);
40
+
41
+ const jobsWithSortedProps = Object.fromEntries(
42
+ Object.entries(jobs).map(([jobName, job]) => [
43
+ jobName,
44
+ sortGitLabJobDefProps(job),
45
+ ]),
46
+ );
47
+
48
+ return {
49
+ image,
50
+ stages,
51
+ variables,
52
+ workflow,
53
+ ...pipelineRest,
54
+ // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
55
+ ...jobsWithSortedProps,
56
+ };
57
+ }
58
+
7
59
  export async function generatePipelineFiles<T extends PipelineType>(
8
60
  config: Config,
9
61
  pipelineType: T,
10
62
  mode: PipelineMode<T>,
11
63
  ) {
12
64
  if (mode === "childpipeline") {
13
- const trigger = getPipelineTriggerForGitlabChildPipeline();
14
-
15
- const { jobs, image, stages, variables, workflow, ...pipelineRest } =
16
- await createChildPipeline(pipelineType, trigger, config);
17
- const jobsWithSortedProps = Object.fromEntries(
18
- Object.entries(jobs).map(([jobName, job]) => [
19
- jobName,
20
- sortGitLabJobDefProps(job),
21
- ]),
22
- );
23
- await writeYamlfile(`__pipeline.yml`, {
24
- image,
25
- stages,
26
- variables,
27
- workflow,
28
- ...pipelineRest,
29
- // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
30
- ...jobsWithSortedProps,
31
- });
32
- } else {
33
- const { jobs, image, stages, variables, workflow, ...pipelineRest } =
34
- await createMainPipeline(pipelineType, config);
35
- const jobsWithSortedProps = Object.fromEntries(
36
- Object.entries(jobs).map(([jobName, job]) => [
37
- jobName,
38
- sortGitLabJobDefProps(job),
39
- ]),
65
+ const pipelineContent = await generateChildPipelineContent(
66
+ config,
67
+ pipelineType,
40
68
  );
41
- await writeYamlfile(`.gitlab-ci.yml`, {
42
- image,
43
- stages,
44
- variables,
45
- workflow,
46
- ...pipelineRest,
47
- // jobs need to be spread into main YAML, because GitLab pipeline YAML has no jobs key - jobs are top level with their key as their name
48
- ...jobsWithSortedProps,
49
- });
69
+ return writeYamlfile(`__pipeline.yml`, pipelineContent);
50
70
  }
71
+ const pipelineContent = await generateLocalPipelineContent(
72
+ config,
73
+ pipelineType,
74
+ );
75
+ return writeYamlfile(`.gitlab-ci.yml`, pipelineContent);
51
76
  }