@teambit/lanes.modules.diff 0.0.162 → 0.0.165
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/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lane-diff-generator.d.ts +17 -11
- package/dist/lane-diff-generator.js +42 -29
- package/dist/lane-diff-generator.js.map +1 -1
- package/dist/lane-diff.cmd.js +11 -5
- package/dist/lane-diff.cmd.js.map +1 -1
- package/index.ts +1 -1
- package/lane-diff-generator.ts +55 -30
- package/lane-diff.cmd.ts +13 -9
- package/package-tar/teambit-lanes.modules.diff-0.0.165.tgz +0 -0
- package/package.json +4 -3
- /package/{preview-1659065375106.js → preview-1659456045857.js} +0 -0
- package/package-tar/teambit-lanes.modules.diff-0.0.162.tgz +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { LaneDiffCmd } from './lane-diff.cmd';
|
|
2
|
-
export { LaneDiffGenerator } from './lane-diff-generator';
|
|
2
|
+
export { LaneDiffGenerator, LaneDiffResults } from './lane-diff-generator';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAArC,4GAAA,WAAW,OAAA;AACpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAArC,4GAAA,WAAW,OAAA;AACpB,6DAA2E;AAAlE,wHAAA,iBAAiB,OAAA"}
|
|
@@ -2,10 +2,24 @@ import { ScopeMain } from '@teambit/scope';
|
|
|
2
2
|
import { Workspace } from '@teambit/workspace';
|
|
3
3
|
import { BitId } from '@teambit/legacy-bit-id';
|
|
4
4
|
import { DiffResults, DiffOptions } from '@teambit/legacy/dist/consumer/component-ops/components-diff';
|
|
5
|
+
declare type Failure = {
|
|
6
|
+
id: BitId;
|
|
7
|
+
msg: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type LaneDiffResults = {
|
|
10
|
+
newCompsFrom: string[];
|
|
11
|
+
newCompsTo: string[];
|
|
12
|
+
compsWithDiff: DiffResults[];
|
|
13
|
+
compsWithNoChanges: string[];
|
|
14
|
+
toLaneName: string;
|
|
15
|
+
fromLaneName: string;
|
|
16
|
+
failures: Failure[];
|
|
17
|
+
};
|
|
5
18
|
export declare class LaneDiffGenerator {
|
|
6
19
|
private workspace;
|
|
7
20
|
private scope;
|
|
8
|
-
private
|
|
21
|
+
private newCompsFrom;
|
|
22
|
+
private newCompsTo;
|
|
9
23
|
private compsWithDiff;
|
|
10
24
|
private compsWithNoChanges;
|
|
11
25
|
private fromLaneData;
|
|
@@ -18,18 +32,10 @@ export declare class LaneDiffGenerator {
|
|
|
18
32
|
* [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
|
|
19
33
|
* [from, to] => diff between "from" lane and "to" lane.
|
|
20
34
|
*/
|
|
21
|
-
generate(values: string[], diffOptions?: DiffOptions, pattern?: string): Promise<
|
|
22
|
-
newComps: string[];
|
|
23
|
-
compsWithDiff: DiffResults[];
|
|
24
|
-
compsWithNoChanges: string[];
|
|
25
|
-
toLaneName: string;
|
|
26
|
-
failures: {
|
|
27
|
-
id: BitId;
|
|
28
|
-
msg: string;
|
|
29
|
-
}[];
|
|
30
|
-
}>;
|
|
35
|
+
generate(values: string[], diffOptions?: DiffOptions, pattern?: string): Promise<LaneDiffResults>;
|
|
31
36
|
private componentDiff;
|
|
32
37
|
private getLaneNames;
|
|
33
38
|
private getDefaultLaneData;
|
|
34
39
|
private mapToLaneData;
|
|
35
40
|
}
|
|
41
|
+
export {};
|
|
@@ -13,11 +13,13 @@ exports.LaneDiffGenerator = void 0;
|
|
|
13
13
|
const components_diff_1 = require("@teambit/legacy/dist/consumer/component-ops/components-diff");
|
|
14
14
|
const lane_id_1 = require("@teambit/lane-id");
|
|
15
15
|
const bit_id_1 = require("@teambit/legacy/dist/bit-id");
|
|
16
|
+
const bit_error_1 = require("@teambit/bit-error");
|
|
16
17
|
class LaneDiffGenerator {
|
|
17
18
|
constructor(workspace, scope) {
|
|
18
19
|
this.workspace = workspace;
|
|
19
20
|
this.scope = scope;
|
|
20
|
-
this.
|
|
21
|
+
this.newCompsFrom = [];
|
|
22
|
+
this.newCompsTo = [];
|
|
21
23
|
this.compsWithDiff = [];
|
|
22
24
|
this.compsWithNoChanges = [];
|
|
23
25
|
this.failures = [];
|
|
@@ -29,28 +31,17 @@ class LaneDiffGenerator {
|
|
|
29
31
|
* [from, to] => diff between "from" lane and "to" lane.
|
|
30
32
|
*/
|
|
31
33
|
generate(values, diffOptions = {}, pattern) {
|
|
32
|
-
var _a;
|
|
33
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
35
|
const { fromLaneName, toLaneName } = this.getLaneNames(values);
|
|
35
36
|
if (fromLaneName === toLaneName) {
|
|
36
37
|
throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
|
|
37
38
|
}
|
|
38
39
|
const legacyScope = this.scope.legacyScope;
|
|
39
|
-
const fromLaneId =
|
|
40
|
-
const toLaneId =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
else if (!isFromOrToDefault && toLaneId && fromLaneId) {
|
|
46
|
-
const toLane = yield legacyScope.lanes.loadLane(toLaneId);
|
|
47
|
-
if (!toLane)
|
|
48
|
-
throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
49
|
-
const fromLane = fromLaneId ? yield legacyScope.lanes.loadLane(fromLaneId) : null;
|
|
50
|
-
this.toLaneData = yield this.mapToLaneData(toLane);
|
|
51
|
-
this.fromLaneData = fromLane ? yield this.mapToLaneData(fromLane) : null;
|
|
52
|
-
}
|
|
53
|
-
else if ((fromLaneId === null || fromLaneId === void 0 ? void 0 : fromLaneId.isDefault()) && toLaneId) {
|
|
40
|
+
const fromLaneId = yield legacyScope.lanes.parseLaneIdFromString(fromLaneName);
|
|
41
|
+
const toLaneId = yield legacyScope.lanes.parseLaneIdFromString(toLaneName);
|
|
42
|
+
if (fromLaneId.isDefault()) {
|
|
43
|
+
if (toLaneId.isDefault())
|
|
44
|
+
throw new Error(`unable to diff between main and main, they're the same lane`);
|
|
54
45
|
const toLane = yield legacyScope.lanes.loadLane(toLaneId);
|
|
55
46
|
if (!toLane)
|
|
56
47
|
throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
@@ -58,18 +49,34 @@ class LaneDiffGenerator {
|
|
|
58
49
|
const bitIds = toLane.components.map((c) => c.id);
|
|
59
50
|
this.fromLaneData = yield this.getDefaultLaneData(bitIds);
|
|
60
51
|
}
|
|
61
|
-
else {
|
|
62
|
-
const fromLane =
|
|
63
|
-
|
|
52
|
+
else if (toLaneId.isDefault()) {
|
|
53
|
+
const fromLane = yield legacyScope.lanes.loadLane(fromLaneId);
|
|
54
|
+
if (!fromLane)
|
|
55
|
+
throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
|
|
56
|
+
this.fromLaneData = yield this.mapToLaneData(fromLane);
|
|
64
57
|
const bitIds = (fromLane === null || fromLane === void 0 ? void 0 : fromLane.components.map((c) => c.id)) || [];
|
|
65
58
|
this.toLaneData = yield this.getDefaultLaneData(bitIds);
|
|
66
59
|
}
|
|
60
|
+
else {
|
|
61
|
+
// both, "from" and "to" are not default-lane.
|
|
62
|
+
const toLane = yield legacyScope.lanes.loadLane(toLaneId);
|
|
63
|
+
if (!toLane)
|
|
64
|
+
throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
65
|
+
const fromLane = yield legacyScope.lanes.loadLane(fromLaneId);
|
|
66
|
+
if (!fromLane)
|
|
67
|
+
throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
|
|
68
|
+
this.toLaneData = yield this.mapToLaneData(toLane);
|
|
69
|
+
this.fromLaneData = yield this.mapToLaneData(fromLane);
|
|
70
|
+
}
|
|
67
71
|
let idsToCheckDiff;
|
|
68
72
|
if (pattern) {
|
|
69
73
|
const allIds = this.toLaneData.components.map((c) => c.id);
|
|
70
74
|
const compIds = yield (this.workspace || this.scope).resolveMultipleComponentIds(allIds);
|
|
71
75
|
idsToCheckDiff = bit_id_1.BitIds.fromArray(this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds).map((c) => c._legacy));
|
|
72
76
|
}
|
|
77
|
+
if (!this.toLaneData.components.length) {
|
|
78
|
+
throw new bit_error_1.BitError(`lane "${toLaneName}" is empty, nothing to show`);
|
|
79
|
+
}
|
|
73
80
|
yield Promise.all(this.toLaneData.components.map(({ id, head }) => __awaiter(this, void 0, void 0, function* () {
|
|
74
81
|
if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
|
|
75
82
|
return;
|
|
@@ -77,21 +84,27 @@ class LaneDiffGenerator {
|
|
|
77
84
|
yield this.componentDiff(id, head, diffOptions);
|
|
78
85
|
})));
|
|
79
86
|
return {
|
|
80
|
-
|
|
87
|
+
newCompsFrom: this.newCompsFrom.map((id) => id.toString()),
|
|
88
|
+
newCompsTo: this.newCompsTo.map((id) => id.toString()),
|
|
81
89
|
compsWithDiff: this.compsWithDiff,
|
|
82
90
|
compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
|
|
83
|
-
toLaneName:
|
|
91
|
+
toLaneName: this.toLaneData.name,
|
|
92
|
+
fromLaneName: this.fromLaneData.name,
|
|
84
93
|
failures: this.failures,
|
|
85
94
|
};
|
|
86
95
|
});
|
|
87
96
|
}
|
|
88
97
|
componentDiff(id, toLaneHead, diffOptions) {
|
|
89
|
-
var _a
|
|
98
|
+
var _a;
|
|
90
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
100
|
const modelComponent = yield this.scope.legacyScope.getModelComponent(id);
|
|
92
|
-
const fromLaneHead = ((
|
|
101
|
+
const fromLaneHead = ((_a = this.fromLaneData.components.find((c) => c.id.isEqualWithoutVersion(id))) === null || _a === void 0 ? void 0 : _a.head) || modelComponent.head;
|
|
93
102
|
if (!fromLaneHead) {
|
|
94
|
-
this.
|
|
103
|
+
this.newCompsTo.push(id);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!toLaneHead) {
|
|
107
|
+
this.newCompsFrom.push(id);
|
|
95
108
|
return;
|
|
96
109
|
}
|
|
97
110
|
if (fromLaneHead.isEqual(toLaneHead)) {
|
|
@@ -107,7 +120,7 @@ class LaneDiffGenerator {
|
|
|
107
120
|
return;
|
|
108
121
|
}
|
|
109
122
|
const toVersion = yield toLaneHead.load(this.scope.legacyScope.objects);
|
|
110
|
-
const fromLaneStr = this.fromLaneData
|
|
123
|
+
const fromLaneStr = this.fromLaneData.name;
|
|
111
124
|
diffOptions.formatDepsAsTable = false;
|
|
112
125
|
const diff = yield (0, components_diff_1.diffBetweenVersionsObjects)(modelComponent, fromVersion, toVersion, fromLaneStr, this.toLaneData.name, this.scope.legacyScope, diffOptions);
|
|
113
126
|
this.compsWithDiff.push(diff);
|
|
@@ -126,10 +139,10 @@ class LaneDiffGenerator {
|
|
|
126
139
|
return { toLaneName: currentLane.name, fromLaneName: lane_id_1.DEFAULT_LANE };
|
|
127
140
|
}
|
|
128
141
|
if (values.length === 1) {
|
|
129
|
-
const
|
|
130
|
-
return {
|
|
142
|
+
const toLaneName = currentLane.isDefault() ? lane_id_1.DEFAULT_LANE : currentLane.name;
|
|
143
|
+
return { toLaneName, fromLaneName: values[0] };
|
|
131
144
|
}
|
|
132
|
-
return {
|
|
145
|
+
return { toLaneName: values[1], fromLaneName: values[0] };
|
|
133
146
|
}
|
|
134
147
|
// running from the scope
|
|
135
148
|
if (values.length < 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-diff-generator.js","sourceRoot":"","sources":["../lane-diff-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,iGAIqE;AACrE,8CAAgD;AAChD,wDAAqD;
|
|
1
|
+
{"version":3,"file":"lane-diff-generator.js","sour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AAE;oBACF,IAAI,EAAE,cAAc,CAAC,IAAW;oBAChC,OAAO,EAAE,cAAc,CAAC,aAAa,EAAE,EAAE,6DAA6D;iBACvG,CAAC;gBACF,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC1C,CAAC,CAAA,CAAC,CACH,CAAC;YAEF,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;IAEa,aAAa,CAAC,IAAU;;YACpC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YAClC,OAAO;gBACL,IAAI;gBACJ,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;;oBAAC,OAAA,CAAC;wBAClC,EAAE,EAAE,EAAE,CAAC,EAAE;wBACT,IAAI,EAAE,EAAE,CAAC,IAAI;wBACb,OAAO,EAAE,MAAA,EAAE,CAAC,EAAE,CAAC,OAAO,0CAAE,QAAQ,EAAE;qBACnC,CAAC,CAAA;iBAAA,CAAC;gBACH,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;aACnC,CAAC;QACJ,CAAC;KAAA;CACF;AApLD,8CAoLC"}
|
package/dist/lane-diff.cmd.js
CHANGED
|
@@ -38,15 +38,21 @@ bit lane diff from to => diff between "from" lane and "to" lane.`;
|
|
|
38
38
|
report([values = []], { pattern }) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const laneDiffGenerator = new lane_diff_generator_1.LaneDiffGenerator(this.workspace, this.scope);
|
|
41
|
-
const { compsWithDiff,
|
|
41
|
+
const { compsWithDiff, newCompsFrom, newCompsTo, toLaneName, fromLaneName, failures } = yield laneDiffGenerator.generate(values, undefined, pattern);
|
|
42
|
+
const newCompsOutput = (laneName, ids) => {
|
|
43
|
+
if (!ids.length)
|
|
44
|
+
return '';
|
|
45
|
+
const newCompsIdsStr = ids.map((id) => chalk_1.default.bold(id)).join('\n');
|
|
46
|
+
const newCompsTitle = `\nThe following components were introduced in ${chalk_1.default.bold(laneName)} lane`;
|
|
47
|
+
return newCompsFrom.length ? `${chalk_1.default.inverse(newCompsTitle)}\n${newCompsIdsStr}` : '';
|
|
48
|
+
};
|
|
42
49
|
const diffResultsStr = (0, components_diff_1.outputDiffResults)(compsWithDiff);
|
|
43
|
-
const newCompsIdsStr = newComps.map((id) => chalk_1.default.bold(id)).join('\n');
|
|
44
|
-
const newCompsTitle = `The following components were introduced in ${chalk_1.default.bold(toLaneName)} lane`;
|
|
45
|
-
const newCompsStr = newComps.length ? `${chalk_1.default.inverse(newCompsTitle)}\n${newCompsIdsStr}` : '';
|
|
46
50
|
const failuresTitle = `\n\nDiff failed on the following component(s)`;
|
|
47
51
|
const failuresIds = failures.map((f) => `${f.id.toString()} - ${chalk_1.default.red(f.msg)}`);
|
|
48
52
|
const failuresStr = failures.length ? `${chalk_1.default.inverse(failuresTitle)}\n${failuresIds}` : '';
|
|
49
|
-
|
|
53
|
+
const newCompsToStr = newCompsOutput(toLaneName, newCompsTo);
|
|
54
|
+
const newCompsFromStr = newCompsOutput(fromLaneName, newCompsFrom);
|
|
55
|
+
return `${diffResultsStr}${newCompsToStr}${newCompsFromStr}${failuresStr}`;
|
|
50
56
|
});
|
|
51
57
|
}
|
|
52
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-diff.cmd.js","sourceRoot":"","sources":["../lane-diff.cmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,kDAA0B;AAC1B,iGAAgG;AAChG,+DAA0D;AAE1D,MAAa,WAAW;IAgBtB,YAAoB,SAAoB,EAAU,KAAgB;QAA9C,cAAS,GAAT,SAAS,CAAW;QAAU,UAAK,GAAL,KAAK,CAAW;QAflE,SAAI,GAAG,kBAAkB,CAAC;QAC1B,gBAAW,GAAG,yBAAyB,CAAC;QACxC,wBAAmB,GAAG;;iEAEyC,CAAC;QAChE,UAAK,GAAG,EAAE,CAAC;QACX,YA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AAU,CAAC,CAAC;YAC7D,MAAM,eAAe,GAAG,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YACnE,OAAO,GAAG,cAAc,GAAG,aAAa,GAAG,eAAe,GAAG,WAAW,EAAE,CAAC;QAC7E,CAAC;KAAA;CACF;AAvCD,kCAuCC"}
|
package/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { LaneDiffCmd } from './lane-diff.cmd';
|
|
2
|
-
export { LaneDiffGenerator } from './lane-diff-generator';
|
|
2
|
+
export { LaneDiffGenerator, LaneDiffResults } from './lane-diff-generator';
|
package/lane-diff-generator.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@teambit/legacy/dist/consumer/component-ops/components-diff';
|
|
11
11
|
import { DEFAULT_LANE } from '@teambit/lane-id';
|
|
12
12
|
import { BitIds } from '@teambit/legacy/dist/bit-id';
|
|
13
|
+
import { BitError } from '@teambit/bit-error';
|
|
13
14
|
|
|
14
15
|
type LaneData = {
|
|
15
16
|
name: string;
|
|
@@ -19,13 +20,27 @@ type LaneData = {
|
|
|
19
20
|
}>;
|
|
20
21
|
remote: string | null;
|
|
21
22
|
};
|
|
23
|
+
|
|
24
|
+
type Failure = { id: BitId; msg: string };
|
|
25
|
+
|
|
26
|
+
export type LaneDiffResults = {
|
|
27
|
+
newCompsFrom: string[];
|
|
28
|
+
newCompsTo: string[];
|
|
29
|
+
compsWithDiff: DiffResults[];
|
|
30
|
+
compsWithNoChanges: string[];
|
|
31
|
+
toLaneName: string;
|
|
32
|
+
fromLaneName: string;
|
|
33
|
+
failures: Failure[];
|
|
34
|
+
};
|
|
35
|
+
|
|
22
36
|
export class LaneDiffGenerator {
|
|
23
|
-
private
|
|
37
|
+
private newCompsFrom: BitId[] = [];
|
|
38
|
+
private newCompsTo: BitId[] = [];
|
|
24
39
|
private compsWithDiff: DiffResults[] = [];
|
|
25
40
|
private compsWithNoChanges: BitId[] = [];
|
|
26
|
-
private fromLaneData: LaneData
|
|
41
|
+
private fromLaneData: LaneData;
|
|
27
42
|
private toLaneData: LaneData;
|
|
28
|
-
private failures:
|
|
43
|
+
private failures: Failure[] = [];
|
|
29
44
|
constructor(private workspace: Workspace | undefined, private scope: ScopeMain) {}
|
|
30
45
|
|
|
31
46
|
/**
|
|
@@ -34,36 +49,36 @@ export class LaneDiffGenerator {
|
|
|
34
49
|
* [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
|
|
35
50
|
* [from, to] => diff between "from" lane and "to" lane.
|
|
36
51
|
*/
|
|
37
|
-
async generate(values: string[], diffOptions: DiffOptions = {}, pattern?: string) {
|
|
52
|
+
async generate(values: string[], diffOptions: DiffOptions = {}, pattern?: string): Promise<LaneDiffResults> {
|
|
38
53
|
const { fromLaneName, toLaneName } = this.getLaneNames(values);
|
|
39
54
|
if (fromLaneName === toLaneName) {
|
|
40
55
|
throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
|
|
41
56
|
}
|
|
42
57
|
const legacyScope = this.scope.legacyScope;
|
|
43
|
-
const fromLaneId =
|
|
44
|
-
const toLaneId =
|
|
45
|
-
const isFromOrToDefault = fromLaneId?.isDefault() || toLaneId?.isDefault();
|
|
58
|
+
const fromLaneId = await legacyScope.lanes.parseLaneIdFromString(fromLaneName);
|
|
59
|
+
const toLaneId = await legacyScope.lanes.parseLaneIdFromString(toLaneName);
|
|
46
60
|
|
|
47
|
-
if (
|
|
48
|
-
throw new Error(`unable to
|
|
49
|
-
} else if (!isFromOrToDefault && toLaneId && fromLaneId) {
|
|
61
|
+
if (fromLaneId.isDefault()) {
|
|
62
|
+
if (toLaneId.isDefault()) throw new Error(`unable to diff between main and main, they're the same lane`);
|
|
50
63
|
const toLane = await legacyScope.lanes.loadLane(toLaneId);
|
|
51
64
|
if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
52
|
-
const fromLane = fromLaneId ? await legacyScope.lanes.loadLane(fromLaneId) : null;
|
|
53
|
-
this.toLaneData = await this.mapToLaneData(toLane);
|
|
54
|
-
this.fromLaneData = fromLane ? await this.mapToLaneData(fromLane) : null;
|
|
55
|
-
} else if (fromLaneId?.isDefault() && toLaneId) {
|
|
56
|
-
const toLane = await legacyScope.lanes.loadLane(toLaneId);
|
|
57
|
-
if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
58
|
-
|
|
59
65
|
this.toLaneData = await this.mapToLaneData(toLane);
|
|
60
66
|
const bitIds = toLane.components.map((c) => c.id);
|
|
61
67
|
this.fromLaneData = await this.getDefaultLaneData(bitIds);
|
|
62
|
-
} else {
|
|
63
|
-
const fromLane =
|
|
64
|
-
|
|
68
|
+
} else if (toLaneId.isDefault()) {
|
|
69
|
+
const fromLane = await legacyScope.lanes.loadLane(fromLaneId);
|
|
70
|
+
if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
|
|
71
|
+
this.fromLaneData = await this.mapToLaneData(fromLane);
|
|
65
72
|
const bitIds = fromLane?.components.map((c) => c.id) || [];
|
|
66
73
|
this.toLaneData = await this.getDefaultLaneData(bitIds);
|
|
74
|
+
} else {
|
|
75
|
+
// both, "from" and "to" are not default-lane.
|
|
76
|
+
const toLane = await legacyScope.lanes.loadLane(toLaneId);
|
|
77
|
+
if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
78
|
+
const fromLane = await legacyScope.lanes.loadLane(fromLaneId);
|
|
79
|
+
if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
|
|
80
|
+
this.toLaneData = await this.mapToLaneData(toLane);
|
|
81
|
+
this.fromLaneData = await this.mapToLaneData(fromLane);
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
let idsToCheckDiff: BitIds | undefined;
|
|
@@ -75,6 +90,10 @@ export class LaneDiffGenerator {
|
|
|
75
90
|
);
|
|
76
91
|
}
|
|
77
92
|
|
|
93
|
+
if (!this.toLaneData.components.length) {
|
|
94
|
+
throw new BitError(`lane "${toLaneName}" is empty, nothing to show`);
|
|
95
|
+
}
|
|
96
|
+
|
|
78
97
|
await Promise.all(
|
|
79
98
|
this.toLaneData.components.map(async ({ id, head }) => {
|
|
80
99
|
if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
|
|
@@ -85,20 +104,26 @@ export class LaneDiffGenerator {
|
|
|
85
104
|
);
|
|
86
105
|
|
|
87
106
|
return {
|
|
88
|
-
|
|
107
|
+
newCompsFrom: this.newCompsFrom.map((id) => id.toString()),
|
|
108
|
+
newCompsTo: this.newCompsTo.map((id) => id.toString()),
|
|
89
109
|
compsWithDiff: this.compsWithDiff,
|
|
90
110
|
compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
|
|
91
|
-
toLaneName: this.toLaneData
|
|
111
|
+
toLaneName: this.toLaneData.name,
|
|
112
|
+
fromLaneName: this.fromLaneData.name,
|
|
92
113
|
failures: this.failures,
|
|
93
114
|
};
|
|
94
115
|
}
|
|
95
116
|
|
|
96
|
-
private async componentDiff(id: BitId, toLaneHead: Ref, diffOptions: DiffOptions) {
|
|
117
|
+
private async componentDiff(id: BitId, toLaneHead: Ref | null, diffOptions: DiffOptions) {
|
|
97
118
|
const modelComponent = await this.scope.legacyScope.getModelComponent(id);
|
|
98
119
|
const fromLaneHead =
|
|
99
|
-
this.fromLaneData
|
|
120
|
+
this.fromLaneData.components.find((c) => c.id.isEqualWithoutVersion(id))?.head || modelComponent.head;
|
|
100
121
|
if (!fromLaneHead) {
|
|
101
|
-
this.
|
|
122
|
+
this.newCompsTo.push(id);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (!toLaneHead) {
|
|
126
|
+
this.newCompsFrom.push(id);
|
|
102
127
|
return;
|
|
103
128
|
}
|
|
104
129
|
if (fromLaneHead.isEqual(toLaneHead)) {
|
|
@@ -113,7 +138,7 @@ export class LaneDiffGenerator {
|
|
|
113
138
|
return;
|
|
114
139
|
}
|
|
115
140
|
const toVersion = await toLaneHead.load(this.scope.legacyScope.objects);
|
|
116
|
-
const fromLaneStr = this.fromLaneData
|
|
141
|
+
const fromLaneStr = this.fromLaneData.name;
|
|
117
142
|
diffOptions.formatDepsAsTable = false;
|
|
118
143
|
const diff = await diffBetweenVersionsObjects(
|
|
119
144
|
modelComponent,
|
|
@@ -127,7 +152,7 @@ export class LaneDiffGenerator {
|
|
|
127
152
|
this.compsWithDiff.push(diff);
|
|
128
153
|
}
|
|
129
154
|
|
|
130
|
-
private getLaneNames(values: string[]): { fromLaneName
|
|
155
|
+
private getLaneNames(values: string[]): { fromLaneName: string; toLaneName: string } {
|
|
131
156
|
if (values.length > 2) {
|
|
132
157
|
throw new Error(`expect "values" to include no more than two args, got ${values.length}`);
|
|
133
158
|
}
|
|
@@ -140,10 +165,10 @@ export class LaneDiffGenerator {
|
|
|
140
165
|
return { toLaneName: currentLane.name, fromLaneName: DEFAULT_LANE };
|
|
141
166
|
}
|
|
142
167
|
if (values.length === 1) {
|
|
143
|
-
const
|
|
144
|
-
return {
|
|
168
|
+
const toLaneName = currentLane.isDefault() ? DEFAULT_LANE : currentLane.name;
|
|
169
|
+
return { toLaneName, fromLaneName: values[0] };
|
|
145
170
|
}
|
|
146
|
-
return {
|
|
171
|
+
return { toLaneName: values[1], fromLaneName: values[0] };
|
|
147
172
|
}
|
|
148
173
|
// running from the scope
|
|
149
174
|
if (values.length < 1) {
|
package/lane-diff.cmd.ts
CHANGED
|
@@ -25,19 +25,23 @@ bit lane diff from to => diff between "from" lane and "to" lane.`;
|
|
|
25
25
|
|
|
26
26
|
async report([values = []]: [string[]], { pattern }: { pattern?: string }) {
|
|
27
27
|
const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope);
|
|
28
|
-
const { compsWithDiff,
|
|
29
|
-
values,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const { compsWithDiff, newCompsFrom, newCompsTo, toLaneName, fromLaneName, failures } =
|
|
29
|
+
await laneDiffGenerator.generate(values, undefined, pattern);
|
|
30
|
+
|
|
31
|
+
const newCompsOutput = (laneName: string, ids: string[]) => {
|
|
32
|
+
if (!ids.length) return '';
|
|
33
|
+
const newCompsIdsStr = ids.map((id) => chalk.bold(id)).join('\n');
|
|
34
|
+
const newCompsTitle = `\nThe following components were introduced in ${chalk.bold(laneName)} lane`;
|
|
35
|
+
return newCompsFrom.length ? `${chalk.inverse(newCompsTitle)}\n${newCompsIdsStr}` : '';
|
|
36
|
+
};
|
|
33
37
|
|
|
34
38
|
const diffResultsStr = outputDiffResults(compsWithDiff);
|
|
35
|
-
|
|
36
|
-
const newCompsTitle = `The following components were introduced in ${chalk.bold(toLaneName)} lane`;
|
|
37
|
-
const newCompsStr = newComps.length ? `${chalk.inverse(newCompsTitle)}\n${newCompsIdsStr}` : '';
|
|
39
|
+
|
|
38
40
|
const failuresTitle = `\n\nDiff failed on the following component(s)`;
|
|
39
41
|
const failuresIds = failures.map((f) => `${f.id.toString()} - ${chalk.red(f.msg)}`);
|
|
40
42
|
const failuresStr = failures.length ? `${chalk.inverse(failuresTitle)}\n${failuresIds}` : '';
|
|
41
|
-
|
|
43
|
+
const newCompsToStr = newCompsOutput(toLaneName, newCompsTo);
|
|
44
|
+
const newCompsFromStr = newCompsOutput(fromLaneName, newCompsFrom);
|
|
45
|
+
return `${diffResultsStr}${newCompsToStr}${newCompsFromStr}${failuresStr}`;
|
|
42
46
|
}
|
|
43
47
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/lanes.modules.diff",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.165",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/lanes/modules/diff",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.lanes",
|
|
8
8
|
"name": "modules/diff",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.165"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
13
|
-
"@teambit/
|
|
13
|
+
"@teambit/bit-error": "0.0.394",
|
|
14
|
+
"@teambit/lane-id": "0.0.55",
|
|
14
15
|
"@teambit/legacy-bit-id": "0.0.402"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
File without changes
|
|
Binary file
|