@modern-js/utils 2.63.1 → 2.63.2
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/is/project.js +19 -0
- package/dist/cjs/cli/prettyInstructions.js +5 -1
- package/dist/esm/cli/is/project.js +15 -0
- package/dist/esm/cli/prettyInstructions.js +4 -1
- package/dist/esm-node/cli/is/project.js +18 -0
- package/dist/esm-node/cli/prettyInstructions.js +5 -1
- package/dist/types/cli/is/project.d.ts +4 -0
- package/package.json +5 -5
@@ -33,6 +33,7 @@ __export(project_exports, {
|
|
33
33
|
isDepExists: () => isDepExists,
|
34
34
|
isPackageInstalled: () => isPackageInstalled,
|
35
35
|
isReact18: () => isReact18,
|
36
|
+
isSupportAutomaticJsx: () => isSupportAutomaticJsx,
|
36
37
|
isTypescript: () => isTypescript,
|
37
38
|
isWebOnly: () => isWebOnly
|
38
39
|
});
|
@@ -94,6 +95,23 @@ const isBeyondReact17 = (cwd) => {
|
|
94
95
|
}
|
95
96
|
return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=17.0.0");
|
96
97
|
};
|
98
|
+
const isSupportAutomaticJsx = (cwd) => {
|
99
|
+
const pkgPath = import_pkg_up.default.sync({
|
100
|
+
cwd
|
101
|
+
});
|
102
|
+
if (!pkgPath) {
|
103
|
+
return false;
|
104
|
+
}
|
105
|
+
const pkgInfo = JSON.parse(import_compiled.fs.readFileSync(pkgPath, "utf8"));
|
106
|
+
const deps = {
|
107
|
+
...pkgInfo.devDependencies,
|
108
|
+
...pkgInfo.dependencies
|
109
|
+
};
|
110
|
+
if (typeof deps.react !== "string") {
|
111
|
+
return false;
|
112
|
+
}
|
113
|
+
return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=16.14.0");
|
114
|
+
};
|
97
115
|
const isReact18 = (cwd = process.cwd()) => {
|
98
116
|
const pkgPath = import_path.default.join(cwd, "package.json");
|
99
117
|
if (!import_compiled.fs.existsSync(pkgPath)) {
|
@@ -117,6 +135,7 @@ const isTypescript = (root) => import_compiled.fs.existsSync(import_path.default
|
|
117
135
|
isDepExists,
|
118
136
|
isPackageInstalled,
|
119
137
|
isReact18,
|
138
|
+
isSupportAutomaticJsx,
|
120
139
|
isTypescript,
|
121
140
|
isWebOnly
|
122
141
|
});
|
@@ -86,7 +86,7 @@ const getAddressUrls = (protocol = "http", port, host) => {
|
|
86
86
|
}, []);
|
87
87
|
};
|
88
88
|
const prettyInstructions = (appContext, config) => {
|
89
|
-
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
|
89
|
+
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source, _config_dev1;
|
90
90
|
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
91
91
|
const isHttps = (0, import_is.isDev)() && ((_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : (_appContext_builder_context_devServer = _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
|
92
92
|
const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
|
@@ -112,6 +112,10 @@ const prettyInstructions = (appContext, config) => {
|
|
112
112
|
message += import_compiled.chalk.cyanBright(" λ (Server) server-side renders at runtime\n");
|
113
113
|
message += import_compiled.chalk.cyanBright(" ○ (Static) client-side renders as static HTML\n");
|
114
114
|
}
|
115
|
+
if ((_config_dev1 = config.dev) === null || _config_dev1 === void 0 ? void 0 : _config_dev1.cliShortcuts) {
|
116
|
+
message += ` ${import_compiled.chalk.dim("> press")} ${import_compiled.chalk.bold("h + enter")} ${import_compiled.chalk.dim("to show shortcuts")}
|
117
|
+
`;
|
118
|
+
}
|
115
119
|
return message;
|
116
120
|
};
|
117
121
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -93,6 +93,20 @@ var isBeyondReact17 = function(cwd) {
|
|
93
93
|
}
|
94
94
|
return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
|
95
95
|
};
|
96
|
+
var isSupportAutomaticJsx = function(cwd) {
|
97
|
+
var pkgPath = pkgUp.sync({
|
98
|
+
cwd
|
99
|
+
});
|
100
|
+
if (!pkgPath) {
|
101
|
+
return false;
|
102
|
+
}
|
103
|
+
var pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
104
|
+
var deps = _object_spread({}, pkgInfo.devDependencies, pkgInfo.dependencies);
|
105
|
+
if (typeof deps.react !== "string") {
|
106
|
+
return false;
|
107
|
+
}
|
108
|
+
return semver.satisfies(semver.minVersion(deps.react), ">=16.14.0");
|
109
|
+
};
|
96
110
|
var isReact18 = function() {
|
97
111
|
var cwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd();
|
98
112
|
var pkgPath = path.join(cwd, "package.json");
|
@@ -115,6 +129,7 @@ export {
|
|
115
129
|
isDepExists,
|
116
130
|
isPackageInstalled,
|
117
131
|
isReact18,
|
132
|
+
isSupportAutomaticJsx,
|
118
133
|
isTypescript,
|
119
134
|
isWebOnly
|
120
135
|
};
|
@@ -58,7 +58,7 @@ var getAddressUrls = function() {
|
|
58
58
|
}, []);
|
59
59
|
};
|
60
60
|
var prettyInstructions = function(appContext, config) {
|
61
|
-
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
|
61
|
+
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source, _config_dev1;
|
62
62
|
var entrypoints = appContext.entrypoints, serverRoutes = appContext.serverRoutes, port = appContext.port, apiOnly = appContext.apiOnly, checkedEntries = appContext.checkedEntries;
|
63
63
|
var isHttps = isDev() && ((_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : (_appContext_builder_context_devServer = _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
|
64
64
|
var urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
|
@@ -91,6 +91,9 @@ var prettyInstructions = function(appContext, config) {
|
|
91
91
|
message += chalk.cyanBright(" λ (Server) server-side renders at runtime\n");
|
92
92
|
message += chalk.cyanBright(" ○ (Static) client-side renders as static HTML\n");
|
93
93
|
}
|
94
|
+
if ((_config_dev1 = config.dev) === null || _config_dev1 === void 0 ? void 0 : _config_dev1.cliShortcuts) {
|
95
|
+
message += " ".concat(chalk.dim("> press"), " ").concat(chalk.bold("h + enter"), " ").concat(chalk.dim("to show shortcuts"), "\n");
|
96
|
+
}
|
94
97
|
return message;
|
95
98
|
};
|
96
99
|
export {
|
@@ -55,6 +55,23 @@ const isBeyondReact17 = (cwd) => {
|
|
55
55
|
}
|
56
56
|
return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
|
57
57
|
};
|
58
|
+
const isSupportAutomaticJsx = (cwd) => {
|
59
|
+
const pkgPath = pkgUp.sync({
|
60
|
+
cwd
|
61
|
+
});
|
62
|
+
if (!pkgPath) {
|
63
|
+
return false;
|
64
|
+
}
|
65
|
+
const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
66
|
+
const deps = {
|
67
|
+
...pkgInfo.devDependencies,
|
68
|
+
...pkgInfo.dependencies
|
69
|
+
};
|
70
|
+
if (typeof deps.react !== "string") {
|
71
|
+
return false;
|
72
|
+
}
|
73
|
+
return semver.satisfies(semver.minVersion(deps.react), ">=16.14.0");
|
74
|
+
};
|
58
75
|
const isReact18 = (cwd = process.cwd()) => {
|
59
76
|
const pkgPath = path.join(cwd, "package.json");
|
60
77
|
if (!fs.existsSync(pkgPath)) {
|
@@ -77,6 +94,7 @@ export {
|
|
77
94
|
isDepExists,
|
78
95
|
isPackageInstalled,
|
79
96
|
isReact18,
|
97
|
+
isSupportAutomaticJsx,
|
80
98
|
isTypescript,
|
81
99
|
isWebOnly
|
82
100
|
};
|
@@ -52,7 +52,7 @@ const getAddressUrls = (protocol = "http", port, host) => {
|
|
52
52
|
}, []);
|
53
53
|
};
|
54
54
|
const prettyInstructions = (appContext, config) => {
|
55
|
-
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
|
55
|
+
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source, _config_dev1;
|
56
56
|
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
57
57
|
const isHttps = isDev() && ((_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : (_appContext_builder_context_devServer = _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
|
58
58
|
const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
|
@@ -78,6 +78,10 @@ const prettyInstructions = (appContext, config) => {
|
|
78
78
|
message += chalk.cyanBright(" λ (Server) server-side renders at runtime\n");
|
79
79
|
message += chalk.cyanBright(" ○ (Static) client-side renders as static HTML\n");
|
80
80
|
}
|
81
|
+
if ((_config_dev1 = config.dev) === null || _config_dev1 === void 0 ? void 0 : _config_dev1.cliShortcuts) {
|
82
|
+
message += ` ${chalk.dim("> press")} ${chalk.bold("h + enter")} ${chalk.dim("to show shortcuts")}
|
83
|
+
`;
|
84
|
+
}
|
81
85
|
return message;
|
82
86
|
};
|
83
87
|
export {
|
@@ -22,7 +22,11 @@ export declare const isPackageInstalled: (name: string, resolvePaths: string | s
|
|
22
22
|
*/
|
23
23
|
export declare const isApiOnly: (appDirectory: string, entryDir?: string, apiDir?: string) => Promise<boolean>;
|
24
24
|
export declare const isWebOnly: () => Promise<boolean>;
|
25
|
+
/**
|
26
|
+
* @deprecated Use {@link isSupportAutomaticJsx} to check if the project supports automatic JSX instead.
|
27
|
+
*/
|
25
28
|
export declare const isBeyondReact17: (cwd: string) => boolean;
|
29
|
+
export declare const isSupportAutomaticJsx: (cwd: string) => boolean;
|
26
30
|
export declare const isReact18: (cwd?: string) => boolean;
|
27
31
|
/**
|
28
32
|
* Is typescript project.
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.63.
|
18
|
+
"version": "2.63.2",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -161,10 +161,10 @@
|
|
161
161
|
"@types/node": "^14",
|
162
162
|
"jest": "^29",
|
163
163
|
"typescript": "^5",
|
164
|
-
"webpack": "^5.
|
165
|
-
"@modern-js/types": "2.63.
|
166
|
-
"@scripts/
|
167
|
-
"@scripts/
|
164
|
+
"webpack": "^5.97.1",
|
165
|
+
"@modern-js/types": "2.63.2",
|
166
|
+
"@scripts/jest-config": "2.63.2",
|
167
|
+
"@scripts/build": "2.63.2"
|
168
168
|
},
|
169
169
|
"sideEffects": false,
|
170
170
|
"scripts": {
|