@teambit/lanes.modules.diff 0.0.0-3e2e1a2e4717ea49c193725079c1107973ecc661

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.
@@ -0,0 +1,3 @@
1
+ export { LaneDiffCmd } from './lane-diff.cmd';
2
+ export { LaneHistoryDiffCmd } from './lane-history-diff.cmd';
3
+ export { LaneDiffGenerator, LaneDiffResults } from './lane-diff-generator';
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "LaneDiffCmd", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _laneDiff().LaneDiffCmd;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "LaneDiffGenerator", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _laneDiffGenerator().LaneDiffGenerator;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "LaneDiffResults", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _laneDiffGenerator().LaneDiffResults;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "LaneHistoryDiffCmd", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _laneHistoryDiff().LaneHistoryDiffCmd;
28
+ }
29
+ });
30
+ function _laneDiff() {
31
+ const data = require("./lane-diff.cmd");
32
+ _laneDiff = function () {
33
+ return data;
34
+ };
35
+ return data;
36
+ }
37
+ function _laneHistoryDiff() {
38
+ const data = require("./lane-history-diff.cmd");
39
+ _laneHistoryDiff = function () {
40
+ return data;
41
+ };
42
+ return data;
43
+ }
44
+ function _laneDiffGenerator() {
45
+ const data = require("./lane-diff-generator");
46
+ _laneDiffGenerator = function () {
47
+ return data;
48
+ };
49
+ return data;
50
+ }
51
+
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_laneDiff","data","require","_laneHistoryDiff","_laneDiffGenerator"],"sources":["index.ts"],"sourcesContent":["export { LaneDiffCmd } from './lane-diff.cmd';\nexport { LaneHistoryDiffCmd } from './lane-history-diff.cmd';\nexport { LaneDiffGenerator, LaneDiffResults } from './lane-diff-generator';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,iBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,mBAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,kBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,47 @@
1
+ import { ScopeMain } from '@teambit/scope';
2
+ import { Workspace } from '@teambit/workspace';
3
+ import { Lane, LaneHistory } from '@teambit/objects';
4
+ import { ComponentID } from '@teambit/component-id';
5
+ import { DiffResults, DiffOptions } from '@teambit/legacy.component-diff';
6
+ import { ComponentCompareMain } from '@teambit/component-compare';
7
+ type Failure = {
8
+ id: ComponentID;
9
+ msg: string;
10
+ };
11
+ export type LaneDiffResults = {
12
+ newCompsFrom: string[];
13
+ newCompsTo: string[];
14
+ compsWithDiff: DiffResults[];
15
+ compsWithNoChanges: string[];
16
+ toLaneName: string;
17
+ fromLaneName: string;
18
+ failures: Failure[];
19
+ };
20
+ export declare class LaneDiffGenerator {
21
+ private workspace;
22
+ private scope;
23
+ private componentCompare;
24
+ private newCompsFrom;
25
+ private newCompsTo;
26
+ private compsWithDiff;
27
+ private compsWithNoChanges;
28
+ private fromLaneData;
29
+ private toLaneData;
30
+ private failures;
31
+ constructor(workspace: Workspace | undefined, scope: ScopeMain, componentCompare: ComponentCompareMain);
32
+ /**
33
+ * the values array may include zero to two values and will be processed as following:
34
+ * [] => diff between the default lane (from) and the current lane (to). (only inside workspace).
35
+ * [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
36
+ * [from, to] => diff between "from" lane and "to" lane.
37
+ */
38
+ generate(values: string[], diffOptions?: DiffOptions, pattern?: string): Promise<LaneDiffResults>;
39
+ generateDiffHistory(lane: Lane, laneHistory: LaneHistory, fromHistoryId: string, toHistoryId: string, pattern?: string): Promise<LaneDiffResults>;
40
+ laneDiffResultsToString(laneDiffResults: LaneDiffResults): string;
41
+ private componentDiff;
42
+ private getLaneNames;
43
+ private getDefaultLaneData;
44
+ private mapToLaneData;
45
+ private mapHistoryToLaneData;
46
+ }
47
+ export {};
@@ -0,0 +1,336 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LaneDiffGenerator = void 0;
7
+ function _objects() {
8
+ const data = require("@teambit/objects");
9
+ _objects = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _componentId() {
15
+ const data = require("@teambit/component-id");
16
+ _componentId = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _legacy() {
22
+ const data = require("@teambit/legacy.component-diff");
23
+ _legacy = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _laneId() {
29
+ const data = require("@teambit/lane-id");
30
+ _laneId = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _bitError() {
36
+ const data = require("@teambit/bit-error");
37
+ _bitError = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _chalk() {
43
+ const data = _interopRequireDefault(require("chalk"));
44
+ _chalk = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
50
+ class LaneDiffGenerator {
51
+ newCompsFrom = [];
52
+ newCompsTo = [];
53
+ compsWithDiff = [];
54
+ compsWithNoChanges = [];
55
+ failures = [];
56
+ constructor(workspace, scope, componentCompare) {
57
+ this.workspace = workspace;
58
+ this.scope = scope;
59
+ this.componentCompare = componentCompare;
60
+ }
61
+
62
+ /**
63
+ * the values array may include zero to two values and will be processed as following:
64
+ * [] => diff between the default lane (from) and the current lane (to). (only inside workspace).
65
+ * [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
66
+ * [from, to] => diff between "from" lane and "to" lane.
67
+ */
68
+ async generate(values, diffOptions = {}, pattern) {
69
+ const {
70
+ fromLaneName,
71
+ toLaneName
72
+ } = this.getLaneNames(values);
73
+ if (fromLaneName === toLaneName) {
74
+ throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
75
+ }
76
+ const legacyScope = this.scope.legacyScope;
77
+ const fromLaneId = await legacyScope.lanes.parseLaneIdFromString(fromLaneName);
78
+ const toLaneId = await legacyScope.lanes.parseLaneIdFromString(toLaneName);
79
+ let toLane;
80
+ let fromLane;
81
+ if (fromLaneId.isDefault()) {
82
+ if (toLaneId.isDefault()) throw new Error(`unable to diff between main and main, they're the same lane`);
83
+ toLane = await legacyScope.lanes.loadLane(toLaneId);
84
+ if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
85
+ this.toLaneData = await this.mapToLaneData(toLane);
86
+ const bitIds = toLane.components.map(c => c.id);
87
+ this.fromLaneData = await this.getDefaultLaneData(bitIds);
88
+ } else if (toLaneId.isDefault()) {
89
+ fromLane = await legacyScope.lanes.loadLane(fromLaneId);
90
+ if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
91
+ this.fromLaneData = await this.mapToLaneData(fromLane);
92
+ const bitIds = fromLane?.components.map(c => c.id) || [];
93
+ this.toLaneData = await this.getDefaultLaneData(bitIds);
94
+ } else {
95
+ // both, "from" and "to" are not default-lane.
96
+ toLane = await legacyScope.lanes.loadLane(toLaneId);
97
+ if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
98
+ fromLane = await legacyScope.lanes.loadLane(fromLaneId);
99
+ if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
100
+ this.toLaneData = await this.mapToLaneData(toLane);
101
+ this.fromLaneData = await this.mapToLaneData(fromLane);
102
+ }
103
+ let idsToCheckDiff;
104
+ if (pattern) {
105
+ const compIds = this.toLaneData.components.map(c => c.id);
106
+ idsToCheckDiff = _componentId().ComponentIdList.fromArray(await this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds));
107
+ }
108
+ if (!this.toLaneData.components.length) {
109
+ throw new (_bitError().BitError)(`lane "${toLaneName}" is empty, nothing to show`);
110
+ }
111
+ const idsOfTo = _componentId().ComponentIdList.fromArray(this.toLaneData.components.map(c => c.id.changeVersion(c.head?.toString())));
112
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfTo, {
113
+ cache: true,
114
+ lane: toLane || undefined,
115
+ ignoreMissingHead: true,
116
+ reason: `for the "to" diff - ${toLane ? toLane.name : _laneId().DEFAULT_LANE}`
117
+ });
118
+ const idsOfFrom = _componentId().ComponentIdList.fromArray(this.fromLaneData.components.map(c => c.id.changeVersion(c.head?.toString())));
119
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfFrom, {
120
+ cache: true,
121
+ lane: fromLane || undefined,
122
+ ignoreMissingHead: true,
123
+ reason: `for the "from" diff - ${fromLane ? fromLane.name : _laneId().DEFAULT_LANE}`
124
+ });
125
+ await Promise.all(this.toLaneData.components.map(async ({
126
+ id,
127
+ head
128
+ }) => {
129
+ if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
130
+ return;
131
+ }
132
+ await this.componentDiff(id, head, diffOptions, true);
133
+ }));
134
+ return {
135
+ newCompsFrom: this.newCompsFrom.map(id => id.toString()),
136
+ newCompsTo: this.newCompsTo.map(id => id.toString()),
137
+ compsWithDiff: this.compsWithDiff,
138
+ compsWithNoChanges: this.compsWithNoChanges.map(id => id.toString()),
139
+ toLaneName: this.toLaneData.name,
140
+ fromLaneName: this.fromLaneData.name,
141
+ failures: this.failures
142
+ };
143
+ }
144
+ async generateDiffHistory(lane, laneHistory, fromHistoryId, toHistoryId, pattern) {
145
+ const laneId = lane.toLaneId();
146
+ const history = laneHistory.getHistory();
147
+ const fromLane = history[fromHistoryId];
148
+ const toLane = history[toHistoryId];
149
+ if (!fromLane) throw new Error(`unable to find the from-history-id "${fromHistoryId}" in lane "${laneId.toString()}"`);
150
+ if (!toLane) throw new Error(`unable to find the to-history-id "${toHistoryId}" in lane "${laneId.toString()}"`);
151
+ this.fromLaneData = this.mapHistoryToLaneData(laneId, fromHistoryId, fromLane);
152
+ this.toLaneData = this.mapHistoryToLaneData(laneId, toHistoryId, toLane);
153
+ let idsToCheckDiff;
154
+ if (pattern) {
155
+ const compIds = this.toLaneData.components.map(c => c.id);
156
+ idsToCheckDiff = _componentId().ComponentIdList.fromArray(await this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds));
157
+ }
158
+ if (!this.toLaneData.components.length) {
159
+ throw new (_bitError().BitError)(`lane-history "${toHistoryId}" is empty, nothing to show`);
160
+ }
161
+ const idsOfTo = _componentId().ComponentIdList.fromArray(this.toLaneData.components.map(c => c.id.changeVersion(c.head?.toString())));
162
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfTo, {
163
+ cache: true,
164
+ lane,
165
+ ignoreMissingHead: true,
166
+ reason: `for the "to" diff - ${laneId.toString()}-${toHistoryId}`
167
+ });
168
+ const idsOfFrom = _componentId().ComponentIdList.fromArray(this.fromLaneData.components.map(c => c.id.changeVersion(c.head?.toString())));
169
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfFrom, {
170
+ cache: true,
171
+ lane,
172
+ ignoreMissingHead: true,
173
+ reason: `for the "from" diff - ${laneId.toString()}-${fromHistoryId}`
174
+ });
175
+ await Promise.all(this.toLaneData.components.map(async ({
176
+ id,
177
+ head
178
+ }) => {
179
+ if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
180
+ return;
181
+ }
182
+ await this.componentDiff(id, head);
183
+ }));
184
+ return {
185
+ newCompsFrom: this.newCompsFrom.map(id => id.toString()),
186
+ newCompsTo: this.newCompsTo.map(id => id.toString()),
187
+ compsWithDiff: this.compsWithDiff,
188
+ compsWithNoChanges: this.compsWithNoChanges.map(id => id.toString()),
189
+ toLaneName: this.toLaneData.name,
190
+ fromLaneName: this.fromLaneData.name,
191
+ failures: this.failures
192
+ };
193
+ }
194
+ laneDiffResultsToString(laneDiffResults) {
195
+ const {
196
+ compsWithDiff,
197
+ newCompsFrom,
198
+ newCompsTo,
199
+ toLaneName,
200
+ fromLaneName,
201
+ failures
202
+ } = laneDiffResults;
203
+ const newCompsOutput = (laneName, ids) => {
204
+ if (!ids.length) return '';
205
+ const newCompsIdsStr = ids.map(id => _chalk().default.bold(id)).join('\n');
206
+ const newCompsTitle = `\nThe following components were introduced in ${_chalk().default.bold(laneName)} lane`;
207
+ return `${_chalk().default.inverse(newCompsTitle)}\n${newCompsIdsStr}`;
208
+ };
209
+ const diffResultsStr = (0, _legacy().outputDiffResults)(compsWithDiff);
210
+ const failuresTitle = `\n\nDiff failed on the following component(s)`;
211
+ const failuresIds = failures.map(f => `${f.id.toString()} - ${_chalk().default.red(f.msg)}`).join('\n');
212
+ const failuresStr = failures.length ? `${_chalk().default.inverse(failuresTitle)}\n${failuresIds}` : '';
213
+ const newCompsToStr = newCompsOutput(toLaneName, newCompsTo);
214
+ const newCompsFromStr = newCompsOutput(fromLaneName, newCompsFrom);
215
+ return `${diffResultsStr}${newCompsToStr}${newCompsFromStr}${failuresStr}`;
216
+ }
217
+ async componentDiff(id, toLaneHead, diffOptions = {}, compareToHeadIfEmpty = false) {
218
+ const modelComponent = await this.scope.legacyScope.getModelComponent(id);
219
+ const foundFromLane = this.fromLaneData.components.find(c => c.id.isEqualWithoutVersion(id))?.head;
220
+ const fromLaneHead = compareToHeadIfEmpty ? foundFromLane || modelComponent.head : foundFromLane;
221
+ if (!fromLaneHead) {
222
+ this.newCompsTo.push(id);
223
+ return;
224
+ }
225
+ if (!toLaneHead) {
226
+ this.newCompsFrom.push(id);
227
+ return;
228
+ }
229
+ if (fromLaneHead.isEqual(toLaneHead)) {
230
+ this.compsWithNoChanges.push(id);
231
+ return;
232
+ }
233
+ let fromVersion;
234
+ try {
235
+ fromVersion = await modelComponent.loadVersion(fromLaneHead.toString(), this.scope.legacyScope.objects, true);
236
+ } catch (err) {
237
+ this.failures.push({
238
+ id,
239
+ msg: err.message
240
+ });
241
+ return;
242
+ }
243
+ const toVersion = await toLaneHead.load(this.scope.legacyScope.objects);
244
+ const fromLaneStr = this.fromLaneData.name;
245
+ diffOptions.formatDepsAsTable = false;
246
+ const diff = await this.componentCompare.diffBetweenVersionsObjects(modelComponent, fromVersion, toVersion, fromLaneStr, this.toLaneData.name, diffOptions);
247
+ this.compsWithDiff.push(diff);
248
+ }
249
+ getLaneNames(values) {
250
+ if (values.length > 2) {
251
+ throw new Error(`expect "values" to include no more than two args, got ${values.length}`);
252
+ }
253
+ if (this.workspace) {
254
+ const currentLane = this.workspace.getCurrentLaneId();
255
+ if (!values.length) {
256
+ if (currentLane.isDefault()) {
257
+ throw new Error(`you are currently on the default branch, to run diff between lanes, please specify them`);
258
+ }
259
+ return {
260
+ toLaneName: currentLane.name,
261
+ fromLaneName: _laneId().DEFAULT_LANE
262
+ };
263
+ }
264
+ if (values.length === 1) {
265
+ const toLaneName = currentLane.isDefault() ? _laneId().DEFAULT_LANE : currentLane.name;
266
+ return {
267
+ toLaneName,
268
+ fromLaneName: values[0]
269
+ };
270
+ }
271
+ return {
272
+ toLaneName: values[1],
273
+ fromLaneName: values[0]
274
+ };
275
+ }
276
+ // running from the scope
277
+ if (values.length < 1) {
278
+ throw new Error(`expect "values" to include at least one arg - the lane name`);
279
+ }
280
+ const fromLaneName = values.length === 2 ? values[0] : _laneId().DEFAULT_LANE;
281
+ const toLaneName = values.length === 2 ? values[1] : values[0];
282
+ return {
283
+ fromLaneName,
284
+ toLaneName
285
+ };
286
+ }
287
+ async getDefaultLaneData(ids) {
288
+ const laneData = {
289
+ name: _laneId().DEFAULT_LANE,
290
+ remote: null,
291
+ components: []
292
+ };
293
+ await Promise.all(ids.map(async id => {
294
+ const modelComponent = await this.scope.legacyScope.getModelComponent(id);
295
+ const laneComponent = {
296
+ id,
297
+ head: modelComponent.head,
298
+ // @todo: this is not true. it can be undefined
299
+ version: modelComponent.latestVersion() // should this be latestVersion() or bitId.version.toString()
300
+ };
301
+ laneData.components.push(laneComponent);
302
+ }));
303
+ return laneData;
304
+ }
305
+ async mapToLaneData(lane) {
306
+ const {
307
+ name,
308
+ components
309
+ } = lane;
310
+ return {
311
+ name,
312
+ components: components.map(lc => ({
313
+ id: lc.id,
314
+ head: lc.head,
315
+ version: lc.id.version?.toString()
316
+ })),
317
+ remote: lane.toLaneId().toString()
318
+ };
319
+ }
320
+ mapHistoryToLaneData(laneId, historyId, historyItem) {
321
+ return {
322
+ name: historyId,
323
+ components: historyItem.components.map(compStr => {
324
+ const compId = _componentId().ComponentID.fromString(compStr);
325
+ return {
326
+ id: compId.changeVersion(undefined),
327
+ head: _objects().Ref.from(compId.version)
328
+ };
329
+ }),
330
+ remote: laneId.toString()
331
+ };
332
+ }
333
+ }
334
+ exports.LaneDiffGenerator = LaneDiffGenerator;
335
+
336
+ //# sourceMappingURL=lane-diff-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_objects","data","require","_componentId","_legacy","_laneId","_bitError","_chalk","_interopRequireDefault","e","__esModule","default","LaneDiffGenerator","newCompsFrom","newCompsTo","compsWithDiff","compsWithNoChanges","failures","constructor","workspace","scope","componentCompare","generate","values","diffOptions","pattern","fromLaneName","toLaneName","getLaneNames","Error","legacyScope","fromLaneId","lanes","parseLaneIdFromString","toLaneId","toLane","fromLane","isDefault","loadLane","toLaneData","mapToLaneData","bitIds","components","map","c","id","fromLaneData","getDefaultLaneData","idsToCheckDiff","compIds","ComponentIdList","fromArray","filterIdsFromPoolIdsByPattern","length","BitError","idsOfTo","changeVersion","head","toString","scopeImporter","importWithoutDeps","cache","lane","undefined","ignoreMissingHead","reason","name","DEFAULT_LANE","idsOfFrom","Promise","all","hasWithoutVersion","componentDiff","generateDiffHistory","laneHistory","fromHistoryId","toHistoryId","laneId","history","getHistory","mapHistoryToLaneData","laneDiffResultsToString","laneDiffResults","newCompsOutput","laneName","ids","newCompsIdsStr","chalk","bold","join","newCompsTitle","inverse","diffResultsStr","outputDiffResults","failuresTitle","failuresIds","f","red","msg","failuresStr","newCompsToStr","newCompsFromStr","toLaneHead","compareToHeadIfEmpty","modelComponent","getModelComponent","foundFromLane","find","isEqualWithoutVersion","fromLaneHead","push","isEqual","fromVersion","loadVersion","objects","err","message","toVersion","load","fromLaneStr","formatDepsAsTable","diff","diffBetweenVersionsObjects","currentLane","getCurrentLaneId","laneData","remote","laneComponent","version","latestVersion","lc","historyId","historyItem","compStr","compId","ComponentID","fromString","Ref","from","exports"],"sources":["lane-diff-generator.ts"],"sourcesContent":["import { ScopeMain } from '@teambit/scope';\nimport { Workspace } from '@teambit/workspace';\nimport { HistoryItem, Ref, Lane, LaneHistory, Version } from '@teambit/objects';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport { DiffResults, DiffOptions, outputDiffResults } from '@teambit/legacy.component-diff';\nimport { DEFAULT_LANE, LaneId } from '@teambit/lane-id';\nimport { BitError } from '@teambit/bit-error';\nimport { ComponentCompareMain } from '@teambit/component-compare';\nimport chalk from 'chalk';\n\ntype LaneData = {\n name: string;\n components: Array<{\n id: ComponentID;\n head: Ref;\n }>;\n remote: string | null;\n};\n\ntype Failure = { id: ComponentID; msg: string };\n\nexport type LaneDiffResults = {\n newCompsFrom: string[];\n newCompsTo: string[];\n compsWithDiff: DiffResults[];\n compsWithNoChanges: string[];\n toLaneName: string;\n fromLaneName: string;\n failures: Failure[];\n};\n\nexport class LaneDiffGenerator {\n private newCompsFrom: ComponentID[] = [];\n private newCompsTo: ComponentID[] = [];\n private compsWithDiff: DiffResults[] = [];\n private compsWithNoChanges: ComponentID[] = [];\n private fromLaneData: LaneData;\n private toLaneData: LaneData;\n private failures: Failure[] = [];\n constructor(\n private workspace: Workspace | undefined,\n private scope: ScopeMain,\n private componentCompare: ComponentCompareMain\n ) {}\n\n /**\n * the values array may include zero to two values and will be processed as following:\n * [] => diff between the default lane (from) and the current lane (to). (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 async generate(values: string[], diffOptions: DiffOptions = {}, pattern?: string): Promise<LaneDiffResults> {\n const { fromLaneName, toLaneName } = this.getLaneNames(values);\n\n if (fromLaneName === toLaneName) {\n throw new Error(`unable to run diff between \"${fromLaneName}\" and \"${toLaneName}\", they're the same lane`);\n }\n const legacyScope = this.scope.legacyScope;\n const fromLaneId = await legacyScope.lanes.parseLaneIdFromString(fromLaneName);\n const toLaneId = await legacyScope.lanes.parseLaneIdFromString(toLaneName);\n let toLane: Lane | null | undefined;\n let fromLane: Lane | null | undefined;\n\n if (fromLaneId.isDefault()) {\n if (toLaneId.isDefault()) throw new Error(`unable to diff between main and main, they're the same lane`);\n toLane = await legacyScope.lanes.loadLane(toLaneId);\n if (!toLane) throw new Error(`unable to find a lane \"${toLaneName}\" in the scope`);\n this.toLaneData = await this.mapToLaneData(toLane);\n const bitIds = toLane.components.map((c) => c.id);\n this.fromLaneData = await this.getDefaultLaneData(bitIds);\n } else if (toLaneId.isDefault()) {\n fromLane = await legacyScope.lanes.loadLane(fromLaneId);\n if (!fromLane) throw new Error(`unable to find a lane \"${fromLaneName}\" in the scope`);\n this.fromLaneData = await this.mapToLaneData(fromLane);\n const bitIds = fromLane?.components.map((c) => c.id) || [];\n this.toLaneData = await this.getDefaultLaneData(bitIds);\n } else {\n // both, \"from\" and \"to\" are not default-lane.\n toLane = await legacyScope.lanes.loadLane(toLaneId);\n if (!toLane) throw new Error(`unable to find a lane \"${toLaneName}\" in the scope`);\n fromLane = await legacyScope.lanes.loadLane(fromLaneId);\n if (!fromLane) throw new Error(`unable to find a lane \"${fromLaneName}\" in the scope`);\n this.toLaneData = await this.mapToLaneData(toLane);\n this.fromLaneData = await this.mapToLaneData(fromLane);\n }\n\n let idsToCheckDiff: ComponentIdList | undefined;\n if (pattern) {\n const compIds = this.toLaneData.components.map((c) => c.id);\n idsToCheckDiff = ComponentIdList.fromArray(await this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds));\n }\n\n if (!this.toLaneData.components.length) {\n throw new BitError(`lane \"${toLaneName}\" is empty, nothing to show`);\n }\n\n const idsOfTo = ComponentIdList.fromArray(\n this.toLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))\n );\n await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfTo, {\n cache: true,\n lane: toLane || undefined,\n ignoreMissingHead: true,\n reason: `for the \"to\" diff - ${toLane ? toLane.name : DEFAULT_LANE}`,\n });\n const idsOfFrom = ComponentIdList.fromArray(\n this.fromLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))\n );\n await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfFrom, {\n cache: true,\n lane: fromLane || undefined,\n ignoreMissingHead: true,\n reason: `for the \"from\" diff - ${fromLane ? fromLane.name : DEFAULT_LANE}`,\n });\n\n await Promise.all(\n this.toLaneData.components.map(async ({ id, head }) => {\n if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {\n return;\n }\n await this.componentDiff(id, head, diffOptions, true);\n })\n );\n\n return {\n newCompsFrom: this.newCompsFrom.map((id) => id.toString()),\n newCompsTo: this.newCompsTo.map((id) => id.toString()),\n compsWithDiff: this.compsWithDiff,\n compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),\n toLaneName: this.toLaneData.name,\n fromLaneName: this.fromLaneData.name,\n failures: this.failures,\n };\n }\n\n async generateDiffHistory(\n lane: Lane,\n laneHistory: LaneHistory,\n fromHistoryId: string,\n toHistoryId: string,\n pattern?: string\n ): Promise<LaneDiffResults> {\n const laneId = lane.toLaneId();\n const history = laneHistory.getHistory();\n const fromLane = history[fromHistoryId];\n const toLane = history[toHistoryId];\n if (!fromLane)\n throw new Error(`unable to find the from-history-id \"${fromHistoryId}\" in lane \"${laneId.toString()}\"`);\n if (!toLane) throw new Error(`unable to find the to-history-id \"${toHistoryId}\" in lane \"${laneId.toString()}\"`);\n this.fromLaneData = this.mapHistoryToLaneData(laneId, fromHistoryId, fromLane);\n this.toLaneData = this.mapHistoryToLaneData(laneId, toHistoryId, toLane);\n\n let idsToCheckDiff: ComponentIdList | undefined;\n if (pattern) {\n const compIds = this.toLaneData.components.map((c) => c.id);\n idsToCheckDiff = ComponentIdList.fromArray(await this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds));\n }\n\n if (!this.toLaneData.components.length) {\n throw new BitError(`lane-history \"${toHistoryId}\" is empty, nothing to show`);\n }\n\n const idsOfTo = ComponentIdList.fromArray(\n this.toLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))\n );\n await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfTo, {\n cache: true,\n lane,\n ignoreMissingHead: true,\n reason: `for the \"to\" diff - ${laneId.toString()}-${toHistoryId}`,\n });\n const idsOfFrom = ComponentIdList.fromArray(\n this.fromLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))\n );\n await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfFrom, {\n cache: true,\n lane,\n ignoreMissingHead: true,\n reason: `for the \"from\" diff - ${laneId.toString()}-${fromHistoryId}`,\n });\n\n await Promise.all(\n this.toLaneData.components.map(async ({ id, head }) => {\n if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {\n return;\n }\n await this.componentDiff(id, head);\n })\n );\n\n return {\n newCompsFrom: this.newCompsFrom.map((id) => id.toString()),\n newCompsTo: this.newCompsTo.map((id) => id.toString()),\n compsWithDiff: this.compsWithDiff,\n compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),\n toLaneName: this.toLaneData.name,\n fromLaneName: this.fromLaneData.name,\n failures: this.failures,\n };\n }\n\n laneDiffResultsToString(laneDiffResults: LaneDiffResults): string {\n const { compsWithDiff, newCompsFrom, newCompsTo, toLaneName, fromLaneName, failures } = laneDiffResults;\n\n const newCompsOutput = (laneName: string, ids: string[]) => {\n if (!ids.length) return '';\n const newCompsIdsStr = ids.map((id) => chalk.bold(id)).join('\\n');\n const newCompsTitle = `\\nThe following components were introduced in ${chalk.bold(laneName)} lane`;\n return `${chalk.inverse(newCompsTitle)}\\n${newCompsIdsStr}`;\n };\n\n const diffResultsStr = outputDiffResults(compsWithDiff);\n\n const failuresTitle = `\\n\\nDiff failed on the following component(s)`;\n const failuresIds = failures.map((f) => `${f.id.toString()} - ${chalk.red(f.msg)}`).join('\\n');\n const failuresStr = failures.length ? `${chalk.inverse(failuresTitle)}\\n${failuresIds}` : '';\n const newCompsToStr = newCompsOutput(toLaneName, newCompsTo);\n\n const newCompsFromStr = newCompsOutput(fromLaneName, newCompsFrom);\n return `${diffResultsStr}${newCompsToStr}${newCompsFromStr}${failuresStr}`;\n }\n\n private async componentDiff(\n id: ComponentID,\n toLaneHead: Ref | null,\n diffOptions: DiffOptions = {},\n compareToHeadIfEmpty = false\n ) {\n const modelComponent = await this.scope.legacyScope.getModelComponent(id);\n const foundFromLane = this.fromLaneData.components.find((c) => c.id.isEqualWithoutVersion(id))?.head;\n const fromLaneHead = compareToHeadIfEmpty ? foundFromLane || modelComponent.head : foundFromLane;\n if (!fromLaneHead) {\n this.newCompsTo.push(id);\n return;\n }\n if (!toLaneHead) {\n this.newCompsFrom.push(id);\n return;\n }\n if (fromLaneHead.isEqual(toLaneHead)) {\n this.compsWithNoChanges.push(id);\n return;\n }\n let fromVersion: Version;\n try {\n fromVersion = await modelComponent.loadVersion(fromLaneHead.toString(), this.scope.legacyScope.objects, true);\n } catch (err: any) {\n this.failures.push({ id, msg: err.message });\n return;\n }\n const toVersion = await toLaneHead.load(this.scope.legacyScope.objects);\n const fromLaneStr = this.fromLaneData.name;\n diffOptions.formatDepsAsTable = false;\n const diff = await this.componentCompare.diffBetweenVersionsObjects(\n modelComponent,\n fromVersion,\n toVersion as Version,\n fromLaneStr,\n this.toLaneData.name,\n diffOptions\n );\n this.compsWithDiff.push(diff);\n }\n\n private getLaneNames(values: string[]): { fromLaneName: string; toLaneName: string } {\n if (values.length > 2) {\n throw new Error(`expect \"values\" to include no more than two args, got ${values.length}`);\n }\n if (this.workspace) {\n const currentLane = this.workspace.getCurrentLaneId();\n if (!values.length) {\n if (currentLane.isDefault()) {\n throw new Error(`you are currently on the default branch, to run diff between lanes, please specify them`);\n }\n return { toLaneName: currentLane.name, fromLaneName: DEFAULT_LANE };\n }\n if (values.length === 1) {\n const toLaneName = currentLane.isDefault() ? DEFAULT_LANE : currentLane.name;\n return { toLaneName, fromLaneName: values[0] };\n }\n return { toLaneName: values[1], fromLaneName: values[0] };\n }\n // running from the scope\n if (values.length < 1) {\n throw new Error(`expect \"values\" to include at least one arg - the lane name`);\n }\n const fromLaneName = values.length === 2 ? values[0] : DEFAULT_LANE;\n const toLaneName = values.length === 2 ? values[1] : values[0];\n return { fromLaneName, toLaneName };\n }\n\n private async getDefaultLaneData(ids: ComponentID[]): Promise<LaneData> {\n const laneData: LaneData = {\n name: DEFAULT_LANE,\n remote: null,\n components: [],\n };\n\n await Promise.all(\n ids.map(async (id) => {\n const modelComponent = await this.scope.legacyScope.getModelComponent(id);\n const laneComponent = {\n id,\n head: modelComponent.head as Ref, // @todo: this is not true. it can be undefined\n version: modelComponent.latestVersion(), // should this be latestVersion() or bitId.version.toString()\n };\n laneData.components.push(laneComponent);\n })\n );\n\n return laneData;\n }\n\n private async mapToLaneData(lane: Lane): Promise<LaneData> {\n const { name, components } = lane;\n return {\n name,\n components: components.map((lc) => ({\n id: lc.id,\n head: lc.head,\n version: lc.id.version?.toString(),\n })),\n remote: lane.toLaneId().toString(),\n };\n }\n\n private mapHistoryToLaneData(laneId: LaneId, historyId: string, historyItem: HistoryItem): LaneData {\n return {\n name: historyId,\n components: historyItem.components.map((compStr) => {\n const compId = ComponentID.fromString(compStr);\n return {\n id: compId.changeVersion(undefined),\n head: Ref.from(compId.version),\n };\n }),\n remote: laneId.toString(),\n };\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,OAAA;EAAA,MAAAN,IAAA,GAAAO,sBAAA,CAAAN,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAO,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAuBnB,MAAMG,iBAAiB,CAAC;EACrBC,YAAY,GAAkB,EAAE;EAChCC,UAAU,GAAkB,EAAE;EAC9BC,aAAa,GAAkB,EAAE;EACjCC,kBAAkB,GAAkB,EAAE;EAGtCC,QAAQ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,CAAC;IACzC,CAAC,CACH,CAAC;IAED,OAAOF,QAAQ;EACjB;EAEA,MAAcrF,aAAaA,CAACsB,IAAU,EAAqB;IACzD,MAAM;MAAEI,IAAI;MAAExB;IAAW,CAAC,GAAGoB,IAAI;IACjC,OAAO;MACLI,IAAI;MACJxB,UAAU,EAAEA,UAAU,CAACC,GAAG,CAAEuF,EAAE,KAAM;QAClCrF,EAAE,EAAEqF,EAAE,CAACrF,EAAE;QACTY,IAAI,EAAEyE,EAAE,CAACzE,IAAI;QACbuE,OAAO,EAAEE,EAAE,CAACrF,EAAE,CAACmF,OAAO,EAAEtE,QAAQ,CAAC;MACnC,CAAC,CAAC,CAAC;MACHoE,MAAM,EAAEhE,IAAI,CAAC5B,QAAQ,CAAC,CAAC,CAACwB,QAAQ,CAAC;IACnC,CAAC;EACH;EAEQsB,oBAAoBA,CAACH,MAAc,EAAEsD,SAAiB,EAAEC,WAAwB,EAAY;IAClG,OAAO;MACLlE,IAAI,EAAEiE,SAAS;MACfzF,UAAU,EAAE0F,WAAW,CAAC1F,UAAU,CAACC,GAAG,CAAE0F,OAAO,IAAK;QAClD,MAAMC,MAAM,GAAGC,0BAAW,CAACC,UAAU,CAACH,OAAO,CAAC;QAC9C,OAAO;UACLxF,EAAE,EAAEyF,MAAM,CAAC9E,aAAa,CAACO,SAAS,CAAC;UACnCN,IAAI,EAAEgF,cAAG,CAACC,IAAI,CAACJ,MAAM,CAACN,OAAO;QAC/B,CAAC;MACH,CAAC,CAAC;MACFF,MAAM,EAAEjD,MAAM,CAACnB,QAAQ,CAAC;IAC1B,CAAC;EACH;AACF;AAACiF,OAAA,CAAA/H,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ScopeMain } from '@teambit/scope';
3
+ import { Workspace } from '@teambit/workspace';
4
+ import { ComponentCompareMain } from '@teambit/component-compare';
5
+ export declare class LaneDiffCmd implements Command {
6
+ private workspace;
7
+ private scope;
8
+ private componentCompare;
9
+ name: string;
10
+ description: string;
11
+ extendedDescription: string;
12
+ alias: string;
13
+ arguments: {
14
+ name: string;
15
+ description: string;
16
+ }[];
17
+ options: CommandOptions;
18
+ loader: boolean;
19
+ private: boolean;
20
+ remoteOp: boolean;
21
+ skipWorkspace: boolean;
22
+ constructor(workspace: Workspace, scope: ScopeMain, componentCompare: ComponentCompareMain);
23
+ report([values]: [string[]], { pattern }: {
24
+ pattern?: string;
25
+ }): Promise<string>;
26
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LaneDiffCmd = void 0;
7
+ function _legacy() {
8
+ const data = require("@teambit/legacy.constants");
9
+ _legacy = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _laneDiffGenerator() {
15
+ const data = require("./lane-diff-generator");
16
+ _laneDiffGenerator = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ class LaneDiffCmd {
22
+ name = 'diff [values...]';
23
+ description = `show diff between lanes`;
24
+ extendedDescription = `bit lane diff => diff between the current lane and default lane. (only inside workspace).
25
+ bit lane diff to => diff between the current lane (or default-lane when in scope) and "to" lane.
26
+ bit lane diff from to => diff between "from" lane and "to" lane.`;
27
+ alias = '';
28
+ arguments = [{
29
+ name: 'from',
30
+ description: `base lane for comparison`
31
+ }, {
32
+ name: 'to',
33
+ description: `lane being compared to base lane`
34
+ }];
35
+ options = [['', 'pattern <component-pattern>', `show lane-diff for components conforming to the specified component-pattern only
36
+ component-pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`]];
37
+ loader = true;
38
+ private = true;
39
+ remoteOp = true;
40
+ skipWorkspace = true;
41
+ constructor(workspace, scope, componentCompare) {
42
+ this.workspace = workspace;
43
+ this.scope = scope;
44
+ this.componentCompare = componentCompare;
45
+ }
46
+ async report([values = []], {
47
+ pattern
48
+ }) {
49
+ const laneDiffGenerator = new (_laneDiffGenerator().LaneDiffGenerator)(this.workspace, this.scope, this.componentCompare);
50
+ const results = await laneDiffGenerator.generate(values, undefined, pattern);
51
+ return laneDiffGenerator.laneDiffResultsToString(results);
52
+ }
53
+ }
54
+ exports.LaneDiffCmd = LaneDiffCmd;
55
+
56
+ //# sourceMappingURL=lane-diff.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_legacy","data","require","_laneDiffGenerator","LaneDiffCmd","name","description","extendedDescription","alias","arguments","options","COMPONENT_PATTERN_HELP","loader","private","remoteOp","skipWorkspace","constructor","workspace","scope","componentCompare","report","values","pattern","laneDiffGenerator","LaneDiffGenerator","results","generate","undefined","laneDiffResultsToString","exports"],"sources":["lane-diff.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ScopeMain } from '@teambit/scope';\nimport { Workspace } from '@teambit/workspace';\nimport { ComponentCompareMain } from '@teambit/component-compare';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport { LaneDiffGenerator } from './lane-diff-generator';\n\nexport class LaneDiffCmd implements Command {\n name = 'diff [values...]';\n description = `show diff between lanes`;\n extendedDescription = `bit lane diff => diff between the current lane and default lane. (only inside workspace).\nbit lane diff to => diff between the current lane (or default-lane when in scope) and \"to\" lane.\nbit lane diff from to => diff between \"from\" lane and \"to\" lane.`;\n alias = '';\n arguments = [\n {\n name: 'from',\n description: `base lane for comparison`,\n },\n {\n name: 'to',\n description: `lane being compared to base lane`,\n },\n ];\n options = [\n [\n '',\n 'pattern <component-pattern>',\n `show lane-diff for components conforming to the specified component-pattern only\ncomponent-pattern format: ${COMPONENT_PATTERN_HELP}`,\n ],\n ] as CommandOptions;\n loader = true;\n private = true;\n remoteOp = true;\n skipWorkspace = true;\n\n constructor(\n private workspace: Workspace,\n private scope: ScopeMain,\n private componentCompare: ComponentCompareMain\n ) {}\n\n async report([values = []]: [string[]], { pattern }: { pattern?: string }) {\n const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope, this.componentCompare);\n const results = await laneDiffGenerator.generate(values, undefined, pattern);\n return laneDiffGenerator.laneDiffResultsToString(results);\n }\n}\n"],"mappings":";;;;;;AAIA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,mBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,kBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAMG,WAAW,CAAoB;EAC1CC,IAAI,GAAG,kBAAkB;EACzBC,WAAW,GAAG,yBAAyB;EACvCC,mBAAmB,GAAG;AACxB;AACA,iEAAiE;EAC/DC,KAAK,GAAG,EAAE;EACVC,SAAS,GAAG,CACV;IACEJ,IAAI,EAAE,MAAM;IACZC,WAAW,EAAE;EACf,CAAC,EACD;IACED,IAAI,EAAE,IAAI;IACVC,WAAW,EAAE;EACf,CAAC,CACF;EACDI,OAAO,GAAG,CACR,CACE,EAAE,EACF,6BAA6B,EAC7B;AACN,4BAA4BC,gCAAsB,EAAE,CAC/C,CACF;EACDC,MAAM,GAAG,IAAI;EACbC,OAAO,GAAG,IAAI;EACdC,QAAQ,GAAG,IAAI;EACfC,aAAa,GAAG,IAAI;EAEpBC,WAAWA,CACDC,SAAoB,EACpBC,KAAgB,EAChBC,gBAAsC,EAC9C;IAAA,KAHQF,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,KAAgB,GAAhBA,KAAgB;IAAA,KAChBC,gBAAsC,GAAtCA,gBAAsC;EAC7C;EAEH,MAAMC,MAAMA,CAAC,CAACC,MAAM,GAAG,EAAE,CAAa,EAAE;IAAEC;EAA8B,CAAC,EAAE;IACzE,MAAMC,iBAAiB,GAAG,KAAIC,sCAAiB,EAAC,IAAI,CAACP,SAAS,EAAE,IAAI,CAACC,KAAK,EAAE,IAAI,CAACC,gBAAgB,CAAC;IAClG,MAAMM,OAAO,GAAG,MAAMF,iBAAiB,CAACG,QAAQ,CAACL,MAAM,EAAEM,SAAS,EAAEL,OAAO,CAAC;IAC5E,OAAOC,iBAAiB,CAACK,uBAAuB,CAACH,OAAO,CAAC;EAC3D;AACF;AAACI,OAAA,CAAAzB,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ScopeMain } from '@teambit/scope';
3
+ import { Workspace } from '@teambit/workspace';
4
+ import { ComponentCompareMain } from '@teambit/component-compare';
5
+ import { LanesMain } from '@teambit/lanes';
6
+ export declare class LaneHistoryDiffCmd implements Command {
7
+ private lanes;
8
+ private workspace;
9
+ private scope;
10
+ private componentCompare;
11
+ name: string;
12
+ description: string;
13
+ extendedDescription: string;
14
+ alias: string;
15
+ options: CommandOptions;
16
+ loader: boolean;
17
+ constructor(lanes: LanesMain, workspace: Workspace, scope: ScopeMain, componentCompare: ComponentCompareMain);
18
+ report([fromHistoryId, toHistoryId]: [string, string], { lane, pattern }: {
19
+ lane?: string;
20
+ pattern?: string;
21
+ }): Promise<string>;
22
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LaneHistoryDiffCmd = void 0;
7
+ function _legacy() {
8
+ const data = require("@teambit/legacy.constants");
9
+ _legacy = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _laneDiffGenerator() {
15
+ const data = require("./lane-diff-generator");
16
+ _laneDiffGenerator = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _bitError() {
22
+ const data = require("@teambit/bit-error");
23
+ _bitError = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ class LaneHistoryDiffCmd {
29
+ name = 'history-diff <from-history-id> <to-history-id>';
30
+ description = 'EXPERIMENTAL. show diff between two lane-history ids';
31
+ extendedDescription = 'run "bit lane history" to find these history-ids';
32
+ alias = '';
33
+ options = [['l', 'lane <lane-name>', 'the name of the lane to diff. if not specified, the current lane is used'], ['', 'pattern <component-pattern>', `show lane-diff for components conforming to the specified component-pattern only
34
+ component-pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`]];
35
+ loader = true;
36
+ constructor(lanes, workspace, scope, componentCompare) {
37
+ this.lanes = lanes;
38
+ this.workspace = workspace;
39
+ this.scope = scope;
40
+ this.componentCompare = componentCompare;
41
+ }
42
+ async report([fromHistoryId, toHistoryId], {
43
+ lane,
44
+ pattern
45
+ }) {
46
+ const laneId = lane ? await this.lanes.parseLaneId(lane) : this.lanes.getCurrentLaneId();
47
+ if (!laneId || laneId.isDefault()) throw new (_bitError().BitError)(`unable to show diff-history of the default lane (main)`);
48
+ await this.lanes.importLaneHistory(laneId);
49
+ const laneHistory = await this.lanes.getLaneHistory(laneId);
50
+ const laneDiffGenerator = new (_laneDiffGenerator().LaneDiffGenerator)(this.workspace, this.scope, this.componentCompare);
51
+ const laneObj = await this.lanes.loadLane(laneId);
52
+ const results = await laneDiffGenerator.generateDiffHistory(laneObj, laneHistory, fromHistoryId, toHistoryId, pattern);
53
+ return laneDiffGenerator.laneDiffResultsToString(results);
54
+ }
55
+ }
56
+ exports.LaneHistoryDiffCmd = LaneHistoryDiffCmd;
57
+
58
+ //# sourceMappingURL=lane-history-diff.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_legacy","data","require","_laneDiffGenerator","_bitError","LaneHistoryDiffCmd","name","description","extendedDescription","alias","options","COMPONENT_PATTERN_HELP","loader","constructor","lanes","workspace","scope","componentCompare","report","fromHistoryId","toHistoryId","lane","pattern","laneId","parseLaneId","getCurrentLaneId","isDefault","BitError","importLaneHistory","laneHistory","getLaneHistory","laneDiffGenerator","LaneDiffGenerator","laneObj","loadLane","results","generateDiffHistory","laneDiffResultsToString","exports"],"sources":["lane-history-diff.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ScopeMain } from '@teambit/scope';\nimport { Workspace } from '@teambit/workspace';\nimport { ComponentCompareMain } from '@teambit/component-compare';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport { LaneDiffGenerator } from './lane-diff-generator';\nimport { BitError } from '@teambit/bit-error';\nimport { LanesMain } from '@teambit/lanes';\n\nexport class LaneHistoryDiffCmd implements Command {\n name = 'history-diff <from-history-id> <to-history-id>';\n description = 'EXPERIMENTAL. show diff between two lane-history ids';\n extendedDescription = 'run \"bit lane history\" to find these history-ids';\n alias = '';\n options = [\n ['l', 'lane <lane-name>', 'the name of the lane to diff. if not specified, the current lane is used'],\n [\n '',\n 'pattern <component-pattern>',\n `show lane-diff for components conforming to the specified component-pattern only\ncomponent-pattern format: ${COMPONENT_PATTERN_HELP}`,\n ],\n ] as CommandOptions;\n loader = true;\n\n constructor(\n private lanes: LanesMain,\n private workspace: Workspace,\n private scope: ScopeMain,\n private componentCompare: ComponentCompareMain\n ) {}\n\n async report(\n [fromHistoryId, toHistoryId]: [string, string],\n { lane, pattern }: { lane?: string; pattern?: string }\n ): Promise<string> {\n const laneId = lane ? await this.lanes.parseLaneId(lane) : this.lanes.getCurrentLaneId();\n if (!laneId || laneId.isDefault()) throw new BitError(`unable to show diff-history of the default lane (main)`);\n await this.lanes.importLaneHistory(laneId);\n const laneHistory = await this.lanes.getLaneHistory(laneId);\n const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope, this.componentCompare);\n const laneObj = await this.lanes.loadLane(laneId);\n const results = await laneDiffGenerator.generateDiffHistory(\n laneObj!,\n laneHistory,\n fromHistoryId,\n toHistoryId,\n pattern\n );\n return laneDiffGenerator.laneDiffResultsToString(results);\n }\n}\n"],"mappings":";;;;;;AAIA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,mB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G,MAAM,IAAI,CAACf,KAAK,CAACgB,cAAc,CAACP,MAAM,CAAC;IAC3D,MAAMQ,iBAAiB,GAAG,KAAIC,sCAAiB,EAAC,IAAI,CAACjB,SAAS,EAAE,IAAI,CAACC,KAAK,EAAE,IAAI,CAACC,gBAAgB,CAAC;IAClG,MAAMgB,OAAO,GAAG,MAAM,IAAI,CAACnB,KAAK,CAACoB,QAAQ,CAACX,MAAM,CAAC;IACjD,MAAMY,OAAO,GAAG,MAAMJ,iBAAiB,CAACK,mBAAmB,CACzDH,OAAO,EACPJ,WAAW,EACXV,aAAa,EACbC,WAAW,EACXE,OACF,CAAC;IACD,OAAOS,iBAAiB,CAACM,uBAAuB,CAACF,OAAO,CAAC;EAC3D;AACF;AAACG,OAAA,CAAAjC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
package/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { LaneDiffCmd } from './lane-diff.cmd';
2
+ export { LaneHistoryDiffCmd } from './lane-history-diff.cmd';
3
+ export { LaneDiffGenerator, LaneDiffResults } from './lane-diff-generator';
@@ -0,0 +1,340 @@
1
+ import { ScopeMain } from '@teambit/scope';
2
+ import { Workspace } from '@teambit/workspace';
3
+ import { HistoryItem, Ref, Lane, LaneHistory, Version } from '@teambit/objects';
4
+ import { ComponentID, ComponentIdList } from '@teambit/component-id';
5
+ import { DiffResults, DiffOptions, outputDiffResults } from '@teambit/legacy.component-diff';
6
+ import { DEFAULT_LANE, LaneId } from '@teambit/lane-id';
7
+ import { BitError } from '@teambit/bit-error';
8
+ import { ComponentCompareMain } from '@teambit/component-compare';
9
+ import chalk from 'chalk';
10
+
11
+ type LaneData = {
12
+ name: string;
13
+ components: Array<{
14
+ id: ComponentID;
15
+ head: Ref;
16
+ }>;
17
+ remote: string | null;
18
+ };
19
+
20
+ type Failure = { id: ComponentID; msg: string };
21
+
22
+ export type LaneDiffResults = {
23
+ newCompsFrom: string[];
24
+ newCompsTo: string[];
25
+ compsWithDiff: DiffResults[];
26
+ compsWithNoChanges: string[];
27
+ toLaneName: string;
28
+ fromLaneName: string;
29
+ failures: Failure[];
30
+ };
31
+
32
+ export class LaneDiffGenerator {
33
+ private newCompsFrom: ComponentID[] = [];
34
+ private newCompsTo: ComponentID[] = [];
35
+ private compsWithDiff: DiffResults[] = [];
36
+ private compsWithNoChanges: ComponentID[] = [];
37
+ private fromLaneData: LaneData;
38
+ private toLaneData: LaneData;
39
+ private failures: Failure[] = [];
40
+ constructor(
41
+ private workspace: Workspace | undefined,
42
+ private scope: ScopeMain,
43
+ private componentCompare: ComponentCompareMain
44
+ ) {}
45
+
46
+ /**
47
+ * the values array may include zero to two values and will be processed as following:
48
+ * [] => diff between the default lane (from) and the current lane (to). (only inside workspace).
49
+ * [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
50
+ * [from, to] => diff between "from" lane and "to" lane.
51
+ */
52
+ async generate(values: string[], diffOptions: DiffOptions = {}, pattern?: string): Promise<LaneDiffResults> {
53
+ const { fromLaneName, toLaneName } = this.getLaneNames(values);
54
+
55
+ if (fromLaneName === toLaneName) {
56
+ throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
57
+ }
58
+ const legacyScope = this.scope.legacyScope;
59
+ const fromLaneId = await legacyScope.lanes.parseLaneIdFromString(fromLaneName);
60
+ const toLaneId = await legacyScope.lanes.parseLaneIdFromString(toLaneName);
61
+ let toLane: Lane | null | undefined;
62
+ let fromLane: Lane | null | undefined;
63
+
64
+ if (fromLaneId.isDefault()) {
65
+ if (toLaneId.isDefault()) throw new Error(`unable to diff between main and main, they're the same lane`);
66
+ toLane = await legacyScope.lanes.loadLane(toLaneId);
67
+ if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
68
+ this.toLaneData = await this.mapToLaneData(toLane);
69
+ const bitIds = toLane.components.map((c) => c.id);
70
+ this.fromLaneData = await this.getDefaultLaneData(bitIds);
71
+ } else if (toLaneId.isDefault()) {
72
+ fromLane = await legacyScope.lanes.loadLane(fromLaneId);
73
+ if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
74
+ this.fromLaneData = await this.mapToLaneData(fromLane);
75
+ const bitIds = fromLane?.components.map((c) => c.id) || [];
76
+ this.toLaneData = await this.getDefaultLaneData(bitIds);
77
+ } else {
78
+ // both, "from" and "to" are not default-lane.
79
+ toLane = await legacyScope.lanes.loadLane(toLaneId);
80
+ if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
81
+ fromLane = await legacyScope.lanes.loadLane(fromLaneId);
82
+ if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
83
+ this.toLaneData = await this.mapToLaneData(toLane);
84
+ this.fromLaneData = await this.mapToLaneData(fromLane);
85
+ }
86
+
87
+ let idsToCheckDiff: ComponentIdList | undefined;
88
+ if (pattern) {
89
+ const compIds = this.toLaneData.components.map((c) => c.id);
90
+ idsToCheckDiff = ComponentIdList.fromArray(await this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds));
91
+ }
92
+
93
+ if (!this.toLaneData.components.length) {
94
+ throw new BitError(`lane "${toLaneName}" is empty, nothing to show`);
95
+ }
96
+
97
+ const idsOfTo = ComponentIdList.fromArray(
98
+ this.toLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))
99
+ );
100
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfTo, {
101
+ cache: true,
102
+ lane: toLane || undefined,
103
+ ignoreMissingHead: true,
104
+ reason: `for the "to" diff - ${toLane ? toLane.name : DEFAULT_LANE}`,
105
+ });
106
+ const idsOfFrom = ComponentIdList.fromArray(
107
+ this.fromLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))
108
+ );
109
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfFrom, {
110
+ cache: true,
111
+ lane: fromLane || undefined,
112
+ ignoreMissingHead: true,
113
+ reason: `for the "from" diff - ${fromLane ? fromLane.name : DEFAULT_LANE}`,
114
+ });
115
+
116
+ await Promise.all(
117
+ this.toLaneData.components.map(async ({ id, head }) => {
118
+ if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
119
+ return;
120
+ }
121
+ await this.componentDiff(id, head, diffOptions, true);
122
+ })
123
+ );
124
+
125
+ return {
126
+ newCompsFrom: this.newCompsFrom.map((id) => id.toString()),
127
+ newCompsTo: this.newCompsTo.map((id) => id.toString()),
128
+ compsWithDiff: this.compsWithDiff,
129
+ compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
130
+ toLaneName: this.toLaneData.name,
131
+ fromLaneName: this.fromLaneData.name,
132
+ failures: this.failures,
133
+ };
134
+ }
135
+
136
+ async generateDiffHistory(
137
+ lane: Lane,
138
+ laneHistory: LaneHistory,
139
+ fromHistoryId: string,
140
+ toHistoryId: string,
141
+ pattern?: string
142
+ ): Promise<LaneDiffResults> {
143
+ const laneId = lane.toLaneId();
144
+ const history = laneHistory.getHistory();
145
+ const fromLane = history[fromHistoryId];
146
+ const toLane = history[toHistoryId];
147
+ if (!fromLane)
148
+ throw new Error(`unable to find the from-history-id "${fromHistoryId}" in lane "${laneId.toString()}"`);
149
+ if (!toLane) throw new Error(`unable to find the to-history-id "${toHistoryId}" in lane "${laneId.toString()}"`);
150
+ this.fromLaneData = this.mapHistoryToLaneData(laneId, fromHistoryId, fromLane);
151
+ this.toLaneData = this.mapHistoryToLaneData(laneId, toHistoryId, toLane);
152
+
153
+ let idsToCheckDiff: ComponentIdList | undefined;
154
+ if (pattern) {
155
+ const compIds = this.toLaneData.components.map((c) => c.id);
156
+ idsToCheckDiff = ComponentIdList.fromArray(await this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds));
157
+ }
158
+
159
+ if (!this.toLaneData.components.length) {
160
+ throw new BitError(`lane-history "${toHistoryId}" is empty, nothing to show`);
161
+ }
162
+
163
+ const idsOfTo = ComponentIdList.fromArray(
164
+ this.toLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))
165
+ );
166
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfTo, {
167
+ cache: true,
168
+ lane,
169
+ ignoreMissingHead: true,
170
+ reason: `for the "to" diff - ${laneId.toString()}-${toHistoryId}`,
171
+ });
172
+ const idsOfFrom = ComponentIdList.fromArray(
173
+ this.fromLaneData.components.map((c) => c.id.changeVersion(c.head?.toString()))
174
+ );
175
+ await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsOfFrom, {
176
+ cache: true,
177
+ lane,
178
+ ignoreMissingHead: true,
179
+ reason: `for the "from" diff - ${laneId.toString()}-${fromHistoryId}`,
180
+ });
181
+
182
+ await Promise.all(
183
+ this.toLaneData.components.map(async ({ id, head }) => {
184
+ if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
185
+ return;
186
+ }
187
+ await this.componentDiff(id, head);
188
+ })
189
+ );
190
+
191
+ return {
192
+ newCompsFrom: this.newCompsFrom.map((id) => id.toString()),
193
+ newCompsTo: this.newCompsTo.map((id) => id.toString()),
194
+ compsWithDiff: this.compsWithDiff,
195
+ compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
196
+ toLaneName: this.toLaneData.name,
197
+ fromLaneName: this.fromLaneData.name,
198
+ failures: this.failures,
199
+ };
200
+ }
201
+
202
+ laneDiffResultsToString(laneDiffResults: LaneDiffResults): string {
203
+ const { compsWithDiff, newCompsFrom, newCompsTo, toLaneName, fromLaneName, failures } = laneDiffResults;
204
+
205
+ const newCompsOutput = (laneName: string, ids: string[]) => {
206
+ if (!ids.length) return '';
207
+ const newCompsIdsStr = ids.map((id) => chalk.bold(id)).join('\n');
208
+ const newCompsTitle = `\nThe following components were introduced in ${chalk.bold(laneName)} lane`;
209
+ return `${chalk.inverse(newCompsTitle)}\n${newCompsIdsStr}`;
210
+ };
211
+
212
+ const diffResultsStr = outputDiffResults(compsWithDiff);
213
+
214
+ const failuresTitle = `\n\nDiff failed on the following component(s)`;
215
+ const failuresIds = failures.map((f) => `${f.id.toString()} - ${chalk.red(f.msg)}`).join('\n');
216
+ const failuresStr = failures.length ? `${chalk.inverse(failuresTitle)}\n${failuresIds}` : '';
217
+ const newCompsToStr = newCompsOutput(toLaneName, newCompsTo);
218
+
219
+ const newCompsFromStr = newCompsOutput(fromLaneName, newCompsFrom);
220
+ return `${diffResultsStr}${newCompsToStr}${newCompsFromStr}${failuresStr}`;
221
+ }
222
+
223
+ private async componentDiff(
224
+ id: ComponentID,
225
+ toLaneHead: Ref | null,
226
+ diffOptions: DiffOptions = {},
227
+ compareToHeadIfEmpty = false
228
+ ) {
229
+ const modelComponent = await this.scope.legacyScope.getModelComponent(id);
230
+ const foundFromLane = this.fromLaneData.components.find((c) => c.id.isEqualWithoutVersion(id))?.head;
231
+ const fromLaneHead = compareToHeadIfEmpty ? foundFromLane || modelComponent.head : foundFromLane;
232
+ if (!fromLaneHead) {
233
+ this.newCompsTo.push(id);
234
+ return;
235
+ }
236
+ if (!toLaneHead) {
237
+ this.newCompsFrom.push(id);
238
+ return;
239
+ }
240
+ if (fromLaneHead.isEqual(toLaneHead)) {
241
+ this.compsWithNoChanges.push(id);
242
+ return;
243
+ }
244
+ let fromVersion: Version;
245
+ try {
246
+ fromVersion = await modelComponent.loadVersion(fromLaneHead.toString(), this.scope.legacyScope.objects, true);
247
+ } catch (err: any) {
248
+ this.failures.push({ id, msg: err.message });
249
+ return;
250
+ }
251
+ const toVersion = await toLaneHead.load(this.scope.legacyScope.objects);
252
+ const fromLaneStr = this.fromLaneData.name;
253
+ diffOptions.formatDepsAsTable = false;
254
+ const diff = await this.componentCompare.diffBetweenVersionsObjects(
255
+ modelComponent,
256
+ fromVersion,
257
+ toVersion as Version,
258
+ fromLaneStr,
259
+ this.toLaneData.name,
260
+ diffOptions
261
+ );
262
+ this.compsWithDiff.push(diff);
263
+ }
264
+
265
+ private getLaneNames(values: string[]): { fromLaneName: string; toLaneName: string } {
266
+ if (values.length > 2) {
267
+ throw new Error(`expect "values" to include no more than two args, got ${values.length}`);
268
+ }
269
+ if (this.workspace) {
270
+ const currentLane = this.workspace.getCurrentLaneId();
271
+ if (!values.length) {
272
+ if (currentLane.isDefault()) {
273
+ throw new Error(`you are currently on the default branch, to run diff between lanes, please specify them`);
274
+ }
275
+ return { toLaneName: currentLane.name, fromLaneName: DEFAULT_LANE };
276
+ }
277
+ if (values.length === 1) {
278
+ const toLaneName = currentLane.isDefault() ? DEFAULT_LANE : currentLane.name;
279
+ return { toLaneName, fromLaneName: values[0] };
280
+ }
281
+ return { toLaneName: values[1], fromLaneName: values[0] };
282
+ }
283
+ // running from the scope
284
+ if (values.length < 1) {
285
+ throw new Error(`expect "values" to include at least one arg - the lane name`);
286
+ }
287
+ const fromLaneName = values.length === 2 ? values[0] : DEFAULT_LANE;
288
+ const toLaneName = values.length === 2 ? values[1] : values[0];
289
+ return { fromLaneName, toLaneName };
290
+ }
291
+
292
+ private async getDefaultLaneData(ids: ComponentID[]): Promise<LaneData> {
293
+ const laneData: LaneData = {
294
+ name: DEFAULT_LANE,
295
+ remote: null,
296
+ components: [],
297
+ };
298
+
299
+ await Promise.all(
300
+ ids.map(async (id) => {
301
+ const modelComponent = await this.scope.legacyScope.getModelComponent(id);
302
+ const laneComponent = {
303
+ id,
304
+ head: modelComponent.head as Ref, // @todo: this is not true. it can be undefined
305
+ version: modelComponent.latestVersion(), // should this be latestVersion() or bitId.version.toString()
306
+ };
307
+ laneData.components.push(laneComponent);
308
+ })
309
+ );
310
+
311
+ return laneData;
312
+ }
313
+
314
+ private async mapToLaneData(lane: Lane): Promise<LaneData> {
315
+ const { name, components } = lane;
316
+ return {
317
+ name,
318
+ components: components.map((lc) => ({
319
+ id: lc.id,
320
+ head: lc.head,
321
+ version: lc.id.version?.toString(),
322
+ })),
323
+ remote: lane.toLaneId().toString(),
324
+ };
325
+ }
326
+
327
+ private mapHistoryToLaneData(laneId: LaneId, historyId: string, historyItem: HistoryItem): LaneData {
328
+ return {
329
+ name: historyId,
330
+ components: historyItem.components.map((compStr) => {
331
+ const compId = ComponentID.fromString(compStr);
332
+ return {
333
+ id: compId.changeVersion(undefined),
334
+ head: Ref.from(compId.version),
335
+ };
336
+ }),
337
+ remote: laneId.toString(),
338
+ };
339
+ }
340
+ }
@@ -0,0 +1,49 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ScopeMain } from '@teambit/scope';
3
+ import { Workspace } from '@teambit/workspace';
4
+ import { ComponentCompareMain } from '@teambit/component-compare';
5
+ import { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';
6
+ import { LaneDiffGenerator } from './lane-diff-generator';
7
+
8
+ export class LaneDiffCmd implements Command {
9
+ name = 'diff [values...]';
10
+ description = `show diff between lanes`;
11
+ extendedDescription = `bit lane diff => diff between the current lane and default lane. (only inside workspace).
12
+ bit lane diff to => diff between the current lane (or default-lane when in scope) and "to" lane.
13
+ bit lane diff from to => diff between "from" lane and "to" lane.`;
14
+ alias = '';
15
+ arguments = [
16
+ {
17
+ name: 'from',
18
+ description: `base lane for comparison`,
19
+ },
20
+ {
21
+ name: 'to',
22
+ description: `lane being compared to base lane`,
23
+ },
24
+ ];
25
+ options = [
26
+ [
27
+ '',
28
+ 'pattern <component-pattern>',
29
+ `show lane-diff for components conforming to the specified component-pattern only
30
+ component-pattern format: ${COMPONENT_PATTERN_HELP}`,
31
+ ],
32
+ ] as CommandOptions;
33
+ loader = true;
34
+ private = true;
35
+ remoteOp = true;
36
+ skipWorkspace = true;
37
+
38
+ constructor(
39
+ private workspace: Workspace,
40
+ private scope: ScopeMain,
41
+ private componentCompare: ComponentCompareMain
42
+ ) {}
43
+
44
+ async report([values = []]: [string[]], { pattern }: { pattern?: string }) {
45
+ const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope, this.componentCompare);
46
+ const results = await laneDiffGenerator.generate(values, undefined, pattern);
47
+ return laneDiffGenerator.laneDiffResultsToString(results);
48
+ }
49
+ }
@@ -0,0 +1,52 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ScopeMain } from '@teambit/scope';
3
+ import { Workspace } from '@teambit/workspace';
4
+ import { ComponentCompareMain } from '@teambit/component-compare';
5
+ import { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';
6
+ import { LaneDiffGenerator } from './lane-diff-generator';
7
+ import { BitError } from '@teambit/bit-error';
8
+ import { LanesMain } from '@teambit/lanes';
9
+
10
+ export class LaneHistoryDiffCmd implements Command {
11
+ name = 'history-diff <from-history-id> <to-history-id>';
12
+ description = 'EXPERIMENTAL. show diff between two lane-history ids';
13
+ extendedDescription = 'run "bit lane history" to find these history-ids';
14
+ alias = '';
15
+ options = [
16
+ ['l', 'lane <lane-name>', 'the name of the lane to diff. if not specified, the current lane is used'],
17
+ [
18
+ '',
19
+ 'pattern <component-pattern>',
20
+ `show lane-diff for components conforming to the specified component-pattern only
21
+ component-pattern format: ${COMPONENT_PATTERN_HELP}`,
22
+ ],
23
+ ] as CommandOptions;
24
+ loader = true;
25
+
26
+ constructor(
27
+ private lanes: LanesMain,
28
+ private workspace: Workspace,
29
+ private scope: ScopeMain,
30
+ private componentCompare: ComponentCompareMain
31
+ ) {}
32
+
33
+ async report(
34
+ [fromHistoryId, toHistoryId]: [string, string],
35
+ { lane, pattern }: { lane?: string; pattern?: string }
36
+ ): Promise<string> {
37
+ const laneId = lane ? await this.lanes.parseLaneId(lane) : this.lanes.getCurrentLaneId();
38
+ if (!laneId || laneId.isDefault()) throw new BitError(`unable to show diff-history of the default lane (main)`);
39
+ await this.lanes.importLaneHistory(laneId);
40
+ const laneHistory = await this.lanes.getLaneHistory(laneId);
41
+ const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope, this.componentCompare);
42
+ const laneObj = await this.lanes.loadLane(laneId);
43
+ const results = await laneDiffGenerator.generateDiffHistory(
44
+ laneObj!,
45
+ laneHistory,
46
+ fromHistoryId,
47
+ toHistoryId,
48
+ pattern
49
+ );
50
+ return laneDiffGenerator.laneDiffResultsToString(results);
51
+ }
52
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@teambit/lanes.modules.diff",
3
+ "version": "0.0.0-3e2e1a2e4717ea49c193725079c1107973ecc661",
4
+ "homepage": "https://bit.cloud/teambit/lanes/modules/diff",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "teambit.lanes",
8
+ "name": "modules/diff",
9
+ "version": "3e2e1a2e4717ea49c193725079c1107973ecc661"
10
+ },
11
+ "dependencies": {
12
+ "chalk": "4.1.2",
13
+ "@teambit/bit-error": "0.0.404",
14
+ "@teambit/component-id": "1.2.4",
15
+ "@teambit/lane-id": "0.0.312",
16
+ "@teambit/legacy.component-diff": "0.0.0-8589f167b80c4a069e8aad8f25a9447cbb741f51",
17
+ "@teambit/legacy.constants": "0.0.12"
18
+ },
19
+ "devDependencies": {
20
+ "@types/mocha": "9.1.0",
21
+ "chai": "4.3.0",
22
+ "@teambit/node.envs.node-babel-mocha": "0.1.5"
23
+ },
24
+ "peerDependencies": {},
25
+ "license": "Apache-2.0",
26
+ "optionalDependencies": {},
27
+ "peerDependenciesMeta": {},
28
+ "private": false,
29
+ "engines": {
30
+ "node": ">=12.22.0"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/teambit/bit"
35
+ },
36
+ "keywords": [
37
+ "bit",
38
+ "components",
39
+ "collaboration",
40
+ "web",
41
+ "react",
42
+ "react-components",
43
+ "angular",
44
+ "angular-components"
45
+ ]
46
+ }
@@ -0,0 +1,41 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
11
+ const src: string;
12
+ export default src;
13
+ }
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }