@teambit/version-history 0.0.1
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/artifacts/__bit_junit.xml +4 -0
- package/artifacts/preview/teambit_scope_version_history-preview.js +1 -0
- package/artifacts/schema.json +1914 -0
- package/dist/build-version-history-action.d.ts +13 -0
- package/dist/build-version-history-action.js +22 -0
- package/dist/build-version-history-action.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1711509617758.js +7 -0
- package/dist/version-history-cmd.d.ts +62 -0
- package/dist/version-history-cmd.js +142 -0
- package/dist/version-history-cmd.js.map +1 -0
- package/dist/version-history.aspect.d.ts +2 -0
- package/dist/version-history.aspect.js +18 -0
- package/dist/version-history.aspect.js.map +1 -0
- package/dist/version-history.main.runtime.d.ts +39 -0
- package/dist/version-history.main.runtime.js +243 -0
- package/dist/version-history.main.runtime.js.map +1 -0
- package/package.json +60 -0
- package/tsconfig.json +39 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BuildOptions } from './version-history-cmd';
|
|
2
|
+
import { VersionHistoryMain } from './version-history.main.runtime';
|
|
3
|
+
export declare class BuildVersionHistoryAction {
|
|
4
|
+
private versionHistory;
|
|
5
|
+
name: string;
|
|
6
|
+
constructor(versionHistory: VersionHistoryMain);
|
|
7
|
+
execute(options: BuildOptions): Promise<{
|
|
8
|
+
[idStr: string]: {
|
|
9
|
+
err?: Error | undefined;
|
|
10
|
+
added?: string[] | undefined;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BuildVersionHistoryAction = void 0;
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
class BuildVersionHistoryAction {
|
|
11
|
+
constructor(versionHistory) {
|
|
12
|
+
this.versionHistory = versionHistory;
|
|
13
|
+
_defineProperty(this, "name", BuildVersionHistoryAction.name);
|
|
14
|
+
}
|
|
15
|
+
async execute(options) {
|
|
16
|
+
if (!options.pattern) throw new Error('BuildVersionHistoryAction: pattern is required');
|
|
17
|
+
return this.versionHistory.buildByPattern(options.pattern, options);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.BuildVersionHistoryAction = BuildVersionHistoryAction;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=build-version-history-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BuildVersionHistoryAction","constructor","versionHistory","_defineProperty","name","execute","options","pattern","Error","buildByPattern","exports"],"sources":["build-version-history-action.ts"],"sourcesContent":["import { BuildOptions } from './version-history-cmd';\nimport { VersionHistoryMain } from './version-history.main.runtime';\n\nexport class BuildVersionHistoryAction {\n name = BuildVersionHistoryAction.name;\n constructor(private versionHistory: VersionHistoryMain) {}\n async execute(options: BuildOptions) {\n if (!options.pattern) throw new Error('BuildVersionHistoryAction: pattern is required');\n return this.versionHistory.buildByPattern(options.pattern, options);\n }\n}\n"],"mappings":";;;;;;;;;AAGO,MAAMA,yBAAyB,CAAC;EAErCC,WAAWA,CAASC,cAAkC,EAAE;IAAA,KAApCA,cAAkC,GAAlCA,cAAkC;IAAAC,eAAA,eAD/CH,yBAAyB,CAACI,IAAI;EACoB;EACzD,MAAMC,OAAOA,CAACC,OAAqB,EAAE;IACnC,IAAI,CAACA,OAAO,CAACC,OAAO,EAAE,MAAM,IAAIC,KAAK,CAAC,gDAAgD,CAAC;IACvF,OAAO,IAAI,CAACN,cAAc,CAACO,cAAc,CAACH,OAAO,CAACC,OAAO,EAAED,OAAO,CAAC;EACrE;AACF;AAACI,OAAA,CAAAV,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "VersionHistoryAspect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _versionHistory().VersionHistoryAspect;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
function _versionHistory() {
|
|
14
|
+
const data = require("./version-history.aspect");
|
|
15
|
+
_versionHistory = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
var _default = exports.default = _versionHistory().VersionHistoryAspect;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_versionHistory","data","require","_default","exports","default","VersionHistoryAspect"],"sources":["index.ts"],"sourcesContent":["import { VersionHistoryAspect } from './version-history.aspect';\n\nexport type { VersionHistoryMain } from './version-history.main.runtime';\nexport default VersionHistoryAspect;\nexport { VersionHistoryAspect };\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgE,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGjDC,sCAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { VersionHistoryMain } from './version-history.main.runtime';
|
|
3
|
+
export declare class VersionHistoryCmd implements Command {
|
|
4
|
+
name: string;
|
|
5
|
+
alias: string;
|
|
6
|
+
description: string;
|
|
7
|
+
options: never[];
|
|
8
|
+
group: string;
|
|
9
|
+
commands: Command[];
|
|
10
|
+
report([unrecognizedSubcommand]: [string]): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
export type BuildOptions = {
|
|
13
|
+
fromSnap?: string;
|
|
14
|
+
deleteExisting?: boolean;
|
|
15
|
+
remote?: string;
|
|
16
|
+
pattern?: string;
|
|
17
|
+
fromAllLanes?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare class VersionHistoryBuildCmd implements Command {
|
|
20
|
+
private versionHistoryMain;
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
arguments: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
}[];
|
|
27
|
+
options: CommandOptions;
|
|
28
|
+
group: string;
|
|
29
|
+
constructor(versionHistoryMain: VersionHistoryMain);
|
|
30
|
+
report([pattern]: [string], opts: BuildOptions): Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
export declare class VersionHistoryGraphCmd implements Command {
|
|
33
|
+
private versionHistoryMain;
|
|
34
|
+
name: string;
|
|
35
|
+
alias: string;
|
|
36
|
+
description: string;
|
|
37
|
+
options: CommandOptions;
|
|
38
|
+
group: string;
|
|
39
|
+
commands: Command[];
|
|
40
|
+
constructor(versionHistoryMain: VersionHistoryMain);
|
|
41
|
+
report([id]: [string], { mark, graphPath, layout, shortHash, }: {
|
|
42
|
+
mark?: string;
|
|
43
|
+
graphPath?: string;
|
|
44
|
+
layout?: string;
|
|
45
|
+
shortHash?: boolean;
|
|
46
|
+
}): Promise<string>;
|
|
47
|
+
}
|
|
48
|
+
export type ShowOptions = {
|
|
49
|
+
shortHash?: boolean;
|
|
50
|
+
};
|
|
51
|
+
export declare class VersionHistoryShowCmd implements Command {
|
|
52
|
+
private versionHistoryMain;
|
|
53
|
+
name: string;
|
|
54
|
+
alias: string;
|
|
55
|
+
description: string;
|
|
56
|
+
options: CommandOptions;
|
|
57
|
+
group: string;
|
|
58
|
+
commands: Command[];
|
|
59
|
+
constructor(versionHistoryMain: VersionHistoryMain);
|
|
60
|
+
report([id]: [string], { shortHash }: ShowOptions): Promise<string>;
|
|
61
|
+
json([id]: [string]): Promise<Record<string, any>>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VersionHistoryShowCmd = exports.VersionHistoryGraphCmd = exports.VersionHistoryCmd = exports.VersionHistoryBuildCmd = void 0;
|
|
7
|
+
function _constants() {
|
|
8
|
+
const data = require("@teambit/legacy/dist/constants");
|
|
9
|
+
_constants = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _catVersionHistory() {
|
|
15
|
+
const data = require("@teambit/legacy/dist/api/scope/lib/cat-version-history");
|
|
16
|
+
_catVersionHistory = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _vizgraph() {
|
|
22
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/graph/vizgraph"));
|
|
23
|
+
_vizgraph = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _chalk() {
|
|
29
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
30
|
+
_chalk = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
37
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
38
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
39
|
+
class VersionHistoryCmd {
|
|
40
|
+
constructor() {
|
|
41
|
+
_defineProperty(this, "name", 'version-history <sub-command>');
|
|
42
|
+
_defineProperty(this, "alias", 'vh');
|
|
43
|
+
_defineProperty(this, "description", 'manage the version-history of components');
|
|
44
|
+
_defineProperty(this, "options", []);
|
|
45
|
+
_defineProperty(this, "group", 'info');
|
|
46
|
+
_defineProperty(this, "commands", []);
|
|
47
|
+
}
|
|
48
|
+
async report([unrecognizedSubcommand]) {
|
|
49
|
+
return _chalk().default.red(`"${unrecognizedSubcommand}" is not a subcommand of "version-history", please run "bit version-history --help" to list the subcommands`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.VersionHistoryCmd = VersionHistoryCmd;
|
|
53
|
+
class VersionHistoryBuildCmd {
|
|
54
|
+
constructor(versionHistoryMain) {
|
|
55
|
+
this.versionHistoryMain = versionHistoryMain;
|
|
56
|
+
_defineProperty(this, "name", 'build <component-pattern>');
|
|
57
|
+
_defineProperty(this, "description", 'rebuild the version history of a component. helpful when it got corrupted for some reason');
|
|
58
|
+
_defineProperty(this, "arguments", [{
|
|
59
|
+
name: 'component-pattern',
|
|
60
|
+
description: _constants().COMPONENT_PATTERN_HELP
|
|
61
|
+
}]);
|
|
62
|
+
_defineProperty(this, "options", [['', 'from-snap <snap>', 'build the version history from a specific snap. the pattern must be a single component-id'], ['', 'from-all-lanes', 'build the version history from the heads of all lanes that include this component'], ['', 'delete-existing', 'delete the existing version history before building it'], ['', 'remote <scope>', 'make the change on the remote scope']]);
|
|
63
|
+
_defineProperty(this, "group", 'info');
|
|
64
|
+
}
|
|
65
|
+
async report([pattern], opts) {
|
|
66
|
+
const results = await this.versionHistoryMain.buildByPattern(pattern, opts);
|
|
67
|
+
const resultsStr = Object.keys(results).map(idStr => {
|
|
68
|
+
const result = results[idStr];
|
|
69
|
+
const getMsg = () => {
|
|
70
|
+
if (result.err) return `failed with an error: ${_chalk().default.red(result.err.message)}`;
|
|
71
|
+
if (!result.added) return 'no changes';
|
|
72
|
+
return `successfully added ${result.added.length} hashes`;
|
|
73
|
+
};
|
|
74
|
+
const msg = getMsg();
|
|
75
|
+
return `${_chalk().default.bold(idStr)}: ${msg}`;
|
|
76
|
+
}).join('\n');
|
|
77
|
+
return `${_chalk().default.green('completed building version history for the following component(s)')}:\n${resultsStr}`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.VersionHistoryBuildCmd = VersionHistoryBuildCmd;
|
|
81
|
+
const colorPerEdgeType = {
|
|
82
|
+
unrelated: 'red',
|
|
83
|
+
squashed: 'blue'
|
|
84
|
+
};
|
|
85
|
+
class VersionHistoryGraphCmd {
|
|
86
|
+
constructor(versionHistoryMain) {
|
|
87
|
+
this.versionHistoryMain = versionHistoryMain;
|
|
88
|
+
_defineProperty(this, "name", 'graph <component-id>');
|
|
89
|
+
_defineProperty(this, "alias", '');
|
|
90
|
+
_defineProperty(this, "description", 'generate a graph of the version history of a component. GraphVis must be installed');
|
|
91
|
+
_defineProperty(this, "options", [['p', 'graph-path <image>', 'image path and format. use one of the following extensions: [gif, png, svg]. default to png in the os tmp dir'], ['l', 'layout <name>', 'GraphVis layout. default to "dot". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]'], ['s', 'short-hash', 'show only 9 chars of the hash'], ['m', 'mark <string>', 'paint the given node-ids in the graph in red color, for multiple, separate by commas']]);
|
|
92
|
+
_defineProperty(this, "group", 'info');
|
|
93
|
+
_defineProperty(this, "commands", []);
|
|
94
|
+
}
|
|
95
|
+
async report([id], {
|
|
96
|
+
mark,
|
|
97
|
+
graphPath,
|
|
98
|
+
layout,
|
|
99
|
+
shortHash
|
|
100
|
+
}) {
|
|
101
|
+
const graphHistory = await this.versionHistoryMain.generateGraph(id, shortHash);
|
|
102
|
+
const markIds = mark ? mark.split(',').map(node => node.trim()) : undefined;
|
|
103
|
+
const config = {
|
|
104
|
+
colorPerEdgeType
|
|
105
|
+
};
|
|
106
|
+
if (layout) config.layout = layout;
|
|
107
|
+
const visualDependencyGraph = await _vizgraph().default.loadFromClearGraph(graphHistory, config, markIds);
|
|
108
|
+
const result = await visualDependencyGraph.image(graphPath);
|
|
109
|
+
return `image created at ${result}`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.VersionHistoryGraphCmd = VersionHistoryGraphCmd;
|
|
113
|
+
class VersionHistoryShowCmd {
|
|
114
|
+
constructor(versionHistoryMain) {
|
|
115
|
+
this.versionHistoryMain = versionHistoryMain;
|
|
116
|
+
_defineProperty(this, "name", 'show <component-id>');
|
|
117
|
+
_defineProperty(this, "alias", 'vh');
|
|
118
|
+
_defineProperty(this, "description", 'show the version-history of a component');
|
|
119
|
+
_defineProperty(this, "options", [['s', 'short-hash', 'show only 9 chars of the hash'], ['j', 'json', 'json format']]);
|
|
120
|
+
_defineProperty(this, "group", 'info');
|
|
121
|
+
_defineProperty(this, "commands", []);
|
|
122
|
+
}
|
|
123
|
+
async report([id], {
|
|
124
|
+
shortHash
|
|
125
|
+
}) {
|
|
126
|
+
const versionHistory = await this.versionHistoryMain.show(id, {
|
|
127
|
+
shortHash
|
|
128
|
+
});
|
|
129
|
+
const output = versionHistory.map(item => {
|
|
130
|
+
const pointers = item.pointers.length ? ` (${_chalk().default.cyan(item.pointers.join(', '))})` : '';
|
|
131
|
+
const edges = item.edges.map(edge => `${edge.hash} (${edge.type})`).join(', ');
|
|
132
|
+
return `${_chalk().default.bold(item.node)}${pointers} ${edges}`;
|
|
133
|
+
}).join('\n');
|
|
134
|
+
return output;
|
|
135
|
+
}
|
|
136
|
+
async json([id]) {
|
|
137
|
+
return (0, _catVersionHistory().catVersionHistory)(id);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.VersionHistoryShowCmd = VersionHistoryShowCmd;
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=version-history-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_constants","data","require","_catVersionHistory","_vizgraph","_interopRequireDefault","_chalk","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","VersionHistoryCmd","constructor","report","unrecognizedSubcommand","chalk","red","exports","VersionHistoryBuildCmd","versionHistoryMain","name","description","COMPONENT_PATTERN_HELP","pattern","opts","results","buildByPattern","resultsStr","keys","map","idStr","result","getMsg","err","message","added","length","msg","bold","join","green","colorPerEdgeType","unrelated","squashed","VersionHistoryGraphCmd","id","mark","graphPath","layout","shortHash","graphHistory","generateGraph","markIds","split","node","trim","undefined","config","visualDependencyGraph","VisualDependencyGraph","loadFromClearGraph","image","VersionHistoryShowCmd","versionHistory","show","output","item","pointers","cyan","edges","edge","hash","type","json","catVersionHistory"],"sources":["version-history-cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport { catVersionHistory } from '@teambit/legacy/dist/api/scope/lib/cat-version-history';\nimport VisualDependencyGraph, { GraphConfig } from '@teambit/legacy/dist/scope/graph/vizgraph';\nimport chalk from 'chalk';\nimport { VersionHistoryMain } from './version-history.main.runtime';\n\nexport class VersionHistoryCmd implements Command {\n name = 'version-history <sub-command>';\n alias = 'vh';\n description = 'manage the version-history of components';\n options = [];\n group = 'info';\n commands: Command[] = [];\n\n async report([unrecognizedSubcommand]: [string]) {\n return chalk.red(\n `\"${unrecognizedSubcommand}\" is not a subcommand of \"version-history\", please run \"bit version-history --help\" to list the subcommands`\n );\n }\n}\n\nexport type BuildOptions = {\n fromSnap?: string;\n deleteExisting?: boolean;\n remote?: string;\n pattern?: string;\n fromAllLanes?: boolean;\n};\n\nexport class VersionHistoryBuildCmd implements Command {\n name = 'build <component-pattern>';\n description = 'rebuild the version history of a component. helpful when it got corrupted for some reason';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n options = [\n [\n '',\n 'from-snap <snap>',\n 'build the version history from a specific snap. the pattern must be a single component-id',\n ],\n ['', 'from-all-lanes', 'build the version history from the heads of all lanes that include this component'],\n ['', 'delete-existing', 'delete the existing version history before building it'],\n ['', 'remote <scope>', 'make the change on the remote scope'],\n ] as CommandOptions;\n group = 'info';\n\n constructor(private versionHistoryMain: VersionHistoryMain) {}\n\n async report([pattern]: [string], opts: BuildOptions) {\n const results = await this.versionHistoryMain.buildByPattern(pattern, opts);\n const resultsStr = Object.keys(results)\n .map((idStr) => {\n const result = results[idStr];\n const getMsg = () => {\n if (result.err) return `failed with an error: ${chalk.red(result.err.message)}`;\n if (!result.added) return 'no changes';\n return `successfully added ${result.added.length} hashes`;\n };\n const msg = getMsg();\n return `${chalk.bold(idStr)}: ${msg}`;\n })\n .join('\\n');\n\n return `${chalk.green('completed building version history for the following component(s)')}:\\n${resultsStr}`;\n }\n}\n\nconst colorPerEdgeType = {\n unrelated: 'red',\n squashed: 'blue',\n};\n\nexport class VersionHistoryGraphCmd implements Command {\n name = 'graph <component-id>';\n alias = '';\n description = 'generate a graph of the version history of a component. GraphVis must be installed';\n options = [\n [\n 'p',\n 'graph-path <image>',\n 'image path and format. use one of the following extensions: [gif, png, svg]. default to png in the os tmp dir',\n ],\n [\n 'l',\n 'layout <name>',\n 'GraphVis layout. default to \"dot\". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]',\n ],\n ['s', 'short-hash', 'show only 9 chars of the hash'],\n ['m', 'mark <string>', 'paint the given node-ids in the graph in red color, for multiple, separate by commas'],\n ] as CommandOptions;\n group = 'info';\n commands: Command[] = [];\n\n constructor(private versionHistoryMain: VersionHistoryMain) {}\n\n async report(\n [id]: [string],\n {\n mark,\n graphPath,\n layout,\n shortHash,\n }: {\n mark?: string;\n graphPath?: string;\n layout?: string;\n shortHash?: boolean;\n }\n ) {\n const graphHistory = await this.versionHistoryMain.generateGraph(id, shortHash);\n const markIds = mark ? mark.split(',').map((node) => node.trim()) : undefined;\n const config: GraphConfig = { colorPerEdgeType };\n if (layout) config.layout = layout;\n const visualDependencyGraph = await VisualDependencyGraph.loadFromClearGraph(graphHistory, config, markIds);\n const result = await visualDependencyGraph.image(graphPath);\n return `image created at ${result}`;\n }\n}\n\nexport type ShowOptions = { shortHash?: boolean };\n\nexport class VersionHistoryShowCmd implements Command {\n name = 'show <component-id>';\n alias = 'vh';\n description = 'show the version-history of a component';\n options = [\n ['s', 'short-hash', 'show only 9 chars of the hash'],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n group = 'info';\n commands: Command[] = [];\n\n constructor(private versionHistoryMain: VersionHistoryMain) {}\n\n async report([id]: [string], { shortHash }: ShowOptions) {\n const versionHistory = await this.versionHistoryMain.show(id, { shortHash });\n const output = versionHistory\n .map((item) => {\n const pointers = item.pointers.length ? ` (${chalk.cyan(item.pointers.join(', '))})` : '';\n const edges = item.edges.map((edge) => `${edge.hash} (${edge.type})`).join(', ');\n return `${chalk.bold(item.node)}${pointers} ${edges}`;\n })\n .join('\\n');\n return output;\n }\n\n async json([id]: [string]) {\n return catVersionHistory(id);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA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CAAC,EAAE;IACvD,MAAMc,cAAc,GAAG,MAAM,IAAI,CAAC5C,kBAAkB,CAAC6C,IAAI,CAACnB,EAAE,EAAE;MAAEI;IAAU,CAAC,CAAC;IAC5E,MAAMgB,MAAM,GAAGF,cAAc,CAC1BlC,GAAG,CAAEqC,IAAI,IAAK;MACb,MAAMC,QAAQ,GAAGD,IAAI,CAACC,QAAQ,CAAC/B,MAAM,GAAI,KAAIrB,gBAAK,CAACqD,IAAI,CAACF,IAAI,CAACC,QAAQ,CAAC5B,IAAI,CAAC,IAAI,CAAC,CAAE,GAAE,GAAG,EAAE;MACzF,MAAM8B,KAAK,GAAGH,IAAI,CAACG,KAAK,CAACxC,GAAG,CAAEyC,IAAI,IAAM,GAAEA,IAAI,CAACC,IAAK,KAAID,IAAI,CAACE,IAAK,GAAE,CAAC,CAACjC,IAAI,CAAC,IAAI,CAAC;MAChF,OAAQ,GAAExB,gBAAK,CAACuB,IAAI,CAAC4B,IAAI,CAACZ,IAAI,CAAE,GAAEa,QAAS,IAAGE,KAAM,EAAC;IACvD,CAAC,CAAC,CACD9B,IAAI,CAAC,IAAI,CAAC;IACb,OAAO0B,MAAM;EACf;EAEA,MAAMQ,IAAIA,CAAC,CAAC5B,EAAE,CAAW,EAAE;IACzB,OAAO,IAAA6B,sCAAiB,EAAC7B,EAAE,CAAC;EAC9B;AACF;AAAC5B,OAAA,CAAA6C,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VersionHistoryAspect = void 0;
|
|
7
|
+
function _harmony() {
|
|
8
|
+
const data = require("@teambit/harmony");
|
|
9
|
+
_harmony = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
const VersionHistoryAspect = exports.VersionHistoryAspect = _harmony().Aspect.create({
|
|
15
|
+
id: 'teambit.scope/version-history'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=version-history.aspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_harmony","data","require","VersionHistoryAspect","exports","Aspect","create","id"],"sources":["version-history.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const VersionHistoryAspect = Aspect.create({\n id: 'teambit.scope/version-history',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EAChDC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
|
2
|
+
import { BuildOptions, ShowOptions } from './version-history-cmd';
|
|
3
|
+
import { ScopeMain } from '@teambit/scope';
|
|
4
|
+
import { ComponentID } from '@teambit/component-id';
|
|
5
|
+
import { VersionHistory } from '@teambit/legacy/dist/scope/models';
|
|
6
|
+
import { Logger, LoggerMain } from '@teambit/logger';
|
|
7
|
+
import { VersionHistoryGraph } from '@teambit/legacy/dist/scope/models/version-history';
|
|
8
|
+
type BuildResult = {
|
|
9
|
+
err?: Error;
|
|
10
|
+
added?: string[];
|
|
11
|
+
};
|
|
12
|
+
type ShowResult = {
|
|
13
|
+
node: string;
|
|
14
|
+
pointers: string[];
|
|
15
|
+
edges: Array<{
|
|
16
|
+
hash: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
export declare class VersionHistoryMain {
|
|
21
|
+
private scope;
|
|
22
|
+
private logger;
|
|
23
|
+
constructor(scope: ScopeMain, logger: Logger);
|
|
24
|
+
build(id: ComponentID, options?: BuildOptions): Promise<BuildResult>;
|
|
25
|
+
show(id: string, options: ShowOptions): Promise<ShowResult[]>;
|
|
26
|
+
get(id: ComponentID): Promise<VersionHistory>;
|
|
27
|
+
generateGraph(id: string, shortHash?: boolean): Promise<VersionHistoryGraph>;
|
|
28
|
+
buildOnRemote(remote: string, pattern: string, options: BuildOptions): Promise<{
|
|
29
|
+
[idStr: string]: BuildResult;
|
|
30
|
+
}>;
|
|
31
|
+
buildByPattern(pattern: string, options: BuildOptions): Promise<{
|
|
32
|
+
[idStr: string]: BuildResult;
|
|
33
|
+
}>;
|
|
34
|
+
static slots: never[];
|
|
35
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
36
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
37
|
+
static provider([cli, scope, loggerMain]: [CLIMain, ScopeMain, LoggerMain]): Promise<VersionHistoryMain>;
|
|
38
|
+
}
|
|
39
|
+
export default VersionHistoryMain;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.VersionHistoryMain = void 0;
|
|
7
|
+
function _cli() {
|
|
8
|
+
const data = _interopRequireWildcard(require("@teambit/cli"));
|
|
9
|
+
_cli = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _getRemoteByName() {
|
|
15
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/remotes/get-remote-by-name"));
|
|
16
|
+
_getRemoteByName = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _consumer() {
|
|
22
|
+
const data = require("@teambit/legacy/dist/consumer");
|
|
23
|
+
_consumer = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _versionHistory() {
|
|
29
|
+
const data = require("./version-history.aspect");
|
|
30
|
+
_versionHistory = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _versionHistoryCmd() {
|
|
36
|
+
const data = require("./version-history-cmd");
|
|
37
|
+
_versionHistoryCmd = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _scope() {
|
|
43
|
+
const data = _interopRequireDefault(require("@teambit/scope"));
|
|
44
|
+
_scope = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _componentId() {
|
|
50
|
+
const data = require("@teambit/component-id");
|
|
51
|
+
_componentId = function () {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
function _bitError() {
|
|
57
|
+
const data = require("@teambit/bit-error");
|
|
58
|
+
_bitError = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
function _objects() {
|
|
64
|
+
const data = require("@teambit/legacy/dist/scope/objects");
|
|
65
|
+
_objects = function () {
|
|
66
|
+
return data;
|
|
67
|
+
};
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
function _action() {
|
|
71
|
+
const data = require("@teambit/legacy/dist/api/scope/lib/action");
|
|
72
|
+
_action = function () {
|
|
73
|
+
return data;
|
|
74
|
+
};
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
function _buildVersionHistoryAction() {
|
|
78
|
+
const data = require("./build-version-history-action");
|
|
79
|
+
_buildVersionHistoryAction = function () {
|
|
80
|
+
return data;
|
|
81
|
+
};
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
84
|
+
function _logger() {
|
|
85
|
+
const data = require("@teambit/logger");
|
|
86
|
+
_logger = function () {
|
|
87
|
+
return data;
|
|
88
|
+
};
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
91
|
+
function _lodash() {
|
|
92
|
+
const data = require("lodash");
|
|
93
|
+
_lodash = function () {
|
|
94
|
+
return data;
|
|
95
|
+
};
|
|
96
|
+
return data;
|
|
97
|
+
}
|
|
98
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
99
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
100
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
101
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
102
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
103
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
104
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
105
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
106
|
+
class VersionHistoryMain {
|
|
107
|
+
constructor(scope, logger) {
|
|
108
|
+
this.scope = scope;
|
|
109
|
+
this.logger = logger;
|
|
110
|
+
}
|
|
111
|
+
async build(id, options = {}) {
|
|
112
|
+
const {
|
|
113
|
+
fromSnap
|
|
114
|
+
} = options;
|
|
115
|
+
const modelComponent = await this.scope.getBitObjectModelComponent(id.changeVersion(undefined), true);
|
|
116
|
+
const from = fromSnap ? _objects().Ref.from(fromSnap) : modelComponent.getHead();
|
|
117
|
+
if (!from) {
|
|
118
|
+
throw new (_bitError().BitError)(`error: ${id.toString()} has no head and "fromSnap" is not provided`);
|
|
119
|
+
}
|
|
120
|
+
const repo = this.scope.legacyScope.objects;
|
|
121
|
+
let versionHistory = await modelComponent.getVersionHistory(repo);
|
|
122
|
+
if (options.deleteExisting) {
|
|
123
|
+
await this.scope.legacyScope.objects.moveObjectsToTrash([versionHistory.hash()]);
|
|
124
|
+
versionHistory = await modelComponent.getVersionHistory(repo);
|
|
125
|
+
}
|
|
126
|
+
const isGraphComplete = versionHistory.isGraphCompleteSince(from);
|
|
127
|
+
if (isGraphComplete) {
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
await this.scope.legacyScope.scopeImporter.importWithoutDeps(_componentId().ComponentIdList.fromArray([id]), {
|
|
131
|
+
cache: false,
|
|
132
|
+
includeVersionHistory: true,
|
|
133
|
+
collectParents: true,
|
|
134
|
+
reason: 'to retrieve missing versions'
|
|
135
|
+
});
|
|
136
|
+
const results = await modelComponent.populateVersionHistoryIfMissingGracefully(repo, versionHistory, from, false);
|
|
137
|
+
const added = results.added?.map(a => a.hash.toString()) || [];
|
|
138
|
+
if (added.length) this.logger.debug(`version-history: added ${added.length} hashes to ${id.toString()}:\n${added.join('\n')}`);
|
|
139
|
+
if (options.fromAllLanes) {
|
|
140
|
+
const lanes = await this.scope.legacyScope.lanes.listLanes();
|
|
141
|
+
for await (const lane of lanes) {
|
|
142
|
+
const headOnLane = lane.getComponentHead(id);
|
|
143
|
+
if (!headOnLane) continue;
|
|
144
|
+
const laneResults = await modelComponent.populateVersionHistoryIfMissingGracefully(repo, versionHistory, headOnLane, false);
|
|
145
|
+
const laneAdded = laneResults.added?.map(a => a.hash.toString());
|
|
146
|
+
if (laneAdded) {
|
|
147
|
+
this.logger.debug(`version-history: added ${laneAdded.length} hashes from lane "${lane.name}":\n${laneAdded.join('\n')}`);
|
|
148
|
+
added.push(...laneAdded);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
err: results.err,
|
|
154
|
+
added
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async show(id, options) {
|
|
158
|
+
const graph = await this.generateGraph(id, options.shortHash);
|
|
159
|
+
const results = graph.toposort().map(node => {
|
|
160
|
+
const metadata = typeof node.attr === 'string' ? undefined : node.attr;
|
|
161
|
+
const pointers = (0, _lodash().compact)([...(metadata?.pointers || []), metadata?.tag]);
|
|
162
|
+
const edges = graph.outEdges(node.id).map(e => ({
|
|
163
|
+
hash: e.targetId,
|
|
164
|
+
type: e.attr
|
|
165
|
+
}));
|
|
166
|
+
return {
|
|
167
|
+
node: node.id,
|
|
168
|
+
pointers,
|
|
169
|
+
edges
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
return results;
|
|
173
|
+
}
|
|
174
|
+
async get(id) {
|
|
175
|
+
const modelComponent = await this.scope.getBitObjectModelComponent(id, true);
|
|
176
|
+
const repo = this.scope.legacyScope.objects;
|
|
177
|
+
const versionHistory = modelComponent.getVersionHistory(repo);
|
|
178
|
+
return versionHistory;
|
|
179
|
+
}
|
|
180
|
+
async generateGraph(id, shortHash) {
|
|
181
|
+
const compId = await this.scope.resolveComponentId(id);
|
|
182
|
+
const modelComponent = await this.scope.getBitObjectModelComponent(compId, true);
|
|
183
|
+
const repo = this.scope.legacyScope.objects;
|
|
184
|
+
const versionHistory = await modelComponent.getVersionHistory(repo);
|
|
185
|
+
const lanePerRef = await repo.remoteLanes.getRefsPerLaneId(compId);
|
|
186
|
+
if (modelComponent.head) {
|
|
187
|
+
lanePerRef.main = modelComponent.head;
|
|
188
|
+
}
|
|
189
|
+
// convert to hash per lane
|
|
190
|
+
const laneHeads = {};
|
|
191
|
+
Object.keys(lanePerRef).forEach(lane => {
|
|
192
|
+
const hash = lanePerRef[lane].toString();
|
|
193
|
+
if (!laneHeads[hash]) laneHeads[hash] = [];
|
|
194
|
+
laneHeads[hash].push(lane);
|
|
195
|
+
});
|
|
196
|
+
return versionHistory.getGraph(modelComponent, laneHeads, shortHash);
|
|
197
|
+
}
|
|
198
|
+
async buildOnRemote(remote, pattern, options) {
|
|
199
|
+
const maybeConsumer = await (0, _consumer().loadConsumerIfExist)();
|
|
200
|
+
const remoteObj = await (0, _getRemoteByName().default)(remote, maybeConsumer);
|
|
201
|
+
const remoteOptions = _objectSpread({
|
|
202
|
+
pattern
|
|
203
|
+
}, options);
|
|
204
|
+
const result = await remoteObj.action('BuildVersionHistoryAction', remoteOptions);
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
async buildByPattern(pattern, options) {
|
|
208
|
+
const {
|
|
209
|
+
remote
|
|
210
|
+
} = options;
|
|
211
|
+
if (remote) {
|
|
212
|
+
delete options.remote;
|
|
213
|
+
return this.buildOnRemote(remote, pattern, options);
|
|
214
|
+
}
|
|
215
|
+
const ids = await this.scope.idsByPattern(pattern);
|
|
216
|
+
if (ids.length > 1 && options.fromSnap) {
|
|
217
|
+
throw new (_bitError().BitError)(`to use the "--from-snap" flag, please provide a single component-id, not a pattern`);
|
|
218
|
+
}
|
|
219
|
+
const results = {};
|
|
220
|
+
for await (const id of ids) {
|
|
221
|
+
const result = await this.build(id, options);
|
|
222
|
+
results[id.toString()] = result;
|
|
223
|
+
}
|
|
224
|
+
return results;
|
|
225
|
+
}
|
|
226
|
+
static async provider([cli, scope, loggerMain]) {
|
|
227
|
+
const logger = loggerMain.createLogger(_versionHistory().VersionHistoryAspect.id);
|
|
228
|
+
const versionHistory = new VersionHistoryMain(scope, logger);
|
|
229
|
+
const versionHistoryCmd = new (_versionHistoryCmd().VersionHistoryCmd)();
|
|
230
|
+
versionHistoryCmd.commands = [new (_versionHistoryCmd().VersionHistoryGraphCmd)(versionHistory), new (_versionHistoryCmd().VersionHistoryShowCmd)(versionHistory), new (_versionHistoryCmd().VersionHistoryBuildCmd)(versionHistory)];
|
|
231
|
+
cli.register(versionHistoryCmd);
|
|
232
|
+
_action().ExternalActions.externalActions.push(new (_buildVersionHistoryAction().BuildVersionHistoryAction)(versionHistory));
|
|
233
|
+
return versionHistory;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.VersionHistoryMain = VersionHistoryMain;
|
|
237
|
+
_defineProperty(VersionHistoryMain, "slots", []);
|
|
238
|
+
_defineProperty(VersionHistoryMain, "dependencies", [_cli().default, _scope().default, _logger().LoggerAspect]);
|
|
239
|
+
_defineProperty(VersionHistoryMain, "runtime", _cli().MainRuntime);
|
|
240
|
+
_versionHistory().VersionHistoryAspect.addRuntime(VersionHistoryMain);
|
|
241
|
+
var _default = exports.default = VersionHistoryMain;
|
|
242
|
+
|
|
243
|
+
//# sourceMappingURL=version-history.main.runtime.js.map
|