@teambit/lanes.modules.diff 0.0.100 → 0.0.105
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/__preview-1644377006839.js +1 -0
- package/dist/lane-diff-generator.d.ts +4 -2
- package/dist/lane-diff-generator.js +76 -14
- package/dist/lane-diff-generator.js.map +1 -1
- package/lane-diff-generator.ts +82 -15
- package/package-tar/teambit-lanes.modules.diff-0.0.105.tgz +0 -0
- package/package.json +4 -9
- package/package-tar/teambit-lanes.modules.diff-0.0.100.tgz +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -7,8 +7,8 @@ export declare class LaneDiffGenerator {
|
|
|
7
7
|
private newComps;
|
|
8
8
|
private compsWithDiff;
|
|
9
9
|
private compsWithNoChanges;
|
|
10
|
-
private
|
|
11
|
-
private
|
|
10
|
+
private fromLaneData;
|
|
11
|
+
private toLaneData;
|
|
12
12
|
constructor(workspace: Workspace | undefined, scope: ScopeMain);
|
|
13
13
|
/**
|
|
14
14
|
* the values array may include zero to two values and will be processed as following:
|
|
@@ -24,4 +24,6 @@ export declare class LaneDiffGenerator {
|
|
|
24
24
|
}>;
|
|
25
25
|
private componentDiff;
|
|
26
26
|
private getLaneNames;
|
|
27
|
+
private getDefaultLaneData;
|
|
28
|
+
private mapToLaneData;
|
|
27
29
|
}
|
|
@@ -31,35 +31,57 @@ class LaneDiffGenerator {
|
|
|
31
31
|
* [from, to] => diff between "from" lane and "to" lane.
|
|
32
32
|
*/
|
|
33
33
|
generate(values, diffOptions = {}) {
|
|
34
|
+
var _a;
|
|
34
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
36
|
const { fromLaneName, toLaneName } = this.getLaneNames(values);
|
|
36
37
|
if (fromLaneName === toLaneName) {
|
|
37
38
|
throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
|
|
38
39
|
}
|
|
39
40
|
const legacyScope = this.scope.legacyScope;
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
41
|
+
const fromLaneId = fromLaneName ? new lane_id_1.default({ name: fromLaneName }) : null;
|
|
42
|
+
const toLaneId = toLaneName ? new lane_id_1.default({ name: toLaneName }) : null;
|
|
43
|
+
const isFromOrToDefault = (fromLaneId === null || fromLaneId === void 0 ? void 0 : fromLaneId.isDefault()) || (toLaneId === null || toLaneId === void 0 ? void 0 : toLaneId.isDefault());
|
|
44
|
+
if (!isFromOrToDefault && !toLaneId) {
|
|
43
45
|
throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
else if (!isFromOrToDefault && toLaneId && fromLaneId) {
|
|
48
|
+
const toLane = yield legacyScope.lanes.loadLane(toLaneId);
|
|
49
|
+
if (!toLane)
|
|
50
|
+
throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
51
|
+
const fromLane = fromLaneId ? yield legacyScope.lanes.loadLane(fromLaneId) : null;
|
|
52
|
+
this.toLaneData = yield this.mapToLaneData(toLane);
|
|
53
|
+
this.fromLaneData = fromLane ? yield this.mapToLaneData(fromLane) : null;
|
|
54
|
+
}
|
|
55
|
+
else if ((fromLaneId === null || fromLaneId === void 0 ? void 0 : fromLaneId.isDefault()) && toLaneId) {
|
|
56
|
+
const toLane = yield legacyScope.lanes.loadLane(toLaneId);
|
|
57
|
+
if (!toLane)
|
|
58
|
+
throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
59
|
+
this.toLaneData = yield this.mapToLaneData(toLane);
|
|
60
|
+
const bitIds = toLane.components.map((c) => c.id);
|
|
61
|
+
this.fromLaneData = yield this.getDefaultLaneData(bitIds);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const fromLane = fromLaneId ? yield legacyScope.lanes.loadLane(fromLaneId) : null;
|
|
65
|
+
this.fromLaneData = fromLane ? yield this.mapToLaneData(fromLane) : null;
|
|
66
|
+
const bitIds = (fromLane === null || fromLane === void 0 ? void 0 : fromLane.components.map((c) => c.id)) || [];
|
|
67
|
+
this.toLaneData = yield this.getDefaultLaneData(bitIds);
|
|
68
|
+
}
|
|
69
|
+
yield Promise.all(this.toLaneData.components.map(({ id, head }) => __awaiter(this, void 0, void 0, function* () {
|
|
47
70
|
yield this.componentDiff(id, head, diffOptions);
|
|
48
71
|
})));
|
|
49
72
|
return {
|
|
50
73
|
newComps: this.newComps.map((id) => id.toString()),
|
|
51
74
|
compsWithDiff: this.compsWithDiff,
|
|
52
75
|
compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
|
|
53
|
-
toLaneName:
|
|
76
|
+
toLaneName: (_a = this.toLaneData) === null || _a === void 0 ? void 0 : _a.name,
|
|
54
77
|
};
|
|
55
78
|
});
|
|
56
79
|
}
|
|
57
80
|
componentDiff(id, toLaneHead, diffOptions) {
|
|
58
|
-
var _a;
|
|
81
|
+
var _a, _b;
|
|
59
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
83
|
const modelComponent = yield this.scope.legacyScope.getModelComponent(id);
|
|
61
|
-
const
|
|
62
|
-
const fromLaneHead = compFromLane ? compFromLane.head : modelComponent.head;
|
|
84
|
+
const fromLaneHead = ((_b = (_a = this.fromLaneData) === null || _a === void 0 ? void 0 : _a.components.find((c) => c.id === id)) === null || _b === void 0 ? void 0 : _b.head) || modelComponent.head;
|
|
63
85
|
if (!fromLaneHead) {
|
|
64
86
|
this.newComps.push(id);
|
|
65
87
|
return;
|
|
@@ -70,9 +92,9 @@ class LaneDiffGenerator {
|
|
|
70
92
|
}
|
|
71
93
|
const fromVersion = yield fromLaneHead.load(this.scope.legacyScope.objects);
|
|
72
94
|
const toVersion = yield toLaneHead.load(this.scope.legacyScope.objects);
|
|
73
|
-
const fromLaneStr = this.
|
|
95
|
+
const fromLaneStr = this.fromLaneData ? this.fromLaneData.name : constants_1.DEFAULT_LANE;
|
|
74
96
|
diffOptions.formatDepsAsTable = false;
|
|
75
|
-
const diff = yield (0, components_diff_1.diffBetweenVersionsObjects)(modelComponent, fromVersion, toVersion, fromLaneStr, this.
|
|
97
|
+
const diff = yield (0, components_diff_1.diffBetweenVersionsObjects)(modelComponent, fromVersion, toVersion, fromLaneStr, this.toLaneData.name, this.scope.legacyScope, diffOptions);
|
|
76
98
|
this.compsWithDiff.push(diff);
|
|
77
99
|
});
|
|
78
100
|
}
|
|
@@ -86,10 +108,10 @@ class LaneDiffGenerator {
|
|
|
86
108
|
if (currentLane.isDefault()) {
|
|
87
109
|
throw new Error(`you are currently on the default branch, to run diff between lanes, please specify them`);
|
|
88
110
|
}
|
|
89
|
-
return { toLaneName: currentLane.name };
|
|
111
|
+
return { toLaneName: currentLane.name, fromLaneName: constants_1.DEFAULT_LANE };
|
|
90
112
|
}
|
|
91
113
|
if (values.length === 1) {
|
|
92
|
-
const fromLaneName = currentLane.isDefault() ?
|
|
114
|
+
const fromLaneName = currentLane.isDefault() ? constants_1.DEFAULT_LANE : currentLane.name;
|
|
93
115
|
return { fromLaneName, toLaneName: values[0] };
|
|
94
116
|
}
|
|
95
117
|
return { fromLaneName: values[0], toLaneName: values[1] };
|
|
@@ -98,10 +120,50 @@ class LaneDiffGenerator {
|
|
|
98
120
|
if (values.length < 1) {
|
|
99
121
|
throw new Error(`expect "values" to include at least one arg - the lane name`);
|
|
100
122
|
}
|
|
101
|
-
const fromLaneName = values.length === 2 ? values[0] :
|
|
123
|
+
const fromLaneName = values.length === 2 ? values[0] : constants_1.DEFAULT_LANE;
|
|
102
124
|
const toLaneName = values.length === 2 ? values[1] : values[0];
|
|
103
125
|
return { fromLaneName, toLaneName };
|
|
104
126
|
}
|
|
127
|
+
getDefaultLaneData(ids) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const laneData = {
|
|
130
|
+
name: constants_1.DEFAULT_LANE,
|
|
131
|
+
remote: null,
|
|
132
|
+
components: [],
|
|
133
|
+
isMerged: null,
|
|
134
|
+
};
|
|
135
|
+
yield Promise.all(ids.map((id) => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
const modelComponent = yield this.scope.legacyScope.getModelComponent(id);
|
|
137
|
+
const laneComponent = {
|
|
138
|
+
id,
|
|
139
|
+
head: modelComponent.head,
|
|
140
|
+
version: modelComponent.latestVersion(), // should this be latestVersion() or bitId.version.toString()
|
|
141
|
+
};
|
|
142
|
+
laneData.components.push(laneComponent);
|
|
143
|
+
})));
|
|
144
|
+
return laneData;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
mapToLaneData(lane) {
|
|
148
|
+
var _a;
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
const { name, components, remoteLaneId } = lane;
|
|
151
|
+
const isMerged = yield lane.isFullyMerged(this.scope.legacyScope);
|
|
152
|
+
return {
|
|
153
|
+
name,
|
|
154
|
+
isMerged,
|
|
155
|
+
components: components.map((lc) => {
|
|
156
|
+
var _a;
|
|
157
|
+
return ({
|
|
158
|
+
id: lc.id,
|
|
159
|
+
head: lc.head,
|
|
160
|
+
version: (_a = lc.id.version) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
161
|
+
});
|
|
162
|
+
}),
|
|
163
|
+
remote: (_a = remoteLaneId === null || remoteLaneId === void 0 ? void 0 : remoteLaneId.toString()) !== null && _a !== void 0 ? _a : null,
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}
|
|
105
167
|
}
|
|
106
168
|
exports.LaneDiffGenerator = LaneDiffGenerator;
|
|
107
169
|
//# sourceMappingURL=lane-diff-generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-diff-generator.js","sourceRoot":"","sources":["../lane-diff-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,8DAA8D;AAC9D,iGAIqE;AACrE,mFAA0D;
|
|
1
|
+
{"version":3,"file":"lane-diff-generator.js","sourceRoot":"","sources":["../lane-diff-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,8D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YAEF,MAAM,OAAO,CAAC,GAAG,CACf,GAAG,CAAC,GAAG,CAAC,CAAO,EAAE,EAAE,EAAE;gBACnB,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;gBAC1E,MAAM,aAAa,GAAG;oBACpB,EAAE;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,YAAY,EAAE,GAAG,IAAI,CAAC;YAChD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAClE,OAAO;gBACL,IAAI;gBACJ,QAAQ;gBACR,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,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,EAAE,mCAAI,IAAI;aACzC,CAAC;;KACH;CACF;AAvJD,8CAuJC"}
|
package/lane-diff-generator.ts
CHANGED
|
@@ -11,12 +11,21 @@ import {
|
|
|
11
11
|
} from '@teambit/legacy/dist/consumer/component-ops/components-diff';
|
|
12
12
|
import LaneId from '@teambit/legacy/dist/lane-id/lane-id';
|
|
13
13
|
|
|
14
|
+
type LaneData = {
|
|
15
|
+
name: string;
|
|
16
|
+
components: Array<{
|
|
17
|
+
id: BitId;
|
|
18
|
+
head: Ref;
|
|
19
|
+
}>;
|
|
20
|
+
remote: string | null;
|
|
21
|
+
isMerged: boolean | null;
|
|
22
|
+
};
|
|
14
23
|
export class LaneDiffGenerator {
|
|
15
24
|
private newComps: BitId[] = [];
|
|
16
25
|
private compsWithDiff: DiffResults[] = [];
|
|
17
26
|
private compsWithNoChanges: BitId[] = [];
|
|
18
|
-
private
|
|
19
|
-
private
|
|
27
|
+
private fromLaneData: LaneData | null;
|
|
28
|
+
private toLaneData: LaneData;
|
|
20
29
|
constructor(private workspace: Workspace | undefined, private scope: ScopeMain) {}
|
|
21
30
|
|
|
22
31
|
/**
|
|
@@ -31,29 +40,49 @@ export class LaneDiffGenerator {
|
|
|
31
40
|
throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
|
|
32
41
|
}
|
|
33
42
|
const legacyScope = this.scope.legacyScope;
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
43
|
+
const fromLaneId = fromLaneName ? new LaneId({ name: fromLaneName }) : null;
|
|
44
|
+
const toLaneId = toLaneName ? new LaneId({ name: toLaneName }) : null;
|
|
45
|
+
const isFromOrToDefault = fromLaneId?.isDefault() || toLaneId?.isDefault();
|
|
46
|
+
|
|
47
|
+
if (!isFromOrToDefault && !toLaneId) {
|
|
37
48
|
throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
|
|
49
|
+
} else if (!isFromOrToDefault && toLaneId && fromLaneId) {
|
|
50
|
+
const toLane = await legacyScope.lanes.loadLane(toLaneId);
|
|
51
|
+
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
|
+
this.toLaneData = await this.mapToLaneData(toLane);
|
|
60
|
+
const bitIds = toLane.components.map((c) => c.id);
|
|
61
|
+
this.fromLaneData = await this.getDefaultLaneData(bitIds);
|
|
62
|
+
} else {
|
|
63
|
+
const fromLane = fromLaneId ? await legacyScope.lanes.loadLane(fromLaneId) : null;
|
|
64
|
+
this.fromLaneData = fromLane ? await this.mapToLaneData(fromLane) : null;
|
|
65
|
+
const bitIds = fromLane?.components.map((c) => c.id) || [];
|
|
66
|
+
this.toLaneData = await this.getDefaultLaneData(bitIds);
|
|
38
67
|
}
|
|
39
|
-
|
|
68
|
+
|
|
40
69
|
await Promise.all(
|
|
41
|
-
this.
|
|
70
|
+
this.toLaneData.components.map(async ({ id, head }) => {
|
|
42
71
|
await this.componentDiff(id, head, diffOptions);
|
|
43
72
|
})
|
|
44
73
|
);
|
|
74
|
+
|
|
45
75
|
return {
|
|
46
76
|
newComps: this.newComps.map((id) => id.toString()),
|
|
47
77
|
compsWithDiff: this.compsWithDiff,
|
|
48
78
|
compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
|
|
49
|
-
toLaneName:
|
|
79
|
+
toLaneName: this.toLaneData?.name,
|
|
50
80
|
};
|
|
51
81
|
}
|
|
52
82
|
|
|
53
83
|
private async componentDiff(id: BitId, toLaneHead: Ref, diffOptions: DiffOptions) {
|
|
54
84
|
const modelComponent = await this.scope.legacyScope.getModelComponent(id);
|
|
55
|
-
const
|
|
56
|
-
const fromLaneHead = compFromLane ? compFromLane.head : modelComponent.head;
|
|
85
|
+
const fromLaneHead = this.fromLaneData?.components.find((c) => c.id === id)?.head || modelComponent.head;
|
|
57
86
|
if (!fromLaneHead) {
|
|
58
87
|
this.newComps.push(id);
|
|
59
88
|
return;
|
|
@@ -64,14 +93,14 @@ export class LaneDiffGenerator {
|
|
|
64
93
|
}
|
|
65
94
|
const fromVersion = await fromLaneHead.load(this.scope.legacyScope.objects);
|
|
66
95
|
const toVersion = await toLaneHead.load(this.scope.legacyScope.objects);
|
|
67
|
-
const fromLaneStr = this.
|
|
96
|
+
const fromLaneStr = this.fromLaneData ? this.fromLaneData.name : DEFAULT_LANE;
|
|
68
97
|
diffOptions.formatDepsAsTable = false;
|
|
69
98
|
const diff = await diffBetweenVersionsObjects(
|
|
70
99
|
modelComponent,
|
|
71
100
|
fromVersion as Version,
|
|
72
101
|
toVersion as Version,
|
|
73
102
|
fromLaneStr,
|
|
74
|
-
this.
|
|
103
|
+
this.toLaneData.name,
|
|
75
104
|
this.scope.legacyScope,
|
|
76
105
|
diffOptions
|
|
77
106
|
);
|
|
@@ -88,10 +117,10 @@ export class LaneDiffGenerator {
|
|
|
88
117
|
if (currentLane.isDefault()) {
|
|
89
118
|
throw new Error(`you are currently on the default branch, to run diff between lanes, please specify them`);
|
|
90
119
|
}
|
|
91
|
-
return { toLaneName: currentLane.name };
|
|
120
|
+
return { toLaneName: currentLane.name, fromLaneName: DEFAULT_LANE };
|
|
92
121
|
}
|
|
93
122
|
if (values.length === 1) {
|
|
94
|
-
const fromLaneName = currentLane.isDefault() ?
|
|
123
|
+
const fromLaneName = currentLane.isDefault() ? DEFAULT_LANE : currentLane.name;
|
|
95
124
|
return { fromLaneName, toLaneName: values[0] };
|
|
96
125
|
}
|
|
97
126
|
return { fromLaneName: values[0], toLaneName: values[1] };
|
|
@@ -100,8 +129,46 @@ export class LaneDiffGenerator {
|
|
|
100
129
|
if (values.length < 1) {
|
|
101
130
|
throw new Error(`expect "values" to include at least one arg - the lane name`);
|
|
102
131
|
}
|
|
103
|
-
const fromLaneName = values.length === 2 ? values[0] :
|
|
132
|
+
const fromLaneName = values.length === 2 ? values[0] : DEFAULT_LANE;
|
|
104
133
|
const toLaneName = values.length === 2 ? values[1] : values[0];
|
|
105
134
|
return { fromLaneName, toLaneName };
|
|
106
135
|
}
|
|
136
|
+
|
|
137
|
+
private async getDefaultLaneData(ids: BitId[]): Promise<LaneData> {
|
|
138
|
+
const laneData: LaneData = {
|
|
139
|
+
name: DEFAULT_LANE,
|
|
140
|
+
remote: null,
|
|
141
|
+
components: [],
|
|
142
|
+
isMerged: null,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
await Promise.all(
|
|
146
|
+
ids.map(async (id) => {
|
|
147
|
+
const modelComponent = await this.scope.legacyScope.getModelComponent(id);
|
|
148
|
+
const laneComponent = {
|
|
149
|
+
id,
|
|
150
|
+
head: modelComponent.head as Ref,
|
|
151
|
+
version: modelComponent.latestVersion(), // should this be latestVersion() or bitId.version.toString()
|
|
152
|
+
};
|
|
153
|
+
laneData.components.push(laneComponent);
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
return laneData;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private async mapToLaneData(lane: Lane): Promise<LaneData> {
|
|
161
|
+
const { name, components, remoteLaneId } = lane;
|
|
162
|
+
const isMerged = await lane.isFullyMerged(this.scope.legacyScope);
|
|
163
|
+
return {
|
|
164
|
+
name,
|
|
165
|
+
isMerged,
|
|
166
|
+
components: components.map((lc) => ({
|
|
167
|
+
id: lc.id,
|
|
168
|
+
head: lc.head,
|
|
169
|
+
version: lc.id.version?.toString(),
|
|
170
|
+
})),
|
|
171
|
+
remote: remoteLaneId?.toString() ?? null,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
107
174
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/lanes.modules.diff",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.105",
|
|
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.105"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
13
|
-
"@teambit/legacy-bit-id": "0.0.
|
|
13
|
+
"@teambit/legacy-bit-id": "0.0.398"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/mocha": "5.2.7",
|
|
@@ -18,9 +18,7 @@
|
|
|
18
18
|
"@types/node": "12.20.4",
|
|
19
19
|
"@types/jest": "26.0.20"
|
|
20
20
|
},
|
|
21
|
-
"peerDependencies": {
|
|
22
|
-
"@teambit/legacy": "1.0.193"
|
|
23
|
-
},
|
|
21
|
+
"peerDependencies": {},
|
|
24
22
|
"license": "Apache-2.0",
|
|
25
23
|
"bit": {
|
|
26
24
|
"bindingPrefix": "@teambit",
|
|
@@ -35,9 +33,6 @@
|
|
|
35
33
|
"@babel/runtime": "7.12.18",
|
|
36
34
|
"@types/node": "12.20.4",
|
|
37
35
|
"@types/jest": "26.0.20"
|
|
38
|
-
},
|
|
39
|
-
"peerDependencies": {
|
|
40
|
-
"@teambit/legacy": "1.0.193"
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
},
|
|
Binary file
|