bod 5.21.7 → 6.0.0
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 +3 -3
- package/dist/src/bod.js +34 -0
- package/dist/{commands → src/commands}/BaseCommand.js +3 -5
- package/dist/{commands → src/commands}/CreateCommand.d.ts +1 -1
- package/dist/{commands → src/commands}/CreateCommand.js +17 -20
- package/dist/{commands → src/commands}/InfoCommand.d.ts +1 -1
- package/dist/{commands → src/commands}/InfoCommand.js +9 -11
- package/dist/{commands → src/commands}/__tests__/BaseCommand.test.js +10 -11
- package/dist/src/commands/__tests__/CreateCommand.test.js +81 -0
- package/dist/src/commands/__tests__/InfoCommand.test.js +22 -0
- package/dist/{commands → src/commands}/__tests__/index.test.js +5 -6
- package/dist/src/commands/index.d.ts +3 -0
- package/dist/src/commands/index.js +3 -0
- package/dist/{index.d.ts → src/index.d.ts} +1 -1
- package/dist/src/index.js +7 -0
- package/dist/src/utils/__tests__/index.test.js +25 -0
- package/dist/src/utils/console.js +3 -0
- package/dist/src/utils/core.d.ts +4 -0
- package/dist/src/utils/core.js +6 -0
- package/dist/src/utils/index.d.ts +5 -0
- package/dist/src/utils/index.js +17 -0
- package/dist/src/utils/os.js +3 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +20 -0
- package/dist/vitest.setup.d.ts +1 -0
- package/dist/vitest.setup.js +6 -0
- package/package.json +10 -9
- package/dist/bod.js +0 -34
- package/dist/commands/__tests__/CreateCommand.test.js +0 -96
- package/dist/commands/__tests__/InfoCommand.test.js +0 -24
- package/dist/commands/index.d.ts +0 -3
- package/dist/commands/index.js +0 -10
- package/dist/index.js +0 -10
- package/dist/utils/__tests__/index.test.js +0 -27
- package/dist/utils/console.js +0 -8
- package/dist/utils/core.d.ts +0 -6
- package/dist/utils/core.js +0 -11
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/index.js +0 -27
- package/dist/utils/os.js +0 -8
- /package/dist/{bod.d.ts → src/bod.d.ts} +0 -0
- /package/dist/{commands → src/commands}/BaseCommand.d.ts +0 -0
- /package/dist/{commands → src/commands}/__tests__/BaseCommand.test.d.ts +0 -0
- /package/dist/{commands → src/commands}/__tests__/CreateCommand.test.d.ts +0 -0
- /package/dist/{commands → src/commands}/__tests__/InfoCommand.test.d.ts +0 -0
- /package/dist/{commands → src/commands}/__tests__/index.test.d.ts +0 -0
- /package/dist/{utils → src/utils}/__tests__/index.test.d.ts +0 -0
- /package/dist/{utils → src/utils}/console.d.ts +0 -0
- /package/dist/{utils → src/utils}/os.d.ts +0 -0
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
[](https://cdn.jsdelivr.net/npm/bod@latest/)
|
|
9
9
|
|
|
10
10
|
[](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
|
|
11
|
-
[](https://codecov.io/gh/sabertazimi/bod)
|
|
12
|
+
[](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
|
|
13
13
|
|
|
14
14
|
Boilerplate CLI App - Create a new project powered by Create React App and @sabertazimi/react-scripts.
|
|
15
15
|
|
|
@@ -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/src/bod.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var _a;
|
|
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
|
+
.command(command.getUsage())
|
|
16
|
+
.alias(command.getAlias())
|
|
17
|
+
.description(command.getDescription())
|
|
18
|
+
.action((appName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
try {
|
|
20
|
+
yield command.run(appName);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
printer.error(error);
|
|
24
|
+
program.outputHelp();
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
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
|
+
});
|
|
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,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const BaseCommand_1 = tslib_1.__importDefault(require("../BaseCommand"));
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import BaseCommand from '../BaseCommand.js';
|
|
5
4
|
const options = {
|
|
6
5
|
name: 'base',
|
|
7
6
|
description: 'Base command description',
|
|
@@ -10,27 +9,27 @@ const options = {
|
|
|
10
9
|
};
|
|
11
10
|
describe('baseCommand', () => {
|
|
12
11
|
it('should have [name] field', () => {
|
|
13
|
-
const baseCommand = new
|
|
12
|
+
const baseCommand = new BaseCommand(options);
|
|
14
13
|
expect(baseCommand.getName()).toBe(options.name);
|
|
15
14
|
});
|
|
16
15
|
it('should have [description] field', () => {
|
|
17
|
-
const baseCommand = new
|
|
16
|
+
const baseCommand = new BaseCommand(options);
|
|
18
17
|
expect(baseCommand.getDescription()).toBe(options.description);
|
|
19
18
|
});
|
|
20
19
|
it('should have [usage] field', () => {
|
|
21
|
-
const baseCommand = new
|
|
20
|
+
const baseCommand = new BaseCommand(options);
|
|
22
21
|
expect(baseCommand.getUsage()).toBe(options.usage);
|
|
23
22
|
});
|
|
24
23
|
it('should have [alias] field', () => {
|
|
25
|
-
const baseCommand = new
|
|
24
|
+
const baseCommand = new BaseCommand(options);
|
|
26
25
|
expect(baseCommand.getAlias()).toBe(options.alias);
|
|
27
26
|
});
|
|
28
27
|
it('should set [alias] field to first character of [name] field by default', () => {
|
|
29
|
-
const baseCommand = new
|
|
28
|
+
const baseCommand = new BaseCommand(Object.assign(Object.assign({}, options), { alias: undefined }));
|
|
30
29
|
expect(baseCommand.getAlias()).toBe(options.name[0]);
|
|
31
30
|
});
|
|
32
|
-
it('should have [run] method', () =>
|
|
33
|
-
const baseCommand = new
|
|
31
|
+
it('should have [run] method', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const baseCommand = new BaseCommand(options);
|
|
34
33
|
yield expect(baseCommand.run()).resolves.toBeUndefined();
|
|
35
34
|
}));
|
|
36
35
|
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { isCI } from 'ci-info';
|
|
3
|
+
import { sync } from 'rimraf';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import * as utils from '../../utils/index.js';
|
|
6
|
+
import CreateCommand from '../CreateCommand.js';
|
|
7
|
+
const { spawn } = utils;
|
|
8
|
+
const appPath = 'bod-unit-tests';
|
|
9
|
+
describe('createCommand', () => {
|
|
10
|
+
beforeEach(() => sync(appPath));
|
|
11
|
+
afterEach(() => sync(appPath));
|
|
12
|
+
it('should extends [BaseCommand] fields', () => {
|
|
13
|
+
const createCommand = new CreateCommand();
|
|
14
|
+
expect(createCommand.getName()).toBe('create');
|
|
15
|
+
expect(createCommand.getDescription()).toBe('Create a new project powered by @sabertazimi/react-scripts');
|
|
16
|
+
expect(createCommand.getUsage()).toBe('create <appName>');
|
|
17
|
+
expect(createCommand.getAlias()).toBe('c');
|
|
18
|
+
});
|
|
19
|
+
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 }) {
|
|
20
|
+
const mockSelect = vi
|
|
21
|
+
.spyOn(utils, 'select')
|
|
22
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return value; }));
|
|
23
|
+
const mockSpawn = vi.spyOn(spawn, 'sync').mockImplementation(() => {
|
|
24
|
+
return {
|
|
25
|
+
status: 0,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const additionalOptions = value === 'vue'
|
|
29
|
+
? ['--default']
|
|
30
|
+
: value === 'vite'
|
|
31
|
+
? ['--template', 'vue']
|
|
32
|
+
: [];
|
|
33
|
+
const createCommand = new CreateCommand();
|
|
34
|
+
yield expect(createCommand.run(appPath, additionalOptions)).resolves.toBeUndefined();
|
|
35
|
+
const { command, args, postCommands } = CreateCommand.TemplateActions.find(action => action.value === value);
|
|
36
|
+
expect(createCommand.getCommand()).toBe(command);
|
|
37
|
+
expect(createCommand.getCommandArgs()).toHaveLength(args.length + 1);
|
|
38
|
+
expect(createCommand.getCommandArgs()).toStrictEqual(args.concat(appPath));
|
|
39
|
+
expect(mockSelect).toHaveBeenCalledTimes(1);
|
|
40
|
+
expect(mockSpawn).toHaveBeenCalledTimes(postCommands.length + 1);
|
|
41
|
+
mockSelect.mockRestore();
|
|
42
|
+
mockSpawn.mockRestore();
|
|
43
|
+
}));
|
|
44
|
+
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 }) {
|
|
45
|
+
const mockSelect = vi
|
|
46
|
+
.spyOn(utils, 'select')
|
|
47
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return value; }));
|
|
48
|
+
const mockSpawn = vi.spyOn(spawn, 'sync').mockImplementation(() => {
|
|
49
|
+
return {
|
|
50
|
+
status: 1,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
const additionalOptions = value === 'vue'
|
|
54
|
+
? ['--default']
|
|
55
|
+
: value === 'vite'
|
|
56
|
+
? ['--template', 'vue']
|
|
57
|
+
: [];
|
|
58
|
+
const createCommand = new CreateCommand();
|
|
59
|
+
yield expect(createCommand.run(appPath, additionalOptions)).rejects.toThrow();
|
|
60
|
+
expect(mockSelect).toHaveBeenCalledTimes(1);
|
|
61
|
+
expect(mockSpawn).toHaveBeenCalledTimes(1);
|
|
62
|
+
mockSelect.mockRestore();
|
|
63
|
+
mockSpawn.mockRestore();
|
|
64
|
+
}));
|
|
65
|
+
it.each(CreateCommand.TemplateActions)('should initialize app directory via template choice [$name]', { timeout: 120000 }, (_a) => __awaiter(void 0, [_a], void 0, function* ({ value }) {
|
|
66
|
+
const mockSelect = vi
|
|
67
|
+
.spyOn(utils, 'select')
|
|
68
|
+
.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return value; }));
|
|
69
|
+
const additionalOptions = value === 'vue'
|
|
70
|
+
? ['--default']
|
|
71
|
+
: value === 'vite'
|
|
72
|
+
? ['--template', 'vue']
|
|
73
|
+
: [];
|
|
74
|
+
const createCommand = new CreateCommand();
|
|
75
|
+
if (isCI) {
|
|
76
|
+
yield expect(createCommand.run(appPath, additionalOptions)).resolves.toBeUndefined();
|
|
77
|
+
expect(mockSelect).toHaveBeenCalledTimes(1);
|
|
78
|
+
}
|
|
79
|
+
mockSelect.mockRestore();
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { printer } from '../../utils/index.js';
|
|
4
|
+
import InfoCommand from '../InfoCommand.js';
|
|
5
|
+
describe('infoCommand', () => {
|
|
6
|
+
it('should extends [BaseCommand] fields', () => {
|
|
7
|
+
const infoCommand = new InfoCommand();
|
|
8
|
+
expect(infoCommand.getName()).toBe('info');
|
|
9
|
+
expect(infoCommand.getDescription()).toBe('Print debugging information about your environment');
|
|
10
|
+
expect(infoCommand.getUsage()).toBe('info');
|
|
11
|
+
expect(infoCommand.getAlias()).toBe('i');
|
|
12
|
+
});
|
|
13
|
+
it('should print environment variables', { timeout: 20000 }, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const mockConsoleInfo = vi
|
|
15
|
+
.spyOn(printer, 'info')
|
|
16
|
+
.mockImplementation(vi.fn());
|
|
17
|
+
const infoCommand = new InfoCommand();
|
|
18
|
+
yield expect(infoCommand.run()).resolves.toBeUndefined();
|
|
19
|
+
expect(mockConsoleInfo).toHaveBeenCalledTimes(2);
|
|
20
|
+
mockConsoleInfo.mockRestore();
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const index_1 = require("../index");
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { BaseCommand, CreateCommand, InfoCommand } from '../index.js';
|
|
4
3
|
describe('commands', () => {
|
|
5
4
|
let commands;
|
|
6
5
|
let counts;
|
|
7
6
|
beforeEach(() => {
|
|
8
7
|
commands = new Set([
|
|
9
|
-
new
|
|
8
|
+
new BaseCommand({
|
|
10
9
|
name: 'base',
|
|
11
10
|
description: 'Base command description',
|
|
12
11
|
usage: 'base',
|
|
13
12
|
}),
|
|
14
|
-
new
|
|
15
|
-
new
|
|
13
|
+
new CreateCommand(),
|
|
14
|
+
new InfoCommand(),
|
|
16
15
|
]);
|
|
17
16
|
counts = new Map();
|
|
18
17
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CreateCommand, InfoCommand } from './commands/index.js';
|
|
2
|
+
const CommandFactory = new Map();
|
|
3
|
+
const createCommand = new CreateCommand();
|
|
4
|
+
const infoCommand = new InfoCommand();
|
|
5
|
+
CommandFactory.set(createCommand.getName(), createCommand);
|
|
6
|
+
CommandFactory.set(infoCommand.getName(), infoCommand);
|
|
7
|
+
export { CommandFactory };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { color, findPackageManager, program } from '../index.js';
|
|
4
|
+
describe('utils', () => {
|
|
5
|
+
it('should execute chalk correctly', () => {
|
|
6
|
+
expect(color('raw text')).toStrictEqual('raw text');
|
|
7
|
+
});
|
|
8
|
+
it('should execute program correctly', () => {
|
|
9
|
+
const mockParse = vi.spyOn(program, 'parse').mockImplementation(vi.fn());
|
|
10
|
+
expect(process.env.__BOD__).toStrictEqual('__BOD__');
|
|
11
|
+
mockParse.mockRestore();
|
|
12
|
+
});
|
|
13
|
+
it('should return correct package manager', () => {
|
|
14
|
+
process.env.npm_config_user_agent = 'pnpm/8.15.0';
|
|
15
|
+
expect(findPackageManager()).toStrictEqual('pnpm');
|
|
16
|
+
process.env.npm_config_user_agent = 'yarn/1.22.22';
|
|
17
|
+
expect(findPackageManager()).toStrictEqual('yarn');
|
|
18
|
+
process.env.npm_config_user_agent = 'yarn/4.2.0';
|
|
19
|
+
expect(findPackageManager()).toStrictEqual('yarn');
|
|
20
|
+
process.env.npm_config_user_agent = 'bun/0.1.0';
|
|
21
|
+
expect(findPackageManager()).toStrictEqual('bun');
|
|
22
|
+
process.env.npm_config_user_agent = 'npm/10.0.0';
|
|
23
|
+
expect(findPackageManager()).toStrictEqual('npm');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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';
|
|
5
|
+
function findPackageManager() {
|
|
6
|
+
var _a;
|
|
7
|
+
const userAgent = (_a = process.env.npm_config_user_agent) !== null && _a !== void 0 ? _a : '';
|
|
8
|
+
const packageManager = /pnpm/.test(userAgent)
|
|
9
|
+
? 'pnpm'
|
|
10
|
+
: /yarn/.test(userAgent)
|
|
11
|
+
? 'yarn'
|
|
12
|
+
: /bun/.test(userAgent)
|
|
13
|
+
? 'bun'
|
|
14
|
+
: 'npm';
|
|
15
|
+
return packageManager;
|
|
16
|
+
}
|
|
17
|
+
export { color, envinfo, findPackageManager, printer, program, select, spawn };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
export default defineConfig({
|
|
3
|
+
test: {
|
|
4
|
+
environment: 'node',
|
|
5
|
+
setupFiles: ['./vitest.setup.ts'],
|
|
6
|
+
coverage: {
|
|
7
|
+
provider: 'v8',
|
|
8
|
+
reportsDirectory: './coverage',
|
|
9
|
+
},
|
|
10
|
+
exclude: [
|
|
11
|
+
'node_modules',
|
|
12
|
+
'.cache',
|
|
13
|
+
'build',
|
|
14
|
+
'dist',
|
|
15
|
+
'coverage',
|
|
16
|
+
'temp',
|
|
17
|
+
'.temp',
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bod",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "6.0.0",
|
|
4
5
|
"description": "Boilerplate CLI App",
|
|
5
6
|
"author": "sabertazimi <sabertazimi@gmail.com>",
|
|
6
7
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://
|
|
8
|
+
"homepage": "https://tazimi.dev/bod",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "git+https://github.com/sabertazimi/bod.git",
|
|
@@ -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.2",
|
|
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.
|
|
69
|
-
"
|
|
68
|
+
"rimraf": "^6.1.2",
|
|
69
|
+
"tsx": "^4.21.0",
|
|
70
|
+
"type-fest": "^5.3.0"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c98290e1b374fdcffa21acd39ab8dac42d8d156d"
|
|
72
73
|
}
|
package/dist/bod.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
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"));
|
|
8
|
-
const index_1 = require("./index");
|
|
9
|
-
const utils_1 = require("./utils");
|
|
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');
|
|
13
|
-
for (const command of index_1.CommandFactory.values()) {
|
|
14
|
-
utils_1.program
|
|
15
|
-
.command(command.getUsage())
|
|
16
|
-
.alias(command.getAlias())
|
|
17
|
-
.description(command.getDescription())
|
|
18
|
-
.action((appName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
try {
|
|
20
|
-
yield command.run(appName);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
utils_1.printer.error(error);
|
|
24
|
-
utils_1.program.outputHelp();
|
|
25
|
-
}
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
utils_1.program.on('--help', () => {
|
|
29
|
-
utils_1.printer.log('');
|
|
30
|
-
utils_1.printer.info(` Run ${utils_1.color.cyan(`bod <command> --help`)} for detailed usage of given command.`);
|
|
31
|
-
utils_1.printer.log('');
|
|
32
|
-
});
|
|
33
|
-
utils_1.program.showHelpAfterError();
|
|
34
|
-
utils_1.program.parse(node_process_1.default.argv);
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const ci_info_1 = require("ci-info");
|
|
5
|
-
const rimraf_1 = require("rimraf");
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const CreateCommand_1 = tslib_1.__importDefault(require("../CreateCommand"));
|
|
8
|
-
const appPath = 'bod-unit-tests';
|
|
9
|
-
describe('createCommand', () => {
|
|
10
|
-
beforeEach(() => (0, rimraf_1.sync)(appPath));
|
|
11
|
-
afterEach(() => (0, rimraf_1.sync)(appPath));
|
|
12
|
-
it('should extends [BaseCommand] fields', () => {
|
|
13
|
-
const createCommand = new CreateCommand_1.default();
|
|
14
|
-
expect(createCommand.getName()).toBe('create');
|
|
15
|
-
expect(createCommand.getDescription()).toBe('Create a new project powered by @sabertazimi/react-scripts');
|
|
16
|
-
expect(createCommand.getUsage()).toBe('create <appName>');
|
|
17
|
-
expect(createCommand.getAlias()).toBe('c');
|
|
18
|
-
});
|
|
19
|
-
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 }) {
|
|
20
|
-
const mockPrompt = jest
|
|
21
|
-
.spyOn(utils_1.inquirer, 'prompt')
|
|
22
|
-
.mockImplementation(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const promise = new Promise((resolve) => {
|
|
24
|
-
resolve({ templateName: value });
|
|
25
|
-
});
|
|
26
|
-
return promise;
|
|
27
|
-
}));
|
|
28
|
-
const mockSpawn = jest.spyOn(utils_1.spawn, 'sync').mockImplementation(() => {
|
|
29
|
-
return {
|
|
30
|
-
status: 0,
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
const additionalOptions = value === 'vue'
|
|
34
|
-
? ['--default']
|
|
35
|
-
: value === 'vite'
|
|
36
|
-
? ['--template', 'vue']
|
|
37
|
-
: [];
|
|
38
|
-
const createCommand = new CreateCommand_1.default();
|
|
39
|
-
yield expect(createCommand.run(appPath, additionalOptions)).resolves.toBeUndefined();
|
|
40
|
-
const { command, args, postCommands } = CreateCommand_1.default.TemplateActions.find(action => action.value === value);
|
|
41
|
-
expect(createCommand.getCommand()).toBe(command);
|
|
42
|
-
expect(createCommand.getCommandArgs()).toHaveLength(args.length + 1);
|
|
43
|
-
expect(createCommand.getCommandArgs()).toStrictEqual(args.concat(appPath));
|
|
44
|
-
expect(mockPrompt).toHaveBeenCalledTimes(1);
|
|
45
|
-
expect(mockSpawn).toHaveBeenCalledTimes(postCommands.length + 1);
|
|
46
|
-
mockPrompt.mockRestore();
|
|
47
|
-
mockSpawn.mockRestore();
|
|
48
|
-
}));
|
|
49
|
-
it.each(CreateCommand_1.default.TemplateActions)('should throw error when exited with non zero via template choice [$name]', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value }) {
|
|
50
|
-
const mockPrompt = jest
|
|
51
|
-
.spyOn(utils_1.inquirer, 'prompt')
|
|
52
|
-
.mockImplementation(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const promise = new Promise((resolve) => {
|
|
54
|
-
resolve({ templateName: value });
|
|
55
|
-
});
|
|
56
|
-
return promise;
|
|
57
|
-
}));
|
|
58
|
-
const mockSpawn = jest.spyOn(utils_1.spawn, 'sync').mockImplementation(() => {
|
|
59
|
-
return {
|
|
60
|
-
status: 1,
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
const additionalOptions = value === 'vue'
|
|
64
|
-
? ['--default']
|
|
65
|
-
: value === 'vite'
|
|
66
|
-
? ['--template', 'vue']
|
|
67
|
-
: [];
|
|
68
|
-
const createCommand = new CreateCommand_1.default();
|
|
69
|
-
yield expect(createCommand.run(appPath, additionalOptions)).rejects.toThrow();
|
|
70
|
-
expect(mockPrompt).toHaveBeenCalledTimes(1);
|
|
71
|
-
expect(mockSpawn).toHaveBeenCalledTimes(1);
|
|
72
|
-
mockPrompt.mockRestore();
|
|
73
|
-
mockSpawn.mockRestore();
|
|
74
|
-
}));
|
|
75
|
-
it.each(CreateCommand_1.default.TemplateActions)('should initialize app directory via template choice [$name]', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value }) {
|
|
76
|
-
const mockPrompt = jest
|
|
77
|
-
.spyOn(utils_1.inquirer, 'prompt')
|
|
78
|
-
.mockImplementation(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
const promise = new Promise((resolve) => {
|
|
80
|
-
resolve({ templateName: value });
|
|
81
|
-
});
|
|
82
|
-
return promise;
|
|
83
|
-
}));
|
|
84
|
-
const additionalOptions = value === 'vue'
|
|
85
|
-
? ['--default']
|
|
86
|
-
: value === 'vite'
|
|
87
|
-
? ['--template', 'vue']
|
|
88
|
-
: [];
|
|
89
|
-
const createCommand = new CreateCommand_1.default();
|
|
90
|
-
if (ci_info_1.isCI) {
|
|
91
|
-
yield expect(createCommand.run(appPath, additionalOptions)).resolves.toBeUndefined();
|
|
92
|
-
expect(mockPrompt).toHaveBeenCalledTimes(1);
|
|
93
|
-
}
|
|
94
|
-
mockPrompt.mockRestore();
|
|
95
|
-
}));
|
|
96
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
});
|
package/dist/commands/index.d.ts
DELETED
package/dist/commands/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InfoCommand = exports.CreateCommand = exports.BaseCommand = void 0;
|
|
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; } });
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandFactory = void 0;
|
|
4
|
-
const commands_1 = require("./commands");
|
|
5
|
-
const CommandFactory = new Map();
|
|
6
|
-
exports.CommandFactory = CommandFactory;
|
|
7
|
-
const createCommand = new commands_1.CreateCommand();
|
|
8
|
-
const infoCommand = new commands_1.InfoCommand();
|
|
9
|
-
CommandFactory.set(createCommand.getName(), createCommand);
|
|
10
|
-
CommandFactory.set(infoCommand.getName(), infoCommand);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
5
|
-
const index_1 = require("../index");
|
|
6
|
-
describe('utils', () => {
|
|
7
|
-
it('should execute chalk correctly', () => {
|
|
8
|
-
expect((0, index_1.color)('raw text')).toStrictEqual('raw text');
|
|
9
|
-
});
|
|
10
|
-
it('should execute program correctly', () => {
|
|
11
|
-
const mockParse = jest.spyOn(index_1.program, 'parse').mockImplementation(jest.fn());
|
|
12
|
-
expect(node_process_1.default.env.__BOD__).toStrictEqual('__BOD__');
|
|
13
|
-
mockParse.mockRestore();
|
|
14
|
-
});
|
|
15
|
-
it('should return correct package manager', () => {
|
|
16
|
-
node_process_1.default.env.npm_config_user_agent = 'pnpm/8.15.0';
|
|
17
|
-
expect((0, index_1.findPackageManager)()).toStrictEqual('pnpm');
|
|
18
|
-
node_process_1.default.env.npm_config_user_agent = 'yarn/1.22.22';
|
|
19
|
-
expect((0, index_1.findPackageManager)()).toStrictEqual('yarn');
|
|
20
|
-
node_process_1.default.env.npm_config_user_agent = 'yarn/4.2.0';
|
|
21
|
-
expect((0, index_1.findPackageManager)()).toStrictEqual('yarn');
|
|
22
|
-
node_process_1.default.env.npm_config_user_agent = 'bun/0.1.0';
|
|
23
|
-
expect((0, index_1.findPackageManager)()).toStrictEqual('bun');
|
|
24
|
-
node_process_1.default.env.npm_config_user_agent = 'npm/10.0.0';
|
|
25
|
-
expect((0, index_1.findPackageManager)()).toStrictEqual('npm');
|
|
26
|
-
});
|
|
27
|
-
});
|
package/dist/utils/console.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printer = exports.color = void 0;
|
|
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;
|
package/dist/utils/core.d.ts
DELETED
package/dist/utils/core.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.program = exports.inquirer = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
6
|
-
const commander_1 = require("commander");
|
|
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__';
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Answers } from './core';
|
|
2
|
-
import { color, printer } from './console';
|
|
3
|
-
import { inquirer, program } from './core';
|
|
4
|
-
import { envinfo, spawn } from './os';
|
|
5
|
-
declare function findPackageManager(): string;
|
|
6
|
-
export { color, envinfo, findPackageManager, inquirer, printer, program, spawn };
|
|
7
|
-
export type { Answers };
|
package/dist/utils/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawn = exports.program = exports.printer = exports.inquirer = exports.envinfo = exports.color = void 0;
|
|
4
|
-
exports.findPackageManager = findPackageManager;
|
|
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; } });
|
|
16
|
-
function findPackageManager() {
|
|
17
|
-
var _a;
|
|
18
|
-
const userAgent = (_a = node_process_1.default.env.npm_config_user_agent) !== null && _a !== void 0 ? _a : '';
|
|
19
|
-
const packageManager = /pnpm/.test(userAgent)
|
|
20
|
-
? 'pnpm'
|
|
21
|
-
: /yarn/.test(userAgent)
|
|
22
|
-
? 'yarn'
|
|
23
|
-
: /bun/.test(userAgent)
|
|
24
|
-
? 'bun'
|
|
25
|
-
: 'npm';
|
|
26
|
-
return packageManager;
|
|
27
|
-
}
|
package/dist/utils/os.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawn = exports.envinfo = void 0;
|
|
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;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|