@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 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
@@ -1,3 +1,4 @@
1
+ export declare const getFullArgv: () => string[];
1
2
  export declare const getArgv: () => string[];
2
3
  export declare const getCommand: () => string;
3
4
  export declare const isDevCommand: () => boolean;
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 getArgv = () => {
26
+ const getFullArgv = () => {
26
27
  var _a;
27
- return (((_a = process.env.MODERN_ARGV) == null ? void 0 : _a.split(" ")) || process.argv).slice(2);
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 declare const getAddressUrls: (protocol: string | undefined, port: number) => {
5
- type: string;
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
- (memo, detail) => {
56
- let type = "Network: ";
57
- let url = `${protocol}://${detail.address}:${port}`;
58
- if (detail.address.includes(`localhost`) || detail.internal) {
59
- type = "Local: ";
60
- url = `${protocol}://localhost:${port}`;
61
- }
62
- memo.push({ type, url });
63
- return memo;
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
- ({ type, url }) => ` ${import_compiled.chalk.bold(`> ${type.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
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(({ type, url }) => {
86
- message += ` ${import_compiled.chalk.bold(`> ${type}`)}
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.11.0",
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.11.0",
179
- "@scripts/build": "2.11.0",
180
- "@scripts/jest-config": "2.11.0"
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": {