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.
- package/README.md +126 -108
- package/dist/cli/index.d.ts +69 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +94 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +70 -0
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +100 -8
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +86 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +101 -9
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-release.yml.tpl.js +141 -0
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
- package/dist/types/index.d.ts +231 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +24 -11
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +63 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +71 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +323 -2
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +551 -23
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/idempotency.d.ts +147 -7
- package/dist/utils/idempotency.d.ts.map +1 -1
- package/dist/utils/idempotency.js +143 -15
- package/dist/utils/idempotency.js.map +1 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +153 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/preflight.d.ts +223 -12
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +216 -16
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +160 -8
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +179 -15
- package/dist/utils/versioning.js.map +1 -1
- package/package.json +26 -5
- package/.claude/settings.local.json +0 -35
- package/.github/actions/calculate-version/action.yml +0 -106
- package/.github/actions/create-pr/action.yml +0 -122
- package/.github/actions/create-release/action.yml +0 -74
- package/.github/actions/create-tag/action.yml +0 -94
- package/.github/actions/detect-changes/action.yml +0 -62
- package/.github/actions/manage-branch/action.yml +0 -113
- package/.github/actions/promote-branch/action.yml +0 -352
- package/.github/example/workflows/job.analyze.code.yml +0 -26
- package/.github/example/workflows/job.analyze.docker.yml +0 -32
- package/.github/example/workflows/job.app.api.deploy.yml +0 -127
- package/.github/example/workflows/job.app.api.test.yml +0 -102
- package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
- package/.github/example/workflows/job.app.docs.test.yml +0 -50
- package/.github/example/workflows/job.app.web.deploy.yml +0 -96
- package/.github/example/workflows/job.app.web.test.yml +0 -49
- package/.github/example/workflows/job.changes.yml +0 -82
- package/.github/example/workflows/job.create-pr.yml +0 -96
- package/.github/example/workflows/job.env-check.yml +0 -43
- package/.github/example/workflows/job.fast-forward.yml +0 -103
- package/.github/example/workflows/job.lint.yml +0 -64
- package/.github/example/workflows/job.pr-name.yml +0 -70
- package/.github/example/workflows/job.pr-squash-name.yml +0 -27
- package/.github/example/workflows/job.tag.yml +0 -38
- package/.github/example/workflows/job.version.yml +0 -99
- package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
- package/.github/example/workflows/pipe.yml +0 -178
- package/.github/example/workflows/scripts/fastforward.sh +0 -51
- package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
- package/.github/scripts/fastforward.sh +0 -51
- package/.github/scripts/pipe-cleaner.sh +0 -70
- package/.github/workflows/pipeline.yml +0 -220
- package/.github/workflows/pr-title-check.yml +0 -70
- package/.github/workflows/publish.yml +0 -39
- package/.pipecraftrc.json +0 -78
- package/.release-it.cjs +0 -71
- package/PIPELINE_TESTING_PLAN.md +0 -499
- package/TRUNK_FLOW_PLAN.md +0 -401
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/docs/USER_JOURNEY_ERRORS.md +0 -352
- package/eslint.config.js +0 -77
- package/examples/basic-config.json +0 -41
- package/examples/monorepo-config.json +0 -49
- package/examples/usage.md +0 -289
- package/scripts/debug-workflows.sh +0 -339
- package/scripts/parse-pipeline.js +0 -29
- package/scripts/test-job-order.cjs +0 -140
- package/scripts/validate-pipeline.cjs +0 -379
- package/scripts/verify-job-order.sh +0 -30
- package/src/cli/index.ts +0 -414
- package/src/generators/init.tpl.ts +0 -126
- package/src/generators/workflows.tpl.ts +0 -80
- package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
- package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
- package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
- package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
- package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
- package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
- package/src/types/index.ts +0 -64
- package/src/utils/README-ast-path-operations.md +0 -390
- package/src/utils/ast-path-operations.ts +0 -581
- package/src/utils/config.ts +0 -64
- package/src/utils/github-setup.ts +0 -558
- package/src/utils/idempotency.ts +0 -215
- package/src/utils/preflight.ts +0 -306
- package/src/utils/versioning.ts +0 -244
- package/tests/README.md +0 -229
- package/tests/TEST_STRUCTURE.md +0 -256
- package/tests/act/run-act-tests.sh +0 -345
- package/tests/debugging/debug-utils.ts +0 -538
- package/tests/debugging/debug-workflow.test.ts +0 -339
- package/tests/debugging/debug-workflows.sh +0 -339
- package/tests/debugging/iterative-debug.ts +0 -652
- package/tests/debugging/run-debug-tests.sh +0 -431
- package/tests/fixtures/basic-config.json +0 -51
- package/tests/fixtures/invalid-config.json +0 -9
- package/tests/fixtures/pipeline-generated.yml +0 -235
- package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
- package/tests/fixtures/pipeline-user-modified.yml +0 -245
- package/tests/fixtures/test-config.json +0 -58
- package/tests/github-live/README.md +0 -250
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
- package/tests/github-local/README.md +0 -240
- package/tests/github-local/run-all-tests.sh +0 -422
- package/tests/github-local/test-job-workflows.sh +0 -631
- package/tests/github-local/test-pipeline-workflow.sh +0 -440
- package/tests/integration/generators.test.ts +0 -578
- package/tests/integration/path-based-template.test.ts +0 -510
- package/tests/integration/simple-path-based.test.ts +0 -415
- package/tests/setup.ts +0 -56
- package/tests/unit/ast-path-operations-extended.test.ts +0 -302
- package/tests/unit/cli.test.ts +0 -541
- package/tests/unit/config-extended.test.ts +0 -412
- package/tests/unit/config.test.ts +0 -152
- package/tests/unit/github-setup.test.ts +0 -189
- package/tests/unit/idempotency-isolated.test.ts +0 -297
- package/tests/unit/job-order.test.ts +0 -157
- package/tests/unit/pipeline-path-based.test.ts +0 -511
- package/tests/unit/validate-pipeline.test.ts +0 -384
- package/tests/unit/versioning-extended.test.ts +0 -279
- package/tests/unit/versioning.test.ts +0 -241
- package/tsconfig.debug.json +0 -17
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -51
package/dist/utils/preflight.js
CHANGED
|
@@ -1,14 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pre-
|
|
3
|
-
*
|
|
2
|
+
* Pre-Flight Validation Checks
|
|
3
|
+
*
|
|
4
|
+
* This module implements comprehensive environment validation before workflow generation.
|
|
5
|
+
* Pre-flight checks prevent common failures by validating:
|
|
6
|
+
* - PipeCraft configuration exists and is valid
|
|
7
|
+
* - Git repository is properly initialized
|
|
8
|
+
* - Git remote is configured
|
|
9
|
+
* - Workflow directories are writable
|
|
10
|
+
* - Node.js version meets minimum requirements
|
|
11
|
+
*
|
|
12
|
+
* All checks return structured results with actionable error messages and suggestions.
|
|
13
|
+
* This provides a better user experience by catching issues early with clear guidance
|
|
14
|
+
* on how to resolve them.
|
|
15
|
+
*
|
|
16
|
+
* @module utils/preflight
|
|
4
17
|
*/
|
|
5
18
|
import { existsSync, mkdirSync, writeFileSync, unlinkSync } from 'fs';
|
|
6
19
|
import { execSync } from 'child_process';
|
|
7
20
|
import { join } from 'path';
|
|
8
21
|
import { cosmiconfigSync } from 'cosmiconfig';
|
|
9
22
|
/**
|
|
10
|
-
* Check if
|
|
11
|
-
*
|
|
23
|
+
* Check if PipeCraft configuration file exists.
|
|
24
|
+
*
|
|
25
|
+
* Uses cosmiconfig to search for configuration files in standard locations:
|
|
26
|
+
* - .pipecraftrc.json
|
|
27
|
+
* - .pipecraftrc (JSON or YAML)
|
|
28
|
+
* - pipecraft.config.js
|
|
29
|
+
* - package.json (pipecraft key)
|
|
30
|
+
*
|
|
31
|
+
* Searches current directory and all parent directories.
|
|
32
|
+
*
|
|
33
|
+
* @returns Check result with pass/fail status and file location if found
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const result = checkConfigExists()
|
|
38
|
+
* if (!result.passed) {
|
|
39
|
+
* console.error(result.message)
|
|
40
|
+
* console.log(result.suggestion) // "Run 'pipecraft init' to create..."
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
12
43
|
*/
|
|
13
44
|
export function checkConfigExists() {
|
|
14
45
|
const explorer = cosmiconfigSync('pipecraft');
|
|
@@ -26,7 +57,26 @@ export function checkConfigExists() {
|
|
|
26
57
|
};
|
|
27
58
|
}
|
|
28
59
|
/**
|
|
29
|
-
* Check if
|
|
60
|
+
* Check if configuration file is valid and contains required fields.
|
|
61
|
+
*
|
|
62
|
+
* Validates:
|
|
63
|
+
* - File can be parsed (valid JSON/YAML)
|
|
64
|
+
* - Required fields are present (ciProvider, branchFlow, domains)
|
|
65
|
+
* - At least one domain is configured
|
|
66
|
+
*
|
|
67
|
+
* @returns Check result with validation status and specific error if invalid
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const result = checkConfigValid()
|
|
72
|
+
* if (!result.passed) {
|
|
73
|
+
* if (result.message.includes('missing required fields')) {
|
|
74
|
+
* // Config exists but incomplete
|
|
75
|
+
* } else if (result.message.includes('Invalid JSON')) {
|
|
76
|
+
* // Syntax error in config file
|
|
77
|
+
* }
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
30
80
|
*/
|
|
31
81
|
export function checkConfigValid() {
|
|
32
82
|
const explorer = cosmiconfigSync('pipecraft');
|
|
@@ -79,12 +129,31 @@ export function checkConfigValid() {
|
|
|
79
129
|
}
|
|
80
130
|
}
|
|
81
131
|
/**
|
|
82
|
-
* Check if current directory is a git repository
|
|
132
|
+
* Check if current directory is inside a git repository.
|
|
133
|
+
*
|
|
134
|
+
* PipeCraft requires a git repository to:
|
|
135
|
+
* - Generate GitHub Actions workflows
|
|
136
|
+
* - Track version history
|
|
137
|
+
* - Enable version management features
|
|
138
|
+
*
|
|
139
|
+
* Uses `git rev-parse --is-inside-work-tree` to detect git repository.
|
|
140
|
+
* Suppresses stderr to avoid noise when git is not initialized.
|
|
141
|
+
*
|
|
142
|
+
* @returns Check result indicating if directory is in a git repository
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const result = checkInGitRepo()
|
|
147
|
+
* if (!result.passed) {
|
|
148
|
+
* console.log('Please initialize git first')
|
|
149
|
+
* execSync('git init')
|
|
150
|
+
* }
|
|
151
|
+
* ```
|
|
83
152
|
*/
|
|
84
153
|
export function checkInGitRepo() {
|
|
85
154
|
try {
|
|
86
155
|
execSync('git rev-parse --is-inside-work-tree', {
|
|
87
|
-
stdio: 'pipe',
|
|
156
|
+
stdio: ['pipe', 'pipe', 'ignore'], // Suppress stderr to avoid "not a git repository" errors
|
|
88
157
|
encoding: 'utf8'
|
|
89
158
|
});
|
|
90
159
|
return {
|
|
@@ -101,12 +170,35 @@ export function checkInGitRepo() {
|
|
|
101
170
|
}
|
|
102
171
|
}
|
|
103
172
|
/**
|
|
104
|
-
* Check if git remote is configured
|
|
173
|
+
* Check if git remote named 'origin' is configured.
|
|
174
|
+
*
|
|
175
|
+
* A git remote is required for:
|
|
176
|
+
* - Pushing generated workflows to GitHub
|
|
177
|
+
* - Repository information extraction
|
|
178
|
+
* - GitHub API integration
|
|
179
|
+
*
|
|
180
|
+
* Checks specifically for the 'origin' remote, which is the standard
|
|
181
|
+
* default remote name. Also detects if the remote is GitHub vs. GitLab
|
|
182
|
+
* and provides appropriate messaging.
|
|
183
|
+
*
|
|
184
|
+
* @returns Check result with remote URL if configured
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const result = checkHasGitRemote()
|
|
189
|
+
* if (!result.passed) {
|
|
190
|
+
* console.log('No git remote found')
|
|
191
|
+
* execSync('git remote add origin https://github.com/user/repo.git')
|
|
192
|
+
* } else if (result.suggestion) {
|
|
193
|
+
* // GitLab detected - show warning about experimental support
|
|
194
|
+
* console.warn(result.suggestion)
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
105
197
|
*/
|
|
106
198
|
export function checkHasGitRemote() {
|
|
107
199
|
try {
|
|
108
200
|
const remote = execSync('git remote get-url origin', {
|
|
109
|
-
stdio: 'pipe',
|
|
201
|
+
stdio: ['pipe', 'pipe', 'ignore'], // Suppress stderr
|
|
110
202
|
encoding: 'utf8'
|
|
111
203
|
}).trim();
|
|
112
204
|
if (!remote) {
|
|
@@ -135,7 +227,29 @@ export function checkHasGitRemote() {
|
|
|
135
227
|
}
|
|
136
228
|
}
|
|
137
229
|
/**
|
|
138
|
-
* Check if .github directory is writable
|
|
230
|
+
* Check if .github/workflows directory exists and is writable.
|
|
231
|
+
*
|
|
232
|
+
* Workflows are written to .github/workflows/, so this directory must:
|
|
233
|
+
* - Exist or be creatable
|
|
234
|
+
* - Be writable by the current user
|
|
235
|
+
*
|
|
236
|
+
* This check attempts to:
|
|
237
|
+
* 1. Create .github/workflows/ if it doesn't exist
|
|
238
|
+
* 2. Write a test file to verify write permissions
|
|
239
|
+
* 3. Clean up the test file
|
|
240
|
+
*
|
|
241
|
+
* @returns Check result indicating if directory is writable
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const result = checkCanWriteGithubDir()
|
|
246
|
+
* if (!result.passed) {
|
|
247
|
+
* if (result.message.includes('permission')) {
|
|
248
|
+
* // Fix permissions
|
|
249
|
+
* execSync('chmod +w .github/workflows/')
|
|
250
|
+
* }
|
|
251
|
+
* }
|
|
252
|
+
* ```
|
|
139
253
|
*/
|
|
140
254
|
export function checkCanWriteGithubDir() {
|
|
141
255
|
const githubDir = '.github';
|
|
@@ -178,7 +292,28 @@ export function checkCanWriteGithubDir() {
|
|
|
178
292
|
}
|
|
179
293
|
}
|
|
180
294
|
/**
|
|
181
|
-
* Check Node.js version
|
|
295
|
+
* Check if Node.js version meets minimum requirement.
|
|
296
|
+
*
|
|
297
|
+
* PipeCraft requires Node.js 18.0.0 or higher because it uses:
|
|
298
|
+
* - Modern ES modules
|
|
299
|
+
* - Latest TypeScript features
|
|
300
|
+
* - Current GitHub Actions syntax
|
|
301
|
+
*
|
|
302
|
+
* Only checks major version for simplicity. Minor/patch versions
|
|
303
|
+
* within the same major release are considered compatible.
|
|
304
|
+
*
|
|
305
|
+
* @param minVersion - Minimum required version (default: '18.0.0')
|
|
306
|
+
* @returns Check result with current and minimum versions
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* const result = checkNodeVersion('18.0.0')
|
|
311
|
+
* if (!result.passed) {
|
|
312
|
+
* console.error('Please upgrade Node.js')
|
|
313
|
+
* console.log('Current:', process.version)
|
|
314
|
+
* console.log('Required: >= 18.0.0')
|
|
315
|
+
* }
|
|
316
|
+
* ```
|
|
182
317
|
*/
|
|
183
318
|
export function checkNodeVersion(minVersion = '18.0.0') {
|
|
184
319
|
const currentVersion = process.version.slice(1); // Remove 'v' prefix
|
|
@@ -197,8 +332,38 @@ export function checkNodeVersion(minVersion = '18.0.0') {
|
|
|
197
332
|
};
|
|
198
333
|
}
|
|
199
334
|
/**
|
|
200
|
-
* Run all pre-flight checks for
|
|
201
|
-
*
|
|
335
|
+
* Run all pre-flight checks for workflow generation.
|
|
336
|
+
*
|
|
337
|
+
* Executes comprehensive environment validation to ensure all prerequisites
|
|
338
|
+
* are met before attempting to generate workflows. This prevents partial
|
|
339
|
+
* failures and provides clear error messages upfront.
|
|
340
|
+
*
|
|
341
|
+
* Checks performed:
|
|
342
|
+
* - Configuration file exists
|
|
343
|
+
* - Configuration is valid
|
|
344
|
+
* - Inside git repository
|
|
345
|
+
* - Git remote configured
|
|
346
|
+
* - Workflow directory writable
|
|
347
|
+
*
|
|
348
|
+
* Note: Node version check is optional and not included by default since
|
|
349
|
+
* if Node is too old, the code wouldn't run at all.
|
|
350
|
+
*
|
|
351
|
+
* @returns Collection of all check results
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* const checks = runPreflightChecks()
|
|
356
|
+
* const { allPassed, output } = formatPreflightResults(checks)
|
|
357
|
+
*
|
|
358
|
+
* if (!allPassed) {
|
|
359
|
+
* console.error('Pre-flight checks failed:')
|
|
360
|
+
* console.log(output)
|
|
361
|
+
* process.exit(1)
|
|
362
|
+
* }
|
|
363
|
+
*
|
|
364
|
+
* // Proceed with workflow generation
|
|
365
|
+
* await generateWorkflows()
|
|
366
|
+
* ```
|
|
202
367
|
*/
|
|
203
368
|
export function runPreflightChecks() {
|
|
204
369
|
return {
|
|
@@ -210,7 +375,33 @@ export function runPreflightChecks() {
|
|
|
210
375
|
};
|
|
211
376
|
}
|
|
212
377
|
/**
|
|
213
|
-
* Format
|
|
378
|
+
* Format pre-flight check results for human-readable display.
|
|
379
|
+
*
|
|
380
|
+
* Converts structured check results into formatted output with:
|
|
381
|
+
* - ✅/❌ icons for visual scanning
|
|
382
|
+
* - Error messages and suggestions
|
|
383
|
+
* - Next steps if all checks passed
|
|
384
|
+
* - Helpful guidance for getting started
|
|
385
|
+
*
|
|
386
|
+
* The output is designed to be printed directly to the console.
|
|
387
|
+
*
|
|
388
|
+
* @param checks - Collection of check results from runPreflightChecks()
|
|
389
|
+
* @returns Formatted output object with overall status and display string
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const checks = runPreflightChecks()
|
|
394
|
+
* const { allPassed, output, nextSteps } = formatPreflightResults(checks)
|
|
395
|
+
*
|
|
396
|
+
* console.log(output)
|
|
397
|
+
*
|
|
398
|
+
* if (allPassed && nextSteps) {
|
|
399
|
+
* console.log('\n' + nextSteps.join('\n'))
|
|
400
|
+
* } else {
|
|
401
|
+
* console.error('\n⚠ Fix the above issues and try again')
|
|
402
|
+
* process.exit(1)
|
|
403
|
+
* }
|
|
404
|
+
* ```
|
|
214
405
|
*/
|
|
215
406
|
export function formatPreflightResults(checks) {
|
|
216
407
|
const results = [];
|
|
@@ -244,12 +435,21 @@ export function formatPreflightResults(checks) {
|
|
|
244
435
|
};
|
|
245
436
|
}
|
|
246
437
|
/**
|
|
247
|
-
* Get current git branch name
|
|
438
|
+
* Get current git branch name.
|
|
439
|
+
*
|
|
440
|
+
* Uses `git branch --show-current` to get the active branch.
|
|
441
|
+
* Falls back to 'main' if:
|
|
442
|
+
* - Not in a git repository
|
|
443
|
+
* - In detached HEAD state
|
|
444
|
+
* - Git command fails
|
|
445
|
+
*
|
|
446
|
+
* @returns Current branch name or 'main' as fallback
|
|
447
|
+
* @private
|
|
248
448
|
*/
|
|
249
449
|
function getCurrentBranch() {
|
|
250
450
|
try {
|
|
251
451
|
const branch = execSync('git branch --show-current', {
|
|
252
|
-
stdio: 'pipe',
|
|
452
|
+
stdio: ['pipe', 'pipe', 'ignore'], // Suppress stderr
|
|
253
453
|
encoding: 'utf8'
|
|
254
454
|
}).trim();
|
|
255
455
|
return branch || 'main';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/utils/preflight.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/utils/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA0C7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAA;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAA;IAEhC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,kCAAkC;YAC3C,UAAU,EAAE,qDAAqD;SAClE,CAAA;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,wBAAwB,MAAM,CAAC,QAAQ,EAAE;KACnD,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAA;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAA;IAEhC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,6BAA6B;YACtC,UAAU,EAA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G,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;QACtC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;QAEzC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,SAAS,GAAG,KAAK,CAAA;YACjB,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;IAED,0CAA0C;IAC1C,MAAM,SAAS,GAAyB,SAAS,CAAC,CAAC,CAAC;QAClD,kDAAkD;QAClD,EAAE;QACF,aAAa;QACb,yDAAyD;QACzD,4DAA4D;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;;;;;;;;;;;GAWG;AACH,SAAS,gBAAgB;IACvB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,2BAA2B,EAAE;YACnD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB;YACrD,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"}
|
|
@@ -1,37 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version Management and Semantic Versioning Utilities
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive version management using release-it and
|
|
5
|
+
* conventional commits. It handles:
|
|
6
|
+
* - Automatic version calculation based on commit history
|
|
7
|
+
* - Generation of release-it, commitlint, and husky configurations
|
|
8
|
+
* - Git tag creation and management
|
|
9
|
+
* - Conventional commit validation
|
|
10
|
+
* - Changelog generation
|
|
11
|
+
*
|
|
12
|
+
* The VersionManager integrates with the trunk-based workflow to automatically
|
|
13
|
+
* bump versions when code is promoted through the pipeline.
|
|
14
|
+
*
|
|
15
|
+
* @module utils/versioning
|
|
16
|
+
*/
|
|
1
17
|
import { PipecraftConfig } from '../types/index.js';
|
|
18
|
+
/**
|
|
19
|
+
* Manager for semantic versioning and release automation.
|
|
20
|
+
*
|
|
21
|
+
* This class handles all version-related operations including configuration
|
|
22
|
+
* generation, version calculation, and commit validation. It integrates with
|
|
23
|
+
* release-it for automated versioning and conventional-changelog for
|
|
24
|
+
* changelog generation.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const versionManager = new VersionManager(config)
|
|
29
|
+
*
|
|
30
|
+
* // Setup version management (creates config files)
|
|
31
|
+
* versionManager.setupVersionManagement()
|
|
32
|
+
*
|
|
33
|
+
* // Get current version from git tags
|
|
34
|
+
* const currentVersion = versionManager.getCurrentVersion()
|
|
35
|
+
*
|
|
36
|
+
* // Calculate next version based on commits
|
|
37
|
+
* const { version, type } = versionManager.calculateNextVersion()
|
|
38
|
+
* console.log(`Next version: ${version} (${type} bump)`)
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
2
41
|
export declare class VersionManager {
|
|
3
42
|
private config;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new VersionManager instance.
|
|
45
|
+
*
|
|
46
|
+
* @param config - PipeCraft configuration object
|
|
47
|
+
*/
|
|
4
48
|
constructor(config: PipecraftConfig);
|
|
5
49
|
/**
|
|
6
|
-
* Generate release-it configuration
|
|
50
|
+
* Generate release-it configuration file content.
|
|
51
|
+
*
|
|
52
|
+
* Creates a CommonJS module exporting release-it configuration that:
|
|
53
|
+
* - Disables npm publishing (for monorepos/private packages)
|
|
54
|
+
* - Configures git tagging with conventional versioning
|
|
55
|
+
* - Sets up conventional-changelog plugin for automatic version bumping
|
|
56
|
+
* - Merges user-defined bump rules with sensible defaults
|
|
57
|
+
*
|
|
58
|
+
* The generated config uses a custom whatBump function that analyzes
|
|
59
|
+
* conventional commits to determine the appropriate version bump level
|
|
60
|
+
* (major, minor, or patch).
|
|
61
|
+
*
|
|
62
|
+
* @returns JavaScript module string ready to write to .release-it.cjs
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const config = versionManager.generateReleaseItConfig()
|
|
67
|
+
* writeFileSync('.release-it.cjs', config)
|
|
68
|
+
* ```
|
|
7
69
|
*/
|
|
8
70
|
generateReleaseItConfig(): string;
|
|
9
71
|
/**
|
|
10
|
-
* Generate commitlint configuration
|
|
72
|
+
* Generate commitlint configuration file content.
|
|
73
|
+
*
|
|
74
|
+
* Creates a CommonJS module that configures commitlint to enforce
|
|
75
|
+
* conventional commit message format. This ensures all commits follow
|
|
76
|
+
* a consistent structure that can be parsed for automatic versioning.
|
|
77
|
+
*
|
|
78
|
+
* Enforced rules include:
|
|
79
|
+
* - Valid commit types (feat, fix, docs, etc.)
|
|
80
|
+
* - Lowercase types
|
|
81
|
+
* - Non-empty subjects
|
|
82
|
+
* - Lowercase subject (except proper nouns)
|
|
83
|
+
* - No trailing period in subject
|
|
84
|
+
*
|
|
85
|
+
* @returns JavaScript module string ready to write to commitlint.config.js
|
|
11
86
|
*/
|
|
12
87
|
generateCommitlintConfig(): string;
|
|
13
88
|
/**
|
|
14
|
-
* Generate husky
|
|
89
|
+
* Generate husky commit-msg hook script.
|
|
90
|
+
*
|
|
91
|
+
* Creates a shell script that runs commitlint on every commit message.
|
|
92
|
+
* This hook automatically validates commit messages before they're accepted,
|
|
93
|
+
* preventing non-conventional commits from entering the repository.
|
|
94
|
+
*
|
|
95
|
+
* @returns Shell script string ready to write to .husky/commit-msg
|
|
15
96
|
*/
|
|
16
97
|
generateHuskyConfig(): string;
|
|
17
98
|
/**
|
|
18
|
-
* Setup version management
|
|
99
|
+
* Setup version management infrastructure.
|
|
100
|
+
*
|
|
101
|
+
* Creates all necessary configuration files and hooks for automated
|
|
102
|
+
* version management:
|
|
103
|
+
* - .release-it.cjs (release-it configuration)
|
|
104
|
+
* - commitlint.config.js (commit message linting)
|
|
105
|
+
* - .husky/commit-msg (git hook for commit validation)
|
|
106
|
+
* - package.json scripts (release, changelog commands)
|
|
107
|
+
*
|
|
108
|
+
* Only runs if versioning is enabled in configuration.
|
|
109
|
+
* Installs husky if not already present.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* versionManager.setupVersionManagement()
|
|
114
|
+
* // Files created:
|
|
115
|
+
* // - .release-it.cjs
|
|
116
|
+
* // - commitlint.config.js
|
|
117
|
+
* // - .husky/commit-msg
|
|
118
|
+
* // - Updated package.json
|
|
119
|
+
* ```
|
|
19
120
|
*/
|
|
20
121
|
setupVersionManagement(): void;
|
|
21
122
|
/**
|
|
22
|
-
* Update package.json with version management scripts
|
|
123
|
+
* Update package.json with version management scripts.
|
|
124
|
+
*
|
|
125
|
+
* Adds npm scripts for common version management tasks:
|
|
126
|
+
* - release: Run release-it to create a new version
|
|
127
|
+
* - release:dry: Preview what release-it would do
|
|
128
|
+
* - version:check: Check what version would be bumped to
|
|
129
|
+
* - changelog: Generate CHANGELOG.md from commits
|
|
130
|
+
* - commit: Stage and commit with interactive prompting
|
|
131
|
+
* - prepare: Install husky hooks (runs automatically on npm install)
|
|
132
|
+
*
|
|
133
|
+
* @private
|
|
23
134
|
*/
|
|
24
135
|
private updatePackageJsonScripts;
|
|
25
136
|
/**
|
|
26
|
-
*
|
|
137
|
+
* Validate that recent commits follow conventional commit format.
|
|
138
|
+
*
|
|
139
|
+
* Checks the last 10 commits to determine if the repository is following
|
|
140
|
+
* conventional commit conventions. This can be used as a pre-flight check
|
|
141
|
+
* before enabling versioning features.
|
|
142
|
+
*
|
|
143
|
+
* Expected format: `type(scope?): subject`
|
|
144
|
+
* Valid types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
|
145
|
+
*
|
|
146
|
+
* @returns true if all recent commits follow conventional format
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* if (!versionManager.validateConventionalCommits()) {
|
|
151
|
+
* console.warn('⚠ Some commits do not follow conventional format')
|
|
152
|
+
* console.log('Enable with: git config commit.template .gitmessage')
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
27
155
|
*/
|
|
28
156
|
validateConventionalCommits(): boolean;
|
|
29
157
|
/**
|
|
30
|
-
* Get current version from git tags
|
|
158
|
+
* Get the current version from git tags.
|
|
159
|
+
*
|
|
160
|
+
* Finds the most recent git tag matching semantic versioning format (v*.*.*)
|
|
161
|
+
* and returns it as a version string. Strips the leading 'v' if present.
|
|
162
|
+
*
|
|
163
|
+
* @returns Current version string (e.g., "1.2.3") or "0.0.0" if no tags exist
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const currentVersion = versionManager.getCurrentVersion()
|
|
168
|
+
* console.log(`Current version: v${currentVersion}`)
|
|
169
|
+
* ```
|
|
31
170
|
*/
|
|
32
171
|
getCurrentVersion(): string;
|
|
33
172
|
/**
|
|
34
|
-
* Calculate next version based on conventional commits
|
|
173
|
+
* Calculate the next version based on conventional commits.
|
|
174
|
+
*
|
|
175
|
+
* Runs release-it in dry-run mode to determine what version would be
|
|
176
|
+
* created based on commits since the last tag. Analyzes conventional
|
|
177
|
+
* commit messages to determine the appropriate bump level.
|
|
178
|
+
*
|
|
179
|
+
* @returns Object containing the next version string and bump type
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const { version, type } = versionManager.calculateNextVersion()
|
|
184
|
+
* console.log(`Next ${type} version: ${version}`)
|
|
185
|
+
* // Output: "Next minor version: 1.3.0"
|
|
186
|
+
* ```
|
|
35
187
|
*/
|
|
36
188
|
calculateNextVersion(): {
|
|
37
189
|
version: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../../src/utils/versioning.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../../src/utils/versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAiB;IAE/B;;;;OAIG;gBACS,MAAM,EAAE,eAAe;IAInC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,uBAAuB,IAAI,MAAM;IAuEjC;;;;;;;;;;;;;;;OAeG;IACH,wBAAwB,IAAI,MAAM;IA8BlC;;;;;;;;OAQG;IACH,mBAAmB,IAAI,MAAM;IAO7B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,sBAAsB,IAAI,IAAI;IAkC9B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,wBAAwB;IAsBhC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,2BAA2B,IAAI,OAAO;IAkBtC;;;;;;;;;;;;;OAaG;IACH,iBAAiB,IAAI,MAAM;IAa3B;;;;;;;;;;;;;;;OAeG;IACH,oBAAoB,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAwB1D"}
|