@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 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,78 @@
1
+ import type { Command, CommandOptions } from '@teambit/cli';
2
+ import type { Logger } from '@teambit/logger';
3
+ import { OutsideWorkspaceError, type Workspace } from '@teambit/workspace';
4
+ import { ReleaseType } from 'semver';
5
+ import { validateOptions } from '@teambit/snapping';
6
+ import { CiMain } from '../ci.main.runtime';
7
+
8
+ type Options = {
9
+ message?: string;
10
+ build?: boolean;
11
+ strict?: boolean;
12
+ increment?: ReleaseType;
13
+ patch?: boolean;
14
+ minor?: boolean;
15
+ major?: boolean;
16
+ preRelease?: string;
17
+ prereleaseId?: string;
18
+ incrementBy?: number;
19
+ verbose?: boolean;
20
+ };
21
+
22
+ export class CiMergeCmd implements Command {
23
+ name = 'merge';
24
+ description = 'Merges a PR';
25
+ group = 'collaborate';
26
+
27
+ options: CommandOptions = [
28
+ ['m', 'message <message>', 'If set, use it as the tag message, if not, try and grab from git-commit-message'],
29
+ ['b', 'build', 'Set to true to build the app locally, false (default) will build on Ripple CI'],
30
+ ['s', 'strict', 'Set to true to fail on warnings as well as errors, false (default) only fails on errors'],
31
+ [
32
+ 'l',
33
+ 'increment <level>',
34
+ 'options are: [major, premajor, minor, preminor, patch, prepatch, prerelease], default to patch',
35
+ ],
36
+ ['', 'prerelease-id <id>', 'prerelease identifier (e.g. "dev" to get "1.0.0-dev.1")'],
37
+ ['p', 'patch', 'syntactic sugar for "--increment patch"'],
38
+ ['', 'minor', 'syntactic sugar for "--increment minor"'],
39
+ ['', 'major', 'syntactic sugar for "--increment major"'],
40
+ ['', 'pre-release [identifier]', 'syntactic sugar for "--increment prerelease" and `--prerelease-id <identifier>`'],
41
+ [
42
+ '',
43
+ 'increment-by <number>',
44
+ '(default to 1) increment semver flag (patch/minor/major) by. e.g. incrementing patch by 2: 0.0.1 -> 0.0.3.',
45
+ ],
46
+ ['', 'verbose', 'show verbose output'],
47
+ ];
48
+
49
+ constructor(
50
+ private workspace: Workspace,
51
+ private logger: Logger,
52
+ private ci: CiMain
53
+ ) {}
54
+
55
+ async report(args: unknown, options: Options) {
56
+ this.logger.console('\n\n');
57
+ this.logger.console('🚀 Initializing Merge command');
58
+ if (!this.workspace) throw new OutsideWorkspaceError();
59
+
60
+ const { releaseType, preReleaseId } = validateOptions(options);
61
+
62
+ // Check if user explicitly provided any version bump flags
63
+ const explicitVersionBump = Boolean(
64
+ options.increment || options.patch || options.minor || options.major || options.preRelease
65
+ );
66
+
67
+ return this.ci.mergePr({
68
+ message: options.message,
69
+ build: options.build,
70
+ strict: options.strict,
71
+ releaseType,
72
+ preReleaseId,
73
+ incrementBy: options.incrementBy,
74
+ explicitVersionBump,
75
+ verbose: options.verbose,
76
+ });
77
+ }
78
+ }
@@ -0,0 +1,76 @@
1
+ import type { Command, CommandOptions } from '@teambit/cli';
2
+ import type { Logger } from '@teambit/logger';
3
+ import { OutsideWorkspaceError, type Workspace } from '@teambit/workspace';
4
+ import type { CiMain } from '../ci.main.runtime';
5
+
6
+ type Options = {
7
+ message?: string;
8
+ build?: boolean;
9
+ lane?: string;
10
+ strict?: boolean;
11
+ };
12
+
13
+ export class CiPrCmd implements Command {
14
+ name = 'pr';
15
+ description = 'This command is meant to run when a PR was open/updated and meant to export a lane to bit-cloud.';
16
+ group = 'collaborate';
17
+
18
+ options: CommandOptions = [
19
+ ['m', 'message <message>', 'If set, set it as the snap message, if not, try and grab from git-commit-message'],
20
+ ['l', 'lane <lane>', 'If set, use as the lane name, if not available, grab from git-branch name'],
21
+ ['b', 'build', 'Set to true to build the app locally, false (default) will build on Ripple CI'],
22
+ ['s', 'strict', 'Set to true to fail on warnings as well as errors, false (default) only fails on errors'],
23
+ ];
24
+
25
+ constructor(
26
+ private workspace: Workspace,
27
+ private logger: Logger,
28
+ private ci: CiMain
29
+ ) {}
30
+
31
+ async report(args: unknown, options: Options) {
32
+ this.logger.console('\n\n');
33
+ this.logger.console('🚀 Initializing PR command');
34
+ if (!this.workspace) throw new OutsideWorkspaceError();
35
+
36
+ let laneIdStr: string;
37
+ let message: string;
38
+
39
+ if (options.lane) {
40
+ laneIdStr = options.lane;
41
+ } else {
42
+ const currentBranch = await this.ci.getBranchName().catch((e) => {
43
+ throw new Error(`Failed to get branch name from Git: ${e.toString()}`);
44
+ });
45
+ if (!currentBranch) {
46
+ throw new Error('Failed to get branch name');
47
+ }
48
+ // Sanitize branch name to make it valid for Bit lane IDs by replacing slashes with dashes
49
+ const sanitizedBranch = currentBranch.replace(/\//g, '-');
50
+ laneIdStr = `${this.workspace.defaultScope}/${sanitizedBranch}`;
51
+ }
52
+
53
+ if (options.message) {
54
+ message = options.message;
55
+ } else {
56
+ const commitMessage = await this.ci.getGitCommitMessage();
57
+ if (!commitMessage) {
58
+ throw new Error('Failed to get commit message');
59
+ }
60
+ message = commitMessage;
61
+ }
62
+
63
+ const results = await this.ci.snapPrCommit({
64
+ laneIdStr: laneIdStr,
65
+ message,
66
+ build: options.build,
67
+ strict: options.strict,
68
+ });
69
+
70
+ if (results) {
71
+ return results;
72
+ }
73
+
74
+ return `PR command executed successfully`;
75
+ }
76
+ }
@@ -0,0 +1,25 @@
1
+ import type { Command, CommandOptions } from '@teambit/cli';
2
+ import type { Logger } from '@teambit/logger';
3
+ import { OutsideWorkspaceError, type Workspace } from '@teambit/workspace';
4
+ import { CiMain } from '../ci.main.runtime';
5
+
6
+ export class CiVerifyCmd implements Command {
7
+ name = 'verify';
8
+ description = 'CI commands';
9
+ group = 'development';
10
+
11
+ options: CommandOptions = [];
12
+
13
+ constructor(
14
+ private workspace: Workspace,
15
+ private logger: Logger,
16
+ private ci: CiMain
17
+ ) {}
18
+
19
+ async report() {
20
+ this.logger.console('\n\n🚀 Initializing Verify command');
21
+ if (!this.workspace) throw new OutsideWorkspaceError();
22
+
23
+ return this.ci.verifyWorkspaceStatus();
24
+ }
25
+ }
@@ -0,0 +1,3 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const CiAspect: Aspect;
3
+ export default CiAspect;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.CiAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const CiAspect = exports.CiAspect = _harmony().Aspect.create({
15
+ id: 'teambit.git/ci'
16
+ });
17
+ var _default = exports.default = CiAspect;
18
+
19
+ //# sourceMappingURL=ci.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","CiAspect","exports","Aspect","create","id","_default","default"],"sources":["ci.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const CiAspect = Aspect.create({\n id: 'teambit.git/ci',\n});\n\nexport default CiAspect;\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EACpCC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAJ,OAAA,CAAAK,OAAA,GAEYN,QAAQ","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import type { Command, CommandOptions } from '@teambit/cli';
2
+ import type { Logger } from '@teambit/logger';
3
+ import type { Workspace } from '@teambit/workspace';
4
+ export declare class CiCmd implements Command {
5
+ private workspace;
6
+ private logger;
7
+ name: string;
8
+ description: string;
9
+ group: string;
10
+ options: CommandOptions;
11
+ commands: Command[];
12
+ constructor(workspace: Workspace, logger: Logger);
13
+ report(): Promise<{
14
+ code: number;
15
+ data: string;
16
+ }>;
17
+ }
package/dist/ci.cmd.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CiCmd = void 0;
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ class CiCmd {
11
+ constructor(workspace, logger) {
12
+ this.workspace = workspace;
13
+ this.logger = logger;
14
+ _defineProperty(this, "name", 'ci <sub-command>');
15
+ _defineProperty(this, "description", 'CI commands');
16
+ _defineProperty(this, "group", 'collaborate');
17
+ _defineProperty(this, "options", []);
18
+ _defineProperty(this, "commands", []);
19
+ }
20
+ async report() {
21
+ return {
22
+ code: 1,
23
+ data: '[ci] not implemented'
24
+ };
25
+ }
26
+ }
27
+ exports.CiCmd = CiCmd;
28
+
29
+ //# sourceMappingURL=ci.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CiCmd","constructor","workspace","logger","_defineProperty","report","code","data","exports"],"sources":["ci.cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from '@teambit/cli';\nimport type { Logger } from '@teambit/logger';\nimport type { Workspace } from '@teambit/workspace';\n\nexport class CiCmd implements Command {\n name = 'ci <sub-command>';\n description = 'CI commands';\n group = 'collaborate';\n\n options: CommandOptions = [];\n commands: Command[] = [];\n\n constructor(\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n async report() {\n return { code: 1, data: '[ci] not implemented' };\n }\n}\n"],"mappings":";;;;;;;;;AAIO,MAAMA,KAAK,CAAoB;EAQpCC,WAAWA,CACDC,SAAoB,EACpBC,MAAc,EACtB;IAAA,KAFQD,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAAC,eAAA,eATjB,kBAAkB;IAAAA,eAAA,sBACX,aAAa;IAAAA,eAAA,gBACnB,aAAa;IAAAA,eAAA,kBAEK,EAAE;IAAAA,eAAA,mBACN,EAAE;EAKrB;EAEH,MAAMC,MAAMA,CAAA,EAAG;IACb,OAAO;MAAEC,IAAI,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAuB,CAAC;EAClD;AACF;AAACC,OAAA,CAAAR,KAAA,GAAAA,KAAA","ignoreList":[]}