@modern-js/utils 2.15.0 → 2.16.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/CHANGELOG.md +16 -0
- package/dist/cjs/FileSizeReporter.js +69 -92
- package/dist/cjs/alias.js +34 -58
- package/dist/cjs/analyzeProject.js +58 -41
- package/dist/cjs/applyOptionsChain.js +15 -42
- package/dist/cjs/babel.js +28 -39
- package/dist/cjs/chainId.js +7 -25
- package/dist/cjs/clearConsole.js +7 -25
- package/dist/cjs/commands.js +14 -29
- package/dist/cjs/compatRequire.js +22 -38
- package/dist/cjs/compiled.js +120 -139
- package/dist/cjs/constants.js +143 -98
- package/dist/cjs/debug.js +8 -26
- package/dist/cjs/emptyDir.js +10 -28
- package/dist/cjs/ensureAbsolutePath.js +13 -36
- package/dist/cjs/ensureArray.js +10 -26
- package/dist/cjs/findExists.js +14 -37
- package/dist/cjs/generateMetaTags.js +12 -31
- package/dist/cjs/getBrowserslist.js +20 -27
- package/dist/cjs/getCoreJsVersion.js +49 -37
- package/dist/cjs/getEntryOptions.js +14 -29
- package/dist/cjs/getPackageManager.js +23 -46
- package/dist/cjs/getPort.js +26 -61
- package/dist/cjs/getServerConfig.js +51 -43
- package/dist/cjs/getTargetDir.js +50 -38
- package/dist/cjs/import.js +16 -27
- package/dist/cjs/index.js +61 -60
- package/dist/cjs/is/index.js +53 -68
- package/dist/cjs/is/nodeEnv.js +13 -29
- package/dist/cjs/is/platform.js +13 -26
- package/dist/cjs/is/type.js +14 -33
- package/dist/cjs/logger.js +54 -50
- package/dist/cjs/monorepo.js +47 -78
- package/dist/cjs/nodeEnv.js +29 -31
- package/dist/cjs/path.js +42 -63
- package/dist/cjs/pathSerializer.js +43 -51
- package/dist/cjs/plugin.js +11 -29
- package/dist/cjs/prettyInstructions.js +35 -68
- package/dist/cjs/printBuildError.js +15 -37
- package/dist/cjs/react.js +18 -41
- package/dist/cjs/readTsConfig.js +21 -39
- package/dist/cjs/removeSlash.js +13 -27
- package/dist/cjs/resolve.js +25 -31
- package/dist/cjs/routes.js +23 -43
- package/dist/cjs/runtime/index.js +18 -17
- package/dist/cjs/runtime/parsed.js +8 -26
- package/dist/cjs/runtimeExports.js +31 -56
- package/dist/cjs/ssr.js +13 -26
- package/dist/cjs/storage.js +51 -41
- package/dist/cjs/testUtils.js +8 -29
- package/dist/cjs/types.js +4 -15
- package/dist/cjs/universal/constants.js +13 -26
- package/dist/cjs/universal/formatWebpack.js +16 -44
- package/dist/cjs/universal/nestedRoutes.js +94 -46
- package/dist/cjs/universal/pluginDagSort.js +58 -0
- package/dist/cjs/universal/remixRouter.js +18 -17
- package/dist/cjs/universal/serialize.js +16 -37
- package/dist/cjs/version.js +25 -41
- package/dist/cjs/wait.js +7 -25
- package/dist/cjs/watch.js +69 -43
- package/dist/esm/FileSizeReporter.js +40 -52
- package/dist/esm/alias.js +9 -19
- package/dist/esm/analyzeProject.js +3 -7
- package/dist/esm/applyOptionsChain.js +5 -17
- package/dist/esm/babel.js +6 -8
- package/dist/esm/chainId.js +1 -4
- package/dist/esm/clearConsole.js +1 -4
- package/dist/esm/commands.js +6 -12
- package/dist/esm/compatRequire.js +10 -17
- package/dist/esm/compiled.js +32 -76
- package/dist/esm/constants.js +143 -89
- package/dist/esm/debug.js +1 -4
- package/dist/esm/emptyDir.js +1 -4
- package/dist/esm/ensureAbsolutePath.js +1 -4
- package/dist/esm/ensureArray.js +4 -5
- package/dist/esm/findExists.js +1 -4
- package/dist/esm/generateMetaTags.js +6 -10
- package/dist/esm/getBrowserslist.js +8 -6
- package/dist/esm/getCoreJsVersion.js +1 -4
- package/dist/esm/getEntryOptions.js +5 -5
- package/dist/esm/getPackageManager.js +1 -4
- package/dist/esm/getPort.js +10 -25
- package/dist/esm/getServerConfig.js +2 -9
- package/dist/esm/getTargetDir.js +1 -4
- package/dist/esm/import.js +3 -4
- package/dist/esm/is/index.js +18 -30
- package/dist/esm/is/nodeEnv.js +5 -12
- package/dist/esm/is/platform.js +2 -6
- package/dist/esm/is/type.js +8 -18
- package/dist/esm/logger.js +37 -17
- package/dist/esm/monorepo.js +21 -38
- package/dist/esm/nodeEnv.js +18 -11
- package/dist/esm/path.js +16 -23
- package/dist/esm/pathSerializer.js +21 -21
- package/dist/esm/plugin.js +1 -4
- package/dist/esm/prettyInstructions.js +13 -32
- package/dist/esm/printBuildError.js +4 -11
- package/dist/esm/react.js +1 -4
- package/dist/esm/readTsConfig.js +2 -6
- package/dist/esm/removeSlash.js +3 -8
- package/dist/esm/resolve.js +14 -11
- package/dist/esm/routes.js +4 -10
- package/dist/esm/runtime/parsed.js +2 -5
- package/dist/esm/runtimeExports.js +17 -22
- package/dist/esm/ssr.js +1 -4
- package/dist/esm/storage.js +2 -6
- package/dist/esm/testUtils.js +2 -8
- package/dist/esm/types.js +1 -0
- package/dist/esm/universal/constants.js +2 -6
- package/dist/esm/universal/formatWebpack.js +10 -22
- package/dist/esm/universal/nestedRoutes.js +41 -27
- package/dist/esm/universal/pluginDagSort.js +50 -0
- package/dist/esm/universal/serialize.js +4 -5
- package/dist/esm/version.js +5 -7
- package/dist/esm/wait.js +1 -3
- package/dist/esm/watch.js +14 -9
- package/dist/types/universal/pluginDagSort.d.ts +1 -0
- package/package.json +17 -5
package/dist/cjs/monorepo.js
CHANGED
|
@@ -1,68 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var monorepo_exports = {};
|
|
29
|
-
__export(monorepo_exports, {
|
|
30
|
-
findMonorepoRoot: () => findMonorepoRoot,
|
|
31
|
-
getMonorepoPackages: () => getMonorepoPackages,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
32
13
|
isLerna: () => isLerna,
|
|
33
|
-
|
|
34
|
-
isMonorepo: () => isMonorepo,
|
|
14
|
+
isYarnWorkspaces: () => isYarnWorkspaces,
|
|
35
15
|
isPnpmWorkspaces: () => isPnpmWorkspaces,
|
|
36
|
-
|
|
16
|
+
isMonorepo: () => isMonorepo,
|
|
17
|
+
isModernjsMonorepo: () => isModernjsMonorepo,
|
|
18
|
+
findMonorepoRoot: () => findMonorepoRoot,
|
|
19
|
+
getMonorepoPackages: () => getMonorepoPackages
|
|
37
20
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
|
|
22
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
23
|
+
const _compiled = require("./compiled");
|
|
24
|
+
function _interop_require_default(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
42
29
|
const PACKAGE_MAX_DEPTH = 5;
|
|
43
30
|
const WORKSPACE_FILES = {
|
|
44
31
|
YARN: "package.json",
|
|
45
32
|
PNPM: "pnpm-workspace.yaml",
|
|
46
33
|
LERNA: "lerna.json"
|
|
47
34
|
};
|
|
48
|
-
const isLerna = (root) =>
|
|
35
|
+
const isLerna = (root) => _fs.default.existsSync(_path.default.join(root, WORKSPACE_FILES.LERNA));
|
|
49
36
|
const isYarnWorkspaces = (root) => {
|
|
50
|
-
var
|
|
51
|
-
const pkg =
|
|
52
|
-
if (!
|
|
37
|
+
var _json_workspaces;
|
|
38
|
+
const pkg = _path.default.join(root, WORKSPACE_FILES.YARN);
|
|
39
|
+
if (!_fs.default.existsSync(pkg)) {
|
|
53
40
|
return false;
|
|
54
41
|
}
|
|
55
|
-
const json = JSON.parse(
|
|
56
|
-
return Boolean((
|
|
42
|
+
const json = JSON.parse(_fs.default.readFileSync(pkg, "utf8"));
|
|
43
|
+
return Boolean((_json_workspaces = json.workspaces) === null || _json_workspaces === void 0 ? void 0 : _json_workspaces.packages);
|
|
57
44
|
};
|
|
58
|
-
const isPnpmWorkspaces = (root) =>
|
|
45
|
+
const isPnpmWorkspaces = (root) => _fs.default.existsSync(_path.default.join(root, WORKSPACE_FILES.PNPM));
|
|
59
46
|
const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
|
60
47
|
const isModernjsMonorepo = (root) => {
|
|
61
|
-
const pkgJsonPath =
|
|
62
|
-
if (!
|
|
48
|
+
const pkgJsonPath = _path.default.join(root, "package.json");
|
|
49
|
+
if (!_fs.default.existsSync(pkgJsonPath)) {
|
|
63
50
|
return false;
|
|
64
51
|
}
|
|
65
|
-
const json = JSON.parse(
|
|
52
|
+
const json = JSON.parse(_fs.default.readFileSync(pkgJsonPath, "utf8"));
|
|
66
53
|
const deps = {
|
|
67
54
|
...json.dependencies || {},
|
|
68
55
|
...json.devDependencies || {}
|
|
@@ -76,51 +63,33 @@ const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
|
|
76
63
|
inMonorepo = true;
|
|
77
64
|
break;
|
|
78
65
|
}
|
|
79
|
-
appDirectory =
|
|
66
|
+
appDirectory = _path.default.dirname(appDirectory);
|
|
80
67
|
}
|
|
81
68
|
return inMonorepo ? appDirectory : void 0;
|
|
82
69
|
};
|
|
83
70
|
const getMonorepoPackages = (root) => {
|
|
84
71
|
let packages = [];
|
|
85
72
|
if (isYarnWorkspaces(root)) {
|
|
86
|
-
const json = JSON.parse(
|
|
87
|
-
import_fs.default.readFileSync(import_path.default.join(root, "package.json"), "utf8")
|
|
88
|
-
);
|
|
73
|
+
const json = JSON.parse(_fs.default.readFileSync(_path.default.join(root, "package.json"), "utf8"));
|
|
89
74
|
({ packages } = json.workspaces);
|
|
90
75
|
} else if (isLerna(root)) {
|
|
91
|
-
const json = JSON.parse(
|
|
92
|
-
import_fs.default.readFileSync(import_path.default.resolve(root, "lerna.json"), "utf8")
|
|
93
|
-
);
|
|
76
|
+
const json = JSON.parse(_fs.default.readFileSync(_path.default.resolve(root, "lerna.json"), "utf8"));
|
|
94
77
|
({ packages } = json);
|
|
95
78
|
} else {
|
|
96
|
-
({ packages } =
|
|
97
|
-
import_fs.default.readFileSync(import_path.default.join(root, WORKSPACE_FILES.PNPM), "utf8")
|
|
98
|
-
));
|
|
79
|
+
({ packages } = _compiled.yaml.load(_fs.default.readFileSync(_path.default.join(root, WORKSPACE_FILES.PNPM), "utf8")));
|
|
99
80
|
}
|
|
100
81
|
if (packages) {
|
|
101
|
-
return packages.map(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
108
|
-
).reduce((acc, val) => acc.concat(val), []).filter((filepath) =>
|
|
82
|
+
return packages.map((name) => (
|
|
83
|
+
// The trailing / ensures only dirs are picked up
|
|
84
|
+
_compiled.glob.sync(_path.default.join(root, `${name}/`), {
|
|
85
|
+
ignore: [
|
|
86
|
+
"**/node_modules/**"
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
)).reduce((acc, val) => acc.concat(val), []).filter((filepath) => _fs.default.existsSync(_path.default.resolve(filepath, "package.json"))).map((filepath) => ({
|
|
109
90
|
path: filepath,
|
|
110
|
-
name: JSON.parse(
|
|
111
|
-
import_fs.default.readFileSync(import_path.default.resolve(filepath, "package.json"), "utf8")
|
|
112
|
-
).name
|
|
91
|
+
name: JSON.parse(_fs.default.readFileSync(_path.default.resolve(filepath, "package.json"), "utf8")).name
|
|
113
92
|
}));
|
|
114
93
|
}
|
|
115
94
|
return [];
|
|
116
95
|
};
|
|
117
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
118
|
-
0 && (module.exports = {
|
|
119
|
-
findMonorepoRoot,
|
|
120
|
-
getMonorepoPackages,
|
|
121
|
-
isLerna,
|
|
122
|
-
isModernjsMonorepo,
|
|
123
|
-
isMonorepo,
|
|
124
|
-
isPnpmWorkspaces,
|
|
125
|
-
isYarnWorkspaces
|
|
126
|
-
});
|
package/dist/cjs/nodeEnv.js
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
6
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var nodeEnv_exports = {};
|
|
19
|
-
__export(nodeEnv_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
20
13
|
canUseNpm: () => canUseNpm,
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
canUseYarn: () => canUseYarn,
|
|
15
|
+
canUsePnpm: () => canUsePnpm
|
|
23
16
|
});
|
|
24
|
-
|
|
25
|
-
var import_compiled = require("./compiled");
|
|
17
|
+
const _compiled = require("./compiled");
|
|
26
18
|
async function canUseNpm() {
|
|
27
19
|
try {
|
|
28
|
-
await (0,
|
|
20
|
+
await (0, _compiled.execa)("npm", [
|
|
21
|
+
"--version"
|
|
22
|
+
], {
|
|
23
|
+
env: process.env
|
|
24
|
+
});
|
|
29
25
|
return true;
|
|
30
26
|
} catch (e) {
|
|
31
27
|
return false;
|
|
@@ -33,7 +29,11 @@ async function canUseNpm() {
|
|
|
33
29
|
}
|
|
34
30
|
async function canUseYarn() {
|
|
35
31
|
try {
|
|
36
|
-
await (0,
|
|
32
|
+
await (0, _compiled.execa)("yarn", [
|
|
33
|
+
"--version"
|
|
34
|
+
], {
|
|
35
|
+
env: process.env
|
|
36
|
+
});
|
|
37
37
|
return true;
|
|
38
38
|
} catch (e) {
|
|
39
39
|
return false;
|
|
@@ -41,15 +41,13 @@ async function canUseYarn() {
|
|
|
41
41
|
}
|
|
42
42
|
async function canUsePnpm() {
|
|
43
43
|
try {
|
|
44
|
-
await (0,
|
|
44
|
+
await (0, _compiled.execa)("pnpm", [
|
|
45
|
+
"--version"
|
|
46
|
+
], {
|
|
47
|
+
env: process.env
|
|
48
|
+
});
|
|
45
49
|
return true;
|
|
46
50
|
} catch (e) {
|
|
47
51
|
return false;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
canUseNpm,
|
|
53
|
-
canUsePnpm,
|
|
54
|
-
canUseYarn
|
|
55
|
-
});
|
package/dist/cjs/path.js
CHANGED
|
@@ -1,75 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var path_exports = {};
|
|
29
|
-
__export(path_exports, {
|
|
30
|
-
_joinPathParts: () => _joinPathParts,
|
|
31
|
-
compilePathMatcherRegExp: () => compilePathMatcherRegExp,
|
|
32
|
-
getRealTemporaryDirectory: () => getRealTemporaryDirectory,
|
|
33
|
-
getTemplatePath: () => getTemplatePath,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
34
13
|
isPathString: () => isPathString,
|
|
35
14
|
isRelativePath: () => isRelativePath,
|
|
36
15
|
normalizeOutputPath: () => normalizeOutputPath,
|
|
37
16
|
normalizeToPosixPath: () => normalizeToPosixPath,
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
getTemplatePath: () => getTemplatePath,
|
|
18
|
+
compilePathMatcherRegExp: () => compilePathMatcherRegExp,
|
|
19
|
+
_joinPathParts: () => _joinPathParts,
|
|
20
|
+
upwardPaths: () => upwardPaths,
|
|
21
|
+
getRealTemporaryDirectory: () => getRealTemporaryDirectory,
|
|
22
|
+
splitPathString: () => splitPathString
|
|
40
23
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
25
|
+
const _os = /* @__PURE__ */ _interop_require_default(require("os"));
|
|
26
|
+
const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
|
|
27
|
+
const _compiled = require("./compiled");
|
|
28
|
+
function _interop_require_default(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const isPathString = (test) => _path.default.posix.basename(test) !== test || _path.default.win32.basename(test) !== test;
|
|
47
34
|
const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
|
48
35
|
const normalizeOutputPath = (s) => s.replace(/\\/g, "\\\\");
|
|
49
|
-
const normalizeToPosixPath = (p) =>
|
|
36
|
+
const normalizeToPosixPath = (p) => _compiled.upath.normalizeSafe(_path.default.normalize(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
|
|
50
37
|
const getTemplatePath = (prefix) => {
|
|
51
|
-
const tmpRoot =
|
|
52
|
-
const parts = [
|
|
38
|
+
const tmpRoot = _fs.default.realpathSync(_os.default.tmpdir());
|
|
39
|
+
const parts = [
|
|
40
|
+
tmpRoot
|
|
41
|
+
];
|
|
53
42
|
prefix && parts.push(prefix);
|
|
54
|
-
parts.push((0,
|
|
55
|
-
return
|
|
43
|
+
parts.push((0, _compiled.nanoid)());
|
|
44
|
+
return _path.default.resolve(...parts);
|
|
56
45
|
};
|
|
57
46
|
function compilePathMatcherRegExp(match) {
|
|
58
47
|
if (typeof match !== "string") {
|
|
59
48
|
return match;
|
|
60
49
|
}
|
|
61
|
-
const escaped =
|
|
50
|
+
const escaped = _compiled.lodash.escapeRegExp(match);
|
|
62
51
|
return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
|
|
63
52
|
}
|
|
64
|
-
const _joinPathParts = (_part, i, parts) => (0,
|
|
53
|
+
const _joinPathParts = (_part, i, parts) => (0, _compiled.lodash)(parts).filter((part) => ![
|
|
54
|
+
"/",
|
|
55
|
+
"\\"
|
|
56
|
+
].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
|
|
65
57
|
function upwardPaths(start) {
|
|
66
|
-
return (0,
|
|
58
|
+
return (0, _compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
|
|
67
59
|
}
|
|
68
60
|
function getRealTemporaryDirectory() {
|
|
69
61
|
let ret = null;
|
|
70
62
|
try {
|
|
71
|
-
ret =
|
|
72
|
-
ret =
|
|
63
|
+
ret = _os.default.tmpdir();
|
|
64
|
+
ret = _fs.default.realpathSync(ret);
|
|
73
65
|
} catch {
|
|
74
66
|
}
|
|
75
67
|
return ret;
|
|
@@ -77,16 +69,3 @@ function getRealTemporaryDirectory() {
|
|
|
77
69
|
function splitPathString(str) {
|
|
78
70
|
return str.split(/[\\/]/);
|
|
79
71
|
}
|
|
80
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
_joinPathParts,
|
|
83
|
-
compilePathMatcherRegExp,
|
|
84
|
-
getRealTemporaryDirectory,
|
|
85
|
-
getTemplatePath,
|
|
86
|
-
isPathString,
|
|
87
|
-
isRelativePath,
|
|
88
|
-
normalizeOutputPath,
|
|
89
|
-
normalizeToPosixPath,
|
|
90
|
-
splitPathString,
|
|
91
|
-
upwardPaths
|
|
92
|
-
});
|
|
@@ -1,50 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var pathSerializer_exports = {};
|
|
29
|
-
__export(pathSerializer_exports, {
|
|
30
|
-
applyMatcherReplacement: () => applyMatcherReplacement,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
matchUpwardPathsAsUnknown: () => matchUpwardPathsAsUnknown,
|
|
31
14
|
applyPathMatcher: () => applyPathMatcher,
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
applyMatcherReplacement: () => applyMatcherReplacement,
|
|
16
|
+
createDefaultPathMatchers: () => createDefaultPathMatchers
|
|
34
17
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
const _os = /* @__PURE__ */ _interop_require_default(require("os"));
|
|
19
|
+
const _lodash = /* @__PURE__ */ _interop_require_default(require("../compiled/lodash"));
|
|
20
|
+
const _path = require("./path");
|
|
21
|
+
function _interop_require_default(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const matchUpwardPathsAsUnknown = (p) => (0, _lodash.default)((0, _path.upwardPaths)((0, _path.normalizeToPosixPath)(p))).map((match) => ({
|
|
27
|
+
match,
|
|
28
|
+
mark: "unknown"
|
|
29
|
+
})).slice(1, -1).value();
|
|
40
30
|
function applyPathMatcher(matcher, str, options = {}) {
|
|
41
|
-
const regex = (0,
|
|
31
|
+
const regex = (0, _path.compilePathMatcherRegExp)(matcher.match);
|
|
42
32
|
const replacer = (substring, ...args) => {
|
|
43
|
-
if (options.minPartials && (0,
|
|
33
|
+
if (options.minPartials && (0, _path.splitPathString)(substring).length < options.minPartials) {
|
|
44
34
|
return substring;
|
|
45
35
|
}
|
|
46
36
|
const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
|
|
47
|
-
return `<${
|
|
37
|
+
return `<${_lodash.default.snakeCase(ret).toUpperCase()}>`;
|
|
48
38
|
};
|
|
49
39
|
return str.replace(regex, replacer);
|
|
50
40
|
}
|
|
@@ -56,21 +46,23 @@ function applyMatcherReplacement(matchers, str, options = {}) {
|
|
|
56
46
|
const createDefaultPathMatchers = (root) => {
|
|
57
47
|
const ret = [
|
|
58
48
|
{
|
|
59
|
-
match:
|
|
49
|
+
match: RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
|
|
60
50
|
mark: "pnpmInner"
|
|
61
51
|
}
|
|
62
52
|
];
|
|
63
|
-
const tmpdir = (0,
|
|
64
|
-
tmpdir && ret.push({
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
const tmpdir = (0, _path.getRealTemporaryDirectory)();
|
|
54
|
+
tmpdir && ret.push({
|
|
55
|
+
match: tmpdir,
|
|
56
|
+
mark: "temp"
|
|
57
|
+
});
|
|
58
|
+
ret.push({
|
|
59
|
+
match: _os.default.tmpdir(),
|
|
60
|
+
mark: "temp"
|
|
61
|
+
});
|
|
62
|
+
ret.push({
|
|
63
|
+
match: _os.default.homedir(),
|
|
64
|
+
mark: "home"
|
|
65
|
+
});
|
|
67
66
|
ret.push(...matchUpwardPathsAsUnknown(root));
|
|
68
67
|
return ret;
|
|
69
68
|
};
|
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
-
0 && (module.exports = {
|
|
72
|
-
applyMatcherReplacement,
|
|
73
|
-
applyPathMatcher,
|
|
74
|
-
createDefaultPathMatchers,
|
|
75
|
-
matchUpwardPathsAsUnknown
|
|
76
|
-
});
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var plugin_exports = {};
|
|
19
|
-
__export(plugin_exports, {
|
|
20
|
-
getInternalPlugins: () => getInternalPlugins
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
21
4
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
Object.defineProperty(exports, "getInternalPlugins", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => getInternalPlugins
|
|
8
|
+
});
|
|
9
|
+
const _constants = require("./constants");
|
|
10
|
+
const _is = require("./is");
|
|
11
|
+
function getInternalPlugins(appDirectory, internalPlugins = _constants.INTERNAL_CLI_PLUGINS) {
|
|
26
12
|
return [
|
|
27
13
|
...Object.keys(internalPlugins).filter((name) => {
|
|
28
14
|
const config = internalPlugins[name];
|
|
29
15
|
if (typeof config !== "string" && config.forced === true) {
|
|
30
16
|
return true;
|
|
31
17
|
}
|
|
32
|
-
return (0,
|
|
18
|
+
return (0, _is.isDepExists)(appDirectory, name);
|
|
33
19
|
}).map((name) => {
|
|
34
20
|
const config = internalPlugins[name];
|
|
35
21
|
if (typeof config !== "string") {
|
|
@@ -40,7 +26,3 @@ function getInternalPlugins(appDirectory, internalPlugins = import_constants.INT
|
|
|
40
26
|
})
|
|
41
27
|
];
|
|
42
28
|
}
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
getInternalPlugins
|
|
46
|
-
});
|