@teambit/lanes.modules.diff 0.0.162 → 0.0.163
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/lane-diff-generator.js +28 -21
- package/dist/lane-diff-generator.js.map +1 -1
- package/lane-diff-generator.ts +25 -20
- package/package-tar/teambit-lanes.modules.diff-0.0.163.tgz +0 -0
- package/package.json +4 -3
- /package/{preview-1659065375106.js → preview-1659151732866.js} +0 -0
- package/package-tar/teambit-lanes.modules.diff-0.0.162.tgz +0 -0
|
@@ -13,6 +13,7 @@ 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;
|
|
@@ -36,21 +37,11 @@ class LaneDiffGenerator {
|
|
|
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;
|
|
@@ -126,10 +133,10 @@ class LaneDiffGenerator {
|
|
|
126
133
|
return { toLaneName: currentLane.name, fromLaneName: lane_id_1.DEFAULT_LANE };
|
|
127
134
|
}
|
|
128
135
|
if (values.length === 1) {
|
|
129
|
-
const
|
|
130
|
-
return {
|
|
136
|
+
const toLaneName = currentLane.isDefault() ? lane_id_1.DEFAULT_LANE : currentLane.name;
|
|
137
|
+
return { toLaneName, fromLaneName: values[0] };
|
|
131
138
|
}
|
|
132
|
-
return {
|
|
139
|
+
return { toLaneName: values[1], fromLaneName: values[0] };
|
|
133
140
|
}
|
|
134
141
|
// running from the scope
|
|
135
142
|
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","sourceRoot":"","sources":["../lane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a,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;AA7KD,8CA6KC"}
|
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;
|
|
@@ -40,30 +41,30 @@ export class LaneDiffGenerator {
|
|
|
40
41
|
throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
|
|
41
42
|
}
|
|
42
43
|
const legacyScope = this.scope.legacyScope;
|
|
43
|
-
const fromLaneId =
|
|
44
|
-
const toLaneId =
|
|
45
|
-
const isFromOrToDefault = fromLaneId?.isDefault() || toLaneId?.isDefault();
|
|
44
|
+
const fromLaneId = await legacyScope.lanes.parseLaneIdFromString(fromLaneName);
|
|
45
|
+
const toLaneId = await legacyScope.lanes.parseLaneIdFromString(toLaneName);
|
|
46
46
|
|
|
47
|
-
if (
|
|
48
|
-
throw new Error(`unable to
|
|
49
|
-
} else if (!isFromOrToDefault && toLaneId && fromLaneId) {
|
|
47
|
+
if (fromLaneId.isDefault()) {
|
|
48
|
+
if (toLaneId.isDefault()) throw new Error(`unable to diff between main and main, they're the same lane`);
|
|
50
49
|
const toLane = await legacyScope.lanes.loadLane(toLaneId);
|
|
51
50
|
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
51
|
this.toLaneData = await this.mapToLaneData(toLane);
|
|
60
52
|
const bitIds = toLane.components.map((c) => c.id);
|
|
61
53
|
this.fromLaneData = await this.getDefaultLaneData(bitIds);
|
|
62
|
-
} else {
|
|
63
|
-
const fromLane =
|
|
64
|
-
|
|
54
|
+
} else if (toLaneId.isDefault()) {
|
|
55
|
+
const fromLane = await legacyScope.lanes.loadLane(fromLaneId);
|
|
56
|
+
if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
|
|
57
|
+
this.fromLaneData = await this.mapToLaneData(fromLane);
|
|
65
58
|
const bitIds = fromLane?.components.map((c) => c.id) || [];
|
|
66
59
|
this.toLaneData = await this.getDefaultLaneData(bitIds);
|
|
60
|
+
} else {
|
|
61
|
+
// both, "from" and "to" are not default-lane.
|
|
62
|
+
const toLane = await legacyScope.lanes.loadLane(toLaneId);
|
|
63
|
+
if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
64
|
+
const fromLane = await legacyScope.lanes.loadLane(fromLaneId);
|
|
65
|
+
if (!fromLane) throw new Error(`unable to find a lane "${fromLaneName}" in the scope`);
|
|
66
|
+
this.toLaneData = await this.mapToLaneData(toLane);
|
|
67
|
+
this.fromLaneData = await this.mapToLaneData(fromLane);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
let idsToCheckDiff: BitIds | undefined;
|
|
@@ -75,6 +76,10 @@ export class LaneDiffGenerator {
|
|
|
75
76
|
);
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
if (!this.toLaneData.components.length) {
|
|
80
|
+
throw new BitError(`lane "${toLaneName}" is empty, nothing to show`);
|
|
81
|
+
}
|
|
82
|
+
|
|
78
83
|
await Promise.all(
|
|
79
84
|
this.toLaneData.components.map(async ({ id, head }) => {
|
|
80
85
|
if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
|
|
@@ -127,7 +132,7 @@ export class LaneDiffGenerator {
|
|
|
127
132
|
this.compsWithDiff.push(diff);
|
|
128
133
|
}
|
|
129
134
|
|
|
130
|
-
private getLaneNames(values: string[]): { fromLaneName
|
|
135
|
+
private getLaneNames(values: string[]): { fromLaneName: string; toLaneName: string } {
|
|
131
136
|
if (values.length > 2) {
|
|
132
137
|
throw new Error(`expect "values" to include no more than two args, got ${values.length}`);
|
|
133
138
|
}
|
|
@@ -140,10 +145,10 @@ export class LaneDiffGenerator {
|
|
|
140
145
|
return { toLaneName: currentLane.name, fromLaneName: DEFAULT_LANE };
|
|
141
146
|
}
|
|
142
147
|
if (values.length === 1) {
|
|
143
|
-
const
|
|
144
|
-
return {
|
|
148
|
+
const toLaneName = currentLane.isDefault() ? DEFAULT_LANE : currentLane.name;
|
|
149
|
+
return { toLaneName, fromLaneName: values[0] };
|
|
145
150
|
}
|
|
146
|
-
return {
|
|
151
|
+
return { toLaneName: values[1], fromLaneName: values[0] };
|
|
147
152
|
}
|
|
148
153
|
// running from the scope
|
|
149
154
|
if (values.length < 1) {
|
|
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.163",
|
|
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.163"
|
|
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.53",
|
|
14
15
|
"@teambit/legacy-bit-id": "0.0.402"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
File without changes
|
|
Binary file
|