bod 5.21.7 → 5.21.8
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 +1 -1
- package/dist/bod.js +22 -22
- package/dist/commands/BaseCommand.js +3 -5
- package/dist/commands/CreateCommand.d.ts +1 -1
- package/dist/commands/CreateCommand.js +17 -20
- package/dist/commands/InfoCommand.d.ts +1 -1
- package/dist/commands/InfoCommand.js +9 -11
- package/dist/commands/__tests__/BaseCommand.test.js +9 -11
- package/dist/commands/__tests__/CreateCommand.test.js +34 -50
- package/dist/commands/__tests__/InfoCommand.test.js +7 -9
- package/dist/commands/__tests__/index.test.js +4 -6
- package/dist/commands/index.d.ts +3 -3
- package/dist/commands/index.js +3 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -7
- package/dist/utils/__tests__/index.test.js +15 -18
- package/dist/utils/console.js +3 -8
- package/dist/utils/core.d.ts +2 -4
- package/dist/utils/core.js +6 -11
- package/dist/utils/index.d.ts +4 -6
- package/dist/utils/index.js +6 -16
- package/dist/utils/os.js +3 -8
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -69,5 +69,5 @@ Options:
|
|
|
69
69
|
## Contact
|
|
70
70
|
|
|
71
71
|
[](mailto:sabertazimi@gmail.com)
|
|
72
|
-
[](https://x.com/sabertazimi)
|
|
73
73
|
[](https://github.com/sabertazimi)
|
package/dist/bod.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _a;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { __awaiter } from "tslib";
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { CommandFactory } from './index.js';
|
|
8
|
+
import { color, printer, program } from './utils/index.js';
|
|
9
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const packageJsonPath = path.join(dirname, '../package.json');
|
|
11
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
|
|
12
|
+
program.version((_a = packageJson.version) !== null && _a !== void 0 ? _a : '0.0.1', '-v, --version');
|
|
13
|
+
for (const command of CommandFactory.values()) {
|
|
14
|
+
program
|
|
15
15
|
.command(command.getUsage())
|
|
16
16
|
.alias(command.getAlias())
|
|
17
17
|
.description(command.getDescription())
|
|
18
|
-
.action((appName) =>
|
|
18
|
+
.action((appName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
try {
|
|
20
20
|
yield command.run(appName);
|
|
21
21
|
}
|
|
22
22
|
catch (error) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
printer.error(error);
|
|
24
|
+
program.outputHelp();
|
|
25
25
|
}
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
program.on('--help', () => {
|
|
29
|
+
printer.log('');
|
|
30
|
+
printer.info(` Run ${color.cyan(`bod <command> --help`)} for detailed usage of given command.`);
|
|
31
|
+
printer.log('');
|
|
32
32
|
});
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
program.showHelpAfterError();
|
|
34
|
+
program.parse(process.argv);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
4
2
|
class BaseCommand {
|
|
5
3
|
constructor(options) {
|
|
6
4
|
const { name, description, usage, alias } = options;
|
|
@@ -10,7 +8,7 @@ class BaseCommand {
|
|
|
10
8
|
this.alias = alias !== null && alias !== void 0 ? alias : this.name[0];
|
|
11
9
|
}
|
|
12
10
|
run(_appName) {
|
|
13
|
-
return
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
14
12
|
}
|
|
15
13
|
getName() {
|
|
16
14
|
return this.name;
|
|
@@ -25,4 +23,4 @@ class BaseCommand {
|
|
|
25
23
|
return this.alias;
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
|
-
|
|
26
|
+
export default BaseCommand;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const BaseCommand_1 = tslib_1.__importDefault(require("./BaseCommand"));
|
|
6
|
-
class CreateCommand extends BaseCommand_1.default {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { findPackageManager, select, spawn } from '../utils/index.js';
|
|
3
|
+
import BaseCommand from './BaseCommand.js';
|
|
4
|
+
class CreateCommand extends BaseCommand {
|
|
7
5
|
constructor() {
|
|
8
6
|
super({
|
|
9
7
|
name: 'create',
|
|
@@ -16,7 +14,7 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
16
14
|
this.resolvePackageManager();
|
|
17
15
|
}
|
|
18
16
|
run(appName_1) {
|
|
19
|
-
return
|
|
17
|
+
return __awaiter(this, arguments, void 0, function* (appName, additionalOptions = []) {
|
|
20
18
|
yield this.processTemplateAction();
|
|
21
19
|
this.resolveAppPath(appName);
|
|
22
20
|
this.execute(additionalOptions);
|
|
@@ -29,15 +27,14 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
29
27
|
return this.commandArgs;
|
|
30
28
|
}
|
|
31
29
|
processTemplateAction() {
|
|
32
|
-
return
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
]);
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const templateName = yield select({
|
|
32
|
+
message: 'Select template:',
|
|
33
|
+
choices: CreateCommand.TemplateActions.map(action => ({
|
|
34
|
+
name: action.name,
|
|
35
|
+
value: action.value,
|
|
36
|
+
})),
|
|
37
|
+
});
|
|
41
38
|
const { command, args, postCommands } = CreateCommand.TemplateActions.find(({ value }) => value === templateName);
|
|
42
39
|
this.command = command;
|
|
43
40
|
this.commandArgs = [...args];
|
|
@@ -45,7 +42,7 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
resolvePackageManager() {
|
|
48
|
-
const packageManager =
|
|
45
|
+
const packageManager = findPackageManager();
|
|
49
46
|
CreateCommand.TemplateActions.forEach((action) => {
|
|
50
47
|
if (action.command === 'npm')
|
|
51
48
|
action.command = packageManager;
|
|
@@ -62,14 +59,14 @@ class CreateCommand extends BaseCommand_1.default {
|
|
|
62
59
|
});
|
|
63
60
|
}
|
|
64
61
|
execute(additionalOptions) {
|
|
65
|
-
const proc =
|
|
62
|
+
const proc = spawn.sync(this.command, [...this.commandArgs, ...additionalOptions], {
|
|
66
63
|
stdio: 'inherit',
|
|
67
64
|
});
|
|
68
65
|
if (proc.status !== 0) {
|
|
69
66
|
throw new Error(`\n\`${this.command} ${this.commandArgs.join(' ')}\` exited.`);
|
|
70
67
|
}
|
|
71
68
|
this.postCommands.forEach((postCommand) => {
|
|
72
|
-
const proc =
|
|
69
|
+
const proc = spawn.sync(postCommand.command, postCommand.args, {
|
|
73
70
|
stdio: 'inherit',
|
|
74
71
|
});
|
|
75
72
|
if (proc.status !== 0) {
|
|
@@ -134,4 +131,4 @@ CreateCommand.TemplateActions = [
|
|
|
134
131
|
postCommands: [],
|
|
135
132
|
},
|
|
136
133
|
];
|
|
137
|
-
|
|
134
|
+
export default CreateCommand;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const BaseCommand_1 = tslib_1.__importDefault(require("./BaseCommand"));
|
|
6
|
-
class InfoCommand extends BaseCommand_1.default {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { envinfo, printer } from '../utils/index.js';
|
|
3
|
+
import BaseCommand from './BaseCommand.js';
|
|
4
|
+
class InfoCommand extends BaseCommand {
|
|
7
5
|
constructor() {
|
|
8
6
|
super({
|
|
9
7
|
name: 'info',
|
|
@@ -12,9 +10,9 @@ class InfoCommand extends BaseCommand_1.default {
|
|
|
12
10
|
});
|
|
13
11
|
}
|
|
14
12
|
run(_appName) {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
const envInfo = yield
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
printer.info(`Environment information:`);
|
|
15
|
+
const envInfo = yield envinfo.run({
|
|
18
16
|
System: ['OS', 'CPU'],
|
|
19
17
|
Binaries: ['Node', 'Yarn', 'npm'],
|
|
20
18
|
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
|
@@ -25,8 +23,8 @@ class InfoCommand extends BaseCommand_1.default {
|
|
|
25
23
|
duplicates: true,
|
|
26
24
|
fullTree: true,
|
|
27
25
|
});
|
|
28
|
-
|
|
26
|
+
printer.info(envInfo);
|
|
29
27
|
});
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
|
-
|
|
30
|
+
export default InfoCommand;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const BaseCommand_1 = tslib_1.__importDefault(require("../BaseCommand"));
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import BaseCommand from '../BaseCommand.js';
|
|
5
3
|
const options = {
|
|
6
4
|
name: 'base',
|
|
7
5
|
description: 'Base command description',
|
|
@@ -10,27 +8,27 @@ const options = {
|
|
|
10
8
|
};
|
|
11
9
|
describe('baseCommand', () => {
|
|
12
10
|
it('should have [name] field', () => {
|
|
13
|
-
const baseCommand = new
|
|
11
|
+
const baseCommand = new BaseCommand(options);
|
|
14
12
|
expect(baseCommand.getName()).toBe(options.name);
|
|
15
13
|
});
|
|
16
14
|
it('should have [description] field', () => {
|
|
17
|
-
const baseCommand = new
|
|
15
|
+
const baseCommand = new BaseCommand(options);
|
|
18
16
|
expect(baseCommand.getDescription()).toBe(options.description);
|
|
19
17
|
});
|
|
20
18
|
it('should have [usage] field', () => {
|
|
21
|
-
const baseCommand = new
|
|
19
|
+
const baseCommand = new BaseCommand(options);
|
|
22
20
|
expect(baseCommand.getUsage()).toBe(options.usage);
|
|
23
21
|
});
|
|
24
22
|
it('should have [alias] field', () => {
|
|
25
|
-
const baseCommand = new
|
|
23
|
+
const baseCommand = new BaseCommand(options);
|
|
26
24
|
expect(baseCommand.getAlias()).toBe(options.alias);
|
|
27
25
|
});
|
|
28
26
|
it('should set [alias] field to first character of [name] field by default', () => {
|
|
29
|
-
const baseCommand = new
|
|
27
|
+
const baseCommand = new BaseCommand(Object.assign(Object.assign({}, options), { alias: undefined }));
|
|
30
28
|
expect(baseCommand.getAlias()).toBe(options.name[0]);
|
|
31
29
|
});
|
|
32
|
-
it('should have [run] method', () =>
|
|
33
|
-
const baseCommand = new
|
|
30
|
+
it('should have [run] method', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const baseCommand = new BaseCommand(options);
|
|
34
32
|
yield expect(baseCommand.run()).resolves.toBeUndefined();
|
|
35
33
|
}));
|
|
36
34
|
});
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const CreateCommand_1 = tslib_1.__importDefault(require("../CreateCommand"));
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { isCI } from 'ci-info';
|
|
3
|
+
import { sync } from 'rimraf';
|
|
4
|
+
import * as utils from '../../utils/index.js';
|
|
5
|
+
import CreateCommand from '../CreateCommand.js';
|
|
6
|
+
const { spawn } = utils;
|
|
8
7
|
const appPath = 'bod-unit-tests';
|
|
9
8
|
describe('createCommand', () => {
|
|
10
|
-
beforeEach(() =>
|
|
11
|
-
afterEach(() =>
|
|
9
|
+
beforeEach(() => sync(appPath));
|
|
10
|
+
afterEach(() => sync(appPath));
|
|
12
11
|
it('should extends [BaseCommand] fields', () => {
|
|
13
|
-
const createCommand = new
|
|
12
|
+
const createCommand = new CreateCommand();
|
|
14
13
|
expect(createCommand.getName()).toBe('create');
|
|
15
14
|
expect(createCommand.getDescription()).toBe('Create a new project powered by @sabertazimi/react-scripts');
|
|
16
15
|
expect(createCommand.getUsage()).toBe('create <appName>');
|
|
17
16
|
expect(createCommand.getAlias()).toBe('c');
|
|
18
17
|
});
|
|
19
|
-
it.each(
|
|
20
|
-
const
|
|
21
|
-
.spyOn(
|
|
22
|
-
.mockImplementation(() =>
|
|
23
|
-
|
|
24
|
-
resolve({ templateName: value });
|
|
25
|
-
});
|
|
26
|
-
return promise;
|
|
27
|
-
}));
|
|
28
|
-
const mockSpawn = jest.spyOn(utils_1.spawn, 'sync').mockImplementation(() => {
|
|
18
|
+
it.each(CreateCommand.TemplateActions)('should get correct command/args and invoke [select] via template choice [$name]', (_a) => __awaiter(void 0, [_a], void 0, function* ({ value }) {
|
|
19
|
+
const mockSelect = jest
|
|
20
|
+
.spyOn(utils, 'select')
|
|
21
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return value; }));
|
|
22
|
+
const mockSpawn = jest.spyOn(spawn, 'sync').mockImplementation(() => {
|
|
29
23
|
return {
|
|
30
24
|
status: 0,
|
|
31
25
|
};
|
|
@@ -35,27 +29,22 @@ describe('createCommand', () => {
|
|
|
35
29
|
: value === 'vite'
|
|
36
30
|
? ['--template', 'vue']
|
|
37
31
|
: [];
|
|
38
|
-
const createCommand = new
|
|
32
|
+
const createCommand = new CreateCommand();
|
|
39
33
|
yield expect(createCommand.run(appPath, additionalOptions)).resolves.toBeUndefined();
|
|
40
|
-
const { command, args, postCommands } =
|
|
34
|
+
const { command, args, postCommands } = CreateCommand.TemplateActions.find(action => action.value === value);
|
|
41
35
|
expect(createCommand.getCommand()).toBe(command);
|
|
42
36
|
expect(createCommand.getCommandArgs()).toHaveLength(args.length + 1);
|
|
43
37
|
expect(createCommand.getCommandArgs()).toStrictEqual(args.concat(appPath));
|
|
44
|
-
expect(
|
|
38
|
+
expect(mockSelect).toHaveBeenCalledTimes(1);
|
|
45
39
|
expect(mockSpawn).toHaveBeenCalledTimes(postCommands.length + 1);
|
|
46
|
-
|
|
40
|
+
mockSelect.mockRestore();
|
|
47
41
|
mockSpawn.mockRestore();
|
|
48
42
|
}));
|
|
49
|
-
it.each(
|
|
50
|
-
const
|
|
51
|
-
.spyOn(
|
|
52
|
-
.mockImplementation(() =>
|
|
53
|
-
|
|
54
|
-
resolve({ templateName: value });
|
|
55
|
-
});
|
|
56
|
-
return promise;
|
|
57
|
-
}));
|
|
58
|
-
const mockSpawn = jest.spyOn(utils_1.spawn, 'sync').mockImplementation(() => {
|
|
43
|
+
it.each(CreateCommand.TemplateActions)('should throw error when exited with non zero via template choice [$name]', (_a) => __awaiter(void 0, [_a], void 0, function* ({ value }) {
|
|
44
|
+
const mockSelect = jest
|
|
45
|
+
.spyOn(utils, 'select')
|
|
46
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return value; }));
|
|
47
|
+
const mockSpawn = jest.spyOn(spawn, 'sync').mockImplementation(() => {
|
|
59
48
|
return {
|
|
60
49
|
status: 1,
|
|
61
50
|
};
|
|
@@ -65,32 +54,27 @@ describe('createCommand', () => {
|
|
|
65
54
|
: value === 'vite'
|
|
66
55
|
? ['--template', 'vue']
|
|
67
56
|
: [];
|
|
68
|
-
const createCommand = new
|
|
57
|
+
const createCommand = new CreateCommand();
|
|
69
58
|
yield expect(createCommand.run(appPath, additionalOptions)).rejects.toThrow();
|
|
70
|
-
expect(
|
|
59
|
+
expect(mockSelect).toHaveBeenCalledTimes(1);
|
|
71
60
|
expect(mockSpawn).toHaveBeenCalledTimes(1);
|
|
72
|
-
|
|
61
|
+
mockSelect.mockRestore();
|
|
73
62
|
mockSpawn.mockRestore();
|
|
74
63
|
}));
|
|
75
|
-
it.each(
|
|
76
|
-
const
|
|
77
|
-
.spyOn(
|
|
78
|
-
.mockImplementation(() =>
|
|
79
|
-
const promise = new Promise((resolve) => {
|
|
80
|
-
resolve({ templateName: value });
|
|
81
|
-
});
|
|
82
|
-
return promise;
|
|
83
|
-
}));
|
|
64
|
+
it.each(CreateCommand.TemplateActions)('should initialize app directory via template choice [$name]', (_a) => __awaiter(void 0, [_a], void 0, function* ({ value }) {
|
|
65
|
+
const mockSelect = jest
|
|
66
|
+
.spyOn(utils, 'select')
|
|
67
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return value; }));
|
|
84
68
|
const additionalOptions = value === 'vue'
|
|
85
69
|
? ['--default']
|
|
86
70
|
: value === 'vite'
|
|
87
71
|
? ['--template', 'vue']
|
|
88
72
|
: [];
|
|
89
|
-
const createCommand = new
|
|
90
|
-
if (
|
|
73
|
+
const createCommand = new CreateCommand();
|
|
74
|
+
if (isCI) {
|
|
91
75
|
yield expect(createCommand.run(appPath, additionalOptions)).resolves.toBeUndefined();
|
|
92
|
-
expect(
|
|
76
|
+
expect(mockSelect).toHaveBeenCalledTimes(1);
|
|
93
77
|
}
|
|
94
|
-
|
|
78
|
+
mockSelect.mockRestore();
|
|
95
79
|
}));
|
|
96
80
|
});
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const InfoCommand_1 = tslib_1.__importDefault(require("../InfoCommand"));
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { printer } from '../../utils/index.js';
|
|
3
|
+
import InfoCommand from '../InfoCommand.js';
|
|
6
4
|
describe('infoCommand', () => {
|
|
7
5
|
jest.setTimeout(20000);
|
|
8
6
|
it('should extends [BaseCommand] fields', () => {
|
|
9
|
-
const infoCommand = new
|
|
7
|
+
const infoCommand = new InfoCommand();
|
|
10
8
|
expect(infoCommand.getName()).toBe('info');
|
|
11
9
|
expect(infoCommand.getDescription()).toBe('Print debugging information about your environment');
|
|
12
10
|
expect(infoCommand.getUsage()).toBe('info');
|
|
13
11
|
expect(infoCommand.getAlias()).toBe('i');
|
|
14
12
|
});
|
|
15
|
-
it('should print environment variables', () =>
|
|
13
|
+
it('should print environment variables', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
14
|
const mockConsoleInfo = jest
|
|
17
|
-
.spyOn(
|
|
15
|
+
.spyOn(printer, 'info')
|
|
18
16
|
.mockImplementation(jest.fn());
|
|
19
|
-
const infoCommand = new
|
|
17
|
+
const infoCommand = new InfoCommand();
|
|
20
18
|
yield expect(infoCommand.run()).resolves.toBeUndefined();
|
|
21
19
|
expect(mockConsoleInfo).toHaveBeenCalledTimes(2);
|
|
22
20
|
mockConsoleInfo.mockRestore();
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("../index");
|
|
1
|
+
import { BaseCommand, CreateCommand, InfoCommand } from '../index.js';
|
|
4
2
|
describe('commands', () => {
|
|
5
3
|
let commands;
|
|
6
4
|
let counts;
|
|
7
5
|
beforeEach(() => {
|
|
8
6
|
commands = new Set([
|
|
9
|
-
new
|
|
7
|
+
new BaseCommand({
|
|
10
8
|
name: 'base',
|
|
11
9
|
description: 'Base command description',
|
|
12
10
|
usage: 'base',
|
|
13
11
|
}),
|
|
14
|
-
new
|
|
15
|
-
new
|
|
12
|
+
new CreateCommand(),
|
|
13
|
+
new InfoCommand(),
|
|
16
14
|
]);
|
|
17
15
|
counts = new Map();
|
|
18
16
|
});
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as BaseCommand } from './BaseCommand';
|
|
2
|
-
export { default as CreateCommand } from './CreateCommand';
|
|
3
|
-
export { default as InfoCommand } from './InfoCommand';
|
|
1
|
+
export { default as BaseCommand } from './BaseCommand.js';
|
|
2
|
+
export { default as CreateCommand } from './CreateCommand.js';
|
|
3
|
+
export { default as InfoCommand } from './InfoCommand.js';
|
package/dist/commands/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
var BaseCommand_1 = require("./BaseCommand");
|
|
6
|
-
Object.defineProperty(exports, "BaseCommand", { enumerable: true, get: function () { return tslib_1.__importDefault(BaseCommand_1).default; } });
|
|
7
|
-
var CreateCommand_1 = require("./CreateCommand");
|
|
8
|
-
Object.defineProperty(exports, "CreateCommand", { enumerable: true, get: function () { return tslib_1.__importDefault(CreateCommand_1).default; } });
|
|
9
|
-
var InfoCommand_1 = require("./InfoCommand");
|
|
10
|
-
Object.defineProperty(exports, "InfoCommand", { enumerable: true, get: function () { return tslib_1.__importDefault(InfoCommand_1).default; } });
|
|
1
|
+
export { default as BaseCommand } from './BaseCommand.js';
|
|
2
|
+
export { default as CreateCommand } from './CreateCommand.js';
|
|
3
|
+
export { default as InfoCommand } from './InfoCommand.js';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandFactory = void 0;
|
|
4
|
-
const commands_1 = require("./commands");
|
|
1
|
+
import { CreateCommand, InfoCommand } from './commands/index.js';
|
|
5
2
|
const CommandFactory = new Map();
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const infoCommand = new commands_1.InfoCommand();
|
|
3
|
+
const createCommand = new CreateCommand();
|
|
4
|
+
const infoCommand = new InfoCommand();
|
|
9
5
|
CommandFactory.set(createCommand.getName(), createCommand);
|
|
10
6
|
CommandFactory.set(infoCommand.getName(), infoCommand);
|
|
7
|
+
export { CommandFactory };
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
5
|
-
const index_1 = require("../index");
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { color, findPackageManager, program } from '../index.js';
|
|
6
3
|
describe('utils', () => {
|
|
7
4
|
it('should execute chalk correctly', () => {
|
|
8
|
-
expect(
|
|
5
|
+
expect(color('raw text')).toStrictEqual('raw text');
|
|
9
6
|
});
|
|
10
7
|
it('should execute program correctly', () => {
|
|
11
|
-
const mockParse = jest.spyOn(
|
|
12
|
-
expect(
|
|
8
|
+
const mockParse = jest.spyOn(program, 'parse').mockImplementation(jest.fn());
|
|
9
|
+
expect(process.env.__BOD__).toStrictEqual('__BOD__');
|
|
13
10
|
mockParse.mockRestore();
|
|
14
11
|
});
|
|
15
12
|
it('should return correct package manager', () => {
|
|
16
|
-
|
|
17
|
-
expect(
|
|
18
|
-
|
|
19
|
-
expect(
|
|
20
|
-
|
|
21
|
-
expect(
|
|
22
|
-
|
|
23
|
-
expect(
|
|
24
|
-
|
|
25
|
-
expect(
|
|
13
|
+
process.env.npm_config_user_agent = 'pnpm/8.15.0';
|
|
14
|
+
expect(findPackageManager()).toStrictEqual('pnpm');
|
|
15
|
+
process.env.npm_config_user_agent = 'yarn/1.22.22';
|
|
16
|
+
expect(findPackageManager()).toStrictEqual('yarn');
|
|
17
|
+
process.env.npm_config_user_agent = 'yarn/4.2.0';
|
|
18
|
+
expect(findPackageManager()).toStrictEqual('yarn');
|
|
19
|
+
process.env.npm_config_user_agent = 'bun/0.1.0';
|
|
20
|
+
expect(findPackageManager()).toStrictEqual('bun');
|
|
21
|
+
process.env.npm_config_user_agent = 'npm/10.0.0';
|
|
22
|
+
expect(findPackageManager()).toStrictEqual('npm');
|
|
26
23
|
});
|
|
27
24
|
});
|
package/dist/utils/console.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
-
exports.color = chalk_1.default;
|
|
7
|
-
const consola_1 = tslib_1.__importDefault(require("consola"));
|
|
8
|
-
exports.printer = consola_1.default;
|
|
1
|
+
import color from 'chalk';
|
|
2
|
+
import printer from 'consola';
|
|
3
|
+
export { color, printer };
|
package/dist/utils/core.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { select } from '@inquirer/prompts';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
3
|
declare const program: Command;
|
|
5
|
-
export {
|
|
6
|
-
export type { Answers };
|
|
4
|
+
export { program, select };
|
package/dist/utils/core.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
-
exports.inquirer = inquirer_1.default;
|
|
9
|
-
const program = new commander_1.Command();
|
|
10
|
-
exports.program = program;
|
|
11
|
-
node_process_1.default.env.__BOD__ = '__BOD__';
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { select } from '@inquirer/prompts';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
const program = new Command();
|
|
5
|
+
process.env.__BOD__ = '__BOD__';
|
|
6
|
+
export { program, select };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { envinfo, spawn } from './os';
|
|
1
|
+
import { color, printer } from './console.js';
|
|
2
|
+
import { program, select } from './core.js';
|
|
3
|
+
import { envinfo, spawn } from './os.js';
|
|
5
4
|
declare function findPackageManager(): string;
|
|
6
|
-
export { color, envinfo, findPackageManager,
|
|
7
|
-
export type { Answers };
|
|
5
|
+
export { color, envinfo, findPackageManager, printer, program, select, spawn };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
7
|
-
const console_1 = require("./console");
|
|
8
|
-
Object.defineProperty(exports, "color", { enumerable: true, get: function () { return console_1.color; } });
|
|
9
|
-
Object.defineProperty(exports, "printer", { enumerable: true, get: function () { return console_1.printer; } });
|
|
10
|
-
const core_1 = require("./core");
|
|
11
|
-
Object.defineProperty(exports, "inquirer", { enumerable: true, get: function () { return core_1.inquirer; } });
|
|
12
|
-
Object.defineProperty(exports, "program", { enumerable: true, get: function () { return core_1.program; } });
|
|
13
|
-
const os_1 = require("./os");
|
|
14
|
-
Object.defineProperty(exports, "envinfo", { enumerable: true, get: function () { return os_1.envinfo; } });
|
|
15
|
-
Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return os_1.spawn; } });
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { color, printer } from './console.js';
|
|
3
|
+
import { program, select } from './core.js';
|
|
4
|
+
import { envinfo, spawn } from './os.js';
|
|
16
5
|
function findPackageManager() {
|
|
17
6
|
var _a;
|
|
18
|
-
const userAgent = (_a =
|
|
7
|
+
const userAgent = (_a = process.env.npm_config_user_agent) !== null && _a !== void 0 ? _a : '';
|
|
19
8
|
const packageManager = /pnpm/.test(userAgent)
|
|
20
9
|
? 'pnpm'
|
|
21
10
|
: /yarn/.test(userAgent)
|
|
@@ -25,3 +14,4 @@ function findPackageManager() {
|
|
|
25
14
|
: 'npm';
|
|
26
15
|
return packageManager;
|
|
27
16
|
}
|
|
17
|
+
export { color, envinfo, findPackageManager, printer, program, select, spawn };
|
package/dist/utils/os.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const cross_spawn_1 = tslib_1.__importDefault(require("cross-spawn"));
|
|
6
|
-
exports.spawn = cross_spawn_1.default;
|
|
7
|
-
const envinfo_1 = tslib_1.__importDefault(require("envinfo"));
|
|
8
|
-
exports.envinfo = envinfo_1.default;
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
|
+
import envinfo from 'envinfo';
|
|
3
|
+
export { envinfo, spawn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bod",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.21.8",
|
|
4
5
|
"description": "Boilerplate CLI App",
|
|
5
6
|
"author": "sabertazimi <sabertazimi@gmail.com>",
|
|
6
7
|
"license": "MIT",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"build": "pnpm clean && pnpm compile",
|
|
44
45
|
"clean": "rimraf ./dist/",
|
|
45
46
|
"compile": "tsc",
|
|
46
|
-
"dev": "
|
|
47
|
+
"dev": "tsx ./src/bod.ts",
|
|
47
48
|
"format": "prettier --write src/**/*.ts",
|
|
48
49
|
"lint": "pnpm lint:style && pnpm lint:type-check",
|
|
49
50
|
"lint:style": "eslint ./src",
|
|
@@ -52,21 +53,21 @@
|
|
|
52
53
|
"start": "pnpm dev"
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
56
|
+
"@inquirer/prompts": "^8.0.1",
|
|
55
57
|
"chalk": "^4.1.2",
|
|
56
58
|
"commander": "^14.0.2",
|
|
57
59
|
"consola": "^3.4.2",
|
|
58
60
|
"cross-spawn": "^7.0.6",
|
|
59
|
-
"envinfo": "^7.
|
|
60
|
-
"inquirer": "^8.2.7",
|
|
61
|
+
"envinfo": "^7.21.0",
|
|
61
62
|
"tslib": "^2.8.1"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@types/cross-spawn": "^6.0.6",
|
|
65
66
|
"@types/envinfo": "^7.8.4",
|
|
66
|
-
"@types/inquirer": "^8.2.12",
|
|
67
67
|
"ci-info": "^4.3.1",
|
|
68
|
-
"rimraf": "^6.1.
|
|
68
|
+
"rimraf": "^6.1.2",
|
|
69
|
+
"tsx": "^4.20.6",
|
|
69
70
|
"type-fest": "^5.2.0"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "74eab627b3c0388b1f96c802df1674b37d42838f"
|
|
72
73
|
}
|