@teambit/ci 1.0.522 → 1.0.524
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 +26 -13
- package/commands/sync.cmd.ts +2 -2
- package/dist/ci.docs.mdx +26 -13
- package/dist/commands/sync.cmd.js +2 -2
- package/dist/commands/sync.cmd.js.map +1 -1
- package/dist/{preview-1787250962708.js → preview-1787264602520.js} +1 -1
- package/dist/sync/heal-missing-main-files.d.ts +36 -0
- package/dist/sync/heal-missing-main-files.js +180 -0
- package/dist/sync/heal-missing-main-files.js.map +1 -0
- package/dist/sync/lane-sync-executor.d.ts +37 -19
- package/dist/sync/lane-sync-executor.js +102 -42
- package/dist/sync/lane-sync-executor.js.map +1 -1
- package/dist/sync/lane-sync-executor.spec.js +67 -9
- package/dist/sync/lane-sync-executor.spec.js.map +1 -1
- package/dist/sync/main-sync-executor.d.ts +3 -0
- package/dist/sync/main-sync-executor.js +23 -4
- package/dist/sync/main-sync-executor.js.map +1 -1
- package/dist/sync/sync-orchestrator.js +1 -0
- package/dist/sync/sync-orchestrator.js.map +1 -1
- package/package.json +15 -13
- package/sync/heal-missing-main-files.ts +153 -0
- package/sync/lane-sync-executor.spec.ts +80 -10
- package/sync/lane-sync-executor.ts +123 -46
- package/sync/main-sync-executor.ts +38 -3
- package/sync/sync-orchestrator.ts +1 -0
|
@@ -3,11 +3,14 @@ import { formatWarningSummary } from '@teambit/cli';
|
|
|
3
3
|
import type { Logger } from '@teambit/logger';
|
|
4
4
|
import type { LanesMain } from '@teambit/lanes';
|
|
5
5
|
import type { CheckoutMain } from '@teambit/checkout';
|
|
6
|
+
import type { Workspace } from '@teambit/workspace';
|
|
6
7
|
import { git } from '../git';
|
|
7
8
|
import type { CiMain } from '../ci.main.runtime';
|
|
8
9
|
import type { CiSyncConfig } from './sync-config';
|
|
9
10
|
import { SYNC_COMMIT_MARKER, isSyncAuthoredMessage } from './sync-state';
|
|
10
11
|
import { currentLaneIdStr } from './workspace-lane';
|
|
12
|
+
import type { MainFileHeal } from './heal-missing-main-files';
|
|
13
|
+
import { healMissingMainFiles } from './heal-missing-main-files';
|
|
11
14
|
import type { GitHostProvider } from './git-host-provider';
|
|
12
15
|
import { HALT_SUMMARY_PREFIX, capEntries } from './lane-sync-executor';
|
|
13
16
|
import {
|
|
@@ -28,6 +31,8 @@ import {
|
|
|
28
31
|
export type MainSyncDeps = {
|
|
29
32
|
checkout: CheckoutMain;
|
|
30
33
|
lanes: LanesMain;
|
|
34
|
+
/** for the pre-checkout `.bitmap` heal (see `heal-missing-main-files`) */
|
|
35
|
+
workspace: Workspace;
|
|
31
36
|
/** for reloadWorkspaceFromDisk + switchToLaneForSync */
|
|
32
37
|
ci: CiMain;
|
|
33
38
|
logger: Logger;
|
|
@@ -108,6 +113,11 @@ export class MainSyncExecutor {
|
|
|
108
113
|
);
|
|
109
114
|
}
|
|
110
115
|
|
|
116
|
+
// An entry whose recorded main file is gone cannot be loaded, and one of those fails the whole
|
|
117
|
+
// checkout below. Heal them first (repoint the entry, or untrack it so `includeNewFromScope`
|
|
118
|
+
// re-imports it). Reported so the sync PR explains the `.bitmap` lines it carries.
|
|
119
|
+
const healedMainFiles = await healMissingMainFiles(this.deps.workspace, logger);
|
|
120
|
+
|
|
111
121
|
// `checkoutByCLIValues` rather than `checkout`: it imports current objects first (so `head`
|
|
112
122
|
// resolves to the remote scope's versions) and persists `.bitmap` on destroy.
|
|
113
123
|
// `includeNewFromScope`: a component exported to the scope's main but never in this repo's
|
|
@@ -193,7 +203,7 @@ export class MainSyncExecutor {
|
|
|
193
203
|
const shortSha = (await git.revparse(['--short', 'HEAD'])).trim();
|
|
194
204
|
return `main -> direct-push (pushed ${branch} @ ${shortSha})`;
|
|
195
205
|
}
|
|
196
|
-
const prUrl = await this.ensureSyncPr({ branch, driftCount: drift.length, newFromScope });
|
|
206
|
+
const prUrl = await this.ensureSyncPr({ branch, driftCount: drift.length, newFromScope, healedMainFiles });
|
|
197
207
|
return `main -> pushed sync commit to ${branch}${prUrl ? ` (PR ${prUrl})` : ''}`;
|
|
198
208
|
} catch (e: any) {
|
|
199
209
|
// Same contract as the lane executor: a HALTED line, never a throw mid-run.
|
|
@@ -304,10 +314,13 @@ export class MainSyncExecutor {
|
|
|
304
314
|
branch,
|
|
305
315
|
driftCount,
|
|
306
316
|
newFromScope,
|
|
317
|
+
healedMainFiles,
|
|
307
318
|
}: {
|
|
308
319
|
branch: string;
|
|
309
320
|
driftCount: number;
|
|
310
321
|
newFromScope: string[];
|
|
322
|
+
/** `.bitmap` entries whose stale main file this run repaired; see the PR body */
|
|
323
|
+
healedMainFiles: MainFileHeal[];
|
|
311
324
|
}): Promise<string | undefined> {
|
|
312
325
|
const { gitHost, logger, defaultBranch } = this.deps;
|
|
313
326
|
if (!gitHost) {
|
|
@@ -327,7 +340,7 @@ export class MainSyncExecutor {
|
|
|
327
340
|
head: branch,
|
|
328
341
|
base: defaultBranch,
|
|
329
342
|
title: 'Bit sync: update to latest main scope versions',
|
|
330
|
-
body: mainSyncPrBody({ driftCount, newFromScope }),
|
|
343
|
+
body: mainSyncPrBody({ driftCount, newFromScope, healedMainFiles }),
|
|
331
344
|
});
|
|
332
345
|
logger.console(chalk.green(`Opened sync PR ${created.htmlUrl}`));
|
|
333
346
|
return created.htmlUrl;
|
|
@@ -370,7 +383,15 @@ function mainSyncCommitMessage(driftCount: number): string {
|
|
|
370
383
|
].join('\n');
|
|
371
384
|
}
|
|
372
385
|
|
|
373
|
-
function mainSyncPrBody({
|
|
386
|
+
function mainSyncPrBody({
|
|
387
|
+
driftCount,
|
|
388
|
+
newFromScope,
|
|
389
|
+
healedMainFiles = [],
|
|
390
|
+
}: {
|
|
391
|
+
driftCount: number;
|
|
392
|
+
newFromScope: string[];
|
|
393
|
+
healedMainFiles?: MainFileHeal[];
|
|
394
|
+
}): string {
|
|
374
395
|
const lines = [
|
|
375
396
|
'Automated sync PR: the Bit scope moved ahead of this repository. This PR checks the workspace out to the ' +
|
|
376
397
|
'latest exported versions (`bit checkout head --auto-merge-resolve theirs`).',
|
|
@@ -390,6 +411,20 @@ function mainSyncPrBody({ driftCount, newFromScope }: { driftCount: number; newF
|
|
|
390
411
|
)
|
|
391
412
|
);
|
|
392
413
|
}
|
|
414
|
+
if (healedMainFiles.length) {
|
|
415
|
+
lines.push(
|
|
416
|
+
`- components whose \`.bitmap\` entry named a main file that no longer exists here ` +
|
|
417
|
+
`(${healedMainFiles.length}); the entry was repaired so the component can be loaded again:`,
|
|
418
|
+
...capEntries(
|
|
419
|
+
healedMainFiles.map((heal) =>
|
|
420
|
+
heal.retargetedTo
|
|
421
|
+
? ` - \`${heal.id}\` — main file repointed to \`${heal.retargetedTo}\``
|
|
422
|
+
: ` - \`${heal.id}\` — re-imported from the scope (no usable main file was left here)`
|
|
423
|
+
),
|
|
424
|
+
' - '
|
|
425
|
+
)
|
|
426
|
+
);
|
|
427
|
+
}
|
|
393
428
|
lines.push(
|
|
394
429
|
'',
|
|
395
430
|
'This PR is maintained by `bit ci sync` — re-running the command pushes any further drift onto the same branch.'
|