@teambit/lanes 0.0.290 → 0.0.291
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/lanes.main.runtime.d.ts +21 -3
- package/dist/lanes.main.runtime.js +89 -5
- package/dist/lanes.main.runtime.js.map +1 -1
- package/dist/switch-lanes.d.ts +32 -0
- package/dist/switch-lanes.js +461 -0
- package/dist/switch-lanes.js.map +1 -0
- package/dist/switch.cmd.d.ts +4 -2
- package/dist/switch.cmd.js +9 -66
- package/dist/switch.cmd.js.map +1 -1
- package/package-tar/teambit-lanes-0.0.291.tgz +0 -0
- package/package.json +19 -18
- package/{preview-1650964831029.js → preview-1651029886240.js} +2 -2
- package/package-tar/teambit-lanes-0.0.290.tgz +0 -0
@@ -3,6 +3,7 @@ import { ScopeMain } from '@teambit/scope';
|
|
3
3
|
import { GraphqlMain } from '@teambit/graphql';
|
4
4
|
import { Workspace } from '@teambit/workspace';
|
5
5
|
import { LaneData } from '@teambit/legacy/dist/scope/lanes/lanes';
|
6
|
+
import { Logger, LoggerMain } from '@teambit/logger';
|
6
7
|
import { DiffOptions } from '@teambit/legacy/dist/consumer/component-ops/components-diff';
|
7
8
|
import { MergeStrategy, ApplyVersionResults } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';
|
8
9
|
import { TrackLane } from '@teambit/legacy/dist/scope/scope-json';
|
@@ -26,12 +27,21 @@ export declare type CreateLaneOptions = {
|
|
26
27
|
remoteScope?: string;
|
27
28
|
remoteName?: string;
|
28
29
|
};
|
30
|
+
export declare type SwitchLaneOptions = {
|
31
|
+
newLaneName?: string;
|
32
|
+
merge?: MergeStrategy;
|
33
|
+
getAll?: boolean;
|
34
|
+
skipDependencyInstallation?: boolean;
|
35
|
+
verbose?: boolean;
|
36
|
+
override?: boolean;
|
37
|
+
};
|
29
38
|
export declare class LanesMain {
|
30
39
|
private workspace;
|
31
40
|
private scope;
|
32
41
|
private merging;
|
33
42
|
private componentAspect;
|
34
|
-
|
43
|
+
private logger;
|
44
|
+
constructor(workspace: Workspace | undefined, scope: ScopeMain, merging: MergingMain, componentAspect: ComponentMain, logger: Logger);
|
35
45
|
getLanes({ name, remote, merged, showDefaultLane, notMerged, }: {
|
36
46
|
name?: string;
|
37
47
|
remote?: string;
|
@@ -53,6 +63,13 @@ export declare class LanesMain {
|
|
53
63
|
mergeResults: ApplyVersionResults;
|
54
64
|
deleteResults: any;
|
55
65
|
}>;
|
66
|
+
/**
|
67
|
+
* switch to a different local or remote lane.
|
68
|
+
* switching to a remote lane also imports and writes the components of that remote lane.
|
69
|
+
* by default, only the components existing on the workspace will be imported from that lane, unless the "getAll"
|
70
|
+
* flag is true.
|
71
|
+
*/
|
72
|
+
switchLanes(laneName: string, { newLaneName, merge, getAll, skipDependencyInstallation }: SwitchLaneOptions): Promise<ApplyVersionResults>;
|
56
73
|
/**
|
57
74
|
* the values array may include zero to two values and will be processed as following:
|
58
75
|
* [] => diff between the current lane and default lane. (only inside workspace).
|
@@ -79,14 +96,15 @@ export declare class LanesMain {
|
|
79
96
|
static slots: never[];
|
80
97
|
static dependencies: import("@teambit/harmony").Aspect[];
|
81
98
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
82
|
-
static provider([cli, scope, workspace, graphql, community, merging, component]: [
|
99
|
+
static provider([cli, scope, workspace, graphql, community, merging, component, loggerMain]: [
|
83
100
|
CLIMain,
|
84
101
|
ScopeMain,
|
85
102
|
Workspace,
|
86
103
|
GraphqlMain,
|
87
104
|
CommunityMain,
|
88
105
|
MergingMain,
|
89
|
-
ComponentMain
|
106
|
+
ComponentMain,
|
107
|
+
LoggerMain
|
90
108
|
]): Promise<LanesMain>;
|
91
109
|
}
|
92
110
|
export default LanesMain;
|
@@ -121,6 +121,26 @@ function _constants() {
|
|
121
121
|
return data;
|
122
122
|
}
|
123
123
|
|
124
|
+
function _logger() {
|
125
|
+
const data = require("@teambit/logger");
|
126
|
+
|
127
|
+
_logger = function () {
|
128
|
+
return data;
|
129
|
+
};
|
130
|
+
|
131
|
+
return data;
|
132
|
+
}
|
133
|
+
|
134
|
+
function _mergeVersion() {
|
135
|
+
const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
|
136
|
+
|
137
|
+
_mergeVersion = function () {
|
138
|
+
return data;
|
139
|
+
};
|
140
|
+
|
141
|
+
return data;
|
142
|
+
}
|
143
|
+
|
124
144
|
function _community() {
|
125
145
|
const data = require("@teambit/community");
|
126
146
|
|
@@ -211,16 +231,27 @@ function _mergeLanes() {
|
|
211
231
|
return data;
|
212
232
|
}
|
213
233
|
|
234
|
+
function _switchLanes() {
|
235
|
+
const data = require("./switch-lanes");
|
236
|
+
|
237
|
+
_switchLanes = function () {
|
238
|
+
return data;
|
239
|
+
};
|
240
|
+
|
241
|
+
return data;
|
242
|
+
}
|
243
|
+
|
214
244
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
215
245
|
|
216
246
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
217
247
|
|
218
248
|
class LanesMain {
|
219
|
-
constructor(workspace, scope, merging, componentAspect) {
|
249
|
+
constructor(workspace, scope, merging, componentAspect, logger) {
|
220
250
|
this.workspace = workspace;
|
221
251
|
this.scope = scope;
|
222
252
|
this.merging = merging;
|
223
253
|
this.componentAspect = componentAspect;
|
254
|
+
this.logger = logger;
|
224
255
|
}
|
225
256
|
|
226
257
|
async getLanes({
|
@@ -334,6 +365,58 @@ class LanesMain {
|
|
334
365
|
this.workspace.consumer.bitMap.syncWithLanes(this.workspace.consumer.bitMap.workspaceLane);
|
335
366
|
return results;
|
336
367
|
}
|
368
|
+
/**
|
369
|
+
* switch to a different local or remote lane.
|
370
|
+
* switching to a remote lane also imports and writes the components of that remote lane.
|
371
|
+
* by default, only the components existing on the workspace will be imported from that lane, unless the "getAll"
|
372
|
+
* flag is true.
|
373
|
+
*/
|
374
|
+
|
375
|
+
|
376
|
+
async switchLanes(laneName, {
|
377
|
+
newLaneName,
|
378
|
+
merge,
|
379
|
+
getAll = false,
|
380
|
+
skipDependencyInstallation = false
|
381
|
+
}) {
|
382
|
+
if (!this.workspace) {
|
383
|
+
throw new (_bitError().BitError)(`unable to switch lanes outside of Bit workspace`);
|
384
|
+
}
|
385
|
+
|
386
|
+
let mergeStrategy;
|
387
|
+
|
388
|
+
if (merge && typeof merge === 'string') {
|
389
|
+
const mergeOptions = Object.keys(_mergeVersion().MergeOptions);
|
390
|
+
|
391
|
+
if (!mergeOptions.includes(merge)) {
|
392
|
+
throw new (_bitError().BitError)(`merge must be one of the following: ${mergeOptions.join(', ')}`);
|
393
|
+
}
|
394
|
+
|
395
|
+
mergeStrategy = merge;
|
396
|
+
}
|
397
|
+
|
398
|
+
const switchProps = {
|
399
|
+
laneName,
|
400
|
+
existingOnWorkspaceOnly: !getAll,
|
401
|
+
newLaneName
|
402
|
+
};
|
403
|
+
const checkoutProps = {
|
404
|
+
mergeStrategy,
|
405
|
+
skipNpmInstall: skipDependencyInstallation,
|
406
|
+
verbose: false,
|
407
|
+
// not relevant in Harmony
|
408
|
+
ignorePackageJson: true,
|
409
|
+
// not relevant in Harmony
|
410
|
+
ignoreDist: true,
|
411
|
+
// not relevant in Harmony
|
412
|
+
isLane: true,
|
413
|
+
promptMergeOptions: false,
|
414
|
+
writeConfig: false,
|
415
|
+
reset: false,
|
416
|
+
all: false
|
417
|
+
};
|
418
|
+
return new (_switchLanes().LaneSwitcher)(this.workspace, this.logger, switchProps, checkoutProps).switch();
|
419
|
+
}
|
337
420
|
/**
|
338
421
|
* the values array may include zero to two values and will be processed as following:
|
339
422
|
* [] => diff between the current lane and default lane. (only inside workspace).
|
@@ -488,10 +571,11 @@ class LanesMain {
|
|
488
571
|
};
|
489
572
|
}
|
490
573
|
|
491
|
-
static async provider([cli, scope, workspace, graphql, community, merging, component]) {
|
492
|
-
const
|
574
|
+
static async provider([cli, scope, workspace, graphql, community, merging, component, loggerMain]) {
|
575
|
+
const logger = loggerMain.createLogger(_lanes().LanesAspect.id);
|
576
|
+
const lanesMain = new LanesMain(workspace, scope, merging, component, logger);
|
493
577
|
const isLegacy = workspace && workspace.consumer.isLegacy;
|
494
|
-
const switchCmd = new (_switch().SwitchCmd)();
|
578
|
+
const switchCmd = new (_switch().SwitchCmd)(lanesMain);
|
495
579
|
|
496
580
|
if (!isLegacy) {
|
497
581
|
const laneCmd = new (_lane().LaneCmd)(lanesMain, workspace, scope, community.getDocsDomain());
|
@@ -507,7 +591,7 @@ class LanesMain {
|
|
507
591
|
|
508
592
|
exports.LanesMain = LanesMain;
|
509
593
|
(0, _defineProperty2().default)(LanesMain, "slots", []);
|
510
|
-
(0, _defineProperty2().default)(LanesMain, "dependencies", [_cli().CLIAspect, _scope().ScopeAspect, _workspace().WorkspaceAspect, _graphql().GraphqlAspect, _community().CommunityAspect, _merging().MergingAspect, _component().default]);
|
594
|
+
(0, _defineProperty2().default)(LanesMain, "dependencies", [_cli().CLIAspect, _scope().ScopeAspect, _workspace().WorkspaceAspect, _graphql().GraphqlAspect, _community().CommunityAspect, _merging().MergingAspect, _component().default, _logger().LoggerAspect]);
|
511
595
|
(0, _defineProperty2().default)(LanesMain, "runtime", _cli().MainRuntime);
|
512
596
|
|
513
597
|
_lanes().LanesAspect.addRuntime(LanesMain);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["lanes.main.runtime.ts"],"names":["LanesMain","constructor","workspace","scope","merging","componentAspect","getLanes","name","remote","merged","showDefaultLane","notMerged","showMergeData","Boolean","consumer","remoteObj","lanes","listLanes","DEFAULT_LANE","defaultLane","getLaneDataOfDefaultLane","legacyScope","getLanesData","push","getCurrentLane","getCurrentLaneName","createLane","remoteScope","remoteName","BitError","setCurrentLane","trackLaneData","localLane","remoteLane","defaultScope","trackLane","onDestroy","localName","lane","loadLane","LaneId","from","beforeTrackData","getRemoteTrackedDataByLocalLane","beforeTrackDataCloned","undefined","afterTrackData","removeLanes","laneNames","force","results","laneResults","mergeLane","laneName","options","bitMap","syncWithLanes","workspaceLane","getDiff","values","diffOptions","laneDiffGenerator","LaneDiffGenerator","generate","getLaneComponentModels","laneComponents","components","host","getHost","laneComponentIds","Promise","all","map","laneComponent","legacyIdWithVersion","id","changeVersion","head","resolveComponentId","getMany","getLaneReadmeComponent","laneReadmeComponent","readmeComponent","laneReadmeComponentId","get","removeLaneReadme","currentLaneName","result","message","laneId","readmeComponentId","existingLaneConfig","getSpecificComponentConfig","LanesAspect","remoteLaneIdStr","remoteLaneId","toString","readme","removeSpecificComponentConfig","addSpecificComponentConfig","setReadmeComponent","saveLane","write","addLaneReadme","readmeComponentIdStr","readmeComponentBitId","_legacy","bitIds","scopeComponents","list","filter","component","getAuthoredAndImportedBitIdsOfDefaultLane","bitId","version","isMerged","provider","cli","graphql","community","lanesMain","isLegacy","switchCmd","SwitchCmd","laneCmd","LaneCmd","getDocsDomain","commands","LaneListCmd","LaneShowCmd","LaneCreateCmd","LaneMergeCmd","LaneRemoveCmd","LaneTrackCmd","LaneDiffCmd","LaneAddReadmeCmd","LaneRemoveReadmeCmd","LaneImportCmd","register","CLIAspect","ScopeAspect","WorkspaceAspect","GraphqlAspect","CommunityAspect","MergingAspect","ComponentAspect","MainRuntime","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;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AAA,OAAO,CAACG,QAAR,GAAmB,CACjB,KAAIC,mBAAJ,EAAgBR,SAAhB,EAA2BtH,SAA3B,EAAsCC,KAAtC,CADiB,EAEjBuH,SAFiB,EAGjB,KAAIO,mBAAJ,EAAgBT,SAAhB,EAA2BtH,SAA3B,EAAsCC,KAAtC,CAHiB,EAIjB,KAAI+H,qBAAJ,EAAkBV,SAAlB,CAJiB,EAKjB,KAAIW,oBAAJ,EAAiBX,SAAjB,CALiB,EAMjB,KAAIY,qBAAJ,EAAkBZ,SAAlB,CANiB,EAOjB,KAAIa,oBAAJ,EAAiBb,SAAjB,CAPiB,EAQjB,KAAIc,2BAAJ,EAAgBpI,SAAhB,EAA2BC,KAA3B,CARiB,EASjB,KAAIoI,wBAAJ,EAAqBf,SAArB,CATiB,EAUjB,KAAIgB,2BAAJ,EAAwBhB,SAAxB,CAViB,EAWjB,KAAIiB,qBAAJ,EAAkBf,SAAlB,CAXiB,CAAnB;AAaAL,MAAAA,GAAG,CAACqB,QAAJ,CAAad,OAAb,EAAsBF,SAAtB;AACAJ,MAAAA,OAAO,CAACoB,QAAR,CAAiB,2BAAYlB,SAAZ,CAAjB;AACD;;AACD,WAAOA,SAAP;AACD;;AAhToB;;;gCAAVxH,S,WAsQI,E;gCAtQJA,S,kBAuQW,CACpB2I,gBADoB,EAEpBC,oBAFoB,EAGpBC,4BAHoB,EAIpBC,wBAJoB,EAKpBC,4BALoB,EAMpBC,wBANoB,EAOpBC,oBAPoB,C;gCAvQXjJ,S,aAgRMkJ,kB;;AAmCnBrD,qBAAYsD,UAAZ,CAAuBnJ,SAAvB;;eAEeA,S","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ScopeMain, ScopeAspect } from '@teambit/scope';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\nimport { LaneDiffCmd, LaneDiffGenerator } from '@teambit/lanes.modules.diff';\nimport { LaneData } from '@teambit/legacy/dist/scope/lanes/lanes';\nimport LaneId from '@teambit/legacy/dist/lane-id/lane-id';\nimport { BitError } from '@teambit/bit-error';\nimport createNewLane from '@teambit/legacy/dist/consumer/lanes/create-lane';\nimport { DEFAULT_LANE } from '@teambit/legacy/dist/constants';\nimport { DiffOptions } from '@teambit/legacy/dist/consumer/component-ops/components-diff';\nimport { MergeStrategy, ApplyVersionResults } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport { TrackLane } from '@teambit/legacy/dist/scope/scope-json';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\nimport ComponentAspect, { Component, ComponentMain } from '@teambit/component';\nimport removeLanes from '@teambit/legacy/dist/consumer/lanes/remove-lanes';\nimport { Lane } from '@teambit/legacy/dist/scope/models';\nimport { Scope as LegacyScope } from '@teambit/legacy/dist/scope';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { MergingMain, MergingAspect } from '@teambit/merging';\nimport { LanesAspect } from './lanes.aspect';\nimport {\n LaneCmd,\n LaneCreateCmd,\n LaneImportCmd,\n LaneListCmd,\n LaneMergeCmd,\n LaneRemoveCmd,\n LaneShowCmd,\n LaneTrackCmd,\n LaneAddReadmeCmd,\n LaneRemoveReadmeCmd,\n} from './lane.cmd';\nimport { lanesSchema } from './lanes.graphql';\nimport { SwitchCmd } from './switch.cmd';\nimport { mergeLanes } from './merge-lanes';\n\nexport type LaneResults = {\n lanes: LaneData[];\n currentLane?: string | null;\n};\n\nexport type MergeLaneOptions = {\n remoteName: string | null;\n mergeStrategy: MergeStrategy;\n noSnap: boolean;\n snapMessage: string;\n existingOnWorkspaceOnly: boolean;\n build: boolean;\n keepReadme: boolean;\n};\n\nexport type CreateLaneOptions = {\n remoteScope?: string; // default to the defaultScope in workspace.jsonc\n remoteName?: string; // default to the local lane\n};\n\nexport class LanesMain {\n constructor(\n private workspace: Workspace | undefined,\n private scope: ScopeMain,\n private merging: MergingMain,\n private componentAspect: ComponentMain\n ) {}\n\n async getLanes({\n name,\n remote,\n merged,\n showDefaultLane,\n notMerged,\n }: {\n name?: string;\n remote?: string;\n merged?: boolean;\n showDefaultLane?: boolean;\n notMerged?: boolean;\n }): Promise<LaneData[]> {\n const showMergeData = Boolean(merged || notMerged);\n const consumer = this.workspace?.consumer;\n if (remote) {\n const remoteObj = await getRemoteByName(remote, consumer);\n const lanes = await remoteObj.listLanes(name, showMergeData);\n return lanes;\n }\n\n if (name === DEFAULT_LANE) {\n const defaultLane = await this.getLaneDataOfDefaultLane();\n return defaultLane ? [defaultLane] : [];\n }\n\n const lanes = await this.scope.legacyScope.lanes.getLanesData(this.scope.legacyScope, name, showMergeData);\n\n if (showDefaultLane) {\n const defaultLane = await this.getLaneDataOfDefaultLane();\n if (defaultLane) lanes.push(defaultLane);\n }\n\n return lanes;\n }\n\n getCurrentLane(): string | null {\n if (!this.workspace?.consumer) return null;\n return this.scope.legacyScope.lanes.getCurrentLaneName();\n }\n\n async createLane(name: string, { remoteScope, remoteName }: CreateLaneOptions = {}): Promise<TrackLane> {\n if (!this.workspace) {\n throw new BitError(`unable to create a lane outside of Bit workspace`);\n }\n await createNewLane(this.workspace.consumer, name);\n this.scope.legacyScope.lanes.setCurrentLane(name);\n const trackLaneData = {\n localLane: name,\n remoteLane: remoteName || name,\n remoteScope: remoteScope || this.workspace.defaultScope,\n };\n this.scope.legacyScope.lanes.trackLane(trackLaneData);\n await this.workspace.consumer.onDestroy();\n\n return trackLaneData;\n }\n\n async trackLane(\n localName: string,\n remoteScope: string,\n remoteName?: string\n ): Promise<{ beforeTrackData?: TrackLane; afterTrackData: TrackLane }> {\n if (!this.workspace) {\n throw new BitError(`unable to track a lane outside of Bit workspace`);\n }\n const lane = await this.scope.legacyScope.lanes.loadLane(LaneId.from(localName));\n if (!lane) {\n throw new BitError(`unable to find a local lane \"${localName}\"`);\n }\n const beforeTrackData = this.scope.legacyScope.lanes.getRemoteTrackedDataByLocalLane(localName);\n const beforeTrackDataCloned = beforeTrackData ? { ...beforeTrackData } : undefined;\n const afterTrackData = {\n localLane: localName,\n remoteLane: remoteName || beforeTrackData?.remoteLane || localName,\n remoteScope,\n };\n this.scope.legacyScope.lanes.trackLane(afterTrackData);\n await this.workspace.consumer.onDestroy();\n\n return { beforeTrackData: beforeTrackDataCloned, afterTrackData };\n }\n\n async removeLanes(laneNames: string[], { remote, force }: { remote: boolean; force: boolean }): Promise<string[]> {\n const results = await removeLanes(this.workspace?.consumer, laneNames, remote, force);\n if (this.workspace) await this.workspace.consumer.onDestroy();\n\n return results.laneResults;\n }\n\n async mergeLane(\n laneName: string,\n options: MergeLaneOptions\n ): Promise<{ mergeResults: ApplyVersionResults; deleteResults: any }> {\n if (!this.workspace) {\n throw new BitError(`unable to merge a lane outside of Bit workspace`);\n }\n const results = await mergeLanes({\n merging: this.merging,\n consumer: this.workspace.consumer,\n laneName,\n ...options,\n });\n\n await this.workspace.consumer.onDestroy();\n this.workspace.consumer.bitMap.syncWithLanes(this.workspace.consumer.bitMap.workspaceLane);\n return results;\n }\n\n /**\n * the values array may include zero to two values and will be processed as following:\n * [] => diff between the current lane and default lane. (only inside workspace).\n * [to] => diff between the current lane (or default-lane when in scope) and \"to\" lane.\n * [from, to] => diff between \"from\" lane and \"to\" lane.\n */\n public getDiff(values: string[], diffOptions: DiffOptions = {}) {\n const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope);\n return laneDiffGenerator.generate(values, diffOptions);\n }\n\n async getLaneComponentModels(name: string): Promise<Component[]> {\n if (!name) return [];\n\n const [lane] = await this.getLanes({ name });\n const laneComponents = lane.components;\n const host = this.componentAspect.getHost();\n const laneComponentIds = await Promise.all(\n laneComponents.map((laneComponent) => {\n const legacyIdWithVersion = laneComponent.id.changeVersion(laneComponent.head);\n return host.resolveComponentId(legacyIdWithVersion);\n })\n );\n const components = await host.getMany(laneComponentIds);\n return components;\n }\n\n async getLaneReadmeComponent(name: string): Promise<Component | undefined> {\n if (!name) return undefined;\n\n const [lane] = await this.getLanes({ name });\n const laneReadmeComponent = lane.readmeComponent;\n if (!laneReadmeComponent) return undefined;\n const host = this.componentAspect.getHost();\n const laneReadmeComponentId = await host.resolveComponentId(\n laneReadmeComponent.id.changeVersion(laneReadmeComponent.head)\n );\n const readmeComponent = await host.get(laneReadmeComponentId);\n return readmeComponent;\n }\n\n async removeLaneReadme(laneName?: string): Promise<{ result: boolean; message?: string }> {\n if (!this.workspace) {\n throw new BitError('unable to remove the lane readme component outside of Bit workspace');\n }\n const currentLaneName = this.getCurrentLane();\n\n if (!laneName && !currentLaneName) {\n return {\n result: false,\n message: 'unable to remove the lane readme component. Either pass a laneName or switch to a lane',\n };\n }\n\n const laneId: LaneId = (laneName && LaneId.from(laneName)) || LaneId.from(currentLaneName as string);\n const scope: LegacyScope = this.workspace.scope.legacyScope;\n const lane: Lane | null | undefined = await scope.loadLane(laneId);\n\n if (!lane?.readmeComponent) {\n throw new BitError(`there is no readme component added to the lane ${laneName || currentLaneName}`);\n }\n\n const readmeComponentId = await this.workspace.resolveComponentId(lane.readmeComponent.id);\n const existingLaneConfig =\n (await this.workspace.getSpecificComponentConfig(readmeComponentId, LanesAspect.id)) || {};\n\n const remoteLaneIdStr = (lane.remoteLaneId || LaneId.from(laneId.name, lane.scope)).toString();\n\n if (existingLaneConfig.readme) {\n delete existingLaneConfig.readme[remoteLaneIdStr];\n await this.workspace.removeSpecificComponentConfig(readmeComponentId, LanesAspect.id, false);\n await this.workspace.addSpecificComponentConfig(readmeComponentId, LanesAspect.id, existingLaneConfig);\n }\n\n lane.setReadmeComponent(undefined);\n await scope.lanes.saveLane(lane);\n await this.workspace.bitMap.write();\n\n return { result: true };\n }\n\n async addLaneReadme(readmeComponentIdStr: string, laneName?: string): Promise<{ result: boolean; message?: string }> {\n if (!this.workspace) {\n throw new BitError(`unable to track a lane readme component outside of Bit workspace`);\n }\n const readmeComponentId = await this.workspace.resolveComponentId(readmeComponentIdStr);\n\n const currentLaneName = this.getCurrentLane();\n\n const readmeComponentBitId = readmeComponentId._legacy;\n\n const laneId: LaneId = (laneName && LaneId.from(laneName)) || LaneId.from(currentLaneName as string);\n const scope: LegacyScope = this.workspace.scope.legacyScope;\n const lane: Lane | null | undefined = await scope.loadLane(laneId);\n\n if (!lane) {\n return { result: false, message: `cannot find lane ${laneName}` };\n }\n\n lane.setReadmeComponent(readmeComponentBitId);\n await scope.lanes.saveLane(lane);\n\n const existingLaneConfig =\n (await this.workspace.getSpecificComponentConfig(readmeComponentId, LanesAspect.id)) || {};\n\n const remoteLaneIdStr = (lane.remoteLaneId || LaneId.from(laneId.name, lane.scope)).toString();\n\n if (existingLaneConfig.readme) {\n await this.workspace.addSpecificComponentConfig(readmeComponentId, LanesAspect.id, {\n ...existingLaneConfig,\n readme: {\n ...existingLaneConfig.readme,\n [remoteLaneIdStr]: true,\n },\n });\n } else {\n await this.workspace.addSpecificComponentConfig(readmeComponentId, LanesAspect.id, {\n ...existingLaneConfig,\n readme: {\n [remoteLaneIdStr]: true,\n },\n });\n }\n await this.workspace.bitMap.write();\n return { result: true };\n }\n\n private async getLaneDataOfDefaultLane(): Promise<LaneData | null> {\n const consumer = this.workspace?.consumer;\n let bitIds: BitId[] = [];\n if (!consumer) {\n const scopeComponents = await this.scope.list();\n bitIds = scopeComponents.filter((component) => component.head).map((component) => component.id._legacy);\n } else {\n bitIds = consumer.bitMap.getAuthoredAndImportedBitIdsOfDefaultLane();\n }\n\n return {\n name: DEFAULT_LANE,\n remote: null,\n components: bitIds.map((bitId) => ({ id: bitId, head: bitId.version as string })),\n isMerged: null,\n };\n }\n\n static slots = [];\n static dependencies = [\n CLIAspect,\n ScopeAspect,\n WorkspaceAspect,\n GraphqlAspect,\n CommunityAspect,\n MergingAspect,\n ComponentAspect,\n ];\n static runtime = MainRuntime;\n static async provider([cli, scope, workspace, graphql, community, merging, component]: [\n CLIMain,\n ScopeMain,\n Workspace,\n GraphqlMain,\n CommunityMain,\n MergingMain,\n ComponentMain\n ]) {\n const lanesMain = new LanesMain(workspace, scope, merging, component);\n const isLegacy = workspace && workspace.consumer.isLegacy;\n const switchCmd = new SwitchCmd();\n if (!isLegacy) {\n const laneCmd = new LaneCmd(lanesMain, workspace, scope, community.getDocsDomain());\n laneCmd.commands = [\n new LaneListCmd(lanesMain, workspace, scope),\n switchCmd,\n new LaneShowCmd(lanesMain, workspace, scope),\n new LaneCreateCmd(lanesMain),\n new LaneMergeCmd(lanesMain),\n new LaneRemoveCmd(lanesMain),\n new LaneTrackCmd(lanesMain),\n new LaneDiffCmd(workspace, scope),\n new LaneAddReadmeCmd(lanesMain),\n new LaneRemoveReadmeCmd(lanesMain),\n new LaneImportCmd(switchCmd),\n ];\n cli.register(laneCmd, switchCmd);\n graphql.register(lanesSchema(lanesMain));\n }\n return lanesMain;\n }\n}\n\nLanesAspect.addRuntime(LanesMain);\n\nexport default LanesMain;\n"]}
|
1
|
+
{"version":3,"sources":["lanes.main.runtime.ts"],"names":["LanesMain","constructor","workspace","scope","merging","componentAspect","logger","getLanes","name","remote","merged","showDefaultLane","notMerged","showMergeData","Boolean","consumer","remoteObj","lanes","listLanes","DEFAULT_LANE","defaultLane","getLaneDataOfDefaultLane","legacyScope","getLanesData","push","getCurrentLane","getCurrentLaneName","createLane","remoteScope","remoteName","BitError","setCurrentLane","trackLaneData","localLane","remoteLane","defaultScope","trackLane","onDestroy","localName","lane","loadLane","LaneId","from","beforeTrackData","getRemoteTrackedDataByLocalLane","beforeTrackDataCloned","undefined","afterTrackData","removeLanes","laneNames","force","results","laneResults","mergeLane","laneName","options","bitMap","syncWithLanes","workspaceLane","switchLanes","newLaneName","merge","getAll","skipDependencyInstallation","mergeStrategy","mergeOptions","Object","keys","MergeOptions","includes","join","switchProps","existingOnWorkspaceOnly","checkoutProps","skipNpmInstall","verbose","ignorePackageJson","ignoreDist","isLane","promptMergeOptions","writeConfig","reset","all","LaneSwitcher","switch","getDiff","values","diffOptions","laneDiffGenerator","LaneDiffGenerator","generate","getLaneComponentModels","laneComponents","components","host","getHost","laneComponentIds","Promise","map","laneComponent","legacyIdWithVersion","id","changeVersion","head","resolveComponentId","getMany","getLaneReadmeComponent","laneReadmeComponent","readmeComponent","laneReadmeComponentId","get","removeLaneReadme","currentLaneName","result","message","laneId","readmeComponentId","existingLaneConfig","getSpecificComponentConfig","LanesAspect","remoteLaneIdStr","remoteLaneId","toString","readme","removeSpecificComponentConfig","addSpecificComponentConfig","setReadmeComponent","saveLane","write","addLaneReadme","readmeComponentIdStr","readmeComponentBitId","_legacy","bitIds","scopeComponents","list","filter","component","getAuthoredAndImportedBitIdsOfDefaultLane","bitId","version","isMerged","provider","cli","graphql","community","loggerMain","createLogger","lanesMain","isLegacy","switchCmd","SwitchCmd","laneCmd","LaneCmd","getDocsDomain","commands","LaneListCmd","LaneShowCmd","LaneCreateCmd","LaneMergeCmd","LaneRemoveCmd","LaneTrackCmd","LaneDiffCmd","LaneAddReadmeCmd","LaneRemoveReadmeCmd","LaneImportCmd","register","CLIAspect","ScopeAspect","WorkspaceAspect","GraphqlAspect","CommunityAspect","MergingAspect","ComponentAspect","LoggerAspect","MainRuntime","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;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AA2BlJ,SAA3B,EAAsCC,KAAtC,CADiB,EAEjBmJ,SAFiB,EAGjB,KAAIO,mBAAJ,EAAgBT,SAAhB,EAA2BlJ,SAA3B,EAAsCC,KAAtC,CAHiB,EAIjB,KAAI2J,qBAAJ,EAAkBV,SAAlB,CAJiB,EAKjB,KAAIW,oBAAJ,EAAiBX,SAAjB,CALiB,EAMjB,KAAIY,qBAAJ,EAAkBZ,SAAlB,CANiB,EAOjB,KAAIa,oBAAJ,EAAiBb,SAAjB,CAPiB,EAQjB,KAAIc,2BAAJ,EAAgBhK,SAAhB,EAA2BC,KAA3B,CARiB,EASjB,KAAIgK,wBAAJ,EAAqBf,SAArB,CATiB,EAUjB,KAAIgB,2BAAJ,EAAwBhB,SAAxB,CAViB,EAWjB,KAAIiB,qBAAJ,EAAkBf,SAAlB,CAXiB,CAAnB;AAaAP,MAAAA,GAAG,CAACuB,QAAJ,CAAad,OAAb,EAAsBF,SAAtB;AACAN,MAAAA,OAAO,CAACsB,QAAR,CAAiB,2BAAYlB,SAAZ,CAAjB;AACD;;AACD,WAAOA,SAAP;AACD;;AA9VoB;;;gCAAVpJ,S,WAiTI,E;gCAjTJA,S,kBAkTW,CACpBuK,gBADoB,EAEpBC,oBAFoB,EAGpBC,4BAHoB,EAIpBC,wBAJoB,EAKpBC,4BALoB,EAMpBC,wBANoB,EAOpBC,oBAPoB,EAQpBC,sBARoB,C;gCAlTX9K,S,aA4TM+K,kB;;AAqCnBxD,qBAAYyD,UAAZ,CAAuBhL,SAAvB;;eAEeA,S","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ScopeMain, ScopeAspect } from '@teambit/scope';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\nimport { LaneDiffCmd, LaneDiffGenerator } from '@teambit/lanes.modules.diff';\nimport { LaneData } from '@teambit/legacy/dist/scope/lanes/lanes';\nimport LaneId from '@teambit/legacy/dist/lane-id/lane-id';\nimport { BitError } from '@teambit/bit-error';\nimport createNewLane from '@teambit/legacy/dist/consumer/lanes/create-lane';\nimport { DEFAULT_LANE } from '@teambit/legacy/dist/constants';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { DiffOptions } from '@teambit/legacy/dist/consumer/component-ops/components-diff';\nimport {\n MergeStrategy,\n ApplyVersionResults,\n MergeOptions,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport { TrackLane } from '@teambit/legacy/dist/scope/scope-json';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\nimport ComponentAspect, { Component, ComponentMain } from '@teambit/component';\nimport removeLanes from '@teambit/legacy/dist/consumer/lanes/remove-lanes';\nimport { Lane } from '@teambit/legacy/dist/scope/models';\nimport { Scope as LegacyScope } from '@teambit/legacy/dist/scope';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { MergingMain, MergingAspect } from '@teambit/merging';\nimport { LanesAspect } from './lanes.aspect';\nimport {\n LaneCmd,\n LaneCreateCmd,\n LaneImportCmd,\n LaneListCmd,\n LaneMergeCmd,\n LaneRemoveCmd,\n LaneShowCmd,\n LaneTrackCmd,\n LaneAddReadmeCmd,\n LaneRemoveReadmeCmd,\n} from './lane.cmd';\nimport { lanesSchema } from './lanes.graphql';\nimport { SwitchCmd } from './switch.cmd';\nimport { mergeLanes } from './merge-lanes';\nimport { LaneSwitcher } from './switch-lanes';\n\nexport type LaneResults = {\n lanes: LaneData[];\n currentLane?: string | null;\n};\n\nexport type MergeLaneOptions = {\n remoteName: string | null;\n mergeStrategy: MergeStrategy;\n noSnap: boolean;\n snapMessage: string;\n existingOnWorkspaceOnly: boolean;\n build: boolean;\n keepReadme: boolean;\n};\n\nexport type CreateLaneOptions = {\n remoteScope?: string; // default to the defaultScope in workspace.jsonc\n remoteName?: string; // default to the local lane\n};\n\nexport type SwitchLaneOptions = {\n newLaneName?: string;\n merge?: MergeStrategy;\n getAll?: boolean;\n skipDependencyInstallation?: boolean;\n verbose?: boolean;\n override?: boolean;\n};\n\nexport class LanesMain {\n constructor(\n private workspace: Workspace | undefined,\n private scope: ScopeMain,\n private merging: MergingMain,\n private componentAspect: ComponentMain,\n private logger: Logger\n ) {}\n\n async getLanes({\n name,\n remote,\n merged,\n showDefaultLane,\n notMerged,\n }: {\n name?: string;\n remote?: string;\n merged?: boolean;\n showDefaultLane?: boolean;\n notMerged?: boolean;\n }): Promise<LaneData[]> {\n const showMergeData = Boolean(merged || notMerged);\n const consumer = this.workspace?.consumer;\n if (remote) {\n const remoteObj = await getRemoteByName(remote, consumer);\n const lanes = await remoteObj.listLanes(name, showMergeData);\n return lanes;\n }\n\n if (name === DEFAULT_LANE) {\n const defaultLane = await this.getLaneDataOfDefaultLane();\n return defaultLane ? [defaultLane] : [];\n }\n\n const lanes = await this.scope.legacyScope.lanes.getLanesData(this.scope.legacyScope, name, showMergeData);\n\n if (showDefaultLane) {\n const defaultLane = await this.getLaneDataOfDefaultLane();\n if (defaultLane) lanes.push(defaultLane);\n }\n\n return lanes;\n }\n\n getCurrentLane(): string | null {\n if (!this.workspace?.consumer) return null;\n return this.scope.legacyScope.lanes.getCurrentLaneName();\n }\n\n async createLane(name: string, { remoteScope, remoteName }: CreateLaneOptions = {}): Promise<TrackLane> {\n if (!this.workspace) {\n throw new BitError(`unable to create a lane outside of Bit workspace`);\n }\n await createNewLane(this.workspace.consumer, name);\n this.scope.legacyScope.lanes.setCurrentLane(name);\n const trackLaneData = {\n localLane: name,\n remoteLane: remoteName || name,\n remoteScope: remoteScope || this.workspace.defaultScope,\n };\n this.scope.legacyScope.lanes.trackLane(trackLaneData);\n await this.workspace.consumer.onDestroy();\n\n return trackLaneData;\n }\n\n async trackLane(\n localName: string,\n remoteScope: string,\n remoteName?: string\n ): Promise<{ beforeTrackData?: TrackLane; afterTrackData: TrackLane }> {\n if (!this.workspace) {\n throw new BitError(`unable to track a lane outside of Bit workspace`);\n }\n const lane = await this.scope.legacyScope.lanes.loadLane(LaneId.from(localName));\n if (!lane) {\n throw new BitError(`unable to find a local lane \"${localName}\"`);\n }\n const beforeTrackData = this.scope.legacyScope.lanes.getRemoteTrackedDataByLocalLane(localName);\n const beforeTrackDataCloned = beforeTrackData ? { ...beforeTrackData } : undefined;\n const afterTrackData = {\n localLane: localName,\n remoteLane: remoteName || beforeTrackData?.remoteLane || localName,\n remoteScope,\n };\n this.scope.legacyScope.lanes.trackLane(afterTrackData);\n await this.workspace.consumer.onDestroy();\n\n return { beforeTrackData: beforeTrackDataCloned, afterTrackData };\n }\n\n async removeLanes(laneNames: string[], { remote, force }: { remote: boolean; force: boolean }): Promise<string[]> {\n const results = await removeLanes(this.workspace?.consumer, laneNames, remote, force);\n if (this.workspace) await this.workspace.consumer.onDestroy();\n\n return results.laneResults;\n }\n\n async mergeLane(\n laneName: string,\n options: MergeLaneOptions\n ): Promise<{ mergeResults: ApplyVersionResults; deleteResults: any }> {\n if (!this.workspace) {\n throw new BitError(`unable to merge a lane outside of Bit workspace`);\n }\n const results = await mergeLanes({\n merging: this.merging,\n consumer: this.workspace.consumer,\n laneName,\n ...options,\n });\n\n await this.workspace.consumer.onDestroy();\n this.workspace.consumer.bitMap.syncWithLanes(this.workspace.consumer.bitMap.workspaceLane);\n return results;\n }\n\n /**\n * switch to a different local or remote lane.\n * switching to a remote lane also imports and writes the components of that remote lane.\n * by default, only the components existing on the workspace will be imported from that lane, unless the \"getAll\"\n * flag is true.\n */\n async switchLanes(\n laneName: string,\n { newLaneName, merge, getAll = false, skipDependencyInstallation = false }: SwitchLaneOptions\n ) {\n if (!this.workspace) {\n throw new BitError(`unable to switch lanes outside of Bit workspace`);\n }\n let mergeStrategy;\n if (merge && typeof merge === 'string') {\n const mergeOptions = Object.keys(MergeOptions);\n if (!mergeOptions.includes(merge)) {\n throw new BitError(`merge must be one of the following: ${mergeOptions.join(', ')}`);\n }\n mergeStrategy = merge;\n }\n\n const switchProps = {\n laneName,\n existingOnWorkspaceOnly: !getAll,\n newLaneName,\n };\n const checkoutProps = {\n mergeStrategy,\n skipNpmInstall: skipDependencyInstallation,\n verbose: false, // not relevant in Harmony\n ignorePackageJson: true, // not relevant in Harmony\n ignoreDist: true, // not relevant in Harmony\n isLane: true,\n promptMergeOptions: false,\n writeConfig: false,\n reset: false,\n all: false,\n };\n return new LaneSwitcher(this.workspace, this.logger, switchProps, checkoutProps).switch();\n }\n\n /**\n * the values array may include zero to two values and will be processed as following:\n * [] => diff between the current lane and default lane. (only inside workspace).\n * [to] => diff between the current lane (or default-lane when in scope) and \"to\" lane.\n * [from, to] => diff between \"from\" lane and \"to\" lane.\n */\n public getDiff(values: string[], diffOptions: DiffOptions = {}) {\n const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope);\n return laneDiffGenerator.generate(values, diffOptions);\n }\n\n async getLaneComponentModels(name: string): Promise<Component[]> {\n if (!name) return [];\n\n const [lane] = await this.getLanes({ name });\n const laneComponents = lane.components;\n const host = this.componentAspect.getHost();\n const laneComponentIds = await Promise.all(\n laneComponents.map((laneComponent) => {\n const legacyIdWithVersion = laneComponent.id.changeVersion(laneComponent.head);\n return host.resolveComponentId(legacyIdWithVersion);\n })\n );\n const components = await host.getMany(laneComponentIds);\n return components;\n }\n\n async getLaneReadmeComponent(name: string): Promise<Component | undefined> {\n if (!name) return undefined;\n\n const [lane] = await this.getLanes({ name });\n const laneReadmeComponent = lane.readmeComponent;\n if (!laneReadmeComponent) return undefined;\n const host = this.componentAspect.getHost();\n const laneReadmeComponentId = await host.resolveComponentId(\n laneReadmeComponent.id.changeVersion(laneReadmeComponent.head)\n );\n const readmeComponent = await host.get(laneReadmeComponentId);\n return readmeComponent;\n }\n\n async removeLaneReadme(laneName?: string): Promise<{ result: boolean; message?: string }> {\n if (!this.workspace) {\n throw new BitError('unable to remove the lane readme component outside of Bit workspace');\n }\n const currentLaneName = this.getCurrentLane();\n\n if (!laneName && !currentLaneName) {\n return {\n result: false,\n message: 'unable to remove the lane readme component. Either pass a laneName or switch to a lane',\n };\n }\n\n const laneId: LaneId = (laneName && LaneId.from(laneName)) || LaneId.from(currentLaneName as string);\n const scope: LegacyScope = this.workspace.scope.legacyScope;\n const lane: Lane | null | undefined = await scope.loadLane(laneId);\n\n if (!lane?.readmeComponent) {\n throw new BitError(`there is no readme component added to the lane ${laneName || currentLaneName}`);\n }\n\n const readmeComponentId = await this.workspace.resolveComponentId(lane.readmeComponent.id);\n const existingLaneConfig =\n (await this.workspace.getSpecificComponentConfig(readmeComponentId, LanesAspect.id)) || {};\n\n const remoteLaneIdStr = (lane.remoteLaneId || LaneId.from(laneId.name, lane.scope)).toString();\n\n if (existingLaneConfig.readme) {\n delete existingLaneConfig.readme[remoteLaneIdStr];\n await this.workspace.removeSpecificComponentConfig(readmeComponentId, LanesAspect.id, false);\n await this.workspace.addSpecificComponentConfig(readmeComponentId, LanesAspect.id, existingLaneConfig);\n }\n\n lane.setReadmeComponent(undefined);\n await scope.lanes.saveLane(lane);\n await this.workspace.bitMap.write();\n\n return { result: true };\n }\n\n async addLaneReadme(readmeComponentIdStr: string, laneName?: string): Promise<{ result: boolean; message?: string }> {\n if (!this.workspace) {\n throw new BitError(`unable to track a lane readme component outside of Bit workspace`);\n }\n const readmeComponentId = await this.workspace.resolveComponentId(readmeComponentIdStr);\n\n const currentLaneName = this.getCurrentLane();\n\n const readmeComponentBitId = readmeComponentId._legacy;\n\n const laneId: LaneId = (laneName && LaneId.from(laneName)) || LaneId.from(currentLaneName as string);\n const scope: LegacyScope = this.workspace.scope.legacyScope;\n const lane: Lane | null | undefined = await scope.loadLane(laneId);\n\n if (!lane) {\n return { result: false, message: `cannot find lane ${laneName}` };\n }\n\n lane.setReadmeComponent(readmeComponentBitId);\n await scope.lanes.saveLane(lane);\n\n const existingLaneConfig =\n (await this.workspace.getSpecificComponentConfig(readmeComponentId, LanesAspect.id)) || {};\n\n const remoteLaneIdStr = (lane.remoteLaneId || LaneId.from(laneId.name, lane.scope)).toString();\n\n if (existingLaneConfig.readme) {\n await this.workspace.addSpecificComponentConfig(readmeComponentId, LanesAspect.id, {\n ...existingLaneConfig,\n readme: {\n ...existingLaneConfig.readme,\n [remoteLaneIdStr]: true,\n },\n });\n } else {\n await this.workspace.addSpecificComponentConfig(readmeComponentId, LanesAspect.id, {\n ...existingLaneConfig,\n readme: {\n [remoteLaneIdStr]: true,\n },\n });\n }\n await this.workspace.bitMap.write();\n return { result: true };\n }\n\n private async getLaneDataOfDefaultLane(): Promise<LaneData | null> {\n const consumer = this.workspace?.consumer;\n let bitIds: BitId[] = [];\n if (!consumer) {\n const scopeComponents = await this.scope.list();\n bitIds = scopeComponents.filter((component) => component.head).map((component) => component.id._legacy);\n } else {\n bitIds = consumer.bitMap.getAuthoredAndImportedBitIdsOfDefaultLane();\n }\n\n return {\n name: DEFAULT_LANE,\n remote: null,\n components: bitIds.map((bitId) => ({ id: bitId, head: bitId.version as string })),\n isMerged: null,\n };\n }\n\n static slots = [];\n static dependencies = [\n CLIAspect,\n ScopeAspect,\n WorkspaceAspect,\n GraphqlAspect,\n CommunityAspect,\n MergingAspect,\n ComponentAspect,\n LoggerAspect,\n ];\n static runtime = MainRuntime;\n static async provider([cli, scope, workspace, graphql, community, merging, component, loggerMain]: [\n CLIMain,\n ScopeMain,\n Workspace,\n GraphqlMain,\n CommunityMain,\n MergingMain,\n ComponentMain,\n LoggerMain\n ]) {\n const logger = loggerMain.createLogger(LanesAspect.id);\n const lanesMain = new LanesMain(workspace, scope, merging, component, logger);\n const isLegacy = workspace && workspace.consumer.isLegacy;\n const switchCmd = new SwitchCmd(lanesMain);\n if (!isLegacy) {\n const laneCmd = new LaneCmd(lanesMain, workspace, scope, community.getDocsDomain());\n laneCmd.commands = [\n new LaneListCmd(lanesMain, workspace, scope),\n switchCmd,\n new LaneShowCmd(lanesMain, workspace, scope),\n new LaneCreateCmd(lanesMain),\n new LaneMergeCmd(lanesMain),\n new LaneRemoveCmd(lanesMain),\n new LaneTrackCmd(lanesMain),\n new LaneDiffCmd(workspace, scope),\n new LaneAddReadmeCmd(lanesMain),\n new LaneRemoveReadmeCmd(lanesMain),\n new LaneImportCmd(switchCmd),\n ];\n cli.register(laneCmd, switchCmd);\n graphql.register(lanesSchema(lanesMain));\n }\n return lanesMain;\n }\n}\n\nLanesAspect.addRuntime(LanesMain);\n\nexport default LanesMain;\n"]}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { BitId } from '@teambit/legacy-bit-id';
|
2
|
+
import { LaneComponent } from '@teambit/legacy/dist/scope/models/lane';
|
3
|
+
import { CheckoutProps } from '@teambit/legacy/dist/consumer/versions-ops/checkout-version';
|
4
|
+
import { ApplyVersionResults } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';
|
5
|
+
import { Workspace } from '@teambit/workspace';
|
6
|
+
import { Logger } from '@teambit/logger';
|
7
|
+
export declare type SwitchProps = {
|
8
|
+
laneName: string;
|
9
|
+
remoteScope?: string;
|
10
|
+
ids?: BitId[];
|
11
|
+
existingOnWorkspaceOnly: boolean;
|
12
|
+
localLaneName?: string;
|
13
|
+
remoteLaneScope?: string;
|
14
|
+
remoteLaneName?: string;
|
15
|
+
remoteLaneComponents?: LaneComponent[];
|
16
|
+
localTrackedLane?: string;
|
17
|
+
newLaneName?: string;
|
18
|
+
};
|
19
|
+
export declare class LaneSwitcher {
|
20
|
+
private workspace;
|
21
|
+
private logger;
|
22
|
+
private switchProps;
|
23
|
+
private checkoutProps;
|
24
|
+
private consumer;
|
25
|
+
constructor(workspace: Workspace, logger: Logger, switchProps: SwitchProps, checkoutProps: CheckoutProps);
|
26
|
+
switch(): Promise<ApplyVersionResults>;
|
27
|
+
private populateSwitchProps;
|
28
|
+
private populatePropsAccordingToRemoteLane;
|
29
|
+
private populatePropsAccordingToLocalLane;
|
30
|
+
private getAllComponentsStatus;
|
31
|
+
private saveLanesData;
|
32
|
+
}
|
@@ -0,0 +1,461 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
6
|
+
|
7
|
+
require("core-js/modules/es.promise.js");
|
8
|
+
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
10
|
+
value: true
|
11
|
+
});
|
12
|
+
exports.LaneSwitcher = void 0;
|
13
|
+
|
14
|
+
function _defineProperty2() {
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
16
|
+
|
17
|
+
_defineProperty2 = function () {
|
18
|
+
return data;
|
19
|
+
};
|
20
|
+
|
21
|
+
return data;
|
22
|
+
}
|
23
|
+
|
24
|
+
function _pMapSeries() {
|
25
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
26
|
+
|
27
|
+
_pMapSeries = function () {
|
28
|
+
return data;
|
29
|
+
};
|
30
|
+
|
31
|
+
return data;
|
32
|
+
}
|
33
|
+
|
34
|
+
function _constants() {
|
35
|
+
const data = require("@teambit/legacy/dist/constants");
|
36
|
+
|
37
|
+
_constants = function () {
|
38
|
+
return data;
|
39
|
+
};
|
40
|
+
|
41
|
+
return data;
|
42
|
+
}
|
43
|
+
|
44
|
+
function _generalError() {
|
45
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/error/general-error"));
|
46
|
+
|
47
|
+
_generalError = function () {
|
48
|
+
return data;
|
49
|
+
};
|
50
|
+
|
51
|
+
return data;
|
52
|
+
}
|
53
|
+
|
54
|
+
function _laneId() {
|
55
|
+
const data = require("@teambit/legacy/dist/lane-id/lane-id");
|
56
|
+
|
57
|
+
_laneId = function () {
|
58
|
+
return data;
|
59
|
+
};
|
60
|
+
|
61
|
+
return data;
|
62
|
+
}
|
63
|
+
|
64
|
+
function _scopeComponentsImporter() {
|
65
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/component-ops/scope-components-importer"));
|
66
|
+
|
67
|
+
_scopeComponentsImporter = function () {
|
68
|
+
return data;
|
69
|
+
};
|
70
|
+
|
71
|
+
return data;
|
72
|
+
}
|
73
|
+
|
74
|
+
function _repositories() {
|
75
|
+
const data = require("@teambit/legacy/dist/scope/repositories");
|
76
|
+
|
77
|
+
_repositories = function () {
|
78
|
+
return data;
|
79
|
+
};
|
80
|
+
|
81
|
+
return data;
|
82
|
+
}
|
83
|
+
|
84
|
+
function _workspaceLane() {
|
85
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/bit-map/workspace-lane"));
|
86
|
+
|
87
|
+
_workspaceLane = function () {
|
88
|
+
return data;
|
89
|
+
};
|
90
|
+
|
91
|
+
return data;
|
92
|
+
}
|
93
|
+
|
94
|
+
function _checkoutVersion() {
|
95
|
+
const data = require("@teambit/legacy/dist/consumer/versions-ops/checkout-version");
|
96
|
+
|
97
|
+
_checkoutVersion = function () {
|
98
|
+
return data;
|
99
|
+
};
|
100
|
+
|
101
|
+
return data;
|
102
|
+
}
|
103
|
+
|
104
|
+
function _manyComponentsWriter() {
|
105
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component-ops/many-components-writer"));
|
106
|
+
|
107
|
+
_manyComponentsWriter = function () {
|
108
|
+
return data;
|
109
|
+
};
|
110
|
+
|
111
|
+
return data;
|
112
|
+
}
|
113
|
+
|
114
|
+
function _mergeVersion() {
|
115
|
+
const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
|
116
|
+
|
117
|
+
_mergeVersion = function () {
|
118
|
+
return data;
|
119
|
+
};
|
120
|
+
|
121
|
+
return data;
|
122
|
+
}
|
123
|
+
|
124
|
+
function _createLane() {
|
125
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/lanes/create-lane"));
|
126
|
+
|
127
|
+
_createLane = function () {
|
128
|
+
return data;
|
129
|
+
};
|
130
|
+
|
131
|
+
return data;
|
132
|
+
}
|
133
|
+
|
134
|
+
function _threeWayMerge() {
|
135
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge"));
|
136
|
+
|
137
|
+
_threeWayMerge = function () {
|
138
|
+
return data;
|
139
|
+
};
|
140
|
+
|
141
|
+
return data;
|
142
|
+
}
|
143
|
+
|
144
|
+
class LaneSwitcher {
|
145
|
+
constructor(workspace, logger, switchProps, checkoutProps) {
|
146
|
+
this.workspace = workspace;
|
147
|
+
this.logger = logger;
|
148
|
+
this.switchProps = switchProps;
|
149
|
+
this.checkoutProps = checkoutProps;
|
150
|
+
(0, _defineProperty2().default)(this, "consumer", void 0);
|
151
|
+
this.consumer = this.workspace.consumer;
|
152
|
+
}
|
153
|
+
|
154
|
+
async switch() {
|
155
|
+
this.logger.setStatusLine(`switching lanes`);
|
156
|
+
await this.populateSwitchProps();
|
157
|
+
const allComponentsStatus = await this.getAllComponentsStatus();
|
158
|
+
const componentWithConflict = allComponentsStatus.find(component => component.mergeResults && component.mergeResults.hasConflicts);
|
159
|
+
|
160
|
+
if (componentWithConflict) {
|
161
|
+
if (!this.checkoutProps.promptMergeOptions && !this.checkoutProps.mergeStrategy) {
|
162
|
+
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`);
|
163
|
+
}
|
164
|
+
|
165
|
+
if (!this.checkoutProps.mergeStrategy) this.checkoutProps.mergeStrategy = await (0, _mergeVersion().getMergeStrategyInteractive)();
|
166
|
+
}
|
167
|
+
|
168
|
+
const failedComponents = allComponentsStatus.filter(componentStatus => componentStatus.failureMessage).map(componentStatus => ({
|
169
|
+
id: componentStatus.id,
|
170
|
+
failureMessage: componentStatus.failureMessage
|
171
|
+
}));
|
172
|
+
const succeededComponents = allComponentsStatus.filter(componentStatus => !componentStatus.failureMessage); // do not use Promise.all for applyVersion. otherwise, it'll write all components in parallel,
|
173
|
+
// which can be an issue when some components are also dependencies of others
|
174
|
+
|
175
|
+
const componentsResults = await (0, _pMapSeries().default)(succeededComponents, ({
|
176
|
+
id,
|
177
|
+
componentFromFS,
|
178
|
+
mergeResults
|
179
|
+
}) => {
|
180
|
+
return (0, _checkoutVersion().applyVersion)(this.consumer, id, componentFromFS, mergeResults, this.checkoutProps);
|
181
|
+
});
|
182
|
+
(0, _checkoutVersion().markFilesToBeRemovedIfNeeded)(succeededComponents, componentsResults);
|
183
|
+
await this.saveLanesData();
|
184
|
+
const componentsWithDependencies = componentsResults.map(c => c.component).filter(c => c);
|
185
|
+
const manyComponentsWriter = new (_manyComponentsWriter().default)({
|
186
|
+
consumer: this.consumer,
|
187
|
+
componentsWithDependencies,
|
188
|
+
installNpmPackages: !this.checkoutProps.skipNpmInstall,
|
189
|
+
override: true,
|
190
|
+
verbose: this.checkoutProps.verbose,
|
191
|
+
writeDists: !this.checkoutProps.ignoreDist,
|
192
|
+
writeConfig: this.checkoutProps.writeConfig,
|
193
|
+
writePackageJson: !this.checkoutProps.ignorePackageJson
|
194
|
+
});
|
195
|
+
await manyComponentsWriter.writeAll();
|
196
|
+
await (0, _checkoutVersion().deleteFilesIfNeeded)(componentsResults, this.consumer);
|
197
|
+
const appliedVersionComponents = componentsResults.map(c => c.applyVersionResult);
|
198
|
+
await this.consumer.onDestroy();
|
199
|
+
return {
|
200
|
+
components: appliedVersionComponents,
|
201
|
+
failedComponents
|
202
|
+
};
|
203
|
+
}
|
204
|
+
|
205
|
+
async populateSwitchProps() {
|
206
|
+
const lanes = await this.consumer.scope.listLanes();
|
207
|
+
|
208
|
+
const isDefaultLane = this.switchProps.laneName === _constants().DEFAULT_LANE;
|
209
|
+
|
210
|
+
const localLane = lanes.find(lane => lane.name === this.switchProps.laneName);
|
211
|
+
|
212
|
+
if (isDefaultLane || localLane) {
|
213
|
+
this.populatePropsAccordingToLocalLane(localLane);
|
214
|
+
} else {
|
215
|
+
await this.populatePropsAccordingToRemoteLane(lanes);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
async populatePropsAccordingToRemoteLane(lanes) {
|
220
|
+
let remoteLaneId;
|
221
|
+
|
222
|
+
try {
|
223
|
+
remoteLaneId = _laneId().RemoteLaneId.parse(this.switchProps.laneName);
|
224
|
+
} catch (e) {
|
225
|
+
throw new (_generalError().default)(`invalid lane id "${this.switchProps.laneName}", the lane ${this.switchProps.laneName} doesn't exist.`);
|
226
|
+
}
|
227
|
+
|
228
|
+
if (remoteLaneId.name === _constants().DEFAULT_LANE) {
|
229
|
+
throw new (_generalError().default)(`invalid remote lane id "${this.switchProps.laneName}". to switch to the main lane on remote,
|
230
|
+
run "bit switch main" and then "bit import".`);
|
231
|
+
} // fetch the remote to update all heads
|
232
|
+
|
233
|
+
|
234
|
+
const localTrackedLane = this.consumer.scope.lanes.getLocalTrackedLaneByRemoteName(remoteLaneId.name, remoteLaneId.scope);
|
235
|
+
this.logger.debug(`populatePropsAccordingToRemoteLane, remoteLaneId: ${remoteLaneId.toString()}`);
|
236
|
+
this.switchProps.localLaneName = this.switchProps.newLaneName || localTrackedLane || remoteLaneId.name;
|
237
|
+
|
238
|
+
if (this.consumer.getCurrentLaneId().name === this.switchProps.localLaneName) {
|
239
|
+
throw new (_generalError().default)(`already checked out to "${this.switchProps.localLaneName}"`);
|
240
|
+
}
|
241
|
+
|
242
|
+
const scopeComponentImporter = _scopeComponentsImporter().default.getInstance(this.consumer.scope);
|
243
|
+
|
244
|
+
const remoteLaneObjects = await scopeComponentImporter.importFromLanes([remoteLaneId]);
|
245
|
+
|
246
|
+
if (remoteLaneObjects.length === 0) {
|
247
|
+
throw new (_generalError().default)(`invalid lane id "${this.switchProps.laneName}", the lane ${this.switchProps.laneName} doesn't exist.`);
|
248
|
+
}
|
249
|
+
|
250
|
+
const remoteLaneComponents = remoteLaneObjects[0].components;
|
251
|
+
this.switchProps.remoteLaneName = remoteLaneId.name;
|
252
|
+
this.switchProps.laneName = remoteLaneId.name;
|
253
|
+
this.switchProps.remoteLaneScope = remoteLaneId.scope;
|
254
|
+
this.switchProps.remoteScope = remoteLaneId.scope;
|
255
|
+
this.switchProps.ids = remoteLaneComponents.map(l => l.id.changeVersion(l.head.toString()));
|
256
|
+
this.switchProps.remoteLaneComponents = remoteLaneComponents;
|
257
|
+
this.switchProps.localTrackedLane = localTrackedLane || undefined;
|
258
|
+
const laneExistsLocally = lanes.find(l => l.name === this.switchProps.localLaneName);
|
259
|
+
|
260
|
+
if (laneExistsLocally) {
|
261
|
+
throw new (_generalError().default)(`unable to checkout to a remote lane ${this.switchProps.remoteScope}/${this.switchProps.laneName}.
|
262
|
+
the local lane "${this.switchProps.localLaneName}" already exists, please switch to the local lane first by running "bit switch ${this.switchProps.localLaneName}"
|
263
|
+
then, to merge the remote lane into the local lane, run "bit lane merge ${this.switchProps.localLaneName} --remote ${this.switchProps.remoteScope}"`);
|
264
|
+
}
|
265
|
+
|
266
|
+
this.logger.debug(`populatePropsAccordingToRemoteLane, completed`);
|
267
|
+
}
|
268
|
+
|
269
|
+
populatePropsAccordingToLocalLane(localLane) {
|
270
|
+
this.switchProps.localLaneName = this.switchProps.laneName;
|
271
|
+
|
272
|
+
if (this.consumer.getCurrentLaneId().name === this.switchProps.laneName) {
|
273
|
+
throw new (_generalError().default)(`already checked out to "${this.switchProps.laneName}"`);
|
274
|
+
}
|
275
|
+
|
276
|
+
if (this.switchProps.laneName === _constants().DEFAULT_LANE) {
|
277
|
+
this.switchProps.ids = this.consumer.bitMap.getAuthoredAndImportedBitIdsOfDefaultLane();
|
278
|
+
return;
|
279
|
+
}
|
280
|
+
|
281
|
+
if (!localLane) {
|
282
|
+
throw new (_generalError().default)(`unable to find a local lane "${this.switchProps.laneName}", to create a new lane please run "bit lane create"`);
|
283
|
+
}
|
284
|
+
|
285
|
+
this.switchProps.ids = localLane.components.map(c => c.id.changeVersion(c.head.toString()));
|
286
|
+
}
|
287
|
+
|
288
|
+
async getAllComponentsStatus() {
|
289
|
+
const {
|
290
|
+
ids
|
291
|
+
} = this.switchProps;
|
292
|
+
const tmp = new (_repositories().Tmp)(this.consumer.scope);
|
293
|
+
|
294
|
+
try {
|
295
|
+
const componentsStatusP = ids.map(id => getComponentStatus(this.consumer, id, this.switchProps));
|
296
|
+
const componentsStatus = await Promise.all(componentsStatusP);
|
297
|
+
await tmp.clear(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
298
|
+
|
299
|
+
return componentsStatus;
|
300
|
+
} catch (err) {
|
301
|
+
await tmp.clear();
|
302
|
+
throw err;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
async saveLanesData() {
|
307
|
+
await saveCheckedOutLaneInfo(this.consumer, {
|
308
|
+
remoteLaneScope: this.switchProps.remoteLaneScope,
|
309
|
+
remoteLaneName: this.switchProps.remoteLaneName,
|
310
|
+
localLaneName: this.switchProps.localLaneName,
|
311
|
+
addTrackingInfo: !this.switchProps.localTrackedLane,
|
312
|
+
laneComponents: this.switchProps.remoteLaneComponents
|
313
|
+
});
|
314
|
+
}
|
315
|
+
|
316
|
+
}
|
317
|
+
|
318
|
+
exports.LaneSwitcher = LaneSwitcher;
|
319
|
+
|
320
|
+
async function saveCheckedOutLaneInfo(consumer, opts) {
|
321
|
+
const saveRemoteLaneToBitmap = () => {
|
322
|
+
if (opts.remoteLaneScope) {
|
323
|
+
consumer.bitMap.setRemoteLane(_laneId().RemoteLaneId.from(opts.remoteLaneName, opts.remoteLaneScope)); // add versions to lane
|
324
|
+
}
|
325
|
+
};
|
326
|
+
|
327
|
+
const throwIfLaneExists = async () => {
|
328
|
+
const allLanes = await consumer.scope.listLanes();
|
329
|
+
|
330
|
+
if (allLanes.find(l => l.name === opts.localLaneName)) {
|
331
|
+
throw new (_generalError().default)(`unable to checkout to lane "${opts.localLaneName}".
|
332
|
+
the lane already exists. please switch to the lane and merge`);
|
333
|
+
}
|
334
|
+
};
|
335
|
+
|
336
|
+
if (opts.remoteLaneScope) {
|
337
|
+
await throwIfLaneExists();
|
338
|
+
await (0, _createLane().default)(consumer, opts.localLaneName, opts.laneComponents);
|
339
|
+
|
340
|
+
if (opts.addTrackingInfo) {
|
341
|
+
// otherwise, it is tracked already
|
342
|
+
consumer.scope.lanes.trackLane({
|
343
|
+
localLane: opts.localLaneName,
|
344
|
+
remoteLane: opts.remoteLaneName,
|
345
|
+
remoteScope: opts.remoteLaneScope
|
346
|
+
});
|
347
|
+
}
|
348
|
+
}
|
349
|
+
|
350
|
+
saveRemoteLaneToBitmap();
|
351
|
+
consumer.scope.lanes.setCurrentLane(opts.localLaneName);
|
352
|
+
const workspaceLane = opts.localLaneName === _constants().DEFAULT_LANE ? null : _workspaceLane().default.load(opts.localLaneName, consumer.scope.path);
|
353
|
+
consumer.bitMap.syncWithLanes(workspaceLane);
|
354
|
+
}
|
355
|
+
|
356
|
+
async function getComponentStatus(consumer, id, switchProps) {
|
357
|
+
const componentStatus = {
|
358
|
+
id
|
359
|
+
};
|
360
|
+
|
361
|
+
const returnFailure = msg => {
|
362
|
+
componentStatus.failureMessage = msg;
|
363
|
+
return componentStatus;
|
364
|
+
};
|
365
|
+
|
366
|
+
const modelComponent = await consumer.scope.getModelComponentIfExist(id);
|
367
|
+
|
368
|
+
if (!modelComponent) {
|
369
|
+
return returnFailure(`component ${id.toString()} had never imported`);
|
370
|
+
}
|
371
|
+
|
372
|
+
const unmerged = consumer.scope.objects.unmergedComponents.getEntry(id.name);
|
373
|
+
|
374
|
+
if (unmerged && unmerged.resolved === false) {
|
375
|
+
return returnFailure(`component ${id.toStringWithoutVersion()} has conflicts that need to be resolved first, please use bit merge --resolve/--abort`);
|
376
|
+
}
|
377
|
+
|
378
|
+
const version = id.version;
|
379
|
+
|
380
|
+
if (!version) {
|
381
|
+
return returnFailure(`component doesn't have any snaps on ${_constants().DEFAULT_LANE}`);
|
382
|
+
}
|
383
|
+
|
384
|
+
const existingBitMapId = consumer.bitMap.getBitIdIfExist(id, {
|
385
|
+
ignoreVersion: true
|
386
|
+
});
|
387
|
+
const componentOnLane = await modelComponent.loadVersion(version, consumer.scope.objects);
|
388
|
+
|
389
|
+
if (!existingBitMapId) {
|
390
|
+
if (switchProps.existingOnWorkspaceOnly) {
|
391
|
+
return returnFailure(`component ${id.toStringWithoutVersion()} is not in the workspace`);
|
392
|
+
}
|
393
|
+
|
394
|
+
return {
|
395
|
+
componentFromFS: undefined,
|
396
|
+
componentFromModel: componentOnLane,
|
397
|
+
id,
|
398
|
+
mergeResults: null
|
399
|
+
};
|
400
|
+
}
|
401
|
+
|
402
|
+
if (!existingBitMapId.hasVersion()) {
|
403
|
+
// happens when switching from main to a lane and a component was snapped on the lane.
|
404
|
+
// in the .bitmap file, the version is "latest" or empty. so we just need to write the component according to the
|
405
|
+
// model. we don't care about the componentFromFS
|
406
|
+
return {
|
407
|
+
componentFromFS: undefined,
|
408
|
+
componentFromModel: componentOnLane,
|
409
|
+
id,
|
410
|
+
mergeResults: null
|
411
|
+
};
|
412
|
+
}
|
413
|
+
|
414
|
+
const currentlyUsedVersion = existingBitMapId.version;
|
415
|
+
|
416
|
+
if (currentlyUsedVersion === version) {
|
417
|
+
return returnFailure(`component ${id.toStringWithoutVersion()} is already at version ${version}`);
|
418
|
+
} // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
419
|
+
|
420
|
+
|
421
|
+
const baseComponent = await modelComponent.loadVersion(currentlyUsedVersion, consumer.scope.objects);
|
422
|
+
const component = await consumer.loadComponent(existingBitMapId);
|
423
|
+
const isModified = await consumer.isComponentModified(baseComponent, component);
|
424
|
+
let mergeResults;
|
425
|
+
|
426
|
+
const isHeadSameAsMain = () => {
|
427
|
+
const head = modelComponent.getHead();
|
428
|
+
if (!head) return false;
|
429
|
+
if (!existingBitMapId.version) return false;
|
430
|
+
const tagVersion = modelComponent.getTagOfRefIfExists(head);
|
431
|
+
const headVersion = tagVersion || head.toString();
|
432
|
+
return existingBitMapId.version === headVersion;
|
433
|
+
};
|
434
|
+
|
435
|
+
if (isModified) {
|
436
|
+
if (!isHeadSameAsMain()) {
|
437
|
+
throw new (_generalError().default)(`unable to checkout ${id.toStringWithoutVersion()}, the component is modified and belongs to another lane`);
|
438
|
+
}
|
439
|
+
|
440
|
+
const otherComponent = await modelComponent.loadVersion(existingBitMapId.version, // we are here because the head is same as main. so, existingBitMapId.version must be set
|
441
|
+
consumer.scope.objects);
|
442
|
+
mergeResults = await (0, _threeWayMerge().default)({
|
443
|
+
consumer,
|
444
|
+
otherComponent,
|
445
|
+
otherLabel: version,
|
446
|
+
currentComponent: component,
|
447
|
+
currentLabel: `${currentlyUsedVersion} modified`,
|
448
|
+
baseComponent
|
449
|
+
});
|
450
|
+
} // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
451
|
+
|
452
|
+
|
453
|
+
return {
|
454
|
+
componentFromFS: component,
|
455
|
+
componentFromModel: componentOnLane,
|
456
|
+
id,
|
457
|
+
mergeResults
|
458
|
+
};
|
459
|
+
}
|
460
|
+
|
461
|
+
//# sourceMappingURL=switch-lanes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["switch-lanes.ts"],"names":["LaneSwitcher","constructor","workspace","logger","switchProps","checkoutProps","consumer","switch","setStatusLine","populateSwitchProps","allComponentsStatus","getAllComponentsStatus","componentWithConflict","find","component","mergeResults","hasConflicts","promptMergeOptions","mergeStrategy","GeneralError","id","toStringWithoutVersion","failedComponents","filter","componentStatus","failureMessage","map","succeededComponents","componentsResults","componentFromFS","saveLanesData","componentsWithDependencies","c","manyComponentsWriter","ManyComponentsWriter","installNpmPackages","skipNpmInstall","override","verbose","writeDists","ignoreDist","writeConfig","writePackageJson","ignorePackageJson","writeAll","appliedVersionComponents","applyVersionResult","onDestroy","components","lanes","scope","listLanes","isDefaultLane","laneName","DEFAULT_LANE","localLane","lane","name","populatePropsAccordingToLocalLane","populatePropsAccordingToRemoteLane","remoteLaneId","RemoteLaneId","parse","e","localTrackedLane","getLocalTrackedLaneByRemoteName","debug","toString","localLaneName","newLaneName","getCurrentLaneId","scopeComponentImporter","ScopeComponentsImporter","getInstance","remoteLaneObjects","importFromLanes","length","remoteLaneComponents","remoteLaneName","remoteLaneScope","remoteScope","ids","l","changeVersion","head","undefined","laneExistsLocally","bitMap","getAuthoredAndImportedBitIdsOfDefaultLane","tmp","Tmp","componentsStatusP","getComponentStatus","componentsStatus","Promise","all","clear","err","saveCheckedOutLaneInfo","addTrackingInfo","laneComponents","opts","saveRemoteLaneToBitmap","setRemoteLane","from","throwIfLaneExists","allLanes","trackLane","remoteLane","setCurrentLane","workspaceLane","WorkspaceLane","load","path","syncWithLanes","returnFailure","msg","modelComponent","getModelComponentIfExist","unmerged","objects","unmergedComponents","getEntry","resolved","version","existingBitMapId","getBitIdIfExist","ignoreVersion","componentOnLane","loadVersion","existingOnWorkspaceOnly","componentFromModel","hasVersion","currentlyUsedVersion","baseComponent","loadComponent","isModified","isComponentModified","isHeadSameAsMain","getHead","tagVersion","getTagOfRefIfExists","headVersion","otherComponent","otherLabel","currentComponent","currentLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAOA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAmBO,MAAMA,YAAN,CAAmB;AAExBC,EAAAA,WAAW,CACDC,SADC,EAEDC,MAFC,EAGDC,WAH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iC,cAAc,CAACsB,OAAf,EAAb;AACA,QAAI,CAACvD,IAAL,EAAW,OAAO,KAAP;AACX,QAAI,CAACyC,gBAAgB,CAACD,OAAtB,EAA+B,OAAO,KAAP;AAC/B,UAAMgB,UAAU,GAAGvB,cAAc,CAACwB,mBAAf,CAAmCzD,IAAnC,CAAnB;AACA,UAAM0D,WAAW,GAAGF,UAAU,IAAIxD,IAAI,CAACjB,QAAL,EAAlC;AACA,WAAO0D,gBAAgB,CAACD,OAAjB,KAA6BkB,WAApC;AACD,GAPD;;AAQA,MAAIN,UAAJ,EAAgB;AACd,QAAI,CAACE,gBAAgB,EAArB,EAAyB;AACvB,YAAM,KAAIvH,uBAAJ,EACH,sBAAqBC,EAAE,CAACC,sBAAH,EAA4B,yDAD9C,CAAN;AAGD;;AAED,UAAM0H,cAAuB,GAAG,MAAM1B,cAAc,CAACY,WAAf,CACpCJ,gBAAgB,CAACD,OADmB,EACA;AACpCtH,IAAAA,QAAQ,CAAC4C,KAAT,CAAesE,OAFqB,CAAtC;AAIAzG,IAAAA,YAAY,GAAG,MAAM,8BAAc;AACjCT,MAAAA,QADiC;AAEjCyI,MAAAA,cAFiC;AAGjCC,MAAAA,UAAU,EAAEpB,OAHqB;AAIjCqB,MAAAA,gBAAgB,EAAEnI,SAJe;AAKjCoI,MAAAA,YAAY,EAAG,GAAEb,oBAAqB,WALL;AAMjCC,MAAAA;AANiC,KAAd,CAArB;AAQD,GAtEkH,CAuEnH;;;AACA,SAAO;AAAEzG,IAAAA,eAAe,EAAEf,SAAnB;AAA8BqH,IAAAA,kBAAkB,EAAEH,eAAlD;AAAmE5G,IAAAA,EAAnE;AAAuEL,IAAAA;AAAvE,GAAP;AACD","sourcesContent":["import mapSeries from 'p-map-series';\nimport { DEFAULT_LANE } from '@teambit/legacy/dist/constants';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { RemoteLaneId } from '@teambit/legacy/dist/lane-id/lane-id';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ComponentWithDependencies } from '@teambit/legacy/dist/scope';\nimport { Version, Lane } from '@teambit/legacy/dist/scope/models';\nimport { LaneComponent } from '@teambit/legacy/dist/scope/models/lane';\nimport { Tmp } from '@teambit/legacy/dist/scope/repositories';\nimport WorkspaceLane from '@teambit/legacy/dist/consumer/bit-map/workspace-lane';\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 createNewLane from '@teambit/legacy/dist/consumer/lanes/create-lane';\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';\n\nexport type SwitchProps = {\n laneName: string;\n remoteScope?: string;\n ids?: BitId[];\n existingOnWorkspaceOnly: boolean;\n localLaneName?: string;\n remoteLaneScope?: string;\n remoteLaneName?: string;\n remoteLaneComponents?: LaneComponent[];\n localTrackedLane?: string;\n newLaneName?: string;\n};\n\nexport class LaneSwitcher {\n private consumer: Consumer;\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private switchProps: SwitchProps,\n private checkoutProps: CheckoutProps\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) => ({ id: componentStatus.id, failureMessage: componentStatus.failureMessage as string }));\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 writeDists: !this.checkoutProps.ignoreDist,\n writeConfig: this.checkoutProps.writeConfig,\n writePackageJson: !this.checkoutProps.ignorePackageJson,\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 lanes = await this.consumer.scope.listLanes();\n const isDefaultLane = this.switchProps.laneName === DEFAULT_LANE;\n\n const localLane = lanes.find((lane) => lane.name === this.switchProps.laneName);\n\n if (isDefaultLane || localLane) {\n this.populatePropsAccordingToLocalLane(localLane);\n } else {\n await this.populatePropsAccordingToRemoteLane(lanes);\n }\n }\n\n private async populatePropsAccordingToRemoteLane(lanes: Lane[]) {\n let remoteLaneId: RemoteLaneId;\n try {\n remoteLaneId = RemoteLaneId.parse(this.switchProps.laneName);\n } catch (e) {\n throw new GeneralError(\n `invalid lane id \"${this.switchProps.laneName}\", the lane ${this.switchProps.laneName} doesn't exist.`\n );\n }\n if (remoteLaneId.name === DEFAULT_LANE) {\n throw new GeneralError(`invalid remote lane id \"${this.switchProps.laneName}\". to switch to the main lane on remote,\n run \"bit switch main\" and then \"bit import\".`);\n }\n // fetch the remote to update all heads\n const localTrackedLane = this.consumer.scope.lanes.getLocalTrackedLaneByRemoteName(\n remoteLaneId.name,\n remoteLaneId.scope as string\n );\n this.logger.debug(`populatePropsAccordingToRemoteLane, remoteLaneId: ${remoteLaneId.toString()}`);\n this.switchProps.localLaneName = this.switchProps.newLaneName || localTrackedLane || remoteLaneId.name;\n if (this.consumer.getCurrentLaneId().name === this.switchProps.localLaneName) {\n throw new GeneralError(`already checked out to \"${this.switchProps.localLaneName}\"`);\n }\n const scopeComponentImporter = ScopeComponentsImporter.getInstance(this.consumer.scope);\n const remoteLaneObjects = await scopeComponentImporter.importFromLanes([remoteLaneId]);\n if (remoteLaneObjects.length === 0) {\n throw new GeneralError(\n `invalid lane id \"${this.switchProps.laneName}\", the lane ${this.switchProps.laneName} doesn't exist.`\n );\n }\n const remoteLaneComponents = remoteLaneObjects[0].components;\n this.switchProps.remoteLaneName = remoteLaneId.name;\n this.switchProps.laneName = remoteLaneId.name;\n this.switchProps.remoteLaneScope = remoteLaneId.scope;\n this.switchProps.remoteScope = remoteLaneId.scope;\n this.switchProps.ids = remoteLaneComponents.map((l) => l.id.changeVersion(l.head.toString()));\n this.switchProps.remoteLaneComponents = remoteLaneComponents;\n this.switchProps.localTrackedLane = localTrackedLane || undefined;\n const laneExistsLocally = lanes.find((l) => l.name === this.switchProps.localLaneName);\n if (laneExistsLocally) {\n throw new GeneralError(`unable to checkout to a remote lane ${this.switchProps.remoteScope}/${this.switchProps.laneName}.\nthe local lane \"${this.switchProps.localLaneName}\" already exists, please switch to the local lane first by running \"bit switch ${this.switchProps.localLaneName}\"\nthen, to merge the remote lane into the local lane, run \"bit lane merge ${this.switchProps.localLaneName} --remote ${this.switchProps.remoteScope}\"`);\n }\n this.logger.debug(`populatePropsAccordingToRemoteLane, completed`);\n }\n\n private populatePropsAccordingToLocalLane(localLane: Lane | undefined) {\n this.switchProps.localLaneName = this.switchProps.laneName;\n if (this.consumer.getCurrentLaneId().name === this.switchProps.laneName) {\n throw new GeneralError(`already checked out to \"${this.switchProps.laneName}\"`);\n }\n if (this.switchProps.laneName === DEFAULT_LANE) {\n this.switchProps.ids = this.consumer.bitMap.getAuthoredAndImportedBitIdsOfDefaultLane();\n return;\n }\n if (!localLane) {\n throw new GeneralError(\n `unable to find a local lane \"${this.switchProps.laneName}\", to create a new lane please run \"bit lane create\"`\n );\n }\n this.switchProps.ids = localLane.components.map((c) => c.id.changeVersion(c.head.toString()));\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 private async saveLanesData() {\n await saveCheckedOutLaneInfo(this.consumer, {\n remoteLaneScope: this.switchProps.remoteLaneScope,\n remoteLaneName: this.switchProps.remoteLaneName,\n localLaneName: this.switchProps.localLaneName,\n addTrackingInfo: !this.switchProps.localTrackedLane,\n laneComponents: this.switchProps.remoteLaneComponents,\n });\n }\n}\n\nasync function saveCheckedOutLaneInfo(\n consumer: Consumer,\n opts: {\n remoteLaneScope?: string;\n remoteLaneName?: string;\n localLaneName?: string;\n addTrackingInfo?: boolean;\n laneComponents?: LaneComponent[];\n }\n) {\n const saveRemoteLaneToBitmap = () => {\n if (opts.remoteLaneScope) {\n consumer.bitMap.setRemoteLane(RemoteLaneId.from(opts.remoteLaneName as string, opts.remoteLaneScope));\n // add versions to lane\n }\n };\n const throwIfLaneExists = async () => {\n const allLanes = await consumer.scope.listLanes();\n if (allLanes.find((l) => l.name === opts.localLaneName)) {\n throw new GeneralError(`unable to checkout to lane \"${opts.localLaneName}\".\nthe lane already exists. please switch to the lane and merge`);\n }\n };\n\n if (opts.remoteLaneScope) {\n await throwIfLaneExists();\n await createNewLane(consumer, opts.localLaneName as string, opts.laneComponents);\n if (opts.addTrackingInfo) {\n // otherwise, it is tracked already\n consumer.scope.lanes.trackLane({\n localLane: opts.localLaneName as string,\n remoteLane: opts.remoteLaneName as string,\n remoteScope: opts.remoteLaneScope as string,\n });\n }\n }\n\n saveRemoteLaneToBitmap();\n consumer.scope.lanes.setCurrentLane(opts.localLaneName as string);\n const workspaceLane =\n opts.localLaneName === DEFAULT_LANE ? null : WorkspaceLane.load(opts.localLaneName as string, consumer.scope.path);\n consumer.bitMap.syncWithLanes(workspaceLane);\n}\n\nasync function getComponentStatus(consumer: Consumer, id: BitId, switchProps: SwitchProps): Promise<ComponentStatus> {\n const componentStatus: ComponentStatus = { id };\n const returnFailure = (msg: string) => {\n componentStatus.failureMessage = msg;\n return componentStatus;\n };\n const modelComponent = await consumer.scope.getModelComponentIfExist(id);\n if (!modelComponent) {\n return returnFailure(`component ${id.toString()} had never imported`);\n }\n const unmerged = consumer.scope.objects.unmergedComponents.getEntry(id.name);\n if (unmerged && unmerged.resolved === false) {\n return returnFailure(\n `component ${id.toStringWithoutVersion()} has conflicts that need to be resolved first, please 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}`);\n }\n const existingBitMapId = consumer.bitMap.getBitIdIfExist(id, { ignoreVersion: true });\n const componentOnLane: Version = await modelComponent.loadVersion(version, consumer.scope.objects);\n if (!existingBitMapId) {\n if (switchProps.existingOnWorkspaceOnly) {\n return returnFailure(`component ${id.toStringWithoutVersion()} is not in the workspace`);\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}`);\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 const isModified = await consumer.isComponentModified(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"]}
|
package/dist/switch.cmd.d.ts
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
import { Command, CommandOptions } from '@teambit/cli';
|
2
2
|
import { MergeStrategy } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';
|
3
|
+
import { LanesMain } from './lanes.main.runtime';
|
3
4
|
export declare class SwitchCmd implements Command {
|
5
|
+
private lanes;
|
4
6
|
name: string;
|
5
7
|
description: string;
|
6
8
|
private: boolean;
|
7
9
|
alias: string;
|
8
10
|
options: CommandOptions;
|
9
11
|
loader: boolean;
|
10
|
-
|
12
|
+
constructor(lanes: LanesMain);
|
13
|
+
report([lane]: [string], { as, merge, getAll, skipDependencyInstallation, json, }: {
|
11
14
|
as?: string;
|
12
15
|
merge?: MergeStrategy;
|
13
16
|
getAll?: boolean;
|
14
17
|
skipDependencyInstallation?: boolean;
|
15
|
-
verbose?: boolean;
|
16
18
|
override?: boolean;
|
17
19
|
json?: boolean;
|
18
20
|
}): Promise<string>;
|
package/dist/switch.cmd.js
CHANGED
@@ -31,26 +31,6 @@ function _chalk() {
|
|
31
31
|
return data;
|
32
32
|
}
|
33
33
|
|
34
|
-
function _ramda() {
|
35
|
-
const data = _interopRequireDefault(require("ramda"));
|
36
|
-
|
37
|
-
_ramda = function () {
|
38
|
-
return data;
|
39
|
-
};
|
40
|
-
|
41
|
-
return data;
|
42
|
-
}
|
43
|
-
|
44
|
-
function _consumer() {
|
45
|
-
const data = require("@teambit/legacy/dist/api/consumer");
|
46
|
-
|
47
|
-
_consumer = function () {
|
48
|
-
return data;
|
49
|
-
};
|
50
|
-
|
51
|
-
return data;
|
52
|
-
}
|
53
|
-
|
54
34
|
function _mergeVersion() {
|
55
35
|
const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
|
56
36
|
|
@@ -61,23 +41,14 @@ function _mergeVersion() {
|
|
61
41
|
return data;
|
62
42
|
}
|
63
43
|
|
64
|
-
function _bitError() {
|
65
|
-
const data = require("@teambit/bit-error");
|
66
|
-
|
67
|
-
_bitError = function () {
|
68
|
-
return data;
|
69
|
-
};
|
70
|
-
|
71
|
-
return data;
|
72
|
-
}
|
73
|
-
|
74
44
|
class SwitchCmd {
|
75
|
-
constructor() {
|
45
|
+
constructor(lanes) {
|
46
|
+
this.lanes = lanes;
|
76
47
|
(0, _defineProperty2().default)(this, "name", 'switch <lane>');
|
77
48
|
(0, _defineProperty2().default)(this, "description", `switch to the specified lane`);
|
78
49
|
(0, _defineProperty2().default)(this, "private", true);
|
79
50
|
(0, _defineProperty2().default)(this, "alias", '');
|
80
|
-
(0, _defineProperty2().default)(this, "options", [['n', 'as <as>', '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'], ['
|
51
|
+
(0, _defineProperty2().default)(this, "options", [['n', 'as <as>', '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']]);
|
81
52
|
(0, _defineProperty2().default)(this, "loader", true);
|
82
53
|
}
|
83
54
|
|
@@ -86,45 +57,17 @@ class SwitchCmd {
|
|
86
57
|
merge,
|
87
58
|
getAll = false,
|
88
59
|
skipDependencyInstallation = false,
|
89
|
-
verbose = false,
|
90
60
|
json = false
|
91
61
|
}) {
|
92
|
-
let mergeStrategy;
|
93
|
-
|
94
|
-
if (merge && _ramda().default.is(String, merge)) {
|
95
|
-
const options = Object.keys(_mergeVersion().MergeOptions);
|
96
|
-
|
97
|
-
if (!options.includes(merge)) {
|
98
|
-
throw new (_bitError().BitError)(`merge must be one of the following: ${options.join(', ')}`);
|
99
|
-
}
|
100
|
-
|
101
|
-
mergeStrategy = merge;
|
102
|
-
}
|
103
|
-
|
104
|
-
const switchProps = {
|
105
|
-
laneName: lane,
|
106
|
-
existingOnWorkspaceOnly: !getAll,
|
107
|
-
newLaneName: as
|
108
|
-
};
|
109
|
-
const checkoutProps = {
|
110
|
-
mergeStrategy,
|
111
|
-
verbose,
|
112
|
-
skipNpmInstall: skipDependencyInstallation,
|
113
|
-
// not relevant in Harmony
|
114
|
-
ignorePackageJson: true,
|
115
|
-
// not relevant in Harmony
|
116
|
-
ignoreDist: true,
|
117
|
-
// not relevant in Harmony
|
118
|
-
isLane: true,
|
119
|
-
promptMergeOptions: false,
|
120
|
-
writeConfig: false,
|
121
|
-
reset: false,
|
122
|
-
all: false
|
123
|
-
};
|
124
62
|
const {
|
125
63
|
components,
|
126
64
|
failedComponents
|
127
|
-
} = await
|
65
|
+
} = await this.lanes.switchLanes(lane, {
|
66
|
+
newLaneName: as,
|
67
|
+
merge,
|
68
|
+
getAll,
|
69
|
+
skipDependencyInstallation
|
70
|
+
});
|
128
71
|
|
129
72
|
if (json) {
|
130
73
|
return JSON.stringify({
|
package/dist/switch.cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["switch.cmd.ts"],"names":["SwitchCmd","report","lane","as","merge","getAll","skipDependencyInstallation","
|
1
|
+
{"version":3,"sources":["switch.cmd.ts"],"names":["SwitchCmd","constructor","lanes","report","lane","as","merge","getAll","skipDependencyInstallation","json","components","failedComponents","switchLanes","newLaneName","JSON","stringify","getFailureOutput","length","title","body","map","failedComponent","chalk","bold","id","toString","red","failureMessage","join","getSuccessfulOutput","laneSwitched","green","component","componentName","toStringWithoutVersion","version","componentsStr","failedOutput","successOutput"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,SAAN,CAAmC;AAs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C","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 'as <as>',\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 as,\n merge,\n getAll = false,\n skipDependencyInstallation = false,\n json = false,\n }: {\n as?: 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 newLaneName: as,\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(\n (failedComponent) =>\n `${chalk.bold(failedComponent.id.toString())} - ${chalk.red(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"]}
|
Binary file
|
package/package.json
CHANGED
@@ -1,39 +1,40 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/lanes",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.291",
|
4
4
|
"homepage": "https://bit.dev/teambit/lanes/lanes",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.lanes",
|
8
8
|
"name": "lanes",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.291"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
|
-
"chalk": "
|
12
|
+
"chalk": "4.1.2",
|
13
13
|
"yn": "2.0.0",
|
14
14
|
"graphql-tag": "2.12.1",
|
15
15
|
"lodash": "4.17.21",
|
16
16
|
"react-router-dom": "5.2.0",
|
17
|
-
"
|
17
|
+
"p-map-series": "2.1.0",
|
18
18
|
"@babel/runtime": "7.12.18",
|
19
19
|
"core-js": "^3.0.0",
|
20
20
|
"@teambit/harmony": "0.3.3",
|
21
21
|
"@teambit/bit-error": "0.0.394",
|
22
|
-
"@teambit/cli": "0.0.
|
23
|
-
"@teambit/merging": "0.0.
|
24
|
-
"@teambit/scope": "0.0.
|
25
|
-
"@teambit/workspace": "0.0.
|
26
|
-
"@teambit/graphql": "0.0.
|
27
|
-
"@teambit/community": "0.0.
|
28
|
-
"@teambit/component": "0.0.
|
29
|
-
"@teambit/lanes.modules.diff": "0.0.
|
22
|
+
"@teambit/cli": "0.0.478",
|
23
|
+
"@teambit/merging": "0.0.34",
|
24
|
+
"@teambit/scope": "0.0.719",
|
25
|
+
"@teambit/workspace": "0.0.719",
|
26
|
+
"@teambit/graphql": "0.0.719",
|
27
|
+
"@teambit/community": "0.0.26",
|
28
|
+
"@teambit/component": "0.0.719",
|
29
|
+
"@teambit/lanes.modules.diff": "0.0.108",
|
30
30
|
"@teambit/legacy-bit-id": "0.0.399",
|
31
|
-
"@teambit/
|
32
|
-
"@teambit/
|
33
|
-
"@teambit/
|
31
|
+
"@teambit/logger": "0.0.570",
|
32
|
+
"@teambit/lanes.ui.lanes": "0.0.45",
|
33
|
+
"@teambit/react-router": "0.0.719",
|
34
|
+
"@teambit/sidebar": "0.0.719",
|
34
35
|
"@teambit/ui-foundation.ui.menu": "0.0.487",
|
35
36
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.489",
|
36
|
-
"@teambit/ui": "0.0.
|
37
|
+
"@teambit/ui": "0.0.719"
|
37
38
|
},
|
38
39
|
"devDependencies": {
|
39
40
|
"@types/react": "^17.0.8",
|
@@ -49,7 +50,7 @@
|
|
49
50
|
"@teambit/workspace.testing.mock-workspace": "0.0.5"
|
50
51
|
},
|
51
52
|
"peerDependencies": {
|
52
|
-
"@teambit/legacy": "1.0.
|
53
|
+
"@teambit/legacy": "1.0.258",
|
53
54
|
"react-dom": "^16.8.0 || ^17.0.0",
|
54
55
|
"react": "^16.8.0 || ^17.0.0"
|
55
56
|
},
|
@@ -77,7 +78,7 @@
|
|
77
78
|
"react": "-"
|
78
79
|
},
|
79
80
|
"peerDependencies": {
|
80
|
-
"@teambit/legacy": "1.0.
|
81
|
+
"@teambit/legacy": "1.0.258",
|
81
82
|
"react-dom": "^16.8.0 || ^17.0.0",
|
82
83
|
"react": "^16.8.0 || ^17.0.0"
|
83
84
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.291/dist/lanes.composition.js')]
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.291/dist/lanes.docs.mdx')]
|
Binary file
|