pipecraft 0.0.0-releaseit

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 (176) hide show
  1. package/.claude/settings.local.json +35 -0
  2. package/.github/actions/calculate-version/action.yml +106 -0
  3. package/.github/actions/create-pr/action.yml +122 -0
  4. package/.github/actions/create-release/action.yml +74 -0
  5. package/.github/actions/create-tag/action.yml +94 -0
  6. package/.github/actions/detect-changes/action.yml +62 -0
  7. package/.github/actions/manage-branch/action.yml +113 -0
  8. package/.github/actions/promote-branch/action.yml +352 -0
  9. package/.github/example/workflows/job.analyze.code.yml +26 -0
  10. package/.github/example/workflows/job.analyze.docker.yml +32 -0
  11. package/.github/example/workflows/job.app.api.deploy.yml +127 -0
  12. package/.github/example/workflows/job.app.api.test.yml +102 -0
  13. package/.github/example/workflows/job.app.docs.deploy.yml +40 -0
  14. package/.github/example/workflows/job.app.docs.test.yml +50 -0
  15. package/.github/example/workflows/job.app.web.deploy.yml +96 -0
  16. package/.github/example/workflows/job.app.web.test.yml +49 -0
  17. package/.github/example/workflows/job.changes.yml +82 -0
  18. package/.github/example/workflows/job.create-pr.yml +96 -0
  19. package/.github/example/workflows/job.env-check.yml +43 -0
  20. package/.github/example/workflows/job.fast-forward.yml +103 -0
  21. package/.github/example/workflows/job.lint.yml +64 -0
  22. package/.github/example/workflows/job.pr-name.yml +70 -0
  23. package/.github/example/workflows/job.pr-squash-name.yml +27 -0
  24. package/.github/example/workflows/job.tag.yml +38 -0
  25. package/.github/example/workflows/job.version.yml +99 -0
  26. package/.github/example/workflows/lib.plugin-base.publish.yml +59 -0
  27. package/.github/example/workflows/pipe.yml +178 -0
  28. package/.github/example/workflows/scripts/fastforward.sh +51 -0
  29. package/.github/example/workflows/scripts/pipe-cleaner.sh +70 -0
  30. package/.github/scripts/fastforward.sh +51 -0
  31. package/.github/scripts/pipe-cleaner.sh +70 -0
  32. package/.github/workflows/pipeline.yml +220 -0
  33. package/.github/workflows/pr-title-check.yml +70 -0
  34. package/.github/workflows/publish.yml +39 -0
  35. package/.pipecraftrc.json +78 -0
  36. package/.release-it.cjs +71 -0
  37. package/PIPELINE_TESTING_PLAN.md +499 -0
  38. package/README.md +1101 -0
  39. package/TRUNK_FLOW_PLAN.md +401 -0
  40. package/assets/logo_banner.png +0 -0
  41. package/assets/logo_banner.webp +0 -0
  42. package/dist/cli/index.d.ts +3 -0
  43. package/dist/cli/index.d.ts.map +1 -0
  44. package/dist/cli/index.js +364 -0
  45. package/dist/cli/index.js.map +1 -0
  46. package/dist/generators/init.tpl.d.ts +3 -0
  47. package/dist/generators/init.tpl.d.ts.map +1 -0
  48. package/dist/generators/init.tpl.js +117 -0
  49. package/dist/generators/init.tpl.js.map +1 -0
  50. package/dist/generators/workflows.tpl.d.ts +7 -0
  51. package/dist/generators/workflows.tpl.d.ts.map +1 -0
  52. package/dist/generators/workflows.tpl.js +73 -0
  53. package/dist/generators/workflows.tpl.js.map +1 -0
  54. package/dist/templates/actions/calculate-version.yml.tpl.d.ts +3 -0
  55. package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -0
  56. package/dist/templates/actions/calculate-version.yml.tpl.js +122 -0
  57. package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -0
  58. package/dist/templates/actions/create-pr.yml.tpl.d.ts +3 -0
  59. package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -0
  60. package/dist/templates/actions/create-pr.yml.tpl.js +145 -0
  61. package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -0
  62. package/dist/templates/actions/create-tag.yml.tpl.d.ts +3 -0
  63. package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -0
  64. package/dist/templates/actions/create-tag.yml.tpl.js +111 -0
  65. package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -0
  66. package/dist/templates/actions/detect-changes.yml.tpl.d.ts +3 -0
  67. package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -0
  68. package/dist/templates/actions/detect-changes.yml.tpl.js +79 -0
  69. package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -0
  70. package/dist/templates/actions/manage-branch.yml.tpl.d.ts +3 -0
  71. package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -0
  72. package/dist/templates/actions/manage-branch.yml.tpl.js +130 -0
  73. package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -0
  74. package/dist/templates/actions/promote-branch.yml.tpl.d.ts +3 -0
  75. package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -0
  76. package/dist/templates/actions/promote-branch.yml.tpl.js +362 -0
  77. package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -0
  78. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +16 -0
  79. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -0
  80. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +652 -0
  81. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -0
  82. package/dist/types/index.d.ts +63 -0
  83. package/dist/types/index.d.ts.map +1 -0
  84. package/dist/types/index.js +2 -0
  85. package/dist/types/index.js.map +1 -0
  86. package/dist/utils/ast-path-operations.d.ts +287 -0
  87. package/dist/utils/ast-path-operations.d.ts.map +1 -0
  88. package/dist/utils/ast-path-operations.js +419 -0
  89. package/dist/utils/ast-path-operations.js.map +1 -0
  90. package/dist/utils/config.d.ts +3 -0
  91. package/dist/utils/config.d.ts.map +1 -0
  92. package/dist/utils/config.js +49 -0
  93. package/dist/utils/config.js.map +1 -0
  94. package/dist/utils/github-setup.d.ts +74 -0
  95. package/dist/utils/github-setup.d.ts.map +1 -0
  96. package/dist/utils/github-setup.js +418 -0
  97. package/dist/utils/github-setup.js.map +1 -0
  98. package/dist/utils/idempotency.d.ts +47 -0
  99. package/dist/utils/idempotency.d.ts.map +1 -0
  100. package/dist/utils/idempotency.js +176 -0
  101. package/dist/utils/idempotency.js.map +1 -0
  102. package/dist/utils/preflight.d.ts +55 -0
  103. package/dist/utils/preflight.d.ts.map +1 -0
  104. package/dist/utils/preflight.js +261 -0
  105. package/dist/utils/preflight.js.map +1 -0
  106. package/dist/utils/versioning.d.ts +41 -0
  107. package/dist/utils/versioning.d.ts.map +1 -0
  108. package/dist/utils/versioning.js +219 -0
  109. package/dist/utils/versioning.js.map +1 -0
  110. package/docs/USER_JOURNEY_ERRORS.md +352 -0
  111. package/eslint.config.js +77 -0
  112. package/examples/basic-config.json +41 -0
  113. package/examples/monorepo-config.json +49 -0
  114. package/examples/usage.md +289 -0
  115. package/package.json +58 -0
  116. package/scripts/debug-workflows.sh +339 -0
  117. package/scripts/parse-pipeline.js +29 -0
  118. package/scripts/test-job-order.cjs +140 -0
  119. package/scripts/validate-pipeline.cjs +379 -0
  120. package/scripts/verify-job-order.sh +30 -0
  121. package/src/cli/index.ts +414 -0
  122. package/src/generators/init.tpl.ts +126 -0
  123. package/src/generators/workflows.tpl.ts +80 -0
  124. package/src/templates/actions/calculate-version.yml.tpl.ts +124 -0
  125. package/src/templates/actions/create-pr.yml.tpl.ts +147 -0
  126. package/src/templates/actions/create-tag.yml.tpl.ts +112 -0
  127. package/src/templates/actions/detect-changes.yml.tpl.ts +87 -0
  128. package/src/templates/actions/manage-branch.yml.tpl.ts +132 -0
  129. package/src/templates/actions/promote-branch.yml.tpl.ts +364 -0
  130. package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +706 -0
  131. package/src/types/index.ts +64 -0
  132. package/src/utils/README-ast-path-operations.md +390 -0
  133. package/src/utils/ast-path-operations.ts +581 -0
  134. package/src/utils/config.ts +64 -0
  135. package/src/utils/github-setup.ts +558 -0
  136. package/src/utils/idempotency.ts +215 -0
  137. package/src/utils/preflight.ts +306 -0
  138. package/src/utils/versioning.ts +244 -0
  139. package/tests/README.md +229 -0
  140. package/tests/TEST_STRUCTURE.md +256 -0
  141. package/tests/act/run-act-tests.sh +345 -0
  142. package/tests/debugging/debug-utils.ts +538 -0
  143. package/tests/debugging/debug-workflow.test.ts +339 -0
  144. package/tests/debugging/debug-workflows.sh +339 -0
  145. package/tests/debugging/iterative-debug.ts +652 -0
  146. package/tests/debugging/run-debug-tests.sh +431 -0
  147. package/tests/fixtures/basic-config.json +51 -0
  148. package/tests/fixtures/invalid-config.json +9 -0
  149. package/tests/fixtures/pipeline-generated.yml +235 -0
  150. package/tests/fixtures/pipeline-preserve-comments.yml +245 -0
  151. package/tests/fixtures/pipeline-user-modified.yml +245 -0
  152. package/tests/fixtures/test-config.json +58 -0
  153. package/tests/github-live/README.md +250 -0
  154. package/tests/github-local/JOB_WORKFLOW_TESTS.md +296 -0
  155. package/tests/github-local/README.md +240 -0
  156. package/tests/github-local/run-all-tests.sh +422 -0
  157. package/tests/github-local/test-job-workflows.sh +631 -0
  158. package/tests/github-local/test-pipeline-workflow.sh +440 -0
  159. package/tests/integration/generators.test.ts +578 -0
  160. package/tests/integration/path-based-template.test.ts +510 -0
  161. package/tests/integration/simple-path-based.test.ts +415 -0
  162. package/tests/setup.ts +56 -0
  163. package/tests/unit/ast-path-operations-extended.test.ts +302 -0
  164. package/tests/unit/cli.test.ts +541 -0
  165. package/tests/unit/config-extended.test.ts +412 -0
  166. package/tests/unit/config.test.ts +152 -0
  167. package/tests/unit/github-setup.test.ts +189 -0
  168. package/tests/unit/idempotency-isolated.test.ts +297 -0
  169. package/tests/unit/job-order.test.ts +157 -0
  170. package/tests/unit/pipeline-path-based.test.ts +511 -0
  171. package/tests/unit/validate-pipeline.test.ts +384 -0
  172. package/tests/unit/versioning-extended.test.ts +279 -0
  173. package/tests/unit/versioning.test.ts +241 -0
  174. package/tsconfig.debug.json +17 -0
  175. package/tsconfig.json +28 -0
  176. package/vitest.config.ts +51 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idempotency.js","sourceRoot":"","sources":["../../src/utils/idempotency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,UAA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AAC,SAAS,CAAC;gBACzC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE;gBAC1C,IAAI,EAAE,CAAC;aACR,CAAA;QACH,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CAAC,QAAgB;QACzC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;YAClC,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC;YACzC,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QACtD,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAExC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,IAAI,CAAA,CAAC,sCAAsC;QACpD,CAAC;QAED,OAAO,UAAU,CAAC,IAAI,KAAK,WAAW,CAAA;IACxC,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Pre-flight checks for PipeCraft commands
3
+ * Validates environment and prerequisites before executing commands
4
+ */
5
+ export interface PreflightResult {
6
+ passed: boolean;
7
+ message: string;
8
+ suggestion?: string;
9
+ }
10
+ export interface PreflightChecks {
11
+ configExists: PreflightResult;
12
+ configValid: PreflightResult;
13
+ inGitRepo: PreflightResult;
14
+ hasGitRemote: PreflightResult;
15
+ canWriteGithubDir: PreflightResult;
16
+ }
17
+ /**
18
+ * Check if config file exists using cosmiconfig
19
+ * Searches for .pipecraftrc.json, .pipecraftrc, or package.json pipecraft key
20
+ */
21
+ export declare function checkConfigExists(): PreflightResult;
22
+ /**
23
+ * Check if config file is valid and has required fields
24
+ */
25
+ export declare function checkConfigValid(): PreflightResult;
26
+ /**
27
+ * Check if current directory is a git repository
28
+ */
29
+ export declare function checkInGitRepo(): PreflightResult;
30
+ /**
31
+ * Check if git remote is configured
32
+ */
33
+ export declare function checkHasGitRemote(): PreflightResult;
34
+ /**
35
+ * Check if .github directory is writable
36
+ */
37
+ export declare function checkCanWriteGithubDir(): PreflightResult;
38
+ /**
39
+ * Check Node.js version
40
+ */
41
+ export declare function checkNodeVersion(minVersion?: string): PreflightResult;
42
+ /**
43
+ * Run all pre-flight checks for generate command
44
+ * Note: No longer needs configPath - uses cosmiconfig to search automatically
45
+ */
46
+ export declare function runPreflightChecks(): PreflightChecks;
47
+ /**
48
+ * Format preflight results for display
49
+ */
50
+ export declare function formatPreflightResults(checks: PreflightChecks): {
51
+ allPassed: boolean;
52
+ output: string;
53
+ nextSteps?: string[];
54
+ };
55
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/utils/preflight.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,eAAe,CAAA;IAC7B,WAAW,EAAE,eAAe,CAAA;IAC5B,SAAS,EAAE,eAAe,CAAA;IAC1B,YAAY,EAAE,eAAe,CAAA;IAC7B,iBAAiB,EAAE,eAAe,CAAA;CACnC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,eAAe,CAgBnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CAuDlD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,eAAe,CAkBhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,eAAe,CAgCnD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,eAAe,CAyCxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,MAAiB,GAAG,eAAe,CAkB/E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAQpD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG;IAC/D,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB,CAkCA"}
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Pre-flight checks for PipeCraft commands
3
+ * Validates environment and prerequisites before executing commands
4
+ */
5
+ import { existsSync, mkdirSync, writeFileSync, unlinkSync } from 'fs';
6
+ import { execSync } from 'child_process';
7
+ import { join } from 'path';
8
+ import { cosmiconfigSync } from 'cosmiconfig';
9
+ /**
10
+ * Check if config file exists using cosmiconfig
11
+ * Searches for .pipecraftrc.json, .pipecraftrc, or package.json pipecraft key
12
+ */
13
+ export function checkConfigExists() {
14
+ const explorer = cosmiconfigSync('pipecraft');
15
+ const result = explorer.search();
16
+ if (!result) {
17
+ return {
18
+ passed: false,
19
+ message: 'No PipeCraft configuration found',
20
+ suggestion: "Run 'pipecraft init' to create a configuration file"
21
+ };
22
+ }
23
+ return {
24
+ passed: true,
25
+ message: `Configuration found: ${result.filepath}`
26
+ };
27
+ }
28
+ /**
29
+ * Check if config file is valid and has required fields
30
+ */
31
+ export function checkConfigValid() {
32
+ const explorer = cosmiconfigSync('pipecraft');
33
+ const result = explorer.search();
34
+ if (!result) {
35
+ return {
36
+ passed: false,
37
+ message: 'No configuration file found',
38
+ suggestion: "Run 'pipecraft init' first"
39
+ };
40
+ }
41
+ try {
42
+ const config = result.config;
43
+ // Check for required fields
44
+ const requiredFields = ['ciProvider', 'branchFlow', 'domains'];
45
+ const missingFields = requiredFields.filter(field => !(field in config));
46
+ if (missingFields.length > 0) {
47
+ return {
48
+ passed: false,
49
+ message: `Config is missing required fields: ${missingFields.join(', ')}`,
50
+ suggestion: "Run 'pipecraft init --force' to recreate config"
51
+ };
52
+ }
53
+ // Check domains is not empty
54
+ if (!config.domains || Object.keys(config.domains).length === 0) {
55
+ return {
56
+ passed: false,
57
+ message: 'Config has no domains configured',
58
+ suggestion: "Add at least one domain to your config file"
59
+ };
60
+ }
61
+ return {
62
+ passed: true,
63
+ message: 'Configuration is valid'
64
+ };
65
+ }
66
+ catch (error) {
67
+ if (error instanceof SyntaxError) {
68
+ return {
69
+ passed: false,
70
+ message: `Invalid JSON in config file: ${error.message}`,
71
+ suggestion: 'Fix JSON syntax in your config file'
72
+ };
73
+ }
74
+ return {
75
+ passed: false,
76
+ message: `Error reading config: ${error.message}`,
77
+ suggestion: 'Check file permissions for your config file'
78
+ };
79
+ }
80
+ }
81
+ /**
82
+ * Check if current directory is a git repository
83
+ */
84
+ export function checkInGitRepo() {
85
+ try {
86
+ execSync('git rev-parse --is-inside-work-tree', {
87
+ stdio: 'pipe',
88
+ encoding: 'utf8'
89
+ });
90
+ return {
91
+ passed: true,
92
+ message: 'Current directory is a git repository'
93
+ };
94
+ }
95
+ catch (error) {
96
+ return {
97
+ passed: false,
98
+ message: 'Not in a git repository',
99
+ suggestion: "Initialize git: 'git init' or clone an existing repository"
100
+ };
101
+ }
102
+ }
103
+ /**
104
+ * Check if git remote is configured
105
+ */
106
+ export function checkHasGitRemote() {
107
+ try {
108
+ const remote = execSync('git remote get-url origin', {
109
+ stdio: 'pipe',
110
+ encoding: 'utf8'
111
+ }).trim();
112
+ if (!remote) {
113
+ return {
114
+ passed: false,
115
+ message: 'No git remote configured',
116
+ suggestion: "Add remote: 'git remote add origin <url>'"
117
+ };
118
+ }
119
+ // Check if it's a GitHub remote
120
+ const isGitHub = remote.includes('github.com');
121
+ return {
122
+ passed: true,
123
+ message: `Git remote configured: ${remote}`,
124
+ suggestion: !isGitHub
125
+ ? 'Note: PipeCraft is optimized for GitHub. GitLab support is experimental.'
126
+ : undefined
127
+ };
128
+ }
129
+ catch (error) {
130
+ return {
131
+ passed: false,
132
+ message: 'No git remote named "origin"',
133
+ suggestion: "Add remote: 'git remote add origin <url>'"
134
+ };
135
+ }
136
+ }
137
+ /**
138
+ * Check if .github directory is writable
139
+ */
140
+ export function checkCanWriteGithubDir() {
141
+ const githubDir = '.github';
142
+ const workflowsDir = join(githubDir, 'workflows');
143
+ try {
144
+ if (!existsSync(githubDir)) {
145
+ // Try to create it
146
+ mkdirSync(githubDir, { recursive: true });
147
+ mkdirSync(workflowsDir, { recursive: true });
148
+ return {
149
+ passed: true,
150
+ message: 'Created .github/workflows directory'
151
+ };
152
+ }
153
+ // Directory exists, check if writable
154
+ if (existsSync(workflowsDir)) {
155
+ // Try to write a test file
156
+ const testFile = join(workflowsDir, '.pipecraft-test');
157
+ writeFileSync(testFile, 'test');
158
+ unlinkSync(testFile);
159
+ return {
160
+ passed: true,
161
+ message: '.github/workflows directory is writable'
162
+ };
163
+ }
164
+ else {
165
+ mkdirSync(workflowsDir, { recursive: true });
166
+ return {
167
+ passed: true,
168
+ message: 'Created .github/workflows directory'
169
+ };
170
+ }
171
+ }
172
+ catch (error) {
173
+ return {
174
+ passed: false,
175
+ message: `Cannot write to .github directory: ${error.message}`,
176
+ suggestion: 'Check directory permissions'
177
+ };
178
+ }
179
+ }
180
+ /**
181
+ * Check Node.js version
182
+ */
183
+ export function checkNodeVersion(minVersion = '18.0.0') {
184
+ const currentVersion = process.version.slice(1); // Remove 'v' prefix
185
+ const [currentMajor] = currentVersion.split('.').map(Number);
186
+ const [minMajor] = minVersion.split('.').map(Number);
187
+ if (currentMajor < minMajor) {
188
+ return {
189
+ passed: false,
190
+ message: `Node.js ${currentVersion} is too old (minimum: ${minVersion})`,
191
+ suggestion: 'Update Node.js: https://nodejs.org'
192
+ };
193
+ }
194
+ return {
195
+ passed: true,
196
+ message: `Node.js ${currentVersion} (>= ${minVersion})`
197
+ };
198
+ }
199
+ /**
200
+ * Run all pre-flight checks for generate command
201
+ * Note: No longer needs configPath - uses cosmiconfig to search automatically
202
+ */
203
+ export function runPreflightChecks() {
204
+ return {
205
+ configExists: checkConfigExists(),
206
+ configValid: checkConfigValid(),
207
+ inGitRepo: checkInGitRepo(),
208
+ hasGitRemote: checkHasGitRemote(),
209
+ canWriteGithubDir: checkCanWriteGithubDir()
210
+ };
211
+ }
212
+ /**
213
+ * Format preflight results for display
214
+ */
215
+ export function formatPreflightResults(checks) {
216
+ const results = [];
217
+ let allPassed = true;
218
+ for (const [key, result] of Object.entries(checks)) {
219
+ const icon = result.passed ? '✅' : '❌';
220
+ results.push(`${icon} ${result.message}`);
221
+ if (!result.passed) {
222
+ allPassed = false;
223
+ if (result.suggestion) {
224
+ results.push(` 💡 ${result.suggestion}`);
225
+ }
226
+ }
227
+ }
228
+ // Provide next steps if all checks passed
229
+ const nextSteps = allPassed ? [
230
+ 'Your environment is ready to generate workflows!',
231
+ '',
232
+ 'Next steps:',
233
+ ' 1. Validate the pipeline: pipecraft validate:pipeline',
234
+ ' 2. Set up GitHub tokens: pipecraft setup-github --verify',
235
+ ' 3. Commit the generated workflows: git add .github && git commit -m "chore: add workflows"',
236
+ ' 4. Push to remote: git push origin ' + getCurrentBranch(),
237
+ '',
238
+ '⚠️ Important: Set up GitHub tokens (step 2) BEFORE pushing to ensure workflows run correctly!'
239
+ ] : undefined;
240
+ return {
241
+ allPassed,
242
+ output: results.join('\n'),
243
+ nextSteps
244
+ };
245
+ }
246
+ /**
247
+ * Get current git branch name
248
+ */
249
+ function getCurrentBranch() {
250
+ try {
251
+ const branch = execSync('git branch --show-current', {
252
+ stdio: 'pipe',
253
+ encoding: 'utf8'
254
+ }).trim();
255
+ return branch || 'main';
256
+ }
257
+ catch (error) {
258
+ return 'main';
259
+ }
260
+ }
261
+ //# sourceMappingURL=preflight.js.map
@@ -0,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D;QAC5D,8FAA8F;QAC9F,uCAAuC,GAAG,gBAAgB,EAAE;QAC5D,EAAE;QACF,gGAAgG;KACjG,CAAC,CAAC,CAAC,SAAS,CAAA;IAEb,OAAO;QACL,SAAS;QACT,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1B,SAAS;KACV,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB;IACvB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,2BAA2B,EAAE;YACnD,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC,IAAI,EAAE,CAAA;QACT,OAAO,MAAM,IAAI,MAAM,CAAA;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAA;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { PipecraftConfig } from '../types/index.js';
2
+ export declare class VersionManager {
3
+ private config;
4
+ constructor(config: PipecraftConfig);
5
+ /**
6
+ * Generate release-it configuration
7
+ */
8
+ generateReleaseItConfig(): string;
9
+ /**
10
+ * Generate commitlint configuration
11
+ */
12
+ generateCommitlintConfig(): string;
13
+ /**
14
+ * Generate husky configuration
15
+ */
16
+ generateHuskyConfig(): string;
17
+ /**
18
+ * Setup version management files
19
+ */
20
+ setupVersionManagement(): void;
21
+ /**
22
+ * Update package.json with version management scripts
23
+ */
24
+ private updatePackageJsonScripts;
25
+ /**
26
+ * Check if conventional commits are being used
27
+ */
28
+ validateConventionalCommits(): boolean;
29
+ /**
30
+ * Get current version from git tags
31
+ */
32
+ getCurrentVersion(): string;
33
+ /**
34
+ * Calculate next version based on conventional commits
35
+ */
36
+ calculateNextVersion(): {
37
+ version: string;
38
+ type: string;
39
+ };
40
+ }
41
+ //# sourceMappingURL=versioning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../../src/utils/versioning.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,eAAe;IAInC;;OAEG;IACH,uBAAuB,IAAI,MAAM;IAuEjC;;OAEG;IACH,wBAAwB,IAAI,MAAM;IA8BlC;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAO7B;;OAEG;IACH,sBAAsB,IAAI,IAAI;IAgC9B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;OAEG;IACH,2BAA2B,IAAI,OAAO;IActC;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAS3B;;OAEG;IACH,oBAAoB,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAuB1D"}
@@ -0,0 +1,219 @@
1
+ import { execSync } from 'child_process';
2
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
3
+ import { join } from 'path';
4
+ export class VersionManager {
5
+ config;
6
+ constructor(config) {
7
+ this.config = config;
8
+ }
9
+ /**
10
+ * Generate release-it configuration
11
+ */
12
+ generateReleaseItConfig() {
13
+ const defaultConfig = {
14
+ git: {
15
+ requireCleanWorkingDir: false,
16
+ commit: false,
17
+ pushArgs: ["--tags"],
18
+ tagMatch: "v[0-9]*.[0-9]*.[0-9]*"
19
+ },
20
+ github: {
21
+ release: false
22
+ },
23
+ npm: {
24
+ ignoreVersion: true,
25
+ publish: false,
26
+ skipChecks: true
27
+ },
28
+ hooks: {
29
+ "after:release": "echo ${version} > .release-version"
30
+ },
31
+ plugins: {
32
+ "@release-it/conventional-changelog": {
33
+ whatBump: (commits, options) => {
34
+ const defaults = {
35
+ test: 'ignore',
36
+ build: 'ignore',
37
+ ci: 'patch',
38
+ docs: 'patch',
39
+ chore: 'minor',
40
+ style: 'patch',
41
+ fix: 'patch',
42
+ perf: 'patch',
43
+ refactor: 'patch',
44
+ feat: 'minor',
45
+ major: 'major',
46
+ };
47
+ // Merge with user-defined bump rules
48
+ const bumpRules = { ...defaults, ...this.config.versioning?.bumpRules };
49
+ let breakings = 0;
50
+ let features = 0;
51
+ let levelSet = ['major', 'minor', 'patch', 'ignore'];
52
+ // eslint-disable-next-line prefer-spread
53
+ let level = Math.min.apply(Math, commits.map(commit => {
54
+ let level = levelSet.indexOf(bumpRules[commit.type] || 'ignore');
55
+ level = level < 0 ? 3 : level;
56
+ if (commit.notes.length > 0) {
57
+ breakings += commit.notes.length;
58
+ }
59
+ if (commit.type === 'feat') {
60
+ features += 1;
61
+ }
62
+ return level;
63
+ }));
64
+ return {
65
+ level: level,
66
+ reason: breakings === 1
67
+ ? `There is ${breakings} BREAKING CHANGE and ${features} features`
68
+ : `There are ${breakings} BREAKING CHANGES and ${features} features`
69
+ };
70
+ }
71
+ }
72
+ }
73
+ };
74
+ return `module.exports = ${JSON.stringify(defaultConfig, null, 2)}`;
75
+ }
76
+ /**
77
+ * Generate commitlint configuration
78
+ */
79
+ generateCommitlintConfig() {
80
+ return `module.exports = {
81
+ extends: ['@commitlint/config-conventional'],
82
+ rules: {
83
+ 'type-enum': [
84
+ 2,
85
+ 'always',
86
+ [
87
+ 'feat',
88
+ 'fix',
89
+ 'docs',
90
+ 'style',
91
+ 'refactor',
92
+ 'perf',
93
+ 'test',
94
+ 'build',
95
+ 'ci',
96
+ 'chore',
97
+ 'revert'
98
+ ]
99
+ ],
100
+ 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
101
+ 'subject-empty': [2, 'never'],
102
+ 'subject-full-stop': [2, 'never', '.'],
103
+ 'type-case': [2, 'always', 'lower-case'],
104
+ 'type-empty': [2, 'never']
105
+ }
106
+ }`;
107
+ }
108
+ /**
109
+ * Generate husky configuration
110
+ */
111
+ generateHuskyConfig() {
112
+ return `#!/usr/bin/env sh
113
+ . "$(dirname -- "$0")/_/husky.sh"
114
+
115
+ npx commitlint --edit $1`;
116
+ }
117
+ /**
118
+ * Setup version management files
119
+ */
120
+ setupVersionManagement() {
121
+ if (!this.config.versioning?.enabled) {
122
+ return;
123
+ }
124
+ // Generate .release-it.cjs
125
+ const releaseItConfig = this.generateReleaseItConfig();
126
+ writeFileSync('.release-it.cjs', releaseItConfig);
127
+ // Generate commitlint.config.js
128
+ const commitlintConfig = this.generateCommitlintConfig();
129
+ writeFileSync('commitlint.config.js', commitlintConfig);
130
+ // Generate .husky/commit-msg
131
+ const huskyDir = '.husky';
132
+ if (!existsSync(huskyDir)) {
133
+ execSync('npx husky install', { stdio: 'inherit' });
134
+ // Ensure directory exists (in case husky install was mocked/failed)
135
+ if (!existsSync(huskyDir)) {
136
+ const { mkdirSync } = require('fs');
137
+ mkdirSync(huskyDir, { recursive: true });
138
+ }
139
+ }
140
+ const commitMsgHook = this.generateHuskyConfig();
141
+ writeFileSync(join(huskyDir, 'commit-msg'), commitMsgHook);
142
+ execSync(`chmod +x ${join(huskyDir, 'commit-msg')}`);
143
+ // Update package.json scripts
144
+ this.updatePackageJsonScripts();
145
+ }
146
+ /**
147
+ * Update package.json with version management scripts
148
+ */
149
+ updatePackageJsonScripts() {
150
+ const packageJsonPath = 'package.json';
151
+ if (!existsSync(packageJsonPath)) {
152
+ return;
153
+ }
154
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
155
+ packageJson.scripts = {
156
+ ...packageJson.scripts,
157
+ 'release': 'release-it',
158
+ 'release:dry': 'release-it --dry-run',
159
+ 'version:check': 'release-it --dry-run',
160
+ 'changelog': 'conventional-changelog -p angular -i CHANGELOG.md -s',
161
+ 'commit': 'git add . && git commit',
162
+ 'prepare': 'husky install'
163
+ };
164
+ writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
165
+ }
166
+ /**
167
+ * Check if conventional commits are being used
168
+ */
169
+ validateConventionalCommits() {
170
+ try {
171
+ const result = execSync('git log --oneline -10', { encoding: 'utf8' });
172
+ const commits = result.split('\n').filter(line => line.trim());
173
+ // Check if commits follow conventional format
174
+ const conventionalPattern = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .+/;
175
+ return commits.every(commit => conventionalPattern.test(commit));
176
+ }
177
+ catch (error) {
178
+ return false;
179
+ }
180
+ }
181
+ /**
182
+ * Get current version from git tags
183
+ */
184
+ getCurrentVersion() {
185
+ try {
186
+ const result = execSync('git describe --tags --abbrev=0', { encoding: 'utf8' });
187
+ return result.trim().replace('v', '');
188
+ }
189
+ catch (error) {
190
+ return '0.0.0';
191
+ }
192
+ }
193
+ /**
194
+ * Calculate next version based on conventional commits
195
+ */
196
+ calculateNextVersion() {
197
+ try {
198
+ const currentVersion = this.getCurrentVersion();
199
+ const result = execSync('npx release-it --dry-run --no-git.requireCleanWorkingDir', {
200
+ encoding: 'utf8',
201
+ stdio: 'pipe'
202
+ });
203
+ // Parse release-it output to get version info
204
+ const versionMatch = result.match(/version\s+(\d+\.\d+\.\d+)/);
205
+ const typeMatch = result.match(/bump\s+(\w+)/);
206
+ return {
207
+ version: versionMatch ? versionMatch[1] : currentVersion,
208
+ type: typeMatch ? typeMatch[1] : 'patch'
209
+ };
210
+ }
211
+ catch (error) {
212
+ return {
213
+ version: this.getCurrentVersion(),
214
+ type: 'patch'
215
+ };
216
+ }
217
+ }
218
+ }
219
+ //# sourceMappingURL=versioning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versioning.js","sourceRoot":"","sources":["../../src/utils/versioning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiB;IAE/B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;OAEG;IACH,uBAAuB;Q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