@teambit/lanes 0.0.452 → 0.0.454
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/create-lane.js +7 -24
- package/dist/create-lane.js.map +1 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/lane.cmd.js +3 -91
- package/dist/lane.cmd.js.map +1 -1
- package/dist/lanes.aspect.js +0 -5
- package/dist/lanes.aspect.js.map +1 -1
- package/dist/lanes.composition.js +0 -6
- package/dist/lanes.composition.js.map +1 -1
- package/dist/lanes.graphql.js +0 -21
- package/dist/lanes.graphql.js.map +1 -1
- package/dist/lanes.main.runtime.js +15 -190
- package/dist/lanes.main.runtime.js.map +1 -1
- package/dist/lanes.spec.js +0 -13
- package/dist/lanes.spec.js.map +1 -1
- package/dist/lanes.ui.runtime.js +6 -91
- package/dist/lanes.ui.runtime.js.map +1 -1
- package/dist/switch-lanes.js +12 -86
- package/dist/switch-lanes.js.map +1 -1
- package/dist/switch.cmd.js +0 -23
- package/dist/switch.cmd.js.map +1 -1
- package/package-tar/teambit-lanes-0.0.454.tgz +0 -0
- package/package.json +23 -23
- package/{preview-1666312873430.js → preview-1666496165706.js} +2 -2
- package/package-tar/teambit-lanes-0.0.452.tgz +0 -0
package/dist/switch-lanes.js
CHANGED
@@ -1,116 +1,82 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
6
|
-
|
7
5
|
require("core-js/modules/es.promise.js");
|
8
|
-
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
10
7
|
value: true
|
11
8
|
});
|
12
9
|
exports.LaneSwitcher = void 0;
|
13
|
-
|
14
10
|
function _defineProperty2() {
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
16
|
-
|
17
12
|
_defineProperty2 = function () {
|
18
13
|
return data;
|
19
14
|
};
|
20
|
-
|
21
15
|
return data;
|
22
16
|
}
|
23
|
-
|
24
17
|
function _pMapSeries() {
|
25
18
|
const data = _interopRequireDefault(require("p-map-series"));
|
26
|
-
|
27
19
|
_pMapSeries = function () {
|
28
20
|
return data;
|
29
21
|
};
|
30
|
-
|
31
22
|
return data;
|
32
23
|
}
|
33
|
-
|
34
24
|
function _generalError() {
|
35
25
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/error/general-error"));
|
36
|
-
|
37
26
|
_generalError = function () {
|
38
27
|
return data;
|
39
28
|
};
|
40
|
-
|
41
29
|
return data;
|
42
30
|
}
|
43
|
-
|
44
31
|
function _laneId() {
|
45
32
|
const data = require("@teambit/lane-id");
|
46
|
-
|
47
33
|
_laneId = function () {
|
48
34
|
return data;
|
49
35
|
};
|
50
|
-
|
51
36
|
return data;
|
52
37
|
}
|
53
|
-
|
54
38
|
function _repositories() {
|
55
39
|
const data = require("@teambit/legacy/dist/scope/repositories");
|
56
|
-
|
57
40
|
_repositories = function () {
|
58
41
|
return data;
|
59
42
|
};
|
60
|
-
|
61
43
|
return data;
|
62
44
|
}
|
63
|
-
|
64
45
|
function _checkoutVersion() {
|
65
46
|
const data = require("@teambit/legacy/dist/consumer/versions-ops/checkout-version");
|
66
|
-
|
67
47
|
_checkoutVersion = function () {
|
68
48
|
return data;
|
69
49
|
};
|
70
|
-
|
71
50
|
return data;
|
72
51
|
}
|
73
|
-
|
74
52
|
function _manyComponentsWriter() {
|
75
53
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component-ops/many-components-writer"));
|
76
|
-
|
77
54
|
_manyComponentsWriter = function () {
|
78
55
|
return data;
|
79
56
|
};
|
80
|
-
|
81
57
|
return data;
|
82
58
|
}
|
83
|
-
|
84
59
|
function _mergeVersion() {
|
85
60
|
const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
|
86
|
-
|
87
61
|
_mergeVersion = function () {
|
88
62
|
return data;
|
89
63
|
};
|
90
|
-
|
91
64
|
return data;
|
92
65
|
}
|
93
|
-
|
94
66
|
function _threeWayMerge() {
|
95
67
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge"));
|
96
|
-
|
97
68
|
_threeWayMerge = function () {
|
98
69
|
return data;
|
99
70
|
};
|
100
|
-
|
101
71
|
return data;
|
102
72
|
}
|
103
|
-
|
104
73
|
function _bitError() {
|
105
74
|
const data = require("@teambit/bit-error");
|
106
|
-
|
107
75
|
_bitError = function () {
|
108
76
|
return data;
|
109
77
|
};
|
110
|
-
|
111
78
|
return data;
|
112
79
|
}
|
113
|
-
|
114
80
|
class LaneSwitcher {
|
115
81
|
// populated by `this.populateSwitchProps()`
|
116
82
|
// populated by `this.populateSwitchProps()`, if default-lane, it's undefined
|
@@ -125,29 +91,25 @@ class LaneSwitcher {
|
|
125
91
|
(0, _defineProperty2().default)(this, "laneToSwitchTo", void 0);
|
126
92
|
this.consumer = this.workspace.consumer;
|
127
93
|
}
|
128
|
-
|
129
94
|
async switch() {
|
130
95
|
this.logger.setStatusLine(`switching lanes`);
|
131
96
|
await this.populateSwitchProps();
|
132
97
|
const allComponentsStatus = await this.getAllComponentsStatus();
|
133
98
|
const componentWithConflict = allComponentsStatus.find(component => component.mergeResults && component.mergeResults.hasConflicts);
|
134
|
-
|
135
99
|
if (componentWithConflict) {
|
136
100
|
if (!this.checkoutProps.promptMergeOptions && !this.checkoutProps.mergeStrategy) {
|
137
101
|
throw new (_generalError().default)(`automatic merge has failed for component ${componentWithConflict.id.toStringWithoutVersion()}.\nplease use "--manual" to manually merge changes or use "--theirs / --ours" to choose one of the conflicted versions`);
|
138
102
|
}
|
139
|
-
|
140
103
|
if (!this.checkoutProps.mergeStrategy) this.checkoutProps.mergeStrategy = await (0, _mergeVersion().getMergeStrategyInteractive)();
|
141
104
|
}
|
142
|
-
|
143
105
|
const failedComponents = allComponentsStatus.filter(componentStatus => componentStatus.failureMessage).map(componentStatus => ({
|
144
106
|
id: componentStatus.id,
|
145
107
|
failureMessage: componentStatus.failureMessage,
|
146
108
|
unchangedLegitimately: componentStatus.unchangedLegitimately
|
147
109
|
}));
|
148
|
-
const succeededComponents = allComponentsStatus.filter(componentStatus => !componentStatus.failureMessage);
|
110
|
+
const succeededComponents = allComponentsStatus.filter(componentStatus => !componentStatus.failureMessage);
|
111
|
+
// do not use Promise.all for applyVersion. otherwise, it'll write all components in parallel,
|
149
112
|
// which can be an issue when some components are also dependencies of others
|
150
|
-
|
151
113
|
const componentsResults = await (0, _pMapSeries().default)(succeededComponents, ({
|
152
114
|
id,
|
153
115
|
componentFromFS,
|
@@ -175,11 +137,9 @@ class LaneSwitcher {
|
|
175
137
|
failedComponents
|
176
138
|
};
|
177
139
|
}
|
178
|
-
|
179
140
|
async populateSwitchProps() {
|
180
141
|
const laneId = await this.consumer.scope.lanes.parseLaneIdFromString(this.switchProps.laneName);
|
181
142
|
const localLane = await this.consumer.scope.loadLane(laneId);
|
182
|
-
|
183
143
|
if (laneId.isDefault()) {
|
184
144
|
await this.populatePropsAccordingToDefaultLane();
|
185
145
|
} else if (localLane) {
|
@@ -188,15 +148,12 @@ class LaneSwitcher {
|
|
188
148
|
await this.populatePropsAccordingToRemoteLane(laneId);
|
189
149
|
}
|
190
150
|
}
|
191
|
-
|
192
151
|
async populatePropsAccordingToRemoteLane(remoteLaneId) {
|
193
152
|
this.laneIdToSwitch = remoteLaneId;
|
194
153
|
this.logger.debug(`populatePropsAccordingToRemoteLane, remoteLaneId: ${remoteLaneId.toString()}`);
|
195
|
-
|
196
154
|
if (this.consumer.getCurrentLaneId().isEqual(remoteLaneId)) {
|
197
155
|
throw new (_bitError().BitError)(`already checked out to "${remoteLaneId.toString()}"`);
|
198
156
|
}
|
199
|
-
|
200
157
|
const remoteLane = await this.Lanes.fetchLaneWithItsComponents(remoteLaneId);
|
201
158
|
this.switchProps.laneName = remoteLaneId.name;
|
202
159
|
this.switchProps.ids = remoteLane.components.map(l => l.id.changeVersion(l.head.toString()));
|
@@ -205,49 +162,40 @@ class LaneSwitcher {
|
|
205
162
|
this.laneToSwitchTo = remoteLane;
|
206
163
|
this.logger.debug(`populatePropsAccordingToRemoteLane, completed`);
|
207
164
|
}
|
208
|
-
|
209
165
|
async populatePropsAccordingToDefaultLane() {
|
210
166
|
if (!this.consumer.isOnLane()) {
|
211
167
|
throw new (_bitError().BitError)(`already checked out to "${this.switchProps.laneName}"`);
|
212
168
|
}
|
213
|
-
|
214
169
|
this.switchProps.ids = await this.consumer.getIdsOfDefaultLane();
|
215
170
|
this.laneIdToSwitch = _laneId().LaneId.from(_laneId().DEFAULT_LANE, this.consumer.scope.name);
|
216
171
|
}
|
217
|
-
|
218
172
|
populatePropsAccordingToLocalLane(localLane) {
|
219
173
|
if (this.consumer.getCurrentLaneId().name === this.switchProps.laneName) {
|
220
174
|
throw new (_bitError().BitError)(`already checked out to "${this.switchProps.laneName}"`);
|
221
175
|
}
|
222
|
-
|
223
176
|
this.switchProps.ids = localLane.components.map(c => c.id.changeVersion(c.head.toString()));
|
224
177
|
this.laneIdToSwitch = localLane.toLaneId();
|
225
178
|
this.laneToSwitchTo = localLane;
|
226
179
|
}
|
227
|
-
|
228
180
|
async getAllComponentsStatus() {
|
229
181
|
const {
|
230
182
|
ids
|
231
183
|
} = this.switchProps;
|
232
184
|
const tmp = new (_repositories().Tmp)(this.consumer.scope);
|
233
|
-
|
234
185
|
try {
|
235
186
|
const componentsStatusP = ids.map(id => getComponentStatus(this.consumer, id, this.switchProps));
|
236
187
|
const componentsStatus = await Promise.all(componentsStatusP);
|
237
|
-
await tmp.clear();
|
238
|
-
|
188
|
+
await tmp.clear();
|
189
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
239
190
|
return componentsStatus;
|
240
191
|
} catch (err) {
|
241
192
|
await tmp.clear();
|
242
193
|
throw err;
|
243
194
|
}
|
244
195
|
}
|
245
|
-
|
246
196
|
async saveLanesData() {
|
247
197
|
var _this$laneToSwitchTo;
|
248
|
-
|
249
198
|
const localLaneName = this.switchProps.alias || this.laneIdToSwitch.name;
|
250
|
-
|
251
199
|
if (this.switchProps.remoteLane) {
|
252
200
|
if (!this.switchProps.localTrackedLane) {
|
253
201
|
this.consumer.scope.lanes.trackLane({
|
@@ -257,58 +205,43 @@ class LaneSwitcher {
|
|
257
205
|
});
|
258
206
|
}
|
259
207
|
}
|
260
|
-
|
261
208
|
this.consumer.setCurrentLane(this.laneIdToSwitch, !((_this$laneToSwitchTo = this.laneToSwitchTo) !== null && _this$laneToSwitchTo !== void 0 && _this$laneToSwitchTo.isNew));
|
262
209
|
this.consumer.bitMap.syncWithLanes(this.laneToSwitchTo);
|
263
210
|
}
|
264
|
-
|
265
211
|
}
|
266
|
-
|
267
212
|
exports.LaneSwitcher = LaneSwitcher;
|
268
|
-
|
269
213
|
async function getComponentStatus(consumer, id, switchProps) {
|
270
214
|
const componentStatus = {
|
271
215
|
id
|
272
216
|
};
|
273
|
-
|
274
217
|
const returnFailure = (msg, unchangedLegitimately = false) => {
|
275
218
|
componentStatus.failureMessage = msg;
|
276
219
|
componentStatus.unchangedLegitimately = unchangedLegitimately;
|
277
220
|
return componentStatus;
|
278
221
|
};
|
279
|
-
|
280
222
|
const modelComponent = await consumer.scope.getModelComponentIfExist(id);
|
281
|
-
|
282
223
|
if (!modelComponent) {
|
283
224
|
return returnFailure(`component ${id.toString()} had never imported`, true);
|
284
225
|
}
|
285
|
-
|
286
226
|
const unmerged = consumer.scope.objects.unmergedComponents.getEntry(id.name);
|
287
|
-
|
288
227
|
if (unmerged) {
|
289
228
|
return returnFailure(`component ${id.toStringWithoutVersion()} is in during-merge state, please snap/tag it first (or use bit merge --resolve/--abort)`);
|
290
229
|
}
|
291
|
-
|
292
230
|
const version = id.version;
|
293
|
-
|
294
231
|
if (!version) {
|
295
232
|
return returnFailure(`component doesn't have any snaps on ${_laneId().DEFAULT_LANE}`, true);
|
296
233
|
}
|
297
|
-
|
298
234
|
const existingBitMapId = consumer.bitMap.getBitIdIfExist(id, {
|
299
235
|
ignoreVersion: true
|
300
236
|
});
|
301
237
|
const componentOnLane = await modelComponent.loadVersion(version, consumer.scope.objects);
|
302
|
-
|
303
238
|
if (componentOnLane.isRemoved()) {
|
304
239
|
return returnFailure(`component has been removed`, true);
|
305
240
|
}
|
306
|
-
|
307
241
|
if (!existingBitMapId) {
|
308
242
|
if (switchProps.existingOnWorkspaceOnly) {
|
309
243
|
return returnFailure(`component ${id.toStringWithoutVersion()} is not in the workspace`, true);
|
310
244
|
}
|
311
|
-
|
312
245
|
return {
|
313
246
|
componentFromFS: undefined,
|
314
247
|
componentFromModel: componentOnLane,
|
@@ -316,7 +249,6 @@ async function getComponentStatus(consumer, id, switchProps) {
|
|
316
249
|
mergeResults: null
|
317
250
|
};
|
318
251
|
}
|
319
|
-
|
320
252
|
if (!existingBitMapId.hasVersion()) {
|
321
253
|
// happens when switching from main to a lane and a component was snapped on the lane.
|
322
254
|
// in the .bitmap file, the version is "latest" or empty. so we just need to write the component according to the
|
@@ -328,21 +260,17 @@ async function getComponentStatus(consumer, id, switchProps) {
|
|
328
260
|
mergeResults: null
|
329
261
|
};
|
330
262
|
}
|
331
|
-
|
332
263
|
const currentlyUsedVersion = existingBitMapId.version;
|
333
|
-
|
334
264
|
if (currentlyUsedVersion === version) {
|
335
265
|
return returnFailure(`component ${id.toStringWithoutVersion()} is already at version ${version}`, true);
|
336
|
-
}
|
337
|
-
|
338
|
-
|
266
|
+
}
|
267
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
339
268
|
const baseComponent = await modelComponent.loadVersion(currentlyUsedVersion, consumer.scope.objects);
|
340
|
-
const component = await consumer.loadComponent(existingBitMapId);
|
269
|
+
const component = await consumer.loadComponent(existingBitMapId);
|
270
|
+
// don't use `consumer.isModified` here. otherwise, if there are dependency changes, the user can't discard them
|
341
271
|
// and won't be able to switch lanes.
|
342
|
-
|
343
272
|
const isModified = await consumer.isComponentSourceCodeModified(baseComponent, component);
|
344
273
|
let mergeResults;
|
345
|
-
|
346
274
|
const isHeadSameAsMain = () => {
|
347
275
|
const head = modelComponent.getHead();
|
348
276
|
if (!head) return false;
|
@@ -351,13 +279,12 @@ async function getComponentStatus(consumer, id, switchProps) {
|
|
351
279
|
const headVersion = tagVersion || head.toString();
|
352
280
|
return existingBitMapId.version === headVersion;
|
353
281
|
};
|
354
|
-
|
355
282
|
if (isModified) {
|
356
283
|
if (!isHeadSameAsMain()) {
|
357
284
|
throw new (_generalError().default)(`unable to checkout ${id.toStringWithoutVersion()}, the component is modified and belongs to another lane`);
|
358
285
|
}
|
359
|
-
|
360
|
-
|
286
|
+
const otherComponent = await modelComponent.loadVersion(existingBitMapId.version,
|
287
|
+
// we are here because the head is same as main. so, existingBitMapId.version must be set
|
361
288
|
consumer.scope.objects);
|
362
289
|
mergeResults = await (0, _threeWayMerge().default)({
|
363
290
|
consumer,
|
@@ -367,9 +294,8 @@ async function getComponentStatus(consumer, id, switchProps) {
|
|
367
294
|
currentLabel: `${currentlyUsedVersion} modified`,
|
368
295
|
baseComponent
|
369
296
|
});
|
370
|
-
}
|
371
|
-
|
372
|
-
|
297
|
+
}
|
298
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
373
299
|
return {
|
374
300
|
componentFromFS: component,
|
375
301
|
componentFromModel: componentOnLane,
|
package/dist/switch-lanes.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["LaneSwitcher","constructor","workspace","logger","switchProps","checkoutProps","Lanes","consumer","switch","setStatusLine","populateSwitchProps","allComponentsStatus","getAllComponentsStatus","componentWithConflict","find","component","mergeResults","hasConflicts","promptMergeOptions","mergeStrategy","GeneralError","id","toStringWithoutVersion","getMergeStrategyInteractive","failedComponents","filter","componentStatus","failureMessage","map","unchangedLegitimately","succeededComponents","componentsResults","mapSeries","componentFromFS","applyVersion","markFilesToBeRemovedIfNeeded","saveLanesData","componentsWithDependencies","c","manyComponentsWriter","ManyComponentsWriter","installNpmPackages","skipNpmInstall","override","verbose","writeConfig","writeAll","deleteFilesIfNeeded","appliedVersionComponents","applyVersionResult","onDestroy","components","laneId","scope","lanes","parseLaneIdFromString","laneName","localLane","loadLane","isDefault","populatePropsAccordingToDefaultLane","populatePropsAccordingToLocalLane","populatePropsAccordingToRemoteLane","remoteLaneId","laneIdToSwitch","debug","toString","getCurrentLaneId","isEqual","BitError","remoteLane","fetchLaneWithItsComponents","name","ids","l","changeVersion","head","localTrackedLane","getAliasByLaneId","undefined","laneToSwitchTo","isOnLane","getIdsOfDefaultLane","LaneId","from","DEFAULT_LANE","toLaneId","tmp","Tmp","componentsStatusP","getComponentStatus","componentsStatus","Promise","all","clear","err","localLaneName","alias","trackLane","remoteScope","setCurrentLane","isNew","bitMap","syncWithLanes","returnFailure","msg","modelComponent","getModelComponentIfExist","unmerged","objects","unmergedComponents","getEntry","version","existingBitMapId","getBitIdIfExist","ignoreVersion","componentOnLane","loadVersion","isRemoved","existingOnWorkspaceOnly","componentFromModel","hasVersion","currentlyUsedVersion","baseComponent","loadComponent","isModified","isComponentSourceCodeModified","isHeadSameAsMain","getHead","tagVersion","getTagOfRefIfExists","headVersion","otherComponent","threeWayMerge","otherLabel","currentComponent","currentLabel"],"sources":["switch-lanes.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { LaneId, DEFAULT_LANE } from '@teambit/lane-id';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ComponentWithDependencies } from '@teambit/legacy/dist/scope';\nimport { Version, Lane } from '@teambit/legacy/dist/scope/models';\nimport { Tmp } from '@teambit/legacy/dist/scope/repositories';\nimport {\n applyVersion,\n ComponentStatus,\n CheckoutProps,\n deleteFilesIfNeeded,\n markFilesToBeRemovedIfNeeded,\n} from '@teambit/legacy/dist/consumer/versions-ops/checkout-version';\nimport ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';\nimport {\n FailedComponents,\n getMergeStrategyInteractive,\n ApplyVersionResults,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport threeWayMerge, {\n MergeResultsThreeWay,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';\nimport { Workspace } from '@teambit/workspace';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { LanesMain } from './lanes.main.runtime';\n\nexport type SwitchProps = {\n laneName: string;\n ids?: BitId[];\n existingOnWorkspaceOnly: boolean;\n remoteLane?: Lane;\n localTrackedLane?: string;\n alias?: string;\n};\n\nexport class LaneSwitcher {\n private consumer: Consumer;\n private laneIdToSwitch: LaneId; // populated by `this.populateSwitchProps()`\n private laneToSwitchTo: Lane | undefined; // populated by `this.populateSwitchProps()`, if default-lane, it's undefined\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private switchProps: SwitchProps,\n private checkoutProps: CheckoutProps,\n private Lanes: LanesMain\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n async switch(): Promise<ApplyVersionResults> {\n this.logger.setStatusLine(`switching lanes`);\n await this.populateSwitchProps();\n const allComponentsStatus: ComponentStatus[] = await this.getAllComponentsStatus();\n const componentWithConflict = allComponentsStatus.find(\n (component) => component.mergeResults && component.mergeResults.hasConflicts\n );\n if (componentWithConflict) {\n if (!this.checkoutProps.promptMergeOptions && !this.checkoutProps.mergeStrategy) {\n throw new GeneralError(\n `automatic merge has failed for component ${componentWithConflict.id.toStringWithoutVersion()}.\\nplease use \"--manual\" to manually merge changes or use \"--theirs / --ours\" to choose one of the conflicted versions`\n );\n }\n if (!this.checkoutProps.mergeStrategy) this.checkoutProps.mergeStrategy = await getMergeStrategyInteractive();\n }\n const failedComponents: FailedComponents[] = allComponentsStatus\n .filter((componentStatus) => componentStatus.failureMessage)\n .map((componentStatus) => ({\n id: componentStatus.id,\n failureMessage: componentStatus.failureMessage as string,\n unchangedLegitimately: componentStatus.unchangedLegitimately,\n }));\n\n const succeededComponents = allComponentsStatus.filter((componentStatus) => !componentStatus.failureMessage);\n // do not use Promise.all for applyVersion. otherwise, it'll write all components in parallel,\n // which can be an issue when some components are also dependencies of others\n const componentsResults = await mapSeries(succeededComponents, ({ id, componentFromFS, mergeResults }) => {\n return applyVersion(this.consumer, id, componentFromFS, mergeResults, this.checkoutProps);\n });\n\n markFilesToBeRemovedIfNeeded(succeededComponents, componentsResults);\n\n await this.saveLanesData();\n\n const componentsWithDependencies = componentsResults\n .map((c) => c.component)\n .filter((c) => c) as ComponentWithDependencies[];\n\n const manyComponentsWriter = new ManyComponentsWriter({\n consumer: this.consumer,\n componentsWithDependencies,\n installNpmPackages: !this.checkoutProps.skipNpmInstall,\n override: true,\n verbose: this.checkoutProps.verbose,\n writeConfig: this.checkoutProps.writeConfig,\n });\n await manyComponentsWriter.writeAll();\n await deleteFilesIfNeeded(componentsResults, this.consumer);\n\n const appliedVersionComponents = componentsResults.map((c) => c.applyVersionResult);\n\n await this.consumer.onDestroy();\n\n return { components: appliedVersionComponents, failedComponents };\n }\n\n private async populateSwitchProps() {\n const laneId = await this.consumer.scope.lanes.parseLaneIdFromString(this.switchProps.laneName);\n\n const localLane = await this.consumer.scope.loadLane(laneId);\n if (laneId.isDefault()) {\n await this.populatePropsAccordingToDefaultLane();\n } else if (localLane) {\n this.populatePropsAccordingToLocalLane(localLane);\n } else {\n await this.populatePropsAccordingToRemoteLane(laneId);\n }\n }\n\n private async populatePropsAccordingToRemoteLane(remoteLaneId: LaneId) {\n this.laneIdToSwitch = remoteLaneId;\n this.logger.debug(`populatePropsAccordingToRemoteLane, remoteLaneId: ${remoteLaneId.toString()}`);\n if (this.consumer.getCurrentLaneId().isEqual(remoteLaneId)) {\n throw new BitError(`already checked out to \"${remoteLaneId.toString()}\"`);\n }\n const remoteLane = await this.Lanes.fetchLaneWithItsComponents(remoteLaneId);\n this.switchProps.laneName = remoteLaneId.name;\n this.switchProps.ids = remoteLane.components.map((l) => l.id.changeVersion(l.head.toString()));\n this.switchProps.localTrackedLane = this.consumer.scope.lanes.getAliasByLaneId(remoteLaneId) || undefined;\n this.switchProps.remoteLane = remoteLane;\n this.laneToSwitchTo = remoteLane;\n this.logger.debug(`populatePropsAccordingToRemoteLane, completed`);\n }\n\n private async populatePropsAccordingToDefaultLane() {\n if (!this.consumer.isOnLane()) {\n throw new BitError(`already checked out to \"${this.switchProps.laneName}\"`);\n }\n this.switchProps.ids = await this.consumer.getIdsOfDefaultLane();\n this.laneIdToSwitch = LaneId.from(DEFAULT_LANE, this.consumer.scope.name);\n }\n\n private populatePropsAccordingToLocalLane(localLane: Lane) {\n if (this.consumer.getCurrentLaneId().name === this.switchProps.laneName) {\n throw new BitError(`already checked out to \"${this.switchProps.laneName}\"`);\n }\n this.switchProps.ids = localLane.components.map((c) => c.id.changeVersion(c.head.toString()));\n this.laneIdToSwitch = localLane.toLaneId();\n this.laneToSwitchTo = localLane;\n }\n\n private async getAllComponentsStatus(): Promise<ComponentStatus[]> {\n const { ids } = this.switchProps;\n const tmp = new Tmp(this.consumer.scope);\n try {\n const componentsStatusP = (ids as BitId[]).map((id) => getComponentStatus(this.consumer, id, this.switchProps));\n const componentsStatus = await Promise.all(componentsStatusP);\n await tmp.clear();\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return componentsStatus;\n } catch (err: any) {\n await tmp.clear();\n throw err;\n }\n }\n\n private async saveLanesData() {\n const localLaneName = this.switchProps.alias || this.laneIdToSwitch.name;\n if (this.switchProps.remoteLane) {\n if (!this.switchProps.localTrackedLane) {\n this.consumer.scope.lanes.trackLane({\n localLane: localLaneName,\n remoteLane: this.laneIdToSwitch.name,\n remoteScope: this.laneIdToSwitch.scope,\n });\n }\n }\n\n this.consumer.setCurrentLane(this.laneIdToSwitch, !this.laneToSwitchTo?.isNew);\n this.consumer.bitMap.syncWithLanes(this.laneToSwitchTo);\n }\n}\n\nasync function getComponentStatus(consumer: Consumer, id: BitId, switchProps: SwitchProps): Promise<ComponentStatus> {\n const componentStatus: ComponentStatus = { id };\n const returnFailure = (msg: string, unchangedLegitimately = false) => {\n componentStatus.failureMessage = msg;\n componentStatus.unchangedLegitimately = unchangedLegitimately;\n return componentStatus;\n };\n const modelComponent = await consumer.scope.getModelComponentIfExist(id);\n if (!modelComponent) {\n return returnFailure(`component ${id.toString()} had never imported`, true);\n }\n const unmerged = consumer.scope.objects.unmergedComponents.getEntry(id.name);\n if (unmerged) {\n return returnFailure(\n `component ${id.toStringWithoutVersion()} is in during-merge state, please snap/tag it first (or use bit merge --resolve/--abort)`\n );\n }\n const version = id.version;\n if (!version) {\n return returnFailure(`component doesn't have any snaps on ${DEFAULT_LANE}`, true);\n }\n const existingBitMapId = consumer.bitMap.getBitIdIfExist(id, { ignoreVersion: true });\n const componentOnLane: Version = await modelComponent.loadVersion(version, consumer.scope.objects);\n if (componentOnLane.isRemoved()) {\n return returnFailure(`component has been removed`, true);\n }\n if (!existingBitMapId) {\n if (switchProps.existingOnWorkspaceOnly) {\n return returnFailure(`component ${id.toStringWithoutVersion()} is not in the workspace`, true);\n }\n return { componentFromFS: undefined, componentFromModel: componentOnLane, id, mergeResults: null };\n }\n if (!existingBitMapId.hasVersion()) {\n // happens when switching from main to a lane and a component was snapped on the lane.\n // in the .bitmap file, the version is \"latest\" or empty. so we just need to write the component according to the\n // model. we don't care about the componentFromFS\n return { componentFromFS: undefined, componentFromModel: componentOnLane, id, mergeResults: null };\n }\n const currentlyUsedVersion = existingBitMapId.version;\n if (currentlyUsedVersion === version) {\n return returnFailure(`component ${id.toStringWithoutVersion()} is already at version ${version}`, true);\n }\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const baseComponent: Version = await modelComponent.loadVersion(currentlyUsedVersion, consumer.scope.objects);\n const component = await consumer.loadComponent(existingBitMapId);\n // don't use `consumer.isModified` here. otherwise, if there are dependency changes, the user can't discard them\n // and won't be able to switch lanes.\n const isModified = await consumer.isComponentSourceCodeModified(baseComponent, component);\n let mergeResults: MergeResultsThreeWay | null | undefined;\n const isHeadSameAsMain = () => {\n const head = modelComponent.getHead();\n if (!head) return false;\n if (!existingBitMapId.version) return false;\n const tagVersion = modelComponent.getTagOfRefIfExists(head);\n const headVersion = tagVersion || head.toString();\n return existingBitMapId.version === headVersion;\n };\n if (isModified) {\n if (!isHeadSameAsMain()) {\n throw new GeneralError(\n `unable to checkout ${id.toStringWithoutVersion()}, the component is modified and belongs to another lane`\n );\n }\n\n const otherComponent: Version = await modelComponent.loadVersion(\n existingBitMapId.version as string, // we are here because the head is same as main. so, existingBitMapId.version must be set\n consumer.scope.objects\n );\n mergeResults = await threeWayMerge({\n consumer,\n otherComponent,\n otherLabel: version,\n currentComponent: component,\n currentLabel: `${currentlyUsedVersion} modified`,\n baseComponent,\n });\n }\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return { componentFromFS: component, componentFromModel: componentOnLane, id, mergeResults };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAOA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAYO,MAAMA,YAAN,CAAmB;EAEQ;EACU;EAC1CC,WAAW,CACDC,SADC,EAEDC,MAFC,EAGDC,WAHC,EAIDC,aAJC,EAKDC,KALC,EAMT;IAAA,KALQJ,SAKR,GALQA,SAKR;IAAA,K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,IAAnC,CAAnB;IACA,MAAMuD,WAAW,GAAGF,UAAU,IAAIrD,IAAI,CAACV,QAAL,EAAlC;IACA,OAAO+C,gBAAgB,CAACD,OAAjB,KAA6BmB,WAApC;EACD,CAPD;;EAQA,IAAIN,UAAJ,EAAgB;IACd,IAAI,CAACE,gBAAgB,EAArB,EAAyB;MACvB,MAAM,KAAI3G,uBAAJ,EACH,sBAAqBC,EAAE,CAACC,sBAAH,EAA4B,yDAD9C,CAAN;IAGD;;IAED,MAAM8G,cAAuB,GAAG,MAAM1B,cAAc,CAACW,WAAf,CACpCJ,gBAAgB,CAACD,OADmB,EACA;IACpCzG,QAAQ,CAAC8C,KAAT,CAAewD,OAFqB,CAAtC;IAIA7F,YAAY,GAAG,MAAM,IAAAqH,wBAAA,EAAc;MACjC9H,QADiC;MAEjC6H,cAFiC;MAGjCE,UAAU,EAAEtB,OAHqB;MAIjCuB,gBAAgB,EAAExH,SAJe;MAKjCyH,YAAY,EAAG,GAAEd,oBAAqB,WALL;MAMjCC;IANiC,CAAd,CAArB;EAQD,CA5EkH,CA6EnH;;;EACA,OAAO;IAAE1F,eAAe,EAAElB,SAAnB;IAA8ByG,kBAAkB,EAAEJ,eAAlD;IAAmE/F,EAAnE;IAAuEL;EAAvE,CAAP;AACD"}
|
1
|
+
{"version":3,"names":["LaneSwitcher","constructor","workspace","logger","switchProps","checkoutProps","Lanes","consumer","switch","setStatusLine","populateSwitchProps","allComponentsStatus","getAllComponentsStatus","componentWithConflict","find","component","mergeResults","hasConflicts","promptMergeOptions","mergeStrategy","GeneralError","id","toStringWithoutVersion","getMergeStrategyInteractive","failedComponents","filter","componentStatus","failureMessage","map","unchangedLegitimately","succeededComponents","componentsResults","mapSeries","componentFromFS","applyVersion","markFilesToBeRemovedIfNeeded","saveLanesData","componentsWithDependencies","c","manyComponentsWriter","ManyComponentsWriter","installNpmPackages","skipNpmInstall","override","verbose","writeConfig","writeAll","deleteFilesIfNeeded","appliedVersionComponents","applyVersionResult","onDestroy","components","laneId","scope","lanes","parseLaneIdFromString","laneName","localLane","loadLane","isDefault","populatePropsAccordingToDefaultLane","populatePropsAccordingToLocalLane","populatePropsAccordingToRemoteLane","remoteLaneId","laneIdToSwitch","debug","toString","getCurrentLaneId","isEqual","BitError","remoteLane","fetchLaneWithItsComponents","name","ids","l","changeVersion","head","localTrackedLane","getAliasByLaneId","undefined","laneToSwitchTo","isOnLane","getIdsOfDefaultLane","LaneId","from","DEFAULT_LANE","toLaneId","tmp","Tmp","componentsStatusP","getComponentStatus","componentsStatus","Promise","all","clear","err","localLaneName","alias","trackLane","remoteScope","setCurrentLane","isNew","bitMap","syncWithLanes","returnFailure","msg","modelComponent","getModelComponentIfExist","unmerged","objects","unmergedComponents","getEntry","version","existingBitMapId","getBitIdIfExist","ignoreVersion","componentOnLane","loadVersion","isRemoved","existingOnWorkspaceOnly","componentFromModel","hasVersion","currentlyUsedVersion","baseComponent","loadComponent","isModified","isComponentSourceCodeModified","isHeadSameAsMain","getHead","tagVersion","getTagOfRefIfExists","headVersion","otherComponent","threeWayMerge","otherLabel","currentComponent","currentLabel"],"sources":["switch-lanes.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { LaneId, DEFAULT_LANE } from '@teambit/lane-id';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ComponentWithDependencies } from '@teambit/legacy/dist/scope';\nimport { Version, Lane } from '@teambit/legacy/dist/scope/models';\nimport { Tmp } from '@teambit/legacy/dist/scope/repositories';\nimport {\n applyVersion,\n ComponentStatus,\n CheckoutProps,\n deleteFilesIfNeeded,\n markFilesToBeRemovedIfNeeded,\n} from '@teambit/legacy/dist/consumer/versions-ops/checkout-version';\nimport ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';\nimport {\n FailedComponents,\n getMergeStrategyInteractive,\n ApplyVersionResults,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport threeWayMerge, {\n MergeResultsThreeWay,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';\nimport { Workspace } from '@teambit/workspace';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { LanesMain } from './lanes.main.runtime';\n\nexport type SwitchProps = {\n laneName: string;\n ids?: BitId[];\n existingOnWorkspaceOnly: boolean;\n remoteLane?: Lane;\n localTrackedLane?: string;\n alias?: string;\n};\n\nexport class LaneSwitcher {\n private consumer: Consumer;\n private laneIdToSwitch: LaneId; // populated by `this.populateSwitchProps()`\n private laneToSwitchTo: Lane | undefined; // populated by `this.populateSwitchProps()`, if default-lane, it's undefined\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private switchProps: SwitchProps,\n private checkoutProps: CheckoutProps,\n private Lanes: LanesMain\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n async switch(): Promise<ApplyVersionResults> {\n this.logger.setStatusLine(`switching lanes`);\n await this.populateSwitchProps();\n const allComponentsStatus: ComponentStatus[] = await this.getAllComponentsStatus();\n const componentWithConflict = allComponentsStatus.find(\n (component) => component.mergeResults && component.mergeResults.hasConflicts\n );\n if (componentWithConflict) {\n if (!this.checkoutProps.promptMergeOptions && !this.checkoutProps.mergeStrategy) {\n throw new GeneralError(\n `automatic merge has failed for component ${componentWithConflict.id.toStringWithoutVersion()}.\\nplease use \"--manual\" to manually merge changes or use \"--theirs / --ours\" to choose one of the conflicted versions`\n );\n }\n if (!this.checkoutProps.mergeStrategy) this.checkoutProps.mergeStrategy = await getMergeStrategyInteractive();\n }\n const failedComponents: FailedComponents[] = allComponentsStatus\n .filter((componentStatus) => componentStatus.failureMessage)\n .map((componentStatus) => ({\n id: componentStatus.id,\n failureMessage: componentStatus.failureMessage as string,\n unchangedLegitimately: componentStatus.unchangedLegitimately,\n }));\n\n const succeededComponents = allComponentsStatus.filter((componentStatus) => !componentStatus.failureMessage);\n // do not use Promise.all for applyVersion. otherwise, it'll write all components in parallel,\n // which can be an issue when some components are also dependencies of others\n const componentsResults = await mapSeries(succeededComponents, ({ id, componentFromFS, mergeResults }) => {\n return applyVersion(this.consumer, id, componentFromFS, mergeResults, this.checkoutProps);\n });\n\n markFilesToBeRemovedIfNeeded(succeededComponents, componentsResults);\n\n await this.saveLanesData();\n\n const componentsWithDependencies = componentsResults\n .map((c) => c.component)\n .filter((c) => c) as ComponentWithDependencies[];\n\n const manyComponentsWriter = new ManyComponentsWriter({\n consumer: this.consumer,\n componentsWithDependencies,\n installNpmPackages: !this.checkoutProps.skipNpmInstall,\n override: true,\n verbose: this.checkoutProps.verbose,\n writeConfig: this.checkoutProps.writeConfig,\n });\n await manyComponentsWriter.writeAll();\n await deleteFilesIfNeeded(componentsResults, this.consumer);\n\n const appliedVersionComponents = componentsResults.map((c) => c.applyVersionResult);\n\n await this.consumer.onDestroy();\n\n return { components: appliedVersionComponents, failedComponents };\n }\n\n private async populateSwitchProps() {\n const laneId = await this.consumer.scope.lanes.parseLaneIdFromString(this.switchProps.laneName);\n\n const localLane = await this.consumer.scope.loadLane(laneId);\n if (laneId.isDefault()) {\n await this.populatePropsAccordingToDefaultLane();\n } else if (localLane) {\n this.populatePropsAccordingToLocalLane(localLane);\n } else {\n await this.populatePropsAccordingToRemoteLane(laneId);\n }\n }\n\n private async populatePropsAccordingToRemoteLane(remoteLaneId: LaneId) {\n this.laneIdToSwitch = remoteLaneId;\n this.logger.debug(`populatePropsAccordingToRemoteLane, remoteLaneId: ${remoteLaneId.toString()}`);\n if (this.consumer.getCurrentLaneId().isEqual(remoteLaneId)) {\n throw new BitError(`already checked out to \"${remoteLaneId.toString()}\"`);\n }\n const remoteLane = await this.Lanes.fetchLaneWithItsComponents(remoteLaneId);\n this.switchProps.laneName = remoteLaneId.name;\n this.switchProps.ids = remoteLane.components.map((l) => l.id.changeVersion(l.head.toString()));\n this.switchProps.localTrackedLane = this.consumer.scope.lanes.getAliasByLaneId(remoteLaneId) || undefined;\n this.switchProps.remoteLane = remoteLane;\n this.laneToSwitchTo = remoteLane;\n this.logger.debug(`populatePropsAccordingToRemoteLane, completed`);\n }\n\n private async populatePropsAccordingToDefaultLane() {\n if (!this.consumer.isOnLane()) {\n throw new BitError(`already checked out to \"${this.switchProps.laneName}\"`);\n }\n this.switchProps.ids = await this.consumer.getIdsOfDefaultLane();\n this.laneIdToSwitch = LaneId.from(DEFAULT_LANE, this.consumer.scope.name);\n }\n\n private populatePropsAccordingToLocalLane(localLane: Lane) {\n if (this.consumer.getCurrentLaneId().name === this.switchProps.laneName) {\n throw new BitError(`already checked out to \"${this.switchProps.laneName}\"`);\n }\n this.switchProps.ids = localLane.components.map((c) => c.id.changeVersion(c.head.toString()));\n this.laneIdToSwitch = localLane.toLaneId();\n this.laneToSwitchTo = localLane;\n }\n\n private async getAllComponentsStatus(): Promise<ComponentStatus[]> {\n const { ids } = this.switchProps;\n const tmp = new Tmp(this.consumer.scope);\n try {\n const componentsStatusP = (ids as BitId[]).map((id) => getComponentStatus(this.consumer, id, this.switchProps));\n const componentsStatus = await Promise.all(componentsStatusP);\n await tmp.clear();\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return componentsStatus;\n } catch (err: any) {\n await tmp.clear();\n throw err;\n }\n }\n\n private async saveLanesData() {\n const localLaneName = this.switchProps.alias || this.laneIdToSwitch.name;\n if (this.switchProps.remoteLane) {\n if (!this.switchProps.localTrackedLane) {\n this.consumer.scope.lanes.trackLane({\n localLane: localLaneName,\n remoteLane: this.laneIdToSwitch.name,\n remoteScope: this.laneIdToSwitch.scope,\n });\n }\n }\n\n this.consumer.setCurrentLane(this.laneIdToSwitch, !this.laneToSwitchTo?.isNew);\n this.consumer.bitMap.syncWithLanes(this.laneToSwitchTo);\n }\n}\n\nasync function getComponentStatus(consumer: Consumer, id: BitId, switchProps: SwitchProps): Promise<ComponentStatus> {\n const componentStatus: ComponentStatus = { id };\n const returnFailure = (msg: string, unchangedLegitimately = false) => {\n componentStatus.failureMessage = msg;\n componentStatus.unchangedLegitimately = unchangedLegitimately;\n return componentStatus;\n };\n const modelComponent = await consumer.scope.getModelComponentIfExist(id);\n if (!modelComponent) {\n return returnFailure(`component ${id.toString()} had never imported`, true);\n }\n const unmerged = consumer.scope.objects.unmergedComponents.getEntry(id.name);\n if (unmerged) {\n return returnFailure(\n `component ${id.toStringWithoutVersion()} is in during-merge state, please snap/tag it first (or use bit merge --resolve/--abort)`\n );\n }\n const version = id.version;\n if (!version) {\n return returnFailure(`component doesn't have any snaps on ${DEFAULT_LANE}`, true);\n }\n const existingBitMapId = consumer.bitMap.getBitIdIfExist(id, { ignoreVersion: true });\n const componentOnLane: Version = await modelComponent.loadVersion(version, consumer.scope.objects);\n if (componentOnLane.isRemoved()) {\n return returnFailure(`component has been removed`, true);\n }\n if (!existingBitMapId) {\n if (switchProps.existingOnWorkspaceOnly) {\n return returnFailure(`component ${id.toStringWithoutVersion()} is not in the workspace`, true);\n }\n return { componentFromFS: undefined, componentFromModel: componentOnLane, id, mergeResults: null };\n }\n if (!existingBitMapId.hasVersion()) {\n // happens when switching from main to a lane and a component was snapped on the lane.\n // in the .bitmap file, the version is \"latest\" or empty. so we just need to write the component according to the\n // model. we don't care about the componentFromFS\n return { componentFromFS: undefined, componentFromModel: componentOnLane, id, mergeResults: null };\n }\n const currentlyUsedVersion = existingBitMapId.version;\n if (currentlyUsedVersion === version) {\n return returnFailure(`component ${id.toStringWithoutVersion()} is already at version ${version}`, true);\n }\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const baseComponent: Version = await modelComponent.loadVersion(currentlyUsedVersion, consumer.scope.objects);\n const component = await consumer.loadComponent(existingBitMapId);\n // don't use `consumer.isModified` here. otherwise, if there are dependency changes, the user can't discard them\n // and won't be able to switch lanes.\n const isModified = await consumer.isComponentSourceCodeModified(baseComponent, component);\n let mergeResults: MergeResultsThreeWay | null | undefined;\n const isHeadSameAsMain = () => {\n const head = modelComponent.getHead();\n if (!head) return false;\n if (!existingBitMapId.version) return false;\n const tagVersion = modelComponent.getTagOfRefIfExists(head);\n const headVersion = tagVersion || head.toString();\n return existingBitMapId.version === headVersion;\n };\n if (isModified) {\n if (!isHeadSameAsMain()) {\n throw new GeneralError(\n `unable to checkout ${id.toStringWithoutVersion()}, the component is modified and belongs to another lane`\n );\n }\n\n const otherComponent: Version = await modelComponent.loadVersion(\n existingBitMapId.version as string, // we are here because the head is same as main. so, existingBitMapId.version must be set\n consumer.scope.objects\n );\n mergeResults = await threeWayMerge({\n consumer,\n otherComponent,\n otherLabel: version,\n currentComponent: component,\n currentLabel: `${currentlyUsedVersion} modified`,\n baseComponent,\n });\n }\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return { componentFromFS: component, componentFromModel: componentOnLane, id, mergeResults };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAYO,MAAMA,YAAY,CAAC;EAEQ;EACU;EAC1CC,WAAW,CACDC,SAAoB,EACpBC,MAAc,EACdC,WAAwB,EACxBC,aAA4B,EAC5BC,KAAgB,EACxB;IAAA,KALQJ,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,KACdC,WAAwB,GAAxBA,WAAwB;IAAA,KACxBC,aAA4B,GAA5BA,aAA4B;IAAA,KAC5BC,KAAgB,GAAhBA,KAAgB;IAAA;IA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OAAO+C,gBAAgB,CAACD,OAAO,KAAKmB,WAAW;EACjD,CAAC;EACD,IAAIN,UAAU,EAAE;IACd,IAAI,CAACE,gBAAgB,EAAE,EAAE;MACvB,MAAM,KAAI3G,uBAAY,EACnB,sBAAqBC,EAAE,CAACC,sBAAsB,EAAG,yDAAwD,CAC3G;IACH;IAEA,MAAM8G,cAAuB,GAAG,MAAM1B,cAAc,CAACW,WAAW,CAC9DJ,gBAAgB,CAACD,OAAO;IAAY;IACpCzG,QAAQ,CAAC8C,KAAK,CAACwD,OAAO,CACvB;IACD7F,YAAY,GAAG,MAAM,IAAAqH,wBAAa,EAAC;MACjC9H,QAAQ;MACR6H,cAAc;MACdE,UAAU,EAAEtB,OAAO;MACnBuB,gBAAgB,EAAExH,SAAS;MAC3ByH,YAAY,EAAG,GAAEd,oBAAqB,WAAU;MAChDC;IACF,CAAC,CAAC;EACJ;EACA;EACA,OAAO;IAAE1F,eAAe,EAAElB,SAAS;IAAEyG,kBAAkB,EAAEJ,eAAe;IAAE/F,EAAE;IAAEL;EAAa,CAAC;AAC9F"}
|
package/dist/switch.cmd.js
CHANGED
@@ -1,46 +1,33 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
6
|
-
|
7
5
|
require("core-js/modules/es.promise.js");
|
8
|
-
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
10
7
|
value: true
|
11
8
|
});
|
12
9
|
exports.SwitchCmd = void 0;
|
13
|
-
|
14
10
|
function _defineProperty2() {
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
16
|
-
|
17
12
|
_defineProperty2 = function () {
|
18
13
|
return data;
|
19
14
|
};
|
20
|
-
|
21
15
|
return data;
|
22
16
|
}
|
23
|
-
|
24
17
|
function _chalk() {
|
25
18
|
const data = _interopRequireDefault(require("chalk"));
|
26
|
-
|
27
19
|
_chalk = function () {
|
28
20
|
return data;
|
29
21
|
};
|
30
|
-
|
31
22
|
return data;
|
32
23
|
}
|
33
|
-
|
34
24
|
function _mergeVersion() {
|
35
25
|
const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
|
36
|
-
|
37
26
|
_mergeVersion = function () {
|
38
27
|
return data;
|
39
28
|
};
|
40
|
-
|
41
29
|
return data;
|
42
30
|
}
|
43
|
-
|
44
31
|
class SwitchCmd {
|
45
32
|
constructor(lanes) {
|
46
33
|
this.lanes = lanes;
|
@@ -51,7 +38,6 @@ class SwitchCmd {
|
|
51
38
|
(0, _defineProperty2().default)(this, "options", [['n', 'alias <string>', 'relevant when the specified lane is a remote late. name a local lane differently than the remote lane'], ['m', 'merge [strategy]', 'merge local changes with the checked out version. strategy should be "theirs", "ours" or "manual"'], ['a', 'get-all', 'checkout all components in a lane include ones that do not exist in the workspace'], ['', 'skip-dependency-installation', 'do not install packages of the imported components'], ['j', 'json', 'return the output as JSON']]);
|
52
39
|
(0, _defineProperty2().default)(this, "loader", true);
|
53
40
|
}
|
54
|
-
|
55
41
|
async report([lane], {
|
56
42
|
alias,
|
57
43
|
merge,
|
@@ -68,14 +54,12 @@ class SwitchCmd {
|
|
68
54
|
getAll,
|
69
55
|
skipDependencyInstallation
|
70
56
|
});
|
71
|
-
|
72
57
|
if (json) {
|
73
58
|
return JSON.stringify({
|
74
59
|
components,
|
75
60
|
failedComponents
|
76
61
|
}, null, 4);
|
77
62
|
}
|
78
|
-
|
79
63
|
const getFailureOutput = () => {
|
80
64
|
if (!failedComponents || !failedComponents.length) return '';
|
81
65
|
const title = 'the switch has been canceled on the following component(s)';
|
@@ -85,31 +69,24 @@ class SwitchCmd {
|
|
85
69
|
}).join('\n');
|
86
70
|
return `${title}\n${body}\n\n`;
|
87
71
|
};
|
88
|
-
|
89
72
|
const getSuccessfulOutput = () => {
|
90
73
|
const laneSwitched = _chalk().default.green(`\nsuccessfully set "${_chalk().default.bold(lane)}" as the active lane`);
|
91
|
-
|
92
74
|
if (!components || !components.length) return `No component had been changed.${laneSwitched}`;
|
93
|
-
|
94
75
|
if (components.length === 1) {
|
95
76
|
const component = components[0];
|
96
77
|
const componentName = component.id.toStringWithoutVersion();
|
97
78
|
const title = `successfully switched ${_chalk().default.bold(componentName)} to version ${_chalk().default.bold(component.id.version)}\n`;
|
98
79
|
return `${title} ${(0, _mergeVersion().applyVersionReport)(components, false)}${laneSwitched}`;
|
99
80
|
}
|
100
|
-
|
101
81
|
const title = `successfully switched the following components to the version of ${lane}\n\n`;
|
102
82
|
const componentsStr = (0, _mergeVersion().applyVersionReport)(components, true, false);
|
103
83
|
return title + componentsStr + laneSwitched;
|
104
84
|
};
|
105
|
-
|
106
85
|
const failedOutput = getFailureOutput();
|
107
86
|
const successOutput = getSuccessfulOutput();
|
108
87
|
return failedOutput + successOutput;
|
109
88
|
}
|
110
|
-
|
111
89
|
}
|
112
|
-
|
113
90
|
exports.SwitchCmd = SwitchCmd;
|
114
91
|
|
115
92
|
//# sourceMappingURL=switch.cmd.js.map
|
package/dist/switch.cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["SwitchCmd","constructor","lanes","report","lane","alias","merge","getAll","skipDependencyInstallation","json","components","failedComponents","switchLanes","JSON","stringify","getFailureOutput","length","title","body","map","failedComponent","color","unchangedLegitimately","chalk","bold","id","toString","failureMessage","join","getSuccessfulOutput","laneSwitched","green","component","componentName","toStringWithoutVersion","version","applyVersionReport","componentsStr","failedOutput","successOutput"],"sources":["switch.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { MergeStrategy, applyVersionReport } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport { LanesMain } from './lanes.main.runtime';\n\nexport class SwitchCmd implements Command {\n name = 'switch <lane>';\n description = `switch to the specified lane`;\n private = true;\n alias = '';\n options = [\n [\n 'n',\n 'alias <string>',\n 'relevant when the specified lane is a remote late. name a local lane differently than the remote lane',\n ],\n [\n 'm',\n 'merge [strategy]',\n 'merge local changes with the checked out version. strategy should be \"theirs\", \"ours\" or \"manual\"',\n ],\n ['a', 'get-all', 'checkout all components in a lane include ones that do not exist in the workspace'],\n ['', 'skip-dependency-installation', 'do not install packages of the imported components'],\n ['j', 'json', 'return the output as JSON'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private lanes: LanesMain) {}\n\n async report(\n [lane]: [string],\n {\n alias,\n merge,\n getAll = false,\n skipDependencyInstallation = false,\n json = false,\n }: {\n alias?: string;\n merge?: MergeStrategy;\n getAll?: boolean;\n skipDependencyInstallation?: boolean;\n override?: boolean;\n json?: boolean;\n }\n ) {\n const { components, failedComponents } = await this.lanes.switchLanes(lane, {\n alias,\n merge,\n getAll,\n skipDependencyInstallation,\n });\n if (json) {\n return JSON.stringify({ components, failedComponents }, null, 4);\n }\n const getFailureOutput = () => {\n if (!failedComponents || !failedComponents.length) return '';\n const title = 'the switch has been canceled on the following component(s)';\n const body = failedComponents\n .map((failedComponent) => {\n const color = failedComponent.unchangedLegitimately ? 'white' : 'red';\n return `${chalk.bold(failedComponent.id.toString())} - ${chalk[color](failedComponent.failureMessage)}`;\n })\n .join('\\n');\n return `${title}\\n${body}\\n\\n`;\n };\n const getSuccessfulOutput = () => {\n const laneSwitched = chalk.green(`\\nsuccessfully set \"${chalk.bold(lane)}\" as the active lane`);\n if (!components || !components.length) return `No component had been changed.${laneSwitched}`;\n if (components.length === 1) {\n const component = components[0];\n const componentName = component.id.toStringWithoutVersion();\n const title = `successfully switched ${chalk.bold(componentName)} to version ${chalk.bold(\n component.id.version as string\n )}\\n`;\n return `${title} ${applyVersionReport(components, false)}${laneSwitched}`;\n }\n const title = `successfully switched the following components to the version of ${lane}\\n\\n`;\n const componentsStr = applyVersionReport(components, true, false);\n return title + componentsStr + laneSwitched;\n };\n const failedOutput = getFailureOutput();\n const successOutput = getSuccessfulOutput();\n return failedOutput + successOutput;\n }\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["SwitchCmd","constructor","lanes","report","lane","alias","merge","getAll","skipDependencyInstallation","json","components","failedComponents","switchLanes","JSON","stringify","getFailureOutput","length","title","body","map","failedComponent","color","unchangedLegitimately","chalk","bold","id","toString","failureMessage","join","getSuccessfulOutput","laneSwitched","green","component","componentName","toStringWithoutVersion","version","applyVersionReport","componentsStr","failedOutput","successOutput"],"sources":["switch.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { MergeStrategy, applyVersionReport } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport { LanesMain } from './lanes.main.runtime';\n\nexport class SwitchCmd implements Command {\n name = 'switch <lane>';\n description = `switch to the specified lane`;\n private = true;\n alias = '';\n options = [\n [\n 'n',\n 'alias <string>',\n 'relevant when the specified lane is a remote late. name a local lane differently than the remote lane',\n ],\n [\n 'm',\n 'merge [strategy]',\n 'merge local changes with the checked out version. strategy should be \"theirs\", \"ours\" or \"manual\"',\n ],\n ['a', 'get-all', 'checkout all components in a lane include ones that do not exist in the workspace'],\n ['', 'skip-dependency-installation', 'do not install packages of the imported components'],\n ['j', 'json', 'return the output as JSON'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private lanes: LanesMain) {}\n\n async report(\n [lane]: [string],\n {\n alias,\n merge,\n getAll = false,\n skipDependencyInstallation = false,\n json = false,\n }: {\n alias?: string;\n merge?: MergeStrategy;\n getAll?: boolean;\n skipDependencyInstallation?: boolean;\n override?: boolean;\n json?: boolean;\n }\n ) {\n const { components, failedComponents } = await this.lanes.switchLanes(lane, {\n alias,\n merge,\n getAll,\n skipDependencyInstallation,\n });\n if (json) {\n return JSON.stringify({ components, failedComponents }, null, 4);\n }\n const getFailureOutput = () => {\n if (!failedComponents || !failedComponents.length) return '';\n const title = 'the switch has been canceled on the following component(s)';\n const body = failedComponents\n .map((failedComponent) => {\n const color = failedComponent.unchangedLegitimately ? 'white' : 'red';\n return `${chalk.bold(failedComponent.id.toString())} - ${chalk[color](failedComponent.failureMessage)}`;\n })\n .join('\\n');\n return `${title}\\n${body}\\n\\n`;\n };\n const getSuccessfulOutput = () => {\n const laneSwitched = chalk.green(`\\nsuccessfully set \"${chalk.bold(lane)}\" as the active lane`);\n if (!components || !components.length) return `No component had been changed.${laneSwitched}`;\n if (components.length === 1) {\n const component = components[0];\n const componentName = component.id.toStringWithoutVersion();\n const title = `successfully switched ${chalk.bold(componentName)} to version ${chalk.bold(\n component.id.version as string\n )}\\n`;\n return `${title} ${applyVersionReport(components, false)}${laneSwitched}`;\n }\n const title = `successfully switched the following components to the version of ${lane}\\n\\n`;\n const componentsStr = applyVersionReport(components, true, false);\n return title + componentsStr + laneSwitched;\n };\n const failedOutput = getFailureOutput();\n const successOutput = getSuccessfulOutput();\n return failedOutput + successOutput;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,SAAS,CAAoB;EAsBxCC,WAAW,CAASC,KAAgB,EAAE;IAAA,KAAlBA,KAAgB,GAAhBA,KAAgB;IAAA,8CArB7B,eAAe;IAAA,qDACP,8BAA6B;IAAA,iDAClC,IAAI;IAAA,+CACN,EAAE;IAAA,iDACA,CACR,CACE,GAAG,EACH,gBAAgB,EAChB,uGAAuG,CACxG,EACD,CACE,GAAG,EACH,kBAAkB,EAClB,mGAAmG,CACpG,EACD,CAAC,GAAG,EAAE,SAAS,EAAE,mFAAmF,CAAC,EACrG,CAAC,EAAE,EAAE,8BAA8B,EAAE,oDAAoD,CAAC,EAC1F,CAAC,GAAG,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAC3C;IAAA,gDACQ,IAAI;EAE0B;EAEvC,MAAMC,MAAM,CACV,CAACC,IAAI,CAAW,EAChB;IACEC,KAAK;IACLC,KAAK;IACLC,MAAM,GAAG,KAAK;IACdC,0BAA0B,GAAG,KAAK;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