bod 0.0.0-1 → 0.0.0-1867
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/README.md +2 -2
- package/bin/bod.js +1 -1
- package/dist/bod.js +9 -7
- package/dist/commands/BaseCommand.js +1 -1
- package/dist/commands/CreateCommand.d.ts +5 -0
- package/dist/commands/CreateCommand.js +47 -17
- package/dist/commands/InfoCommand.js +2 -2
- package/dist/commands/__tests__/BaseCommand.test.d.ts +1 -0
- package/dist/commands/__tests__/BaseCommand.test.js +36 -0
- package/dist/commands/__tests__/CreateCommand.test.d.ts +1 -0
- package/dist/commands/__tests__/CreateCommand.test.js +82 -0
- package/dist/commands/__tests__/InfoCommand.test.d.ts +1 -0
- package/dist/commands/__tests__/InfoCommand.test.js +24 -0
- package/dist/commands/__tests__/index.test.d.ts +1 -0
- package/dist/commands/__tests__/index.test.js +65 -0
- package/dist/index.d.ts +1 -1
- package/dist/utils/__tests__/index.test.d.ts +1 -0
- package/dist/utils/__tests__/index.test.js +13 -0
- package/dist/utils/console.js +2 -2
- package/dist/utils/core.js +3 -2
- package/dist/utils/os.js +2 -2
- package/package.json +41 -39
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/bod)
|
|
7
7
|
[](https://www.npmjs.com/package/bod)
|
|
8
|
-
[](https://
|
|
8
|
+
[](https://cdn.jsdelivr.net/npm/bod@latest/)
|
|
9
9
|
|
|
10
|
-
[](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
|
|
11
11
|
[](https://codecov.io/gh/sabertazimi/bod)
|
|
12
12
|
[](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
|
|
13
13
|
|
package/bin/bod.js
CHANGED
package/dist/bod.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
|
+
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
6
8
|
const utils_1 = require("./utils");
|
|
7
9
|
const index_1 = require("./index");
|
|
8
|
-
const packageJsonPath =
|
|
9
|
-
const packageJson = JSON.parse(
|
|
10
|
-
utils_1.program.version(packageJson.version, '-v, --version');
|
|
10
|
+
const packageJsonPath = node_path_1.default.join(__dirname, '../package.json');
|
|
11
|
+
const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
|
|
12
|
+
utils_1.program.version((_a = packageJson.version) !== null && _a !== void 0 ? _a : '0.0.1', '-v, --version');
|
|
11
13
|
for (const command of index_1.CommandFactory.values()) {
|
|
12
14
|
utils_1.program
|
|
13
15
|
.command(command.getUsage())
|
|
14
16
|
.alias(command.getAlias())
|
|
15
17
|
.description(command.getDescription())
|
|
16
|
-
.action((appName) =>
|
|
18
|
+
.action((appName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
19
|
try {
|
|
18
20
|
yield command.run(appName);
|
|
19
21
|
}
|
|
@@ -29,4 +31,4 @@ utils_1.program.on('--help', () => {
|
|
|
29
31
|
utils_1.printer.log('');
|
|
30
32
|
});
|
|
31
33
|
utils_1.program.showHelpAfterError();
|
|
32
|
-
utils_1.program.parse(
|
|
34
|
+
utils_1.program.parse(node_process_1.default.argv);
|
|
@@ -10,7 +10,7 @@ class BaseCommand {
|
|
|
10
10
|
this.alias = alias !== null && alias !== void 0 ? alias : this.name[0];
|
|
11
11
|
}
|
|
12
12
|
run(_appName) {
|
|
13
|
-
return
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () { });
|
|
14
14
|
}
|
|
15
15
|
getName() {
|
|
16
16
|
return this.name;
|
|
@@ -4,11 +4,16 @@ interface Action {
|
|
|
4
4
|
value: string;
|
|
5
5
|
command: string;
|
|
6
6
|
args: string[];
|
|
7
|
+
postCommands: {
|
|
8
|
+
command: string;
|
|
9
|
+
args: string[];
|
|
10
|
+
}[];
|
|
7
11
|
}
|
|
8
12
|
declare class CreateCommand extends BaseCommand {
|
|
9
13
|
static readonly TemplateActions: Action[];
|
|
10
14
|
private command;
|
|
11
15
|
private commandArgs;
|
|
16
|
+
private postCommands;
|
|
12
17
|
constructor();
|
|
13
18
|
run(appName: string): Promise<void>;
|
|
14
19
|
getCommand(): string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
-
const BaseCommand_1 =
|
|
5
|
+
const BaseCommand_1 = tslib_1.__importDefault(require("./BaseCommand"));
|
|
6
6
|
class CreateCommand extends BaseCommand_1.default {
|
|
7
7
|
constructor() {
|
|
8
8
|
super({
|
|
@@ -12,9 +12,10 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
12
12
|
});
|
|
13
13
|
this.command = 'npx';
|
|
14
14
|
this.commandArgs = [];
|
|
15
|
+
this.postCommands = [];
|
|
15
16
|
}
|
|
16
17
|
run(appName) {
|
|
17
|
-
return
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
yield this.processTemplateAction();
|
|
19
20
|
this.resolveAppPath(appName);
|
|
20
21
|
this.execute();
|
|
@@ -27,7 +28,7 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
27
28
|
return this.commandArgs;
|
|
28
29
|
}
|
|
29
30
|
processTemplateAction() {
|
|
30
|
-
return
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
32
|
const { templateName } = yield utils_1.inquirer.prompt([
|
|
32
33
|
{
|
|
33
34
|
name: 'templateName',
|
|
@@ -36,13 +37,21 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
36
37
|
choices: [...CreateCommand.TemplateActions],
|
|
37
38
|
},
|
|
38
39
|
]);
|
|
39
|
-
const { command, args } = CreateCommand.TemplateActions.find(({ value }) => value === templateName);
|
|
40
|
+
const { command, args, postCommands } = CreateCommand.TemplateActions.find(({ value }) => value === templateName);
|
|
40
41
|
this.command = command;
|
|
41
42
|
this.commandArgs = [...args];
|
|
43
|
+
this.postCommands = postCommands;
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
resolveAppPath(appName) {
|
|
45
47
|
this.commandArgs.push(appName);
|
|
48
|
+
CreateCommand.TemplateActions.forEach(({ postCommands }) => {
|
|
49
|
+
for (const postCommand of postCommands) {
|
|
50
|
+
postCommand.args = postCommand.args.map((arg) => {
|
|
51
|
+
return arg.replace('appPath', appName);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
46
55
|
}
|
|
47
56
|
execute() {
|
|
48
57
|
const proc = utils_1.spawn.sync(this.command, this.commandArgs, {
|
|
@@ -51,6 +60,14 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
51
60
|
if (proc.status !== 0) {
|
|
52
61
|
throw new Error(`\n\`${this.command} ${this.commandArgs.join(' ')}\` exited.`);
|
|
53
62
|
}
|
|
63
|
+
for (const postCommand of this.postCommands) {
|
|
64
|
+
const proc = utils_1.spawn.sync(postCommand.command, postCommand.args, {
|
|
65
|
+
stdio: 'inherit',
|
|
66
|
+
});
|
|
67
|
+
if (proc.status !== 0) {
|
|
68
|
+
throw new Error(`\n\`${postCommand.command} ${postCommand.args.join(' ')}\` exited.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
54
71
|
}
|
|
55
72
|
}
|
|
56
73
|
CreateCommand.TemplateActions = [
|
|
@@ -58,10 +75,20 @@ CreateCommand.TemplateActions = [
|
|
|
58
75
|
name: 'Simple',
|
|
59
76
|
value: 'simple',
|
|
60
77
|
command: 'git',
|
|
61
|
-
args: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
args: ['clone', '--depth=1', 'https://github.com/sabertazimi/bod'],
|
|
79
|
+
postCommands: [
|
|
80
|
+
{
|
|
81
|
+
command: 'mv',
|
|
82
|
+
args: ['appPath', 'appPath.bak'],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
command: 'mv',
|
|
86
|
+
args: ['appPath.bak/packages/webpack-template', 'appPath'],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
command: 'rm',
|
|
90
|
+
args: ['-rf', 'appPath.bak'],
|
|
91
|
+
},
|
|
65
92
|
],
|
|
66
93
|
},
|
|
67
94
|
{
|
|
@@ -69,36 +96,39 @@ CreateCommand.TemplateActions = [
|
|
|
69
96
|
value: 'jsx',
|
|
70
97
|
command: 'npx',
|
|
71
98
|
args: [
|
|
72
|
-
'create-react-app',
|
|
99
|
+
'create-react-app@latest',
|
|
73
100
|
'--template',
|
|
74
|
-
'@sabertazimi',
|
|
101
|
+
'@sabertazimi/cra-template@latest',
|
|
75
102
|
'--scripts-version',
|
|
76
|
-
'@sabertazimi/react-scripts',
|
|
103
|
+
'@sabertazimi/react-scripts@latest',
|
|
77
104
|
],
|
|
105
|
+
postCommands: [],
|
|
78
106
|
},
|
|
79
107
|
{
|
|
80
108
|
name: 'React TSX',
|
|
81
109
|
value: 'tsx',
|
|
82
110
|
command: 'npx',
|
|
83
111
|
args: [
|
|
84
|
-
'create-react-app',
|
|
112
|
+
'create-react-app@latest',
|
|
85
113
|
'--template',
|
|
86
|
-
'@sabertazimi/typescript',
|
|
114
|
+
'@sabertazimi/cra-template-typescript@latest',
|
|
87
115
|
'--scripts-version',
|
|
88
|
-
'@sabertazimi/react-scripts',
|
|
116
|
+
'@sabertazimi/react-scripts@latest',
|
|
89
117
|
],
|
|
118
|
+
postCommands: [],
|
|
90
119
|
},
|
|
91
120
|
{
|
|
92
121
|
name: 'React Framework',
|
|
93
122
|
value: 'framework',
|
|
94
123
|
command: 'npx',
|
|
95
124
|
args: [
|
|
96
|
-
'create-react-app',
|
|
125
|
+
'create-react-app@latest',
|
|
97
126
|
'--template',
|
|
98
|
-
'bod',
|
|
127
|
+
'cra-template-bod@latest',
|
|
99
128
|
'--scripts-version',
|
|
100
|
-
'@sabertazimi/react-scripts',
|
|
129
|
+
'@sabertazimi/react-scripts@latest',
|
|
101
130
|
],
|
|
131
|
+
postCommands: [],
|
|
102
132
|
},
|
|
103
133
|
];
|
|
104
134
|
exports.default = CreateCommand;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
-
const BaseCommand_1 =
|
|
5
|
+
const BaseCommand_1 = tslib_1.__importDefault(require("./BaseCommand"));
|
|
6
6
|
class InfoCommand extends BaseCommand_1.default {
|
|
7
7
|
constructor() {
|
|
8
8
|
super({
|
|
@@ -12,7 +12,7 @@ class InfoCommand extends BaseCommand_1.default {
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
run(_appName) {
|
|
15
|
-
return
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
utils_1.printer.info(`Environment information:`);
|
|
17
17
|
const envInfo = yield utils_1.envinfo.run({
|
|
18
18
|
System: ['OS', 'CPU'],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const BaseCommand_1 = tslib_1.__importDefault(require("../BaseCommand"));
|
|
5
|
+
const options = {
|
|
6
|
+
name: 'base',
|
|
7
|
+
description: 'Base command description',
|
|
8
|
+
usage: 'base',
|
|
9
|
+
alias: 'c',
|
|
10
|
+
};
|
|
11
|
+
describe('baseCommand', () => {
|
|
12
|
+
it('should have [name] field', () => {
|
|
13
|
+
const baseCommand = new BaseCommand_1.default(options);
|
|
14
|
+
expect(baseCommand.getName()).toBe(options.name);
|
|
15
|
+
});
|
|
16
|
+
it('should have [description] field', () => {
|
|
17
|
+
const baseCommand = new BaseCommand_1.default(options);
|
|
18
|
+
expect(baseCommand.getDescription()).toBe(options.description);
|
|
19
|
+
});
|
|
20
|
+
it('should have [usage] field', () => {
|
|
21
|
+
const baseCommand = new BaseCommand_1.default(options);
|
|
22
|
+
expect(baseCommand.getUsage()).toBe(options.usage);
|
|
23
|
+
});
|
|
24
|
+
it('should have [alias] field', () => {
|
|
25
|
+
const baseCommand = new BaseCommand_1.default(options);
|
|
26
|
+
expect(baseCommand.getAlias()).toBe(options.alias);
|
|
27
|
+
});
|
|
28
|
+
it('should set [alias] field to first character of [name] field by default', () => {
|
|
29
|
+
const baseCommand = new BaseCommand_1.default(Object.assign(Object.assign({}, options), { alias: undefined }));
|
|
30
|
+
expect(baseCommand.getAlias()).toBe(options.name[0]);
|
|
31
|
+
});
|
|
32
|
+
it('should have [run] method', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const baseCommand = new BaseCommand_1.default(options);
|
|
34
|
+
yield expect(baseCommand.run()).resolves.toBeUndefined();
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
5
|
+
const ci_info_1 = require("ci-info");
|
|
6
|
+
const rimraf_1 = require("rimraf");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
const CreateCommand_1 = tslib_1.__importDefault(require("../CreateCommand"));
|
|
9
|
+
const appPath = node_path_1.default.join(process.cwd(), '..', 'bod-unit-tests');
|
|
10
|
+
describe('createCommand', () => {
|
|
11
|
+
beforeEach(() => (0, rimraf_1.sync)(appPath));
|
|
12
|
+
afterEach(() => (0, rimraf_1.sync)(appPath));
|
|
13
|
+
it('should extends [BaseCommand] fields', () => {
|
|
14
|
+
const createCommand = new CreateCommand_1.default();
|
|
15
|
+
expect(createCommand.getName()).toBe('create');
|
|
16
|
+
expect(createCommand.getDescription()).toBe('Create a new project powered by @sabertazimi/react-scripts');
|
|
17
|
+
expect(createCommand.getUsage()).toBe('create <appName>');
|
|
18
|
+
expect(createCommand.getAlias()).toBe('c');
|
|
19
|
+
});
|
|
20
|
+
it.each(CreateCommand_1.default.TemplateActions)('should get correct command/args and invoke [inquirer] via template choice [$name]', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value }) {
|
|
21
|
+
const mockPrompt = jest
|
|
22
|
+
.spyOn(utils_1.inquirer, 'prompt')
|
|
23
|
+
.mockImplementation(() => {
|
|
24
|
+
const promise = new Promise((resolve) => {
|
|
25
|
+
resolve({ templateName: value });
|
|
26
|
+
});
|
|
27
|
+
return promise;
|
|
28
|
+
});
|
|
29
|
+
const mockSpawn = jest.spyOn(utils_1.spawn, 'sync').mockImplementation(() => {
|
|
30
|
+
return {
|
|
31
|
+
status: 0,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const createCommand = new CreateCommand_1.default();
|
|
35
|
+
yield expect(createCommand.run(appPath)).resolves.toBeUndefined();
|
|
36
|
+
const { command, args, postCommands } = CreateCommand_1.default.TemplateActions.find(action => action.value === value);
|
|
37
|
+
expect(createCommand.getCommand()).toBe(command);
|
|
38
|
+
expect(createCommand.getCommandArgs()).toHaveLength(args.length + 1);
|
|
39
|
+
expect(createCommand.getCommandArgs()).toStrictEqual(args.concat(appPath));
|
|
40
|
+
expect(mockPrompt).toHaveBeenCalledTimes(1);
|
|
41
|
+
expect(mockSpawn).toHaveBeenCalledTimes(postCommands.length + 1);
|
|
42
|
+
mockPrompt.mockRestore();
|
|
43
|
+
mockSpawn.mockRestore();
|
|
44
|
+
}));
|
|
45
|
+
it.each(CreateCommand_1.default.TemplateActions)('should throw error when exited with non zero via template choice [$name]', (_b) => tslib_1.__awaiter(void 0, [_b], void 0, function* ({ value }) {
|
|
46
|
+
const mockPrompt = jest
|
|
47
|
+
.spyOn(utils_1.inquirer, 'prompt')
|
|
48
|
+
.mockImplementation(() => {
|
|
49
|
+
const promise = new Promise((resolve) => {
|
|
50
|
+
resolve({ templateName: value });
|
|
51
|
+
});
|
|
52
|
+
return promise;
|
|
53
|
+
});
|
|
54
|
+
const mockSpawn = jest.spyOn(utils_1.spawn, 'sync').mockImplementation(() => {
|
|
55
|
+
return {
|
|
56
|
+
status: 1,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
const createCommand = new CreateCommand_1.default();
|
|
60
|
+
yield expect(createCommand.run(appPath)).rejects.toThrowError();
|
|
61
|
+
expect(mockPrompt).toHaveBeenCalledTimes(1);
|
|
62
|
+
expect(mockSpawn).toHaveBeenCalledTimes(1);
|
|
63
|
+
mockPrompt.mockRestore();
|
|
64
|
+
mockSpawn.mockRestore();
|
|
65
|
+
}));
|
|
66
|
+
it.each(CreateCommand_1.default.TemplateActions)('should initialize app directory via template choice [$name]', (_c) => tslib_1.__awaiter(void 0, [_c], void 0, function* ({ value }) {
|
|
67
|
+
const mockPrompt = jest
|
|
68
|
+
.spyOn(utils_1.inquirer, 'prompt')
|
|
69
|
+
.mockImplementation(() => {
|
|
70
|
+
const promise = new Promise((resolve) => {
|
|
71
|
+
resolve({ templateName: value });
|
|
72
|
+
});
|
|
73
|
+
return promise;
|
|
74
|
+
});
|
|
75
|
+
const createCommand = new CreateCommand_1.default();
|
|
76
|
+
if (ci_info_1.isCI) {
|
|
77
|
+
yield expect(createCommand.run(appPath)).resolves.toBeUndefined();
|
|
78
|
+
expect(mockPrompt).toHaveBeenCalledTimes(1);
|
|
79
|
+
}
|
|
80
|
+
mockPrompt.mockRestore();
|
|
81
|
+
}));
|
|
82
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const InfoCommand_1 = tslib_1.__importDefault(require("../InfoCommand"));
|
|
6
|
+
describe('infoCommand', () => {
|
|
7
|
+
jest.setTimeout(20000);
|
|
8
|
+
it('should extends [BaseCommand] fields', () => {
|
|
9
|
+
const infoCommand = new InfoCommand_1.default();
|
|
10
|
+
expect(infoCommand.getName()).toBe('info');
|
|
11
|
+
expect(infoCommand.getDescription()).toBe('Print debugging information about your environment');
|
|
12
|
+
expect(infoCommand.getUsage()).toBe('info');
|
|
13
|
+
expect(infoCommand.getAlias()).toBe('i');
|
|
14
|
+
});
|
|
15
|
+
it('should print environment variables', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const mockConsoleInfo = jest
|
|
17
|
+
.spyOn(utils_1.printer, 'info')
|
|
18
|
+
.mockImplementation(jest.fn());
|
|
19
|
+
const infoCommand = new InfoCommand_1.default();
|
|
20
|
+
yield expect(infoCommand.run()).resolves.toBeUndefined();
|
|
21
|
+
expect(mockConsoleInfo).toHaveBeenCalledTimes(2);
|
|
22
|
+
mockConsoleInfo.mockRestore();
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../index");
|
|
4
|
+
describe('commands', () => {
|
|
5
|
+
let commands;
|
|
6
|
+
let counts;
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
commands = new Set([
|
|
9
|
+
new index_1.BaseCommand({
|
|
10
|
+
name: 'base',
|
|
11
|
+
description: 'Base command description',
|
|
12
|
+
usage: 'base',
|
|
13
|
+
}),
|
|
14
|
+
new index_1.CreateCommand(),
|
|
15
|
+
new index_1.InfoCommand(),
|
|
16
|
+
]);
|
|
17
|
+
counts = new Map();
|
|
18
|
+
});
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
commands.clear();
|
|
21
|
+
counts.clear();
|
|
22
|
+
});
|
|
23
|
+
it('should has unique name', () => {
|
|
24
|
+
for (const command of commands) {
|
|
25
|
+
const name = command.getName();
|
|
26
|
+
if (counts.has(name))
|
|
27
|
+
counts.set(name, counts.get(name) + 1);
|
|
28
|
+
else
|
|
29
|
+
counts.set(name, 1);
|
|
30
|
+
expect(command).toBeDefined();
|
|
31
|
+
}
|
|
32
|
+
for (const [name, count] of counts) {
|
|
33
|
+
expect(name).toBeTruthy();
|
|
34
|
+
expect(count).toBe(1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
it('should has unique usage', () => {
|
|
38
|
+
for (const command of commands) {
|
|
39
|
+
const usage = command.getUsage();
|
|
40
|
+
if (counts.has(usage))
|
|
41
|
+
counts.set(usage, counts.get(usage) + 1);
|
|
42
|
+
else
|
|
43
|
+
counts.set(usage, 1);
|
|
44
|
+
expect(command).toBeDefined();
|
|
45
|
+
}
|
|
46
|
+
for (const [usage, count] of counts) {
|
|
47
|
+
expect(usage).toBeTruthy();
|
|
48
|
+
expect(count).toBe(1);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
it('should has unique alias', () => {
|
|
52
|
+
for (const command of commands) {
|
|
53
|
+
const alias = command.getAlias();
|
|
54
|
+
if (counts.has(alias))
|
|
55
|
+
counts.set(alias, counts.get(alias) + 1);
|
|
56
|
+
else
|
|
57
|
+
counts.set(alias, 1);
|
|
58
|
+
expect(command).toBeDefined();
|
|
59
|
+
}
|
|
60
|
+
for (const [alias, count] of counts) {
|
|
61
|
+
expect(alias).toBeTruthy();
|
|
62
|
+
expect(count).toBe(1);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../index");
|
|
4
|
+
describe('utils', () => {
|
|
5
|
+
it('should execute chalk correctly', () => {
|
|
6
|
+
expect((0, index_1.color)('raw text')).toStrictEqual('raw text');
|
|
7
|
+
});
|
|
8
|
+
it('should execute program correctly', () => {
|
|
9
|
+
const mockParse = jest.spyOn(index_1.program, 'parse').mockImplementation(jest.fn());
|
|
10
|
+
expect(process.env.__BOD__).toStrictEqual('__BOD__');
|
|
11
|
+
mockParse.mockRestore();
|
|
12
|
+
});
|
|
13
|
+
});
|
package/dist/utils/console.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printer = exports.color = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const chalk_1 =
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
exports.color = chalk_1.default;
|
|
7
|
-
const consola_1 =
|
|
7
|
+
const consola_1 = tslib_1.__importDefault(require("consola"));
|
|
8
8
|
exports.printer = consola_1.default;
|
package/dist/utils/core.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.program = exports.inquirer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
5
6
|
const commander_1 = require("commander");
|
|
6
|
-
const inquirer_1 =
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
8
|
exports.inquirer = inquirer_1.default;
|
|
8
9
|
const program = new commander_1.Command();
|
|
9
10
|
exports.program = program;
|
|
10
|
-
|
|
11
|
+
node_process_1.default.env.__BOD__ = '__BOD__';
|
package/dist/utils/os.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.spawn = exports.envinfo = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const cross_spawn_1 =
|
|
5
|
+
const cross_spawn_1 = tslib_1.__importDefault(require("cross-spawn"));
|
|
6
6
|
exports.spawn = cross_spawn_1.default;
|
|
7
|
-
const envinfo_1 =
|
|
7
|
+
const envinfo_1 = tslib_1.__importDefault(require("envinfo"));
|
|
8
8
|
exports.envinfo = envinfo_1.default;
|
package/package.json
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bod",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-1867",
|
|
4
4
|
"description": "Boilerplate CLI App",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"compile": "tsc",
|
|
9
|
-
"dev": "ts-node ./src/bod.ts",
|
|
10
|
-
"format": "prettier --write src/**/*.ts",
|
|
11
|
-
"lint": "yarn lint:style && yarn lint:type-check",
|
|
12
|
-
"lint:style": "eslint --fix --ext .ts ./src",
|
|
13
|
-
"lint:type-check": "tsc --noEmit",
|
|
14
|
-
"start": "yarn dev"
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"bin/bod.js",
|
|
18
|
-
"dist/**/*.js",
|
|
19
|
-
"dist/**/*.d.ts",
|
|
20
|
-
"!dist/**/*.test.js",
|
|
21
|
-
"!dist/**/*.test.d.ts"
|
|
22
|
-
],
|
|
23
|
-
"bin": "bin/bod.js",
|
|
24
|
-
"main": "dist/index.js",
|
|
25
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"author": "sabertazimi <sabertazimi@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://sabertazimi.github.io/bod",
|
|
26
8
|
"repository": {
|
|
27
9
|
"type": "git",
|
|
28
10
|
"url": "git+https://github.com/sabertazimi/bod.git",
|
|
29
11
|
"directory": "packages/bod"
|
|
30
12
|
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/sabertazimi/bod/issues"
|
|
15
|
+
},
|
|
31
16
|
"keywords": [
|
|
32
17
|
"bod",
|
|
33
18
|
"bod-cli",
|
|
@@ -41,30 +26,47 @@
|
|
|
41
26
|
"template",
|
|
42
27
|
"typescript"
|
|
43
28
|
],
|
|
44
|
-
"
|
|
45
|
-
"
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"types": "dist/index.d.ts",
|
|
31
|
+
"bin": "bin/bod.js",
|
|
32
|
+
"files": [
|
|
33
|
+
"!dist/**/*.test.d.ts",
|
|
34
|
+
"!dist/**/*.test.js",
|
|
35
|
+
"bin/bod.js",
|
|
36
|
+
"dist/**/*.d.ts",
|
|
37
|
+
"dist/**/*.js"
|
|
38
|
+
],
|
|
46
39
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
40
|
+
"node": ">=18.0.0"
|
|
48
41
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "pnpm clean && pnpm compile",
|
|
44
|
+
"clean": "rimraf ./dist/",
|
|
45
|
+
"compile": "tsc",
|
|
46
|
+
"dev": "ts-node ./src/bod.ts",
|
|
47
|
+
"format": "prettier --write src/**/*.ts",
|
|
48
|
+
"lint": "pnpm lint:style && pnpm lint:type-check",
|
|
49
|
+
"lint:style": "eslint ./src",
|
|
50
|
+
"lint:type-check": "tsc --noEmit",
|
|
51
|
+
"start": "pnpm dev"
|
|
51
52
|
},
|
|
52
|
-
"homepage": "https://sabertazimi.github.io/bod",
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"chalk": "^4.1.2",
|
|
55
|
-
"commander": "^
|
|
56
|
-
"consola": "^2.
|
|
55
|
+
"commander": "^12.0.0",
|
|
56
|
+
"consola": "^3.2.3",
|
|
57
57
|
"cross-spawn": "^7.0.3",
|
|
58
|
-
"envinfo": "^7.
|
|
59
|
-
"inquirer": "^8.
|
|
58
|
+
"envinfo": "^7.11.1",
|
|
59
|
+
"inquirer": "^8.2.6",
|
|
60
|
+
"tslib": "^2.6.2"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@types/cross-spawn": "^6.0.
|
|
63
|
-
"@types/envinfo": "^7.8.
|
|
64
|
-
"@types/inquirer": "^8.
|
|
65
|
-
"@types/rimraf": "^
|
|
66
|
-
"ci-info": "^
|
|
67
|
-
"rimraf": "^
|
|
63
|
+
"@types/cross-spawn": "^6.0.6",
|
|
64
|
+
"@types/envinfo": "^7.8.3",
|
|
65
|
+
"@types/inquirer": "^8.2.10",
|
|
66
|
+
"@types/rimraf": "^4.0.5",
|
|
67
|
+
"ci-info": "^4.0.0",
|
|
68
|
+
"rimraf": "^5.0.5",
|
|
69
|
+
"type-fest": "^4.14.0"
|
|
68
70
|
},
|
|
69
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "27b404c9bab635676f0939f84764ddc292fa681d"
|
|
70
72
|
}
|