@modern-js/utils 2.69.7 → 3.0.0-alpha.1
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 +76 -70
- package/dist/cjs/cli/applyOptionsChain.js +44 -45
- package/dist/cjs/cli/babel.js +100 -119
- package/dist/cjs/cli/commands.js +61 -59
- package/dist/cjs/cli/common.js +45 -37
- package/dist/cjs/cli/config.js +36 -30
- package/dist/cjs/cli/constants.js +124 -161
- package/dist/cjs/cli/ensure.js +52 -45
- package/dist/cjs/cli/fs.js +41 -38
- package/dist/cjs/cli/get/config.js +43 -38
- package/dist/cjs/cli/get/data.js +108 -125
- package/dist/cjs/cli/get/index.js +109 -58
- package/dist/cjs/cli/index.js +202 -63
- package/dist/cjs/cli/is/config.js +75 -71
- package/dist/cjs/cli/is/env.js +49 -37
- package/dist/cjs/cli/is/index.js +76 -25
- package/dist/cjs/cli/is/project.js +139 -135
- package/dist/cjs/cli/is/type.js +65 -49
- package/dist/cjs/cli/logger.js +36 -27
- package/dist/cjs/cli/monorepo.js +100 -96
- package/dist/cjs/cli/package.js +85 -82
- package/dist/cjs/cli/path.js +101 -82
- package/dist/cjs/cli/port.js +71 -74
- package/dist/cjs/cli/prettyInstructions.js +106 -116
- package/dist/cjs/cli/require.js +116 -136
- package/dist/cjs/cli/route.js +67 -77
- package/dist/cjs/cli/runtimeExports.js +16 -70
- package/dist/cjs/cli/version.js +53 -42
- package/dist/cjs/cli/watch.js +79 -72
- package/dist/cjs/compiled.js +199 -128
- package/dist/cjs/import.js +58 -33
- package/dist/cjs/index.js +69 -23
- package/dist/cjs/universal/constants.js +77 -67
- package/dist/cjs/universal/index.js +33 -25
- package/dist/cjs/universal/path.js +33 -27
- package/dist/cjs/universal/pluginDagSort.js +69 -68
- package/dist/compiled/address/index.js +171 -1
- package/dist/compiled/browserslist/index.js +1329 -1
- package/dist/compiled/chalk/index.js +2368 -1
- package/dist/compiled/chokidar/index.js +4138 -16
- package/dist/compiled/chokidar/index.js.LICENSE.txt +41 -0
- package/dist/compiled/commander/index.js +1540 -1
- package/dist/compiled/debug/index.js +621 -1
- package/dist/compiled/dotenv/index.js +101 -1
- package/dist/compiled/dotenv-expand/index.js +54 -1
- package/dist/compiled/execa/index.js +1738 -1
- package/dist/compiled/fast-glob/index.js +4645 -17
- package/dist/compiled/fast-glob/index.js.LICENSE.txt +38 -0
- package/dist/compiled/filesize/index.js +193 -4
- package/dist/compiled/filesize/index.js.LICENSE.txt +7 -0
- package/dist/compiled/fs-extra/index.js +2222 -1
- package/dist/compiled/glob/index.js +2011 -1
- package/dist/compiled/globby/index.js +690 -1
- package/dist/compiled/gzip-size/index.js +157 -1
- package/dist/compiled/import-lazy/index.js +45 -1
- package/dist/compiled/inquirer/index.js +20162 -4
- package/dist/compiled/inquirer/index.js.LICENSE.txt +7 -0
- package/dist/compiled/js-yaml/index.js +2188 -1
- package/dist/compiled/json5/index.js +983 -1
- package/dist/compiled/lodash/index.js +0 -4
- package/dist/compiled/mime-types/index.js +108 -6
- package/dist/compiled/mime-types/index.js.LICENSE.txt +13 -0
- package/dist/compiled/minimist/index.js +202 -1
- package/dist/compiled/nanoid/index.js +83 -1
- package/dist/compiled/ora/index.js +3936 -3
- package/dist/compiled/ora/index.js.LICENSE.txt +1 -0
- package/dist/compiled/pkg-up/index.js +177 -1
- package/dist/compiled/semver/index.js +1779 -1
- package/dist/compiled/signale/index.js +1704 -1
- package/dist/compiled/slash/index.js +32 -1
- package/dist/compiled/strip-ansi/index.js +34 -1
- package/dist/compiled/tsconfig-paths/index.js +629 -1
- package/dist/compiled/upath/index.js +135 -1
- package/dist/compiled/url-join/index.js +61 -1
- package/dist/compiled/webpack-chain/index.js +1475 -1
- package/dist/esm/cli/alias.mjs +31 -0
- package/dist/esm/cli/applyOptionsChain.mjs +16 -0
- package/dist/esm/cli/babel.mjs +76 -0
- package/dist/esm/cli/commands.mjs +23 -0
- package/dist/esm/cli/common.mjs +11 -0
- package/dist/esm/cli/config.mjs +5 -0
- package/dist/esm/cli/constants.mjs +29 -0
- package/dist/esm/cli/ensure.mjs +9 -0
- package/dist/esm/cli/fs.mjs +9 -0
- package/dist/esm/cli/get/config.mjs +14 -0
- package/dist/esm/cli/get/data.mjs +57 -0
- package/dist/esm/cli/get/index.mjs +18 -0
- package/dist/{esm-node/cli/index.js → esm/cli/index.mjs} +0 -1
- package/dist/esm/cli/is/config.mjs +34 -0
- package/dist/esm/cli/is/env.mjs +6 -0
- package/dist/esm/cli/is/project.mjs +104 -0
- package/dist/esm/cli/is/type.mjs +26 -0
- package/dist/esm/cli/logger.mjs +2 -0
- package/dist/esm/cli/monorepo.mjs +50 -0
- package/dist/esm/cli/package.mjs +51 -0
- package/dist/esm/cli/path.mjs +35 -0
- package/dist/esm/cli/port.mjs +35 -0
- package/dist/esm/cli/prettyInstructions.mjs +68 -0
- package/dist/esm/cli/require.mjs +79 -0
- package/dist/esm/cli/route.mjs +36 -0
- package/dist/esm/cli/runtimeExports.mjs +0 -0
- package/dist/esm/cli/version.mjs +21 -0
- package/dist/esm/cli/watch.mjs +40 -0
- package/dist/esm/compiled.mjs +115 -0
- package/dist/esm/import.mjs +25 -0
- package/dist/esm/universal/constants.mjs +13 -0
- package/dist/{esm-node/universal/index.js → esm/universal/index.mjs} +1 -3
- package/dist/esm/universal/path.mjs +2 -0
- package/dist/esm/universal/pluginDagSort.mjs +41 -0
- package/dist/esm-node/cli/alias.mjs +31 -0
- package/dist/esm-node/cli/applyOptionsChain.mjs +16 -0
- package/dist/esm-node/cli/babel.mjs +76 -0
- package/dist/esm-node/cli/commands.mjs +23 -0
- package/dist/esm-node/cli/common.mjs +11 -0
- package/dist/esm-node/cli/config.mjs +5 -0
- package/dist/esm-node/cli/constants.mjs +29 -0
- package/dist/esm-node/cli/ensure.mjs +9 -0
- package/dist/esm-node/cli/fs.mjs +9 -0
- package/dist/esm-node/cli/get/config.mjs +14 -0
- package/dist/esm-node/cli/get/data.mjs +57 -0
- package/dist/esm-node/cli/get/index.mjs +18 -0
- package/dist/esm-node/cli/index.mjs +22 -0
- package/dist/esm-node/cli/is/config.mjs +34 -0
- package/dist/esm-node/cli/is/env.mjs +6 -0
- package/dist/esm-node/cli/is/index.mjs +4 -0
- package/dist/esm-node/cli/is/project.mjs +104 -0
- package/dist/esm-node/cli/is/type.mjs +26 -0
- package/dist/esm-node/cli/logger.mjs +2 -0
- package/dist/esm-node/cli/monorepo.mjs +50 -0
- package/dist/esm-node/cli/package.mjs +51 -0
- package/dist/esm-node/cli/path.mjs +35 -0
- package/dist/esm-node/cli/port.mjs +35 -0
- package/dist/esm-node/cli/prettyInstructions.mjs +68 -0
- package/dist/esm-node/cli/require.mjs +79 -0
- package/dist/esm-node/cli/route.mjs +36 -0
- package/dist/esm-node/cli/runtimeExports.mjs +0 -0
- package/dist/esm-node/cli/version.mjs +21 -0
- package/dist/esm-node/cli/watch.mjs +40 -0
- package/dist/esm-node/compiled.mjs +115 -0
- package/dist/esm-node/import.mjs +25 -0
- package/dist/esm-node/index.mjs +3 -0
- package/dist/esm-node/universal/constants.mjs +13 -0
- package/dist/esm-node/universal/index.mjs +2 -0
- package/dist/esm-node/universal/path.mjs +2 -0
- package/dist/esm-node/universal/pluginDagSort.mjs +41 -0
- package/dist/types/cli/constants.d.ts +2 -26
- package/dist/types/cli/get/data.d.ts +0 -1
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/is/config.d.ts +1 -1
- package/dist/types/cli/runtimeExports.d.ts +1 -4
- package/dist/types/cli/watch.d.ts +1 -1
- package/dist/types/compiled.d.ts +0 -5
- package/dist/types/universal/constants.d.ts +4 -7
- package/package.json +27 -27
- package/rslib.config.mts +140 -0
- package/dist/cjs/cli/action.js +0 -55
- package/dist/cjs/universal/formatWebpack.js +0 -127
- package/dist/esm/cli/action.js +0 -68
- package/dist/esm/cli/alias.js +0 -43
- package/dist/esm/cli/applyOptionsChain.js +0 -29
- package/dist/esm/cli/babel.js +0 -122
- package/dist/esm/cli/commands.js +0 -39
- package/dist/esm/cli/common.js +0 -20
- package/dist/esm/cli/config.js +0 -11
- package/dist/esm/cli/constants.js +0 -114
- package/dist/esm/cli/ensure.js +0 -16
- package/dist/esm/cli/fs.js +0 -65
- package/dist/esm/cli/get/config.js +0 -19
- package/dist/esm/cli/get/data.js +0 -143
- package/dist/esm/cli/get/index.js +0 -38
- package/dist/esm/cli/index.js +0 -23
- package/dist/esm/cli/is/config.js +0 -70
- package/dist/esm/cli/is/env.js +0 -22
- package/dist/esm/cli/is/index.js +0 -4
- package/dist/esm/cli/is/project.js +0 -146
- package/dist/esm/cli/is/type.js +0 -39
- package/dist/esm/cli/logger.js +0 -5
- package/dist/esm/cli/monorepo.js +0 -82
- package/dist/esm/cli/package.js +0 -203
- package/dist/esm/cli/path.js +0 -66
- package/dist/esm/cli/port.js +0 -97
- package/dist/esm/cli/prettyInstructions.js +0 -102
- package/dist/esm/cli/require.js +0 -235
- package/dist/esm/cli/route.js +0 -64
- package/dist/esm/cli/runtimeExports.js +0 -44
- package/dist/esm/cli/version.js +0 -26
- package/dist/esm/cli/watch.js +0 -112
- package/dist/esm/compiled.js +0 -66
- package/dist/esm/import.js +0 -11
- package/dist/esm/index.js +0 -3
- package/dist/esm/universal/constants.js +0 -32
- package/dist/esm/universal/formatWebpack.js +0 -95
- package/dist/esm/universal/index.js +0 -4
- package/dist/esm/universal/path.js +0 -6
- package/dist/esm/universal/pluginDagSort.js +0 -73
- package/dist/esm-node/cli/action.js +0 -30
- package/dist/esm-node/cli/alias.js +0 -40
- package/dist/esm-node/cli/applyOptionsChain.js +0 -27
- package/dist/esm-node/cli/babel.js +0 -107
- package/dist/esm-node/cli/commands.js +0 -39
- package/dist/esm-node/cli/common.js +0 -15
- package/dist/esm-node/cli/config.js +0 -9
- package/dist/esm-node/cli/constants.js +0 -114
- package/dist/esm-node/cli/ensure.js +0 -14
- package/dist/esm-node/cli/fs.js +0 -18
- package/dist/esm-node/cli/get/config.js +0 -19
- package/dist/esm-node/cli/get/data.js +0 -96
- package/dist/esm-node/cli/get/index.js +0 -22
- package/dist/esm-node/cli/is/config.js +0 -50
- package/dist/esm-node/cli/is/env.js +0 -12
- package/dist/esm-node/cli/is/project.js +0 -105
- package/dist/esm-node/cli/is/type.js +0 -36
- package/dist/esm-node/cli/logger.js +0 -5
- package/dist/esm-node/cli/monorepo.js +0 -67
- package/dist/esm-node/cli/package.js +0 -66
- package/dist/esm-node/cli/path.js +0 -48
- package/dist/esm-node/cli/port.js +0 -48
- package/dist/esm-node/cli/prettyInstructions.js +0 -90
- package/dist/esm-node/cli/require.js +0 -111
- package/dist/esm-node/cli/route.js +0 -60
- package/dist/esm-node/cli/runtimeExports.js +0 -38
- package/dist/esm-node/cli/version.js +0 -26
- package/dist/esm-node/cli/watch.js +0 -45
- package/dist/esm-node/compiled.js +0 -66
- package/dist/esm-node/import.js +0 -11
- package/dist/esm-node/universal/constants.js +0 -32
- package/dist/esm-node/universal/formatWebpack.js +0 -102
- package/dist/esm-node/universal/path.js +0 -6
- package/dist/esm-node/universal/pluginDagSort.js +0 -50
- package/dist/types/cli/action.d.ts +0 -2
- package/dist/types/universal/formatWebpack.d.ts +0 -26
- /package/dist/{esm-node/cli/is/index.js → esm/cli/is/index.mjs} +0 -0
- /package/dist/{esm-node/index.js → esm/index.mjs} +0 -0
package/dist/esm/cli/is/type.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
2
|
-
function isString(str) {
|
|
3
|
-
return typeof str === "string";
|
|
4
|
-
}
|
|
5
|
-
function isUndefined(obj) {
|
|
6
|
-
return typeof obj === "undefined";
|
|
7
|
-
}
|
|
8
|
-
function isArray(obj) {
|
|
9
|
-
return Array.isArray(obj);
|
|
10
|
-
}
|
|
11
|
-
function isFunction(func) {
|
|
12
|
-
return typeof func === "function";
|
|
13
|
-
}
|
|
14
|
-
function isObject(obj) {
|
|
15
|
-
return obj !== null && (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object";
|
|
16
|
-
}
|
|
17
|
-
function isPlainObject(obj) {
|
|
18
|
-
return isObject(obj) && Object.prototype.toString.call(obj) === "[object Object]";
|
|
19
|
-
}
|
|
20
|
-
function isPromise(obj) {
|
|
21
|
-
return Boolean(obj) && ((typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
22
|
-
}
|
|
23
|
-
function isRegExp(obj) {
|
|
24
|
-
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
25
|
-
}
|
|
26
|
-
var isEmpty = function(o) {
|
|
27
|
-
return Object.entries(o).length === 0 && o.constructor === Object;
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
isArray,
|
|
31
|
-
isEmpty,
|
|
32
|
-
isFunction,
|
|
33
|
-
isObject,
|
|
34
|
-
isPlainObject,
|
|
35
|
-
isPromise,
|
|
36
|
-
isRegExp,
|
|
37
|
-
isString,
|
|
38
|
-
isUndefined
|
|
39
|
-
};
|
package/dist/esm/cli/logger.js
DELETED
package/dist/esm/cli/monorepo.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { glob, yaml } from "../compiled";
|
|
4
|
-
var PACKAGE_MAX_DEPTH = 5;
|
|
5
|
-
var WORKSPACE_FILES = {
|
|
6
|
-
YARN: "package.json",
|
|
7
|
-
PNPM: "pnpm-workspace.yaml",
|
|
8
|
-
LERNA: "lerna.json"
|
|
9
|
-
};
|
|
10
|
-
var isLerna = function(root) {
|
|
11
|
-
return fs.existsSync(path.join(root, WORKSPACE_FILES.LERNA));
|
|
12
|
-
};
|
|
13
|
-
var isYarnWorkspaces = function(root) {
|
|
14
|
-
var _json_workspaces;
|
|
15
|
-
var pkg = path.join(root, WORKSPACE_FILES.YARN);
|
|
16
|
-
if (!fs.existsSync(pkg)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
var json = JSON.parse(fs.readFileSync(pkg, "utf8"));
|
|
20
|
-
return Boolean((_json_workspaces = json.workspaces) === null || _json_workspaces === void 0 ? void 0 : _json_workspaces.packages);
|
|
21
|
-
};
|
|
22
|
-
var isPnpmWorkspaces = function(root) {
|
|
23
|
-
return fs.existsSync(path.join(root, WORKSPACE_FILES.PNPM));
|
|
24
|
-
};
|
|
25
|
-
var isMonorepo = function(root) {
|
|
26
|
-
return isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
|
27
|
-
};
|
|
28
|
-
var findMonorepoRoot = function(appDirectory) {
|
|
29
|
-
var maxDepth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : PACKAGE_MAX_DEPTH;
|
|
30
|
-
var inMonorepo = false;
|
|
31
|
-
var monorepoRoot = appDirectory;
|
|
32
|
-
for (var depth = 0; depth < maxDepth; depth++) {
|
|
33
|
-
if (isMonorepo(appDirectory)) {
|
|
34
|
-
inMonorepo = true;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
monorepoRoot = path.dirname(appDirectory);
|
|
38
|
-
}
|
|
39
|
-
return inMonorepo ? monorepoRoot : void 0;
|
|
40
|
-
};
|
|
41
|
-
var getMonorepoPackages = function(root) {
|
|
42
|
-
var packages = [];
|
|
43
|
-
if (isYarnWorkspaces(root)) {
|
|
44
|
-
var json = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
45
|
-
packages = json.workspaces.packages;
|
|
46
|
-
} else if (isLerna(root)) {
|
|
47
|
-
var json1 = JSON.parse(fs.readFileSync(path.resolve(root, "lerna.json"), "utf8"));
|
|
48
|
-
packages = json1.packages;
|
|
49
|
-
} else {
|
|
50
|
-
packages = yaml.load(fs.readFileSync(path.join(root, WORKSPACE_FILES.PNPM), "utf8")).packages;
|
|
51
|
-
}
|
|
52
|
-
if (packages) {
|
|
53
|
-
return packages.map(function(name) {
|
|
54
|
-
return (
|
|
55
|
-
// The trailing / ensures only dirs are picked up
|
|
56
|
-
glob.sync(path.join(root, "".concat(name, "/")), {
|
|
57
|
-
ignore: [
|
|
58
|
-
"**/node_modules/**"
|
|
59
|
-
]
|
|
60
|
-
})
|
|
61
|
-
);
|
|
62
|
-
}).reduce(function(acc, val) {
|
|
63
|
-
return acc.concat(val);
|
|
64
|
-
}, []).filter(function(filepath) {
|
|
65
|
-
return fs.existsSync(path.resolve(filepath, "package.json"));
|
|
66
|
-
}).map(function(filepath) {
|
|
67
|
-
return {
|
|
68
|
-
path: filepath,
|
|
69
|
-
name: JSON.parse(fs.readFileSync(path.resolve(filepath, "package.json"), "utf8")).name
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return [];
|
|
74
|
-
};
|
|
75
|
-
export {
|
|
76
|
-
findMonorepoRoot,
|
|
77
|
-
getMonorepoPackages,
|
|
78
|
-
isLerna,
|
|
79
|
-
isMonorepo,
|
|
80
|
-
isPnpmWorkspaces,
|
|
81
|
-
isYarnWorkspaces
|
|
82
|
-
};
|
package/dist/esm/cli/package.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
|
-
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
4
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
|
-
import { execa } from "../compiled";
|
|
6
|
-
function getPnpmVersion() {
|
|
7
|
-
return _getPnpmVersion.apply(this, arguments);
|
|
8
|
-
}
|
|
9
|
-
function _getPnpmVersion() {
|
|
10
|
-
_getPnpmVersion = _async_to_generator(function() {
|
|
11
|
-
var stdout;
|
|
12
|
-
return _ts_generator(this, function(_state) {
|
|
13
|
-
switch (_state.label) {
|
|
14
|
-
case 0:
|
|
15
|
-
return [
|
|
16
|
-
4,
|
|
17
|
-
execa("pnpm", [
|
|
18
|
-
"--version"
|
|
19
|
-
])
|
|
20
|
-
];
|
|
21
|
-
case 1:
|
|
22
|
-
stdout = _state.sent().stdout;
|
|
23
|
-
return [
|
|
24
|
-
2,
|
|
25
|
-
stdout
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
return _getPnpmVersion.apply(this, arguments);
|
|
31
|
-
}
|
|
32
|
-
function canUseNpm() {
|
|
33
|
-
return _canUseNpm.apply(this, arguments);
|
|
34
|
-
}
|
|
35
|
-
function _canUseNpm() {
|
|
36
|
-
_canUseNpm = _async_to_generator(function() {
|
|
37
|
-
var e;
|
|
38
|
-
return _ts_generator(this, function(_state) {
|
|
39
|
-
switch (_state.label) {
|
|
40
|
-
case 0:
|
|
41
|
-
_state.trys.push([
|
|
42
|
-
0,
|
|
43
|
-
2,
|
|
44
|
-
,
|
|
45
|
-
3
|
|
46
|
-
]);
|
|
47
|
-
return [
|
|
48
|
-
4,
|
|
49
|
-
execa("npm", [
|
|
50
|
-
"--version"
|
|
51
|
-
], {
|
|
52
|
-
env: process.env
|
|
53
|
-
})
|
|
54
|
-
];
|
|
55
|
-
case 1:
|
|
56
|
-
_state.sent();
|
|
57
|
-
return [
|
|
58
|
-
2,
|
|
59
|
-
true
|
|
60
|
-
];
|
|
61
|
-
case 2:
|
|
62
|
-
e = _state.sent();
|
|
63
|
-
return [
|
|
64
|
-
2,
|
|
65
|
-
false
|
|
66
|
-
];
|
|
67
|
-
case 3:
|
|
68
|
-
return [
|
|
69
|
-
2
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
return _canUseNpm.apply(this, arguments);
|
|
75
|
-
}
|
|
76
|
-
function canUseYarn() {
|
|
77
|
-
return _canUseYarn.apply(this, arguments);
|
|
78
|
-
}
|
|
79
|
-
function _canUseYarn() {
|
|
80
|
-
_canUseYarn = _async_to_generator(function() {
|
|
81
|
-
var e;
|
|
82
|
-
return _ts_generator(this, function(_state) {
|
|
83
|
-
switch (_state.label) {
|
|
84
|
-
case 0:
|
|
85
|
-
_state.trys.push([
|
|
86
|
-
0,
|
|
87
|
-
2,
|
|
88
|
-
,
|
|
89
|
-
3
|
|
90
|
-
]);
|
|
91
|
-
return [
|
|
92
|
-
4,
|
|
93
|
-
execa("yarn", [
|
|
94
|
-
"--version"
|
|
95
|
-
], {
|
|
96
|
-
env: process.env
|
|
97
|
-
})
|
|
98
|
-
];
|
|
99
|
-
case 1:
|
|
100
|
-
_state.sent();
|
|
101
|
-
return [
|
|
102
|
-
2,
|
|
103
|
-
true
|
|
104
|
-
];
|
|
105
|
-
case 2:
|
|
106
|
-
e = _state.sent();
|
|
107
|
-
return [
|
|
108
|
-
2,
|
|
109
|
-
false
|
|
110
|
-
];
|
|
111
|
-
case 3:
|
|
112
|
-
return [
|
|
113
|
-
2
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
return _canUseYarn.apply(this, arguments);
|
|
119
|
-
}
|
|
120
|
-
function canUsePnpm() {
|
|
121
|
-
return _canUsePnpm.apply(this, arguments);
|
|
122
|
-
}
|
|
123
|
-
function _canUsePnpm() {
|
|
124
|
-
_canUsePnpm = _async_to_generator(function() {
|
|
125
|
-
var e;
|
|
126
|
-
return _ts_generator(this, function(_state) {
|
|
127
|
-
switch (_state.label) {
|
|
128
|
-
case 0:
|
|
129
|
-
_state.trys.push([
|
|
130
|
-
0,
|
|
131
|
-
2,
|
|
132
|
-
,
|
|
133
|
-
3
|
|
134
|
-
]);
|
|
135
|
-
return [
|
|
136
|
-
4,
|
|
137
|
-
execa("pnpm", [
|
|
138
|
-
"--version"
|
|
139
|
-
], {
|
|
140
|
-
env: process.env
|
|
141
|
-
})
|
|
142
|
-
];
|
|
143
|
-
case 1:
|
|
144
|
-
_state.sent();
|
|
145
|
-
return [
|
|
146
|
-
2,
|
|
147
|
-
true
|
|
148
|
-
];
|
|
149
|
-
case 2:
|
|
150
|
-
e = _state.sent();
|
|
151
|
-
return [
|
|
152
|
-
2,
|
|
153
|
-
false
|
|
154
|
-
];
|
|
155
|
-
case 3:
|
|
156
|
-
return [
|
|
157
|
-
2
|
|
158
|
-
];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
return _canUsePnpm.apply(this, arguments);
|
|
163
|
-
}
|
|
164
|
-
function removeModuleSyncFromExports(exports) {
|
|
165
|
-
if ((typeof exports === "undefined" ? "undefined" : _type_of(exports)) !== "object" || exports === null) {
|
|
166
|
-
return exports;
|
|
167
|
-
}
|
|
168
|
-
if (Array.isArray(exports)) {
|
|
169
|
-
return exports.map(removeModuleSyncFromExports);
|
|
170
|
-
}
|
|
171
|
-
var result = {};
|
|
172
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
173
|
-
try {
|
|
174
|
-
for (var _iterator = Object.entries(exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
175
|
-
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
176
|
-
if (key === "module-sync") {
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
result[key] = removeModuleSyncFromExports(value);
|
|
180
|
-
}
|
|
181
|
-
} catch (err) {
|
|
182
|
-
_didIteratorError = true;
|
|
183
|
-
_iteratorError = err;
|
|
184
|
-
} finally {
|
|
185
|
-
try {
|
|
186
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
187
|
-
_iterator.return();
|
|
188
|
-
}
|
|
189
|
-
} finally {
|
|
190
|
-
if (_didIteratorError) {
|
|
191
|
-
throw _iteratorError;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return result;
|
|
196
|
-
}
|
|
197
|
-
export {
|
|
198
|
-
canUseNpm,
|
|
199
|
-
canUsePnpm,
|
|
200
|
-
canUseYarn,
|
|
201
|
-
getPnpmVersion,
|
|
202
|
-
removeModuleSyncFromExports
|
|
203
|
-
};
|
package/dist/esm/cli/path.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import os from "os";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { nanoid, upath } from "../compiled";
|
|
6
|
-
var isPathString = function(test) {
|
|
7
|
-
return path.posix.basename(test) !== test || path.win32.basename(test) !== test;
|
|
8
|
-
};
|
|
9
|
-
var isRelativePath = function(test) {
|
|
10
|
-
return /^\.\.?($|[\\/])/.test(test);
|
|
11
|
-
};
|
|
12
|
-
var normalizeOutputPath = function(s) {
|
|
13
|
-
return s.replace(/\\/g, "\\\\");
|
|
14
|
-
};
|
|
15
|
-
var normalizeToPosixPath = function(p) {
|
|
16
|
-
return upath.normalizeSafe(path.normalize(p || "")).replace(/^([a-zA-Z]+):/, function(_, m) {
|
|
17
|
-
return "/".concat(m.toLowerCase());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
var getTemplatePath = function(prefix) {
|
|
21
|
-
var _path;
|
|
22
|
-
var tmpRoot = fs.realpathSync(os.tmpdir());
|
|
23
|
-
var parts = [
|
|
24
|
-
tmpRoot
|
|
25
|
-
];
|
|
26
|
-
prefix && parts.push(prefix);
|
|
27
|
-
parts.push(nanoid());
|
|
28
|
-
return (_path = path).resolve.apply(_path, _to_consumable_array(parts));
|
|
29
|
-
};
|
|
30
|
-
function getRealTemporaryDirectory() {
|
|
31
|
-
var ret = null;
|
|
32
|
-
try {
|
|
33
|
-
ret = os.tmpdir();
|
|
34
|
-
ret = fs.realpathSync(ret);
|
|
35
|
-
} catch (e) {
|
|
36
|
-
}
|
|
37
|
-
return ret;
|
|
38
|
-
}
|
|
39
|
-
function splitPathString(str) {
|
|
40
|
-
return str.split(/[\\/]/);
|
|
41
|
-
}
|
|
42
|
-
var removeLeadingSlash = function(s) {
|
|
43
|
-
return s.replace(/^\/+/, "");
|
|
44
|
-
};
|
|
45
|
-
var removeTailSlash = function(s) {
|
|
46
|
-
return s.replace(/\/+$/, "");
|
|
47
|
-
};
|
|
48
|
-
var removeSlash = function(s) {
|
|
49
|
-
return removeLeadingSlash(removeTailSlash(s));
|
|
50
|
-
};
|
|
51
|
-
function formatImportPath(str) {
|
|
52
|
-
return str.replace(/\\/g, "/");
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
formatImportPath,
|
|
56
|
-
getRealTemporaryDirectory,
|
|
57
|
-
getTemplatePath,
|
|
58
|
-
isPathString,
|
|
59
|
-
isRelativePath,
|
|
60
|
-
normalizeOutputPath,
|
|
61
|
-
normalizeToPosixPath,
|
|
62
|
-
removeLeadingSlash,
|
|
63
|
-
removeSlash,
|
|
64
|
-
removeTailSlash,
|
|
65
|
-
splitPathString
|
|
66
|
-
};
|
package/dist/esm/cli/port.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
|
-
import net from "net";
|
|
4
|
-
import { chalk } from "../compiled";
|
|
5
|
-
import { logger } from "./logger";
|
|
6
|
-
var getPort = function() {
|
|
7
|
-
var _ref = _async_to_generator(function(expectPort) {
|
|
8
|
-
var _ref2, _ref_tryLimits, tryLimits, _ref_strictPort, strictPort, _ref_slient, slient, port, original, found, attempts, e;
|
|
9
|
-
var _arguments = arguments;
|
|
10
|
-
return _ts_generator(this, function(_state) {
|
|
11
|
-
switch (_state.label) {
|
|
12
|
-
case 0:
|
|
13
|
-
_ref2 = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, _ref_tryLimits = _ref2.tryLimits, tryLimits = _ref_tryLimits === void 0 ? 20 : _ref_tryLimits, _ref_strictPort = _ref2.strictPort, strictPort = _ref_strictPort === void 0 ? false : _ref_strictPort, _ref_slient = _ref2.slient, slient = _ref_slient === void 0 ? false : _ref_slient;
|
|
14
|
-
port = expectPort;
|
|
15
|
-
if (typeof port === "string") {
|
|
16
|
-
port = parseInt(port, 10);
|
|
17
|
-
}
|
|
18
|
-
if (strictPort) {
|
|
19
|
-
tryLimits = 1;
|
|
20
|
-
}
|
|
21
|
-
original = port;
|
|
22
|
-
found = false;
|
|
23
|
-
attempts = 0;
|
|
24
|
-
_state.label = 1;
|
|
25
|
-
case 1:
|
|
26
|
-
if (!(!found && attempts <= tryLimits))
|
|
27
|
-
return [
|
|
28
|
-
3,
|
|
29
|
-
6
|
|
30
|
-
];
|
|
31
|
-
_state.label = 2;
|
|
32
|
-
case 2:
|
|
33
|
-
_state.trys.push([
|
|
34
|
-
2,
|
|
35
|
-
4,
|
|
36
|
-
,
|
|
37
|
-
5
|
|
38
|
-
]);
|
|
39
|
-
return [
|
|
40
|
-
4,
|
|
41
|
-
new Promise(function(resolve, reject) {
|
|
42
|
-
var server = net.createServer();
|
|
43
|
-
server.unref();
|
|
44
|
-
server.on("error", reject);
|
|
45
|
-
server.listen({
|
|
46
|
-
port,
|
|
47
|
-
host: "0.0.0.0"
|
|
48
|
-
}, function() {
|
|
49
|
-
found = true;
|
|
50
|
-
server.close(resolve);
|
|
51
|
-
});
|
|
52
|
-
})
|
|
53
|
-
];
|
|
54
|
-
case 3:
|
|
55
|
-
_state.sent();
|
|
56
|
-
return [
|
|
57
|
-
3,
|
|
58
|
-
5
|
|
59
|
-
];
|
|
60
|
-
case 4:
|
|
61
|
-
e = _state.sent();
|
|
62
|
-
if (e.code !== "EADDRINUSE") {
|
|
63
|
-
throw e;
|
|
64
|
-
}
|
|
65
|
-
port++;
|
|
66
|
-
attempts++;
|
|
67
|
-
return [
|
|
68
|
-
3,
|
|
69
|
-
5
|
|
70
|
-
];
|
|
71
|
-
case 5:
|
|
72
|
-
return [
|
|
73
|
-
3,
|
|
74
|
-
1
|
|
75
|
-
];
|
|
76
|
-
case 6:
|
|
77
|
-
if (port !== original) {
|
|
78
|
-
if (strictPort) {
|
|
79
|
-
throw new Error('Port "'.concat(original, '" is occupied, please choose another one.'));
|
|
80
|
-
} else if (!slient) {
|
|
81
|
-
logger.info("Port ".concat(original, " is in use. ").concat(chalk.yellow("using port ".concat(port, "."))));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return [
|
|
85
|
-
2,
|
|
86
|
-
port
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
return function getPort2(expectPort) {
|
|
92
|
-
return _ref.apply(this, arguments);
|
|
93
|
-
};
|
|
94
|
-
}();
|
|
95
|
-
export {
|
|
96
|
-
getPort
|
|
97
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
2
|
-
import { isIPv6 } from "net";
|
|
3
|
-
import os from "os";
|
|
4
|
-
import { chalk } from "../compiled";
|
|
5
|
-
import { DEFAULT_DEV_HOST } from "./constants";
|
|
6
|
-
import { isDev, isSingleEntry } from "./is";
|
|
7
|
-
var normalizeUrl = function(url) {
|
|
8
|
-
return url.replace(/([^:]\/)\/+/g, "$1");
|
|
9
|
-
};
|
|
10
|
-
var getIpv4Interfaces = function() {
|
|
11
|
-
var interfaces = os.networkInterfaces();
|
|
12
|
-
var ipv4Interfaces = [];
|
|
13
|
-
Object.keys(interfaces).forEach(function(key) {
|
|
14
|
-
interfaces[key].forEach(function(detail) {
|
|
15
|
-
var familyV4Value = typeof detail.family === "string" ? "IPv4" : 4;
|
|
16
|
-
if (detail.family === familyV4Value) {
|
|
17
|
-
ipv4Interfaces.push(detail);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
return ipv4Interfaces;
|
|
22
|
-
};
|
|
23
|
-
var getHostInUrl = function(host) {
|
|
24
|
-
if (isIPv6(host)) {
|
|
25
|
-
return host === "::" ? "[::1]" : "[".concat(host, "]");
|
|
26
|
-
}
|
|
27
|
-
return host;
|
|
28
|
-
};
|
|
29
|
-
var getAddressUrls = function() {
|
|
30
|
-
var protocol = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "http", port = arguments.length > 1 ? arguments[1] : void 0, host = arguments.length > 2 ? arguments[2] : void 0;
|
|
31
|
-
var LOCAL_LABEL = "Local: ";
|
|
32
|
-
var NETWORK_LABEL = "Network: ";
|
|
33
|
-
var isLocalhost = function(url) {
|
|
34
|
-
return url === null || url === void 0 ? void 0 : url.includes("localhost");
|
|
35
|
-
};
|
|
36
|
-
if (host && host !== DEFAULT_DEV_HOST) {
|
|
37
|
-
return [
|
|
38
|
-
{
|
|
39
|
-
label: isLocalhost(host) ? LOCAL_LABEL : NETWORK_LABEL,
|
|
40
|
-
url: "".concat(protocol, "://").concat(getHostInUrl(host), ":").concat(port)
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
var ipv4Interfaces = getIpv4Interfaces();
|
|
45
|
-
return ipv4Interfaces.reduce(function(memo, detail) {
|
|
46
|
-
if (isLocalhost(detail.address) || detail.internal) {
|
|
47
|
-
memo.push({
|
|
48
|
-
label: LOCAL_LABEL,
|
|
49
|
-
url: "".concat(protocol, "://localhost:").concat(port)
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
memo.push({
|
|
53
|
-
label: NETWORK_LABEL,
|
|
54
|
-
url: "".concat(protocol, "://").concat(detail.address, ":").concat(port)
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return memo;
|
|
58
|
-
}, []);
|
|
59
|
-
};
|
|
60
|
-
var prettyInstructions = function(appContext, config) {
|
|
61
|
-
var _config_dev, _config_tools_devServer, _config_tools, _config_dev1, _config_source, _config_dev2;
|
|
62
|
-
var entrypoints = appContext.entrypoints, serverRoutes = appContext.serverRoutes, port = appContext.port, apiOnly = appContext.apiOnly, checkedEntries = appContext.checkedEntries;
|
|
63
|
-
var isHttps = isDev() && ((config === null || config === void 0 ? void 0 : (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.https) || (config === null || config === void 0 ? void 0 : (_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : (_config_tools_devServer = _config_tools.devServer) === null || _config_tools_devServer === void 0 ? void 0 : _config_tools_devServer.https));
|
|
64
|
-
var urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev1 = config.dev) === null || _config_dev1 === void 0 ? void 0 : _config_dev1.host);
|
|
65
|
-
var routes = !apiOnly ? serverRoutes.filter(function(route) {
|
|
66
|
-
return route.entryName;
|
|
67
|
-
}) : serverRoutes;
|
|
68
|
-
var message = "\n";
|
|
69
|
-
if (isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
|
|
70
|
-
message += urls.map(function(param) {
|
|
71
|
-
var label = param.label, url = param.url;
|
|
72
|
-
return " ".concat(chalk.bold("> ".concat(label.padEnd(10)))).concat(chalk.cyanBright(normalizeUrl("".concat(url, "/").concat(routes[0].urlPath))), "\n");
|
|
73
|
-
}).join("");
|
|
74
|
-
} else {
|
|
75
|
-
var _Math;
|
|
76
|
-
var maxNameLength = (_Math = Math).max.apply(_Math, _to_consumable_array(routes.map(function(r) {
|
|
77
|
-
return r.entryName.length;
|
|
78
|
-
})));
|
|
79
|
-
urls.forEach(function(param) {
|
|
80
|
-
var label = param.label, url = param.url;
|
|
81
|
-
message += " ".concat(chalk.bold("> ".concat(label))).concat(routes.length === 0 ? chalk.cyanBright(url) : "", "\n");
|
|
82
|
-
routes.forEach(function(param2) {
|
|
83
|
-
var entryName = param2.entryName, urlPath = param2.urlPath, isSSR = param2.isSSR;
|
|
84
|
-
if (!checkedEntries.includes(entryName)) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
message += " ".concat(chalk.yellowBright(isSSR ? "λ" : "○"), " ").concat(chalk.yellowBright(entryName.padEnd(maxNameLength + 8))).concat(chalk.cyanBright(normalizeUrl("".concat(url, "/").concat(urlPath))), "\n");
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
message += "\n";
|
|
91
|
-
message += chalk.cyanBright(" λ (Server) server-side renders at runtime\n");
|
|
92
|
-
message += chalk.cyanBright(" ○ (Static) client-side renders as static HTML\n");
|
|
93
|
-
}
|
|
94
|
-
if ((_config_dev2 = config.dev) === null || _config_dev2 === void 0 ? void 0 : _config_dev2.cliShortcuts) {
|
|
95
|
-
message += " ".concat(chalk.dim("> press"), " ").concat(chalk.bold("h + enter"), " ").concat(chalk.dim("to show shortcuts"), "\n");
|
|
96
|
-
}
|
|
97
|
-
return message;
|
|
98
|
-
};
|
|
99
|
-
export {
|
|
100
|
-
getAddressUrls,
|
|
101
|
-
prettyInstructions
|
|
102
|
-
};
|