@teambit/ci 1.0.486 → 1.0.488
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/dist/ci.main.runtime.d.ts +8 -1
- package/dist/ci.main.runtime.js +36 -7
- package/dist/ci.main.runtime.js.map +1 -1
- package/dist/{preview-1785864931304.js → preview-1785951580001.js} +1 -1
- package/dist/sync/adopt-lane-new-components.d.ts +36 -0
- package/dist/sync/adopt-lane-new-components.js +146 -0
- package/dist/sync/adopt-lane-new-components.js.map +1 -0
- package/dist/sync/lane-sync-executor.js +2 -1
- package/dist/sync/lane-sync-executor.js.map +1 -1
- package/package.json +13 -13
- package/sync/adopt-lane-new-components.ts +128 -0
- package/sync/lane-sync-executor.ts +5 -1
|
@@ -11,6 +11,10 @@ import { type ImporterMain } from '@teambit/importer';
|
|
|
11
11
|
import { type CheckoutMain } from '@teambit/checkout';
|
|
12
12
|
import type { MergeStrategy } from '@teambit/component.modules.merge-helper';
|
|
13
13
|
import type { ReleaseType } from 'semver';
|
|
14
|
+
export type CiSwitchLaneOptions = SwitchLaneOptions & {
|
|
15
|
+
/** after an adoption retry, write the adopted components' files (`checkout --reset`) */
|
|
16
|
+
writeAdoptedFiles?: boolean;
|
|
17
|
+
};
|
|
14
18
|
import type { CiSyncConfig } from './sync/sync-config';
|
|
15
19
|
import type { GitHostProvider } from './sync/git-host-provider';
|
|
16
20
|
/**
|
|
@@ -150,6 +154,9 @@ export declare class CiMain {
|
|
|
150
154
|
* out" no-op case). Callers that need to react to a specific failure mode (e.g. stale lane) can
|
|
151
155
|
* inspect the returned error; existing callers ignore it and rely on a follow-up
|
|
152
156
|
* `getCurrentLane()` check.
|
|
157
|
+
*
|
|
158
|
+
* A switch that fails because the lane provides a component the workspace tracks as new retries
|
|
159
|
+
* once after adopting the lane's version — see `adoptNewComponentsTheLaneProvides`.
|
|
153
160
|
*/
|
|
154
161
|
private switchToLane;
|
|
155
162
|
/**
|
|
@@ -157,7 +164,7 @@ export declare class CiMain {
|
|
|
157
164
|
* throwing. `switchToLane` spreads caller options AFTER its defaults, so `forceOurs: true` is
|
|
158
165
|
* overridable — the sync import direction depends on that. Do not reorder that spread.
|
|
159
166
|
*/
|
|
160
|
-
switchToLaneForSync(laneName: string, options?:
|
|
167
|
+
switchToLaneForSync(laneName: string, options?: CiSwitchLaneOptions): Promise<Error | undefined>;
|
|
161
168
|
/**
|
|
162
169
|
* Re-read `.bitmap` from disk into the live workspace. `bit ci sync` moves the git checkout
|
|
163
170
|
* underneath a running process, and until the reload every bit operation resolves against the
|
package/dist/ci.main.runtime.js
CHANGED
|
@@ -228,6 +228,13 @@ function _pullRequestRef() {
|
|
|
228
228
|
};
|
|
229
229
|
return data;
|
|
230
230
|
}
|
|
231
|
+
function _adoptLaneNewComponents() {
|
|
232
|
+
const data = require("./sync/adopt-lane-new-components");
|
|
233
|
+
_adoptLaneNewComponents = function () {
|
|
234
|
+
return data;
|
|
235
|
+
};
|
|
236
|
+
return data;
|
|
237
|
+
}
|
|
231
238
|
function _syncOrchestrator() {
|
|
232
239
|
const data = require("./sync/sync-orchestrator");
|
|
233
240
|
_syncOrchestrator = function () {
|
|
@@ -256,9 +263,12 @@ function _syncConfig() {
|
|
|
256
263
|
};
|
|
257
264
|
return data;
|
|
258
265
|
}
|
|
266
|
+
const _excluded = ["writeAdoptedFiles"];
|
|
259
267
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
260
268
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
261
269
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
270
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
271
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
262
272
|
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; }
|
|
263
273
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
264
274
|
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); }
|
|
@@ -536,22 +546,41 @@ class CiMain {
|
|
|
536
546
|
* out" no-op case). Callers that need to react to a specific failure mode (e.g. stale lane) can
|
|
537
547
|
* inspect the returned error; existing callers ignore it and rely on a follow-up
|
|
538
548
|
* `getCurrentLane()` check.
|
|
549
|
+
*
|
|
550
|
+
* A switch that fails because the lane provides a component the workspace tracks as new retries
|
|
551
|
+
* once after adopting the lane's version — see `adoptNewComponentsTheLaneProvides`.
|
|
539
552
|
*/
|
|
540
553
|
async switchToLane(laneName, options = {}) {
|
|
541
554
|
this.logger.console(_chalk().default.blue(`Switching to ${laneName}`));
|
|
555
|
+
const {
|
|
556
|
+
writeAdoptedFiles
|
|
557
|
+
} = options,
|
|
558
|
+
switchOptions = _objectWithoutProperties(options, _excluded);
|
|
559
|
+
const doSwitch = () => this.lanes.switchLanes(laneName, _objectSpread({
|
|
560
|
+
forceOurs: true,
|
|
561
|
+
workspaceOnly: true,
|
|
562
|
+
skipDependencyInstallation: true
|
|
563
|
+
}, switchOptions));
|
|
564
|
+
const failure = err => {
|
|
565
|
+
this.logger.console(_chalk().default.red(`Failed switching to ${laneName}: ${err?.toString() ?? err}`));
|
|
566
|
+
return err;
|
|
567
|
+
};
|
|
542
568
|
try {
|
|
543
|
-
await
|
|
544
|
-
forceOurs: true,
|
|
545
|
-
workspaceOnly: true,
|
|
546
|
-
skipDependencyInstallation: true
|
|
547
|
-
}, options));
|
|
569
|
+
await doSwitch();
|
|
548
570
|
} catch (e) {
|
|
549
571
|
if (e?.toString().includes('already checked out')) {
|
|
550
572
|
this.logger.console(_chalk().default.yellow(`Lane ${laneName} already checked out, skipping checkout`));
|
|
551
573
|
return undefined;
|
|
552
574
|
}
|
|
553
|
-
|
|
554
|
-
|
|
575
|
+
if (!(0, _adoptLaneNewComponents().isLaneMissingComponentError)(e)) return failure(e);
|
|
576
|
+
const retryErr = await (0, _adoptLaneNewComponents().adoptAndRetrySwitch)(laneName, e, doSwitch, writeAdoptedFiles, {
|
|
577
|
+
workspace: this.workspace,
|
|
578
|
+
lanes: this.lanes,
|
|
579
|
+
logger: this.logger,
|
|
580
|
+
checkout: this.checkout,
|
|
581
|
+
reloadWorkspace: () => this.reloadWorkspaceFromDisk()
|
|
582
|
+
});
|
|
583
|
+
if (retryErr) return failure(retryErr);
|
|
555
584
|
}
|
|
556
585
|
return undefined;
|
|
557
586
|
}
|