@teambit/ci 1.0.636 → 1.0.638
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 +13 -7
- package/commands/sync.cmd.ts +5 -2
- package/dist/ci.docs.mdx +13 -7
- package/dist/ci.main.runtime.d.ts +6 -4
- package/dist/ci.main.runtime.js +19 -13
- package/dist/ci.main.runtime.js.map +1 -1
- package/dist/commands/sync.cmd.js +5 -2
- package/dist/commands/sync.cmd.js.map +1 -1
- package/dist/{preview-1792527927744.js → preview-1792591009402.js} +1 -1
- package/dist/sync/init-scaffold.d.ts +89 -12
- package/dist/sync/init-scaffold.js +208 -21
- package/dist/sync/init-scaffold.js.map +1 -1
- package/dist/sync/init-scaffold.spec.js +295 -45
- package/dist/sync/init-scaffold.spec.js.map +1 -1
- package/dist/sync/sync-orchestrator.d.ts +3 -1
- package/dist/sync/sync-orchestrator.js +84 -14
- package/dist/sync/sync-orchestrator.js.map +1 -1
- package/package.json +23 -23
- package/sync/init-scaffold.spec.ts +314 -52
- package/sync/init-scaffold.ts +341 -55
- package/sync/sync-orchestrator.ts +89 -22
package/ci.docs.mdx
CHANGED
|
@@ -243,16 +243,22 @@ bit ci sync --init
|
|
|
243
243
|
```
|
|
244
244
|
|
|
245
245
|
`--init` writes `.github/workflows/bit-sync.yml` and `bit-release.yml`, with the real default branch of this
|
|
246
|
-
repository in both files.
|
|
246
|
+
repository in both files. When the workspace is below the repository root, `--init` writes the files at the
|
|
247
|
+
root and sets `ws-dir` to the workspace directory in both. `--init` adds `"teambit.git/ci": { "sync": {} }` to `workspace.jsonc` if the key is
|
|
247
248
|
absent. The edit keeps the comments in the file, and it changes no existing `sync` setting. `--init` then
|
|
248
|
-
prints the steps that need a person:
|
|
249
|
+
prints one short report: the files it changed, and three steps that need a person, as commands to paste:
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
1. Commit the files `--init` changed, and push. With no `origin`, create the repository with `gh repo create`.
|
|
252
|
+
2. Set the `BIT_CONFIG_ACCESS_TOKEN` secret, allow GitHub Actions to open pull requests, and optionally set
|
|
253
|
+
the `BIT_SYNC_GH_TOKEN` secret.
|
|
254
|
+
3. Optional: make Bit -> Git instant. On github.com, install the `bit-git-sync` GitHub App and add its
|
|
255
|
+
webhook URL to the scope. On GitHub Enterprise Server, add a webhook that calls the repository
|
|
256
|
+
`dispatches` API.
|
|
254
257
|
|
|
255
|
-
|
|
258
|
+
The commands name the repository of `origin`. When `origin` is not a GitHub remote yet, `--init` prints
|
|
259
|
+
only the push step, then tells you to run `--init` again after you push.
|
|
260
|
+
|
|
261
|
+
`--init` reports an existing file as unchanged, and overwrites no file, so a second run is safe. `--init`
|
|
256
262
|
writes the files, then exits. Do not combine `--init` with a lane argument or with another flag.
|
|
257
263
|
|
|
258
264
|
### Usage
|
package/commands/sync.cmd.ts
CHANGED
|
@@ -61,9 +61,12 @@ export class CiSyncCmd implements Command {
|
|
|
61
61
|
// `[lane]: [string]` rather than `[string?]`: `CLIArgs` does not admit an undefined-carrying tuple.
|
|
62
62
|
// The argument is genuinely optional at runtime, hence the `|| undefined` below.
|
|
63
63
|
async report([lane]: [string], options: Options) {
|
|
64
|
-
this.logger.console('\n\n');
|
|
65
|
-
this.logger.console('Initializing sync command');
|
|
66
64
|
if (!this.workspace) throw new OutsideWorkspaceError();
|
|
65
|
+
// --init prints its own report; the banner only frames a reconcile run.
|
|
66
|
+
if (!options.init) {
|
|
67
|
+
this.logger.console('\n\n');
|
|
68
|
+
this.logger.console('Initializing sync command');
|
|
69
|
+
}
|
|
67
70
|
|
|
68
71
|
return this.ci.sync({
|
|
69
72
|
lane: lane || undefined,
|
package/dist/ci.docs.mdx
CHANGED
|
@@ -243,16 +243,22 @@ bit ci sync --init
|
|
|
243
243
|
```
|
|
244
244
|
|
|
245
245
|
`--init` writes `.github/workflows/bit-sync.yml` and `bit-release.yml`, with the real default branch of this
|
|
246
|
-
repository in both files.
|
|
246
|
+
repository in both files. When the workspace is below the repository root, `--init` writes the files at the
|
|
247
|
+
root and sets `ws-dir` to the workspace directory in both. `--init` adds `"teambit.git/ci": { "sync": {} }` to `workspace.jsonc` if the key is
|
|
247
248
|
absent. The edit keeps the comments in the file, and it changes no existing `sync` setting. `--init` then
|
|
248
|
-
prints the steps that need a person:
|
|
249
|
+
prints one short report: the files it changed, and three steps that need a person, as commands to paste:
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
1. Commit the files `--init` changed, and push. With no `origin`, create the repository with `gh repo create`.
|
|
252
|
+
2. Set the `BIT_CONFIG_ACCESS_TOKEN` secret, allow GitHub Actions to open pull requests, and optionally set
|
|
253
|
+
the `BIT_SYNC_GH_TOKEN` secret.
|
|
254
|
+
3. Optional: make Bit -> Git instant. On github.com, install the `bit-git-sync` GitHub App and add its
|
|
255
|
+
webhook URL to the scope. On GitHub Enterprise Server, add a webhook that calls the repository
|
|
256
|
+
`dispatches` API.
|
|
254
257
|
|
|
255
|
-
|
|
258
|
+
The commands name the repository of `origin`. When `origin` is not a GitHub remote yet, `--init` prints
|
|
259
|
+
only the push step, then tells you to run `--init` again after you push.
|
|
260
|
+
|
|
261
|
+
`--init` reports an existing file as unchanged, and overwrites no file, so a second run is safe. `--init`
|
|
256
262
|
writes the files, then exits. Do not combine `--init` with a lane argument or with another flag.
|
|
257
263
|
|
|
258
264
|
### Usage
|
|
@@ -137,14 +137,16 @@ export declare class CiMain {
|
|
|
137
137
|
convertBranchToLaneId(branchName: string): string;
|
|
138
138
|
/**
|
|
139
139
|
* The repository's default branch name, whole — slashes included (see `parseOriginHeadRef`).
|
|
140
|
-
*
|
|
140
|
+
* What `detectDefaultBranchName` finds, else `master`, with a warning that names it.
|
|
141
141
|
*/
|
|
142
142
|
getDefaultBranchName(): Promise<string>;
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
144
|
+
* The default branch as the repository itself states it: the local `origin/HEAD` symref, then the
|
|
145
|
+
* remote's own answer, then `main`/`master` among the remote branches. Undefined when none of them
|
|
146
|
+
* answers (no origin, a repository not pushed yet, a server out of reach), so a caller can tell a
|
|
147
|
+
* detected branch from a guess.
|
|
146
148
|
*/
|
|
147
|
-
|
|
149
|
+
detectDefaultBranchName(): Promise<string | undefined>;
|
|
148
150
|
getGitCommitMessage(): Promise<string | null>;
|
|
149
151
|
private parseVersionBumpFromCommit;
|
|
150
152
|
private getCustomCommitMessage;
|
package/dist/ci.main.runtime.js
CHANGED
|
@@ -423,9 +423,22 @@ class CiMain {
|
|
|
423
423
|
|
|
424
424
|
/**
|
|
425
425
|
* The repository's default branch name, whole — slashes included (see `parseOriginHeadRef`).
|
|
426
|
-
*
|
|
426
|
+
* What `detectDefaultBranchName` finds, else `master`, with a warning that names it.
|
|
427
427
|
*/
|
|
428
428
|
async getDefaultBranchName() {
|
|
429
|
+
const detected = await this.detectDefaultBranchName();
|
|
430
|
+
if (detected) return detected;
|
|
431
|
+
this.logger.console(_chalk().default.yellow(`Unable to detect default branch, using 'master'`));
|
|
432
|
+
return 'master';
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* The default branch as the repository itself states it: the local `origin/HEAD` symref, then the
|
|
437
|
+
* remote's own answer, then `main`/`master` among the remote branches. Undefined when none of them
|
|
438
|
+
* answers (no origin, a repository not pushed yet, a server out of reach), so a caller can tell a
|
|
439
|
+
* detected branch from a guess.
|
|
440
|
+
*/
|
|
441
|
+
async detectDefaultBranchName() {
|
|
429
442
|
try {
|
|
430
443
|
const result = await _git().git.raw(['symbolic-ref', 'refs/remotes/origin/HEAD']);
|
|
431
444
|
const local = (0, _gitOps().parseOriginHeadRef)(result);
|
|
@@ -438,23 +451,16 @@ class CiMain {
|
|
|
438
451
|
}
|
|
439
452
|
const remote = await (0, _gitOps().remoteHeadBranch)();
|
|
440
453
|
if (remote && (0, _syncConfig().isValidGitBranchName)(remote)) return remote;
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Last-resort fallback: the two conventional names among the remote branches, then `master`.
|
|
446
|
-
* Deliberately only `main`/`master` — any wider guess risks protecting the wrong branch.
|
|
447
|
-
*/
|
|
448
|
-
async probeDefaultBranchName(originalError) {
|
|
454
|
+
// Deliberately only `main`/`master` — any wider guess risks protecting the wrong branch.
|
|
449
455
|
try {
|
|
450
456
|
const branches = await _git().git.branch(['-r']);
|
|
451
457
|
if (branches.all.includes('origin/main')) return 'main';
|
|
452
458
|
if (branches.all.includes('origin/master')) return 'master';
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
this.logger.
|
|
456
|
-
return 'master';
|
|
459
|
+
} catch (err) {
|
|
460
|
+
// debug only: the caller decides what to say, and what to use instead
|
|
461
|
+
this.logger.debug(`detectDefaultBranchName: "git branch -r" failed: ${err.message}`);
|
|
457
462
|
}
|
|
463
|
+
return undefined;
|
|
458
464
|
}
|
|
459
465
|
async getGitCommitMessage() {
|
|
460
466
|
try {
|