@noravel/command 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Command.d.ts +1 -0
- package/dist/Command.js +16 -1
- package/dist/Executor.d.ts +1 -1
- package/dist/Kernel.js +3 -3
- package/dist/MakerCommand.d.ts +0 -1
- package/dist/MakerCommand.js +0 -11
- package/dist/Outputs/ProgressBar/ProgressBar.d.ts +17 -0
- package/dist/Outputs/ProgressBar/StatusBarFactory.d.ts +2 -2
- package/dist/Outputs/ProgressBar/StatusBarVerbose.js +1 -1
- package/package.json +1 -1
package/dist/Command.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export default abstract class Command implements CommandContract {
|
|
|
17
17
|
constructor(argv: string[]);
|
|
18
18
|
bootstrap(): this;
|
|
19
19
|
detect(): this;
|
|
20
|
+
basePath(dirPath?: string): string;
|
|
20
21
|
getName(): string;
|
|
21
22
|
getDescription(): string;
|
|
22
23
|
getArgument(name?: string): unknown;
|
package/dist/Command.js
CHANGED
|
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
6
8
|
const node_child_process_1 = require("node:child_process");
|
|
7
9
|
const Parser_1 = __importDefault(require("./Parser"));
|
|
8
10
|
const Detector_1 = __importDefault(require("./Detector"));
|
|
@@ -29,7 +31,9 @@ class Command {
|
|
|
29
31
|
this.prompt = new Prompt_1.default();
|
|
30
32
|
}
|
|
31
33
|
bootstrap() {
|
|
32
|
-
this.signature =
|
|
34
|
+
this.signature =
|
|
35
|
+
this.signature +
|
|
36
|
+
' {--h|help : Display help for the given command} {--v|version : Display the version of Noravel Command}';
|
|
33
37
|
const [name, argumentDefinition, optionDefinition] = Parser_1.default.parse(this.signature);
|
|
34
38
|
this.name = name;
|
|
35
39
|
this.definition.setArguments(argumentDefinition);
|
|
@@ -42,6 +46,17 @@ class Command {
|
|
|
42
46
|
this.inputs.options = _options;
|
|
43
47
|
return this;
|
|
44
48
|
}
|
|
49
|
+
basePath(dirPath) {
|
|
50
|
+
const basePath = process.cwd();
|
|
51
|
+
if (!dirPath) {
|
|
52
|
+
return basePath;
|
|
53
|
+
}
|
|
54
|
+
dirPath = node_path_1.default.join(basePath, dirPath);
|
|
55
|
+
if (!node_fs_1.default.existsSync(dirPath)) {
|
|
56
|
+
node_fs_1.default.mkdirSync(dirPath, { recursive: true });
|
|
57
|
+
}
|
|
58
|
+
return dirPath;
|
|
59
|
+
}
|
|
45
60
|
getName() {
|
|
46
61
|
return this.name;
|
|
47
62
|
}
|
package/dist/Executor.d.ts
CHANGED
package/dist/Kernel.js
CHANGED
|
@@ -29,13 +29,13 @@ class Kernel {
|
|
|
29
29
|
run() {
|
|
30
30
|
if (!this.name) {
|
|
31
31
|
const helper = new Helper_1.default();
|
|
32
|
-
helper.showHelpForMain(this.registeredCommands.map(
|
|
32
|
+
helper.showHelpForMain(this.registeredCommands.map(command => new command(this.argv).bootstrap()));
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
let signatures = [];
|
|
36
36
|
if (['--help', '-h'].includes(this.name)) {
|
|
37
37
|
const helper = new Helper_1.default();
|
|
38
|
-
helper.showHelpForMain(this.registeredCommands.map(
|
|
38
|
+
helper.showHelpForMain(this.registeredCommands.map(command => new command(this.argv).bootstrap()));
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
if (['--version', '-v'].includes(this.name)) {
|
|
@@ -66,7 +66,7 @@ class Kernel {
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
this.output.error(`Command "${this.name}" is not defined. Did you mean one of these?`);
|
|
69
|
-
signatures.forEach(
|
|
69
|
+
signatures.forEach(signature => this.output.comment(` ${signature}`));
|
|
70
70
|
}
|
|
71
71
|
setCallbackVersion(callback) {
|
|
72
72
|
this.callbackVersion = callback.bind(this);
|
package/dist/MakerCommand.d.ts
CHANGED
package/dist/MakerCommand.js
CHANGED
|
@@ -7,17 +7,6 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const Command_1 = __importDefault(require("./Command"));
|
|
9
9
|
class MakerCommand extends Command_1.default {
|
|
10
|
-
basePath(dirPath) {
|
|
11
|
-
const basePath = process.cwd();
|
|
12
|
-
if (!dirPath) {
|
|
13
|
-
return basePath;
|
|
14
|
-
}
|
|
15
|
-
dirPath = node_path_1.default.join(basePath, dirPath);
|
|
16
|
-
if (!node_fs_1.default.existsSync(dirPath)) {
|
|
17
|
-
node_fs_1.default.mkdirSync(dirPath, { recursive: true });
|
|
18
|
-
}
|
|
19
|
-
return dirPath;
|
|
20
|
-
}
|
|
21
10
|
async fileName(question = 'What should the file be named?') {
|
|
22
11
|
let name = this.getArgument('name');
|
|
23
12
|
if (!name) {
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
declare const ARROW_PROGRESS_STYLE: {
|
|
2
|
+
complete: string;
|
|
3
|
+
incomplete: string;
|
|
4
|
+
head: string;
|
|
5
|
+
};
|
|
6
|
+
declare const SHAPE_PROGRESS_STYLE: {
|
|
7
|
+
complete: string;
|
|
8
|
+
incomplete: string;
|
|
9
|
+
head: string;
|
|
10
|
+
};
|
|
11
|
+
declare const BLOCK_PROGRESS_STYLE: {
|
|
12
|
+
complete: string;
|
|
13
|
+
incomplete: string;
|
|
14
|
+
head: string;
|
|
15
|
+
};
|
|
16
|
+
export type ProgressStyle = typeof ARROW_PROGRESS_STYLE | typeof SHAPE_PROGRESS_STYLE | typeof BLOCK_PROGRESS_STYLE;
|
|
1
17
|
export type ProgressBarFormat = 'normal' | 'verbose' | 'minimal';
|
|
2
18
|
export default class ProgressBar {
|
|
3
19
|
private total;
|
|
@@ -20,3 +36,4 @@ export default class ProgressBar {
|
|
|
20
36
|
useArrowProgress(): void;
|
|
21
37
|
useBlockProgress(): void;
|
|
22
38
|
}
|
|
39
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ProgressBar, { ProgressBarFormat } from
|
|
2
|
-
import { StatusBar } from
|
|
1
|
+
import ProgressBar, { ProgressBarFormat } from './ProgressBar';
|
|
2
|
+
import { StatusBar } from './StatusBar';
|
|
3
3
|
export declare class StatusBarFactory {
|
|
4
4
|
static create(type: ProgressBarFormat, progressbar: ProgressBar): StatusBar;
|
|
5
5
|
}
|
|
@@ -6,7 +6,7 @@ class StatusBarVerbose extends StatusBar_1.StatusBar {
|
|
|
6
6
|
super(progressbar);
|
|
7
7
|
}
|
|
8
8
|
getInfo(perc) {
|
|
9
|
-
const elapsed =
|
|
9
|
+
const elapsed = new Date().getTime() / 1000 - this.progressbar.startTime;
|
|
10
10
|
const rate = this.progressbar.current > 0 ? elapsed / this.progressbar.current : 0;
|
|
11
11
|
const left = this.progressbar.getTotal() - this.progressbar.current;
|
|
12
12
|
const eta = (rate * left).toFixed(1);
|