@modern-js/generator-utils 1.1.1 → 1.1.3
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/CHANGELOG.md +17 -0
- package/dist/js/modern/index.js +2 -25
- package/dist/js/modern/utils/index.js +0 -1
- package/dist/js/node/index.js +31 -31
- package/dist/js/node/utils/index.js +0 -13
- package/dist/types/index.d.ts +1 -2
- package/dist/types/utils/index.d.ts +0 -1
- package/package.json +9 -7
- package/src/index.ts +15 -21
- package/src/utils/index.ts +0 -1
- package/tests/index.test.ts +1 -13
- package/tests/tsconfig.json +1 -3
- package/tsconfig.json +1 -3
- package/dist/js/modern/utils/env.js +0 -31
- package/dist/js/node/utils/env.js +0 -45
- package/dist/types/utils/env.d.ts +0 -3
- package/src/utils/env.ts +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @modern-js/generator-utils
|
|
2
2
|
|
|
3
|
+
## 1.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f73fee4b: feat: upgrade codesmith version to add get npm package timeout's time
|
|
8
|
+
|
|
9
|
+
## 1.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 4819a3c7: feat: update generator version
|
|
14
|
+
- b7fb82ec: fix: get package manager function
|
|
15
|
+
- Updated dependencies [5e3de7d8]
|
|
16
|
+
- Updated dependencies [b7fb82ec]
|
|
17
|
+
- @modern-js/plugin-i18n@1.1.2
|
|
18
|
+
- @modern-js/utils@1.1.6
|
|
19
|
+
|
|
3
20
|
## 1.1.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
1
|
import path from 'path';
|
|
3
|
-
import { fs, getMonorepoPackages } from '@modern-js/utils';
|
|
2
|
+
import { fs, getMonorepoPackages, canUseNpm, canUsePnpm, canUseYarn } from '@modern-js/utils';
|
|
4
3
|
import execa from 'execa';
|
|
5
4
|
import ora from 'ora';
|
|
6
|
-
import { canUseNpm, canUsePnpm, canUseYarn } from "./utils/env";
|
|
7
5
|
import { stripAnsi } from "./utils/strip-ansi";
|
|
8
6
|
import { i18n, localeKeys } from "./locale";
|
|
9
7
|
export * from "./utils";
|
|
10
|
-
export { fs, readTsConfigByFile } from '@modern-js/utils';
|
|
8
|
+
export { fs, readTsConfigByFile, getPackageManager, canUseNpm, canUsePnpm, canUseYarn } from '@modern-js/utils';
|
|
11
9
|
export { i18n } from "./locale"; // eslint-disable-next-line max-statements
|
|
12
10
|
|
|
13
11
|
export async function getPackageVersion(packageName, registry) {
|
|
@@ -53,27 +51,6 @@ export async function getPackageVersion(packageName, registry) {
|
|
|
53
51
|
spinner.stop();
|
|
54
52
|
throw new Error('not found npm, please install npm before');
|
|
55
53
|
}
|
|
56
|
-
export function getPackageManager(cwd = process.cwd()) {
|
|
57
|
-
let appDirectory = cwd;
|
|
58
|
-
|
|
59
|
-
while (os.homedir() !== appDirectory) {
|
|
60
|
-
if (fs.existsSync(path.resolve(appDirectory, 'pnpm-lock.yaml'))) {
|
|
61
|
-
return 'pnpm';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (fs.existsSync(path.resolve(appDirectory, 'yarn.lock'))) {
|
|
65
|
-
return 'yarn';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (fs.existsSync(path.resolve(appDirectory, 'package-lock.json'))) {
|
|
69
|
-
return 'npm';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
appDirectory = path.join(appDirectory, '..');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return 'npm';
|
|
76
|
-
}
|
|
77
54
|
export function getPackageManagerText(packageManager) {
|
|
78
55
|
return packageManager === 'yarn' ? 'yarn' : `${packageManager} run`;
|
|
79
56
|
}
|
package/dist/js/node/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
getPackageVersion: true,
|
|
8
|
-
getPackageManager: true,
|
|
9
8
|
getPackageManagerText: true,
|
|
10
9
|
isTsProject: true,
|
|
11
10
|
getPackageObj: true,
|
|
@@ -16,8 +15,30 @@ var _exportNames = {
|
|
|
16
15
|
getMWAProjectPath: true,
|
|
17
16
|
fs: true,
|
|
18
17
|
readTsConfigByFile: true,
|
|
18
|
+
getPackageManager: true,
|
|
19
|
+
canUseNpm: true,
|
|
20
|
+
canUsePnpm: true,
|
|
21
|
+
canUseYarn: true,
|
|
19
22
|
i18n: true
|
|
20
23
|
};
|
|
24
|
+
Object.defineProperty(exports, "canUseNpm", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _utils.canUseNpm;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "canUsePnpm", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _utils.canUsePnpm;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "canUseYarn", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _utils.canUseYarn;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
21
42
|
Object.defineProperty(exports, "fs", {
|
|
22
43
|
enumerable: true,
|
|
23
44
|
get: function () {
|
|
@@ -27,7 +48,12 @@ Object.defineProperty(exports, "fs", {
|
|
|
27
48
|
exports.getAllPackages = getAllPackages;
|
|
28
49
|
exports.getMWAProjectPath = getMWAProjectPath;
|
|
29
50
|
exports.getModuleProjectPath = getModuleProjectPath;
|
|
30
|
-
exports
|
|
51
|
+
Object.defineProperty(exports, "getPackageManager", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _utils.getPackageManager;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
31
57
|
exports.getPackageManagerText = getPackageManagerText;
|
|
32
58
|
exports.getPackageObj = getPackageObj;
|
|
33
59
|
exports.getPackageVersion = getPackageVersion;
|
|
@@ -47,8 +73,6 @@ Object.defineProperty(exports, "readTsConfigByFile", {
|
|
|
47
73
|
exports.validatePackageName = validatePackageName;
|
|
48
74
|
exports.validatePackagePath = validatePackagePath;
|
|
49
75
|
|
|
50
|
-
var _os = _interopRequireDefault(require("os"));
|
|
51
|
-
|
|
52
76
|
var _path = _interopRequireDefault(require("path"));
|
|
53
77
|
|
|
54
78
|
var _utils = require("@modern-js/utils");
|
|
@@ -57,8 +81,6 @@ var _execa = _interopRequireDefault(require("execa"));
|
|
|
57
81
|
|
|
58
82
|
var _ora = _interopRequireDefault(require("ora"));
|
|
59
83
|
|
|
60
|
-
var _env = require("./utils/env");
|
|
61
|
-
|
|
62
84
|
var _stripAnsi = require("./utils/strip-ansi");
|
|
63
85
|
|
|
64
86
|
var _locale = require("./locale");
|
|
@@ -84,7 +106,7 @@ async function getPackageVersion(packageName, registry) {
|
|
|
84
106
|
const spinner = (0, _ora.default)('Loading...').start();
|
|
85
107
|
spinner.color = 'yellow';
|
|
86
108
|
|
|
87
|
-
if (await (0,
|
|
109
|
+
if (await (0, _utils.canUsePnpm)()) {
|
|
88
110
|
const args = ['info', packageName, 'version'];
|
|
89
111
|
|
|
90
112
|
if (registry) {
|
|
@@ -96,7 +118,7 @@ async function getPackageVersion(packageName, registry) {
|
|
|
96
118
|
return (0, _stripAnsi.stripAnsi)(result.stdout);
|
|
97
119
|
}
|
|
98
120
|
|
|
99
|
-
if (await (0,
|
|
121
|
+
if (await (0, _utils.canUseYarn)()) {
|
|
100
122
|
const args = ['info', packageName, 'version', '--silent'];
|
|
101
123
|
|
|
102
124
|
if (registry) {
|
|
@@ -108,7 +130,7 @@ async function getPackageVersion(packageName, registry) {
|
|
|
108
130
|
return (0, _stripAnsi.stripAnsi)(result.stdout);
|
|
109
131
|
}
|
|
110
132
|
|
|
111
|
-
if (await (0,
|
|
133
|
+
if (await (0, _utils.canUseNpm)()) {
|
|
112
134
|
const args = ['view', packageName, 'version'];
|
|
113
135
|
|
|
114
136
|
if (registry) {
|
|
@@ -124,28 +146,6 @@ async function getPackageVersion(packageName, registry) {
|
|
|
124
146
|
throw new Error('not found npm, please install npm before');
|
|
125
147
|
}
|
|
126
148
|
|
|
127
|
-
function getPackageManager(cwd = process.cwd()) {
|
|
128
|
-
let appDirectory = cwd;
|
|
129
|
-
|
|
130
|
-
while (_os.default.homedir() !== appDirectory) {
|
|
131
|
-
if (_utils.fs.existsSync(_path.default.resolve(appDirectory, 'pnpm-lock.yaml'))) {
|
|
132
|
-
return 'pnpm';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (_utils.fs.existsSync(_path.default.resolve(appDirectory, 'yarn.lock'))) {
|
|
136
|
-
return 'yarn';
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (_utils.fs.existsSync(_path.default.resolve(appDirectory, 'package-lock.json'))) {
|
|
140
|
-
return 'npm';
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
appDirectory = _path.default.join(appDirectory, '..');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return 'npm';
|
|
147
|
-
}
|
|
148
|
-
|
|
149
149
|
function getPackageManagerText(packageManager) {
|
|
150
150
|
return packageManager === 'yarn' ? 'yarn' : `${packageManager} run`;
|
|
151
151
|
}
|
|
@@ -4,19 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _env = require("./env");
|
|
8
|
-
|
|
9
|
-
Object.keys(_env).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _env[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _env[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
7
|
var _stripAnsi = require("./strip-ansi");
|
|
21
8
|
|
|
22
9
|
Object.keys(_stripAnsi).forEach(function (key) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { GeneratorContext } from '@modern-js/codesmith';
|
|
2
2
|
export * from './utils';
|
|
3
|
-
export { fs, readTsConfigByFile } from '@modern-js/utils';
|
|
3
|
+
export { fs, readTsConfigByFile, getPackageManager, canUseNpm, canUsePnpm, canUseYarn } from '@modern-js/utils';
|
|
4
4
|
export { i18n } from './locale';
|
|
5
5
|
export declare function getPackageVersion(packageName: string, registry?: string): Promise<string>;
|
|
6
|
-
export declare function getPackageManager(cwd?: string): "npm" | "yarn" | "pnpm";
|
|
7
6
|
export declare function getPackageManagerText(packageManager: 'pnpm' | 'yarn' | 'npm'): string;
|
|
8
7
|
export declare function isTsProject(appDir: string): boolean;
|
|
9
8
|
export declare function getPackageObj(context: GeneratorContext): Promise<any>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1.
|
|
14
|
+
"version": "1.1.3",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"node": {
|
|
23
|
+
"jsnext:source": "./src/index.ts",
|
|
23
24
|
"import": "./dist/js/modern/index.js",
|
|
24
25
|
"require": "./dist/js/node/index.js"
|
|
25
26
|
},
|
|
@@ -28,18 +29,18 @@
|
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@babel/runtime": "^7",
|
|
31
|
-
"@modern-js/plugin-i18n": "^1.1.
|
|
32
|
-
"@modern-js/utils": "^1.1.
|
|
32
|
+
"@modern-js/plugin-i18n": "^1.1.2",
|
|
33
|
+
"@modern-js/utils": "^1.1.6",
|
|
33
34
|
"execa": "^5.1.1",
|
|
34
35
|
"ora": "^5.4.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@modern-js/codesmith": "^1.0.
|
|
38
|
+
"@modern-js/codesmith": "^1.0.8",
|
|
38
39
|
"@types/jest": "^26",
|
|
39
40
|
"@types/node": "^14",
|
|
40
41
|
"typescript": "^4",
|
|
41
|
-
"@modern-js/module-tools": "^1.1.
|
|
42
|
-
"@modern-js/plugin-testing": "^1.
|
|
42
|
+
"@modern-js/module-tools": "^1.1.5",
|
|
43
|
+
"@modern-js/plugin-testing": "^1.2.2"
|
|
43
44
|
},
|
|
44
45
|
"sideEffects": false,
|
|
45
46
|
"modernConfig": {
|
|
@@ -55,5 +56,6 @@
|
|
|
55
56
|
"new": "modern new",
|
|
56
57
|
"build": "modern build",
|
|
57
58
|
"test": "modern test --passWithNoTests"
|
|
58
|
-
}
|
|
59
|
+
},
|
|
60
|
+
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
|
59
61
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
1
|
import path from 'path';
|
|
3
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
fs,
|
|
4
|
+
getMonorepoPackages,
|
|
5
|
+
canUseNpm,
|
|
6
|
+
canUsePnpm,
|
|
7
|
+
canUseYarn,
|
|
8
|
+
} from '@modern-js/utils';
|
|
4
9
|
import execa from 'execa';
|
|
5
10
|
import ora from 'ora';
|
|
6
11
|
import { GeneratorContext } from '@modern-js/codesmith';
|
|
7
|
-
import { canUseNpm, canUsePnpm, canUseYarn } from './utils/env';
|
|
8
12
|
import { stripAnsi } from './utils/strip-ansi';
|
|
9
13
|
import { i18n, localeKeys } from './locale';
|
|
10
14
|
|
|
11
15
|
export * from './utils';
|
|
12
16
|
|
|
13
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
fs,
|
|
19
|
+
readTsConfigByFile,
|
|
20
|
+
getPackageManager,
|
|
21
|
+
canUseNpm,
|
|
22
|
+
canUsePnpm,
|
|
23
|
+
canUseYarn,
|
|
24
|
+
} from '@modern-js/utils';
|
|
14
25
|
|
|
15
26
|
export { i18n } from './locale';
|
|
16
27
|
|
|
@@ -52,23 +63,6 @@ export async function getPackageVersion(
|
|
|
52
63
|
throw new Error('not found npm, please install npm before');
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
export function getPackageManager(cwd: string = process.cwd()) {
|
|
56
|
-
let appDirectory = cwd;
|
|
57
|
-
while (os.homedir() !== appDirectory) {
|
|
58
|
-
if (fs.existsSync(path.resolve(appDirectory, 'pnpm-lock.yaml'))) {
|
|
59
|
-
return 'pnpm';
|
|
60
|
-
}
|
|
61
|
-
if (fs.existsSync(path.resolve(appDirectory, 'yarn.lock'))) {
|
|
62
|
-
return 'yarn';
|
|
63
|
-
}
|
|
64
|
-
if (fs.existsSync(path.resolve(appDirectory, 'package-lock.json'))) {
|
|
65
|
-
return 'npm';
|
|
66
|
-
}
|
|
67
|
-
appDirectory = path.join(appDirectory, '..');
|
|
68
|
-
}
|
|
69
|
-
return 'npm';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
66
|
export function getPackageManagerText(packageManager: 'pnpm' | 'yarn' | 'npm') {
|
|
73
67
|
return packageManager === 'yarn' ? 'yarn' : `${packageManager} run`;
|
|
74
68
|
}
|
package/src/utils/index.ts
CHANGED
package/tests/index.test.ts
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
import { getPackageVersion
|
|
1
|
+
import { getPackageVersion } from '../src';
|
|
2
2
|
|
|
3
3
|
describe('test generator utils', () => {
|
|
4
4
|
test('test getPackageVersion', async () => {
|
|
5
5
|
const version = await getPackageVersion('lodash');
|
|
6
6
|
expect(typeof version === 'string').toBe(true);
|
|
7
7
|
});
|
|
8
|
-
test('test canUseNpm', async () => {
|
|
9
|
-
const npmAbility = await canUseNpm();
|
|
10
|
-
expect(typeof npmAbility === 'boolean').toBe(true);
|
|
11
|
-
});
|
|
12
|
-
test('test canUsePnpm', async () => {
|
|
13
|
-
const pnpmAbility = await canUsePnpm();
|
|
14
|
-
expect(typeof pnpmAbility === 'boolean').toBe(true);
|
|
15
|
-
});
|
|
16
|
-
test('test canUseYarn', async () => {
|
|
17
|
-
const yarnAbility = await canUseYarn();
|
|
18
|
-
expect(typeof yarnAbility === 'boolean').toBe(true);
|
|
19
|
-
});
|
|
20
8
|
});
|
package/tests/tsconfig.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import execa from 'execa';
|
|
2
|
-
export async function canUseNpm() {
|
|
3
|
-
try {
|
|
4
|
-
await execa('npm', ['--version'], {
|
|
5
|
-
env: process.env
|
|
6
|
-
});
|
|
7
|
-
return true;
|
|
8
|
-
} catch (e) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export async function canUseYarn() {
|
|
13
|
-
try {
|
|
14
|
-
await execa('yarn', ['--version'], {
|
|
15
|
-
env: process.env
|
|
16
|
-
});
|
|
17
|
-
return true;
|
|
18
|
-
} catch (e) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export async function canUsePnpm() {
|
|
23
|
-
try {
|
|
24
|
-
await execa('pnpm', ['--version'], {
|
|
25
|
-
env: process.env
|
|
26
|
-
});
|
|
27
|
-
return true;
|
|
28
|
-
} catch (e) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.canUseNpm = canUseNpm;
|
|
7
|
-
exports.canUsePnpm = canUsePnpm;
|
|
8
|
-
exports.canUseYarn = canUseYarn;
|
|
9
|
-
|
|
10
|
-
var _execa = _interopRequireDefault(require("execa"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
async function canUseNpm() {
|
|
15
|
-
try {
|
|
16
|
-
await (0, _execa.default)('npm', ['--version'], {
|
|
17
|
-
env: process.env
|
|
18
|
-
});
|
|
19
|
-
return true;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function canUseYarn() {
|
|
26
|
-
try {
|
|
27
|
-
await (0, _execa.default)('yarn', ['--version'], {
|
|
28
|
-
env: process.env
|
|
29
|
-
});
|
|
30
|
-
return true;
|
|
31
|
-
} catch (e) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function canUsePnpm() {
|
|
37
|
-
try {
|
|
38
|
-
await (0, _execa.default)('pnpm', ['--version'], {
|
|
39
|
-
env: process.env
|
|
40
|
-
});
|
|
41
|
-
return true;
|
|
42
|
-
} catch (e) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
package/src/utils/env.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import execa from 'execa';
|
|
2
|
-
|
|
3
|
-
export async function canUseNpm() {
|
|
4
|
-
try {
|
|
5
|
-
await execa('npm', ['--version'], { env: process.env });
|
|
6
|
-
return true;
|
|
7
|
-
} catch (e) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function canUseYarn() {
|
|
13
|
-
try {
|
|
14
|
-
await execa('yarn', ['--version'], { env: process.env });
|
|
15
|
-
return true;
|
|
16
|
-
} catch (e) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function canUsePnpm() {
|
|
22
|
-
try {
|
|
23
|
-
await execa('pnpm', ['--version'], { env: process.env });
|
|
24
|
-
return true;
|
|
25
|
-
} catch (e) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|