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.
- package/.claude/settings.local.json +35 -0
- package/.github/actions/calculate-version/action.yml +106 -0
- package/.github/actions/create-pr/action.yml +122 -0
- package/.github/actions/create-release/action.yml +74 -0
- package/.github/actions/create-tag/action.yml +94 -0
- package/.github/actions/detect-changes/action.yml +62 -0
- package/.github/actions/manage-branch/action.yml +113 -0
- package/.github/actions/promote-branch/action.yml +352 -0
- package/.github/example/workflows/job.analyze.code.yml +26 -0
- package/.github/example/workflows/job.analyze.docker.yml +32 -0
- package/.github/example/workflows/job.app.api.deploy.yml +127 -0
- package/.github/example/workflows/job.app.api.test.yml +102 -0
- package/.github/example/workflows/job.app.docs.deploy.yml +40 -0
- package/.github/example/workflows/job.app.docs.test.yml +50 -0
- package/.github/example/workflows/job.app.web.deploy.yml +96 -0
- package/.github/example/workflows/job.app.web.test.yml +49 -0
- package/.github/example/workflows/job.changes.yml +82 -0
- package/.github/example/workflows/job.create-pr.yml +96 -0
- package/.github/example/workflows/job.env-check.yml +43 -0
- package/.github/example/workflows/job.fast-forward.yml +103 -0
- package/.github/example/workflows/job.lint.yml +64 -0
- package/.github/example/workflows/job.pr-name.yml +70 -0
- package/.github/example/workflows/job.pr-squash-name.yml +27 -0
- package/.github/example/workflows/job.tag.yml +38 -0
- package/.github/example/workflows/job.version.yml +99 -0
- package/.github/example/workflows/lib.plugin-base.publish.yml +59 -0
- package/.github/example/workflows/pipe.yml +178 -0
- package/.github/example/workflows/scripts/fastforward.sh +51 -0
- package/.github/example/workflows/scripts/pipe-cleaner.sh +70 -0
- package/.github/scripts/fastforward.sh +51 -0
- package/.github/scripts/pipe-cleaner.sh +70 -0
- package/.github/workflows/pipeline.yml +220 -0
- package/.github/workflows/pr-title-check.yml +70 -0
- package/.github/workflows/publish.yml +39 -0
- package/.pipecraftrc.json +78 -0
- package/.release-it.cjs +71 -0
- package/PIPELINE_TESTING_PLAN.md +499 -0
- package/README.md +1101 -0
- package/TRUNK_FLOW_PLAN.md +401 -0
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +364 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/generators/init.tpl.d.ts +3 -0
- package/dist/generators/init.tpl.d.ts.map +1 -0
- package/dist/generators/init.tpl.js +117 -0
- package/dist/generators/init.tpl.js.map +1 -0
- package/dist/generators/workflows.tpl.d.ts +7 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -0
- package/dist/generators/workflows.tpl.js +73 -0
- package/dist/generators/workflows.tpl.js.map +1 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/calculate-version.yml.tpl.js +122 -0
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-pr.yml.tpl.js +145 -0
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.js +111 -0
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/detect-changes.yml.tpl.js +79 -0
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/manage-branch.yml.tpl.js +130 -0
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/promote-branch.yml.tpl.js +362 -0
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +16 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +652 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -0
- package/dist/types/index.d.ts +63 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/ast-path-operations.d.ts +287 -0
- package/dist/utils/ast-path-operations.d.ts.map +1 -0
- package/dist/utils/ast-path-operations.js +419 -0
- package/dist/utils/ast-path-operations.js.map +1 -0
- package/dist/utils/config.d.ts +3 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +49 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/github-setup.d.ts +74 -0
- package/dist/utils/github-setup.d.ts.map +1 -0
- package/dist/utils/github-setup.js +418 -0
- package/dist/utils/github-setup.js.map +1 -0
- package/dist/utils/idempotency.d.ts +47 -0
- package/dist/utils/idempotency.d.ts.map +1 -0
- package/dist/utils/idempotency.js +176 -0
- package/dist/utils/idempotency.js.map +1 -0
- package/dist/utils/preflight.d.ts +55 -0
- package/dist/utils/preflight.d.ts.map +1 -0
- package/dist/utils/preflight.js +261 -0
- package/dist/utils/preflight.js.map +1 -0
- package/dist/utils/versioning.d.ts +41 -0
- package/dist/utils/versioning.d.ts.map +1 -0
- package/dist/utils/versioning.js +219 -0
- package/dist/utils/versioning.js.map +1 -0
- package/docs/USER_JOURNEY_ERRORS.md +352 -0
- package/eslint.config.js +77 -0
- package/examples/basic-config.json +41 -0
- package/examples/monorepo-config.json +49 -0
- package/examples/usage.md +289 -0
- package/package.json +58 -0
- package/scripts/debug-workflows.sh +339 -0
- package/scripts/parse-pipeline.js +29 -0
- package/scripts/test-job-order.cjs +140 -0
- package/scripts/validate-pipeline.cjs +379 -0
- package/scripts/verify-job-order.sh +30 -0
- package/src/cli/index.ts +414 -0
- package/src/generators/init.tpl.ts +126 -0
- package/src/generators/workflows.tpl.ts +80 -0
- package/src/templates/actions/calculate-version.yml.tpl.ts +124 -0
- package/src/templates/actions/create-pr.yml.tpl.ts +147 -0
- package/src/templates/actions/create-tag.yml.tpl.ts +112 -0
- package/src/templates/actions/detect-changes.yml.tpl.ts +87 -0
- package/src/templates/actions/manage-branch.yml.tpl.ts +132 -0
- package/src/templates/actions/promote-branch.yml.tpl.ts +364 -0
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +706 -0
- package/src/types/index.ts +64 -0
- package/src/utils/README-ast-path-operations.md +390 -0
- package/src/utils/ast-path-operations.ts +581 -0
- package/src/utils/config.ts +64 -0
- package/src/utils/github-setup.ts +558 -0
- package/src/utils/idempotency.ts +215 -0
- package/src/utils/preflight.ts +306 -0
- package/src/utils/versioning.ts +244 -0
- package/tests/README.md +229 -0
- package/tests/TEST_STRUCTURE.md +256 -0
- package/tests/act/run-act-tests.sh +345 -0
- package/tests/debugging/debug-utils.ts +538 -0
- package/tests/debugging/debug-workflow.test.ts +339 -0
- package/tests/debugging/debug-workflows.sh +339 -0
- package/tests/debugging/iterative-debug.ts +652 -0
- package/tests/debugging/run-debug-tests.sh +431 -0
- package/tests/fixtures/basic-config.json +51 -0
- package/tests/fixtures/invalid-config.json +9 -0
- package/tests/fixtures/pipeline-generated.yml +235 -0
- package/tests/fixtures/pipeline-preserve-comments.yml +245 -0
- package/tests/fixtures/pipeline-user-modified.yml +245 -0
- package/tests/fixtures/test-config.json +58 -0
- package/tests/github-live/README.md +250 -0
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +296 -0
- package/tests/github-local/README.md +240 -0
- package/tests/github-local/run-all-tests.sh +422 -0
- package/tests/github-local/test-job-workflows.sh +631 -0
- package/tests/github-local/test-pipeline-workflow.sh +440 -0
- package/tests/integration/generators.test.ts +578 -0
- package/tests/integration/path-based-template.test.ts +510 -0
- package/tests/integration/simple-path-based.test.ts +415 -0
- package/tests/setup.ts +56 -0
- package/tests/unit/ast-path-operations-extended.test.ts +302 -0
- package/tests/unit/cli.test.ts +541 -0
- package/tests/unit/config-extended.test.ts +412 -0
- package/tests/unit/config.test.ts +152 -0
- package/tests/unit/github-setup.test.ts +189 -0
- package/tests/unit/idempotency-isolated.test.ts +297 -0
- package/tests/unit/job-order.test.ts +157 -0
- package/tests/unit/pipeline-path-based.test.ts +511 -0
- package/tests/unit/validate-pipeline.test.ts +384 -0
- package/tests/unit/versioning-extended.test.ts +279 -0
- package/tests/unit/versioning.test.ts +241 -0
- package/tsconfig.debug.json +17 -0
- package/tsconfig.json +28 -0
- package/vitest.config.ts +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,1101 @@
|
|
|
1
|
+
<img src="./assets/logo_banner.png" alt="PipeCraft Logo" width="auto">
|
|
2
|
+
|
|
3
|
+
# PipeCraft
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/pipecraft)
|
|
6
|
+
[](https://github.com/jamesvillarrubia/pipecraft/blob/main/LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/pipecraft)
|
|
8
|
+
[](https://nodejs.org/en/)
|
|
9
|
+
[](https://codecov.io/gh/jamesvillarrubia/pipecraft)
|
|
10
|
+
|
|
11
|
+
**Pipeline Status:**
|
|
12
|
+
[](https://github.com/jamesvillarrubia/pipecraft/actions/workflows/pipeline.yml?query=branch%3Adevelop)
|
|
13
|
+
[](https://github.com/jamesvillarrubia/pipecraft/actions/workflows/pipeline.yml?query=branch%3Astaging)
|
|
14
|
+
[](https://github.com/jamesvillarrubia/pipecraft/actions/workflows/pipeline.yml?query=branch%3Amain)
|
|
15
|
+
|
|
16
|
+
PipeCraft is a powerful CLI tool for automating trunk-based development workflows with GitHub Actions. It generates intelligent CI/CD pipelines that adapt to your codebase structure, support multiple domains (monorepos), handle semantic versioning, and manage branch flows with fast-forward merging strategies.
|
|
17
|
+
|
|
18
|
+
## Table of Contents
|
|
19
|
+
- [Features](#features)
|
|
20
|
+
- [Prerequisites](#prerequisites)
|
|
21
|
+
- [Quick Start](#quick-start)
|
|
22
|
+
- [Installation](#installation)
|
|
23
|
+
- [Usage](#usage)
|
|
24
|
+
- [CLI Examples](#cli-examples)
|
|
25
|
+
- [Configuration](#configuration)
|
|
26
|
+
- [Commands](#commands)
|
|
27
|
+
- [Pre-Flight Checks](#pre-flight-checks)
|
|
28
|
+
- [GitHub Actions Setup](#github-actions-setup)
|
|
29
|
+
- [Configuration Options](#configuration-options)
|
|
30
|
+
- [Domain-Based Workflows](#domain-based-workflows)
|
|
31
|
+
- [Version Management](#version-management)
|
|
32
|
+
- [Examples](#examples)
|
|
33
|
+
- [Roadmap & Future Features](#roadmap--future-features)
|
|
34
|
+
- [Troubleshooting](#troubleshooting)
|
|
35
|
+
- [Contributing](#contributing)
|
|
36
|
+
- [License](#license)
|
|
37
|
+
- [Acknowledgments](#acknowledgments)
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Automatic CI/CD Pipeline Generation** - Generate GitHub Actions workflows tailored to your branch flow
|
|
42
|
+
- **Pre-Flight Checks** - Validates prerequisites before generating workflows with helpful error messages
|
|
43
|
+
- **Domain-Based Change Detection** - Smart path-based detection for monorepo architectures
|
|
44
|
+
- **Semantic Versioning** - Automatic version bumping based on conventional commits
|
|
45
|
+
- **Branch Flow Management** - Support for custom branch flows (develop → staging → main)
|
|
46
|
+
- **Fast-Forward Merging** - Automatic branch management with configurable merge strategies
|
|
47
|
+
- **Idempotent Regeneration** - Only regenerate when configuration or templates change
|
|
48
|
+
- **GitLab Support** - Works with both GitHub Actions and GitLab CI (configurable)
|
|
49
|
+
- **Customizable Actions** - Define actions per branch merge (tests, deploys, version bumps)
|
|
50
|
+
- **GitHub Setup Automation** - Automated token and repository setup validation
|
|
51
|
+
|
|
52
|
+
## Prerequisites
|
|
53
|
+
|
|
54
|
+
- Git
|
|
55
|
+
- A GitHub or GitLab account
|
|
56
|
+
- Node.js 18+ (for npm installation)
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
1. Initialize PipeCraft in your project:
|
|
61
|
+
```bash
|
|
62
|
+
npx pipecraft init --interactive
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. Generate your CI/CD workflows:
|
|
66
|
+
```bash
|
|
67
|
+
npx pipecraft generate
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
3. Commit the generated files:
|
|
71
|
+
```bash
|
|
72
|
+
git add .github/workflows .pipecraftrc.json
|
|
73
|
+
git commit -m "chore: add PipeCraft workflows"
|
|
74
|
+
git push
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
That's it! Your trunk-based development workflow is now automated.
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
### Option 1: Using npx (recommended for trying it out)
|
|
82
|
+
|
|
83
|
+
No installation required! Just run commands with `npx`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npx pipecraft init
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Option 2: Global installation via npm
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm install -g pipecraft
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Option 3: Local project installation
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install --save-dev pipecraft
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Then add to your `package.json` scripts:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"scripts": {
|
|
106
|
+
"workflow:init": "pipecraft init",
|
|
107
|
+
"workflow:generate": "pipecraft generate",
|
|
108
|
+
"workflow:validate": "pipecraft validate"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Usage
|
|
114
|
+
|
|
115
|
+
### CLI Examples
|
|
116
|
+
|
|
117
|
+
PipeCraft provides several commands to manage your trunk-based development workflows:
|
|
118
|
+
|
|
119
|
+
#### 1. Initialize Configuration
|
|
120
|
+
|
|
121
|
+
Start with an interactive setup wizard:
|
|
122
|
+
```bash
|
|
123
|
+
pipecraft init --interactive
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Or create a basic configuration:
|
|
127
|
+
```bash
|
|
128
|
+
pipecraft init --ci-provider github --initial-branch develop --final-branch main
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Include version management setup:
|
|
132
|
+
```bash
|
|
133
|
+
pipecraft init --with-versioning
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### 2. Generate Workflows
|
|
137
|
+
|
|
138
|
+
Generate CI/CD workflows based on your configuration:
|
|
139
|
+
```bash
|
|
140
|
+
pipecraft generate
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The generate command automatically runs pre-flight checks to validate:
|
|
144
|
+
- Configuration file exists and is valid
|
|
145
|
+
- Required fields are present (ciProvider, branchFlow, domains)
|
|
146
|
+
- Current directory is a git repository
|
|
147
|
+
- Git remote is configured
|
|
148
|
+
- .github/workflows directory is writable
|
|
149
|
+
|
|
150
|
+
If any check fails, you'll see helpful error messages with suggestions. Example output:
|
|
151
|
+
```
|
|
152
|
+
🔍 Running pre-flight checks...
|
|
153
|
+
|
|
154
|
+
✅ Configuration found: /path/to/.pipecraftrc.json
|
|
155
|
+
✅ Configuration is valid
|
|
156
|
+
❌ Not in a git repository
|
|
157
|
+
💡 Initialize git: 'git init' or clone an existing repository
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Skip pre-flight checks (not recommended):
|
|
161
|
+
```bash
|
|
162
|
+
pipecraft generate --skip-checks
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Force regeneration (bypass cache):
|
|
166
|
+
```bash
|
|
167
|
+
pipecraft generate --force
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Preview what would be generated (dry run):
|
|
171
|
+
```bash
|
|
172
|
+
pipecraft generate --dry-run
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Use custom config and output paths:
|
|
176
|
+
```bash
|
|
177
|
+
pipecraft generate --config custom-config.json --output-pipeline .github/workflows/custom.yml
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### 3. Validate Configuration
|
|
181
|
+
|
|
182
|
+
Check if your configuration is valid:
|
|
183
|
+
```bash
|
|
184
|
+
pipecraft validate
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Validate a custom config file:
|
|
188
|
+
```bash
|
|
189
|
+
pipecraft validate --config custom-config.json
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### 4. Verify Setup
|
|
193
|
+
|
|
194
|
+
Verify that PipeCraft is properly configured:
|
|
195
|
+
```bash
|
|
196
|
+
pipecraft verify
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
This checks:
|
|
200
|
+
- Configuration file exists and is valid
|
|
201
|
+
- GitHub Actions workflows exist (for GitHub projects)
|
|
202
|
+
- Repository structure is correct
|
|
203
|
+
|
|
204
|
+
#### 5. Version Management
|
|
205
|
+
|
|
206
|
+
Check current and next version:
|
|
207
|
+
```bash
|
|
208
|
+
pipecraft version --check
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Bump version based on conventional commits:
|
|
212
|
+
```bash
|
|
213
|
+
pipecraft version --bump
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Create a release:
|
|
217
|
+
```bash
|
|
218
|
+
pipecraft version --release
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### 6. Branch Setup
|
|
222
|
+
|
|
223
|
+
Create all branches defined in your branch flow:
|
|
224
|
+
```bash
|
|
225
|
+
pipecraft setup
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This automatically creates and pushes all branches to your remote repository.
|
|
229
|
+
|
|
230
|
+
### Configuration
|
|
231
|
+
|
|
232
|
+
PipeCraft uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for flexible configuration discovery. It will look for configuration in the following order:
|
|
233
|
+
|
|
234
|
+
1. Command-line options
|
|
235
|
+
2. `.pipecraftrc.json` file
|
|
236
|
+
3. `.pipecraftrc` file
|
|
237
|
+
4. `pipecraft` key in `package.json`
|
|
238
|
+
5. Default values
|
|
239
|
+
|
|
240
|
+
Example `.pipecraftrc.json`:
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"ciProvider": "github",
|
|
245
|
+
"mergeStrategy": "fast-forward",
|
|
246
|
+
"requireConventionalCommits": true,
|
|
247
|
+
"initialBranch": "develop",
|
|
248
|
+
"finalBranch": "main",
|
|
249
|
+
"branchFlow": ["develop", "staging", "main"],
|
|
250
|
+
"semver": {
|
|
251
|
+
"bumpRules": {
|
|
252
|
+
"feat": "minor",
|
|
253
|
+
"fix": "patch",
|
|
254
|
+
"breaking": "major"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"actions": {
|
|
258
|
+
"onDevelopMerge": ["runTests", "fastForwardToStaging"],
|
|
259
|
+
"onStagingMerge": ["runTests", "calculateVersion", "createOrFastForwardToMain"]
|
|
260
|
+
},
|
|
261
|
+
"domains": {
|
|
262
|
+
"api": {
|
|
263
|
+
"paths": ["apps/api/**"],
|
|
264
|
+
"description": "API application changes"
|
|
265
|
+
},
|
|
266
|
+
"web": {
|
|
267
|
+
"paths": ["apps/web/**"],
|
|
268
|
+
"description": "Web application changes"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Commands
|
|
275
|
+
|
|
276
|
+
PipeCraft provides the following commands:
|
|
277
|
+
|
|
278
|
+
| Command | Description | Options |
|
|
279
|
+
|---------|-------------|---------|
|
|
280
|
+
| `init` | Initialize PipeCraft configuration | `--interactive`, `--force`, `--with-versioning`, `--ci-provider`, `--merge-strategy`, `--initial-branch`, `--final-branch` |
|
|
281
|
+
| `generate` | Generate CI/CD workflows with pre-flight checks | `--skip-checks`, `--force`, `--dry-run`, `--config`, `--output-pipeline`, `--verbose` |
|
|
282
|
+
| `validate` | Validate configuration file | `--config` |
|
|
283
|
+
| `validate:pipeline` | Validate generated pipeline files | `--strict` |
|
|
284
|
+
| `setup-github` | Configure GitHub Actions workflow permissions | `--apply`, `--force` |
|
|
285
|
+
| `verify` | Verify PipeCraft setup | None |
|
|
286
|
+
| `version` | Version management commands | `--check`, `--bump`, `--release` |
|
|
287
|
+
| `setup` | Create branches from branch flow | `--force` |
|
|
288
|
+
|
|
289
|
+
### Global Options
|
|
290
|
+
|
|
291
|
+
Available for all commands:
|
|
292
|
+
|
|
293
|
+
- `-c, --config <path>` - Path to config file (default: `.pipecraftrc.json`)
|
|
294
|
+
- `-p, --pipeline <path>` - Path to existing pipeline file for merging
|
|
295
|
+
- `-o, --output-pipeline <path>` - Path to output pipeline file
|
|
296
|
+
- `-v, --verbose` - Verbose output
|
|
297
|
+
- `--force` - Force operation even if unchanged
|
|
298
|
+
- `--dry-run` - Show what would be done without making changes
|
|
299
|
+
|
|
300
|
+
### Command Examples
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Initialize with all options
|
|
304
|
+
pipecraft init --interactive --with-versioning --ci-provider github
|
|
305
|
+
|
|
306
|
+
# Generate workflows with custom paths
|
|
307
|
+
pipecraft generate --config .pipecraft.json --output-pipeline workflows/ci.yml
|
|
308
|
+
|
|
309
|
+
# Validate pipeline files
|
|
310
|
+
pipecraft validate:pipeline
|
|
311
|
+
|
|
312
|
+
# Setup GitHub Actions permissions (interactive mode)
|
|
313
|
+
pipecraft setup-github
|
|
314
|
+
|
|
315
|
+
# Setup GitHub Actions permissions (auto-apply mode)
|
|
316
|
+
pipecraft setup-github --apply
|
|
317
|
+
|
|
318
|
+
# Validate before committing
|
|
319
|
+
pipecraft validate && git commit -am "chore: update workflow config"
|
|
320
|
+
|
|
321
|
+
# Check version and create release
|
|
322
|
+
pipecraft version --check
|
|
323
|
+
pipecraft version --bump
|
|
324
|
+
pipecraft version --release
|
|
325
|
+
|
|
326
|
+
# Setup all branches for new repository
|
|
327
|
+
pipecraft setup
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Pre-Flight Checks
|
|
331
|
+
|
|
332
|
+
PipeCraft includes comprehensive pre-flight validation to catch common errors before generating workflows. This helps new users avoid frustration and ensures your project is properly configured.
|
|
333
|
+
|
|
334
|
+
### What Gets Checked
|
|
335
|
+
|
|
336
|
+
When you run `pipecraft generate`, the following checks are automatically performed:
|
|
337
|
+
|
|
338
|
+
1. **Configuration File Discovery**
|
|
339
|
+
- Searches for config using [cosmiconfig](https://github.com/davidtheclark/cosmiconfig)
|
|
340
|
+
- Looks in: `.pipecraftrc.json`, `.pipecraftrc`, `package.json` (pipecraft key)
|
|
341
|
+
- Searches parent directories recursively
|
|
342
|
+
- Shows the exact path where config was found
|
|
343
|
+
|
|
344
|
+
2. **Configuration Validation**
|
|
345
|
+
- Verifies JSON syntax is valid
|
|
346
|
+
- Checks all required fields are present:
|
|
347
|
+
- `ciProvider` (github or gitlab)
|
|
348
|
+
- `branchFlow` (array of branch names)
|
|
349
|
+
- `domains` (at least one domain configured)
|
|
350
|
+
- Validates domain configuration has paths defined
|
|
351
|
+
|
|
352
|
+
3. **Git Repository Check**
|
|
353
|
+
- Verifies current directory is a git repository
|
|
354
|
+
- Suggests running `git init` if not
|
|
355
|
+
|
|
356
|
+
4. **Git Remote Check**
|
|
357
|
+
- Verifies git remote is configured
|
|
358
|
+
- Shows the remote URL
|
|
359
|
+
- Suggests adding a remote if missing
|
|
360
|
+
|
|
361
|
+
5. **Write Permissions**
|
|
362
|
+
- Tests that `.github/workflows` directory can be created/written to
|
|
363
|
+
- Checks file system permissions
|
|
364
|
+
|
|
365
|
+
### Example Pre-Flight Output
|
|
366
|
+
|
|
367
|
+
**All checks passing:**
|
|
368
|
+
```
|
|
369
|
+
🔍 Running pre-flight checks...
|
|
370
|
+
|
|
371
|
+
✅ Configuration found: /path/to/project/.pipecraftrc.json
|
|
372
|
+
✅ Configuration is valid
|
|
373
|
+
✅ Current directory is a git repository
|
|
374
|
+
✅ Git remote configured: https://github.com/user/repo.git
|
|
375
|
+
✅ .github/workflows directory is writable
|
|
376
|
+
|
|
377
|
+
✅ All pre-flight checks passed!
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Checks failing with helpful suggestions:**
|
|
381
|
+
```
|
|
382
|
+
🔍 Running pre-flight checks...
|
|
383
|
+
|
|
384
|
+
❌ No PipeCraft configuration found
|
|
385
|
+
💡 Run 'pipecraft init' to create a configuration file
|
|
386
|
+
|
|
387
|
+
❌ Not in a git repository
|
|
388
|
+
💡 Initialize git: 'git init' or clone an existing repository
|
|
389
|
+
|
|
390
|
+
❌ No git remote configured
|
|
391
|
+
💡 Add a remote: 'git remote add origin <url>'
|
|
392
|
+
|
|
393
|
+
❌ Pre-flight checks failed. Fix the issues above and try again.
|
|
394
|
+
Or use --skip-checks to bypass (not recommended)
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Skipping Pre-Flight Checks
|
|
398
|
+
|
|
399
|
+
While not recommended, you can skip pre-flight checks if needed:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
pipecraft generate --skip-checks
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
**When you might skip checks:**
|
|
406
|
+
- CI/CD environment with non-standard setup
|
|
407
|
+
- Using PipeCraft in a script/automation
|
|
408
|
+
- Advanced users who know the risks
|
|
409
|
+
|
|
410
|
+
**Why you shouldn't skip:**
|
|
411
|
+
- Prevents cryptic errors during generation
|
|
412
|
+
- Saves time by catching issues early
|
|
413
|
+
- Provides actionable error messages
|
|
414
|
+
- Ensures consistent behavior across environments
|
|
415
|
+
|
|
416
|
+
## GitHub Actions Setup
|
|
417
|
+
|
|
418
|
+
PipeCraft requires specific GitHub Actions permissions and repository settings to function correctly. The `setup-github` command helps you configure everything automatically.
|
|
419
|
+
|
|
420
|
+
### What Gets Configured
|
|
421
|
+
|
|
422
|
+
The `setup-github` command configures:
|
|
423
|
+
|
|
424
|
+
1. **Workflow Permissions**
|
|
425
|
+
- Default workflow permissions: **write** (for creating tags and pushing changes)
|
|
426
|
+
- Can create/approve pull requests: **Yes** (for automated PR creation)
|
|
427
|
+
|
|
428
|
+
2. **Repository Auto-Merge**
|
|
429
|
+
- Enables auto-merge feature at repository level
|
|
430
|
+
- Required for automatic promotion between branches
|
|
431
|
+
|
|
432
|
+
3. **Branch Protection Rules** (for branches with auto-merge enabled)
|
|
433
|
+
- Status checks enabled (no specific checks required)
|
|
434
|
+
- Required linear history (prevents messy merges)
|
|
435
|
+
- No force pushes or branch deletion
|
|
436
|
+
- These rules are required for GitHub's auto-merge feature to work
|
|
437
|
+
|
|
438
|
+
### Usage
|
|
439
|
+
|
|
440
|
+
**Interactive Mode (Default)**
|
|
441
|
+
|
|
442
|
+
Prompts you for each permission change:
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
pipecraft setup-github
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
The command will:
|
|
449
|
+
1. Check your current repository permissions
|
|
450
|
+
2. Enable repository-level auto-merge if needed
|
|
451
|
+
3. Configure branch protection for branches with `autoMerge: true` in config
|
|
452
|
+
4. Prompt you to apply each change
|
|
453
|
+
5. Update the settings if you accept
|
|
454
|
+
|
|
455
|
+
**Auto-Apply Mode**
|
|
456
|
+
|
|
457
|
+
Automatically applies all required changes without prompting:
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
pipecraft setup-github --apply
|
|
461
|
+
# or
|
|
462
|
+
pipecraft setup-github --force
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
This mode is useful for:
|
|
466
|
+
- CI/CD pipeline setup scripts
|
|
467
|
+
- Automated repository initialization
|
|
468
|
+
- Batch configuration of multiple repositories
|
|
469
|
+
|
|
470
|
+
### Example Output
|
|
471
|
+
|
|
472
|
+
**Interactive mode:**
|
|
473
|
+
```
|
|
474
|
+
🔍 Checking GitHub repository configuration...
|
|
475
|
+
|
|
476
|
+
📦 Repository: user/repo
|
|
477
|
+
✅ GitHub token found
|
|
478
|
+
🔍 Fetching current workflow permissions...
|
|
479
|
+
|
|
480
|
+
📋 Current GitHub Actions Workflow Permissions:
|
|
481
|
+
Default permissions: read
|
|
482
|
+
Can create/approve PRs: No
|
|
483
|
+
|
|
484
|
+
⚠️ PipeCraft requires the following permissions:
|
|
485
|
+
• Default permissions: write (for creating tags and pushing)
|
|
486
|
+
• Can create/approve PRs: Yes (for automated PR creation)
|
|
487
|
+
|
|
488
|
+
? Change default workflow permissions from "read" to "write"? (Y/n) Yes
|
|
489
|
+
|
|
490
|
+
🔍 Checking auto-merge configuration...
|
|
491
|
+
✅ Enabled auto-merge for repository
|
|
492
|
+
📋 Branches with auto-merge enabled: staging
|
|
493
|
+
? Enable branch protection for 'staging' to support auto-merge? (Y/n) Yes
|
|
494
|
+
🔧 Configuring branch protection for staging...
|
|
495
|
+
✅ Branch protection enabled for staging
|
|
496
|
+
|
|
497
|
+
✨ Setup complete!
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
**Auto-apply mode:**
|
|
501
|
+
```
|
|
502
|
+
🔍 Checking GitHub repository configuration...
|
|
503
|
+
|
|
504
|
+
📦 Repository: user/repo
|
|
505
|
+
✅ GitHub token found
|
|
506
|
+
🔍 Fetching current workflow permissions...
|
|
507
|
+
|
|
508
|
+
✅ Workflow permissions are already configured correctly!
|
|
509
|
+
|
|
510
|
+
🔍 Checking auto-merge configuration...
|
|
511
|
+
✅ Enabled auto-merge for repository
|
|
512
|
+
📋 Branches with auto-merge enabled: staging
|
|
513
|
+
🔧 Configuring branch protection for staging...
|
|
514
|
+
✅ Branch protection enabled for staging
|
|
515
|
+
|
|
516
|
+
✨ Setup complete!
|
|
517
|
+
|
|
518
|
+
💡 You can verify the changes at:
|
|
519
|
+
https://github.com/user/repo/settings/actions
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Authentication
|
|
523
|
+
|
|
524
|
+
The command requires a GitHub token with admin access to your repository. It will automatically use:
|
|
525
|
+
|
|
526
|
+
1. `GITHUB_TOKEN` environment variable
|
|
527
|
+
2. `GH_TOKEN` environment variable
|
|
528
|
+
3. GitHub CLI (`gh`) authentication
|
|
529
|
+
|
|
530
|
+
To authenticate with GitHub CLI:
|
|
531
|
+
```bash
|
|
532
|
+
gh auth login
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
Or set an environment variable:
|
|
536
|
+
```bash
|
|
537
|
+
export GITHUB_TOKEN=ghp_your_token_here
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### Manual Configuration
|
|
541
|
+
|
|
542
|
+
You can also configure these settings manually:
|
|
543
|
+
|
|
544
|
+
**Workflow Permissions:**
|
|
545
|
+
1. Go to your repository on GitHub
|
|
546
|
+
2. Navigate to **Settings** → **Actions** → **General**
|
|
547
|
+
3. Under "Workflow permissions":
|
|
548
|
+
- Select **Read and write permissions**
|
|
549
|
+
- Check **Allow GitHub Actions to create and approve pull requests**
|
|
550
|
+
4. Click **Save**
|
|
551
|
+
|
|
552
|
+
**Repository Auto-Merge:**
|
|
553
|
+
1. Navigate to **Settings** → **General**
|
|
554
|
+
2. Scroll to "Pull Requests"
|
|
555
|
+
3. Check **Allow auto-merge**
|
|
556
|
+
4. Click **Save**
|
|
557
|
+
|
|
558
|
+
**Branch Protection (for branches with auto-merge):**
|
|
559
|
+
1. Navigate to **Settings** → **Branches**
|
|
560
|
+
2. Click **Add branch protection rule** or edit existing rule
|
|
561
|
+
3. In "Branch name pattern", enter the branch name (e.g., `staging`)
|
|
562
|
+
4. Configure the following:
|
|
563
|
+
- Check **Require status checks to pass before merging**
|
|
564
|
+
- Leave status checks empty (or add your own)
|
|
565
|
+
- Check **Require linear history**
|
|
566
|
+
- Leave other options as needed
|
|
567
|
+
5. Click **Create** or **Save changes**
|
|
568
|
+
|
|
569
|
+
Note: Branch protection rules are required for auto-merge to work in GitHub.
|
|
570
|
+
|
|
571
|
+
## Configuration Options
|
|
572
|
+
|
|
573
|
+
### Core Configuration
|
|
574
|
+
|
|
575
|
+
| Option | Type | Required | Default | Description |
|
|
576
|
+
|--------|------|----------|---------|-------------|
|
|
577
|
+
| `ciProvider` | `'github' \| 'gitlab'` | Yes | `'github'` | CI/CD provider |
|
|
578
|
+
| `mergeStrategy` | `'fast-forward' \| 'merge'` | Yes | `'fast-forward'` | Branch merge strategy |
|
|
579
|
+
| `requireConventionalCommits` | `boolean` | No | `true` | Enforce conventional commits |
|
|
580
|
+
| `initialBranch` | `string` | Yes | `'develop'` | First branch in flow |
|
|
581
|
+
| `finalBranch` | `string` | Yes | `'main'` | Final production branch |
|
|
582
|
+
| `branchFlow` | `string[]` | Yes | - | Ordered list of branches |
|
|
583
|
+
|
|
584
|
+
### Semantic Versioning
|
|
585
|
+
|
|
586
|
+
| Option | Type | Description |
|
|
587
|
+
|--------|------|-------------|
|
|
588
|
+
| `semver.bumpRules.feat` | `'major' \| 'minor' \| 'patch'` | Version bump for features |
|
|
589
|
+
| `semver.bumpRules.fix` | `'major' \| 'minor' \| 'patch'` | Version bump for fixes |
|
|
590
|
+
| `semver.bumpRules.breaking` | `'major' \| 'minor' \| 'patch'` | Version bump for breaking changes |
|
|
591
|
+
|
|
592
|
+
### Actions
|
|
593
|
+
|
|
594
|
+
Define what happens on branch merges:
|
|
595
|
+
|
|
596
|
+
```json
|
|
597
|
+
{
|
|
598
|
+
"actions": {
|
|
599
|
+
"onDevelopMerge": [
|
|
600
|
+
"runTests",
|
|
601
|
+
"fastForwardToStaging"
|
|
602
|
+
],
|
|
603
|
+
"onStagingMerge": [
|
|
604
|
+
"runTests",
|
|
605
|
+
"calculateVersion",
|
|
606
|
+
"createOrFastForwardToMain"
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
Available actions:
|
|
613
|
+
- `runTests` - Run test suite
|
|
614
|
+
- `fastForwardToStaging` - Fast-forward develop to staging
|
|
615
|
+
- `calculateVersion` - Calculate next semantic version
|
|
616
|
+
- `createOrFastForwardToMain` - Merge or fast-forward to main
|
|
617
|
+
- `deploy` - Run deployment steps
|
|
618
|
+
|
|
619
|
+
### Domains (Monorepo Support)
|
|
620
|
+
|
|
621
|
+
Define multiple domains for path-based change detection:
|
|
622
|
+
|
|
623
|
+
```json
|
|
624
|
+
{
|
|
625
|
+
"domains": {
|
|
626
|
+
"api": {
|
|
627
|
+
"paths": ["apps/api/**", "libs/api-utils/**"],
|
|
628
|
+
"description": "API application and utilities"
|
|
629
|
+
},
|
|
630
|
+
"web": {
|
|
631
|
+
"paths": ["apps/web/**", "libs/ui-components/**"],
|
|
632
|
+
"description": "Web application and UI components"
|
|
633
|
+
},
|
|
634
|
+
"mobile": {
|
|
635
|
+
"paths": ["apps/mobile/**"],
|
|
636
|
+
"description": "Mobile application"
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
Each domain can have:
|
|
643
|
+
- `paths` (required): Array of glob patterns for file matching
|
|
644
|
+
- `description` (optional): Human-readable description
|
|
645
|
+
|
|
646
|
+
### Versioning Configuration
|
|
647
|
+
|
|
648
|
+
```json
|
|
649
|
+
{
|
|
650
|
+
"versioning": {
|
|
651
|
+
"enabled": true,
|
|
652
|
+
"releaseItConfig": ".release-it.cjs",
|
|
653
|
+
"conventionalCommits": true,
|
|
654
|
+
"autoTag": true,
|
|
655
|
+
"autoPush": true,
|
|
656
|
+
"changelog": true,
|
|
657
|
+
"bumpRules": {
|
|
658
|
+
"feat": "minor",
|
|
659
|
+
"fix": "patch",
|
|
660
|
+
"breaking": "major"
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
### Rebuild/Idempotency Configuration
|
|
667
|
+
|
|
668
|
+
Control when workflows are regenerated:
|
|
669
|
+
|
|
670
|
+
```json
|
|
671
|
+
{
|
|
672
|
+
"rebuild": {
|
|
673
|
+
"enabled": true,
|
|
674
|
+
"skipIfUnchanged": true,
|
|
675
|
+
"forceRegenerate": false,
|
|
676
|
+
"watchMode": false,
|
|
677
|
+
"hashAlgorithm": "sha256",
|
|
678
|
+
"cacheFile": ".pipecraft-cache.json",
|
|
679
|
+
"ignorePatterns": ["*.md", "docs/**"]
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
## Domain-Based Workflows
|
|
685
|
+
|
|
686
|
+
PipeCraft excels at managing monorepo workflows with multiple domains. The generated workflows automatically detect which domains have changes and run appropriate jobs.
|
|
687
|
+
|
|
688
|
+
### How It Works
|
|
689
|
+
|
|
690
|
+
1. **Change Detection**: The `changes` job uses GitHub's `paths-filter` action to detect which domains have modifications
|
|
691
|
+
2. **Conditional Jobs**: Domain-specific jobs only run if changes are detected in their paths
|
|
692
|
+
3. **Parallel Execution**: Independent domains run in parallel for faster CI times
|
|
693
|
+
4. **Dependency Management**: Jobs can depend on specific domain changes
|
|
694
|
+
|
|
695
|
+
### Example Generated Workflow
|
|
696
|
+
|
|
697
|
+
```yaml
|
|
698
|
+
name: Pipeline
|
|
699
|
+
|
|
700
|
+
on:
|
|
701
|
+
pull_request:
|
|
702
|
+
branches:
|
|
703
|
+
- develop
|
|
704
|
+
- staging
|
|
705
|
+
- main
|
|
706
|
+
|
|
707
|
+
jobs:
|
|
708
|
+
changes:
|
|
709
|
+
runs-on: ubuntu-latest
|
|
710
|
+
outputs:
|
|
711
|
+
api: ${{ steps.changes.outputs.api }}
|
|
712
|
+
web: ${{ steps.changes.outputs.web }}
|
|
713
|
+
steps:
|
|
714
|
+
- uses: actions/checkout@v4
|
|
715
|
+
- uses: dorny/paths-filter@v3
|
|
716
|
+
id: changes
|
|
717
|
+
with:
|
|
718
|
+
filters: |
|
|
719
|
+
api:
|
|
720
|
+
- 'apps/api/**'
|
|
721
|
+
web:
|
|
722
|
+
- 'apps/web/**'
|
|
723
|
+
|
|
724
|
+
test-api:
|
|
725
|
+
needs: changes
|
|
726
|
+
if: needs.changes.outputs.api == 'true'
|
|
727
|
+
runs-on: ubuntu-latest
|
|
728
|
+
steps:
|
|
729
|
+
- uses: actions/checkout@v4
|
|
730
|
+
- name: Run API tests
|
|
731
|
+
run: npm test --workspace=api
|
|
732
|
+
|
|
733
|
+
test-web:
|
|
734
|
+
needs: changes
|
|
735
|
+
if: needs.changes.outputs.web == 'true'
|
|
736
|
+
runs-on: ubuntu-latest
|
|
737
|
+
steps:
|
|
738
|
+
- uses: actions/checkout@v4
|
|
739
|
+
- name: Run Web tests
|
|
740
|
+
run: npm test --workspace=web
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
## Version Management
|
|
744
|
+
|
|
745
|
+
PipeCraft integrates with [release-it](https://github.com/release-it/release-it) for automated semantic versioning.
|
|
746
|
+
|
|
747
|
+
### Setup Version Management
|
|
748
|
+
|
|
749
|
+
```bash
|
|
750
|
+
pipecraft init --with-versioning
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
This creates:
|
|
754
|
+
- `.release-it.cjs` - Release-it configuration
|
|
755
|
+
- `commitlint.config.js` - Commit message linting
|
|
756
|
+
- `.husky/commit-msg` - Git hook for commit validation
|
|
757
|
+
|
|
758
|
+
### Version Commands
|
|
759
|
+
|
|
760
|
+
Check what the next version would be:
|
|
761
|
+
```bash
|
|
762
|
+
pipecraft version --check
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
Output:
|
|
766
|
+
```
|
|
767
|
+
📦 Current version: 1.2.3
|
|
768
|
+
📦 Next version: 1.3.0 (minor)
|
|
769
|
+
📝 Conventional commits: ✅ Valid
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
Bump version based on commits:
|
|
773
|
+
```bash
|
|
774
|
+
pipecraft version --bump
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
Create a full release:
|
|
778
|
+
```bash
|
|
779
|
+
pipecraft version --release
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
### Conventional Commits
|
|
783
|
+
|
|
784
|
+
PipeCraft works best with conventional commits:
|
|
785
|
+
|
|
786
|
+
- `feat:` - New feature (minor bump)
|
|
787
|
+
- `fix:` - Bug fix (patch bump)
|
|
788
|
+
- `feat!:` or `BREAKING CHANGE:` - Breaking change (major bump)
|
|
789
|
+
- `chore:`, `docs:`, `style:`, `refactor:`, `test:` - No version bump
|
|
790
|
+
|
|
791
|
+
Example:
|
|
792
|
+
```bash
|
|
793
|
+
git commit -m "feat: add user authentication" # Bumps to 1.3.0
|
|
794
|
+
git commit -m "fix: resolve login bug" # Bumps to 1.3.1
|
|
795
|
+
git commit -m "feat!: redesign API structure" # Bumps to 2.0.0
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
## Examples
|
|
799
|
+
|
|
800
|
+
### Example 1: Simple Project with Linear Branch Flow
|
|
801
|
+
|
|
802
|
+
Configuration for a project with develop → main flow:
|
|
803
|
+
|
|
804
|
+
```json
|
|
805
|
+
{
|
|
806
|
+
"ciProvider": "github",
|
|
807
|
+
"mergeStrategy": "fast-forward",
|
|
808
|
+
"initialBranch": "develop",
|
|
809
|
+
"finalBranch": "main",
|
|
810
|
+
"branchFlow": ["develop", "main"],
|
|
811
|
+
"domains": {
|
|
812
|
+
"app": {
|
|
813
|
+
"paths": ["src/**"],
|
|
814
|
+
"description": "Application code"
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
### Example 2: Enterprise Monorepo with Multiple Environments
|
|
821
|
+
|
|
822
|
+
Configuration for staging environment:
|
|
823
|
+
|
|
824
|
+
```json
|
|
825
|
+
{
|
|
826
|
+
"ciProvider": "github",
|
|
827
|
+
"mergeStrategy": "fast-forward",
|
|
828
|
+
"requireConventionalCommits": true,
|
|
829
|
+
"initialBranch": "develop",
|
|
830
|
+
"finalBranch": "production",
|
|
831
|
+
"branchFlow": ["develop", "staging", "uat", "production"],
|
|
832
|
+
"semver": {
|
|
833
|
+
"bumpRules": {
|
|
834
|
+
"feat": "minor",
|
|
835
|
+
"fix": "patch",
|
|
836
|
+
"breaking": "major"
|
|
837
|
+
}
|
|
838
|
+
},
|
|
839
|
+
"actions": {
|
|
840
|
+
"onDevelopMerge": ["runTests", "fastForwardToStaging"],
|
|
841
|
+
"onStagingMerge": ["runTests", "deployToStaging"],
|
|
842
|
+
"onUatMerge": ["runTests", "calculateVersion", "deployToUat"],
|
|
843
|
+
"onProductionMerge": ["runTests", "deployToProduction", "createRelease"]
|
|
844
|
+
},
|
|
845
|
+
"domains": {
|
|
846
|
+
"api": {
|
|
847
|
+
"paths": ["services/api/**", "libs/api-core/**"],
|
|
848
|
+
"description": "API services and core libraries"
|
|
849
|
+
},
|
|
850
|
+
"web": {
|
|
851
|
+
"paths": ["apps/web/**", "libs/ui/**"],
|
|
852
|
+
"description": "Web application and UI libraries"
|
|
853
|
+
},
|
|
854
|
+
"mobile": {
|
|
855
|
+
"paths": ["apps/mobile/**"],
|
|
856
|
+
"description": "Mobile application"
|
|
857
|
+
},
|
|
858
|
+
"shared": {
|
|
859
|
+
"paths": ["libs/shared/**", "packages/**"],
|
|
860
|
+
"description": "Shared libraries and packages"
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
"versioning": {
|
|
864
|
+
"enabled": true,
|
|
865
|
+
"conventionalCommits": true,
|
|
866
|
+
"autoTag": true,
|
|
867
|
+
"changelog": true
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
### Example 3: GitLab CI Project
|
|
873
|
+
|
|
874
|
+
Configuration for GitLab:
|
|
875
|
+
|
|
876
|
+
```json
|
|
877
|
+
{
|
|
878
|
+
"ciProvider": "gitlab",
|
|
879
|
+
"mergeStrategy": "merge",
|
|
880
|
+
"initialBranch": "develop",
|
|
881
|
+
"finalBranch": "main",
|
|
882
|
+
"branchFlow": ["develop", "main"],
|
|
883
|
+
"domains": {
|
|
884
|
+
"backend": {
|
|
885
|
+
"paths": ["backend/**"],
|
|
886
|
+
"description": "Backend services"
|
|
887
|
+
},
|
|
888
|
+
"frontend": {
|
|
889
|
+
"paths": ["frontend/**"],
|
|
890
|
+
"description": "Frontend application"
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
### Example 4: Custom Branch Names
|
|
897
|
+
|
|
898
|
+
Configuration with non-standard branch names:
|
|
899
|
+
|
|
900
|
+
```json
|
|
901
|
+
{
|
|
902
|
+
"ciProvider": "github",
|
|
903
|
+
"mergeStrategy": "fast-forward",
|
|
904
|
+
"initialBranch": "alpha",
|
|
905
|
+
"finalBranch": "release",
|
|
906
|
+
"branchFlow": ["alpha", "beta", "gamma", "release"],
|
|
907
|
+
"domains": {
|
|
908
|
+
"core": {
|
|
909
|
+
"paths": ["core/**"],
|
|
910
|
+
"description": "Core functionality"
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
## Roadmap & Future Features
|
|
917
|
+
|
|
918
|
+
PipeCraft is actively being developed with plans for additional features and improvements:
|
|
919
|
+
|
|
920
|
+
### Planned Features
|
|
921
|
+
|
|
922
|
+
#### Enhanced GitLab Support
|
|
923
|
+
- Full GitLab CI/CD pipeline generation (currently basic support)
|
|
924
|
+
- GitLab-specific features (includes, extends, etc.)
|
|
925
|
+
- GitLab merge request automation
|
|
926
|
+
- GitLab runner configuration
|
|
927
|
+
|
|
928
|
+
#### Additional Workflow Patterns
|
|
929
|
+
- Feature branch workflows (Gitflow alternative)
|
|
930
|
+
- Release branch workflows
|
|
931
|
+
- Hotfix workflows
|
|
932
|
+
- Custom workflow patterns via plugins
|
|
933
|
+
|
|
934
|
+
#### Advanced Branch Management
|
|
935
|
+
- Automatic conflict resolution strategies
|
|
936
|
+
- Branch protection rule setup
|
|
937
|
+
- PR template generation
|
|
938
|
+
- Code review automation
|
|
939
|
+
|
|
940
|
+
#### Extended CI/CD Providers
|
|
941
|
+
- Azure DevOps Pipelines
|
|
942
|
+
- Jenkins pipeline generation
|
|
943
|
+
- CircleCI configuration
|
|
944
|
+
- Bitbucket Pipelines
|
|
945
|
+
|
|
946
|
+
#### Improved Developer Experience
|
|
947
|
+
- Interactive CLI improvements
|
|
948
|
+
- Better error messages and diagnostics
|
|
949
|
+
- Configuration migration tools
|
|
950
|
+
- Visual workflow editor (web-based)
|
|
951
|
+
- Real-time workflow preview
|
|
952
|
+
|
|
953
|
+
#### Enterprise Features
|
|
954
|
+
- Team configuration templates
|
|
955
|
+
- Organization-wide policy enforcement
|
|
956
|
+
- Audit logging
|
|
957
|
+
- RBAC integration
|
|
958
|
+
- Self-hosted runner configuration
|
|
959
|
+
|
|
960
|
+
### Contributing to the Roadmap
|
|
961
|
+
|
|
962
|
+
Have a feature request? We'd love to hear from you!
|
|
963
|
+
|
|
964
|
+
1. Check existing [feature requests](https://github.com/jamesvillarrubia/pipecraft/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
|
|
965
|
+
2. [Open a new feature request](https://github.com/jamesvillarrubia/pipecraft/issues/new?labels=enhancement)
|
|
966
|
+
3. Vote on existing feature requests with 👍
|
|
967
|
+
4. Consider contributing! See [Contributing](#contributing)
|
|
968
|
+
|
|
969
|
+
## Troubleshooting
|
|
970
|
+
|
|
971
|
+
### Common Issues
|
|
972
|
+
|
|
973
|
+
#### 1. Workflows Not Generating
|
|
974
|
+
|
|
975
|
+
**Problem**: Running `pipecraft generate` doesn't create files.
|
|
976
|
+
|
|
977
|
+
**Solutions**:
|
|
978
|
+
- PipeCraft now runs automatic pre-flight checks that will catch most issues
|
|
979
|
+
- Review the pre-flight check output for specific problems
|
|
980
|
+
- Check if configuration is valid: `pipecraft validate`
|
|
981
|
+
- Use `--force` to bypass cache: `pipecraft generate --force`
|
|
982
|
+
- Use `--verbose` for detailed output: `pipecraft generate --verbose`
|
|
983
|
+
- Verify file permissions in `.github/workflows/`
|
|
984
|
+
|
|
985
|
+
#### 2. Configuration Validation Errors
|
|
986
|
+
|
|
987
|
+
**Problem**: Getting validation errors when running commands.
|
|
988
|
+
|
|
989
|
+
**Solutions**:
|
|
990
|
+
- Ensure all required fields are present (ciProvider, branchFlow, domains)
|
|
991
|
+
- Check that `initialBranch` and `finalBranch` are in `branchFlow`
|
|
992
|
+
- Verify domain paths are valid glob patterns
|
|
993
|
+
- Use `pipecraft validate` to see specific errors
|
|
994
|
+
|
|
995
|
+
#### 3. Branch Flow Not Working
|
|
996
|
+
|
|
997
|
+
**Problem**: Branches aren't being created or fast-forwarded.
|
|
998
|
+
|
|
999
|
+
**Solutions**:
|
|
1000
|
+
- Run `pipecraft setup` to create missing branches
|
|
1001
|
+
- Verify GitHub token has push permissions
|
|
1002
|
+
- Check that branch protection rules allow fast-forward merges
|
|
1003
|
+
- Ensure branches exist on remote: `git push origin branch-name`
|
|
1004
|
+
|
|
1005
|
+
#### 4. Version Management Not Working
|
|
1006
|
+
|
|
1007
|
+
**Problem**: Version bumps aren't happening automatically.
|
|
1008
|
+
|
|
1009
|
+
**Solutions**:
|
|
1010
|
+
- Initialize version management: `pipecraft init --with-versioning`
|
|
1011
|
+
- Ensure commits follow conventional format
|
|
1012
|
+
- Check that `package.json` exists with version field
|
|
1013
|
+
- Verify `release-it` is configured: check `.release-it.cjs`
|
|
1014
|
+
|
|
1015
|
+
#### 5. Cache Issues
|
|
1016
|
+
|
|
1017
|
+
**Problem**: Changes not being detected after config update.
|
|
1018
|
+
|
|
1019
|
+
**Solutions**:
|
|
1020
|
+
- Force regeneration: `pipecraft generate --force`
|
|
1021
|
+
- Delete cache file: `rm .pipecraft-cache.json`
|
|
1022
|
+
- Check cache file permissions
|
|
1023
|
+
- Verify `rebuild.enabled` is `true` in config
|
|
1024
|
+
|
|
1025
|
+
### Getting Help
|
|
1026
|
+
|
|
1027
|
+
If you encounter issues not covered here:
|
|
1028
|
+
|
|
1029
|
+
1. Check the [GitHub Issues](https://github.com/jamesvillarrubia/pipecraft/issues)
|
|
1030
|
+
2. Enable verbose logging: `pipecraft generate --verbose`
|
|
1031
|
+
3. Validate your configuration: `pipecraft validate`
|
|
1032
|
+
4. [Open a new issue](https://github.com/jamesvillarrubia/pipecraft/issues/new) with:
|
|
1033
|
+
- PipeCraft version: `pipecraft --version`
|
|
1034
|
+
- Node version: `node --version`
|
|
1035
|
+
- Your configuration (sanitized)
|
|
1036
|
+
- Full error output with `--verbose`
|
|
1037
|
+
|
|
1038
|
+
## Contributing
|
|
1039
|
+
|
|
1040
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details on:
|
|
1041
|
+
|
|
1042
|
+
- Code of conduct
|
|
1043
|
+
- Development setup
|
|
1044
|
+
- Running tests
|
|
1045
|
+
- Submitting pull requests
|
|
1046
|
+
- Coding standards
|
|
1047
|
+
|
|
1048
|
+
### Development Setup
|
|
1049
|
+
|
|
1050
|
+
```bash
|
|
1051
|
+
# Clone the repository
|
|
1052
|
+
git clone https://github.com/jamesvillarrubia/pipecraft.git
|
|
1053
|
+
cd pipecraft
|
|
1054
|
+
|
|
1055
|
+
# Install dependencies
|
|
1056
|
+
npm install
|
|
1057
|
+
|
|
1058
|
+
# Run tests
|
|
1059
|
+
npm test
|
|
1060
|
+
|
|
1061
|
+
# Run in development mode
|
|
1062
|
+
npm run dev -- init --interactive
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
### Running Tests
|
|
1066
|
+
|
|
1067
|
+
```bash
|
|
1068
|
+
# Run all tests
|
|
1069
|
+
npm test
|
|
1070
|
+
|
|
1071
|
+
# Run with coverage
|
|
1072
|
+
npm run test:coverage
|
|
1073
|
+
|
|
1074
|
+
# Run in watch mode
|
|
1075
|
+
npm run test:watch
|
|
1076
|
+
|
|
1077
|
+
# Run specific test file
|
|
1078
|
+
npm test tests/unit/config.test.ts
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
## License
|
|
1082
|
+
|
|
1083
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
1084
|
+
|
|
1085
|
+
## Acknowledgments
|
|
1086
|
+
|
|
1087
|
+
- **PullCraft** - Sister project for automated PR generation
|
|
1088
|
+
- **Pinion** - Template generation framework by FeathersCloud
|
|
1089
|
+
- **Commander** - CLI framework
|
|
1090
|
+
- **release-it** - Version management and releases
|
|
1091
|
+
- All contributors who have helped improve PipeCraft
|
|
1092
|
+
|
|
1093
|
+
---
|
|
1094
|
+
|
|
1095
|
+
<div align="center">
|
|
1096
|
+
|
|
1097
|
+
**Built with ❤️ for trunk-based development teams**
|
|
1098
|
+
|
|
1099
|
+
[Report Bug](https://github.com/jamesvillarrubia/pipecraft/issues) · [Request Feature](https://github.com/jamesvillarrubia/pipecraft/issues) · [Documentation](https://github.com/jamesvillarrubia/pipecraft/wiki)
|
|
1100
|
+
|
|
1101
|
+
</div>
|