@catladder/pipeline 3.48.0 → 4.0.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.
Files changed (95) hide show
  1. package/dist/build/index.d.ts +2 -2
  2. package/dist/build/node/buildJob.d.ts +3 -3
  3. package/dist/build/node/buildJob.js +185 -26
  4. package/dist/build/node/cache.d.ts +3 -3
  5. package/dist/build/node/cache.js +199 -36
  6. package/dist/build/node/index.d.ts +3 -3
  7. package/dist/build/node/index.js +151 -3
  8. package/dist/build/node/meteor.d.ts +1 -1
  9. package/dist/build/node/meteor.js +162 -27
  10. package/dist/build/node/testJob.d.ts +1 -1
  11. package/dist/build/node/testJob.js +174 -49
  12. package/dist/build/node/yarn.d.ts +2 -2
  13. package/dist/build/node/yarn.js +168 -21
  14. package/dist/constants.js +1 -1
  15. package/dist/context/createComponentContext.js +10 -12
  16. package/dist/context/createWorkspaceContext.js +29 -34
  17. package/dist/deploy/custom/deployJob.d.ts +1 -1
  18. package/dist/deploy/custom/deployJob.js +147 -23
  19. package/dist/deploy/index.d.ts +1 -1
  20. package/dist/pipeline/createAllJobs.js +30 -14
  21. package/dist/pipeline/createJobsForComponent.d.ts +1 -1
  22. package/dist/pipeline/createJobsForComponent.js +128 -4
  23. package/dist/pipeline/createJobsForWorkspace.d.ts +1 -1
  24. package/dist/pipeline/createJobsForWorkspace.js +127 -2
  25. package/dist/pipeline/yarn/yarnUtils.js +61 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/dist/types/context.d.ts +3 -3
  28. package/examples/__snapshots__/automatic-releases.test.ts.snap +9 -13
  29. package/examples/__snapshots__/cloud-run-execute-script-on-deploy.test.ts.snap +9 -13
  30. package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +9 -13
  31. package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +9 -13
  32. package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +9 -13
  33. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +9 -13
  34. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +9 -13
  35. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +9 -13
  36. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +9 -13
  37. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +9 -13
  38. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +9 -13
  39. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +9 -13
  40. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +9 -13
  41. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +9 -13
  42. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +9 -13
  43. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +9 -13
  44. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +9 -13
  45. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +9 -13
  46. package/examples/__snapshots__/cloud-run-session-affinity.test.ts.snap +9 -13
  47. package/examples/__snapshots__/cloud-run-with-agents.test.ts.snap +9 -13
  48. package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +9 -13
  49. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +9 -13
  50. package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +9 -13
  51. package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +18 -30
  52. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +14 -22
  53. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +9 -13
  54. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +9 -13
  55. package/examples/__snapshots__/cloud-run-worker-pool.test.ts.snap +9 -13
  56. package/examples/__snapshots__/custom-deploy.test.ts.snap +9 -13
  57. package/examples/__snapshots__/custom-docker-file.test.ts.snap +9 -13
  58. package/examples/__snapshots__/custom-envs.test.ts.snap +14 -22
  59. package/examples/__snapshots__/custom-verify-job.test.ts.snap +9 -13
  60. package/examples/__snapshots__/git-submodule.test.ts.snap +9 -13
  61. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +9 -13
  62. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +9 -13
  63. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +14 -22
  64. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +9 -13
  65. package/examples/__snapshots__/local-dot-env.test.ts.snap +9 -13
  66. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +9 -13
  67. package/examples/__snapshots__/modify-generated-files.test.ts.snap +9 -13
  68. package/examples/__snapshots__/modify-generated-yaml.test.ts.snap +9 -13
  69. package/examples/__snapshots__/multiline-var.test.ts.snap +18 -30
  70. package/examples/__snapshots__/native-app.test.ts.snap +14 -22
  71. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +9 -13
  72. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +9 -13
  73. package/examples/__snapshots__/override-secrets.test.ts.snap +9 -13
  74. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +18 -30
  75. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +14 -22
  76. package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +9 -13
  77. package/examples/__snapshots__/workspace-api-www.test.ts.snap +9 -13
  78. package/package.json +1 -1
  79. package/src/build/index.ts +6 -2
  80. package/src/build/node/buildJob.ts +26 -17
  81. package/src/build/node/cache.ts +18 -15
  82. package/src/build/node/index.ts +17 -9
  83. package/src/build/node/meteor.ts +16 -11
  84. package/src/build/node/testJob.ts +10 -6
  85. package/src/build/node/yarn.ts +10 -8
  86. package/src/context/createComponentContext.ts +6 -3
  87. package/src/context/createWorkspaceContext.ts +1 -1
  88. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +3 -1
  89. package/src/deploy/custom/deployJob.ts +3 -3
  90. package/src/deploy/index.ts +1 -1
  91. package/src/pipeline/createAllJobs.ts +9 -7
  92. package/src/pipeline/createJobsForComponent.ts +6 -6
  93. package/src/pipeline/createJobsForWorkspace.ts +3 -3
  94. package/src/pipeline/yarn/yarnUtils.ts +34 -0
  95. package/src/types/context.ts +3 -3
@@ -156,7 +156,7 @@ before_script:
156
156
  - app1/.yarn
157
157
  - key: app1-node-modules
158
158
  policy: pull-push
159
- paths:
159
+ paths: &a2
160
160
  - app1/node_modules
161
161
  - app1/.yarn/install-state.gz
162
162
  rules:
@@ -197,9 +197,7 @@ before_script:
197
197
  - app1/.yarn
198
198
  - key: app1-node-modules
199
199
  policy: pull-push
200
- paths:
201
- - app1/node_modules
202
- - app1/.yarn/install-state.gz
200
+ paths: *a2
203
201
  rules:
204
202
  - when: never
205
203
  if: $CI_PIPELINE_SOURCE == "trigger"
@@ -569,7 +567,7 @@ before_script:
569
567
  - app1-yarn
570
568
  - key: app1-node-modules-mr$CI_MERGE_REQUEST_IID
571
569
  policy: pull-push
572
- paths:
570
+ paths: &a3
573
571
  - app1/node_modules
574
572
  - app1/.yarn/install-state.gz
575
573
  fallback_keys:
@@ -614,9 +612,7 @@ before_script:
614
612
  - app1-yarn
615
613
  - key: app1-node-modules-mr$CI_MERGE_REQUEST_IID
616
614
  policy: pull-push
617
- paths:
618
- - app1/node_modules
619
- - app1/.yarn/install-state.gz
615
+ paths: *a3
620
616
  fallback_keys:
621
617
  - app1-node-modules
622
618
  rules:
@@ -1600,7 +1596,7 @@ before_script:
1600
1596
  - app2/.yarn
1601
1597
  - key: app2-node-modules
1602
1598
  policy: pull-push
1603
- paths:
1599
+ paths: &a4
1604
1600
  - app2/node_modules
1605
1601
  - app2/.yarn/install-state.gz
1606
1602
  rules:
@@ -1641,9 +1637,7 @@ before_script:
1641
1637
  - app2/.yarn
1642
1638
  - key: app2-node-modules
1643
1639
  policy: pull-push
1644
- paths:
1645
- - app2/node_modules
1646
- - app2/.yarn/install-state.gz
1640
+ paths: *a4
1647
1641
  rules:
1648
1642
  - when: never
1649
1643
  if: $CI_PIPELINE_SOURCE == "trigger"
@@ -2023,7 +2017,7 @@ before_script:
2023
2017
  - app2-yarn
2024
2018
  - key: app2-node-modules-mr$CI_MERGE_REQUEST_IID
2025
2019
  policy: pull-push
2026
- paths:
2020
+ paths: &a5
2027
2021
  - app2/node_modules
2028
2022
  - app2/.yarn/install-state.gz
2029
2023
  fallback_keys:
@@ -2068,9 +2062,7 @@ before_script:
2068
2062
  - app2-yarn
2069
2063
  - key: app2-node-modules-mr$CI_MERGE_REQUEST_IID
2070
2064
  policy: pull-push
2071
- paths:
2072
- - app2/node_modules
2073
- - app2/.yarn/install-state.gz
2065
+ paths: *a5
2074
2066
  fallback_keys:
2075
2067
  - app2-node-modules
2076
2068
  rules:
@@ -3084,7 +3076,7 @@ before_script:
3084
3076
  - kube/.yarn
3085
3077
  - key: kube-node-modules
3086
3078
  policy: pull-push
3087
- paths:
3079
+ paths: &a6
3088
3080
  - kube/node_modules
3089
3081
  - kube/.yarn/install-state.gz
3090
3082
  rules:
@@ -3125,9 +3117,7 @@ before_script:
3125
3117
  - kube/.yarn
3126
3118
  - key: kube-node-modules
3127
3119
  policy: pull-push
3128
- paths:
3129
- - kube/node_modules
3130
- - kube/.yarn/install-state.gz
3120
+ paths: *a6
3131
3121
  rules:
3132
3122
  - when: never
3133
3123
  if: $CI_PIPELINE_SOURCE == "trigger"
@@ -3587,7 +3577,7 @@ before_script:
3587
3577
  - kube-yarn
3588
3578
  - key: kube-node-modules-mr$CI_MERGE_REQUEST_IID
3589
3579
  policy: pull-push
3590
- paths:
3580
+ paths: &a7
3591
3581
  - kube/node_modules
3592
3582
  - kube/.yarn/install-state.gz
3593
3583
  fallback_keys:
@@ -3632,9 +3622,7 @@ before_script:
3632
3622
  - kube-yarn
3633
3623
  - key: kube-node-modules-mr$CI_MERGE_REQUEST_IID
3634
3624
  policy: pull-push
3635
- paths:
3636
- - kube/node_modules
3637
- - kube/.yarn/install-state.gz
3625
+ paths: *a7
3638
3626
  fallback_keys:
3639
3627
  - kube-node-modules
3640
3628
  rules:
@@ -4839,13 +4827,13 @@ create release:
4839
4827
  after_script:
4840
4828
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
4841
4829
  rules:
4842
- - &a2
4830
+ - &a8
4843
4831
  if: $CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/
4844
4832
  when: never
4845
- - &a3
4833
+ - &a9
4846
4834
  if: $CI_PIPELINE_SOURCE == "trigger"
4847
4835
  when: never
4848
- - &a4
4836
+ - &a10
4849
4837
  if: $CI_PIPELINE_SOURCE == "schedule"
4850
4838
  when: never
4851
4839
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
@@ -4860,9 +4848,9 @@ create release:
4860
4848
  after_script:
4861
4849
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
4862
4850
  rules:
4863
- - *a2
4864
- - *a3
4865
- - *a4
4851
+ - *a8
4852
+ - *a9
4853
+ - *a10
4866
4854
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
4867
4855
  when: manual
4868
4856
  - if: $CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/
@@ -156,7 +156,7 @@ before_script:
156
156
  - api/.yarn
157
157
  - key: api-node-modules
158
158
  policy: pull-push
159
- paths:
159
+ paths: &a2
160
160
  - api/node_modules
161
161
  - api/.yarn/install-state.gz
162
162
  rules:
@@ -197,9 +197,7 @@ before_script:
197
197
  - api/.yarn
198
198
  - key: api-node-modules
199
199
  policy: pull-push
200
- paths:
201
- - api/node_modules
202
- - api/.yarn/install-state.gz
200
+ paths: *a2
203
201
  rules:
204
202
  - when: never
205
203
  if: $CI_PIPELINE_SOURCE == "trigger"
@@ -384,7 +382,7 @@ before_script:
384
382
  - api-yarn
385
383
  - key: api-node-modules-mr$CI_MERGE_REQUEST_IID
386
384
  policy: pull-push
387
- paths:
385
+ paths: &a3
388
386
  - api/node_modules
389
387
  - api/.yarn/install-state.gz
390
388
  fallback_keys:
@@ -429,9 +427,7 @@ before_script:
429
427
  - api-yarn
430
428
  - key: api-node-modules-mr$CI_MERGE_REQUEST_IID
431
429
  policy: pull-push
432
- paths:
433
- - api/node_modules
434
- - api/.yarn/install-state.gz
430
+ paths: *a3
435
431
  fallback_keys:
436
432
  - api-node-modules
437
433
  rules:
@@ -854,7 +850,7 @@ before_script:
854
850
  - www/.yarn
855
851
  - key: www-node-modules
856
852
  policy: pull-push
857
- paths:
853
+ paths: &a4
858
854
  - www/node_modules
859
855
  - www/.yarn/install-state.gz
860
856
  rules:
@@ -895,9 +891,7 @@ before_script:
895
891
  - www/.yarn
896
892
  - key: www-node-modules
897
893
  policy: pull-push
898
- paths:
899
- - www/node_modules
900
- - www/.yarn/install-state.gz
894
+ paths: *a4
901
895
  rules:
902
896
  - when: never
903
897
  if: $CI_PIPELINE_SOURCE == "trigger"
@@ -1084,7 +1078,7 @@ before_script:
1084
1078
  - www-yarn
1085
1079
  - key: www-node-modules-mr$CI_MERGE_REQUEST_IID
1086
1080
  policy: pull-push
1087
- paths:
1081
+ paths: &a5
1088
1082
  - www/node_modules
1089
1083
  - www/.yarn/install-state.gz
1090
1084
  fallback_keys:
@@ -1129,9 +1123,7 @@ before_script:
1129
1123
  - www-yarn
1130
1124
  - key: www-node-modules-mr$CI_MERGE_REQUEST_IID
1131
1125
  policy: pull-push
1132
- paths:
1133
- - www/node_modules
1134
- - www/.yarn/install-state.gz
1126
+ paths: *a5
1135
1127
  fallback_keys:
1136
1128
  - www-node-modules
1137
1129
  rules:
@@ -1516,13 +1508,13 @@ create release:
1516
1508
  after_script:
1517
1509
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
1518
1510
  rules:
1519
- - &a2
1511
+ - &a6
1520
1512
  if: $CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/
1521
1513
  when: never
1522
- - &a3
1514
+ - &a7
1523
1515
  if: $CI_PIPELINE_SOURCE == "trigger"
1524
1516
  when: never
1525
- - &a4
1517
+ - &a8
1526
1518
  if: $CI_PIPELINE_SOURCE == "schedule"
1527
1519
  when: never
1528
1520
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
@@ -1537,9 +1529,9 @@ create release:
1537
1529
  after_script:
1538
1530
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
1539
1531
  rules:
1540
- - *a2
1541
- - *a3
1542
- - *a4
1532
+ - *a6
1533
+ - *a7
1534
+ - *a8
1543
1535
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
1544
1536
  when: manual
1545
1537
  - if: $CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/
@@ -156,7 +156,7 @@ before_script:
156
156
  - .yarn
157
157
  - key: .-node-modules
158
158
  policy: pull-push
159
- paths:
159
+ paths: &a2
160
160
  - node_modules
161
161
  - .yarn/install-state.gz
162
162
  rules:
@@ -197,9 +197,7 @@ before_script:
197
197
  - .yarn
198
198
  - key: .-node-modules
199
199
  policy: pull-push
200
- paths:
201
- - node_modules
202
- - .yarn/install-state.gz
200
+ paths: *a2
203
201
  rules:
204
202
  - when: never
205
203
  if: $CI_PIPELINE_SOURCE == "trigger"
@@ -356,7 +354,7 @@ before_script:
356
354
  - .-yarn
357
355
  - key: .-node-modules-mr$CI_MERGE_REQUEST_IID
358
356
  policy: pull-push
359
- paths:
357
+ paths: &a3
360
358
  - node_modules
361
359
  - .yarn/install-state.gz
362
360
  fallback_keys:
@@ -401,9 +399,7 @@ before_script:
401
399
  - .-yarn
402
400
  - key: .-node-modules-mr$CI_MERGE_REQUEST_IID
403
401
  policy: pull-push
404
- paths:
405
- - node_modules
406
- - .yarn/install-state.gz
402
+ paths: *a3
407
403
  fallback_keys:
408
404
  - .-node-modules
409
405
  rules:
@@ -2296,13 +2292,13 @@ create release:
2296
2292
  after_script:
2297
2293
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
2298
2294
  rules:
2299
- - &a2
2295
+ - &a4
2300
2296
  if: $CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/
2301
2297
  when: never
2302
- - &a3
2298
+ - &a5
2303
2299
  if: $CI_PIPELINE_SOURCE == "trigger"
2304
2300
  when: never
2305
- - &a4
2301
+ - &a6
2306
2302
  if: $CI_PIPELINE_SOURCE == "schedule"
2307
2303
  when: never
2308
2304
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
@@ -2317,9 +2313,9 @@ create release:
2317
2313
  after_script:
2318
2314
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
2319
2315
  rules:
2320
- - *a2
2321
- - *a3
2322
2316
  - *a4
2317
+ - *a5
2318
+ - *a6
2323
2319
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
2324
2320
  when: manual
2325
2321
  - if: $CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/
@@ -156,7 +156,7 @@ before_script:
156
156
  - .yarn
157
157
  - key: .-node-modules
158
158
  policy: pull-push
159
- paths:
159
+ paths: &a2
160
160
  - node_modules
161
161
  - .yarn/install-state.gz
162
162
  rules:
@@ -197,9 +197,7 @@ before_script:
197
197
  - .yarn
198
198
  - key: .-node-modules
199
199
  policy: pull-push
200
- paths:
201
- - node_modules
202
- - .yarn/install-state.gz
200
+ paths: *a2
203
201
  rules:
204
202
  - when: never
205
203
  if: $CI_PIPELINE_SOURCE == "trigger"
@@ -354,7 +352,7 @@ before_script:
354
352
  - .-yarn
355
353
  - key: .-node-modules-mr$CI_MERGE_REQUEST_IID
356
354
  policy: pull-push
357
- paths:
355
+ paths: &a3
358
356
  - node_modules
359
357
  - .yarn/install-state.gz
360
358
  fallback_keys:
@@ -399,9 +397,7 @@ before_script:
399
397
  - .-yarn
400
398
  - key: .-node-modules-mr$CI_MERGE_REQUEST_IID
401
399
  policy: pull-push
402
- paths:
403
- - node_modules
404
- - .yarn/install-state.gz
400
+ paths: *a3
405
401
  fallback_keys:
406
402
  - .-node-modules
407
403
  rules:
@@ -2280,13 +2276,13 @@ create release:
2280
2276
  after_script:
2281
2277
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
2282
2278
  rules:
2283
- - &a2
2279
+ - &a4
2284
2280
  if: $CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/
2285
2281
  when: never
2286
- - &a3
2282
+ - &a5
2287
2283
  if: $CI_PIPELINE_SOURCE == "trigger"
2288
2284
  when: never
2289
- - &a4
2285
+ - &a6
2290
2286
  if: $CI_PIPELINE_SOURCE == "schedule"
2291
2287
  when: never
2292
2288
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
@@ -2301,9 +2297,9 @@ create release:
2301
2297
  after_script:
2302
2298
  - echo '👉 If this job failed with access denied, the project access token might be invald - run \`project-renew-token\` in catladder CLI to fix.'
2303
2299
  rules:
2304
- - *a2
2305
- - *a3
2306
2300
  - *a4
2301
+ - *a5
2302
+ - *a6
2307
2303
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
2308
2304
  when: manual
2309
2305
  - if: $CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.48.0",
56
+ "version": "4.0.0",
57
57
  "scripts": {
58
58
  "build:tsc": "yarn tsc",
59
59
  "build": "yarn build:compile && yarn build:inline-variables",
@@ -19,7 +19,9 @@ export * from "./types";
19
19
 
20
20
  export type BuildTypes = {
21
21
  [type in BuildConfigStandaloneType]: {
22
- jobs: (context: ComponentContextWithBuild) => CatladderJob[];
22
+ jobs: (
23
+ context: ComponentContextWithBuild,
24
+ ) => CatladderJob[] | Promise<CatladderJob[]>;
23
25
  defaults: (
24
26
  envContext: EnvironmentContext,
25
27
  ) => Partial<Extract<BuildConfig, { type: type }>>;
@@ -76,7 +78,9 @@ export const BUILD_TYPES: BuildTypes = {
76
78
 
77
79
  export type WorkspaceBuildTypes = {
78
80
  [type in WorkspaceBuildConfig["type"]]: {
79
- jobs: (context: WorkspaceContext) => CatladderJob[];
81
+ jobs: (
82
+ context: WorkspaceContext,
83
+ ) => CatladderJob[] | Promise<CatladderJob[]>;
80
84
  defaults: () => Partial<Extract<WorkspaceBuildConfig, { type: type }>>;
81
85
  };
82
86
  };
@@ -19,40 +19,43 @@ import type { BuildConfigDocker } from "../types";
19
19
  import { getNodeCache, getYarnCache } from "./cache";
20
20
  import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
21
21
 
22
- export const createNodeBuildJobs = (
22
+ export const createNodeBuildJobs = async (
23
23
  context: ComponentContextWithBuild | WorkspaceContext,
24
- ): CatladderJob[] => {
24
+ ): Promise<CatladderJob[]> => {
25
25
  if (context.type === "workspace") {
26
26
  return createWorkspaceBuildJobs(context, {
27
- appBuild: createNodeBuildJobDefinition(context),
27
+ appBuild: await createNodeBuildJobDefinition(context),
28
28
  });
29
29
  }
30
30
  return createComponentBuildJobs(context, {
31
31
  appBuild: componentContextIsStandaloneBuild(context)
32
- ? createNodeBuildJobDefinition(context)
32
+ ? await createNodeBuildJobDefinition(context)
33
33
  : undefined,
34
34
 
35
- dockerBuild: createNodeDockerJobDefinition(context),
35
+ dockerBuild: await createNodeDockerJobDefinition(context),
36
36
  });
37
37
  };
38
38
 
39
- export const createNodeBuildJobDefinition = (
39
+ export const createNodeBuildJobDefinition = async (
40
40
  context: ComponentContext<BuildContextStandalone> | WorkspaceContext,
41
- ): AppBuildJobDefinition | undefined => {
41
+ ): Promise<AppBuildJobDefinition | undefined> => {
42
42
  const buildConfig = context.build.config;
43
43
 
44
- const yarnInstall = getYarnInstall(context);
44
+ const [yarnInstall, nodeCache] = await Promise.all([
45
+ getYarnInstall(context),
46
+ getNodeCache(context),
47
+ ]);
45
48
  return createBuildJobDefinition(context, buildConfig, {
46
49
  prescript: yarnInstall,
47
- cache: getNodeCache(context),
50
+ cache: nodeCache,
48
51
  });
49
52
  };
50
53
 
51
54
  type NewType = ComponentContextWithBuild;
52
55
 
53
- export const createNodeDockerJobDefinition = (
56
+ export const createNodeDockerJobDefinition = async (
54
57
  context: NewType,
55
- ): DockerBuildJobDefinition => {
58
+ ): Promise<DockerBuildJobDefinition> => {
56
59
  // get the default docker built-in type based on the build type
57
60
  const dockerDefaultBuiltIn: BuildConfigDocker["type"] =
58
61
  context.build.buildType === "node-static" ||
@@ -60,19 +63,25 @@ export const createNodeDockerJobDefinition = (
60
63
  ? "nginx"
61
64
  : "node";
62
65
 
66
+ const [yarnCache, dockerAppCopyAndBuildScript, packageManagerInfo] =
67
+ await Promise.all([
68
+ getYarnCache(context, "pull"),
69
+ getDockerAppCopyAndBuildScript(context),
70
+ context.packageManagerInfo,
71
+ ]);
72
+
63
73
  return {
64
74
  script: getDockerBuildScriptWithBuiltInDockerFile(
65
75
  context,
66
76
  dockerDefaultBuiltIn,
67
77
  ),
68
- cache: [...getYarnCache(context, "pull")],
78
+ cache: [...yarnCache],
69
79
  variables: {
70
80
  // only required for non static
71
- DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(context),
72
- DOCKER_COPY_WORKSPACE_FILES:
73
- context.packageManagerInfo?.pathsToCopyInDocker
74
- .map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
75
- ?.join("\n"),
81
+ DOCKER_COPY_AND_INSTALL_APP: dockerAppCopyAndBuildScript,
82
+ DOCKER_COPY_WORKSPACE_FILES: packageManagerInfo?.pathsToCopyInDocker
83
+ .map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
84
+ ?.join("\n"),
76
85
  },
77
86
  };
78
87
  };
@@ -5,13 +5,15 @@ import slugify from "slugify";
5
5
  import type { Context, WorkspaceContext } from "../../types/context";
6
6
  import type { CacheConfig } from "../types";
7
7
 
8
- export const getYarnCache = (
8
+ export const getYarnCache = async (
9
9
  context: Context,
10
10
  policy = "pull-push",
11
- ): CacheConfig[] => {
11
+ ): Promise<CacheConfig[]> => {
12
+ const packageManagerInfo = await context.packageManagerInfo;
12
13
  const componentIsInWorkspace =
13
14
  context.type === "component" &&
14
- context.packageManagerInfo.componentIsInWorkspace;
15
+ "componentIsInWorkspace" in packageManagerInfo &&
16
+ packageManagerInfo.componentIsInWorkspace;
15
17
  return [
16
18
  {
17
19
  scope: componentIsInWorkspace ? "global" : "buildDir",
@@ -23,15 +25,17 @@ export const getYarnCache = (
23
25
  ];
24
26
  };
25
27
 
26
- export const getNodeModulesCache = (
28
+ export const getNodeModulesCache = async (
27
29
  context: Context,
28
30
  policy = "pull-push",
29
- ): CacheConfig[] => {
31
+ ): Promise<CacheConfig[]> => {
32
+ const packageManagerInfo = await context.packageManagerInfo;
30
33
  const componentIsInWorkspace =
31
34
  context.type === "component" &&
32
- context.packageManagerInfo.componentIsInWorkspace;
35
+ "componentIsInWorkspace" in packageManagerInfo &&
36
+ packageManagerInfo.componentIsInWorkspace;
33
37
 
34
- const { isClassic } = context.packageManagerInfo;
38
+ const { isClassic, workspaces } = packageManagerInfo;
35
39
 
36
40
  // We intentionally do not use the contents of yarn.lock as a cache key, as yarn install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
37
41
  // It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
@@ -49,13 +53,12 @@ export const getNodeModulesCache = (
49
53
  ...(componentIsInWorkspace
50
54
  ? uniq([
51
55
  "node_modules",
52
- ...(context.packageManagerInfo.workspaces.map((w) =>
53
- join(w.location, "node_modules"),
54
- ) ?? []),
56
+ ...(workspaces.map((w) => join(w.location, "node_modules")) ??
57
+ []),
55
58
  ...(!isClassic
56
59
  ? [
57
60
  ".yarn/install-state.gz",
58
- ...(context.packageManagerInfo.workspaces.map((w) =>
61
+ ...(workspaces.map((w) =>
59
62
  join(w.location, ".yarn/install-state.gz"),
60
63
  ) ?? []),
61
64
  ]
@@ -71,12 +74,12 @@ export const getNodeModulesCache = (
71
74
  },
72
75
  ];
73
76
  };
74
- export const getNodeCache = (
77
+ export const getNodeCache = async (
75
78
  context: Context,
76
79
  policy = "pull-push",
77
- ): CacheConfig[] => {
80
+ ): Promise<CacheConfig[]> => {
78
81
  return [
79
- ...getYarnCache(context, policy),
80
- ...getNodeModulesCache(context, policy),
82
+ ...(await getYarnCache(context, policy)),
83
+ ...(await getNodeModulesCache(context, policy)),
81
84
  ];
82
85
  };
@@ -7,20 +7,28 @@ import { createNodeBuildJobs } from "./buildJob";
7
7
  import { createMeteorBuildJobs } from "./meteor";
8
8
  import { createNodeTestJobs } from "./testJob";
9
9
 
10
- export const createNodeJobs = (
10
+ export const createNodeJobs = async (
11
11
  context: ComponentContextWithBuild | WorkspaceContext,
12
- ): CatladderJob[] => {
13
- return [...createNodeTestJobs(context), ...createNodeBuildJobs(context)];
12
+ ): Promise<CatladderJob[]> => {
13
+ const [testJobs, buildJobs] = await Promise.all([
14
+ createNodeTestJobs(context),
15
+ createNodeBuildJobs(context),
16
+ ]);
17
+ return [...testJobs, ...buildJobs];
14
18
  };
15
19
 
16
- export const createStorybookJobs = (
20
+ export const createStorybookJobs = async (
17
21
  context: ComponentContextWithBuild,
18
- ): CatladderJob[] => {
19
- return [...createNodeBuildJobs(context)];
22
+ ): Promise<CatladderJob[]> => {
23
+ return [...(await createNodeBuildJobs(context))];
20
24
  };
21
25
 
22
- export const createMeteorJobs = (
26
+ export const createMeteorJobs = async (
23
27
  context: ComponentContextWithBuild,
24
- ): CatladderJob[] => {
25
- return [...createNodeTestJobs(context), ...createMeteorBuildJobs(context)];
28
+ ): Promise<CatladderJob[]> => {
29
+ const [testJobs, buildJobs] = await Promise.all([
30
+ createNodeTestJobs(context),
31
+ createMeteorBuildJobs(context),
32
+ ]);
33
+ return [...testJobs, ...buildJobs];
26
34
  };
@@ -26,10 +26,11 @@ const getMeteorCache = (context: ComponentContext): CacheConfig[] => [
26
26
  ],
27
27
  },
28
28
  ];
29
- const getMeteorDockerInstallScripts = (
29
+ const getMeteorDockerInstallScripts = async (
30
30
  context: ComponentContextWithBuild,
31
- ): BashExpression => {
32
- if (context.packageManagerInfo.isClassic) {
31
+ ): Promise<BashExpression> => {
32
+ const packageManagerInfo = await context.packageManagerInfo;
33
+ if (packageManagerInfo.isClassic) {
33
34
  return new BashExpression(
34
35
  `
35
36
  COPY $APP_DIR/package.json $APP_DIR/yarn.lock ./
@@ -43,7 +44,7 @@ RUN yarn --frozen-lockfile --production=true --ignore-engines
43
44
 
44
45
  // yarn >= 4 ships with built-in plugins, see https://github.com/yarnpkg/berry/pull/4253
45
46
  const doesNotShipWithBuiltInPlugins = ["2", "3"].some((v) =>
46
- context.packageManagerInfo.version.startsWith(v),
47
+ packageManagerInfo.version.startsWith(v),
47
48
  );
48
49
  const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins
49
50
  ? "RUN yarn plugin import workspace-tools"
@@ -59,22 +60,28 @@ RUN yarn workspaces focus --production
59
60
  );
60
61
  };
61
62
 
62
- export const createMeteorBuildJobs = (
63
+ export const createMeteorBuildJobs = async (
63
64
  context: ComponentContextWithBuild,
64
- ): CatladderJob[] => {
65
+ ): Promise<CatladderJob[]> => {
65
66
  const buildConfig = context.build.config;
66
67
 
67
68
  if (!isOfBuildType(buildConfig, "meteor")) {
68
69
  throw new Error("deploy config is not meteor");
69
70
  }
70
71
 
71
- const yarnInstall = getYarnInstall(context);
72
+ const [yarnInstall, nodeCache, meteorInstallScripts] = await Promise.all([
73
+ getYarnInstall(context),
74
+ getNodeCache(context),
75
+ buildConfig.installScripts
76
+ ? getMeteorDockerInstallScripts(context)
77
+ : Promise.resolve("" as const),
78
+ ]);
72
79
 
73
80
  return createComponentBuildJobs(context, {
74
81
  appBuild:
75
82
  buildConfig.buildCommand !== null && buildConfig.buildCommand !== false
76
83
  ? {
77
- cache: [...getNodeCache(context), ...getMeteorCache(context)],
84
+ cache: [...nodeCache, ...getMeteorCache(context)],
78
85
  image: getRunnerImage("jobs-meteor"),
79
86
  variables: {
80
87
  METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
@@ -91,9 +98,7 @@ export const createMeteorBuildJobs = (
91
98
  dockerBuild: {
92
99
  script: getDockerBuildScriptWithBuiltInDockerFile(context, "meteor"),
93
100
  variables: {
94
- METEOR_INSTALL_SCRIPTS: buildConfig.installScripts
95
- ? getMeteorDockerInstallScripts(context)
96
- : "",
101
+ METEOR_INSTALL_SCRIPTS: meteorInstallScripts,
97
102
  },
98
103
  },
99
104
  });