@teambit/ci 0.0.0-01196c5baebfaeabe37f33253bb4c38b8b774ea8
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/ci.docs.mdx +258 -0
- package/commands/merge.cmd.ts +78 -0
- package/commands/pr.cmd.ts +76 -0
- package/commands/verify.cmd.ts +25 -0
- package/dist/ci.aspect.d.ts +3 -0
- package/dist/ci.aspect.js +19 -0
- package/dist/ci.aspect.js.map +1 -0
- package/dist/ci.cmd.d.ts +17 -0
- package/dist/ci.cmd.js +29 -0
- package/dist/ci.cmd.js.map +1 -0
- package/dist/ci.docs.mdx +258 -0
- package/dist/ci.main.runtime.d.ts +132 -0
- package/dist/ci.main.runtime.js +605 -0
- package/dist/ci.main.runtime.js.map +1 -0
- package/dist/commands/merge.cmd.d.ts +33 -0
- package/dist/commands/merge.cmd.js +59 -0
- package/dist/commands/merge.cmd.js.map +1 -0
- package/dist/commands/pr.cmd.d.ts +22 -0
- package/dist/commands/pr.cmd.js +69 -0
- package/dist/commands/pr.cmd.js.map +1 -0
- package/dist/commands/verify.cmd.d.ts +18 -0
- package/dist/commands/verify.cmd.js +35 -0
- package/dist/commands/verify.cmd.js.map +1 -0
- package/dist/git.d.ts +1 -0
- package/dist/git.js +16 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1753780788128.js +7 -0
- package/package.json +64 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
package/dist/ci.docs.mdx
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Aspect that eases the Bit workflow in CI'
|
|
3
|
+
labels: ['aspect', 'ci']
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Bit CI
|
|
7
|
+
|
|
8
|
+
Bit's **`bit ci`** commands (plus one BVM enhancement) wrap several routine Bit tasks into single-purpose scripts so your CI pipelines stay short, readable and consistent.
|
|
9
|
+
|
|
10
|
+
| Command | Purpose | Typical CI Stage |
|
|
11
|
+
| --------------------------------- | ----------------------------------------------------- | ---------------------- |
|
|
12
|
+
| [`bit ci verify`](#bit-ci-verify) | Lint + build gate on every commit | pre-push / commit hook |
|
|
13
|
+
| [`bit ci pr`](#bit-ci-pr) | Snap + export a feature lane when a PR opens/updates | pull-request pipeline |
|
|
14
|
+
| [`bit ci merge`](#bit-ci-merge) | Tag + export new semantic versions on merge to `main` | merge-to-main pipeline |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## `bit ci verify`
|
|
19
|
+
|
|
20
|
+
| | |
|
|
21
|
+
| ---------------- | ------------------------------------------------- |
|
|
22
|
+
| **Syntax** | `bit ci verify` |
|
|
23
|
+
| **What it does** | Ensures the component passes CI on every commit |
|
|
24
|
+
| **Runs** | `bit install && bit status --strict && bit build` |
|
|
25
|
+
|
|
26
|
+
### When to run
|
|
27
|
+
|
|
28
|
+
- Every commit that **is not** part of an open Pull Request (e.g. a pre-push hook).
|
|
29
|
+
- As an early CI job to fail fast on dependency drift or broken builds.
|
|
30
|
+
|
|
31
|
+
### Exit behaviour
|
|
32
|
+
|
|
33
|
+
The command stops at the first failing step (`status`, then `build`) and returns a non-zero exit code.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## `bit ci pr`
|
|
38
|
+
|
|
39
|
+
Export a lane to Bit Cloud whenever a Pull Request is opened or updated.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bit ci pr [--message <string>] [--build] [--lane <string>]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Flag | Shorthand | Description |
|
|
46
|
+
| ----------- | --------- | ----------------------------------------------------------------------------------------- |
|
|
47
|
+
| `--message` | `-m` | Changelog entry. If omitted, tries the latest Git commit message (fails if unavailable). |
|
|
48
|
+
| `--build` | `-b` | Build locally before export. If absent, Ripple-CI builds the components. |
|
|
49
|
+
| `--lane` | `-l` | Explicit lane name. Falls back to the current Git branch name. Performs input validation. |
|
|
50
|
+
|
|
51
|
+
### Internal flow (fail-fast on any step)
|
|
52
|
+
|
|
53
|
+
1. **Resolve lane name**
|
|
54
|
+
- From `--lane` or current Git branch.
|
|
55
|
+
- If the lane doesn’t exist remotely, create it; otherwise, `bit lane checkout <lane>`.
|
|
56
|
+
2. **Run wrapped Bit commands**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
bit install
|
|
60
|
+
bit status --strict
|
|
61
|
+
bit lane create <lane> # no-op if already exists
|
|
62
|
+
bit snap --message "<msg>" --build
|
|
63
|
+
bit export
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
3. **Clean-up**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
bit lane switch main # leaves .bitmap unchanged in the working tree
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Typical CI placement
|
|
73
|
+
|
|
74
|
+
Run on the _pull-request_ event after tests but before any deploy step.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## `bit ci merge`
|
|
79
|
+
|
|
80
|
+
Publishes new semantic versions after a PR merges to `main`.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
bit ci merge [--message <string>] [--build] [--increment <level>] [--patch|--minor|--major] [--increment-by <number>]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| Flag | Shorthand | Description |
|
|
87
|
+
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
88
|
+
| `--message` | `-m` | Changelog entry (defaults to last Git commit message). |
|
|
89
|
+
| `--build` | `-b` | Build locally (otherwise Ripple-CI does it). Required if workspace contains _soft-tagged_ components. |
|
|
90
|
+
| `--strict` | `-s` | Fail on warnings as well as errors (default: only fails on errors). |
|
|
91
|
+
| `--increment` | `-l` | Version bump level: `major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, `prerelease` (default: `patch`). |
|
|
92
|
+
| `--patch` | `-p` | Shortcut for `--increment patch`. |
|
|
93
|
+
| `--minor` | | Shortcut for `--increment minor`. |
|
|
94
|
+
| `--major` | | Shortcut for `--increment major`. |
|
|
95
|
+
| `--pre-release` | | Shortcut for `--increment prerelease` with optional identifier. |
|
|
96
|
+
| `--prerelease-id` | | Prerelease identifier (e.g. "dev" to get "1.0.0-dev.1"). |
|
|
97
|
+
| `--increment-by` | | Increment by more than 1 (e.g. `--increment-by 2` with patch: 0.0.1 → 0.0.3). |
|
|
98
|
+
|
|
99
|
+
### Automatic Version Bump Detection
|
|
100
|
+
|
|
101
|
+
When **no explicit version flags** are provided, `bit ci merge` can automatically determine the version bump level from the commit message:
|
|
102
|
+
|
|
103
|
+
1. **Explicit Keywords** (highest priority):
|
|
104
|
+
|
|
105
|
+
- `BIT-BUMP-MAJOR` anywhere in commit message → major version bump
|
|
106
|
+
- `BIT-BUMP-MINOR` anywhere in commit message → minor version bump
|
|
107
|
+
|
|
108
|
+
2. **Conventional Commits** (when enabled):
|
|
109
|
+
|
|
110
|
+
- `feat!:` or `BREAKING CHANGE` → major version bump
|
|
111
|
+
- `feat:` → minor version bump
|
|
112
|
+
- `fix:` → patch version bump
|
|
113
|
+
|
|
114
|
+
3. **Default**: patch version bump
|
|
115
|
+
|
|
116
|
+
**Note**: Auto-detection only occurs when no version flags (`--patch`, `--minor`, `--major`, etc.) are provided. Explicit flags always take precedence.
|
|
117
|
+
|
|
118
|
+
### Internal flow
|
|
119
|
+
|
|
120
|
+
1. **Ensure main lane**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
bit lane switch main # preserves working tree files
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
2. **Tag, build, export**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
bit install
|
|
130
|
+
bit tag --message "<msg>" --build --persist # --persist only if soft tags exist
|
|
131
|
+
bit export
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
3. **Archive remote lane** (house-keeping).
|
|
135
|
+
4. **Commit lock-file updates**
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
git add .bitmap pnpm-lock.yaml
|
|
139
|
+
git commit -m "chore(release): sync bitmap + lockfile"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Version bump examples
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Explicit version bump (takes precedence over auto-detection)
|
|
146
|
+
bit ci merge --minor --message "feat: add new API endpoint"
|
|
147
|
+
bit ci merge --major --message "feat!: breaking API changes"
|
|
148
|
+
bit ci merge --patch --increment-by 3 --message "fix: critical patches"
|
|
149
|
+
|
|
150
|
+
# Automatic detection from commit message (no flags needed)
|
|
151
|
+
git commit -m "feat: add new API endpoint"
|
|
152
|
+
bit ci merge --build # → auto-detects minor bump
|
|
153
|
+
|
|
154
|
+
git commit -m "feat!: breaking API changes"
|
|
155
|
+
bit ci merge --build # → auto-detects major bump
|
|
156
|
+
|
|
157
|
+
git commit -m "fix: resolve memory leak"
|
|
158
|
+
bit ci merge --build # → auto-detects patch bump (if conventional commits enabled)
|
|
159
|
+
|
|
160
|
+
# Using explicit keywords for auto-detection
|
|
161
|
+
git commit -m "feat: add new feature BIT-BUMP-MINOR"
|
|
162
|
+
bit ci merge --build # → auto-detects minor bump
|
|
163
|
+
|
|
164
|
+
git commit -m "refactor: major code restructure BIT-BUMP-MAJOR"
|
|
165
|
+
bit ci merge --build # → auto-detects major bump
|
|
166
|
+
|
|
167
|
+
# Default patch increment (when no detection rules match)
|
|
168
|
+
git commit -m "chore: update dependencies"
|
|
169
|
+
bit ci merge --build # → defaults to patch bump
|
|
170
|
+
|
|
171
|
+
# Prerelease increment (explicit flag required)
|
|
172
|
+
bit ci merge --pre-release dev --message "feat: experimental feature"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### CI hint
|
|
176
|
+
|
|
177
|
+
Gate this step behind a branch-protection rule so only fast-forward merges trigger a release.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Configuration
|
|
182
|
+
|
|
183
|
+
The CI aspect supports configuration in `workspace.jsonc`:
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"teambit.git/ci": {
|
|
188
|
+
"commitMessageScript": "node scripts/generate-commit-message.js",
|
|
189
|
+
"useConventionalCommitsForVersionBump": true,
|
|
190
|
+
"useExplicitBumpKeywords": true
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### `commitMessageScript`
|
|
196
|
+
|
|
197
|
+
**Optional.** Path to a script that generates custom commit messages for the `bit ci merge` command.
|
|
198
|
+
|
|
199
|
+
- **Default**: Uses `"chore: update .bitmap and lockfiles as needed [skip ci]"`
|
|
200
|
+
- **Usage**: The script should output the desired commit message to stdout
|
|
201
|
+
- **Security**: Commands are parsed to avoid shell injection - no chaining allowed
|
|
202
|
+
- **Working Directory**: Script runs in the workspace root directory
|
|
203
|
+
|
|
204
|
+
**Example script:**
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
#!/usr/bin/env node
|
|
208
|
+
const { execSync } = require('child_process');
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
const version = execSync('npm show @my/package version', { encoding: 'utf8' }).trim();
|
|
212
|
+
console.log(`bump version to ${version} [skip ci]`);
|
|
213
|
+
} catch {
|
|
214
|
+
console.log('chore: update .bitmap and lockfiles as needed [skip ci]');
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### `useConventionalCommitsForVersionBump`
|
|
219
|
+
|
|
220
|
+
**Optional.** Enable automatic version bump detection based on conventional commit patterns.
|
|
221
|
+
|
|
222
|
+
- **Default**: `false` (disabled)
|
|
223
|
+
- **When enabled**: Analyzes commit messages for conventional commit patterns:
|
|
224
|
+
- `feat!:` or `BREAKING CHANGE` → major version bump
|
|
225
|
+
- `feat:` → minor version bump
|
|
226
|
+
- `fix:` → patch version bump
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"teambit.git/ci": {
|
|
231
|
+
"useConventionalCommitsForVersionBump": true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### `useExplicitBumpKeywords`
|
|
237
|
+
|
|
238
|
+
**Optional.** Enable automatic version bump detection using explicit keywords.
|
|
239
|
+
|
|
240
|
+
- **Default**: `true` (enabled)
|
|
241
|
+
- **Keywords**:
|
|
242
|
+
- `BIT-BUMP-MAJOR` anywhere in commit message → major version bump
|
|
243
|
+
- `BIT-BUMP-MINOR` anywhere in commit message → minor version bump
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"teambit.git/ci": {
|
|
248
|
+
"useExplicitBumpKeywords": false // disable explicit keywords
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Example usage:**
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
git commit -m "feat: add new feature BIT-BUMP-MINOR"
|
|
257
|
+
bit ci merge --build # → automatically uses minor version bump
|
|
258
|
+
```
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { RuntimeDefinition } from '@teambit/harmony';
|
|
2
|
+
import { type CLIMain } from '@teambit/cli';
|
|
3
|
+
import { type LoggerMain, type Logger } from '@teambit/logger';
|
|
4
|
+
import { type Workspace } from '@teambit/workspace';
|
|
5
|
+
import { type BuilderMain } from '@teambit/builder';
|
|
6
|
+
import { type StatusMain } from '@teambit/status';
|
|
7
|
+
import { type LanesMain } from '@teambit/lanes';
|
|
8
|
+
import { type SnappingMain } from '@teambit/snapping';
|
|
9
|
+
import { type ExportMain } from '@teambit/export';
|
|
10
|
+
import { type ImporterMain } from '@teambit/importer';
|
|
11
|
+
import { type CheckoutMain } from '@teambit/checkout';
|
|
12
|
+
import { ReleaseType } from 'semver';
|
|
13
|
+
export interface CiWorkspaceConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Path to a custom script that generates commit messages for `bit ci merge` operations.
|
|
16
|
+
* The script will be executed when components are tagged and committed to the repository.
|
|
17
|
+
* If not specified, falls back to the default commit message:
|
|
18
|
+
* "chore: update .bitmap and lockfiles as needed [skip ci]"
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```json
|
|
22
|
+
* {
|
|
23
|
+
* "teambit.git/ci": {
|
|
24
|
+
* "commitMessageScript": "node scripts/generate-commit-message.js"
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
commitMessageScript?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Enables automatic version bump detection from conventional commit messages.
|
|
32
|
+
* When enabled, the system analyzes commit messages to determine the appropriate version bump:
|
|
33
|
+
* - `feat!:` or `BREAKING CHANGE` → major version bump
|
|
34
|
+
* - `feat:` → minor version bump
|
|
35
|
+
* - `fix:` → patch version bump
|
|
36
|
+
*
|
|
37
|
+
* Only applies when no explicit version flags (--patch, --minor, --major) are provided.
|
|
38
|
+
*
|
|
39
|
+
* @default false
|
|
40
|
+
* @example
|
|
41
|
+
* ```json
|
|
42
|
+
* {
|
|
43
|
+
* "teambit.git/ci": {
|
|
44
|
+
* "useConventionalCommitsForVersionBump": true
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
useConventionalCommitsForVersionBump?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Enables detection of explicit version bump keywords in commit messages.
|
|
52
|
+
* When enabled, the system looks for these keywords in commit messages:
|
|
53
|
+
* - `BIT-BUMP-MAJOR` → major version bump
|
|
54
|
+
* - `BIT-BUMP-MINOR` → minor version bump
|
|
55
|
+
*
|
|
56
|
+
* These keywords have higher priority than conventional commits parsing.
|
|
57
|
+
* Only applies when no explicit version flags are provided.
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
* @example
|
|
61
|
+
* ```json
|
|
62
|
+
* {
|
|
63
|
+
* "teambit.git/ci": {
|
|
64
|
+
* "useExplicitBumpKeywords": true
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
useExplicitBumpKeywords?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare class CiMain {
|
|
72
|
+
private workspace;
|
|
73
|
+
private builder;
|
|
74
|
+
private status;
|
|
75
|
+
private lanes;
|
|
76
|
+
private snapping;
|
|
77
|
+
private exporter;
|
|
78
|
+
private importer;
|
|
79
|
+
private checkout;
|
|
80
|
+
private logger;
|
|
81
|
+
private config;
|
|
82
|
+
static runtime: RuntimeDefinition;
|
|
83
|
+
static dependencies: any;
|
|
84
|
+
static slots: any;
|
|
85
|
+
constructor(workspace: Workspace, builder: BuilderMain, status: StatusMain, lanes: LanesMain, snapping: SnappingMain, exporter: ExportMain, importer: ImporterMain, checkout: CheckoutMain, logger: Logger, config: CiWorkspaceConfig);
|
|
86
|
+
static provider([cli, workspace, loggerAspect, builder, status, lanes, snapping, exporter, importer, checkout]: [
|
|
87
|
+
CLIMain,
|
|
88
|
+
Workspace,
|
|
89
|
+
LoggerMain,
|
|
90
|
+
BuilderMain,
|
|
91
|
+
StatusMain,
|
|
92
|
+
LanesMain,
|
|
93
|
+
SnappingMain,
|
|
94
|
+
ExportMain,
|
|
95
|
+
ImporterMain,
|
|
96
|
+
CheckoutMain
|
|
97
|
+
], config: CiWorkspaceConfig): Promise<CiMain>;
|
|
98
|
+
getBranchName(): Promise<string>;
|
|
99
|
+
getDefaultBranchName(): Promise<string>;
|
|
100
|
+
getGitCommitMessage(): Promise<string | null>;
|
|
101
|
+
private parseVersionBumpFromCommit;
|
|
102
|
+
private getCustomCommitMessage;
|
|
103
|
+
private verifyWorkspaceStatusInternal;
|
|
104
|
+
private switchToLane;
|
|
105
|
+
verifyWorkspaceStatus(): Promise<{
|
|
106
|
+
code: number;
|
|
107
|
+
data: string;
|
|
108
|
+
}>;
|
|
109
|
+
snapPrCommit({ laneIdStr, message, build, strict, }: {
|
|
110
|
+
laneIdStr: string;
|
|
111
|
+
message: string;
|
|
112
|
+
build: boolean | undefined;
|
|
113
|
+
strict: boolean | undefined;
|
|
114
|
+
}): Promise<"No changes detected, nothing to snap" | undefined>;
|
|
115
|
+
mergePr({ message: argMessage, build, strict, releaseType, preReleaseId, incrementBy, explicitVersionBump, verbose, }: {
|
|
116
|
+
message?: string;
|
|
117
|
+
build?: boolean;
|
|
118
|
+
strict?: boolean;
|
|
119
|
+
releaseType: ReleaseType;
|
|
120
|
+
preReleaseId?: string;
|
|
121
|
+
incrementBy?: number;
|
|
122
|
+
explicitVersionBump?: boolean;
|
|
123
|
+
verbose?: boolean;
|
|
124
|
+
}): Promise<{
|
|
125
|
+
code: number;
|
|
126
|
+
data: string;
|
|
127
|
+
}>;
|
|
128
|
+
/**
|
|
129
|
+
* Auto-detect version bump from commit messages if no explicit version bump was provided
|
|
130
|
+
*/
|
|
131
|
+
private determineReleaseType;
|
|
132
|
+
}
|