@modern-js/utils 2.35.1 → 2.36.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/dist/cjs/cli/alias.js +45 -46
- package/dist/cjs/cli/applyOptionsChain.js +30 -13
- package/dist/cjs/cli/babel.js +36 -26
- package/dist/cjs/cli/commands.js +29 -21
- package/dist/cjs/cli/common.js +29 -20
- package/dist/cjs/cli/config.js +24 -7
- package/dist/cjs/cli/constants/chainId.js +24 -7
- package/dist/cjs/cli/constants/index.js +86 -104
- package/dist/cjs/cli/ensure.js +37 -18
- package/dist/cjs/cli/fs.js +29 -19
- package/dist/cjs/cli/get/config.js +26 -9
- package/dist/cjs/cli/get/data.js +67 -54
- package/dist/cjs/cli/get/index.js +46 -25
- package/dist/cjs/cli/index.js +58 -23
- package/dist/cjs/cli/is/config.js +37 -31
- package/dist/cjs/cli/is/env.js +32 -29
- package/dist/cjs/cli/is/index.js +26 -8
- package/dist/cjs/cli/is/project.js +67 -53
- package/dist/cjs/cli/is/type.js +39 -36
- package/dist/cjs/cli/logger.js +25 -130
- package/dist/cjs/cli/monorepo.js +58 -58
- package/dist/cjs/cli/package.js +34 -26
- package/dist/cjs/cli/path.js +64 -54
- package/dist/cjs/cli/port.js +39 -13
- package/dist/cjs/cli/prettyInstructions.js +48 -29
- package/dist/cjs/cli/require.js +35 -29
- package/dist/cjs/cli/runtimeExports.js +42 -16
- package/dist/cjs/cli/watch.js +41 -22
- package/dist/cjs/compiled.js +127 -138
- package/dist/cjs/import.js +25 -15
- package/dist/cjs/index.js +24 -6
- package/dist/cjs/universal/constants.js +29 -21
- package/dist/cjs/universal/formatWebpack.js +25 -15
- package/dist/cjs/universal/pluginDagSort.js +25 -8
- package/dist/esm/cli/alias.js +10 -22
- package/dist/esm/cli/applyOptionsChain.js +4 -1
- package/dist/esm/cli/babel.js +6 -2
- package/dist/esm/cli/commands.js +10 -4
- package/dist/esm/cli/common.js +8 -3
- package/dist/esm/cli/config.js +4 -1
- package/dist/esm/cli/constants/chainId.js +4 -1
- package/dist/esm/cli/constants/index.js +64 -31
- package/dist/esm/cli/ensure.js +6 -2
- package/dist/esm/cli/fs.js +6 -2
- package/dist/esm/cli/get/config.js +4 -1
- package/dist/esm/cli/get/data.js +18 -8
- package/dist/esm/cli/get/index.js +6 -2
- package/dist/esm/cli/is/config.js +14 -6
- package/dist/esm/cli/is/env.js +12 -8
- package/dist/esm/cli/is/index.js +0 -1
- package/dist/esm/cli/is/project.js +17 -8
- package/dist/esm/cli/is/type.js +20 -9
- package/dist/esm/cli/logger.js +4 -128
- package/dist/esm/cli/monorepo.js +14 -16
- package/dist/esm/cli/package.js +10 -4
- package/dist/esm/cli/path.js +24 -11
- package/dist/esm/cli/port.js +5 -2
- package/dist/esm/cli/prettyInstructions.js +6 -2
- package/dist/esm/cli/require.js +14 -6
- package/dist/esm/cli/runtimeExports.js +6 -3
- package/dist/esm/cli/watch.js +10 -6
- package/dist/esm/compiled.js +65 -31
- package/dist/esm/import.js +6 -3
- package/dist/esm/universal/constants.js +10 -4
- package/dist/esm/universal/formatWebpack.js +5 -2
- package/dist/esm/universal/pluginDagSort.js +5 -2
- package/dist/esm-node/cli/alias.js +8 -19
- package/dist/esm-node/cli/applyOptionsChain.js +4 -1
- package/dist/esm-node/cli/babel.js +6 -2
- package/dist/esm-node/cli/commands.js +10 -4
- package/dist/esm-node/cli/common.js +8 -3
- package/dist/esm-node/cli/config.js +4 -1
- package/dist/esm-node/cli/constants/chainId.js +4 -1
- package/dist/esm-node/cli/constants/index.js +64 -31
- package/dist/esm-node/cli/ensure.js +6 -2
- package/dist/esm-node/cli/fs.js +6 -2
- package/dist/esm-node/cli/get/config.js +4 -1
- package/dist/esm-node/cli/get/data.js +18 -8
- package/dist/esm-node/cli/get/index.js +6 -2
- package/dist/esm-node/cli/is/config.js +14 -6
- package/dist/esm-node/cli/is/env.js +12 -6
- package/dist/esm-node/cli/is/index.js +0 -1
- package/dist/esm-node/cli/is/project.js +16 -7
- package/dist/esm-node/cli/is/type.js +20 -9
- package/dist/esm-node/cli/logger.js +4 -113
- package/dist/esm-node/cli/monorepo.js +14 -18
- package/dist/esm-node/cli/package.js +10 -4
- package/dist/esm-node/cli/path.js +24 -11
- package/dist/esm-node/cli/port.js +4 -1
- package/dist/esm-node/cli/prettyInstructions.js +6 -2
- package/dist/esm-node/cli/require.js +14 -6
- package/dist/esm-node/cli/runtimeExports.js +4 -1
- package/dist/esm-node/cli/watch.js +6 -2
- package/dist/esm-node/compiled.js +65 -31
- package/dist/esm-node/import.js +5 -2
- package/dist/esm-node/universal/constants.js +10 -4
- package/dist/esm-node/universal/formatWebpack.js +5 -2
- package/dist/esm-node/universal/pluginDagSort.js +5 -2
- package/dist/types/cli/alias.d.ts +0 -5
- package/dist/types/cli/is/env.d.ts +1 -2
- package/dist/types/cli/is/index.d.ts +0 -1
- package/dist/types/cli/logger.d.ts +1 -69
- package/dist/types/cli/monorepo.d.ts +0 -1
- package/package.json +6 -13
- package/dist/cjs/cli/is/platform.js +0 -21
- package/dist/compiled/gradient-string/index.d.ts +0 -1
- package/dist/compiled/gradient-string/index.js +0 -1
- package/dist/compiled/gradient-string/license +0 -21
- package/dist/compiled/gradient-string/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/index.js +0 -7
- package/dist/compiled/webpack-dev-middleware/license +0 -20
- package/dist/compiled/webpack-dev-middleware/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/types/index.d.ts +0 -262
- package/dist/esm/cli/is/platform.js +0 -6
- package/dist/esm-node/cli/is/platform.js +0 -2
- package/dist/types/cli/is/platform.d.ts +0 -2
package/dist/cjs/cli/logger.js
CHANGED
|
@@ -1,135 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
isErrorStackMessage: function() {
|
|
14
|
-
return isErrorStackMessage;
|
|
15
|
-
},
|
|
16
|
-
Logger: function() {
|
|
17
|
-
return Logger;
|
|
18
|
-
},
|
|
19
|
-
logger: function() {
|
|
20
|
-
return logger;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
24
|
-
const _chalk = /* @__PURE__ */ _interop_require_default._(require("../../compiled/chalk"));
|
|
25
|
-
const LOG_LEVEL = {
|
|
26
|
-
error: 0,
|
|
27
|
-
warn: 1,
|
|
28
|
-
info: 2,
|
|
29
|
-
debug: 3,
|
|
30
|
-
log: 4
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
31
9
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
info: {
|
|
39
|
-
color: "cyan",
|
|
40
|
-
label: "info",
|
|
41
|
-
level: "info"
|
|
42
|
-
},
|
|
43
|
-
ready: {
|
|
44
|
-
color: "green",
|
|
45
|
-
label: "ready",
|
|
46
|
-
level: "info"
|
|
47
|
-
},
|
|
48
|
-
success: {
|
|
49
|
-
color: "green",
|
|
50
|
-
label: "success",
|
|
51
|
-
level: "info"
|
|
52
|
-
},
|
|
53
|
-
warn: {
|
|
54
|
-
color: "yellow",
|
|
55
|
-
label: "warn",
|
|
56
|
-
level: "warn"
|
|
57
|
-
},
|
|
58
|
-
debug: {
|
|
59
|
-
color: "red",
|
|
60
|
-
label: "debug",
|
|
61
|
-
level: "debug"
|
|
62
|
-
},
|
|
63
|
-
log: {
|
|
64
|
-
level: "log"
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
65
15
|
}
|
|
16
|
+
return to;
|
|
66
17
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (LOG_LEVEL[type] > LOG_LEVEL[this.level]) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
let label = "";
|
|
84
|
-
let text = "";
|
|
85
|
-
const logType = this.types[type];
|
|
86
|
-
if (this.config.displayLabel && logType.label) {
|
|
87
|
-
label = this.config.uppercaseLabel ? logType.label.toUpperCase() : logType.label;
|
|
88
|
-
label = label.padEnd(this.longestLabel.length);
|
|
89
|
-
label = _chalk.default.bold(logType.color ? _chalk.default[logType.color](label) : label);
|
|
90
|
-
}
|
|
91
|
-
if (message instanceof Error) {
|
|
92
|
-
if (message.stack) {
|
|
93
|
-
const [name, ...rest] = message.stack.split("\n");
|
|
94
|
-
text = `${name}
|
|
95
|
-
${_chalk.default.grey(rest.join("\n"))}`;
|
|
96
|
-
} else {
|
|
97
|
-
text = message.message;
|
|
98
|
-
}
|
|
99
|
-
} else if (logType.level === "error" && typeof message === "string") {
|
|
100
|
-
const lines = message.split("\n");
|
|
101
|
-
text = lines.map((line) => isErrorStackMessage(line) ? _chalk.default.gray(line) : line).join("\n");
|
|
102
|
-
} else {
|
|
103
|
-
text = `${message}`;
|
|
104
|
-
}
|
|
105
|
-
const log = label.length > 0 ? `${label} ${text}` : text;
|
|
106
|
-
console.log(log, ...args);
|
|
107
|
-
}
|
|
108
|
-
getLongestLabel() {
|
|
109
|
-
let longestLabel = "";
|
|
110
|
-
Object.keys(this.types).forEach((type) => {
|
|
111
|
-
const { label = "" } = this.types[type];
|
|
112
|
-
if (label.length > longestLabel.length) {
|
|
113
|
-
longestLabel = label;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return longestLabel;
|
|
117
|
-
}
|
|
118
|
-
constructor(options = {}) {
|
|
119
|
-
this.level = options.level || LOG_TYPES.log.level;
|
|
120
|
-
this.config = {
|
|
121
|
-
...DEFAULT_CONFIG,
|
|
122
|
-
...options.config || {}
|
|
123
|
-
};
|
|
124
|
-
this.types = {
|
|
125
|
-
...LOG_TYPES,
|
|
126
|
-
...options.types || {}
|
|
127
|
-
};
|
|
128
|
-
this.longestLabel = this.getLongestLabel();
|
|
129
|
-
Object.keys(this.types).forEach((type) => {
|
|
130
|
-
this[type] = this._log.bind(this, type);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const logger = new Logger();
|
|
135
|
-
logger.Logger = Logger;
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var logger_exports = {};
|
|
20
|
+
__export(logger_exports, {
|
|
21
|
+
createLogger: () => import_rslog.createLogger,
|
|
22
|
+
logger: () => import_rslog.logger
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(logger_exports);
|
|
25
|
+
var import_rslog = require("rslog");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
createLogger,
|
|
29
|
+
logger
|
|
30
|
+
});
|
package/dist/cjs/cli/monorepo.js
CHANGED
|
@@ -1,71 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return isLerna;
|
|
15
|
-
},
|
|
16
|
-
isYarnWorkspaces: function() {
|
|
17
|
-
return isYarnWorkspaces;
|
|
18
|
-
},
|
|
19
|
-
isPnpmWorkspaces: function() {
|
|
20
|
-
return isPnpmWorkspaces;
|
|
21
|
-
},
|
|
22
|
-
isMonorepo: function() {
|
|
23
|
-
return isMonorepo;
|
|
24
|
-
},
|
|
25
|
-
isModernjsMonorepo: function() {
|
|
26
|
-
return isModernjsMonorepo;
|
|
27
|
-
},
|
|
28
|
-
findMonorepoRoot: function() {
|
|
29
|
-
return findMonorepoRoot;
|
|
30
|
-
},
|
|
31
|
-
getMonorepoPackages: function() {
|
|
32
|
-
return getMonorepoPackages;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var monorepo_exports = {};
|
|
30
|
+
__export(monorepo_exports, {
|
|
31
|
+
findMonorepoRoot: () => findMonorepoRoot,
|
|
32
|
+
getMonorepoPackages: () => getMonorepoPackages,
|
|
33
|
+
isLerna: () => isLerna,
|
|
34
|
+
isMonorepo: () => isMonorepo,
|
|
35
|
+
isPnpmWorkspaces: () => isPnpmWorkspaces,
|
|
36
|
+
isYarnWorkspaces: () => isYarnWorkspaces
|
|
34
37
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
module.exports = __toCommonJS(monorepo_exports);
|
|
39
|
+
var import_fs = __toESM(require("fs"));
|
|
40
|
+
var import_path = __toESM(require("path"));
|
|
41
|
+
var import_compiled = require("../compiled");
|
|
39
42
|
const PACKAGE_MAX_DEPTH = 5;
|
|
40
43
|
const WORKSPACE_FILES = {
|
|
41
44
|
YARN: "package.json",
|
|
42
45
|
PNPM: "pnpm-workspace.yaml",
|
|
43
46
|
LERNA: "lerna.json"
|
|
44
47
|
};
|
|
45
|
-
const isLerna = (root) =>
|
|
48
|
+
const isLerna = (root) => import_fs.default.existsSync(import_path.default.join(root, WORKSPACE_FILES.LERNA));
|
|
46
49
|
const isYarnWorkspaces = (root) => {
|
|
47
50
|
var _json_workspaces;
|
|
48
|
-
const pkg =
|
|
49
|
-
if (!
|
|
51
|
+
const pkg = import_path.default.join(root, WORKSPACE_FILES.YARN);
|
|
52
|
+
if (!import_fs.default.existsSync(pkg)) {
|
|
50
53
|
return false;
|
|
51
54
|
}
|
|
52
|
-
const json = JSON.parse(
|
|
55
|
+
const json = JSON.parse(import_fs.default.readFileSync(pkg, "utf8"));
|
|
53
56
|
return Boolean((_json_workspaces = json.workspaces) === null || _json_workspaces === void 0 ? void 0 : _json_workspaces.packages);
|
|
54
57
|
};
|
|
55
|
-
const isPnpmWorkspaces = (root) =>
|
|
58
|
+
const isPnpmWorkspaces = (root) => import_fs.default.existsSync(import_path.default.join(root, WORKSPACE_FILES.PNPM));
|
|
56
59
|
const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
|
57
|
-
const isModernjsMonorepo = (root) => {
|
|
58
|
-
const pkgJsonPath = _path.default.join(root, "package.json");
|
|
59
|
-
if (!_fs.default.existsSync(pkgJsonPath)) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
const json = JSON.parse(_fs.default.readFileSync(pkgJsonPath, "utf8"));
|
|
63
|
-
const deps = {
|
|
64
|
-
...json.dependencies || {},
|
|
65
|
-
...json.devDependencies || {}
|
|
66
|
-
};
|
|
67
|
-
return Boolean(deps["@modern-js/monorepo-tools"]);
|
|
68
|
-
};
|
|
69
60
|
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
|
70
61
|
let inMonorepo = false;
|
|
71
62
|
for (let depth = 0; depth < maxDepth; depth++) {
|
|
@@ -73,33 +64,42 @@ const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
|
|
73
64
|
inMonorepo = true;
|
|
74
65
|
break;
|
|
75
66
|
}
|
|
76
|
-
appDirectory =
|
|
67
|
+
appDirectory = import_path.default.dirname(appDirectory);
|
|
77
68
|
}
|
|
78
69
|
return inMonorepo ? appDirectory : void 0;
|
|
79
70
|
};
|
|
80
71
|
const getMonorepoPackages = (root) => {
|
|
81
72
|
let packages = [];
|
|
82
73
|
if (isYarnWorkspaces(root)) {
|
|
83
|
-
const json = JSON.parse(
|
|
74
|
+
const json = JSON.parse(import_fs.default.readFileSync(import_path.default.join(root, "package.json"), "utf8"));
|
|
84
75
|
({ packages } = json.workspaces);
|
|
85
76
|
} else if (isLerna(root)) {
|
|
86
|
-
const json = JSON.parse(
|
|
77
|
+
const json = JSON.parse(import_fs.default.readFileSync(import_path.default.resolve(root, "lerna.json"), "utf8"));
|
|
87
78
|
({ packages } = json);
|
|
88
79
|
} else {
|
|
89
|
-
({ packages } =
|
|
80
|
+
({ packages } = import_compiled.yaml.load(import_fs.default.readFileSync(import_path.default.join(root, WORKSPACE_FILES.PNPM), "utf8")));
|
|
90
81
|
}
|
|
91
82
|
if (packages) {
|
|
92
83
|
return packages.map((name) => (
|
|
93
84
|
// The trailing / ensures only dirs are picked up
|
|
94
|
-
|
|
85
|
+
import_compiled.glob.sync(import_path.default.join(root, `${name}/`), {
|
|
95
86
|
ignore: [
|
|
96
87
|
"**/node_modules/**"
|
|
97
88
|
]
|
|
98
89
|
})
|
|
99
|
-
)).reduce((acc, val) => acc.concat(val), []).filter((filepath) =>
|
|
90
|
+
)).reduce((acc, val) => acc.concat(val), []).filter((filepath) => import_fs.default.existsSync(import_path.default.resolve(filepath, "package.json"))).map((filepath) => ({
|
|
100
91
|
path: filepath,
|
|
101
|
-
name: JSON.parse(
|
|
92
|
+
name: JSON.parse(import_fs.default.readFileSync(import_path.default.resolve(filepath, "package.json"), "utf8")).name
|
|
102
93
|
}));
|
|
103
94
|
}
|
|
104
95
|
return [];
|
|
105
96
|
};
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
findMonorepoRoot,
|
|
100
|
+
getMonorepoPackages,
|
|
101
|
+
isLerna,
|
|
102
|
+
isMonorepo,
|
|
103
|
+
isPnpmWorkspaces,
|
|
104
|
+
isYarnWorkspaces
|
|
105
|
+
});
|
package/dist/cjs/cli/package.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return getPnpmVersion;
|
|
15
|
-
},
|
|
16
|
-
canUseNpm: function() {
|
|
17
|
-
return canUseNpm;
|
|
18
|
-
},
|
|
19
|
-
canUseYarn: function() {
|
|
20
|
-
return canUseYarn;
|
|
21
|
-
},
|
|
22
|
-
canUsePnpm: function() {
|
|
23
|
-
return canUsePnpm;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var package_exports = {};
|
|
20
|
+
__export(package_exports, {
|
|
21
|
+
canUseNpm: () => canUseNpm,
|
|
22
|
+
canUsePnpm: () => canUsePnpm,
|
|
23
|
+
canUseYarn: () => canUseYarn,
|
|
24
|
+
getPnpmVersion: () => getPnpmVersion
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
module.exports = __toCommonJS(package_exports);
|
|
27
|
+
var import_compiled = require("../compiled");
|
|
27
28
|
async function getPnpmVersion() {
|
|
28
|
-
const { stdout } = await (0,
|
|
29
|
+
const { stdout } = await (0, import_compiled.execa)("pnpm", [
|
|
29
30
|
"--version"
|
|
30
31
|
]);
|
|
31
32
|
return stdout;
|
|
32
33
|
}
|
|
33
34
|
async function canUseNpm() {
|
|
34
35
|
try {
|
|
35
|
-
await (0,
|
|
36
|
+
await (0, import_compiled.execa)("npm", [
|
|
36
37
|
"--version"
|
|
37
38
|
], {
|
|
38
39
|
env: process.env
|
|
@@ -44,7 +45,7 @@ async function canUseNpm() {
|
|
|
44
45
|
}
|
|
45
46
|
async function canUseYarn() {
|
|
46
47
|
try {
|
|
47
|
-
await (0,
|
|
48
|
+
await (0, import_compiled.execa)("yarn", [
|
|
48
49
|
"--version"
|
|
49
50
|
], {
|
|
50
51
|
env: process.env
|
|
@@ -56,7 +57,7 @@ async function canUseYarn() {
|
|
|
56
57
|
}
|
|
57
58
|
async function canUsePnpm() {
|
|
58
59
|
try {
|
|
59
|
-
await (0,
|
|
60
|
+
await (0, import_compiled.execa)("pnpm", [
|
|
60
61
|
"--version"
|
|
61
62
|
], {
|
|
62
63
|
env: process.env
|
|
@@ -66,3 +67,10 @@ async function canUsePnpm() {
|
|
|
66
67
|
return false;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
canUseNpm,
|
|
73
|
+
canUsePnpm,
|
|
74
|
+
canUseYarn,
|
|
75
|
+
getPnpmVersion
|
|
76
|
+
});
|
package/dist/cjs/cli/path.js
CHANGED
|
@@ -1,72 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return isPathString;
|
|
15
|
-
},
|
|
16
|
-
isRelativePath: function() {
|
|
17
|
-
return isRelativePath;
|
|
18
|
-
},
|
|
19
|
-
normalizeOutputPath: function() {
|
|
20
|
-
return normalizeOutputPath;
|
|
21
|
-
},
|
|
22
|
-
normalizeToPosixPath: function() {
|
|
23
|
-
return normalizeToPosixPath;
|
|
24
|
-
},
|
|
25
|
-
getTemplatePath: function() {
|
|
26
|
-
return getTemplatePath;
|
|
27
|
-
},
|
|
28
|
-
getRealTemporaryDirectory: function() {
|
|
29
|
-
return getRealTemporaryDirectory;
|
|
30
|
-
},
|
|
31
|
-
splitPathString: function() {
|
|
32
|
-
return splitPathString;
|
|
33
|
-
},
|
|
34
|
-
removeLeadingSlash: function() {
|
|
35
|
-
return removeLeadingSlash;
|
|
36
|
-
},
|
|
37
|
-
removeTailSlash: function() {
|
|
38
|
-
return removeTailSlash;
|
|
39
|
-
},
|
|
40
|
-
removeSlash: function() {
|
|
41
|
-
return removeSlash;
|
|
42
|
-
},
|
|
43
|
-
cutNameByHyphen: function() {
|
|
44
|
-
return cutNameByHyphen;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var path_exports = {};
|
|
30
|
+
__export(path_exports, {
|
|
31
|
+
cutNameByHyphen: () => cutNameByHyphen,
|
|
32
|
+
getRealTemporaryDirectory: () => getRealTemporaryDirectory,
|
|
33
|
+
getTemplatePath: () => getTemplatePath,
|
|
34
|
+
isPathString: () => isPathString,
|
|
35
|
+
isRelativePath: () => isRelativePath,
|
|
36
|
+
normalizeOutputPath: () => normalizeOutputPath,
|
|
37
|
+
normalizeToPosixPath: () => normalizeToPosixPath,
|
|
38
|
+
removeLeadingSlash: () => removeLeadingSlash,
|
|
39
|
+
removeSlash: () => removeSlash,
|
|
40
|
+
removeTailSlash: () => removeTailSlash,
|
|
41
|
+
splitPathString: () => splitPathString
|
|
46
42
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const isPathString = (test) =>
|
|
43
|
+
module.exports = __toCommonJS(path_exports);
|
|
44
|
+
var import_path = __toESM(require("path"));
|
|
45
|
+
var import_os = __toESM(require("os"));
|
|
46
|
+
var import_fs = __toESM(require("fs"));
|
|
47
|
+
var import_compiled = require("../compiled");
|
|
48
|
+
const isPathString = (test) => import_path.default.posix.basename(test) !== test || import_path.default.win32.basename(test) !== test;
|
|
53
49
|
const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
|
54
50
|
const normalizeOutputPath = (s) => s.replace(/\\/g, "\\\\");
|
|
55
|
-
const normalizeToPosixPath = (p) =>
|
|
51
|
+
const normalizeToPosixPath = (p) => import_compiled.upath.normalizeSafe(import_path.default.normalize(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
|
|
56
52
|
const getTemplatePath = (prefix) => {
|
|
57
|
-
const tmpRoot =
|
|
53
|
+
const tmpRoot = import_fs.default.realpathSync(import_os.default.tmpdir());
|
|
58
54
|
const parts = [
|
|
59
55
|
tmpRoot
|
|
60
56
|
];
|
|
61
57
|
prefix && parts.push(prefix);
|
|
62
|
-
parts.push((0,
|
|
63
|
-
return
|
|
58
|
+
parts.push((0, import_compiled.nanoid)());
|
|
59
|
+
return import_path.default.resolve(...parts);
|
|
64
60
|
};
|
|
65
61
|
function getRealTemporaryDirectory() {
|
|
66
62
|
let ret = null;
|
|
67
63
|
try {
|
|
68
|
-
ret =
|
|
69
|
-
ret =
|
|
64
|
+
ret = import_os.default.tmpdir();
|
|
65
|
+
ret = import_fs.default.realpathSync(ret);
|
|
70
66
|
} catch {
|
|
71
67
|
}
|
|
72
68
|
return ret;
|
|
@@ -80,3 +76,17 @@ const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
|
|
|
80
76
|
const cutNameByHyphen = (s) => {
|
|
81
77
|
return s.split(/[-_]/)[0];
|
|
82
78
|
};
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
cutNameByHyphen,
|
|
82
|
+
getRealTemporaryDirectory,
|
|
83
|
+
getTemplatePath,
|
|
84
|
+
isPathString,
|
|
85
|
+
isRelativePath,
|
|
86
|
+
normalizeOutputPath,
|
|
87
|
+
normalizeToPosixPath,
|
|
88
|
+
removeLeadingSlash,
|
|
89
|
+
removeSlash,
|
|
90
|
+
removeTailSlash,
|
|
91
|
+
splitPathString
|
|
92
|
+
});
|
package/dist/cjs/cli/port.js
CHANGED
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var port_exports = {};
|
|
30
|
+
__export(port_exports, {
|
|
31
|
+
getPort: () => getPort
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
module.exports = __toCommonJS(port_exports);
|
|
34
|
+
var import_net = __toESM(require("net"));
|
|
35
|
+
var import_compiled = require("../compiled");
|
|
36
|
+
var import_logger = require("./logger");
|
|
15
37
|
const getPort = async (port, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
|
|
16
38
|
if (typeof port === "string") {
|
|
17
39
|
port = parseInt(port, 10);
|
|
@@ -25,7 +47,7 @@ const getPort = async (port, { tryLimits = 20, strictPort = false, slient = fals
|
|
|
25
47
|
while (!found && attempts <= tryLimits) {
|
|
26
48
|
try {
|
|
27
49
|
await new Promise((resolve, reject) => {
|
|
28
|
-
const server =
|
|
50
|
+
const server = import_net.default.createServer();
|
|
29
51
|
server.unref();
|
|
30
52
|
server.on("error", reject);
|
|
31
53
|
server.listen({
|
|
@@ -48,8 +70,12 @@ const getPort = async (port, { tryLimits = 20, strictPort = false, slient = fals
|
|
|
48
70
|
if (strictPort) {
|
|
49
71
|
throw new Error(`Port "${original}" is occupied, please choose another one.`);
|
|
50
72
|
} else if (!slient) {
|
|
51
|
-
|
|
73
|
+
import_logger.logger.info(`Port ${original} is in use. ${import_compiled.chalk.yellow(`using port ${port}.`)}`);
|
|
52
74
|
}
|
|
53
75
|
}
|
|
54
76
|
return port;
|
|
55
77
|
};
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
getPort
|
|
81
|
+
});
|