@teambit/ci 0.0.0-031a1d30cdf91fc70af4ca36aa0be18827e410d1

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,117 @@
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]
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
+
91
+ ### Internal flow
92
+
93
+ 1. **Ensure main lane**
94
+
95
+ ```bash
96
+ bit lane switch main # preserves working tree files
97
+ ```
98
+
99
+ 2. **Tag, build, export**
100
+
101
+ ```bash
102
+ bit install
103
+ bit tag --message "<msg>" --build --persist # --persist only if soft tags exist
104
+ bit export
105
+ ```
106
+
107
+ 3. **Archive remote lane** (house-keeping).
108
+ 4. **Commit lock-file updates**
109
+
110
+ ```bash
111
+ git add .bitmap pnpm-lock.yaml
112
+ git commit -m "chore(release): sync bitmap + lockfile"
113
+ ```
114
+
115
+ ### CI hint
116
+
117
+ Gate this step behind a branch-protection rule so only fast-forward merges trigger a release.
@@ -0,0 +1,36 @@
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
+ type Options = {
7
+ message?: string;
8
+ build?: boolean;
9
+ strict?: boolean;
10
+ };
11
+
12
+ export class CiMergeCmd implements Command {
13
+ name = 'merge';
14
+ description = 'Merges a PR';
15
+ group = 'collaborate';
16
+
17
+ options: CommandOptions = [
18
+ ['m', 'message <message>', 'If set, use it as the snap message, if not, try and grab from git-commit-message'],
19
+ ['b', 'build', 'Set to true to build the app locally, false (default) will build on Ripple CI'],
20
+ ['s', 'strict', 'Set to true to fail on warnings as well as errors, false (default) only fails on errors'],
21
+ ];
22
+
23
+ constructor(
24
+ private workspace: Workspace,
25
+ private logger: Logger,
26
+ private ci: CiMain
27
+ ) {}
28
+
29
+ async report(args: unknown, options: Options) {
30
+ this.logger.console('\n\n');
31
+ this.logger.console('🚀 Initializing Merge command');
32
+ if (!this.workspace) throw new OutsideWorkspaceError();
33
+
34
+ return this.ci.mergePr({ message: options.message, build: options.build, strict: options.strict });
35
+ }
36
+ }
@@ -0,0 +1,70 @@
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 branch: string;
37
+ let message: string;
38
+
39
+ if (options.lane) {
40
+ branch = 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
+ branch = `${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
+ return this.ci.snapPrCommit({
64
+ branch,
65
+ message,
66
+ build: options.build,
67
+ strict: options.strict,
68
+ });
69
+ }
70
+ }
@@ -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":[]}
@@ -0,0 +1,117 @@
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]
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
+
91
+ ### Internal flow
92
+
93
+ 1. **Ensure main lane**
94
+
95
+ ```bash
96
+ bit lane switch main # preserves working tree files
97
+ ```
98
+
99
+ 2. **Tag, build, export**
100
+
101
+ ```bash
102
+ bit install
103
+ bit tag --message "<msg>" --build --persist # --persist only if soft tags exist
104
+ bit export
105
+ ```
106
+
107
+ 3. **Archive remote lane** (house-keeping).
108
+ 4. **Commit lock-file updates**
109
+
110
+ ```bash
111
+ git add .bitmap pnpm-lock.yaml
112
+ git commit -m "chore(release): sync bitmap + lockfile"
113
+ ```
114
+
115
+ ### CI hint
116
+
117
+ Gate this step behind a branch-protection rule so only fast-forward merges trigger a release.
@@ -0,0 +1,64 @@
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
+ export declare class CiMain {
13
+ private workspace;
14
+ private builder;
15
+ private status;
16
+ private lanes;
17
+ private snapping;
18
+ private exporter;
19
+ private importer;
20
+ private checkout;
21
+ private logger;
22
+ static runtime: RuntimeDefinition;
23
+ static dependencies: any;
24
+ static slots: any;
25
+ constructor(workspace: Workspace, builder: BuilderMain, status: StatusMain, lanes: LanesMain, snapping: SnappingMain, exporter: ExportMain, importer: ImporterMain, checkout: CheckoutMain, logger: Logger);
26
+ static provider([cli, workspace, loggerAspect, builder, status, lanes, snapping, exporter, importer, checkout,]: [
27
+ CLIMain,
28
+ Workspace,
29
+ LoggerMain,
30
+ BuilderMain,
31
+ StatusMain,
32
+ LanesMain,
33
+ SnappingMain,
34
+ ExportMain,
35
+ ImporterMain,
36
+ CheckoutMain
37
+ ]): Promise<CiMain>;
38
+ getBranchName(): Promise<string>;
39
+ getDefaultBranchName(): Promise<string>;
40
+ getGitCommitMessage(): Promise<string | null>;
41
+ private verifyWorkspaceStatusInternal;
42
+ private switchToLane;
43
+ verifyWorkspaceStatus(): Promise<{
44
+ code: number;
45
+ data: string;
46
+ }>;
47
+ snapPrCommit({ branch, message, build, strict, }: {
48
+ branch: string;
49
+ message: string;
50
+ build: boolean | undefined;
51
+ strict: boolean | undefined;
52
+ }): Promise<string | {
53
+ code: number;
54
+ data: string;
55
+ }>;
56
+ mergePr({ message: argMessage, build, strict }: {
57
+ message?: string;
58
+ build?: boolean;
59
+ strict?: boolean;
60
+ }): Promise<{
61
+ code: number;
62
+ data: string;
63
+ }>;
64
+ }