@modern-js/utils 2.11.0 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +12 -0
- package/dist/commands.d.ts +1 -0
- package/dist/commands.js +7 -2
- package/dist/prettyInstructions.d.ts +4 -3
- package/dist/prettyInstructions.js +13 -16
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 2.12.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- c2ca6c8: fix(app-tools): failed to restart CLI
|
8
|
+
|
9
|
+
fix(app-tools): 修复 CLI 重启失败的问题
|
10
|
+
|
11
|
+
- 6d86e34: feat(doc-tools): print dev server URLs with base
|
12
|
+
|
13
|
+
feat(doc-tools): 输出 dev server 的 URLs 时补全 base 信息
|
14
|
+
|
3
15
|
## 2.11.0
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/commands.d.ts
CHANGED
package/dist/commands.js
CHANGED
@@ -19,12 +19,16 @@ var commands_exports = {};
|
|
19
19
|
__export(commands_exports, {
|
20
20
|
getArgv: () => getArgv,
|
21
21
|
getCommand: () => getCommand,
|
22
|
+
getFullArgv: () => getFullArgv,
|
22
23
|
isDevCommand: () => isDevCommand
|
23
24
|
});
|
24
25
|
module.exports = __toCommonJS(commands_exports);
|
25
|
-
const
|
26
|
+
const getFullArgv = () => {
|
26
27
|
var _a;
|
27
|
-
return ((
|
28
|
+
return ((_a = process.env.MODERN_ARGV) == null ? void 0 : _a.split(" ")) || process.argv;
|
29
|
+
};
|
30
|
+
const getArgv = () => {
|
31
|
+
return getFullArgv().slice(2);
|
28
32
|
};
|
29
33
|
const getCommand = () => {
|
30
34
|
const args = getArgv();
|
@@ -39,5 +43,6 @@ const isDevCommand = () => {
|
|
39
43
|
0 && (module.exports = {
|
40
44
|
getArgv,
|
41
45
|
getCommand,
|
46
|
+
getFullArgv,
|
42
47
|
isDevCommand
|
43
48
|
});
|
@@ -1,8 +1,9 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import os from 'os';
|
3
3
|
export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
|
4
|
-
export
|
5
|
-
|
4
|
+
export type AddressUrl = {
|
5
|
+
label: string;
|
6
6
|
url: string;
|
7
|
-
}
|
7
|
+
};
|
8
|
+
export declare const getAddressUrls: (protocol: string | undefined, port: number) => AddressUrl[];
|
8
9
|
export declare const prettyInstructions: (appContext: any, config: any) => string;
|
@@ -51,19 +51,16 @@ const getIpv4Interfaces = () => {
|
|
51
51
|
};
|
52
52
|
const getAddressUrls = (protocol = "http", port) => {
|
53
53
|
const ipv4Interfaces = getIpv4Interfaces();
|
54
|
-
return ipv4Interfaces.reduce(
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
},
|
65
|
-
[]
|
66
|
-
);
|
54
|
+
return ipv4Interfaces.reduce((memo, detail) => {
|
55
|
+
let label = "Network: ";
|
56
|
+
let url = `${protocol}://${detail.address}:${port}`;
|
57
|
+
if (detail.address.includes(`localhost`) || detail.internal) {
|
58
|
+
label = "Local: ";
|
59
|
+
url = `${protocol}://localhost:${port}`;
|
60
|
+
}
|
61
|
+
memo.push({ label, url });
|
62
|
+
return memo;
|
63
|
+
}, []);
|
67
64
|
};
|
68
65
|
const prettyInstructions = (appContext, config) => {
|
69
66
|
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
@@ -75,15 +72,15 @@ const prettyInstructions = (appContext, config) => {
|
|
75
72
|
let message = "App running at:\n\n";
|
76
73
|
if ((0, import_is.isSingleEntry)(entrypoints) || apiOnly) {
|
77
74
|
message += urls.map(
|
78
|
-
({
|
75
|
+
({ label, url }) => ` ${import_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
|
79
76
|
normalizeUrl(`${url}/${routes[0].urlPath}`)
|
80
77
|
)}
|
81
78
|
`
|
82
79
|
).join("");
|
83
80
|
} else {
|
84
81
|
const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
|
85
|
-
urls.forEach(({
|
86
|
-
message += ` ${import_compiled.chalk.bold(`> ${
|
82
|
+
urls.forEach(({ label, url }) => {
|
83
|
+
message += ` ${import_compiled.chalk.bold(`> ${label}`)}
|
87
84
|
`;
|
88
85
|
routes.forEach(({ entryName, urlPath, isSSR }) => {
|
89
86
|
if (!checkedEntries.includes(entryName)) {
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
14
|
+
"version": "2.12.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
@@ -175,9 +175,9 @@
|
|
175
175
|
"typescript": "^4",
|
176
176
|
"webpack": "^5.76.2",
|
177
177
|
"@types/serialize-javascript": "^5.0.1",
|
178
|
-
"@modern-js/types": "2.
|
179
|
-
"@scripts/build": "2.
|
180
|
-
"@scripts/jest-config": "2.
|
178
|
+
"@modern-js/types": "2.12.0",
|
179
|
+
"@scripts/build": "2.12.0",
|
180
|
+
"@scripts/jest-config": "2.12.0"
|
181
181
|
},
|
182
182
|
"sideEffects": false,
|
183
183
|
"scripts": {
|