@teambit/lanes.modules.diff 0.0.160 → 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.
@@ -1,5 +1,6 @@
1
1
  import { ScopeMain } from '@teambit/scope';
2
2
  import { Workspace } from '@teambit/workspace';
3
+ import { BitId } from '@teambit/legacy-bit-id';
3
4
  import { DiffResults, DiffOptions } from '@teambit/legacy/dist/consumer/component-ops/components-diff';
4
5
  export declare class LaneDiffGenerator {
5
6
  private workspace;
@@ -9,6 +10,7 @@ export declare class LaneDiffGenerator {
9
10
  private compsWithNoChanges;
10
11
  private fromLaneData;
11
12
  private toLaneData;
13
+ private failures;
12
14
  constructor(workspace: Workspace | undefined, scope: ScopeMain);
13
15
  /**
14
16
  * the values array may include zero to two values and will be processed as following:
@@ -16,11 +18,15 @@ export declare class LaneDiffGenerator {
16
18
  * [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
17
19
  * [from, to] => diff between "from" lane and "to" lane.
18
20
  */
19
- generate(values: string[], diffOptions?: DiffOptions): Promise<{
21
+ generate(values: string[], diffOptions?: DiffOptions, pattern?: string): Promise<{
20
22
  newComps: string[];
21
23
  compsWithDiff: DiffResults[];
22
24
  compsWithNoChanges: string[];
23
25
  toLaneName: string;
26
+ failures: {
27
+ id: BitId;
28
+ msg: string;
29
+ }[];
24
30
  }>;
25
31
  private componentDiff;
26
32
  private getLaneNames;
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  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
+ const bit_id_1 = require("@teambit/legacy/dist/bit-id");
16
+ const bit_error_1 = require("@teambit/bit-error");
15
17
  class LaneDiffGenerator {
16
18
  constructor(workspace, scope) {
17
19
  this.workspace = workspace;
@@ -19,6 +21,7 @@ class LaneDiffGenerator {
19
21
  this.newComps = [];
20
22
  this.compsWithDiff = [];
21
23
  this.compsWithNoChanges = [];
24
+ this.failures = [];
22
25
  }
23
26
  /**
24
27
  * the values array may include zero to two values and will be processed as following:
@@ -26,7 +29,7 @@ class LaneDiffGenerator {
26
29
  * [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
27
30
  * [from, to] => diff between "from" lane and "to" lane.
28
31
  */
29
- generate(values, diffOptions = {}) {
32
+ generate(values, diffOptions = {}, pattern) {
30
33
  var _a;
31
34
  return __awaiter(this, void 0, void 0, function* () {
32
35
  const { fromLaneName, toLaneName } = this.getLaneNames(values);
@@ -34,35 +37,50 @@ class LaneDiffGenerator {
34
37
  throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
35
38
  }
36
39
  const legacyScope = this.scope.legacyScope;
37
- const fromLaneId = fromLaneName ? yield legacyScope.lanes.parseLaneIdFromString(fromLaneName) : null;
38
- const toLaneId = toLaneName ? yield legacyScope.lanes.parseLaneIdFromString(toLaneName) : null;
39
- const isFromOrToDefault = (fromLaneId === null || fromLaneId === void 0 ? void 0 : fromLaneId.isDefault()) || (toLaneId === null || toLaneId === void 0 ? void 0 : toLaneId.isDefault());
40
- if (!isFromOrToDefault && !toLaneId) {
41
- throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
42
- }
43
- else if (!isFromOrToDefault && toLaneId && fromLaneId) {
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`);
44
45
  const toLane = yield legacyScope.lanes.loadLane(toLaneId);
45
46
  if (!toLane)
46
47
  throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
47
- const fromLane = fromLaneId ? yield legacyScope.lanes.loadLane(fromLaneId) : null;
48
48
  this.toLaneData = yield this.mapToLaneData(toLane);
49
- this.fromLaneData = fromLane ? yield this.mapToLaneData(fromLane) : null;
49
+ const bitIds = toLane.components.map((c) => c.id);
50
+ this.fromLaneData = yield this.getDefaultLaneData(bitIds);
50
51
  }
51
- else if ((fromLaneId === null || fromLaneId === void 0 ? void 0 : fromLaneId.isDefault()) && toLaneId) {
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);
57
+ const bitIds = (fromLane === null || fromLane === void 0 ? void 0 : fromLane.components.map((c) => c.id)) || [];
58
+ this.toLaneData = yield this.getDefaultLaneData(bitIds);
59
+ }
60
+ else {
61
+ // both, "from" and "to" are not default-lane.
52
62
  const toLane = yield legacyScope.lanes.loadLane(toLaneId);
53
63
  if (!toLane)
54
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`);
55
68
  this.toLaneData = yield this.mapToLaneData(toLane);
56
- const bitIds = toLane.components.map((c) => c.id);
57
- this.fromLaneData = yield this.getDefaultLaneData(bitIds);
69
+ this.fromLaneData = yield this.mapToLaneData(fromLane);
58
70
  }
59
- else {
60
- const fromLane = fromLaneId ? yield legacyScope.lanes.loadLane(fromLaneId) : null;
61
- this.fromLaneData = fromLane ? yield this.mapToLaneData(fromLane) : null;
62
- const bitIds = (fromLane === null || fromLane === void 0 ? void 0 : fromLane.components.map((c) => c.id)) || [];
63
- this.toLaneData = yield this.getDefaultLaneData(bitIds);
71
+ let idsToCheckDiff;
72
+ if (pattern) {
73
+ const allIds = this.toLaneData.components.map((c) => c.id);
74
+ const compIds = yield (this.workspace || this.scope).resolveMultipleComponentIds(allIds);
75
+ idsToCheckDiff = bit_id_1.BitIds.fromArray(this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds).map((c) => c._legacy));
76
+ }
77
+ if (!this.toLaneData.components.length) {
78
+ throw new bit_error_1.BitError(`lane "${toLaneName}" is empty, nothing to show`);
64
79
  }
65
80
  yield Promise.all(this.toLaneData.components.map(({ id, head }) => __awaiter(this, void 0, void 0, function* () {
81
+ if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
82
+ return;
83
+ }
66
84
  yield this.componentDiff(id, head, diffOptions);
67
85
  })));
68
86
  return {
@@ -70,6 +88,7 @@ class LaneDiffGenerator {
70
88
  compsWithDiff: this.compsWithDiff,
71
89
  compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
72
90
  toLaneName: (_a = this.toLaneData) === null || _a === void 0 ? void 0 : _a.name,
91
+ failures: this.failures,
73
92
  };
74
93
  });
75
94
  }
@@ -86,7 +105,14 @@ class LaneDiffGenerator {
86
105
  this.compsWithNoChanges.push(id);
87
106
  return;
88
107
  }
89
- const fromVersion = yield fromLaneHead.load(this.scope.legacyScope.objects);
108
+ let fromVersion;
109
+ try {
110
+ fromVersion = (yield fromLaneHead.load(this.scope.legacyScope.objects, true));
111
+ }
112
+ catch (err) {
113
+ this.failures.push({ id, msg: err.message });
114
+ return;
115
+ }
90
116
  const toVersion = yield toLaneHead.load(this.scope.legacyScope.objects);
91
117
  const fromLaneStr = this.fromLaneData ? this.fromLaneData.name : lane_id_1.DEFAULT_LANE;
92
118
  diffOptions.formatDepsAsTable = false;
@@ -107,10 +133,10 @@ class LaneDiffGenerator {
107
133
  return { toLaneName: currentLane.name, fromLaneName: lane_id_1.DEFAULT_LANE };
108
134
  }
109
135
  if (values.length === 1) {
110
- const fromLaneName = currentLane.isDefault() ? lane_id_1.DEFAULT_LANE : currentLane.name;
111
- return { fromLaneName, toLaneName: values[0] };
136
+ const toLaneName = currentLane.isDefault() ? lane_id_1.DEFAULT_LANE : currentLane.name;
137
+ return { toLaneName, fromLaneName: values[0] };
112
138
  }
113
- return { fromLaneName: values[0], toLaneName: values[1] };
139
+ return { toLaneName: values[1], fromLaneName: values[0] };
114
140
  }
115
141
  // running from the scope
116
142
  if (values.length < 1) {
@@ -126,7 +152,6 @@ class LaneDiffGenerator {
126
152
  name: lane_id_1.DEFAULT_LANE,
127
153
  remote: null,
128
154
  components: [],
129
- isMerged: null,
130
155
  };
131
156
  yield Promise.all(ids.map((id) => __awaiter(this, void 0, void 0, function* () {
132
157
  const modelComponent = yield this.scope.legacyScope.getModelComponent(id);
@@ -143,10 +168,8 @@ class LaneDiffGenerator {
143
168
  mapToLaneData(lane) {
144
169
  return __awaiter(this, void 0, void 0, function* () {
145
170
  const { name, components } = lane;
146
- const isMerged = yield lane.isFullyMerged(this.scope.legacyScope);
147
171
  return {
148
172
  name,
149
- isMerged,
150
173
  components: components.map((lc) => {
151
174
  var _a;
152
175
  return ({
@@ -1 +1 @@
1
- {"version":3,"file":"lane-diff-generator.js","sourceRoot":"","sources":["../lane-diff-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,iGAIqE;AACrE,8CAAgD;AAWhD,MAAa,iBAAiB;IAM5B,YAAoB,SAAgC,EAAU,KAAgB;QAA1D,cAAS,GAAT,SAAS,CAAuB;QAAU,UAAK,GAAL,KAAK,CAAW;QALtE,aAAQ,GAAY,EAAE,CAAC;QACvB,kBAAa,GAAkB,EAAE,CAAC;QAClC,uBAAkB,GAAY,EAAE,CAAC;IAGwC,CAAC;IAElF;;;;;OAKG;IACG,QAAQ,CAAC,MAAgB,EAAE,cAA2B,EAAE;;;YAC5D,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC/D,IAAI,YAAY,KAAK,UAAU,EAAE;gBAC/B,MAAM,IAAI,KAAK,CAAC,+BAA+B,YAAY,UAAU,UAAU,0BAA0B,CAAC,CAAC;aAC5G;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;YAC3C,MAAM,UAAU,GAAG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AE,IAAI;gBACZ,UAAU,EAAE,EAAE;aACf,CAAC;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,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"}
@@ -15,5 +15,7 @@ export declare class LaneDiffCmd implements Command {
15
15
  remoteOp: boolean;
16
16
  skipWorkspace: boolean;
17
17
  constructor(workspace: Workspace, scope: ScopeMain);
18
- report([values]: [string[]]): Promise<string>;
18
+ report([values]: [string[]], { pattern }: {
19
+ pattern?: string;
20
+ }): Promise<string>;
19
21
  }
@@ -26,22 +26,27 @@ class LaneDiffCmd {
26
26
  bit lane diff to => diff between the current lane (or default-lane when in scope) and "to" lane.
27
27
  bit lane diff from to => diff between "from" lane and "to" lane.`;
28
28
  this.alias = '';
29
- this.options = [];
29
+ this.options = [
30
+ ['', 'pattern <component-pattern>', 'EXPERIMENTAL. show lane-diff for the specified component-pattern only'],
31
+ ];
30
32
  this.loader = true;
31
33
  this.private = true;
32
34
  this.migration = true;
33
35
  this.remoteOp = true;
34
36
  this.skipWorkspace = true;
35
37
  }
36
- report([values = []]) {
38
+ report([values = []], { pattern }) {
37
39
  return __awaiter(this, void 0, void 0, function* () {
38
40
  const laneDiffGenerator = new lane_diff_generator_1.LaneDiffGenerator(this.workspace, this.scope);
39
- const { compsWithDiff, newComps, toLaneName } = yield laneDiffGenerator.generate(values);
41
+ const { compsWithDiff, newComps, toLaneName, failures } = yield laneDiffGenerator.generate(values, undefined, pattern);
40
42
  const diffResultsStr = (0, components_diff_1.outputDiffResults)(compsWithDiff);
41
43
  const newCompsIdsStr = newComps.map((id) => chalk_1.default.bold(id)).join('\n');
42
44
  const newCompsTitle = `The following components were introduced in ${chalk_1.default.bold(toLaneName)} lane`;
43
45
  const newCompsStr = newComps.length ? `${chalk_1.default.inverse(newCompsTitle)}\n${newCompsIdsStr}` : '';
44
- return `${diffResultsStr}\n${newCompsStr}`;
46
+ const failuresTitle = `\n\nDiff failed on the following component(s)`;
47
+ const failuresIds = failures.map((f) => `${f.id.toString()} - ${chalk_1.default.red(f.msg)}`);
48
+ const failuresStr = failures.length ? `${chalk_1.default.inverse(failuresTitle)}\n${failuresIds}` : '';
49
+ return `${diffResultsStr}\n${newCompsStr}${failuresStr}`;
45
50
  });
46
51
  }
47
52
  }
@@ -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;IAct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,UAAU,CAAC,OAAO,CAAC;YACnG,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,eAAK,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChG,MAAM,aAAa,GAAG,+CAA+C,CAAC;YACtE,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,eAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpF,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,eAAK,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7F,OAAO,GAAG,cAAc,KAAK,WAAW,GAAG,WAAW,EAAE,CAAC;QAC3D,CAAC;KAAA;CACF;AAnCD,kCAmCC"}
@@ -9,6 +9,8 @@ import {
9
9
  DiffOptions,
10
10
  } from '@teambit/legacy/dist/consumer/component-ops/components-diff';
11
11
  import { DEFAULT_LANE } from '@teambit/lane-id';
12
+ import { BitIds } from '@teambit/legacy/dist/bit-id';
13
+ import { BitError } from '@teambit/bit-error';
12
14
 
13
15
  type LaneData = {
14
16
  name: string;
@@ -17,7 +19,6 @@ type LaneData = {
17
19
  head: Ref;
18
20
  }>;
19
21
  remote: string | null;
20
- isMerged: boolean | null;
21
22
  };
22
23
  export class LaneDiffGenerator {
23
24
  private newComps: BitId[] = [];
@@ -25,6 +26,7 @@ export class LaneDiffGenerator {
25
26
  private compsWithNoChanges: BitId[] = [];
26
27
  private fromLaneData: LaneData | null;
27
28
  private toLaneData: LaneData;
29
+ private failures: { id: BitId; msg: string }[] = [];
28
30
  constructor(private workspace: Workspace | undefined, private scope: ScopeMain) {}
29
31
 
30
32
  /**
@@ -33,40 +35,56 @@ export class LaneDiffGenerator {
33
35
  * [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
34
36
  * [from, to] => diff between "from" lane and "to" lane.
35
37
  */
36
- async generate(values: string[], diffOptions: DiffOptions = {}) {
38
+ async generate(values: string[], diffOptions: DiffOptions = {}, pattern?: string) {
37
39
  const { fromLaneName, toLaneName } = this.getLaneNames(values);
38
40
  if (fromLaneName === toLaneName) {
39
41
  throw new Error(`unable to run diff between "${fromLaneName}" and "${toLaneName}", they're the same lane`);
40
42
  }
41
43
  const legacyScope = this.scope.legacyScope;
42
- const fromLaneId = fromLaneName ? await legacyScope.lanes.parseLaneIdFromString(fromLaneName) : null;
43
- const toLaneId = toLaneName ? await legacyScope.lanes.parseLaneIdFromString(toLaneName) : null;
44
- const isFromOrToDefault = fromLaneId?.isDefault() || toLaneId?.isDefault();
44
+ const fromLaneId = await legacyScope.lanes.parseLaneIdFromString(fromLaneName);
45
+ const toLaneId = await legacyScope.lanes.parseLaneIdFromString(toLaneName);
45
46
 
46
- if (!isFromOrToDefault && !toLaneId) {
47
- throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
48
- } 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`);
49
49
  const toLane = await legacyScope.lanes.loadLane(toLaneId);
50
50
  if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
51
- const fromLane = fromLaneId ? await legacyScope.lanes.loadLane(fromLaneId) : null;
52
- this.toLaneData = await this.mapToLaneData(toLane);
53
- this.fromLaneData = fromLane ? await this.mapToLaneData(fromLane) : null;
54
- } else if (fromLaneId?.isDefault() && toLaneId) {
55
- const toLane = await legacyScope.lanes.loadLane(toLaneId);
56
- if (!toLane) throw new Error(`unable to find a lane "${toLaneName}" in the scope`);
57
-
58
51
  this.toLaneData = await this.mapToLaneData(toLane);
59
52
  const bitIds = toLane.components.map((c) => c.id);
60
53
  this.fromLaneData = await this.getDefaultLaneData(bitIds);
61
- } else {
62
- const fromLane = fromLaneId ? await legacyScope.lanes.loadLane(fromLaneId) : null;
63
- this.fromLaneData = fromLane ? await this.mapToLaneData(fromLane) : null;
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);
64
58
  const bitIds = fromLane?.components.map((c) => c.id) || [];
65
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);
68
+ }
69
+
70
+ let idsToCheckDiff: BitIds | undefined;
71
+ if (pattern) {
72
+ const allIds = this.toLaneData.components.map((c) => c.id);
73
+ const compIds = await (this.workspace || this.scope).resolveMultipleComponentIds(allIds);
74
+ idsToCheckDiff = BitIds.fromArray(
75
+ this.scope.filterIdsFromPoolIdsByPattern(pattern, compIds).map((c) => c._legacy)
76
+ );
77
+ }
78
+
79
+ if (!this.toLaneData.components.length) {
80
+ throw new BitError(`lane "${toLaneName}" is empty, nothing to show`);
66
81
  }
67
82
 
68
83
  await Promise.all(
69
84
  this.toLaneData.components.map(async ({ id, head }) => {
85
+ if (idsToCheckDiff && !idsToCheckDiff.hasWithoutVersion(id)) {
86
+ return;
87
+ }
70
88
  await this.componentDiff(id, head, diffOptions);
71
89
  })
72
90
  );
@@ -76,6 +94,7 @@ export class LaneDiffGenerator {
76
94
  compsWithDiff: this.compsWithDiff,
77
95
  compsWithNoChanges: this.compsWithNoChanges.map((id) => id.toString()),
78
96
  toLaneName: this.toLaneData?.name,
97
+ failures: this.failures,
79
98
  };
80
99
  }
81
100
 
@@ -91,13 +110,19 @@ export class LaneDiffGenerator {
91
110
  this.compsWithNoChanges.push(id);
92
111
  return;
93
112
  }
94
- const fromVersion = await fromLaneHead.load(this.scope.legacyScope.objects);
113
+ let fromVersion: Version;
114
+ try {
115
+ fromVersion = (await fromLaneHead.load(this.scope.legacyScope.objects, true)) as Version;
116
+ } catch (err: any) {
117
+ this.failures.push({ id, msg: err.message });
118
+ return;
119
+ }
95
120
  const toVersion = await toLaneHead.load(this.scope.legacyScope.objects);
96
121
  const fromLaneStr = this.fromLaneData ? this.fromLaneData.name : DEFAULT_LANE;
97
122
  diffOptions.formatDepsAsTable = false;
98
123
  const diff = await diffBetweenVersionsObjects(
99
124
  modelComponent,
100
- fromVersion as Version,
125
+ fromVersion,
101
126
  toVersion as Version,
102
127
  fromLaneStr,
103
128
  this.toLaneData.name,
@@ -107,7 +132,7 @@ export class LaneDiffGenerator {
107
132
  this.compsWithDiff.push(diff);
108
133
  }
109
134
 
110
- private getLaneNames(values: string[]): { fromLaneName?: string; toLaneName: string } {
135
+ private getLaneNames(values: string[]): { fromLaneName: string; toLaneName: string } {
111
136
  if (values.length > 2) {
112
137
  throw new Error(`expect "values" to include no more than two args, got ${values.length}`);
113
138
  }
@@ -120,10 +145,10 @@ export class LaneDiffGenerator {
120
145
  return { toLaneName: currentLane.name, fromLaneName: DEFAULT_LANE };
121
146
  }
122
147
  if (values.length === 1) {
123
- const fromLaneName = currentLane.isDefault() ? DEFAULT_LANE : currentLane.name;
124
- return { fromLaneName, toLaneName: values[0] };
148
+ const toLaneName = currentLane.isDefault() ? DEFAULT_LANE : currentLane.name;
149
+ return { toLaneName, fromLaneName: values[0] };
125
150
  }
126
- return { fromLaneName: values[0], toLaneName: values[1] };
151
+ return { toLaneName: values[1], fromLaneName: values[0] };
127
152
  }
128
153
  // running from the scope
129
154
  if (values.length < 1) {
@@ -139,7 +164,6 @@ export class LaneDiffGenerator {
139
164
  name: DEFAULT_LANE,
140
165
  remote: null,
141
166
  components: [],
142
- isMerged: null,
143
167
  };
144
168
 
145
169
  await Promise.all(
@@ -159,10 +183,8 @@ export class LaneDiffGenerator {
159
183
 
160
184
  private async mapToLaneData(lane: Lane): Promise<LaneData> {
161
185
  const { name, components } = lane;
162
- const isMerged = await lane.isFullyMerged(this.scope.legacyScope);
163
186
  return {
164
187
  name,
165
- isMerged,
166
188
  components: components.map((lc) => ({
167
189
  id: lc.id,
168
190
  head: lc.head,
package/lane-diff.cmd.ts CHANGED
@@ -12,7 +12,9 @@ export class LaneDiffCmd implements Command {
12
12
  bit lane diff to => diff between the current lane (or default-lane when in scope) and "to" lane.
13
13
  bit lane diff from to => diff between "from" lane and "to" lane.`;
14
14
  alias = '';
15
- options = [] as CommandOptions;
15
+ options = [
16
+ ['', 'pattern <component-pattern>', 'EXPERIMENTAL. show lane-diff for the specified component-pattern only'],
17
+ ] as CommandOptions;
16
18
  loader = true;
17
19
  private = true;
18
20
  migration = true;
@@ -21,13 +23,21 @@ bit lane diff from to => diff between "from" lane and "to" lane.`;
21
23
 
22
24
  constructor(private workspace: Workspace, private scope: ScopeMain) {}
23
25
 
24
- async report([values = []]: [string[]]) {
26
+ async report([values = []]: [string[]], { pattern }: { pattern?: string }) {
25
27
  const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope);
26
- const { compsWithDiff, newComps, toLaneName } = await laneDiffGenerator.generate(values);
28
+ const { compsWithDiff, newComps, toLaneName, failures } = await laneDiffGenerator.generate(
29
+ values,
30
+ undefined,
31
+ pattern
32
+ );
33
+
27
34
  const diffResultsStr = outputDiffResults(compsWithDiff);
28
35
  const newCompsIdsStr = newComps.map((id) => chalk.bold(id)).join('\n');
29
36
  const newCompsTitle = `The following components were introduced in ${chalk.bold(toLaneName)} lane`;
30
37
  const newCompsStr = newComps.length ? `${chalk.inverse(newCompsTitle)}\n${newCompsIdsStr}` : '';
31
- return `${diffResultsStr}\n${newCompsStr}`;
38
+ const failuresTitle = `\n\nDiff failed on the following component(s)`;
39
+ const failuresIds = failures.map((f) => `${f.id.toString()} - ${chalk.red(f.msg)}`);
40
+ const failuresStr = failures.length ? `${chalk.inverse(failuresTitle)}\n${failuresIds}` : '';
41
+ return `${diffResultsStr}\n${newCompsStr}${failuresStr}`;
32
42
  }
33
43
  }
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@teambit/lanes.modules.diff",
3
- "version": "0.0.160",
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.160"
9
+ "version": "0.0.163"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
13
- "@teambit/lane-id": "0.0.50",
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": {