@modern-js/utils 0.0.0-next-8a882ed80 → 0.0.0-next-c835d71
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 +8 -1
- package/dist/analyzeProject.d.ts +2 -1
- package/dist/analyzeProject.js +8 -2
- package/dist/is/index.d.ts +6 -0
- package/dist/is/index.js +10 -0
- package/dist/prettyInstructions.d.ts +1 -6
- package/dist/prettyInstructions.js +1 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# @modern-js/utils
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-c835d71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1104a9f18b: feat: support start web service only
|
|
8
|
+
feat: 支持只启动 web 服务
|
|
9
|
+
- c835d714bc: fix: nested routes in ssg
|
|
10
|
+
fix: 修复嵌套路由在 SSG 中的问题
|
|
4
11
|
|
|
5
12
|
## 2.7.0
|
|
6
13
|
|
package/dist/analyzeProject.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const isApiOnly: (appDirectory: string, entryDir?: string) => Promise<boolean>;
|
|
1
|
+
export declare const isApiOnly: (appDirectory: string, entryDir?: string) => Promise<boolean>;
|
|
2
|
+
export declare const isWebOnly: () => Promise<boolean>;
|
package/dist/analyzeProject.js
CHANGED
|
@@ -47,7 +47,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
47
47
|
};
|
|
48
48
|
var analyzeProject_exports = {};
|
|
49
49
|
__export(analyzeProject_exports, {
|
|
50
|
-
isApiOnly: () => isApiOnly
|
|
50
|
+
isApiOnly: () => isApiOnly,
|
|
51
|
+
isWebOnly: () => isWebOnly
|
|
51
52
|
});
|
|
52
53
|
module.exports = __toCommonJS(analyzeProject_exports);
|
|
53
54
|
var path = __toESM(require("path"));
|
|
@@ -58,7 +59,12 @@ const isApiOnly = (appDirectory, entryDir) => __async(void 0, null, function* ()
|
|
|
58
59
|
const options = (0, import_compiled.minimist)(process.argv.slice(2));
|
|
59
60
|
return !existSrc || Boolean(options["api-only"]);
|
|
60
61
|
});
|
|
62
|
+
const isWebOnly = () => __async(void 0, null, function* () {
|
|
63
|
+
const options = (0, import_compiled.minimist)(process.argv.slice(2));
|
|
64
|
+
return Boolean(options["web-only"]);
|
|
65
|
+
});
|
|
61
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
62
67
|
0 && (module.exports = {
|
|
63
|
-
isApiOnly
|
|
68
|
+
isApiOnly,
|
|
69
|
+
isWebOnly
|
|
64
70
|
});
|
package/dist/is/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
interface EntryPoint {
|
|
2
|
+
entryName: string;
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* Check if the package name is in dependencies or devDependencies.
|
|
3
6
|
*
|
|
@@ -5,6 +8,7 @@
|
|
|
5
8
|
* @param name - Package name.
|
|
6
9
|
* @returns True if the name is in dependencies or devDependencies, false otherwise.
|
|
7
10
|
*/
|
|
11
|
+
|
|
8
12
|
export declare const isDepExists: (appDirectory: string, name: string) => boolean;
|
|
9
13
|
/**
|
|
10
14
|
* Is typescript project.
|
|
@@ -47,6 +51,8 @@ export declare const isRouterV5: (config: {
|
|
|
47
51
|
} | boolean;
|
|
48
52
|
};
|
|
49
53
|
}) => boolean;
|
|
54
|
+
export declare const isSSGEntry: (config: any, entryName: string, entrypoints: EntryPoint[]) => boolean;
|
|
55
|
+
export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
|
|
50
56
|
export * from './nodeEnv';
|
|
51
57
|
export * from './platform';
|
|
52
58
|
export * from './type';
|
package/dist/is/index.js
CHANGED
|
@@ -32,8 +32,10 @@ __export(is_exports, {
|
|
|
32
32
|
isEmpty: () => isEmpty,
|
|
33
33
|
isFastRefresh: () => isFastRefresh,
|
|
34
34
|
isRouterV5: () => isRouterV5,
|
|
35
|
+
isSSGEntry: () => isSSGEntry,
|
|
35
36
|
isSSR: () => isSSR,
|
|
36
37
|
isServiceWorker: () => isServiceWorker,
|
|
38
|
+
isSingleEntry: () => isSingleEntry,
|
|
37
39
|
isTypescript: () => isTypescript,
|
|
38
40
|
isUseSSRBundle: () => isUseSSRBundle
|
|
39
41
|
});
|
|
@@ -91,14 +93,22 @@ const isRouterV5 = (config) => {
|
|
|
91
93
|
var _a, _b, _c;
|
|
92
94
|
return typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
|
|
93
95
|
};
|
|
96
|
+
const isSSGEntry = (config, entryName, entrypoints) => {
|
|
97
|
+
const ssgConfig = config.output.ssg;
|
|
98
|
+
const useSSG = isSingleEntry(entrypoints) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig == null ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig == null ? void 0 : ssgConfig[entryName]);
|
|
99
|
+
return useSSG;
|
|
100
|
+
};
|
|
101
|
+
const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
|
|
94
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
103
|
0 && (module.exports = {
|
|
96
104
|
isDepExists,
|
|
97
105
|
isEmpty,
|
|
98
106
|
isFastRefresh,
|
|
99
107
|
isRouterV5,
|
|
108
|
+
isSSGEntry,
|
|
100
109
|
isSSR,
|
|
101
110
|
isServiceWorker,
|
|
111
|
+
isSingleEntry,
|
|
102
112
|
isTypescript,
|
|
103
113
|
isUseSSRBundle
|
|
104
114
|
});
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import os from 'os';
|
|
3
|
-
interface EntryPoint {
|
|
4
|
-
entryName: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
|
|
7
3
|
export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
|
|
8
4
|
export declare const getAddressUrls: (protocol: string | undefined, port: number) => {
|
|
9
5
|
type: string;
|
|
10
6
|
url: string;
|
|
11
7
|
}[];
|
|
12
|
-
export declare const prettyInstructions: (appContext: any, config: any) => string;
|
|
13
|
-
export {};
|
|
8
|
+
export declare const prettyInstructions: (appContext: any, config: any) => string;
|
|
@@ -29,14 +29,12 @@ var prettyInstructions_exports = {};
|
|
|
29
29
|
__export(prettyInstructions_exports, {
|
|
30
30
|
getAddressUrls: () => getAddressUrls,
|
|
31
31
|
getIpv4Interfaces: () => getIpv4Interfaces,
|
|
32
|
-
isSingleEntry: () => isSingleEntry,
|
|
33
32
|
prettyInstructions: () => prettyInstructions
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(prettyInstructions_exports);
|
|
36
35
|
var import_os = __toESM(require("os"));
|
|
37
36
|
var import_compiled = require("./compiled");
|
|
38
37
|
var import_is = require("./is");
|
|
39
|
-
const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
|
|
40
38
|
const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
|
41
39
|
const getIpv4Interfaces = () => {
|
|
42
40
|
const interfaces = import_os.default.networkInterfaces();
|
|
@@ -75,7 +73,7 @@ const prettyInstructions = (appContext, config) => {
|
|
|
75
73
|
);
|
|
76
74
|
const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
|
|
77
75
|
let message = "App running at:\n\n";
|
|
78
|
-
if (isSingleEntry(entrypoints) || apiOnly) {
|
|
76
|
+
if ((0, import_is.isSingleEntry)(entrypoints) || apiOnly) {
|
|
79
77
|
message += urls.map(
|
|
80
78
|
({ type, url }) => ` ${import_compiled.chalk.bold(`> ${type.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
|
|
81
79
|
normalizeUrl(`${url}/${routes[0].urlPath}`)
|
|
@@ -113,6 +111,5 @@ const prettyInstructions = (appContext, config) => {
|
|
|
113
111
|
0 && (module.exports = {
|
|
114
112
|
getAddressUrls,
|
|
115
113
|
getIpv4Interfaces,
|
|
116
|
-
isSingleEntry,
|
|
117
114
|
prettyInstructions
|
|
118
115
|
});
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.0-next-
|
|
14
|
+
"version": "0.0.0-next-c835d71",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"main": "./dist/index.js",
|
|
@@ -167,9 +167,9 @@
|
|
|
167
167
|
"typescript": "^4",
|
|
168
168
|
"webpack": "^5.75.0",
|
|
169
169
|
"@types/serialize-javascript": "^5.0.1",
|
|
170
|
-
"@modern-js/types": "0.0.0-next-
|
|
171
|
-
"@scripts/build": "0.0.0-next-
|
|
172
|
-
"@scripts/jest-config": "0.0.0-next-
|
|
170
|
+
"@modern-js/types": "0.0.0-next-c835d71",
|
|
171
|
+
"@scripts/build": "0.0.0-next-c835d71",
|
|
172
|
+
"@scripts/jest-config": "0.0.0-next-c835d71"
|
|
173
173
|
},
|
|
174
174
|
"sideEffects": false,
|
|
175
175
|
"scripts": {
|