pipecraft 0.0.0-releaseit → 0.26.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 (183) hide show
  1. package/README.md +126 -108
  2. package/dist/cli/index.d.ts +69 -0
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +94 -22
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/generators/init.tpl.d.ts +70 -0
  7. package/dist/generators/init.tpl.d.ts.map +1 -1
  8. package/dist/generators/init.tpl.js +100 -8
  9. package/dist/generators/init.tpl.js.map +1 -1
  10. package/dist/generators/workflows.tpl.d.ts +86 -0
  11. package/dist/generators/workflows.tpl.d.ts.map +1 -1
  12. package/dist/generators/workflows.tpl.js +101 -9
  13. package/dist/generators/workflows.tpl.js.map +1 -1
  14. package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
  15. package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
  16. package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
  17. package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
  18. package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
  19. package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
  20. package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
  21. package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
  22. package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
  23. package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
  24. package/dist/templates/actions/create-release.yml.tpl.js +141 -0
  25. package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
  26. package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
  27. package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
  28. package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
  29. package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
  30. package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
  31. package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
  32. package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
  33. package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
  34. package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
  35. package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
  36. package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
  37. package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
  38. package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
  39. package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
  40. package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
  41. package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
  42. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
  43. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
  44. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
  45. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
  46. package/dist/types/index.d.ts +231 -8
  47. package/dist/types/index.d.ts.map +1 -1
  48. package/dist/types/index.js +9 -0
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/utils/ast-path-operations.d.ts.map +1 -1
  51. package/dist/utils/ast-path-operations.js +24 -11
  52. package/dist/utils/ast-path-operations.js.map +1 -1
  53. package/dist/utils/config.d.ts +63 -0
  54. package/dist/utils/config.d.ts.map +1 -1
  55. package/dist/utils/config.js +71 -0
  56. package/dist/utils/config.js.map +1 -1
  57. package/dist/utils/github-setup.d.ts +323 -2
  58. package/dist/utils/github-setup.d.ts.map +1 -1
  59. package/dist/utils/github-setup.js +551 -23
  60. package/dist/utils/github-setup.js.map +1 -1
  61. package/dist/utils/idempotency.d.ts +147 -7
  62. package/dist/utils/idempotency.d.ts.map +1 -1
  63. package/dist/utils/idempotency.js +143 -15
  64. package/dist/utils/idempotency.js.map +1 -1
  65. package/dist/utils/logger.d.ts +134 -0
  66. package/dist/utils/logger.d.ts.map +1 -0
  67. package/dist/utils/logger.js +153 -0
  68. package/dist/utils/logger.js.map +1 -0
  69. package/dist/utils/preflight.d.ts +223 -12
  70. package/dist/utils/preflight.d.ts.map +1 -1
  71. package/dist/utils/preflight.js +216 -16
  72. package/dist/utils/preflight.js.map +1 -1
  73. package/dist/utils/versioning.d.ts +160 -8
  74. package/dist/utils/versioning.d.ts.map +1 -1
  75. package/dist/utils/versioning.js +179 -15
  76. package/dist/utils/versioning.js.map +1 -1
  77. package/package.json +26 -5
  78. package/.claude/settings.local.json +0 -35
  79. package/.github/actions/calculate-version/action.yml +0 -106
  80. package/.github/actions/create-pr/action.yml +0 -122
  81. package/.github/actions/create-release/action.yml +0 -74
  82. package/.github/actions/create-tag/action.yml +0 -94
  83. package/.github/actions/detect-changes/action.yml +0 -62
  84. package/.github/actions/manage-branch/action.yml +0 -113
  85. package/.github/actions/promote-branch/action.yml +0 -352
  86. package/.github/example/workflows/job.analyze.code.yml +0 -26
  87. package/.github/example/workflows/job.analyze.docker.yml +0 -32
  88. package/.github/example/workflows/job.app.api.deploy.yml +0 -127
  89. package/.github/example/workflows/job.app.api.test.yml +0 -102
  90. package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
  91. package/.github/example/workflows/job.app.docs.test.yml +0 -50
  92. package/.github/example/workflows/job.app.web.deploy.yml +0 -96
  93. package/.github/example/workflows/job.app.web.test.yml +0 -49
  94. package/.github/example/workflows/job.changes.yml +0 -82
  95. package/.github/example/workflows/job.create-pr.yml +0 -96
  96. package/.github/example/workflows/job.env-check.yml +0 -43
  97. package/.github/example/workflows/job.fast-forward.yml +0 -103
  98. package/.github/example/workflows/job.lint.yml +0 -64
  99. package/.github/example/workflows/job.pr-name.yml +0 -70
  100. package/.github/example/workflows/job.pr-squash-name.yml +0 -27
  101. package/.github/example/workflows/job.tag.yml +0 -38
  102. package/.github/example/workflows/job.version.yml +0 -99
  103. package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
  104. package/.github/example/workflows/pipe.yml +0 -178
  105. package/.github/example/workflows/scripts/fastforward.sh +0 -51
  106. package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
  107. package/.github/scripts/fastforward.sh +0 -51
  108. package/.github/scripts/pipe-cleaner.sh +0 -70
  109. package/.github/workflows/pipeline.yml +0 -220
  110. package/.github/workflows/pr-title-check.yml +0 -70
  111. package/.github/workflows/publish.yml +0 -39
  112. package/.pipecraftrc.json +0 -78
  113. package/.release-it.cjs +0 -71
  114. package/PIPELINE_TESTING_PLAN.md +0 -499
  115. package/TRUNK_FLOW_PLAN.md +0 -401
  116. package/assets/logo_banner.png +0 -0
  117. package/assets/logo_banner.webp +0 -0
  118. package/docs/USER_JOURNEY_ERRORS.md +0 -352
  119. package/eslint.config.js +0 -77
  120. package/examples/basic-config.json +0 -41
  121. package/examples/monorepo-config.json +0 -49
  122. package/examples/usage.md +0 -289
  123. package/scripts/debug-workflows.sh +0 -339
  124. package/scripts/parse-pipeline.js +0 -29
  125. package/scripts/test-job-order.cjs +0 -140
  126. package/scripts/validate-pipeline.cjs +0 -379
  127. package/scripts/verify-job-order.sh +0 -30
  128. package/src/cli/index.ts +0 -414
  129. package/src/generators/init.tpl.ts +0 -126
  130. package/src/generators/workflows.tpl.ts +0 -80
  131. package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
  132. package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
  133. package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
  134. package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
  135. package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
  136. package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
  137. package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
  138. package/src/types/index.ts +0 -64
  139. package/src/utils/README-ast-path-operations.md +0 -390
  140. package/src/utils/ast-path-operations.ts +0 -581
  141. package/src/utils/config.ts +0 -64
  142. package/src/utils/github-setup.ts +0 -558
  143. package/src/utils/idempotency.ts +0 -215
  144. package/src/utils/preflight.ts +0 -306
  145. package/src/utils/versioning.ts +0 -244
  146. package/tests/README.md +0 -229
  147. package/tests/TEST_STRUCTURE.md +0 -256
  148. package/tests/act/run-act-tests.sh +0 -345
  149. package/tests/debugging/debug-utils.ts +0 -538
  150. package/tests/debugging/debug-workflow.test.ts +0 -339
  151. package/tests/debugging/debug-workflows.sh +0 -339
  152. package/tests/debugging/iterative-debug.ts +0 -652
  153. package/tests/debugging/run-debug-tests.sh +0 -431
  154. package/tests/fixtures/basic-config.json +0 -51
  155. package/tests/fixtures/invalid-config.json +0 -9
  156. package/tests/fixtures/pipeline-generated.yml +0 -235
  157. package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
  158. package/tests/fixtures/pipeline-user-modified.yml +0 -245
  159. package/tests/fixtures/test-config.json +0 -58
  160. package/tests/github-live/README.md +0 -250
  161. package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
  162. package/tests/github-local/README.md +0 -240
  163. package/tests/github-local/run-all-tests.sh +0 -422
  164. package/tests/github-local/test-job-workflows.sh +0 -631
  165. package/tests/github-local/test-pipeline-workflow.sh +0 -440
  166. package/tests/integration/generators.test.ts +0 -578
  167. package/tests/integration/path-based-template.test.ts +0 -510
  168. package/tests/integration/simple-path-based.test.ts +0 -415
  169. package/tests/setup.ts +0 -56
  170. package/tests/unit/ast-path-operations-extended.test.ts +0 -302
  171. package/tests/unit/cli.test.ts +0 -541
  172. package/tests/unit/config-extended.test.ts +0 -412
  173. package/tests/unit/config.test.ts +0 -152
  174. package/tests/unit/github-setup.test.ts +0 -189
  175. package/tests/unit/idempotency-isolated.test.ts +0 -297
  176. package/tests/unit/job-order.test.ts +0 -157
  177. package/tests/unit/pipeline-path-based.test.ts +0 -511
  178. package/tests/unit/validate-pipeline.test.ts +0 -384
  179. package/tests/unit/versioning-extended.test.ts +0 -279
  180. package/tests/unit/versioning.test.ts +0 -241
  181. package/tsconfig.debug.json +0 -17
  182. package/tsconfig.json +0 -28
  183. package/vitest.config.ts +0 -51
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Manage Branch Action Template
3
+ *
4
+ * Generates a composite action for branch operations including fast-forward merges,
5
+ * branch creation, and deletion. Core utility for trunk-based development workflows.
6
+ *
7
+ * @module templates/actions/manage-branch.yml.tpl
8
+ */
1
9
  import { PinionContext } from '@featherscloud/pinion';
10
+ /**
11
+ * Generator entry point for manage-branch composite action.
12
+ *
13
+ * @param {PinionContext} ctx - Pinion generator context
14
+ * @returns {Promise<PinionContext>} Updated context after file generation
15
+ */
2
16
  export declare const generate: (ctx: PinionContext) => Promise<any>;
3
17
  //# sourceMappingURL=manage-branch.yml.tpl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manage-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAyH7E,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUwD,CAAA"}
1
+ {"version":3,"file":"manage-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA+H7E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUwD,CAAA"}
@@ -1,7 +1,21 @@
1
+ /**
2
+ * Manage Branch Action Template
3
+ *
4
+ * Generates a composite action for branch operations including fast-forward merges,
5
+ * branch creation, and deletion. Core utility for trunk-based development workflows.
6
+ *
7
+ * @module templates/actions/manage-branch.yml.tpl
8
+ */
1
9
  import { toFile, renderTemplate } from '@featherscloud/pinion';
2
10
  import fs from 'fs';
3
11
  import dedent from 'dedent';
4
- // Template for the Branch Management GitHub Action
12
+ import { logger } from '../../utils/logger.js';
13
+ /**
14
+ * Generates the manage-branch composite action YAML content.
15
+ *
16
+ * @param {any} ctx - Context (not currently used)
17
+ * @returns {string} YAML content for the composite action
18
+ */
5
19
  const branchActionTemplate = (ctx) => {
6
20
  return dedent `name: 'Branch Management'
7
21
  description: 'Manage branches (fast-forward, create, delete)'
@@ -117,13 +131,19 @@ const branchActionTemplate = (ctx) => {
117
131
  echo "❌ \${{ steps.branch-action.outputs.message }}"
118
132
  fi`;
119
133
  };
134
+ /**
135
+ * Generator entry point for manage-branch composite action.
136
+ *
137
+ * @param {PinionContext} ctx - Pinion generator context
138
+ * @returns {Promise<PinionContext>} Updated context after file generation
139
+ */
120
140
  export const generate = (ctx) => Promise.resolve(ctx)
121
141
  .then((ctx) => {
122
142
  // Check if file exists to determine merge status
123
143
  const filePath = '.github/actions/manage-branch/action.yml';
124
144
  const exists = fs.existsSync(filePath);
125
145
  const status = exists ? '🔄 Merged with existing' : '📝 Created new';
126
- console.log(`${status} ${filePath}`);
146
+ logger.verbose(`${status} ${filePath}`);
127
147
  return ctx;
128
148
  })
129
149
  .then(renderTemplate(branchActionTemplate, toFile('.github/actions/manage-branch/action.yml')));
@@ -1 +1 @@
1
- {"version":3,"file":"manage-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,mDAAmD;AACnD,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACxC,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgHA,CAAA;AACf,CAA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C,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,0CAA0C,CAAA;IAC3D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,MAAM,CAAC,0CAA0C,CAAC,CAAC,CAAC,CAAA"}
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Promote Branch Action Template
3
+ *
4
+ * Generates a composite action that promotes code from one branch to another via
5
+ * temporary branch and pull request. Handles auto-merge and cleanup for trunk flow.
6
+ *
7
+ * @module templates/actions/promote-branch.yml.tpl
8
+ */
1
9
  import { PinionContext } from '@featherscloud/pinion';
10
+ /**
11
+ * Generator entry point for promote-branch composite action.
12
+ *
13
+ * @param {PinionContext} ctx - Pinion generator context
14
+ * @returns {Promise<PinionContext>} Updated context after file generation
15
+ */
2
16
  export declare const generate: (ctx: PinionContext) => Promise<any>;
3
17
  //# sourceMappingURL=promote-branch.yml.tpl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promote-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAiW7E,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUgE,CAAA"}
1
+ {"version":3,"file":"promote-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA8X7E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUgE,CAAA"}
@@ -1,8 +1,21 @@
1
+ /**
2
+ * Promote Branch Action Template
3
+ *
4
+ * Generates a composite action that promotes code from one branch to another via
5
+ * temporary branch and pull request. Handles auto-merge and cleanup for trunk flow.
6
+ *
7
+ * @module templates/actions/promote-branch.yml.tpl
8
+ */
1
9
  import { toFile, renderTemplate } from '@featherscloud/pinion';
2
10
  import fs from 'fs';
3
11
  import dedent from 'dedent';
4
- // Template for the Promote Branch GitHub Action
5
- // This action handles branch promotions via temporary branches + PRs
12
+ import { logger } from '../../utils/logger.js';
13
+ /**
14
+ * Generates the promote-branch composite action YAML content.
15
+ *
16
+ * @param {any} ctx - Context (not currently used)
17
+ * @returns {string} YAML content for the composite action
18
+ */
6
19
  const promoteBranchActionTemplate = (ctx) => {
7
20
  return dedent `name: 'Promote Branch'
8
21
  description: 'Promote code from source to target branch via temporary branch + PR'
@@ -17,6 +30,10 @@ const promoteBranchActionTemplate = (ctx) => {
17
30
  description: 'Version being promoted (e.g., v1.2.3, auto-detected from git tags if not provided)'
18
31
  required: false
19
32
  default: ''
33
+ run_number:
34
+ description: 'The original run number from develop branch for traceability'
35
+ required: false
36
+ default: ''
20
37
  configPath:
21
38
  description: 'Path to .pipecraftrc.json config file'
22
39
  required: false
@@ -296,6 +313,14 @@ const promoteBranchActionTemplate = (ctx) => {
296
313
  echo "✅ Fast-forwarded \$TARGET to \$COMMIT_SHA"
297
314
  echo "📝 PR will be closed automatically for audit trail"
298
315
 
316
+ - name: Wait for Branch to Propagate
317
+ if: steps.read-config.outputs.autoMerge == 'true'
318
+ shell: bash
319
+ run: |
320
+ echo "⏳ Waiting 5 seconds for branch update to propagate..."
321
+ sleep 5
322
+ echo "✅ Branch should be fully propagated"
323
+
299
324
  - name: Trigger Pipeline Workflow on Target Branch
300
325
  if: steps.read-config.outputs.autoMerge == 'true'
301
326
  shell: bash
@@ -304,15 +329,27 @@ const promoteBranchActionTemplate = (ctx) => {
304
329
  run: |
305
330
  TARGET="\${{ steps.read-config.outputs.targetBranch }}"
306
331
  VERSION="\${{ steps.get-version.outputs.version }}"
332
+ RUN_NUMBER="\${{ inputs.run_number }}"
307
333
 
308
- echo "🔄 Triggering pipeline workflow on \$TARGET branch with version \$VERSION"
334
+ # Get the exact commit SHA that was just pushed to target branch
335
+ COMMIT_SHA=$(git rev-parse \$TARGET)
336
+ echo "🔄 Triggering pipeline workflow on \$TARGET branch"
337
+ echo " Version: \$VERSION"
338
+ echo " Commit SHA: \$COMMIT_SHA"
309
339
 
310
340
  # Trigger the pipeline workflow on the target branch
311
341
  # This is necessary because GITHUB_TOKEN pushes don't trigger workflows by default
312
- # Pass the version so the run name is descriptive
313
- gh workflow run pipeline.yml --ref "\$TARGET" --field version="\$VERSION"
342
+ # Pass the exact commit SHA to ensure the workflow checks out the correct commit
343
+ # (avoids race conditions from GitHub's eventual consistency)
344
+ WORKFLOW_ARGS=(--ref "\$TARGET" --field version="\$VERSION" --field commitSha="\$COMMIT_SHA")
345
+ if [ -n "\$RUN_NUMBER" ]; then
346
+ WORKFLOW_ARGS+=(--field run_number="\$RUN_NUMBER")
347
+ echo " Run number: \$RUN_NUMBER (for traceability)"
348
+ fi
349
+
350
+ gh workflow run pipeline.yml "\${WORKFLOW_ARGS[@]}"
314
351
 
315
- echo "✅ Pipeline workflow triggered on \$TARGET with version \$VERSION"
352
+ echo "✅ Pipeline workflow triggered on \$TARGET with version \$VERSION at commit \$COMMIT_SHA"
316
353
 
317
354
  - name: Close PR and Delete Branch
318
355
  if: steps.read-config.outputs.autoMerge == 'true'
@@ -349,13 +386,19 @@ const promoteBranchActionTemplate = (ctx) => {
349
386
  # Note: Fast-forward merge happens in separate step if autoMerge is enabled
350
387
  `;
351
388
  };
389
+ /**
390
+ * Generator entry point for promote-branch composite action.
391
+ *
392
+ * @param {PinionContext} ctx - Pinion generator context
393
+ * @returns {Promise<PinionContext>} Updated context after file generation
394
+ */
352
395
  export const generate = (ctx) => Promise.resolve(ctx)
353
396
  .then((ctx) => {
354
397
  // Check if file exists to determine merge status
355
398
  const filePath = '.github/actions/promote-branch/action.yml';
356
399
  const exists = fs.existsSync(filePath);
357
400
  const status = exists ? '🔄 Merged with existing' : '📝 Created new';
358
- console.log(`${status} ${filePath}`);
401
+ logger.verbose(`${status} ${filePath}`);
359
402
  return ctx;
360
403
  })
361
404
  .then(renderTemplate(promoteBranchActionTemplate, toFile('.github/actions/promote-branch/action.yml')));
@@ -1 +1 @@
1
- {"version":3,"file":"promote-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,gDAAgD;AAChD,qEAAqE;AACrE,MAAM,2BAA2B,GAAG,CAAC,GAAQ,EAAE,EAAE;IAC/C,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuVZ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+WZ,CAAA;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,2CAA2C,CAAA;IAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,2BAA2B,EAAE,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAA"}
@@ -1,3 +1,67 @@
1
+ /**
2
+ * Path-Based Pipeline Template Generator
3
+ *
4
+ * The core template that generates the main CI/CD pipeline workflow for PipeCraft.
5
+ * This is the most complex template in the system, responsible for creating a
6
+ * GitHub Actions workflow that orchestrates the entire trunk-based development flow.
7
+ *
8
+ * ## Key Responsibilities
9
+ *
10
+ * 1. **Change Detection**: Generates jobs to detect which domains (api, web, libs, etc.) changed
11
+ * 2. **Test Execution**: Creates domain-specific test jobs based on changes
12
+ * 3. **Version Management**: Integrates semantic versioning for staging/production branches
13
+ * 4. **Branch Promotion**: Auto-promotes code through branch flow (develop → staging → main)
14
+ * 5. **User Job Preservation**: Maintains user-added custom jobs during regeneration
15
+ * 6. **Comment Preservation**: Retains user comments when updating workflows
16
+ *
17
+ * ## Intelligent Merging
18
+ *
19
+ * The generator distinguishes between:
20
+ * - **Pipecraft-owned jobs**: `changes`, `version`, `tag`, `promote`, `release`, `test-*`, `deploy-*`
21
+ * - **User jobs**: Any jobs not owned by Pipecraft
22
+ *
23
+ * During regeneration:
24
+ * - Pipecraft jobs are completely replaced with template versions
25
+ * - User jobs are preserved exactly as-is
26
+ * - User comments are maintained
27
+ * - Job order is intelligently managed (Pipecraft jobs first, then user jobs)
28
+ *
29
+ * ## Architecture
30
+ *
31
+ * Uses AST-based path operations for surgical YAML manipulation:
32
+ * - Parse existing workflow into AST
33
+ * - Apply precise path-based operations
34
+ * - Preserve formatting and comments
35
+ * - Rebuild YAML maintaining structure
36
+ *
37
+ * @module templates/workflows/pipeline-path-based.yml.tpl
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { generate } from './templates/workflows/pipeline-path-based.yml.tpl.js'
42
+ *
43
+ * // Initial generation
44
+ * await generate({
45
+ * cwd: '/path/to/project',
46
+ * branchFlow: ['develop', 'staging', 'main'],
47
+ * domains: {
48
+ * api: { paths: ['src/api/**'], test: true },
49
+ * web: { paths: ['src/web/**'], test: true }
50
+ * }
51
+ * })
52
+ *
53
+ * // Incremental update (preserves user jobs)
54
+ * await generate({
55
+ * cwd: '/path/to/project',
56
+ * existingPipeline: parsedYAML,
57
+ * existingPipelineContent: rawYAMLString,
58
+ * branchFlow: ['develop', 'staging', 'main'],
59
+ * domains: { ... }
60
+ * })
61
+ * ```
62
+ *
63
+ * @see {@link module:utils/ast-path-operations} for YAML manipulation details
64
+ */
1
65
  import { PinionContext } from '@featherscloud/pinion';
2
66
  /**
3
67
  * Create path-based pipeline content
@@ -7,7 +71,56 @@ export declare const createPathBasedPipeline: (ctx: any) => {
7
71
  mergeStatus: string;
8
72
  };
9
73
  /**
10
- * Main export - path-based pipeline generator
74
+ * Main pipeline generator entry point.
75
+ *
76
+ * Generates the complete GitHub Actions pipeline workflow with intelligent
77
+ * merging of existing user customizations.
78
+ *
79
+ * @param {PinionContext & { existingPipeline?: any, outputPipelinePath?: string }} ctx - Generator context
80
+ * @param {any} [ctx.existingPipeline] - Parsed existing pipeline YAML for merging
81
+ * @param {string} [ctx.existingPipelineContent] - Raw existing pipeline content for comment preservation
82
+ * @param {string} [ctx.outputPipelinePath] - Custom output path (default: .github/workflows/pipeline.yml)
83
+ * @param {string[]} ctx.branchFlow - Branch flow sequence (e.g., ['develop', 'staging', 'main'])
84
+ * @param {Record<string, DomainConfig>} ctx.domains - Domain configurations for change detection
85
+ * @param {string} [ctx.ciProvider] - CI provider ('github' or 'gitlab')
86
+ * @param {string} [ctx.mergeStrategy] - Merge strategy ('fast-forward' or 'merge')
87
+ * @returns {Promise<PinionContext>} Updated context with generated YAML
88
+ *
89
+ * @throws {Error} If pipeline file cannot be written
90
+ * @throws {Error} If existing pipeline cannot be parsed
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * // Generate new pipeline
95
+ * await generate({
96
+ * cwd: '/path/to/project',
97
+ * branchFlow: ['develop', 'main'],
98
+ * domains: {
99
+ * api: { paths: ['src/api/**'], test: true }
100
+ * }
101
+ * })
102
+ *
103
+ * // Update existing pipeline (preserves user jobs)
104
+ * const existing = parseDocument(readFileSync('pipeline.yml', 'utf8'))
105
+ * await generate({
106
+ * cwd: '/path/to/project',
107
+ * existingPipeline: existing,
108
+ * existingPipelineContent: readFileSync('pipeline.yml', 'utf8'),
109
+ * branchFlow: ['develop', 'staging', 'main'],
110
+ * domains: { ... }
111
+ * })
112
+ * ```
113
+ *
114
+ * @note The generator performs these steps:
115
+ * 1. Calls `createPathBasedPipeline()` to build the workflow
116
+ * 2. Logs merge status (new vs. merged)
117
+ * 3. Writes the final YAML to the output path
118
+ *
119
+ * The heavy lifting is done by `createPathBasedPipeline()` which handles:
120
+ * - Job generation based on domains and branch flow
121
+ * - User job preservation and merging
122
+ * - Comment preservation from existing pipeline
123
+ * - Intelligent job ordering
11
124
  */
12
125
  export declare const generate: (ctx: PinionContext & {
13
126
  existingPipeline?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-path-based.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/workflows/pipeline-path-based.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA8D7E;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,KAAK,GAAG;;;CA2lB/C,CAAA;AAcD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,GAAG;IAAE,gBAAgB,CAAC,EAAE,GAAG,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,iBAoB/F,CAAA"}
1
+ {"version":3,"file":"pipeline-path-based.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/workflows/pipeline-path-based.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAsD7E;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,KAAK,GAAG;;;CAm5B/C,CAAA;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,GAAG;IAAE,gBAAgB,CAAC,EAAE,GAAG,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,iBAoB/F,CAAA"}