@teambit/lanes.modules.diff 0.0.595 → 0.0.596
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.
|
@@ -15,7 +15,7 @@ export declare class LaneHistoryDiffCmd implements Command {
|
|
|
15
15
|
options: CommandOptions;
|
|
16
16
|
loader: boolean;
|
|
17
17
|
constructor(lanes: LanesMain, workspace: Workspace, scope: ScopeMain, componentCompare: ComponentCompareMain);
|
|
18
|
-
report([
|
|
18
|
+
report([historyId, toHistoryId]: string[], { lane, pattern }: {
|
|
19
19
|
lane?: string;
|
|
20
20
|
pattern?: string;
|
|
21
21
|
}): Promise<string>;
|
|
@@ -26,9 +26,12 @@ function _bitError() {
|
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
28
|
class LaneHistoryDiffCmd {
|
|
29
|
-
name = 'history-diff
|
|
30
|
-
description = '
|
|
31
|
-
extendedDescription =
|
|
29
|
+
name = 'history-diff [history-id] [to-history-id]';
|
|
30
|
+
description = 'show diff between lane-history entries';
|
|
31
|
+
extendedDescription = `with no arguments - diff the latest history entry against its predecessor
|
|
32
|
+
with one argument - diff the given history entry against its predecessor
|
|
33
|
+
with two arguments - diff between two specific history entries (first=from, second=to), useful for comparing any two points in history
|
|
34
|
+
run "bit lane history" to find history-ids`;
|
|
32
35
|
alias = '';
|
|
33
36
|
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
37
|
component-pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`]];
|
|
@@ -39,7 +42,7 @@ component-pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`]];
|
|
|
39
42
|
this.scope = scope;
|
|
40
43
|
this.componentCompare = componentCompare;
|
|
41
44
|
}
|
|
42
|
-
async report([
|
|
45
|
+
async report([historyId, toHistoryId], {
|
|
43
46
|
lane,
|
|
44
47
|
pattern
|
|
45
48
|
}) {
|
|
@@ -47,9 +50,28 @@ component-pattern format: ${_legacy().COMPONENT_PATTERN_HELP}`]];
|
|
|
47
50
|
if (!laneId || laneId.isDefault()) throw new (_bitError().BitError)(`unable to show diff-history of the default lane (main)`);
|
|
48
51
|
await this.lanes.importLaneHistory(laneId);
|
|
49
52
|
const laneHistory = await this.lanes.getLaneHistory(laneId);
|
|
53
|
+
let fromId;
|
|
54
|
+
let toId;
|
|
55
|
+
const historyIds = laneHistory.getHistoryIds();
|
|
56
|
+
if (historyId && toHistoryId) {
|
|
57
|
+
// two args: explicit from and to
|
|
58
|
+
fromId = historyId;
|
|
59
|
+
toId = toHistoryId;
|
|
60
|
+
} else if (historyId) {
|
|
61
|
+
// one arg: diff this snap against its predecessor
|
|
62
|
+
toId = historyId;
|
|
63
|
+
const predecessorIndex = historyIds.indexOf(historyId) - 1;
|
|
64
|
+
if (predecessorIndex < 0) throw new (_bitError().BitError)(`unable to find a predecessor for history-id "${historyId}". it's either the first entry or not found`);
|
|
65
|
+
fromId = historyIds[predecessorIndex];
|
|
66
|
+
} else {
|
|
67
|
+
// no args: diff the latest snap against the one before it
|
|
68
|
+
if (historyIds.length < 2) throw new (_bitError().BitError)(`need at least two history entries to diff, got ${historyIds.length}`);
|
|
69
|
+
toId = historyIds[historyIds.length - 1];
|
|
70
|
+
fromId = historyIds[historyIds.length - 2];
|
|
71
|
+
}
|
|
50
72
|
const laneDiffGenerator = new (_laneDiffGenerator().LaneDiffGenerator)(this.workspace, this.scope, this.componentCompare);
|
|
51
73
|
const laneObj = await this.lanes.loadLane(laneId);
|
|
52
|
-
const results = await laneDiffGenerator.generateDiffHistory(laneObj, laneHistory,
|
|
74
|
+
const results = await laneDiffGenerator.generateDiffHistory(laneObj, laneHistory, fromId, toId, pattern);
|
|
53
75
|
return laneDiffGenerator.laneDiffResultsToString(results);
|
|
54
76
|
}
|
|
55
77
|
}
|
|
@@ -1 +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","
|
|
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","historyId","toHistoryId","lane","pattern","laneId","parseLaneId","getCurrentLaneId","isDefault","BitError","importLaneHistory","laneHistory","getLaneHistory","fromId","toId","historyIds","getHistoryIds","predecessorIndex","indexOf","length","laneDiffGenerator","LaneDiffGenerator","laneObj","loadLane","results","generateDiffHistory","laneDiffResultsToString","exports"],"sources":["lane-history-diff.cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from '@teambit/cli';\nimport type { ScopeMain } from '@teambit/scope';\nimport type { Workspace } from '@teambit/workspace';\nimport type { 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 type { LanesMain } from '@teambit/lanes';\n\nexport class LaneHistoryDiffCmd implements Command {\n name = 'history-diff [history-id] [to-history-id]';\n description = 'show diff between lane-history entries';\n extendedDescription = `with no arguments - diff the latest history entry against its predecessor\nwith one argument - diff the given history entry against its predecessor\nwith two arguments - diff between two specific history entries (first=from, second=to), useful for comparing any two points in history\nrun \"bit lane history\" to find 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 [historyId, toHistoryId]: 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\n let fromId: string;\n let toId: string;\n const historyIds = laneHistory.getHistoryIds();\n\n if (historyId && toHistoryId) {\n // two args: explicit from and to\n fromId = historyId;\n toId = toHistoryId;\n } else if (historyId) {\n // one arg: diff this snap against its predecessor\n toId = historyId;\n const predecessorIndex = historyIds.indexOf(historyId) - 1;\n if (predecessorIndex < 0)\n throw new BitError(\n `unable to find a predecessor for history-id \"${historyId}\". it's either the first entry or not found`\n );\n fromId = historyIds[predecessorIndex];\n } else {\n // no args: diff the latest snap against the one before it\n if (historyIds.length < 2)\n throw new BitError(`need at least two history entries to diff, got ${historyIds.length}`);\n toId = historyIds[historyIds.length - 1];\n fromId = historyIds[historyIds.length - 2];\n }\n\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(laneObj!, laneHistory, fromId, toId, 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;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGO,MAAMI,k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AAGZ,WAAW;IACpB,CAAC,MAAM,IAAID,SAAS,EAAE;MACpB;MACAa,IAAI,GAAGb,SAAS;MAChB,MAAMgB,gBAAgB,GAAGF,UAAU,CAACG,OAAO,CAACjB,SAAS,CAAC,GAAG,CAAC;MAC1D,IAAIgB,gBAAgB,GAAG,CAAC,EACtB,MAAM,KAAIR,oBAAQ,EAChB,gDAAgDR,SAAS,6CAC3D,CAAC;MACHY,MAAM,GAAGE,UAAU,CAACE,gBAAgB,CAAC;IACvC,CAAC,MAAM;MACL;MACA,IAAIF,UAAU,CAACI,MAAM,GAAG,CAAC,EACvB,MAAM,KAAIV,oBAAQ,EAAC,kDAAkDM,UAAU,CAACI,MAAM,EAAE,CAAC;MAC3FL,IAAI,GAAGC,UAAU,CAACA,UAAU,CAACI,MAAM,GAAG,CAAC,CAAC;MACxCN,MAAM,GAAGE,UAAU,CAACA,UAAU,CAACI,MAAM,GAAG,CAAC,CAAC;IAC5C;IAEA,MAAMC,iBAAiB,GAAG,KAAIC,sCAAiB,EAAC,IAAI,CAACxB,SAAS,EAAE,IAAI,CAACC,KAAK,EAAE,IAAI,CAACC,gBAAgB,CAAC;IAClG,MAAMuB,OAAO,GAAG,MAAM,IAAI,CAAC1B,KAAK,CAAC2B,QAAQ,CAAClB,MAAM,CAAC;IACjD,MAAMmB,OAAO,GAAG,MAAMJ,iBAAiB,CAACK,mBAAmB,CAACH,OAAO,EAAGX,WAAW,EAAEE,MAAM,EAAEC,IAAI,EAAEV,OAAO,CAAC;IACzG,OAAOgB,iBAAiB,CAACM,uBAAuB,CAACF,OAAO,CAAC;EAC3D;AACF;AAACG,OAAA,CAAAxC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/lane-history-diff.cmd.ts
CHANGED
|
@@ -8,9 +8,12 @@ import { BitError } from '@teambit/bit-error';
|
|
|
8
8
|
import type { LanesMain } from '@teambit/lanes';
|
|
9
9
|
|
|
10
10
|
export class LaneHistoryDiffCmd implements Command {
|
|
11
|
-
name = 'history-diff
|
|
12
|
-
description = '
|
|
13
|
-
extendedDescription =
|
|
11
|
+
name = 'history-diff [history-id] [to-history-id]';
|
|
12
|
+
description = 'show diff between lane-history entries';
|
|
13
|
+
extendedDescription = `with no arguments - diff the latest history entry against its predecessor
|
|
14
|
+
with one argument - diff the given history entry against its predecessor
|
|
15
|
+
with two arguments - diff between two specific history entries (first=from, second=to), useful for comparing any two points in history
|
|
16
|
+
run "bit lane history" to find history-ids`;
|
|
14
17
|
alias = '';
|
|
15
18
|
options = [
|
|
16
19
|
['l', 'lane <lane-name>', 'the name of the lane to diff. if not specified, the current lane is used'],
|
|
@@ -31,22 +34,42 @@ component-pattern format: ${COMPONENT_PATTERN_HELP}`,
|
|
|
31
34
|
) {}
|
|
32
35
|
|
|
33
36
|
async report(
|
|
34
|
-
[
|
|
37
|
+
[historyId, toHistoryId]: string[],
|
|
35
38
|
{ lane, pattern }: { lane?: string; pattern?: string }
|
|
36
39
|
): Promise<string> {
|
|
37
40
|
const laneId = lane ? await this.lanes.parseLaneId(lane) : this.lanes.getCurrentLaneId();
|
|
38
41
|
if (!laneId || laneId.isDefault()) throw new BitError(`unable to show diff-history of the default lane (main)`);
|
|
39
42
|
await this.lanes.importLaneHistory(laneId);
|
|
40
43
|
const laneHistory = await this.lanes.getLaneHistory(laneId);
|
|
44
|
+
|
|
45
|
+
let fromId: string;
|
|
46
|
+
let toId: string;
|
|
47
|
+
const historyIds = laneHistory.getHistoryIds();
|
|
48
|
+
|
|
49
|
+
if (historyId && toHistoryId) {
|
|
50
|
+
// two args: explicit from and to
|
|
51
|
+
fromId = historyId;
|
|
52
|
+
toId = toHistoryId;
|
|
53
|
+
} else if (historyId) {
|
|
54
|
+
// one arg: diff this snap against its predecessor
|
|
55
|
+
toId = historyId;
|
|
56
|
+
const predecessorIndex = historyIds.indexOf(historyId) - 1;
|
|
57
|
+
if (predecessorIndex < 0)
|
|
58
|
+
throw new BitError(
|
|
59
|
+
`unable to find a predecessor for history-id "${historyId}". it's either the first entry or not found`
|
|
60
|
+
);
|
|
61
|
+
fromId = historyIds[predecessorIndex];
|
|
62
|
+
} else {
|
|
63
|
+
// no args: diff the latest snap against the one before it
|
|
64
|
+
if (historyIds.length < 2)
|
|
65
|
+
throw new BitError(`need at least two history entries to diff, got ${historyIds.length}`);
|
|
66
|
+
toId = historyIds[historyIds.length - 1];
|
|
67
|
+
fromId = historyIds[historyIds.length - 2];
|
|
68
|
+
}
|
|
69
|
+
|
|
41
70
|
const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope, this.componentCompare);
|
|
42
71
|
const laneObj = await this.lanes.loadLane(laneId);
|
|
43
|
-
const results = await laneDiffGenerator.generateDiffHistory(
|
|
44
|
-
laneObj!,
|
|
45
|
-
laneHistory,
|
|
46
|
-
fromHistoryId,
|
|
47
|
-
toHistoryId,
|
|
48
|
-
pattern
|
|
49
|
-
);
|
|
72
|
+
const results = await laneDiffGenerator.generateDiffHistory(laneObj!, laneHistory, fromId, toId, pattern);
|
|
50
73
|
return laneDiffGenerator.laneDiffResultsToString(results);
|
|
51
74
|
}
|
|
52
75
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/lanes.modules.diff",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.596",
|
|
4
4
|
"homepage": "https://bit.cloud/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.596"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "4.1.2",
|