@modern-js/utils 2.26.0 → 2.28.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/cli/alias.js +3 -3
- package/dist/cjs/cli/constants/chainId.js +4 -0
- package/dist/cjs/cli/constants/index.js +0 -1
- package/dist/cjs/cli/is/config.js +11 -8
- package/dist/cjs/cli/prettyInstructions.js +3 -2
- package/dist/cjs/cli/require.js +2 -1
- package/dist/cjs/runtime/nestedRoutes.js +9 -5
- package/dist/cjs/runtime-browser/parsed.js +2 -1
- package/dist/cjs/universal/formatWebpack.js +55 -12
- package/dist/esm/cli/alias.js +27 -23
- package/dist/esm/cli/applyOptionsChain.js +8 -6
- package/dist/esm/cli/babel.js +50 -35
- package/dist/esm/cli/commands.js +7 -7
- package/dist/esm/cli/common.js +10 -5
- package/dist/esm/cli/constants/chainId.js +5 -1
- package/dist/esm/cli/constants/index.js +33 -38
- package/dist/esm/cli/ensure.js +4 -2
- package/dist/esm/cli/fs.js +56 -9
- package/dist/esm/cli/get/config.js +7 -7
- package/dist/esm/cli/get/data.js +102 -55
- package/dist/esm/cli/get/index.js +21 -6
- package/dist/esm/cli/is/config.js +43 -21
- package/dist/esm/cli/is/env.js +18 -6
- package/dist/esm/cli/is/platform.js +6 -2
- package/dist/esm/cli/is/project.js +73 -36
- package/dist/esm/cli/is/type.js +3 -1
- package/dist/esm/cli/logger.js +49 -38
- package/dist/esm/cli/monorepo.js +49 -36
- package/dist/esm/cli/package.js +156 -38
- package/dist/esm/cli/path.js +44 -20
- package/dist/esm/cli/pathSerializer.js +29 -15
- package/dist/esm/cli/port.js +89 -40
- package/dist/esm/cli/prettyInstructions.js +44 -32
- package/dist/esm/cli/require.js +22 -16
- package/dist/esm/cli/runtimeExports.js +21 -15
- package/dist/esm/cli/watch.js +94 -27
- package/dist/esm/compiled.js +3 -3
- package/dist/esm/import.js +4 -4
- package/dist/esm/runtime/nestedRoutes.js +49 -32
- package/dist/esm/runtime-browser/parsed.js +6 -5
- package/dist/esm/runtime-node/index.js +1 -1
- package/dist/esm/runtime-node/nestedRoutes.js +6 -4
- package/dist/esm/runtime-node/serialize.js +1 -1
- package/dist/esm/runtime-node/storage.js +12 -14
- package/dist/esm/universal/constants.js +3 -3
- package/dist/esm/universal/formatWebpack.js +54 -28
- package/dist/esm/universal/pluginDagSort.js +49 -26
- package/dist/esm-node/cli/alias.js +51 -0
- package/dist/esm-node/cli/applyOptionsChain.js +24 -0
- package/dist/esm-node/cli/babel.js +103 -0
- package/dist/esm-node/cli/commands.js +16 -0
- package/dist/esm-node/cli/common.js +10 -0
- package/dist/esm-node/cli/constants/chainId.js +184 -0
- package/dist/esm-node/cli/constants/index.js +102 -0
- package/dist/esm-node/cli/ensure.js +10 -0
- package/dist/esm-node/cli/fs.js +14 -0
- package/dist/esm-node/cli/get/config.js +16 -0
- package/dist/esm-node/cli/get/data.js +86 -0
- package/dist/esm-node/cli/get/index.js +13 -0
- package/dist/esm-node/cli/index.js +20 -0
- package/dist/esm-node/cli/is/config.js +43 -0
- package/dist/esm-node/cli/is/env.js +6 -0
- package/dist/esm-node/cli/is/index.js +5 -0
- package/dist/esm-node/cli/is/platform.js +2 -0
- package/dist/esm-node/cli/is/project.js +73 -0
- package/dist/esm-node/cli/is/type.js +25 -0
- package/dist/esm-node/cli/logger.js +103 -0
- package/dist/esm-node/cli/monorepo.js +70 -0
- package/dist/esm-node/cli/package.js +43 -0
- package/dist/esm-node/cli/path.js +49 -0
- package/dist/esm-node/cli/pathSerializer.js +46 -0
- package/dist/esm-node/cli/port.js +44 -0
- package/dist/esm-node/cli/prettyInstructions.js +78 -0
- package/dist/esm-node/cli/require.js +53 -0
- package/dist/esm-node/cli/runtimeExports.js +35 -0
- package/dist/esm-node/cli/watch.js +41 -0
- package/dist/esm-node/compiled.js +33 -0
- package/dist/esm-node/import.js +8 -0
- package/dist/esm-node/index.js +3 -0
- package/dist/esm-node/runtime/nestedRoutes.js +116 -0
- package/dist/esm-node/runtime/remixRouter.js +1 -0
- package/dist/esm-node/runtime/router.js +1 -0
- package/dist/esm-node/runtime-browser/index.js +1 -0
- package/dist/esm-node/runtime-browser/parsed.js +18 -0
- package/dist/esm-node/runtime-node/index.js +5 -0
- package/dist/esm-node/runtime-node/nestedRoutes.js +18 -0
- package/dist/esm-node/runtime-node/router.js +1 -0
- package/dist/esm-node/runtime-node/serialize.js +6 -0
- package/dist/esm-node/runtime-node/storage.js +38 -0
- package/dist/esm-node/universal/constants.js +3 -0
- package/dist/esm-node/universal/formatWebpack.js +99 -0
- package/dist/esm-node/universal/pluginDagSort.js +50 -0
- package/dist/types/cli/constants/chainId.d.ts +4 -0
- package/dist/types/universal/formatWebpack.d.ts +14 -1
- package/package.json +4 -4
@@ -1,21 +1,24 @@
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
3
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
1
4
|
import path from "path";
|
2
5
|
import pkgUp from "../../../compiled/pkg-up";
|
3
6
|
import { getArgv } from "../commands";
|
4
7
|
import { fs, minimist, semver } from "../../compiled";
|
5
8
|
import { createDebugger } from "../common";
|
6
9
|
import { ensureArray } from "../ensure";
|
7
|
-
|
8
|
-
export
|
9
|
-
|
10
|
+
var debug = createDebugger("judge-depExists");
|
11
|
+
export var isDepExists = function(appDirectory, name) {
|
12
|
+
var pkgPath = path.resolve(appDirectory, "./package.json");
|
10
13
|
if (!fs.existsSync(pkgPath)) {
|
11
|
-
debug(
|
14
|
+
debug("can't find package.json under: %s", appDirectory);
|
12
15
|
return false;
|
13
16
|
}
|
14
|
-
|
15
|
-
|
17
|
+
var json = require(pkgPath);
|
18
|
+
var _json_dependencies = json.dependencies, dependencies = _json_dependencies === void 0 ? {} : _json_dependencies, _json_devDependencies = json.devDependencies, devDependencies = _json_devDependencies === void 0 ? {} : _json_devDependencies;
|
16
19
|
return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
|
17
20
|
};
|
18
|
-
export
|
21
|
+
export var isPackageInstalled = function(name, resolvePaths) {
|
19
22
|
try {
|
20
23
|
require.resolve(name, {
|
21
24
|
paths: ensureArray(resolvePaths)
|
@@ -25,49 +28,83 @@ export const isPackageInstalled = (name, resolvePaths) => {
|
|
25
28
|
return false;
|
26
29
|
}
|
27
30
|
};
|
28
|
-
export
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
export var isApiOnly = function() {
|
32
|
+
var _ref = _async_to_generator(function(appDirectory, entryDir, apiDir) {
|
33
|
+
var existApi, existSrc, options;
|
34
|
+
return _ts_generator(this, function(_state) {
|
35
|
+
switch (_state.label) {
|
36
|
+
case 0:
|
37
|
+
return [
|
38
|
+
4,
|
39
|
+
fs.pathExists(apiDir !== null && apiDir !== void 0 ? apiDir : path.join(appDirectory, "api"))
|
40
|
+
];
|
41
|
+
case 1:
|
42
|
+
existApi = _state.sent();
|
43
|
+
return [
|
44
|
+
4,
|
45
|
+
fs.pathExists(path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src"))
|
46
|
+
];
|
47
|
+
case 2:
|
48
|
+
existSrc = _state.sent();
|
49
|
+
options = minimist(getArgv());
|
50
|
+
if (options["api-only"]) {
|
51
|
+
return [
|
52
|
+
2,
|
53
|
+
true
|
54
|
+
];
|
55
|
+
}
|
56
|
+
return [
|
57
|
+
2,
|
58
|
+
existApi && !existSrc
|
59
|
+
];
|
60
|
+
}
|
61
|
+
});
|
62
|
+
});
|
63
|
+
return function isApiOnly2(appDirectory, entryDir, apiDir) {
|
64
|
+
return _ref.apply(this, arguments);
|
65
|
+
};
|
66
|
+
}();
|
67
|
+
export var isWebOnly = function() {
|
68
|
+
var _ref = _async_to_generator(function() {
|
69
|
+
var options;
|
70
|
+
return _ts_generator(this, function(_state) {
|
71
|
+
options = minimist(getArgv());
|
72
|
+
return [
|
73
|
+
2,
|
74
|
+
Boolean(options["web-only"])
|
75
|
+
];
|
76
|
+
});
|
77
|
+
});
|
78
|
+
return function isWebOnly2() {
|
79
|
+
return _ref.apply(this, arguments);
|
80
|
+
};
|
81
|
+
}();
|
82
|
+
export var isBeyondReact17 = function(cwd) {
|
83
|
+
var pkgPath = pkgUp.sync({
|
84
|
+
cwd: cwd
|
44
85
|
});
|
45
86
|
if (!pkgPath) {
|
46
87
|
return false;
|
47
88
|
}
|
48
|
-
|
49
|
-
|
50
|
-
...pkgInfo.devDependencies,
|
51
|
-
...pkgInfo.dependencies
|
52
|
-
};
|
89
|
+
var pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
90
|
+
var deps = _object_spread({}, pkgInfo.devDependencies, pkgInfo.dependencies);
|
53
91
|
if (typeof deps.react !== "string") {
|
54
92
|
return false;
|
55
93
|
}
|
56
94
|
return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
|
57
95
|
};
|
58
|
-
export
|
59
|
-
|
96
|
+
export var isReact18 = function(cwd) {
|
97
|
+
var pkgPath = path.join(cwd, "package.json");
|
60
98
|
if (!fs.existsSync(pkgPath)) {
|
61
99
|
return false;
|
62
100
|
}
|
63
|
-
|
64
|
-
|
65
|
-
...pkgInfo.devDependencies,
|
66
|
-
...pkgInfo.dependencies
|
67
|
-
};
|
101
|
+
var pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
102
|
+
var deps = _object_spread({}, pkgInfo.devDependencies, pkgInfo.dependencies);
|
68
103
|
if (typeof deps.react !== "string") {
|
69
104
|
return false;
|
70
105
|
}
|
71
106
|
return semver.satisfies(semver.minVersion(deps.react), ">=18.0.0");
|
72
107
|
};
|
73
|
-
export
|
108
|
+
export var isTypescript = function(root) {
|
109
|
+
return fs.existsSync(path.resolve(root, "./tsconfig.json"));
|
110
|
+
};
|
package/dist/esm/cli/is/type.js
CHANGED
@@ -22,4 +22,6 @@ export function isPromise(obj) {
|
|
22
22
|
export function isRegExp(obj) {
|
23
23
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
24
24
|
}
|
25
|
-
export
|
25
|
+
export var isEmpty = function(o) {
|
26
|
+
return Object.entries(o).length === 0 && o.constructor === Object;
|
27
|
+
};
|
package/dist/esm/cli/logger.js
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
2
|
+
import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
3
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
4
|
+
import { _ as _to_array } from "@swc/helpers/_/_to_array";
|
5
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
1
6
|
import chalk from "../../compiled/chalk";
|
2
|
-
|
7
|
+
var LOG_LEVEL = {
|
3
8
|
error: 0,
|
4
9
|
warn: 1,
|
5
10
|
info: 2,
|
6
11
|
debug: 3,
|
7
12
|
log: 4
|
8
13
|
};
|
9
|
-
|
14
|
+
var LOG_TYPES = {
|
10
15
|
error: {
|
11
16
|
color: "red",
|
12
17
|
label: "error",
|
@@ -36,12 +41,30 @@ const LOG_TYPES = {
|
|
36
41
|
level: "log"
|
37
42
|
}
|
38
43
|
};
|
39
|
-
|
44
|
+
var DEFAULT_CONFIG = {
|
40
45
|
displayLabel: true,
|
41
46
|
uppercaseLabel: false
|
42
47
|
};
|
43
|
-
|
44
|
-
|
48
|
+
var Logger = /* @__PURE__ */ function() {
|
49
|
+
"use strict";
|
50
|
+
function Logger2() {
|
51
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
52
|
+
var _this = this;
|
53
|
+
_class_call_check(this, Logger2);
|
54
|
+
this.level = options.level || LOG_TYPES.log.level;
|
55
|
+
this.config = _object_spread({}, DEFAULT_CONFIG, options.config || {});
|
56
|
+
this.types = _object_spread({}, LOG_TYPES, options.types || {});
|
57
|
+
this.longestLabel = this.getLongestLabel();
|
58
|
+
Object.keys(this.types).forEach(function(type) {
|
59
|
+
_this[type] = _this._log.bind(_this, type);
|
60
|
+
});
|
61
|
+
}
|
62
|
+
var _proto = Logger2.prototype;
|
63
|
+
_proto._log = function _log(type, message) {
|
64
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
65
|
+
args[_key - 2] = arguments[_key];
|
66
|
+
}
|
67
|
+
var _console;
|
45
68
|
if (message === void 0 || message === null) {
|
46
69
|
console.log();
|
47
70
|
return;
|
@@ -49,55 +72,43 @@ class Logger {
|
|
49
72
|
if (LOG_LEVEL[type] > LOG_LEVEL[this.level]) {
|
50
73
|
return;
|
51
74
|
}
|
52
|
-
|
53
|
-
|
54
|
-
|
75
|
+
var label = "";
|
76
|
+
var text = "";
|
77
|
+
var logType = this.types[type];
|
55
78
|
if (this.config.displayLabel && logType.label) {
|
56
79
|
label = this.config.uppercaseLabel ? logType.label.toUpperCase() : logType.label;
|
57
80
|
label = label.padEnd(this.longestLabel.length);
|
58
81
|
label = chalk.bold(logType.color ? chalk[logType.color](label) : label);
|
59
82
|
}
|
60
|
-
if (message
|
83
|
+
if (_instanceof(message, Error)) {
|
61
84
|
if (message.stack) {
|
62
|
-
|
63
|
-
text =
|
64
|
-
${chalk.grey(rest.join("\n"))}`;
|
85
|
+
var _message_stack_split = _to_array(message.stack.split("\n")), name = _message_stack_split[0], rest = _message_stack_split.slice(1);
|
86
|
+
text = "".concat(name, "\n").concat(chalk.grey(rest.join("\n")));
|
65
87
|
} else {
|
66
88
|
text = message.message;
|
67
89
|
}
|
68
90
|
} else {
|
69
|
-
text =
|
91
|
+
text = "".concat(message);
|
70
92
|
}
|
71
|
-
|
72
|
-
console.log(
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
93
|
+
var log = label.length > 0 ? "".concat(label, " ").concat(text) : text;
|
94
|
+
(_console = console).log.apply(_console, [
|
95
|
+
log
|
96
|
+
].concat(_to_consumable_array(args)));
|
97
|
+
};
|
98
|
+
_proto.getLongestLabel = function getLongestLabel() {
|
99
|
+
var _this = this;
|
100
|
+
var longestLabel = "";
|
101
|
+
Object.keys(this.types).forEach(function(type) {
|
102
|
+
var _this_types_type = _this.types[type], _this_types_type_label = _this_types_type.label, label = _this_types_type_label === void 0 ? "" : _this_types_type_label;
|
78
103
|
if (label.length > longestLabel.length) {
|
79
104
|
longestLabel = label;
|
80
105
|
}
|
81
106
|
});
|
82
107
|
return longestLabel;
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
...DEFAULT_CONFIG,
|
88
|
-
...options.config || {}
|
89
|
-
};
|
90
|
-
this.types = {
|
91
|
-
...LOG_TYPES,
|
92
|
-
...options.types || {}
|
93
|
-
};
|
94
|
-
this.longestLabel = this.getLongestLabel();
|
95
|
-
Object.keys(this.types).forEach((type) => {
|
96
|
-
this[type] = this._log.bind(this, type);
|
97
|
-
});
|
98
|
-
}
|
99
|
-
}
|
100
|
-
const logger = new Logger();
|
108
|
+
};
|
109
|
+
return Logger2;
|
110
|
+
}();
|
111
|
+
var logger = new Logger();
|
101
112
|
logger.Logger = Logger;
|
102
113
|
export { Logger };
|
103
114
|
export { logger };
|
package/dist/esm/cli/monorepo.js
CHANGED
@@ -1,39 +1,44 @@
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
1
2
|
import fs from "fs";
|
2
3
|
import path from "path";
|
3
4
|
import { glob, yaml } from "../compiled";
|
4
|
-
|
5
|
-
|
5
|
+
var PACKAGE_MAX_DEPTH = 5;
|
6
|
+
var WORKSPACE_FILES = {
|
6
7
|
YARN: "package.json",
|
7
8
|
PNPM: "pnpm-workspace.yaml",
|
8
9
|
LERNA: "lerna.json"
|
9
10
|
};
|
10
|
-
export
|
11
|
-
|
11
|
+
export var isLerna = function(root) {
|
12
|
+
return fs.existsSync(path.join(root, WORKSPACE_FILES.LERNA));
|
13
|
+
};
|
14
|
+
export var isYarnWorkspaces = function(root) {
|
12
15
|
var _json_workspaces;
|
13
|
-
|
16
|
+
var pkg = path.join(root, WORKSPACE_FILES.YARN);
|
14
17
|
if (!fs.existsSync(pkg)) {
|
15
18
|
return false;
|
16
19
|
}
|
17
|
-
|
20
|
+
var json = JSON.parse(fs.readFileSync(pkg, "utf8"));
|
18
21
|
return Boolean((_json_workspaces = json.workspaces) === null || _json_workspaces === void 0 ? void 0 : _json_workspaces.packages);
|
19
22
|
};
|
20
|
-
export
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
export var isPnpmWorkspaces = function(root) {
|
24
|
+
return fs.existsSync(path.join(root, WORKSPACE_FILES.PNPM));
|
25
|
+
};
|
26
|
+
export var isMonorepo = function(root) {
|
27
|
+
return isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
28
|
+
};
|
29
|
+
export var isModernjsMonorepo = function(root) {
|
30
|
+
var pkgJsonPath = path.join(root, "package.json");
|
24
31
|
if (!fs.existsSync(pkgJsonPath)) {
|
25
32
|
return false;
|
26
33
|
}
|
27
|
-
|
28
|
-
|
29
|
-
...json.dependencies || {},
|
30
|
-
...json.devDependencies || {}
|
31
|
-
};
|
34
|
+
var json = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
35
|
+
var deps = _object_spread({}, json.dependencies || {}, json.devDependencies || {});
|
32
36
|
return Boolean(deps["@modern-js/monorepo-tools"]);
|
33
37
|
};
|
34
|
-
export
|
35
|
-
|
36
|
-
|
38
|
+
export var findMonorepoRoot = function(appDirectory) {
|
39
|
+
var maxDepth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : PACKAGE_MAX_DEPTH;
|
40
|
+
var inMonorepo = false;
|
41
|
+
for (var depth = 0; depth < maxDepth; depth++) {
|
37
42
|
if (isMonorepo(appDirectory)) {
|
38
43
|
inMonorepo = true;
|
39
44
|
break;
|
@@ -42,29 +47,37 @@ export const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) =>
|
|
42
47
|
}
|
43
48
|
return inMonorepo ? appDirectory : void 0;
|
44
49
|
};
|
45
|
-
export
|
46
|
-
|
50
|
+
export var getMonorepoPackages = function(root) {
|
51
|
+
var packages = [];
|
47
52
|
if (isYarnWorkspaces(root)) {
|
48
|
-
|
49
|
-
|
53
|
+
var json = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
54
|
+
packages = json.workspaces.packages;
|
50
55
|
} else if (isLerna(root)) {
|
51
|
-
|
52
|
-
|
56
|
+
var json1 = JSON.parse(fs.readFileSync(path.resolve(root, "lerna.json"), "utf8"));
|
57
|
+
packages = json1.packages;
|
53
58
|
} else {
|
54
|
-
|
59
|
+
packages = yaml.load(fs.readFileSync(path.join(root, WORKSPACE_FILES.PNPM), "utf8")).packages;
|
55
60
|
}
|
56
61
|
if (packages) {
|
57
|
-
return packages.map((name)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
return packages.map(function(name) {
|
63
|
+
return (
|
64
|
+
// The trailing / ensures only dirs are picked up
|
65
|
+
glob.sync(path.join(root, "".concat(name, "/")), {
|
66
|
+
ignore: [
|
67
|
+
"**/node_modules/**"
|
68
|
+
]
|
69
|
+
})
|
70
|
+
);
|
71
|
+
}).reduce(function(acc, val) {
|
72
|
+
return acc.concat(val);
|
73
|
+
}, []).filter(function(filepath) {
|
74
|
+
return fs.existsSync(path.resolve(filepath, "package.json"));
|
75
|
+
}).map(function(filepath) {
|
76
|
+
return {
|
77
|
+
path: filepath,
|
78
|
+
name: JSON.parse(fs.readFileSync(path.resolve(filepath, "package.json"), "utf8")).name
|
79
|
+
};
|
80
|
+
});
|
68
81
|
}
|
69
82
|
return [];
|
70
83
|
};
|
package/dist/esm/cli/package.js
CHANGED
@@ -1,43 +1,161 @@
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
1
3
|
import { execa } from "../compiled";
|
2
|
-
export
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
export function getPnpmVersion() {
|
5
|
+
return _getPnpmVersion.apply(this, arguments);
|
6
|
+
}
|
7
|
+
function _getPnpmVersion() {
|
8
|
+
_getPnpmVersion = _async_to_generator(function() {
|
9
|
+
var stdout;
|
10
|
+
return _ts_generator(this, function(_state) {
|
11
|
+
switch (_state.label) {
|
12
|
+
case 0:
|
13
|
+
return [
|
14
|
+
4,
|
15
|
+
execa("pnpm", [
|
16
|
+
"--version"
|
17
|
+
])
|
18
|
+
];
|
19
|
+
case 1:
|
20
|
+
stdout = _state.sent().stdout;
|
21
|
+
return [
|
22
|
+
2,
|
23
|
+
stdout
|
24
|
+
];
|
25
|
+
}
|
26
|
+
});
|
27
|
+
});
|
28
|
+
return _getPnpmVersion.apply(this, arguments);
|
29
|
+
}
|
30
|
+
export function canUseNpm() {
|
31
|
+
return _canUseNpm.apply(this, arguments);
|
32
|
+
}
|
33
|
+
function _canUseNpm() {
|
34
|
+
_canUseNpm = _async_to_generator(function() {
|
35
|
+
var e;
|
36
|
+
return _ts_generator(this, function(_state) {
|
37
|
+
switch (_state.label) {
|
38
|
+
case 0:
|
39
|
+
_state.trys.push([
|
40
|
+
0,
|
41
|
+
2,
|
42
|
+
,
|
43
|
+
3
|
44
|
+
]);
|
45
|
+
return [
|
46
|
+
4,
|
47
|
+
execa("npm", [
|
48
|
+
"--version"
|
49
|
+
], {
|
50
|
+
env: process.env
|
51
|
+
})
|
52
|
+
];
|
53
|
+
case 1:
|
54
|
+
_state.sent();
|
55
|
+
return [
|
56
|
+
2,
|
57
|
+
true
|
58
|
+
];
|
59
|
+
case 2:
|
60
|
+
e = _state.sent();
|
61
|
+
return [
|
62
|
+
2,
|
63
|
+
false
|
64
|
+
];
|
65
|
+
case 3:
|
66
|
+
return [
|
67
|
+
2
|
68
|
+
];
|
69
|
+
}
|
14
70
|
});
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
71
|
+
});
|
72
|
+
return _canUseNpm.apply(this, arguments);
|
73
|
+
}
|
74
|
+
export function canUseYarn() {
|
75
|
+
return _canUseYarn.apply(this, arguments);
|
76
|
+
}
|
77
|
+
function _canUseYarn() {
|
78
|
+
_canUseYarn = _async_to_generator(function() {
|
79
|
+
var e;
|
80
|
+
return _ts_generator(this, function(_state) {
|
81
|
+
switch (_state.label) {
|
82
|
+
case 0:
|
83
|
+
_state.trys.push([
|
84
|
+
0,
|
85
|
+
2,
|
86
|
+
,
|
87
|
+
3
|
88
|
+
]);
|
89
|
+
return [
|
90
|
+
4,
|
91
|
+
execa("yarn", [
|
92
|
+
"--version"
|
93
|
+
], {
|
94
|
+
env: process.env
|
95
|
+
})
|
96
|
+
];
|
97
|
+
case 1:
|
98
|
+
_state.sent();
|
99
|
+
return [
|
100
|
+
2,
|
101
|
+
true
|
102
|
+
];
|
103
|
+
case 2:
|
104
|
+
e = _state.sent();
|
105
|
+
return [
|
106
|
+
2,
|
107
|
+
false
|
108
|
+
];
|
109
|
+
case 3:
|
110
|
+
return [
|
111
|
+
2
|
112
|
+
];
|
113
|
+
}
|
26
114
|
});
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
115
|
+
});
|
116
|
+
return _canUseYarn.apply(this, arguments);
|
117
|
+
}
|
118
|
+
export function canUsePnpm() {
|
119
|
+
return _canUsePnpm.apply(this, arguments);
|
120
|
+
}
|
121
|
+
function _canUsePnpm() {
|
122
|
+
_canUsePnpm = _async_to_generator(function() {
|
123
|
+
var e;
|
124
|
+
return _ts_generator(this, function(_state) {
|
125
|
+
switch (_state.label) {
|
126
|
+
case 0:
|
127
|
+
_state.trys.push([
|
128
|
+
0,
|
129
|
+
2,
|
130
|
+
,
|
131
|
+
3
|
132
|
+
]);
|
133
|
+
return [
|
134
|
+
4,
|
135
|
+
execa("pnpm", [
|
136
|
+
"--version"
|
137
|
+
], {
|
138
|
+
env: process.env
|
139
|
+
})
|
140
|
+
];
|
141
|
+
case 1:
|
142
|
+
_state.sent();
|
143
|
+
return [
|
144
|
+
2,
|
145
|
+
true
|
146
|
+
];
|
147
|
+
case 2:
|
148
|
+
e = _state.sent();
|
149
|
+
return [
|
150
|
+
2,
|
151
|
+
false
|
152
|
+
];
|
153
|
+
case 3:
|
154
|
+
return [
|
155
|
+
2
|
156
|
+
];
|
157
|
+
}
|
38
158
|
});
|
39
|
-
|
40
|
-
|
41
|
-
return false;
|
42
|
-
}
|
159
|
+
});
|
160
|
+
return _canUsePnpm.apply(this, arguments);
|
43
161
|
}
|