@herodevs/cli 0.2.2 → 0.2.3-rc1
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/main.js +959 -0
- package/package.json +14 -115
- package/README.md +0 -35
- package/bin/dev +0 -17
- package/bin/dev.cmd +0 -3
- package/bin/run +0 -5
- package/bin/run.cmd +0 -3
- package/dist/commands/report/committers.d.ts +0 -19
- package/dist/commands/report/committers.js +0 -190
- package/dist/commands/tracker/init.d.ts +0 -8
- package/dist/commands/tracker/init.js +0 -16
- package/dist/commands/tracker/run.d.ts +0 -11
- package/dist/commands/tracker/run.js +0 -37
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -5
- package/dist/package.json +0 -120
- package/dist/shared/command/base-command.d.ts +0 -22
- package/dist/shared/command/base-command.js +0 -47
- package/dist/shared/command/index.d.ts +0 -1
- package/dist/shared/command/index.js +0 -4
- package/dist/shared/config/environment.d.ts +0 -4
- package/dist/shared/config/environment.js +0 -10
- package/dist/shared/config/index.d.ts +0 -1
- package/dist/shared/config/index.js +0 -4
- package/dist/shared/enums/index.d.ts +0 -1
- package/dist/shared/enums/index.js +0 -4
- package/dist/shared/enums/log-colors.d.ts +0 -28
- package/dist/shared/enums/log-colors.js +0 -9
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared/index.js +0 -7
- package/dist/shared/lib/index.d.ts +0 -2
- package/dist/shared/lib/index.js +0 -5
- package/dist/shared/lib/shell.d.ts +0 -7
- package/dist/shared/lib/shell.js +0 -34
- package/dist/shared/lib/version-update.d.ts +0 -3
- package/dist/shared/lib/version-update.js +0 -52
- package/dist/shared/tracker/default-config.d.ts +0 -3
- package/dist/shared/tracker/default-config.js +0 -19
- package/dist/shared/tracker/initialize.d.ts +0 -1
- package/dist/shared/tracker/initialize.js +0 -15
- package/dist/shared/tracker/models/aggregate-result.d.ts +0 -4
- package/dist/shared/tracker/models/aggregate-result.js +0 -2
- package/dist/shared/tracker/models/category-result.d.ts +0 -7
- package/dist/shared/tracker/models/category-result.js +0 -2
- package/dist/shared/tracker/models/category.d.ts +0 -9
- package/dist/shared/tracker/models/category.js +0 -2
- package/dist/shared/tracker/models/chart-config.d.ts +0 -24
- package/dist/shared/tracker/models/chart-config.js +0 -65
- package/dist/shared/tracker/models/config.d.ts +0 -8
- package/dist/shared/tracker/models/config.js +0 -2
- package/dist/shared/tracker/models/file-result.d.ts +0 -5
- package/dist/shared/tracker/models/file-result.js +0 -2
- package/dist/shared/tracker/models/process-result.d.ts +0 -6
- package/dist/shared/tracker/models/process-result.js +0 -2
- package/dist/shared/tracker/models/result.d.ts +0 -11
- package/dist/shared/tracker/models/result.js +0 -2
- package/dist/shared/tracker/models/total-result.d.ts +0 -4
- package/dist/shared/tracker/models/total-result.js +0 -2
- package/dist/shared/tracker/models/viz-dataset.d.ts +0 -4
- package/dist/shared/tracker/models/viz-dataset.js +0 -2
- package/dist/shared/tracker/models/viz-labels-datasets.d.ts +0 -5
- package/dist/shared/tracker/models/viz-labels-datasets.js +0 -2
- package/dist/shared/tracker/process-category.d.ts +0 -3
- package/dist/shared/tracker/process-category.js +0 -155
- package/dist/shared/tracker/process-config.d.ts +0 -3
- package/dist/shared/tracker/process-config.js +0 -16
- package/dist/shared/tracker/tracker-chart.d.ts +0 -0
- package/dist/shared/tracker/tracker-chart.js +0 -156
- package/dist/shared/tracker/util.d.ts +0 -17
- package/dist/shared/tracker/util.js +0 -98
- package/dist/shared/types/flags.type.d.ts +0 -4
- package/dist/shared/types/flags.type.js +0 -2
- package/dist/shared/types/index.d.ts +0 -1
- package/dist/shared/types/index.js +0 -4
- package/oclif.manifest.json +0 -118
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processCategory = void 0;
|
|
4
|
-
const sloc = require("sloc");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
function processCategory(rootDirectory, category, ignorePatterns) {
|
|
8
|
-
console.log(`Processing "${category.name}"...`);
|
|
9
|
-
const allFiles = category.includes.reduce((acc, include) => {
|
|
10
|
-
return [...acc, ...findAllFilesInDirectory((0, path_1.join)(rootDirectory, include))];
|
|
11
|
-
}, []);
|
|
12
|
-
const includedFiles = findIncludedFiles(category, ignorePatterns, allFiles);
|
|
13
|
-
console.log(` ${includedFiles.length} files...`);
|
|
14
|
-
const results = includedFiles.map(getFileStats);
|
|
15
|
-
const resultMap = aggregateResults(results);
|
|
16
|
-
const aggregatedResults = Object.values(resultMap).map((val) => val);
|
|
17
|
-
const totals = aggregatedResults.reduce((totals, curr) => ({
|
|
18
|
-
fileCount: totals.fileCount + curr.fileCount,
|
|
19
|
-
total: totals.total + curr.total,
|
|
20
|
-
source: totals.source + curr.source,
|
|
21
|
-
comment: totals.comment + curr.comment,
|
|
22
|
-
single: totals.single + curr.single,
|
|
23
|
-
block: totals.block + curr.block,
|
|
24
|
-
mixed: totals.mixed + curr.mixed,
|
|
25
|
-
empty: totals.empty + curr.empty,
|
|
26
|
-
todo: totals.todo + curr.todo,
|
|
27
|
-
blockEmpty: totals.blockEmpty + curr.blockEmpty,
|
|
28
|
-
}), {
|
|
29
|
-
fileCount: 0,
|
|
30
|
-
total: 0,
|
|
31
|
-
source: 0,
|
|
32
|
-
comment: 0,
|
|
33
|
-
single: 0,
|
|
34
|
-
block: 0,
|
|
35
|
-
mixed: 0,
|
|
36
|
-
empty: 0,
|
|
37
|
-
todo: 0,
|
|
38
|
-
blockEmpty: 0,
|
|
39
|
-
});
|
|
40
|
-
const final = {
|
|
41
|
-
name: category.name,
|
|
42
|
-
totals: totals,
|
|
43
|
-
fileTypes: aggregatedResults,
|
|
44
|
-
};
|
|
45
|
-
console.log(` ${final.totals.total} total lines`);
|
|
46
|
-
return final;
|
|
47
|
-
}
|
|
48
|
-
exports.processCategory = processCategory;
|
|
49
|
-
function aggregateResults(results) {
|
|
50
|
-
return results.reduce((acc, result) => {
|
|
51
|
-
const fileTypeResults = acc[result.fileType];
|
|
52
|
-
if (!fileTypeResults) {
|
|
53
|
-
acc[result.fileType] = {
|
|
54
|
-
fileType: result.fileType,
|
|
55
|
-
fileCount: 1,
|
|
56
|
-
total: result.total,
|
|
57
|
-
source: result.source,
|
|
58
|
-
comment: result.comment,
|
|
59
|
-
single: result.single,
|
|
60
|
-
block: result.block,
|
|
61
|
-
mixed: result.mixed,
|
|
62
|
-
empty: result.empty,
|
|
63
|
-
todo: result.todo,
|
|
64
|
-
blockEmpty: result.blockEmpty,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
acc[result.fileType] = {
|
|
69
|
-
fileType: result.fileType,
|
|
70
|
-
fileCount: fileTypeResults.fileCount + 1,
|
|
71
|
-
total: fileTypeResults.total + result.total,
|
|
72
|
-
source: fileTypeResults.source + result.source,
|
|
73
|
-
comment: fileTypeResults.comment + result.comment,
|
|
74
|
-
single: fileTypeResults.single + result.single,
|
|
75
|
-
block: fileTypeResults.block + result.block,
|
|
76
|
-
mixed: fileTypeResults.mixed + result.mixed,
|
|
77
|
-
empty: fileTypeResults.empty + result.empty,
|
|
78
|
-
todo: fileTypeResults.todo + result.todo,
|
|
79
|
-
blockEmpty: fileTypeResults.blockEmpty + result.blockEmpty,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return acc;
|
|
83
|
-
}, {});
|
|
84
|
-
}
|
|
85
|
-
function getFileStats(file) {
|
|
86
|
-
const contents = (0, fs_1.readFileSync)(file).toString('utf-8');
|
|
87
|
-
const fileType = getFileExt(file);
|
|
88
|
-
const stats = sloc(contents, fileType);
|
|
89
|
-
return {
|
|
90
|
-
path: file,
|
|
91
|
-
fileType: fileType,
|
|
92
|
-
...stats,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function findIncludedFiles(category, ignorePatterns, allFiles) {
|
|
96
|
-
return allFiles
|
|
97
|
-
.filter((file) => {
|
|
98
|
-
var _a;
|
|
99
|
-
const ext = getFileExt(file);
|
|
100
|
-
let shouldBeIncluded = !!category.fileTypes.find((fileType) => fileType === ext);
|
|
101
|
-
if (shouldBeIncluded) {
|
|
102
|
-
ignorePatterns === null || ignorePatterns === void 0 ? void 0 : ignorePatterns.forEach((ignorePattern) => {
|
|
103
|
-
if (file.indexOf(ignorePattern) !== -1) {
|
|
104
|
-
shouldBeIncluded = false;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
if (shouldBeIncluded) {
|
|
109
|
-
(_a = category.excludes) === null || _a === void 0 ? void 0 : _a.forEach((exclude) => {
|
|
110
|
-
if (file.indexOf(exclude) !== -1) {
|
|
111
|
-
shouldBeIncluded = false;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return shouldBeIncluded;
|
|
116
|
-
})
|
|
117
|
-
.filter((file, _index, files) => {
|
|
118
|
-
if (category.jsTsPairs === 'ignore' || category.jsTsPairs === undefined) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
const fileExtToKeep = category.jsTsPairs;
|
|
122
|
-
const ext = getFileExt(file);
|
|
123
|
-
const fileExtToDiscard = fileExtToKeep === 'js' ? 'ts' : 'js';
|
|
124
|
-
// if it is the extension to keep
|
|
125
|
-
// or if it is not the one to discard, we keep those files
|
|
126
|
-
if (fileExtToKeep === ext || fileExtToDiscard !== ext) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
// get the counterpart's extension
|
|
130
|
-
const counterpartExt = ext === 'js' ? 'ts' : 'js';
|
|
131
|
-
const parts = file.split('.');
|
|
132
|
-
parts[parts.length - 1] = counterpartExt;
|
|
133
|
-
const counterpartExists = files.filter((f) => f === parts.join('.')).length !== 0;
|
|
134
|
-
if (counterpartExists) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function findAllFilesInDirectory(directory) {
|
|
141
|
-
const results = (0, fs_1.readdirSync)(directory);
|
|
142
|
-
const subfiles = results
|
|
143
|
-
.filter((result) => (0, fs_1.lstatSync)((0, path_1.join)(directory, result)).isDirectory())
|
|
144
|
-
.reduce((acc, subdir) => {
|
|
145
|
-
const files = findAllFilesInDirectory((0, path_1.join)(directory, subdir));
|
|
146
|
-
return [...acc, ...files];
|
|
147
|
-
}, []);
|
|
148
|
-
const files = results
|
|
149
|
-
.filter((result) => (0, fs_1.lstatSync)((0, path_1.join)(directory, result)).isFile())
|
|
150
|
-
.map((fileName) => (0, path_1.join)(directory, fileName));
|
|
151
|
-
return [...files, ...subfiles];
|
|
152
|
-
}
|
|
153
|
-
function getFileExt(file) {
|
|
154
|
-
return (0, path_1.extname)(file).replace(/\./g, '');
|
|
155
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processConfig = void 0;
|
|
4
|
-
const process_category_1 = require("./process-category");
|
|
5
|
-
const util_1 = require("./util");
|
|
6
|
-
async function processConfig(config, rootDirectory) {
|
|
7
|
-
console.log(`Starting...`);
|
|
8
|
-
const categoryResults = Object.entries(config.categories).map(([name, category]) => (0, process_category_1.processCategory)(rootDirectory, { ...category, name }, config.ignorePatterns || []));
|
|
9
|
-
const commit = await (0, util_1.getGitCommit)();
|
|
10
|
-
return {
|
|
11
|
-
timestamp: commit.timestamp,
|
|
12
|
-
hash: commit.hash,
|
|
13
|
-
categories: categoryResults,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
exports.processConfig = processConfig;
|
|
File without changes
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// import { join } from 'path';
|
|
2
|
-
// import { AggregateResult } from './models/aggregate-result';
|
|
3
|
-
// import { ChartConfig } from './models/chart-config';
|
|
4
|
-
// import { ProcessResult } from './models/process-result';
|
|
5
|
-
// import { VizDataset } from './models/viz-dataset';
|
|
6
|
-
// import { VizLabelsDatasets } from './models/viz-labels-datasets';
|
|
7
|
-
// import { existsSync, rmSync, writeFileSync } from 'fs';
|
|
8
|
-
// import { format, parse } from 'date-fns';
|
|
9
|
-
// import { ChartJSNodeCanvas } from 'chartjs-node-canvas';
|
|
10
|
-
// import * as ChartDataLabels from 'chartjs-plugin-datalabels';
|
|
11
|
-
// import * as autocolors from 'chartjs-plugin-autocolors';
|
|
12
|
-
// import { ChartConfiguration } from 'chart.js';
|
|
13
|
-
// export class TrackerChart {
|
|
14
|
-
// constructor(private _config: ChartConfig, private _allProcessResults: ProcessResult[], private _dateFormat: string) { }
|
|
15
|
-
// private getDataAndLabels(allJsonData, propName: string): VizLabelsDatasets {
|
|
16
|
-
// if (this._config.perCategoryTotals) {
|
|
17
|
-
// return this.getTotalsPerCategory(allJsonData, propName);
|
|
18
|
-
// }
|
|
19
|
-
// if (this._config.perCategoryAndFileType) {
|
|
20
|
-
// return this.getTotalsPerFileTypePerCategory(allJsonData, propName);
|
|
21
|
-
// }
|
|
22
|
-
// return this.getTotalsPerCategory(allJsonData, propName);
|
|
23
|
-
// }
|
|
24
|
-
// private getTotalsPerFileTypePerCategory(allJsonData, propName: string): VizLabelsDatasets {
|
|
25
|
-
// const runs = { };
|
|
26
|
-
// const allTypes = { };
|
|
27
|
-
// allJsonData.forEach((jsonData: ProcessResult, i) => {
|
|
28
|
-
// runs[jsonData.hash] = jsonData.timestamp;
|
|
29
|
-
// jsonData.categories.forEach((category) => {
|
|
30
|
-
// category.fileTypes.forEach((t) => {
|
|
31
|
-
// const label = `${category.name}: ${t.fileType}`;
|
|
32
|
-
// if (!allTypes[label]) {
|
|
33
|
-
// allTypes[label] = {
|
|
34
|
-
// label,
|
|
35
|
-
// data: []
|
|
36
|
-
// }
|
|
37
|
-
// }
|
|
38
|
-
// allTypes[label].data[i] = t[propName];
|
|
39
|
-
// });
|
|
40
|
-
// });
|
|
41
|
-
// });
|
|
42
|
-
// const labels = Object.values(runs) as string[];
|
|
43
|
-
// const datasets = Object.values(allTypes).map((t: VizDataset) => {
|
|
44
|
-
// return {
|
|
45
|
-
// ...t,
|
|
46
|
-
// fill: false,
|
|
47
|
-
// tension: .1
|
|
48
|
-
// }
|
|
49
|
-
// }) as VizDataset[];
|
|
50
|
-
// return {
|
|
51
|
-
// labels,
|
|
52
|
-
// datasets,
|
|
53
|
-
// };
|
|
54
|
-
// }
|
|
55
|
-
// private getTotalsPerCategory(allJsonData, propName: string): VizLabelsDatasets {
|
|
56
|
-
// const runs = { };
|
|
57
|
-
// const allTypes = { };
|
|
58
|
-
// allJsonData.forEach((jsonData: ProcessResult, i) => {
|
|
59
|
-
// runs[jsonData.hash] = jsonData.timestamp;
|
|
60
|
-
// jsonData.categories.forEach((category) => {
|
|
61
|
-
// const label = category.name;
|
|
62
|
-
// if (!allTypes[label]) {
|
|
63
|
-
// allTypes[label] = {
|
|
64
|
-
// label,
|
|
65
|
-
// data: []
|
|
66
|
-
// };
|
|
67
|
-
// }
|
|
68
|
-
// allTypes[label].data[i] = category.totals[propName];
|
|
69
|
-
// });
|
|
70
|
-
// });
|
|
71
|
-
// const labels = Object.values(runs) as string[];
|
|
72
|
-
// const datasets = Object.values(allTypes).map((t: VizDataset) => {
|
|
73
|
-
// return {
|
|
74
|
-
// ...t,
|
|
75
|
-
// fill: false,
|
|
76
|
-
// tension: .1
|
|
77
|
-
// }
|
|
78
|
-
// }) as VizDataset[];
|
|
79
|
-
// return {
|
|
80
|
-
// labels,
|
|
81
|
-
// datasets,
|
|
82
|
-
// };
|
|
83
|
-
// }
|
|
84
|
-
// private async generateGraphImageFile(parentDirectory: string, vizData: VizLabelsDatasets): Promise<void> {
|
|
85
|
-
// const outFile = join(parentDirectory, this._config.outFile);
|
|
86
|
-
// if (this._config.overwrite && existsSync(outFile)) { rmSync(outFile); }
|
|
87
|
-
// const dateFmt = this._dateFormat;
|
|
88
|
-
// const configuration = {
|
|
89
|
-
// type: 'line',
|
|
90
|
-
// data: vizData,
|
|
91
|
-
// options: {
|
|
92
|
-
// elements: {
|
|
93
|
-
// point:{
|
|
94
|
-
// radius: 0
|
|
95
|
-
// }
|
|
96
|
-
// },
|
|
97
|
-
// plugins: {
|
|
98
|
-
// title: {
|
|
99
|
-
// display: true,
|
|
100
|
-
// text: this._config.title
|
|
101
|
-
// },
|
|
102
|
-
// autocolors: {
|
|
103
|
-
// enabled: true,
|
|
104
|
-
// mode: 'data',
|
|
105
|
-
// },
|
|
106
|
-
// scales: {
|
|
107
|
-
// x: {
|
|
108
|
-
// type: 'timeseries',
|
|
109
|
-
// time: {
|
|
110
|
-
// minUnit: 'week',
|
|
111
|
-
// },
|
|
112
|
-
// parsing: false,
|
|
113
|
-
// title: {
|
|
114
|
-
// display: true,
|
|
115
|
-
// text: this._config.xAxisLabel
|
|
116
|
-
// },
|
|
117
|
-
// ticks: {
|
|
118
|
-
// source: 'data',
|
|
119
|
-
// callback: function(val) {
|
|
120
|
-
// return format(
|
|
121
|
-
// parse(this.getLabelForValue(val), dateFmt, new Date()),
|
|
122
|
-
// 'yyyy-MM-dd'
|
|
123
|
-
// );
|
|
124
|
-
// }
|
|
125
|
-
// }
|
|
126
|
-
// },
|
|
127
|
-
// y: {
|
|
128
|
-
// title: {
|
|
129
|
-
// display: true,
|
|
130
|
-
// text: this._config.yAxisLabel
|
|
131
|
-
// }
|
|
132
|
-
// }
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
// },
|
|
136
|
-
// };
|
|
137
|
-
// try {
|
|
138
|
-
// const pieChart = new ChartJSNodeCanvas({
|
|
139
|
-
// width: this._config.width,
|
|
140
|
-
// height: this._config.height,
|
|
141
|
-
// backgroundColour: this._config.bg,
|
|
142
|
-
// plugins: {
|
|
143
|
-
// modern: [ChartDataLabels, autocolors],
|
|
144
|
-
// }
|
|
145
|
-
// });
|
|
146
|
-
// const result = await pieChart.renderToBuffer(configuration as ChartConfiguration);
|
|
147
|
-
// writeFileSync(outFile, result);
|
|
148
|
-
// } catch (exc) {
|
|
149
|
-
// console.error(exc);
|
|
150
|
-
// }
|
|
151
|
-
// }
|
|
152
|
-
// writeTo(parentDirectory: string, graphablePropertyName: keyof AggregateResult = 'total'): Promise<void> {
|
|
153
|
-
// const vizData = this.getDataAndLabels(this._allProcessResults, graphablePropertyName);
|
|
154
|
-
// return this.generateGraphImageFile(parentDirectory, vizData);
|
|
155
|
-
// }
|
|
156
|
-
// }
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Config } from './models/config';
|
|
2
|
-
import { ProcessResult } from './models/process-result';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* exported alphabetized util functions ->
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export declare function getData(localRootDir: string, outputDir: string): any;
|
|
11
|
-
export declare function getGitCommit(): Promise<{
|
|
12
|
-
hash: string;
|
|
13
|
-
timestamp: string;
|
|
14
|
-
}>;
|
|
15
|
-
export declare function getTheRootDirectory(directory: string): string;
|
|
16
|
-
export declare function readConfig(rootDirectory: string, optionsPath?: string): Config;
|
|
17
|
-
export declare function saveResults(localRootDir: string, outputDir: string, results: ProcessResult): void;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveResults = exports.readConfig = exports.getTheRootDirectory = exports.getGitCommit = exports.getData = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const date_fns_1 = require("date-fns");
|
|
7
|
-
const git_last_commit_1 = require("git-last-commit");
|
|
8
|
-
// import { AggregateResult } from './models/aggregate-result';
|
|
9
|
-
// import { TrackerChart } from './tracker-chart';
|
|
10
|
-
// import { ChartConfig } from './models/chart-config';
|
|
11
|
-
const DATE_FORMAT = 'yyyy-MM-dd-HH-mm-ss-SSS';
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* internal alphabetized helper functions ->
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
function formatDate(date) {
|
|
20
|
-
return (0, date_fns_1.format)(date, DATE_FORMAT);
|
|
21
|
-
}
|
|
22
|
-
function getDataFilePath(localRootDir, outputDir) {
|
|
23
|
-
return (0, path_1.resolve)((0, path_1.join)(localRootDir, outputDir, 'data.json'));
|
|
24
|
-
}
|
|
25
|
-
function getGitDate(date) {
|
|
26
|
-
return new Date(+date * 1000);
|
|
27
|
-
}
|
|
28
|
-
function getLastCommitAsPromise() {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
(0, git_last_commit_1.getLastCommit)((err, commit) => {
|
|
31
|
-
if (err) {
|
|
32
|
-
reject(err);
|
|
33
|
-
}
|
|
34
|
-
resolve(commit);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* exported alphabetized util functions ->
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
// export async function createDataVizIn(
|
|
46
|
-
// chartConfig: ChartConfig,
|
|
47
|
-
// parentDirectory: string,
|
|
48
|
-
// allJsonData: ProcessResult[],
|
|
49
|
-
// graphablePropertyName: keyof AggregateResult = 'total'
|
|
50
|
-
// ): Promise<void> {
|
|
51
|
-
// const chart = new TrackerChart(chartConfig, allJsonData, DATE_FORMAT);
|
|
52
|
-
// return chart.writeTo(parentDirectory, graphablePropertyName);
|
|
53
|
-
// }
|
|
54
|
-
function getData(localRootDir, outputDir) {
|
|
55
|
-
const outputPath = getDataFilePath(localRootDir, outputDir);
|
|
56
|
-
let contents = '';
|
|
57
|
-
if ((0, fs_1.existsSync)(outputPath)) {
|
|
58
|
-
contents = (0, fs_1.readFileSync)(outputPath).toString('utf-8');
|
|
59
|
-
}
|
|
60
|
-
return contents === '' ? [] : JSON.parse(contents);
|
|
61
|
-
}
|
|
62
|
-
exports.getData = getData;
|
|
63
|
-
async function getGitCommit() {
|
|
64
|
-
const commit = await getLastCommitAsPromise();
|
|
65
|
-
return {
|
|
66
|
-
hash: commit.hash,
|
|
67
|
-
timestamp: formatDate(getGitDate(commit.committedOn)),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
exports.getGitCommit = getGitCommit;
|
|
71
|
-
function getTheRootDirectory(directory) {
|
|
72
|
-
if ((0, fs_1.existsSync)((0, path_1.join)(directory, 'package.json'))) {
|
|
73
|
-
return directory;
|
|
74
|
-
}
|
|
75
|
-
return getTheRootDirectory((0, path_1.resolve)((0, path_1.join)(directory, '..')));
|
|
76
|
-
}
|
|
77
|
-
exports.getTheRootDirectory = getTheRootDirectory;
|
|
78
|
-
function readConfig(rootDirectory, optionsPath) {
|
|
79
|
-
const path = optionsPath && (0, fs_1.existsSync)((0, path_1.join)(rootDirectory, optionsPath))
|
|
80
|
-
? (0, path_1.join)(rootDirectory, optionsPath)
|
|
81
|
-
: (0, path_1.join)(rootDirectory, 'hd-tracker', 'config.json');
|
|
82
|
-
const contents = (0, fs_1.readFileSync)(path).toString('utf-8');
|
|
83
|
-
return JSON.parse(contents);
|
|
84
|
-
}
|
|
85
|
-
exports.readConfig = readConfig;
|
|
86
|
-
function saveResults(localRootDir, outputDir, results) {
|
|
87
|
-
console.log('Outputting file');
|
|
88
|
-
const output = getData(localRootDir, outputDir);
|
|
89
|
-
if (!Array.isArray(output)) {
|
|
90
|
-
console.error('Invalid output file format');
|
|
91
|
-
}
|
|
92
|
-
output.push(results);
|
|
93
|
-
const outputPath = getDataFilePath(localRootDir, outputDir);
|
|
94
|
-
const outputText = JSON.stringify(output, null, 2);
|
|
95
|
-
(0, fs_1.writeFileSync)(outputPath, outputText);
|
|
96
|
-
console.log(`Output written to: ${outputPath}`);
|
|
97
|
-
}
|
|
98
|
-
exports.saveResults = saveResults;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Command, Interfaces } from "@oclif/core";
|
|
2
|
-
import { BaseCommand } from "../command";
|
|
3
|
-
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<typeof BaseCommand['baseFlags'] & T['flags']>;
|
|
4
|
-
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './flags.type';
|
package/oclif.manifest.json
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.2",
|
|
3
|
-
"commands": {
|
|
4
|
-
"report:committers": {
|
|
5
|
-
"id": "report:committers",
|
|
6
|
-
"summary": "Get Committers Between Two Dates",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"usage": "<%= command.id %> [flags [-s][-e][-x]]",
|
|
9
|
-
"pluginName": "@herodevs/cli",
|
|
10
|
-
"pluginAlias": "@herodevs/cli",
|
|
11
|
-
"pluginType": "core",
|
|
12
|
-
"aliases": [],
|
|
13
|
-
"examples": [
|
|
14
|
-
"<%= config.bin %> <%= command.id %>"
|
|
15
|
-
],
|
|
16
|
-
"flags": {
|
|
17
|
-
"json": {
|
|
18
|
-
"name": "json",
|
|
19
|
-
"type": "boolean",
|
|
20
|
-
"description": "Format output as json.",
|
|
21
|
-
"helpGroup": "GLOBAL",
|
|
22
|
-
"allowNo": false
|
|
23
|
-
},
|
|
24
|
-
"log-level": {
|
|
25
|
-
"name": "log-level",
|
|
26
|
-
"type": "option",
|
|
27
|
-
"summary": "Specify level for logging.",
|
|
28
|
-
"helpGroup": "GLOBAL",
|
|
29
|
-
"multiple": false,
|
|
30
|
-
"options": [
|
|
31
|
-
"debug",
|
|
32
|
-
"info",
|
|
33
|
-
"warn",
|
|
34
|
-
"error"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
"startDate": {
|
|
38
|
-
"name": "startDate",
|
|
39
|
-
"type": "option",
|
|
40
|
-
"char": "s",
|
|
41
|
-
"summary": "Start Date (format: yyyy-MM-dd)",
|
|
42
|
-
"required": false,
|
|
43
|
-
"multiple": false,
|
|
44
|
-
"default": "2024-03-06"
|
|
45
|
-
},
|
|
46
|
-
"endDate": {
|
|
47
|
-
"name": "endDate",
|
|
48
|
-
"type": "option",
|
|
49
|
-
"char": "e",
|
|
50
|
-
"summary": "End Date (format: yyyy-MM-dd)",
|
|
51
|
-
"required": false,
|
|
52
|
-
"multiple": false,
|
|
53
|
-
"default": "2023-03-06"
|
|
54
|
-
},
|
|
55
|
-
"exclude": {
|
|
56
|
-
"name": "exclude",
|
|
57
|
-
"type": "option",
|
|
58
|
-
"char": "x",
|
|
59
|
-
"summary": "Path Exclusions (eg -x=\"./src/bin\" -x=\"./dist\")",
|
|
60
|
-
"required": false,
|
|
61
|
-
"multiple": true
|
|
62
|
-
},
|
|
63
|
-
"monthly": {
|
|
64
|
-
"name": "monthly",
|
|
65
|
-
"type": "boolean",
|
|
66
|
-
"char": "m",
|
|
67
|
-
"summary": "Break down by calendar month, rather than by committer. (eg -m)",
|
|
68
|
-
"required": false,
|
|
69
|
-
"allowNo": false
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"args": {}
|
|
73
|
-
},
|
|
74
|
-
"tracker:init": {
|
|
75
|
-
"id": "tracker:init",
|
|
76
|
-
"description": "Initialize the tracker configuration",
|
|
77
|
-
"strict": true,
|
|
78
|
-
"pluginName": "@herodevs/cli",
|
|
79
|
-
"pluginAlias": "@herodevs/cli",
|
|
80
|
-
"pluginType": "core",
|
|
81
|
-
"aliases": [],
|
|
82
|
-
"examples": [
|
|
83
|
-
"<%= config.bin %> <%= command.id %>"
|
|
84
|
-
],
|
|
85
|
-
"flags": {},
|
|
86
|
-
"args": {}
|
|
87
|
-
},
|
|
88
|
-
"tracker:run": {
|
|
89
|
-
"id": "tracker:run",
|
|
90
|
-
"description": "Run the tracker",
|
|
91
|
-
"strict": true,
|
|
92
|
-
"pluginName": "@herodevs/cli",
|
|
93
|
-
"pluginAlias": "@herodevs/cli",
|
|
94
|
-
"pluginType": "core",
|
|
95
|
-
"aliases": [],
|
|
96
|
-
"examples": [
|
|
97
|
-
"<%= config.bin %> <%= command.id %>"
|
|
98
|
-
],
|
|
99
|
-
"flags": {
|
|
100
|
-
"root": {
|
|
101
|
-
"name": "root",
|
|
102
|
-
"type": "option",
|
|
103
|
-
"char": "r",
|
|
104
|
-
"description": "root dir of the project",
|
|
105
|
-
"multiple": false
|
|
106
|
-
},
|
|
107
|
-
"config": {
|
|
108
|
-
"name": "config",
|
|
109
|
-
"type": "option",
|
|
110
|
-
"char": "c",
|
|
111
|
-
"description": "path to config file",
|
|
112
|
-
"multiple": false
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"args": {}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|