@teambit/component-log 1.0.106 → 1.0.108

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.
@@ -0,0 +1,5 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+
3
+ export const ComponentLogAspect = Aspect.create({
4
+ id: 'teambit.component/component-log',
5
+ });
@@ -0,0 +1,252 @@
1
+ import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
2
+ import { ComponentID } from '@teambit/component-id';
3
+ import { LegacyComponentLog as ComponentLog } from '@teambit/legacy-component-log';
4
+ import path from 'path';
5
+ import moment from 'moment';
6
+ import pMap from 'p-map';
7
+ import WorkspaceAspect, { OutsideWorkspaceError, Workspace } from '@teambit/workspace';
8
+ import { compact } from 'lodash';
9
+ import pMapSeries from 'p-map-series';
10
+ import { Version } from '@teambit/legacy/dist/scope/models';
11
+ import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils/path';
12
+ import { Ref } from '@teambit/legacy/dist/scope/objects';
13
+ import { getFilesDiff } from '@teambit/legacy/dist/consumer/component-ops/components-diff';
14
+ import chalk from 'chalk';
15
+ import getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';
16
+ import { ComponentLogAspect } from './component-log.aspect';
17
+ import LogCmd from './log-cmd';
18
+ import { buildSnapGraph } from './snap-graph';
19
+ import { LogFileCmd } from './log-file-cmd';
20
+
21
+ export type FileLog = {
22
+ hash: string;
23
+ tag?: string;
24
+ username?: string;
25
+ email?: string;
26
+ date: string;
27
+ message: string;
28
+ fileHash: string;
29
+ parentFileHash?: string;
30
+ fileDiff?: string;
31
+ };
32
+
33
+ export type FileHashDiffFromParent = {
34
+ filePath: string; // path OS absolute
35
+ hash?: string; // if undefined, the file was deleted in this snap
36
+ parentHash?: string; // if undefined, the file was added in this snap
37
+ };
38
+
39
+ export class ComponentLogMain {
40
+ constructor(private workspace: Workspace | undefined) {}
41
+
42
+ /**
43
+ * get component log sorted by the timestamp in ascending order (from the earliest to the latest)
44
+ */
45
+ async getLogs(id: string, isRemote?: boolean, shortHash = false): Promise<ComponentLog[]> {
46
+ if (isRemote) {
47
+ const consumer = this.workspace?.consumer;
48
+ const bitId = ComponentID.fromString(id);
49
+ const remote = await getRemoteByName(bitId.scope as string, consumer);
50
+ return remote.log(bitId);
51
+ }
52
+ if (!this.workspace) throw new OutsideWorkspaceError();
53
+ const componentId = await this.workspace.resolveComponentId(id);
54
+ const logs = await this.workspace.scope.getLogs(componentId, shortHash);
55
+ logs.forEach((log) => {
56
+ log.date = log.date ? moment(new Date(parseInt(log.date))).format('YYYY-MM-DD HH:mm:ss') : undefined;
57
+ });
58
+ return logs;
59
+ }
60
+
61
+ async getLogsWithParents(id: string, fullHash = false) {
62
+ const logs = await this.getLogs(id, false, !fullHash);
63
+ const graph = buildSnapGraph(logs);
64
+ const sorted = graph.toposort();
65
+ return sorted.map((node) => this.stringifyLogInfoOneLine(node.attr));
66
+ }
67
+
68
+ async getChangedFilesFromParent(id: string): Promise<FileHashDiffFromParent[]> {
69
+ const workspace = this.workspace;
70
+ if (!workspace) throw new OutsideWorkspaceError();
71
+ const componentId = await workspace.resolveComponentId(id);
72
+ const modelComp = await workspace.scope.getBitObjectModelComponent(componentId, true);
73
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
74
+ const versionObj = (await workspace.scope.getBitObjectVersion(modelComp!, componentId.version!, true)) as Version;
75
+ const firstParent = versionObj.parents[0];
76
+ const parentObj = firstParent
77
+ ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
78
+ ((await workspace.scope.getBitObjectVersion(modelComp!, firstParent.toString(), true)) as Version)
79
+ : null;
80
+ const compDir = workspace.componentDir(componentId, { ignoreVersion: true });
81
+ const results: FileHashDiffFromParent[] = compact(
82
+ versionObj.files.map((file) => {
83
+ const parentFile = parentObj?.files.find((f) => f.relativePath === file.relativePath);
84
+ if (parentFile?.file.isEqual(file.file)) return null;
85
+ return {
86
+ filePath: path.join(compDir, file.relativePath),
87
+ hash: file.file.toString(),
88
+ parentHash: parentFile?.file.toString(),
89
+ };
90
+ })
91
+ );
92
+ const filesOnParentOnly = (parentObj?.files || []).filter(
93
+ (parentFile) => !versionObj.files.find((file) => file.relativePath === parentFile.relativePath)
94
+ );
95
+ if (filesOnParentOnly.length) {
96
+ results.push(
97
+ ...filesOnParentOnly.map((file) => ({
98
+ filePath: file.relativePath,
99
+ hash: undefined,
100
+ parentHash: file.file.toString(),
101
+ }))
102
+ );
103
+ }
104
+
105
+ return results;
106
+ }
107
+
108
+ async getFileHistoryHashes(filePath: string): Promise<FileLog[]> {
109
+ const workspace = this.workspace;
110
+ if (!workspace) throw new OutsideWorkspaceError();
111
+ const componentId = await workspace.getComponentIdByPath(filePath);
112
+ if (!componentId) {
113
+ // filePath could be from the component dir but the file is not part of the bit-component (such as component.json)
114
+ return [];
115
+ }
116
+
117
+ const rootDir = workspace.componentDir(componentId, undefined);
118
+
119
+ const logs = await this.getLogs(componentId.toString());
120
+
121
+ const filePathAsLinux = pathNormalizeToLinux(filePath);
122
+ const filePathRelativeInComponent = filePathAsLinux.replace(`${rootDir}/`, '');
123
+
124
+ const modelComp = await workspace.scope.getBitObjectModelComponent(componentId);
125
+ if (!modelComp) return []; // probably a new component
126
+ const results: FileLog[] = [];
127
+ await pMap(
128
+ logs,
129
+ async (logItem) => {
130
+ const versionObj = await workspace.scope.getBitObjectVersion(modelComp, logItem.hash, true);
131
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
132
+ const fileInComp = versionObj!.files.find((f) => f.relativePath === filePathRelativeInComponent);
133
+ if (!fileInComp) return;
134
+ const fileHash = fileInComp.file.toString();
135
+ const getFileHashFromParent = async (parent: Ref) => {
136
+ const parentObj = parent
137
+ ? await workspace.scope.getBitObjectVersion(modelComp, parent.toString(), true)
138
+ : undefined;
139
+
140
+ const parentFileInComp = parentObj
141
+ ? parentObj.files.find((f) => f.relativePath === filePathRelativeInComponent)
142
+ : undefined;
143
+
144
+ return parentFileInComp?.file.toString();
145
+ };
146
+ const fileHashesFromParent = versionObj ? await Promise.all(versionObj.parents.map(getFileHashFromParent)) : [];
147
+
148
+ const getParentFileHash = () => {
149
+ if (fileHashesFromParent.length === 0) return undefined;
150
+ if (fileHashesFromParent.length === 1) return fileHashesFromParent[0];
151
+ // if one parent has it, it means that this merge-snap didn't change the file.
152
+ if (fileHashesFromParent.includes(fileHash)) return fileHash;
153
+ return fileHashesFromParent[0];
154
+ };
155
+
156
+ results.push({
157
+ hash: logItem.hash,
158
+ tag: logItem.tag,
159
+ username: logItem.username,
160
+ email: logItem.email,
161
+ date: logItem.date || '<N/A>',
162
+ message: logItem.message,
163
+ fileHash,
164
+ parentFileHash: getParentFileHash(),
165
+ });
166
+ },
167
+ { concurrency: 100 }
168
+ );
169
+
170
+ // remove entries that their fileHash is the same as their parent.
171
+ return results.filter((r) => r.fileHash !== r.parentFileHash);
172
+ }
173
+
174
+ async getFileLog(filePath: string) {
175
+ const workspace = this.workspace;
176
+ if (!workspace) throw new OutsideWorkspaceError();
177
+ const componentId = await workspace.getComponentIdByPath(filePath);
178
+ if (!componentId) throw new Error(`unable to find component for file ${filePath}`);
179
+
180
+ const rootDir = workspace.componentDir(componentId, undefined, { relative: true });
181
+
182
+ const logs = await this.getLogs(componentId.toString());
183
+
184
+ const filePathAsLinux = pathNormalizeToLinux(filePath);
185
+ const filePathRelativeInComponent = filePathAsLinux.replace(`${rootDir}/`, '');
186
+
187
+ const results: FileLog[] = [];
188
+ let lastFile;
189
+ await pMapSeries(logs, async (logItem) => {
190
+ const component = await workspace.get(componentId.changeVersion(logItem.tag || logItem.hash));
191
+ const fileInComp = component.filesystem.files.find((f) => f.relative === filePathRelativeInComponent);
192
+ const lastResult = results[results.length - 1];
193
+ const lastHash = lastResult?.fileHash;
194
+ let fileHash: string;
195
+ if (!fileInComp) {
196
+ if (!lastHash) return;
197
+ fileHash = '<REMOVED>';
198
+ } else {
199
+ fileHash = fileInComp.toSourceAsLinuxEOL().hash().toString();
200
+ }
201
+ if (fileHash === lastHash) return;
202
+
203
+ let diff;
204
+ if (lastFile && fileInComp) {
205
+ diff = await getFilesDiff([lastFile], [fileInComp], logItem.hash, lastResult.hash, undefined);
206
+ }
207
+
208
+ lastFile = fileInComp;
209
+
210
+ results.push({
211
+ hash: logItem.hash,
212
+ tag: logItem.tag,
213
+ username: logItem.username,
214
+ email: logItem.email,
215
+ date: logItem.date || '<N/A>',
216
+ message: logItem.message,
217
+ fileDiff: diff?.length ? diff[0].diffOutput : undefined,
218
+ fileHash,
219
+ });
220
+ });
221
+ return results;
222
+ }
223
+
224
+ private stringifyLogInfoOneLine(logInfo: ComponentLogInfo) {
225
+ const parents = logInfo.parents.length ? `Parent(s): ${logInfo.parents.join(', ')}` : '<N/A>';
226
+ return `${chalk.yellow(logInfo.hash)} ${logInfo.username || ''} ${logInfo.date || ''} ${
227
+ logInfo.message
228
+ }, ${parents}`;
229
+ }
230
+
231
+ static slots = [];
232
+ static dependencies = [CLIAspect, WorkspaceAspect];
233
+ static runtime = MainRuntime;
234
+ static async provider([cli, workspace]: [CLIMain, Workspace]) {
235
+ const componentLog = new ComponentLogMain(workspace);
236
+ cli.register(new LogCmd(componentLog), new LogFileCmd(componentLog));
237
+ return componentLog;
238
+ }
239
+ }
240
+
241
+ ComponentLogAspect.addRuntime(ComponentLogMain);
242
+
243
+ export type ComponentLogInfo = {
244
+ hash: string;
245
+ message: string;
246
+ onLane?: boolean;
247
+ parents: string[];
248
+ username?: string;
249
+ email?: string;
250
+ date?: string;
251
+ tag?: string;
252
+ };
@@ -1,2 +1,2 @@
1
- import React from 'react';
2
- export declare const Logo: () => React.JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const Logo: () => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { CLIMain } from '@teambit/cli';
2
2
  import { LegacyComponentLog as ComponentLog } from '@teambit/legacy-component-log';
3
3
  import { Workspace } from '@teambit/workspace';
4
- export declare type FileLog = {
4
+ export type FileLog = {
5
5
  hash: string;
6
6
  tag?: string;
7
7
  username?: string;
@@ -12,7 +12,7 @@ export declare type FileLog = {
12
12
  parentFileHash?: string;
13
13
  fileDiff?: string;
14
14
  };
15
- export declare type FileHashDiffFromParent = {
15
+ export type FileHashDiffFromParent = {
16
16
  filePath: string;
17
17
  hash?: string;
18
18
  parentHash?: string;
@@ -29,12 +29,12 @@ export declare class ComponentLogMain {
29
29
  getFileHistoryHashes(filePath: string): Promise<FileLog[]>;
30
30
  getFileLog(filePath: string): Promise<FileLog[]>;
31
31
  private stringifyLogInfoOneLine;
32
- static slots: never[];
32
+ static slots: any[];
33
33
  static dependencies: import("@teambit/harmony").Aspect[];
34
34
  static runtime: import("@teambit/harmony").RuntimeDefinition;
35
35
  static provider([cli, workspace]: [CLIMain, Workspace]): Promise<ComponentLogMain>;
36
36
  }
37
- export declare type ComponentLogInfo = {
37
+ export type ComponentLogInfo = {
38
38
  hash: string;
39
39
  message: string;
40
40
  onLane?: boolean;
@@ -132,8 +132,7 @@ class ComponentLogMain {
132
132
  */
133
133
  async getLogs(id, isRemote, shortHash = false) {
134
134
  if (isRemote) {
135
- var _this$workspace;
136
- const consumer = (_this$workspace = this.workspace) === null || _this$workspace === void 0 ? void 0 : _this$workspace.consumer;
135
+ const consumer = this.workspace?.consumer;
137
136
  const bitId = _componentId().ComponentID.fromString(id);
138
137
  const remote = await (0, _getRemoteByName().default)(bitId.scope, consumer);
139
138
  return remote.log(bitId);
@@ -167,15 +166,15 @@ class ComponentLogMain {
167
166
  ignoreVersion: true
168
167
  });
169
168
  const results = (0, _lodash().compact)(versionObj.files.map(file => {
170
- const parentFile = parentObj === null || parentObj === void 0 ? void 0 : parentObj.files.find(f => f.relativePath === file.relativePath);
171
- if (parentFile !== null && parentFile !== void 0 && parentFile.file.isEqual(file.file)) return null;
169
+ const parentFile = parentObj?.files.find(f => f.relativePath === file.relativePath);
170
+ if (parentFile?.file.isEqual(file.file)) return null;
172
171
  return {
173
172
  filePath: _path().default.join(compDir, file.relativePath),
174
173
  hash: file.file.toString(),
175
- parentHash: parentFile === null || parentFile === void 0 ? void 0 : parentFile.file.toString()
174
+ parentHash: parentFile?.file.toString()
176
175
  };
177
176
  }));
178
- const filesOnParentOnly = ((parentObj === null || parentObj === void 0 ? void 0 : parentObj.files) || []).filter(parentFile => !versionObj.files.find(file => file.relativePath === parentFile.relativePath));
177
+ const filesOnParentOnly = (parentObj?.files || []).filter(parentFile => !versionObj.files.find(file => file.relativePath === parentFile.relativePath));
179
178
  if (filesOnParentOnly.length) {
180
179
  results.push(...filesOnParentOnly.map(file => ({
181
180
  filePath: file.relativePath,
@@ -209,7 +208,7 @@ class ComponentLogMain {
209
208
  const getFileHashFromParent = async parent => {
210
209
  const parentObj = parent ? await workspace.scope.getBitObjectVersion(modelComp, parent.toString(), true) : undefined;
211
210
  const parentFileInComp = parentObj ? parentObj.files.find(f => f.relativePath === filePathRelativeInComponent) : undefined;
212
- return parentFileInComp === null || parentFileInComp === void 0 ? void 0 : parentFileInComp.file.toString();
211
+ return parentFileInComp?.file.toString();
213
212
  };
214
213
  const fileHashesFromParent = versionObj ? await Promise.all(versionObj.parents.map(getFileHashFromParent)) : [];
215
214
  const getParentFileHash = () => {
@@ -250,11 +249,10 @@ class ComponentLogMain {
250
249
  const results = [];
251
250
  let lastFile;
252
251
  await (0, _pMapSeries().default)(logs, async logItem => {
253
- var _diff;
254
252
  const component = await workspace.get(componentId.changeVersion(logItem.tag || logItem.hash));
255
253
  const fileInComp = component.filesystem.files.find(f => f.relative === filePathRelativeInComponent);
256
254
  const lastResult = results[results.length - 1];
257
- const lastHash = lastResult === null || lastResult === void 0 ? void 0 : lastResult.fileHash;
255
+ const lastHash = lastResult?.fileHash;
258
256
  let fileHash;
259
257
  if (!fileInComp) {
260
258
  if (!lastHash) return;
@@ -275,7 +273,7 @@ class ComponentLogMain {
275
273
  email: logItem.email,
276
274
  date: logItem.date || '<N/A>',
277
275
  message: logItem.message,
278
- fileDiff: (_diff = diff) !== null && _diff !== void 0 && _diff.length ? diff[0].diffOutput : undefined,
276
+ fileDiff: diff?.length ? diff[0].diffOutput : undefined,
279
277
  fileHash
280
278
  });
281
279
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_cli","data","require","_componentId","_path","_interopRequireDefault","_moment","_pMap","_workspace","_interopRequireWildcard","_lodash","_pMapSeries","_path2","_componentsDiff","_chalk","_getRemoteByName","_componentLog","_logCmd","_snapGraph","_logFileCmd","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_defineProperty","key","value","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","ComponentLogMain","constructor","workspace","getLogs","id","isRemote","shortHash","_this$workspace","consumer","bitId","ComponentID","fromString","remote","getRemoteByName","scope","log","OutsideWorkspaceError","componentId","resolveComponentId","logs","forEach","date","moment","Date","parseInt","format","undefined","getLogsWithParents","fullHash","graph","buildSnapGraph","sorted","toposort","map","node","stringifyLogInfoOneLine","attr","getChangedFilesFromParent","modelComp","getBitObjectModelComponent","versionObj","getBitObjectVersion","version","firstParent","parents","parentObj","toString","compDir","componentDir","ignoreVersion","results","compact","files","file","parentFile","find","f","relativePath","isEqual","filePath","path","join","hash","parentHash","filesOnParentOnly","filter","length","push","getFileHistoryHashes","getComponentIdByPath","rootDir","filePathAsLinux","pathNormalizeToLinux","filePathRelativeInComponent","replace","pMap","logItem","fileInComp","fileHash","getFileHashFromParent","parent","parentFileInComp","fileHashesFromParent","Promise","all","getParentFileHash","includes","tag","username","email","message","parentFileHash","concurrency","getFileLog","Error","relative","lastFile","pMapSeries","_diff","component","changeVersion","filesystem","lastResult","lastHash","toSourceAsLinuxEOL","diff","getFilesDiff","fileDiff","diffOutput","logInfo","chalk","yellow","provider","cli","componentLog","register","LogCmd","LogFileCmd","exports","CLIAspect","WorkspaceAspect","MainRuntime","ComponentLogAspect","addRuntime"],"sources":["component-log.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component-id';\nimport { LegacyComponentLog as ComponentLog } from '@teambit/legacy-component-log';\nimport path from 'path';\nimport moment from 'moment';\nimport pMap from 'p-map';\nimport WorkspaceAspect, { OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { compact } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Version } from '@teambit/legacy/dist/scope/models';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils/path';\nimport { Ref } from '@teambit/legacy/dist/scope/objects';\nimport { getFilesDiff } from '@teambit/legacy/dist/consumer/component-ops/components-diff';\nimport chalk from 'chalk';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\nimport { ComponentLogAspect } from './component-log.aspect';\nimport LogCmd from './log-cmd';\nimport { buildSnapGraph } from './snap-graph';\nimport { LogFileCmd } from './log-file-cmd';\n\nexport type FileLog = {\n hash: string;\n tag?: string;\n username?: string;\n email?: string;\n date: string;\n message: string;\n fileHash: string;\n parentFileHash?: string;\n fileDiff?: string;\n};\n\nexport type FileHashDiffFromParent = {\n filePath: string; // path OS absolute\n hash?: string; // if undefined, the file was deleted in this snap\n parentHash?: string; // if undefined, the file was added in this snap\n};\n\nexport class ComponentLogMain {\n constructor(private workspace: Workspace | undefined) {}\n\n /**\n * get component log sorted by the timestamp in ascending order (from the earliest to the latest)\n */\n async getLogs(id: string, isRemote?: boolean, shortHash = false): Promise<ComponentLog[]> {\n if (isRemote) {\n const consumer = this.workspace?.consumer;\n const bitId = ComponentID.fromString(id);\n const remote = await getRemoteByName(bitId.scope as string, consumer);\n return remote.log(bitId);\n }\n if (!this.workspace) throw new OutsideWorkspaceError();\n const componentId = await this.workspace.resolveComponentId(id);\n const logs = await this.workspace.scope.getLogs(componentId, shortHash);\n logs.forEach((log) => {\n log.date = log.date ? moment(new Date(parseInt(log.date))).format('YYYY-MM-DD HH:mm:ss') : undefined;\n });\n return logs;\n }\n\n async getLogsWithParents(id: string, fullHash = false) {\n const logs = await this.getLogs(id, false, !fullHash);\n const graph = buildSnapGraph(logs);\n const sorted = graph.toposort();\n return sorted.map((node) => this.stringifyLogInfoOneLine(node.attr));\n }\n\n async getChangedFilesFromParent(id: string): Promise<FileHashDiffFromParent[]> {\n const workspace = this.workspace;\n if (!workspace) throw new OutsideWorkspaceError();\n const componentId = await workspace.resolveComponentId(id);\n const modelComp = await workspace.scope.getBitObjectModelComponent(componentId, true);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const versionObj = (await workspace.scope.getBitObjectVersion(modelComp!, componentId.version!, true)) as Version;\n const firstParent = versionObj.parents[0];\n const parentObj = firstParent\n ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n ((await workspace.scope.getBitObjectVersion(modelComp!, firstParent.toString(), true)) as Version)\n : null;\n const compDir = workspace.componentDir(componentId, { ignoreVersion: true });\n const results: FileHashDiffFromParent[] = compact(\n versionObj.files.map((file) => {\n const parentFile = parentObj?.files.find((f) => f.relativePath === file.relativePath);\n if (parentFile?.file.isEqual(file.file)) return null;\n return {\n filePath: path.join(compDir, file.relativePath),\n hash: file.file.toString(),\n parentHash: parentFile?.file.toString(),\n };\n })\n );\n const filesOnParentOnly = (parentObj?.files || []).filter(\n (parentFile) => !versionObj.files.find((file) => file.relativePath === parentFile.relativePath)\n );\n if (filesOnParentOnly.length) {\n results.push(\n ...filesOnParentOnly.map((file) => ({\n filePath: file.relativePath,\n hash: undefined,\n parentHash: file.file.toString(),\n }))\n );\n }\n\n return results;\n }\n\n async getFileHistoryHashes(filePath: string): Promise<FileLog[]> {\n const workspace = this.workspace;\n if (!workspace) throw new OutsideWorkspaceError();\n const componentId = await workspace.getComponentIdByPath(filePath);\n if (!componentId) {\n // filePath could be from the component dir but the file is not part of the bit-component (such as component.json)\n return [];\n }\n\n const rootDir = workspace.componentDir(componentId, undefined);\n\n const logs = await this.getLogs(componentId.toString());\n\n const filePathAsLinux = pathNormalizeToLinux(filePath);\n const filePathRelativeInComponent = filePathAsLinux.replace(`${rootDir}/`, '');\n\n const modelComp = await workspace.scope.getBitObjectModelComponent(componentId);\n if (!modelComp) return []; // probably a new component\n const results: FileLog[] = [];\n await pMap(\n logs,\n async (logItem) => {\n const versionObj = await workspace.scope.getBitObjectVersion(modelComp, logItem.hash, true);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const fileInComp = versionObj!.files.find((f) => f.relativePath === filePathRelativeInComponent);\n if (!fileInComp) return;\n const fileHash = fileInComp.file.toString();\n const getFileHashFromParent = async (parent: Ref) => {\n const parentObj = parent\n ? await workspace.scope.getBitObjectVersion(modelComp, parent.toString(), true)\n : undefined;\n\n const parentFileInComp = parentObj\n ? parentObj.files.find((f) => f.relativePath === filePathRelativeInComponent)\n : undefined;\n\n return parentFileInComp?.file.toString();\n };\n const fileHashesFromParent = versionObj ? await Promise.all(versionObj.parents.map(getFileHashFromParent)) : [];\n\n const getParentFileHash = () => {\n if (fileHashesFromParent.length === 0) return undefined;\n if (fileHashesFromParent.length === 1) return fileHashesFromParent[0];\n // if one parent has it, it means that this merge-snap didn't change the file.\n if (fileHashesFromParent.includes(fileHash)) return fileHash;\n return fileHashesFromParent[0];\n };\n\n results.push({\n hash: logItem.hash,\n tag: logItem.tag,\n username: logItem.username,\n email: logItem.email,\n date: logItem.date || '<N/A>',\n message: logItem.message,\n fileHash,\n parentFileHash: getParentFileHash(),\n });\n },\n { concurrency: 100 }\n );\n\n // remove entries that their fileHash is the same as their parent.\n return results.filter((r) => r.fileHash !== r.parentFileHash);\n }\n\n async getFileLog(filePath: string) {\n const workspace = this.workspace;\n if (!workspace) throw new OutsideWorkspaceError();\n const componentId = await workspace.getComponentIdByPath(filePath);\n if (!componentId) throw new Error(`unable to find component for file ${filePath}`);\n\n const rootDir = workspace.componentDir(componentId, undefined, { relative: true });\n\n const logs = await this.getLogs(componentId.toString());\n\n const filePathAsLinux = pathNormalizeToLinux(filePath);\n const filePathRelativeInComponent = filePathAsLinux.replace(`${rootDir}/`, '');\n\n const results: FileLog[] = [];\n let lastFile;\n await pMapSeries(logs, async (logItem) => {\n const component = await workspace.get(componentId.changeVersion(logItem.tag || logItem.hash));\n const fileInComp = component.filesystem.files.find((f) => f.relative === filePathRelativeInComponent);\n const lastResult = results[results.length - 1];\n const lastHash = lastResult?.fileHash;\n let fileHash: string;\n if (!fileInComp) {\n if (!lastHash) return;\n fileHash = '<REMOVED>';\n } else {\n fileHash = fileInComp.toSourceAsLinuxEOL().hash().toString();\n }\n if (fileHash === lastHash) return;\n\n let diff;\n if (lastFile && fileInComp) {\n diff = await getFilesDiff([lastFile], [fileInComp], logItem.hash, lastResult.hash, undefined);\n }\n\n lastFile = fileInComp;\n\n results.push({\n hash: logItem.hash,\n tag: logItem.tag,\n username: logItem.username,\n email: logItem.email,\n date: logItem.date || '<N/A>',\n message: logItem.message,\n fileDiff: diff?.length ? diff[0].diffOutput : undefined,\n fileHash,\n });\n });\n return results;\n }\n\n private stringifyLogInfoOneLine(logInfo: ComponentLogInfo) {\n const parents = logInfo.parents.length ? `Parent(s): ${logInfo.parents.join(', ')}` : '<N/A>';\n return `${chalk.yellow(logInfo.hash)} ${logInfo.username || ''} ${logInfo.date || ''} ${\n logInfo.message\n }, ${parents}`;\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace]: [CLIMain, Workspace]) {\n const componentLog = new ComponentLogMain(workspace);\n cli.register(new LogCmd(componentLog), new LogFileCmd(componentLog));\n return componentLog;\n }\n}\n\nComponentLogAspect.addRuntime(ComponentLogMain);\n\nexport type ComponentLogInfo = {\n hash: string;\n message: string;\n onLane?: boolean;\n parents: string[];\n username?: string;\n email?: string;\n date?: string;\n tag?: string;\n};\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,O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interopRequireDefault","_moment","_pMap","_workspace","_interopRequireWildcard","_lodash","_pMapSeries","_path2","_componentsDiff","_chalk","_getRemoteByName","_componentLog","_logCmd","_snapGraph","_logFileCmd","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_defineProperty","key","value","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","ComponentLogMain","constructor","workspace","getLogs","id","isRemote","shortHash","consumer","bitId","ComponentID","fromString","remote","getRemoteByName","scope","log","OutsideWorkspaceError","componentId","resolveComponentId","logs","forEach","date","moment","Date","parseInt","format","undefined","getLogsWithParents","fullHash","graph","buildSnapGraph","sorted","toposort","map","node","stringifyLogInfoOneLine","attr","getChangedFilesFromParent","modelComp","getBitObjectModelComponent","versionObj","getBitObjectVersion","version","firstParent","parents","parentObj","toString","compDir","componentDir","ignoreVersion","results","compact","files","file","parentFile","find","f","relativePath","isEqual","filePath","path","join","hash","parentHash","filesOnParentOnly","filter","length","push","getFileHistoryHashes","getComponentIdByPath","rootDir","filePathAsLinux","pathNormalizeToLinux","filePathRelativeInComponent","replace","pMap","logItem","fileInComp","fileHash","getFileHashFromParent","parent","parentFileInComp","fileHashesFromParent","Promise","all","getParentFileHash","includes","tag","username","email","message","parentFileHash","concurrency","getFileLog","Error","relative","lastFile","pMapSeries","component","changeVersion","filesystem","lastResult","lastHash","toSourceAsLinuxEOL","diff","getFilesDiff","fileDiff","diffOutput","logInfo","chalk","yellow","provider","cli","componentLog","register","LogCmd","LogFileCmd","exports","CLIAspect","WorkspaceAspect","MainRuntime","ComponentLogAspect","addRuntime"],"sources":["component-log.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component-id';\nimport { LegacyComponentLog as ComponentLog } from '@teambit/legacy-component-log';\nimport path from 'path';\nimport moment from 'moment';\nimport pMap from 'p-map';\nimport WorkspaceAspect, { OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { compact } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Version } from '@teambit/legacy/dist/scope/models';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils/path';\nimport { Ref } from '@teambit/legacy/dist/scope/objects';\nimport { getFilesDiff } from '@teambit/legacy/dist/consumer/component-ops/components-diff';\nimport chalk from 'chalk';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\nimport { ComponentLogAspect } from './component-log.aspect';\nimport LogCmd from './log-cmd';\nimport { buildSnapGraph } from './snap-graph';\nimport { LogFileCmd } from './log-file-cmd';\n\nexport type FileLog = {\n hash: string;\n tag?: string;\n username?: string;\n email?: string;\n date: string;\n message: string;\n fileHash: string;\n parentFileHash?: string;\n fileDiff?: string;\n};\n\nexport type FileHashDiffFromParent = {\n filePath: string; // path OS absolute\n hash?: string; // if undefined, the file was deleted in this snap\n parentHash?: string; // if undefined, the file was added in this snap\n};\n\nexport class ComponentLogMain {\n constructor(private workspace: Workspace | undefined) {}\n\n /**\n * get component log sorted by the timestamp in ascending order (from the earliest to the latest)\n */\n async getLogs(id: string, isRemote?: boolean, shortHash = false): Promise<ComponentLog[]> {\n if (isRemote) {\n const consumer = this.workspace?.consumer;\n const bitId = ComponentID.fromString(id);\n const remote = await getRemoteByName(bitId.scope as string, consumer);\n return remote.log(bitId);\n }\n if (!this.workspace) throw new OutsideWorkspaceError();\n const componentId = await this.workspace.resolveComponentId(id);\n const logs = await this.workspace.scope.getLogs(componentId, shortHash);\n logs.forEach((log) => {\n log.date = log.date ? moment(new Date(parseInt(log.date))).format('YYYY-MM-DD HH:mm:ss') : undefined;\n });\n return logs;\n }\n\n async getLogsWithParents(id: string, fullHash = false) {\n const logs = await this.getLogs(id, false, !fullHash);\n const graph = buildSnapGraph(logs);\n const sorted = graph.toposort();\n return sorted.map((node) => this.stringifyLogInfoOneLine(node.attr));\n }\n\n async getChangedFilesFromParent(id: string): Promise<FileHashDiffFromParent[]> {\n const workspace = this.workspace;\n if (!workspace) throw new OutsideWorkspaceError();\n const componentId = await workspace.resolveComponentId(id);\n const modelComp = await workspace.scope.getBitObjectModelComponent(componentId, true);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const versionObj = (await workspace.scope.getBitObjectVersion(modelComp!, componentId.version!, true)) as Version;\n const firstParent = versionObj.parents[0];\n const parentObj = firstParent\n ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n ((await workspace.scope.getBitObjectVersion(modelComp!, firstParent.toString(), true)) as Version)\n : null;\n const compDir = workspace.componentDir(componentId, { ignoreVersion: true });\n const results: FileHashDiffFromParent[] = compact(\n versionObj.files.map((file) => {\n const parentFile = parentObj?.files.find((f) => f.relativePath === file.relativePath);\n if (parentFile?.file.isEqual(file.file)) return null;\n return {\n filePath: path.join(compDir, file.relativePath),\n hash: file.file.toString(),\n parentHash: parentFile?.file.toString(),\n };\n })\n );\n const filesOnParentOnly = (parentObj?.files || []).filter(\n (parentFile) => !versionObj.files.find((file) => file.relativePath === parentFile.relativePath)\n );\n if (filesOnParentOnly.length) {\n results.push(\n ...filesOnParentOnly.map((file) => ({\n filePath: file.relativePath,\n hash: undefined,\n parentHash: file.file.toString(),\n }))\n );\n }\n\n return results;\n }\n\n async getFileHistoryHashes(filePath: string): Promise<FileLog[]> {\n const workspace = this.workspace;\n if (!workspace) throw new OutsideWorkspaceError();\n const componentId = await workspace.getComponentIdByPath(filePath);\n if (!componentId) {\n // filePath could be from the component dir but the file is not part of the bit-component (such as component.json)\n return [];\n }\n\n const rootDir = workspace.componentDir(componentId, undefined);\n\n const logs = await this.getLogs(componentId.toString());\n\n const filePathAsLinux = pathNormalizeToLinux(filePath);\n const filePathRelativeInComponent = filePathAsLinux.replace(`${rootDir}/`, '');\n\n const modelComp = await workspace.scope.getBitObjectModelComponent(componentId);\n if (!modelComp) return []; // probably a new component\n const results: FileLog[] = [];\n await pMap(\n logs,\n async (logItem) => {\n const versionObj = await workspace.scope.getBitObjectVersion(modelComp, logItem.hash, true);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const fileInComp = versionObj!.files.find((f) => f.relativePath === filePathRelativeInComponent);\n if (!fileInComp) return;\n const fileHash = fileInComp.file.toString();\n const getFileHashFromParent = async (parent: Ref) => {\n const parentObj = parent\n ? await workspace.scope.getBitObjectVersion(modelComp, parent.toString(), true)\n : undefined;\n\n const parentFileInComp = parentObj\n ? parentObj.files.find((f) => f.relativePath === filePathRelativeInComponent)\n : undefined;\n\n return parentFileInComp?.file.toString();\n };\n const fileHashesFromParent = versionObj ? await Promise.all(versionObj.parents.map(getFileHashFromParent)) : [];\n\n const getParentFileHash = () => {\n if (fileHashesFromParent.length === 0) return undefined;\n if (fileHashesFromParent.length === 1) return fileHashesFromParent[0];\n // if one parent has it, it means that this merge-snap didn't change the file.\n if (fileHashesFromParent.includes(fileHash)) return fileHash;\n return fileHashesFromParent[0];\n };\n\n results.push({\n hash: logItem.hash,\n tag: logItem.tag,\n username: logItem.username,\n email: logItem.email,\n date: logItem.date || '<N/A>',\n message: logItem.message,\n fileHash,\n parentFileHash: getParentFileHash(),\n });\n },\n { concurrency: 100 }\n );\n\n // remove entries that their fileHash is the same as their parent.\n return results.filter((r) => r.fileHash !== r.parentFileHash);\n }\n\n async getFileLog(filePath: string) {\n const workspace = this.workspace;\n if (!workspace) throw new OutsideWorkspaceError();\n const componentId = await workspace.getComponentIdByPath(filePath);\n if (!componentId) throw new Error(`unable to find component for file ${filePath}`);\n\n const rootDir = workspace.componentDir(componentId, undefined, { relative: true });\n\n const logs = await this.getLogs(componentId.toString());\n\n const filePathAsLinux = pathNormalizeToLinux(filePath);\n const filePathRelativeInComponent = filePathAsLinux.replace(`${rootDir}/`, '');\n\n const results: FileLog[] = [];\n let lastFile;\n await pMapSeries(logs, async (logItem) => {\n const component = await workspace.get(componentId.changeVersion(logItem.tag || logItem.hash));\n const fileInComp = component.filesystem.files.find((f) => f.relative === filePathRelativeInComponent);\n const lastResult = results[results.length - 1];\n const lastHash = lastResult?.fileHash;\n let fileHash: string;\n if (!fileInComp) {\n if (!lastHash) return;\n fileHash = '<REMOVED>';\n } else {\n fileHash = fileInComp.toSourceAsLinuxEOL().hash().toString();\n }\n if (fileHash === lastHash) return;\n\n let diff;\n if (lastFile && fileInComp) {\n diff = await getFilesDiff([lastFile], [fileInComp], logItem.hash, lastResult.hash, undefined);\n }\n\n lastFile = fileInComp;\n\n results.push({\n hash: logItem.hash,\n tag: logItem.tag,\n username: logItem.username,\n email: logItem.email,\n date: logItem.date || '<N/A>',\n message: logItem.message,\n fileDiff: diff?.length ? diff[0].diffOutput : undefined,\n fileHash,\n });\n });\n return results;\n }\n\n private stringifyLogInfoOneLine(logInfo: ComponentLogInfo) {\n const parents = logInfo.parents.length ? `Parent(s): ${logInfo.parents.join(', ')}` : '<N/A>';\n return `${chalk.yellow(logInfo.hash)} ${logInfo.username || ''} ${logInfo.date || ''} ${\n logInfo.message\n }, ${parents}`;\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace]: [CLIMain, Workspace]) {\n const componentLog = new ComponentLogMain(workspace);\n cli.register(new LogCmd(componentLog), new LogFileCmd(componentLog));\n return componentLog;\n }\n}\n\nComponentLogAspect.addRuntime(ComponentLogMain);\n\nexport type ComponentLogInfo = {\n hash: string;\n message: string;\n onLane?: boolean;\n parents: string[];\n username?: string;\n email?: string;\n date?: string;\n tag?: string;\n};\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAA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,gBAAK,CAACC,MAAM,CAACF,OAAO,CAAC9C,IAAI,CAAE,IAAG8C,OAAO,CAACpB,QAAQ,IAAI,EAAG,IAAGoB,OAAO,CAACvF,IAAI,IAAI,EAAG,IACnFuF,OAAO,CAAClB,OACT,KAAI9C,OAAQ,EAAC;EAChB;EAKA,aAAamE,QAAQA,CAAC,CAACC,GAAG,EAAE7G,SAAS,CAAuB,EAAE;IAC5D,MAAM8G,YAAY,GAAG,IAAIhH,gBAAgB,CAACE,SAAS,CAAC;IACpD6G,GAAG,CAACE,QAAQ,CAAC,KAAIC,iBAAM,EAACF,YAAY,CAAC,EAAE,KAAIG,wBAAU,EAACH,YAAY,CAAC,CAAC;IACpE,OAAOA,YAAY;EACrB;AACF;AAACI,OAAA,CAAApH,gBAAA,GAAAA,gBAAA;AAAAb,eAAA,CAxMYa,gBAAgB,WAgMZ,EAAE;AAAAb,eAAA,CAhMNa,gBAAgB,kBAiML,CAACqH,gBAAS,EAAEC,oBAAe,CAAC;AAAAnI,eAAA,CAjMvCa,gBAAgB,aAkMVuH,kBAAW;AAQ9BC,kCAAkB,CAACC,UAAU,CAACzH,gBAAgB,CAAC"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component-log@1.0.106/dist/component-log.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component-log@1.0.106/dist/component-log.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component-log@1.0.108/dist/component-log.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component-log@1.0.108/dist/component-log.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { ComponentLogAspect } from './component-log.aspect';
2
+
3
+ export type { ComponentLogMain, FileHashDiffFromParent } from './component-log.main.runtime';
4
+ export default ComponentLogAspect;
5
+ export { ComponentLogAspect };
package/log-cmd.ts ADDED
@@ -0,0 +1,117 @@
1
+ import c from 'chalk';
2
+ import Table from 'cli-table';
3
+ import { Command, CommandOptions } from '@teambit/cli';
4
+ import { LegacyComponentLog } from '@teambit/legacy-component-log';
5
+ import { ComponentLogMain } from './component-log.main.runtime';
6
+
7
+ export default class LogCmd implements Command {
8
+ name = 'log <id>';
9
+ description = 'show components(s) version history';
10
+ helpUrl = 'reference/components/navigating-history';
11
+ extendedDescription: string;
12
+ group = 'info';
13
+ alias = '';
14
+ options = [
15
+ ['r', 'remote', 'show log of a remote component'],
16
+ ['', 'parents', 'show parents and lanes data'],
17
+ ['o', 'one-line', 'show each log entry in one line'],
18
+ ['f', 'full-hash', 'show full hash of the snap (default to the first 9 characters for --one-line/--parents flags)'],
19
+ ['j', 'json', 'json format'],
20
+ ] as CommandOptions;
21
+ migration = true;
22
+ remoteOp = true; // should support log against remote
23
+ skipWorkspace = true;
24
+ arguments = [{ name: 'id', description: 'component-id or component-name' }];
25
+
26
+ constructor(private componentLog: ComponentLogMain) {}
27
+
28
+ async report(
29
+ [id]: [string],
30
+ {
31
+ remote = false,
32
+ parents = false,
33
+ oneLine = false,
34
+ fullHash = false,
35
+ }: { remote: boolean; parents: boolean; oneLine?: boolean; fullHash?: boolean }
36
+ ) {
37
+ if (!parents && !oneLine) fullHash = true;
38
+ if (parents) {
39
+ const logs = await this.componentLog.getLogsWithParents(id, fullHash);
40
+ return logs.join('\n');
41
+ }
42
+ const logs = await this.componentLog.getLogs(id, remote, !fullHash);
43
+ if (oneLine) {
44
+ return logOneLine(logs.reverse());
45
+ }
46
+ // reverse to show from the latest to earliest
47
+ return logs.reverse().map(paintLog).join('\n');
48
+ }
49
+
50
+ async json([id]: [string], { remote = false, parents = false }: { remote: boolean; parents: boolean }) {
51
+ if (parents) {
52
+ return this.componentLog.getLogsWithParents(id);
53
+ }
54
+ return this.componentLog.getLogs(id, remote);
55
+ }
56
+ }
57
+
58
+ export function paintAuthor(email: string | null | undefined, username: string | null | undefined) {
59
+ if (email && username) {
60
+ return c.white(`author: ${username} <${email}>\n`);
61
+ }
62
+ if (email && !username) {
63
+ return c.white(`author: <${email}>\n`);
64
+ }
65
+ if (!email && username) {
66
+ return c.white(`author: ${username}\n`);
67
+ }
68
+
69
+ return '';
70
+ }
71
+
72
+ function paintLog(log: LegacyComponentLog): string {
73
+ const { message, date, tag, hash, username, email } = log;
74
+ const title = tag ? `tag ${tag} (${hash})\n` : `snap ${hash}\n`;
75
+ return (
76
+ c.yellow(title) +
77
+ paintAuthor(email, username) +
78
+ (date ? c.white(`date: ${date}\n`) : '') +
79
+ (message ? c.white(`\n ${message}\n`) : '')
80
+ );
81
+ }
82
+
83
+ /**
84
+ * table with no style and no borders, just to align the columns.
85
+ */
86
+ export function getEmptyTableWithoutStyle() {
87
+ return new Table({
88
+ chars: {
89
+ top: '',
90
+ 'top-mid': '',
91
+ 'top-left': '',
92
+ 'top-right': '',
93
+ bottom: '',
94
+ 'bottom-mid': '',
95
+ 'bottom-left': '',
96
+ 'bottom-right': '',
97
+ left: '',
98
+ 'left-mid': '',
99
+ mid: '',
100
+ 'mid-mid': '',
101
+ right: '',
102
+ 'right-mid': '',
103
+ middle: ' ',
104
+ },
105
+ style: { 'padding-left': 0, 'padding-right': 0 },
106
+ });
107
+ }
108
+
109
+ function logOneLine(logs: LegacyComponentLog[]) {
110
+ const table = getEmptyTableWithoutStyle();
111
+
112
+ logs.map(({ hash, tag, username, date, message }) =>
113
+ table.push([hash, tag || '', username || '', date || '', message || ''])
114
+ );
115
+
116
+ return table.toString();
117
+ }
@@ -0,0 +1,42 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import chalk from 'chalk';
3
+ import { ComponentLogMain } from './component-log.main.runtime';
4
+ import { getEmptyTableWithoutStyle, paintAuthor } from './log-cmd';
5
+
6
+ export class LogFileCmd implements Command {
7
+ name = 'log-file <filepath>';
8
+ description = 'EXPERIMENTAL. show file history';
9
+ group = 'info';
10
+ alias = '';
11
+ options = [['o', 'one-line', 'show each log entry in one line']] as CommandOptions;
12
+ arguments = [{ name: 'filepath', description: 'file path relative to the workspace' }];
13
+
14
+ constructor(private componentLog: ComponentLogMain) {}
15
+
16
+ async report([filePath]: [string], { oneLine = false }: { oneLine?: boolean }) {
17
+ const results = await this.componentLog.getFileLog(filePath);
18
+ if (oneLine) {
19
+ const table = getEmptyTableWithoutStyle();
20
+ results.forEach(({ hash, tag, username, date, message, fileHash }) => {
21
+ table.push([hash, tag || '', username || '', date, message, fileHash]);
22
+ });
23
+ return table.toString();
24
+ }
25
+ const output = results.map(({ hash, tag, username, email, date, message, fileDiff }) => {
26
+ const title = tag ? `tag ${tag} (${hash})\n` : `snap ${hash}\n`;
27
+ const author = paintAuthor(email, username);
28
+ const body = (fileDiff || chalk.green('<FILE-ADDED>'))
29
+ .split('\n')
30
+ .map((line) => ` ${line}`)
31
+ .join('\n');
32
+ return (
33
+ chalk.yellow(title) +
34
+ author +
35
+ (date ? chalk.white(`date: ${date}\n`) : '') +
36
+ (message ? chalk.white(`message: ${message}\n\n`) : '\n') +
37
+ body
38
+ );
39
+ });
40
+ return output.join('\n');
41
+ }
42
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component-log",
3
- "version": "1.0.106",
3
+ "version": "1.0.108",
4
4
  "homepage": "https://bit.cloud/teambit/component/component-log",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "component-log",
9
- "version": "1.0.106"
9
+ "version": "1.0.108"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -15,29 +15,25 @@
15
15
  "p-map-series": "2.1.0",
16
16
  "p-map": "4.0.0",
17
17
  "cli-table": "0.3.6",
18
- "core-js": "^3.0.0",
19
- "@babel/runtime": "7.20.0",
20
18
  "@teambit/harmony": "0.4.6",
21
19
  "@teambit/component-id": "1.2.0",
22
20
  "@teambit/legacy-component-log": "0.0.402",
23
21
  "@teambit/graph.cleargraph": "0.0.1",
24
- "@teambit/cli": "0.0.839",
25
- "@teambit/workspace": "1.0.106"
22
+ "@teambit/cli": "0.0.840",
23
+ "@teambit/workspace": "1.0.108"
26
24
  },
27
25
  "devDependencies": {
28
- "@types/react": "^17.0.8",
29
26
  "@types/lodash": "4.14.165",
30
27
  "@types/cli-table": "^0.3.0",
31
28
  "@types/mocha": "9.1.0",
32
- "@types/node": "12.20.4",
33
- "@types/react-dom": "^17.0.5",
34
- "@types/jest": "^26.0.0",
35
- "@types/testing-library__jest-dom": "5.9.5"
29
+ "@types/jest": "^29.2.2",
30
+ "@types/testing-library__jest-dom": "^5.9.5",
31
+ "@teambit/harmony.envs.core-aspect-env": "0.0.13"
36
32
  },
37
33
  "peerDependencies": {
38
- "@teambit/legacy": "1.0.624",
39
- "react": "^16.8.0 || ^17.0.0",
40
- "react-dom": "^16.8.0 || ^17.0.0"
34
+ "react": "^17.0.0 || ^18.0.0",
35
+ "@types/react": "^18.2.12",
36
+ "@teambit/legacy": "1.0.624"
41
37
  },
42
38
  "license": "Apache-2.0",
43
39
  "optionalDependencies": {},
@@ -51,7 +47,7 @@
51
47
  },
52
48
  "private": false,
53
49
  "engines": {
54
- "node": ">=12.22.0"
50
+ "node": ">=16.0.0"
55
51
  },
56
52
  "repository": {
57
53
  "type": "git",
@@ -60,12 +56,9 @@
60
56
  "keywords": [
61
57
  "bit",
62
58
  "bit-aspect",
59
+ "bit-core-aspect",
63
60
  "components",
64
61
  "collaboration",
65
- "web",
66
- "react",
67
- "react-components",
68
- "angular",
69
- "angular-components"
62
+ "web"
70
63
  ]
71
64
  }
package/snap-graph.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { Graph, Node, Edge } from '@teambit/graph.cleargraph';
2
+ import { ComponentLogInfo } from './component-log.main.runtime';
3
+
4
+ export function buildSnapGraph(componentLog: ComponentLogInfo[]) {
5
+ const graph = new Graph<ComponentLogInfo, string>();
6
+ // add nodes
7
+ componentLog.forEach((snap) => {
8
+ graph.setNode(new Node(snap.hash, snap));
9
+ });
10
+ // add edges
11
+ componentLog.forEach((snap) => {
12
+ snap.parents.forEach((parent) => {
13
+ graph.setEdge(new Edge(snap.hash, parent, 'parent'));
14
+ });
15
+ });
16
+ return graph;
17
+ }
package/tsconfig.json CHANGED
@@ -1,38 +1,33 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
4
+ "esnext",
5
+ "dom",
6
+ "dom.Iterable"
9
7
  ],
10
- "target": "es2015",
11
- "module": "CommonJS",
12
- "jsx": "react",
13
- "allowJs": true,
14
- "composite": true,
8
+ "target": "es2020",
9
+ "module": "es2020",
10
+ "jsx": "react-jsx",
15
11
  "declaration": true,
16
12
  "sourceMap": true,
17
- "skipLibCheck": true,
18
13
  "experimentalDecorators": true,
19
- "outDir": "dist",
14
+ "skipLibCheck": true,
20
15
  "moduleResolution": "node",
21
16
  "esModuleInterop": true,
22
- "rootDir": ".",
23
17
  "resolveJsonModule": true,
24
- "emitDeclarationOnly": true,
25
- "emitDecoratorMetadata": true,
26
- "allowSyntheticDefaultImports": true,
27
- "strictPropertyInitialization": false,
28
- "strict": true,
29
- "noImplicitAny": false,
30
- "preserveConstEnums": true
18
+ "allowJs": true,
19
+ "outDir": "dist",
20
+ "emitDeclarationOnly": true
31
21
  },
32
22
  "exclude": [
23
+ "artifacts",
24
+ "public",
33
25
  "dist",
26
+ "node_modules",
27
+ "package.json",
34
28
  "esm.mjs",
35
- "package.json"
29
+ "**/*.cjs",
30
+ "./dist"
36
31
  ],
37
32
  "include": [
38
33
  "**/*",
package/types/asset.d.ts CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
5
5
  declare module '*.svg' {
6
6
  import type { FunctionComponent, SVGProps } from 'react';
7
7
 
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
9
11
  const src: string;
10
12
  export default src;
11
13
  }
12
-
13
- // @TODO Gilad
14
14
  declare module '*.jpg' {
15
15
  const value: any;
16
16
  export = value;
@@ -27,3 +27,15 @@ declare module '*.bmp' {
27
27
  const value: any;
28
28
  export = value;
29
29
  }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }