@teambit/ci 0.0.0-0116fb794cbc27e424eae2192c63c5225562b86d
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 +107 -0
- package/commands/pr.cmd.ts +75 -0
- package/commands/verify.cmd.ts +26 -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 +156 -0
- package/dist/ci.main.runtime.js +715 -0
- package/dist/ci.main.runtime.js.map +1 -0
- package/dist/commands/merge.cmd.d.ts +39 -0
- package/dist/commands/merge.cmd.js +76 -0
- package/dist/commands/merge.cmd.js.map +1 -0
- package/dist/commands/pr.cmd.d.ts +23 -0
- package/dist/commands/pr.cmd.js +68 -0
- package/dist/commands/pr.cmd.js.map +1 -0
- package/dist/commands/verify.cmd.d.ts +19 -0
- package/dist/commands/verify.cmd.js +36 -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-1756863251924.js +7 -0
- package/dist/source-branch-detector.d.ts +55 -0
- package/dist/source-branch-detector.js +255 -0
- package/dist/source-branch-detector.js.map +1 -0
- package/package.json +67 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
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,107 @@
|
|
|
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 { ReleaseType } from 'semver';
|
|
5
|
+
import { validateOptions } from '@teambit/snapping';
|
|
6
|
+
import { BitError } from '@teambit/bit-error';
|
|
7
|
+
import type { MergeStrategy } from '@teambit/component.modules.merge-helper';
|
|
8
|
+
import type { CiMain } from '../ci.main.runtime';
|
|
9
|
+
|
|
10
|
+
type Options = {
|
|
11
|
+
message?: string;
|
|
12
|
+
build?: boolean;
|
|
13
|
+
strict?: boolean;
|
|
14
|
+
increment?: ReleaseType;
|
|
15
|
+
patch?: boolean;
|
|
16
|
+
minor?: boolean;
|
|
17
|
+
major?: boolean;
|
|
18
|
+
preRelease?: string;
|
|
19
|
+
prereleaseId?: string;
|
|
20
|
+
incrementBy?: number;
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
versionsFile?: string;
|
|
23
|
+
autoMergeResolve?: MergeStrategy;
|
|
24
|
+
forceTheirs?: boolean;
|
|
25
|
+
laneName?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export class CiMergeCmd implements Command {
|
|
29
|
+
name = 'merge';
|
|
30
|
+
description = 'Tags and exports new semantic versions after merging a PR to main.';
|
|
31
|
+
extendedDescription = `By default, bumps patch versions when merging to main. If specific configuration variables are set, it can use commit messages or explicit flags to determine the version bump. Runs install, tag, build, and export, then archives the remote lane and syncs lockfiles. Use in merge-to-main CI pipelines to publish releases.`;
|
|
32
|
+
group = 'collaborate';
|
|
33
|
+
|
|
34
|
+
options: CommandOptions = [
|
|
35
|
+
['m', 'message <message>', 'If set, use it as the tag message, if not, try and grab from git-commit-message'],
|
|
36
|
+
['b', 'build', 'Set to true to build the app locally, false (default) will build on Ripple CI'],
|
|
37
|
+
['s', 'strict', 'Set to true to fail on warnings as well as errors, false (default) only fails on errors'],
|
|
38
|
+
[
|
|
39
|
+
'l',
|
|
40
|
+
'increment <level>',
|
|
41
|
+
'options are: [major, premajor, minor, preminor, patch, prepatch, prerelease], default to patch',
|
|
42
|
+
],
|
|
43
|
+
['', 'prerelease-id <id>', 'prerelease identifier (e.g. "dev" to get "1.0.0-dev.1")'],
|
|
44
|
+
['p', 'patch', 'syntactic sugar for "--increment patch"'],
|
|
45
|
+
['', 'minor', 'syntactic sugar for "--increment minor"'],
|
|
46
|
+
['', 'major', 'syntactic sugar for "--increment major"'],
|
|
47
|
+
['', 'pre-release [identifier]', 'syntactic sugar for "--increment prerelease" and `--prerelease-id <identifier>`'],
|
|
48
|
+
[
|
|
49
|
+
'',
|
|
50
|
+
'increment-by <number>',
|
|
51
|
+
'(default to 1) increment semver flag (patch/minor/major) by. e.g. incrementing patch by 2: 0.0.1 -> 0.0.3.',
|
|
52
|
+
],
|
|
53
|
+
['', 'versions-file <path>', 'path to a file containing component versions. format: "component-id: version"'],
|
|
54
|
+
['', 'verbose', 'show verbose output'],
|
|
55
|
+
[
|
|
56
|
+
'r',
|
|
57
|
+
'auto-merge-resolve <merge-strategy>',
|
|
58
|
+
'in case of merge conflict during checkout, resolve according to the provided strategy: [ours, theirs, manual]',
|
|
59
|
+
],
|
|
60
|
+
['', 'force-theirs', 'do not merge during checkout, just overwrite with incoming files'],
|
|
61
|
+
['', 'lane-name <name>', 'specify the lane name to delete after merge (auto-detected if not provided)'],
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
constructor(
|
|
65
|
+
private workspace: Workspace,
|
|
66
|
+
private logger: Logger,
|
|
67
|
+
private ci: CiMain
|
|
68
|
+
) {}
|
|
69
|
+
|
|
70
|
+
async report(args: unknown, options: Options) {
|
|
71
|
+
this.logger.console('\n\n');
|
|
72
|
+
this.logger.console('🚀 Initializing Merge command');
|
|
73
|
+
if (!this.workspace) throw new OutsideWorkspaceError();
|
|
74
|
+
|
|
75
|
+
// Validate autoMergeResolve option
|
|
76
|
+
if (
|
|
77
|
+
options.autoMergeResolve &&
|
|
78
|
+
options.autoMergeResolve !== 'ours' &&
|
|
79
|
+
options.autoMergeResolve !== 'theirs' &&
|
|
80
|
+
options.autoMergeResolve !== 'manual'
|
|
81
|
+
) {
|
|
82
|
+
throw new BitError('--auto-merge-resolve must be one of the following: [ours, theirs, manual]');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { releaseType, preReleaseId } = validateOptions(options);
|
|
86
|
+
|
|
87
|
+
// Check if user explicitly provided any version bump flags
|
|
88
|
+
const explicitVersionBump = Boolean(
|
|
89
|
+
options.increment || options.patch || options.minor || options.major || options.preRelease
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return this.ci.mergePr({
|
|
93
|
+
message: options.message,
|
|
94
|
+
build: options.build,
|
|
95
|
+
strict: options.strict,
|
|
96
|
+
releaseType,
|
|
97
|
+
preReleaseId,
|
|
98
|
+
incrementBy: options.incrementBy,
|
|
99
|
+
explicitVersionBump,
|
|
100
|
+
verbose: options.verbose,
|
|
101
|
+
versionsFile: options.versionsFile,
|
|
102
|
+
autoMergeResolve: options.autoMergeResolve,
|
|
103
|
+
forceTheirs: options.forceTheirs,
|
|
104
|
+
laneName: options.laneName,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 = 'Exports a feature lane to Bit Cloud when a Pull Request is opened or updated.';
|
|
16
|
+
extendedDescription = `Resolves the lane name from --lane or the current Git branch, validates it, and runs install, status, snap, and export. Cleans up by switching back to main. Use in pull-request CI pipelines after tests and before deploy.`;
|
|
17
|
+
group = 'collaborate';
|
|
18
|
+
|
|
19
|
+
options: CommandOptions = [
|
|
20
|
+
['m', 'message <message>', 'If set, set it as the snap message, if not, try and grab from git-commit-message'],
|
|
21
|
+
['l', 'lane <lane>', 'If set, use as the lane name, if not available, grab from git-branch name'],
|
|
22
|
+
['b', 'build', 'Set to true to build the app locally, false (default) will build on Ripple CI'],
|
|
23
|
+
['s', 'strict', 'Set to true to fail on warnings as well as errors, false (default) only fails on errors'],
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
private workspace: Workspace,
|
|
28
|
+
private logger: Logger,
|
|
29
|
+
private ci: CiMain
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
async report(args: unknown, options: Options) {
|
|
33
|
+
this.logger.console('\n\n');
|
|
34
|
+
this.logger.console('🚀 Initializing PR command');
|
|
35
|
+
if (!this.workspace) throw new OutsideWorkspaceError();
|
|
36
|
+
|
|
37
|
+
let laneIdStr: string;
|
|
38
|
+
let message: string;
|
|
39
|
+
|
|
40
|
+
if (options.lane) {
|
|
41
|
+
laneIdStr = options.lane;
|
|
42
|
+
} else {
|
|
43
|
+
const currentBranch = await this.ci.getBranchName().catch((e) => {
|
|
44
|
+
throw new Error(`Failed to get branch name from Git: ${e.toString()}`);
|
|
45
|
+
});
|
|
46
|
+
if (!currentBranch) {
|
|
47
|
+
throw new Error('Failed to get branch name');
|
|
48
|
+
}
|
|
49
|
+
laneIdStr = this.ci.convertBranchToLaneId(currentBranch);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (options.message) {
|
|
53
|
+
message = options.message;
|
|
54
|
+
} else {
|
|
55
|
+
const commitMessage = await this.ci.getGitCommitMessage();
|
|
56
|
+
if (!commitMessage) {
|
|
57
|
+
throw new Error('Failed to get commit message');
|
|
58
|
+
}
|
|
59
|
+
message = commitMessage;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const results = await this.ci.snapPrCommit({
|
|
63
|
+
laneIdStr: laneIdStr,
|
|
64
|
+
message,
|
|
65
|
+
build: options.build,
|
|
66
|
+
strict: options.strict,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (results) {
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return `PR command executed successfully`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export class CiVerifyCmd implements Command {
|
|
7
|
+
name = 'verify';
|
|
8
|
+
description = 'Ensures the workspace passes CI checks on every commit.';
|
|
9
|
+
extendedDescription = `Runs lint, build, and status checks to catch dependency drift or broken builds early. Typically used as a pre-push hook or early CI job. Stops at the first failing step and returns a non-zero exit code.`;
|
|
10
|
+
group = 'development';
|
|
11
|
+
|
|
12
|
+
options: CommandOptions = [];
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
private workspace: Workspace,
|
|
16
|
+
private logger: Logger,
|
|
17
|
+
private ci: CiMain
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
async report() {
|
|
21
|
+
this.logger.console('\n\n🚀 Initializing Verify command');
|
|
22
|
+
if (!this.workspace) throw new OutsideWorkspaceError();
|
|
23
|
+
|
|
24
|
+
return this.ci.verifyWorkspaceStatus();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -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":[]}
|
package/dist/ci.cmd.d.ts
ADDED
|
@@ -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":[]}
|