@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.
Files changed (75) hide show
  1. package/main.js +959 -0
  2. package/package.json +14 -115
  3. package/README.md +0 -35
  4. package/bin/dev +0 -17
  5. package/bin/dev.cmd +0 -3
  6. package/bin/run +0 -5
  7. package/bin/run.cmd +0 -3
  8. package/dist/commands/report/committers.d.ts +0 -19
  9. package/dist/commands/report/committers.js +0 -190
  10. package/dist/commands/tracker/init.d.ts +0 -8
  11. package/dist/commands/tracker/init.js +0 -16
  12. package/dist/commands/tracker/run.d.ts +0 -11
  13. package/dist/commands/tracker/run.js +0 -37
  14. package/dist/index.d.ts +0 -1
  15. package/dist/index.js +0 -5
  16. package/dist/package.json +0 -120
  17. package/dist/shared/command/base-command.d.ts +0 -22
  18. package/dist/shared/command/base-command.js +0 -47
  19. package/dist/shared/command/index.d.ts +0 -1
  20. package/dist/shared/command/index.js +0 -4
  21. package/dist/shared/config/environment.d.ts +0 -4
  22. package/dist/shared/config/environment.js +0 -10
  23. package/dist/shared/config/index.d.ts +0 -1
  24. package/dist/shared/config/index.js +0 -4
  25. package/dist/shared/enums/index.d.ts +0 -1
  26. package/dist/shared/enums/index.js +0 -4
  27. package/dist/shared/enums/log-colors.d.ts +0 -28
  28. package/dist/shared/enums/log-colors.js +0 -9
  29. package/dist/shared/index.d.ts +0 -4
  30. package/dist/shared/index.js +0 -7
  31. package/dist/shared/lib/index.d.ts +0 -2
  32. package/dist/shared/lib/index.js +0 -5
  33. package/dist/shared/lib/shell.d.ts +0 -7
  34. package/dist/shared/lib/shell.js +0 -34
  35. package/dist/shared/lib/version-update.d.ts +0 -3
  36. package/dist/shared/lib/version-update.js +0 -52
  37. package/dist/shared/tracker/default-config.d.ts +0 -3
  38. package/dist/shared/tracker/default-config.js +0 -19
  39. package/dist/shared/tracker/initialize.d.ts +0 -1
  40. package/dist/shared/tracker/initialize.js +0 -15
  41. package/dist/shared/tracker/models/aggregate-result.d.ts +0 -4
  42. package/dist/shared/tracker/models/aggregate-result.js +0 -2
  43. package/dist/shared/tracker/models/category-result.d.ts +0 -7
  44. package/dist/shared/tracker/models/category-result.js +0 -2
  45. package/dist/shared/tracker/models/category.d.ts +0 -9
  46. package/dist/shared/tracker/models/category.js +0 -2
  47. package/dist/shared/tracker/models/chart-config.d.ts +0 -24
  48. package/dist/shared/tracker/models/chart-config.js +0 -65
  49. package/dist/shared/tracker/models/config.d.ts +0 -8
  50. package/dist/shared/tracker/models/config.js +0 -2
  51. package/dist/shared/tracker/models/file-result.d.ts +0 -5
  52. package/dist/shared/tracker/models/file-result.js +0 -2
  53. package/dist/shared/tracker/models/process-result.d.ts +0 -6
  54. package/dist/shared/tracker/models/process-result.js +0 -2
  55. package/dist/shared/tracker/models/result.d.ts +0 -11
  56. package/dist/shared/tracker/models/result.js +0 -2
  57. package/dist/shared/tracker/models/total-result.d.ts +0 -4
  58. package/dist/shared/tracker/models/total-result.js +0 -2
  59. package/dist/shared/tracker/models/viz-dataset.d.ts +0 -4
  60. package/dist/shared/tracker/models/viz-dataset.js +0 -2
  61. package/dist/shared/tracker/models/viz-labels-datasets.d.ts +0 -5
  62. package/dist/shared/tracker/models/viz-labels-datasets.js +0 -2
  63. package/dist/shared/tracker/process-category.d.ts +0 -3
  64. package/dist/shared/tracker/process-category.js +0 -155
  65. package/dist/shared/tracker/process-config.d.ts +0 -3
  66. package/dist/shared/tracker/process-config.js +0 -16
  67. package/dist/shared/tracker/tracker-chart.d.ts +0 -0
  68. package/dist/shared/tracker/tracker-chart.js +0 -156
  69. package/dist/shared/tracker/util.d.ts +0 -17
  70. package/dist/shared/tracker/util.js +0 -98
  71. package/dist/shared/types/flags.type.d.ts +0 -4
  72. package/dist/shared/types/flags.type.js +0 -2
  73. package/dist/shared/types/index.d.ts +0 -1
  74. package/dist/shared/types/index.js +0 -4
  75. package/oclif.manifest.json +0 -118
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseCommand = void 0;
4
- const core_1 = require("@oclif/core");
5
- const lib_1 = require("../lib");
6
- var LogLevel;
7
- (function (LogLevel) {
8
- LogLevel["debug"] = "debug";
9
- LogLevel["info"] = "info";
10
- LogLevel["warn"] = "warn";
11
- LogLevel["error"] = "error";
12
- })(LogLevel || (LogLevel = {}));
13
- class BaseCommand extends core_1.Command {
14
- async init() {
15
- await super.init();
16
- const { args, flags } = await this.parse({
17
- flags: this.ctor.flags,
18
- baseFlags: (super.ctor.baseFlags),
19
- args: this.ctor.args,
20
- strict: this.ctor.strict,
21
- });
22
- this.flags = flags;
23
- this.args = args;
24
- await (0, lib_1.ensureVersionIsUpToDate)(this);
25
- }
26
- async catch(err) {
27
- // add any custom logic to handle errors from the command
28
- // or simply return the parent class error handling
29
- this.logToStderr(JSON.stringify(err));
30
- return super.catch(err);
31
- }
32
- async finally(_) {
33
- // called after run and catch regardless of whether or not the command errored
34
- return super.finally(_);
35
- }
36
- }
37
- exports.BaseCommand = BaseCommand;
38
- // add the --json flag
39
- BaseCommand.enableJsonFlag = true;
40
- // define flags that can be inherited by any command that extends BaseCommand
41
- BaseCommand.baseFlags = {
42
- 'log-level': core_1.Flags.custom({
43
- summary: 'Specify level for logging.',
44
- options: Object.values(LogLevel),
45
- helpGroup: 'GLOBAL',
46
- })(),
47
- };
@@ -1 +0,0 @@
1
- export * from './base-command';
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./base-command"), exports);
@@ -1,4 +0,0 @@
1
- export declare const env: {
2
- packageVersion: string;
3
- packageName: string;
4
- };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.env = void 0;
4
- const path = require('path');
5
- const packageJsonPath = path.join(__dirname, '../../../package.json');
6
- const packageJson = require(packageJsonPath);
7
- exports.env = {
8
- packageVersion: packageJson.version,
9
- packageName: packageJson.name,
10
- };
@@ -1 +0,0 @@
1
- export * from './environment';
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./environment"), exports);
@@ -1 +0,0 @@
1
- export * from './log-colors';
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./log-colors"), exports);
@@ -1,28 +0,0 @@
1
- export declare const enum Color {
2
- Reset = "\u001B[0m",
3
- Bright = "\u001B[1m",
4
- Dim = "\u001B[2m",
5
- Underscore = "\u001B[4m",
6
- Blink = "\u001B[5m",
7
- Reverse = "\u001B[7m",
8
- Hidden = "\u001B[8m",
9
- FgBlack = "\u001B[30m",
10
- FgRed = "\u001B[31m",
11
- FgGreen = "\u001B[32m",
12
- FgYellow = "\u001B[33m",
13
- FgBlue = "\u001B[34m",
14
- FgMagenta = "\u001B[35m",
15
- FgCyan = "\u001B[36m",
16
- FgWhite = "\u001B[37m",
17
- FgGray = "\u001B[90m",
18
- BgBlack = "\u001B[40m",
19
- BgRed = "\u001B[41m",
20
- BgGreen = "\u001B[42m",
21
- BgYellow = "\u001B[43m",
22
- BgBlue = "\u001B[44m",
23
- BgMagenta = "\u001B[45m",
24
- BgCyan = "\u001B[46m",
25
- BgWhite = "\u001B[47m",
26
- BgGray = "\u001B[100m"
27
- }
28
- export declare function color(color: Color): (...args: string[]) => string;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.color = void 0;
4
- function color(color) {
5
- return (...args) => {
6
- return `${color}${args.join(` ${color}` /*reset color for nested color*/)}${"\u001B[0m" /* Color.Reset */}`;
7
- };
8
- }
9
- exports.color = color;
@@ -1,4 +0,0 @@
1
- export * from './config';
2
- export * from './command';
3
- export * from './types';
4
- export * from './lib';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./config"), exports);
5
- tslib_1.__exportStar(require("./command"), exports);
6
- tslib_1.__exportStar(require("./types"), exports);
7
- tslib_1.__exportStar(require("./lib"), exports);
@@ -1,2 +0,0 @@
1
- export * from './shell';
2
- export * from './version-update';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./shell"), exports);
5
- tslib_1.__exportStar(require("./version-update"), exports);
@@ -1,7 +0,0 @@
1
- interface shellOptions {
2
- returnCode: boolean;
3
- suppressExit: boolean;
4
- suppressStdOut: boolean;
5
- }
6
- export declare function run<T>(command: string, config?: Partial<shellOptions>): Promise<T>;
7
- export {};
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- const shelljs = require('shelljs');
5
- ;
6
- const defaultRunOptions = {
7
- returnCode: false,
8
- suppressExit: true,
9
- suppressStdOut: true,
10
- };
11
- function run(command, config = defaultRunOptions) {
12
- const options = { ...defaultRunOptions, ...config };
13
- return new Promise((resolve, reject) => {
14
- if (options.suppressStdOut) {
15
- shelljs.config.silent = true;
16
- }
17
- shelljs.exec(command, (code, stdout, stderr) => {
18
- if (stderr) {
19
- const errorOutput = options.returnCode ? code : stderr;
20
- reject(errorOutput);
21
- if (!options.suppressExit) {
22
- process.exit(code);
23
- }
24
- return;
25
- }
26
- const output = options.returnCode ? code : stdout;
27
- if (!options.suppressStdOut) {
28
- console.log(output);
29
- }
30
- resolve(output);
31
- });
32
- });
33
- }
34
- exports.run = run;
@@ -1,3 +0,0 @@
1
- import { Command } from '@oclif/core';
2
- export declare function isVersionUpToDate(command: Command, quietIfSuccessful?: boolean): Promise<boolean>;
3
- export declare function ensureVersionIsUpToDate(command: Command): Promise<void>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureVersionIsUpToDate = exports.isVersionUpToDate = void 0;
4
- const config_1 = require("../config");
5
- const getJson = require("get-json");
6
- const enums_1 = require("../enums");
7
- const red = (0, enums_1.color)("\u001B[31m" /* Color.FgRed */);
8
- const yellow = (0, enums_1.color)("\u001B[33m" /* Color.FgYellow */);
9
- function reconstituteCommandPositionalsAndFlags(command) {
10
- var _a;
11
- return [
12
- ...(_a = command.id) === null || _a === void 0 ? void 0 : _a.split(':'),
13
- ...Object.keys(command.flags).map((flag) => `--${flag}='${command.flags[flag]}'`),
14
- ].join(' ');
15
- }
16
- async function getLatestVersion(pkgName) {
17
- return getJson(`https://registry.npmjs.org/${pkgName}`).then((packageData) => {
18
- return packageData['dist-tags'].latest;
19
- });
20
- }
21
- async function isVersionUpToDate(command, quietIfSuccessful = false) {
22
- if (config_1.env.packageVersion === '0.0.0') {
23
- return true;
24
- }
25
- const latestVersion = await getLatestVersion(config_1.env.packageName);
26
- if (latestVersion === config_1.env.packageVersion) {
27
- if (!quietIfSuccessful) {
28
- command.log(`${config_1.env.packageName}@${latestVersion} is up to date`);
29
- }
30
- return true;
31
- }
32
- command.log(`${yellow('Your version:', red(`${config_1.env.packageName}@${config_1.env.packageVersion}`), `is not up to date`)}`);
33
- command.log(`${yellow('Latest version:', red(`${config_1.env.packageName}@${latestVersion}`))}`);
34
- return false;
35
- }
36
- exports.isVersionUpToDate = isVersionUpToDate;
37
- async function ensureVersionIsUpToDate(command) {
38
- const versionUpToDate = await isVersionUpToDate(command);
39
- if (!versionUpToDate) {
40
- // see `update-plugin-behavior` branch for previous implementation of auto-update
41
- const commandAndPositionals = reconstituteCommandPositionalsAndFlags(command);
42
- command.log([
43
- `\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n`,
44
- `${red(`ERROR:`)} Did not run command.\n\n`,
45
- ` - Rerun your command with the ${yellow('@latest')} tag to ensure correct output:\n\n\n`,
46
- `\t${yellow(`npx ${config_1.env.packageName}@latest ${commandAndPositionals}`)}\n`,
47
- `\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n`,
48
- ].join(' '));
49
- return process.exit(1);
50
- }
51
- }
52
- exports.ensureVersionIsUpToDate = ensureVersionIsUpToDate;
@@ -1,3 +0,0 @@
1
- import { Config } from './models/config';
2
- declare const defaultConfig: Config;
3
- export default defaultConfig;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const defaultConfig = {
4
- categories: {
5
- legacy: {
6
- fileTypes: ['js', 'ts', 'html', 'css', 'scss', 'less'],
7
- includes: ['./legacy'],
8
- jsTsPairs: 'js',
9
- },
10
- modern: {
11
- fileTypes: ['ts', 'html', 'css', 'scss', 'less'],
12
- includes: ['./modern'],
13
- jsTsPairs: 'ts',
14
- },
15
- },
16
- ignorePatterns: ['node_modules'],
17
- outputDir: 'hd-tracker',
18
- };
19
- exports.default = defaultConfig;
@@ -1 +0,0 @@
1
- export declare function initialize(rootDir: string): void;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialize = void 0;
4
- const path_1 = require("path");
5
- const fs_1 = require("fs");
6
- const default_config_1 = require("./default-config");
7
- function initialize(rootDir) {
8
- const output = JSON.stringify(default_config_1.default, null, 2);
9
- const dir = (0, path_1.join)(rootDir, 'hd-tracker');
10
- if (!(0, fs_1.existsSync)(dir)) {
11
- (0, fs_1.mkdirSync)(dir);
12
- }
13
- (0, fs_1.writeFileSync)((0, path_1.join)(dir, 'config.json'), output);
14
- }
15
- exports.initialize = initialize;
@@ -1,4 +0,0 @@
1
- import { TotalResult } from './total-result';
2
- export interface AggregateResult extends TotalResult {
3
- fileType: string;
4
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- import { AggregateResult } from './aggregate-result';
2
- import { TotalResult } from './total-result';
3
- export interface CategoryResult {
4
- name: string;
5
- totals: TotalResult;
6
- fileTypes: AggregateResult[];
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- export interface Category extends CategoryDefinition {
2
- name: string;
3
- }
4
- export interface CategoryDefinition {
5
- fileTypes: string[];
6
- includes: string[];
7
- excludes?: string[];
8
- jsTsPairs?: 'js' | 'ts' | 'ignore';
9
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- export declare class ChartConfig {
2
- private _cliOptions;
3
- private _perCategoryAndFileType;
4
- private _perCategoryTotals;
5
- private _width;
6
- private _height;
7
- private _bg;
8
- private _title;
9
- private _xAxisLabel;
10
- private _yAxisLabel;
11
- private _overwrite;
12
- private _outFile;
13
- get perCategoryAndFileType(): boolean;
14
- get perCategoryTotals(): boolean;
15
- get width(): number;
16
- get height(): number;
17
- get bg(): string;
18
- get title(): string;
19
- get xAxisLabel(): string;
20
- get yAxisLabel(): string;
21
- get overwrite(): boolean;
22
- get outFile(): string;
23
- constructor(_cliOptions?: ChartConfig);
24
- }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChartConfig = void 0;
4
- class ChartConfig {
5
- get perCategoryAndFileType() {
6
- // if false, use false; false !== undefined
7
- return this._cliOptions.perCategoryAndFileType !== undefined
8
- ? this._cliOptions.perCategoryAndFileType
9
- : this._perCategoryAndFileType;
10
- }
11
- get perCategoryTotals() {
12
- // if false, use false; false !== undefined
13
- return this._cliOptions.perCategoryTotals !== undefined
14
- ? this._cliOptions.perCategoryTotals
15
- : this._perCategoryTotals;
16
- }
17
- get width() {
18
- // if set and non-numeric
19
- if (this._cliOptions.width !== undefined && isNaN(Number(this._cliOptions.width))) {
20
- throw Error('--chart.width must be a number');
21
- }
22
- // if unset or numeric
23
- return this._cliOptions.width !== undefined ? this._cliOptions.width : this._width;
24
- }
25
- get height() {
26
- // if set and non-numeric
27
- if (this._cliOptions.height !== undefined && isNaN(Number(this._cliOptions.height))) {
28
- throw Error('--chart.height must be a number');
29
- }
30
- // if unset or numeric
31
- return this._cliOptions.height !== undefined ? this._cliOptions.height : this._height;
32
- }
33
- get bg() {
34
- return this._cliOptions.bg ? this._cliOptions.bg : this._bg;
35
- }
36
- get title() {
37
- return this._cliOptions.title ? this._cliOptions.title : this._title;
38
- }
39
- get xAxisLabel() {
40
- return this._cliOptions.xAxisLabel ? this._cliOptions.xAxisLabel : this._xAxisLabel;
41
- }
42
- get yAxisLabel() {
43
- return this._cliOptions.yAxisLabel ? this._cliOptions.yAxisLabel : this._yAxisLabel;
44
- }
45
- get overwrite() {
46
- return this._cliOptions.overwrite !== undefined ? this._cliOptions.overwrite : this._overwrite;
47
- }
48
- get outFile() {
49
- return this._cliOptions.outFile ? this._cliOptions.outFile : this._outFile;
50
- }
51
- constructor(_cliOptions = {}) {
52
- this._cliOptions = _cliOptions;
53
- this._perCategoryAndFileType = false;
54
- this._perCategoryTotals = true;
55
- this._width = 1200;
56
- this._height = 800;
57
- this._bg = 'white';
58
- this._title = 'Migration Progress LOC';
59
- this._xAxisLabel = 'Date';
60
- this._yAxisLabel = 'Totals';
61
- this._overwrite = true;
62
- this._outFile = 'viz.png';
63
- }
64
- }
65
- exports.ChartConfig = ChartConfig;
@@ -1,8 +0,0 @@
1
- import { CategoryDefinition } from './category';
2
- export interface Config {
3
- categories: {
4
- [key: string]: CategoryDefinition;
5
- };
6
- ignorePatterns?: string[];
7
- outputDir: string;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- import { Result } from './result';
2
- export interface FileResult extends Result {
3
- fileType: string;
4
- path: string;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- import { CategoryResult } from './category-result';
2
- export interface ProcessResult {
3
- timestamp: string;
4
- hash: string;
5
- categories: CategoryResult[];
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- export interface Result {
2
- total: number;
3
- source: number;
4
- comment: number;
5
- single: number;
6
- block: number;
7
- mixed: number;
8
- empty: number;
9
- todo: number;
10
- blockEmpty: number;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import { Result } from './result';
2
- export interface TotalResult extends Result {
3
- fileCount: number;
4
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- export type VizDataset = {
2
- label: string;
3
- data: number[];
4
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- import { VizDataset } from './viz-dataset';
2
- export type VizLabelsDatasets = {
3
- labels: string[];
4
- datasets: VizDataset[];
5
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- import { Category } from './models/category';
2
- import { CategoryResult } from './models/category-result';
3
- export declare function processCategory(rootDirectory: string, category: Category, ignorePatterns: string[]): CategoryResult;