@modern-js/utils 2.65.3 → 2.65.5
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 +27 -25
- package/dist/compiled/ajv/codegen.js +1 -0
- package/dist/compiled/ajv/index.js +9 -0
- package/dist/compiled/ajv/license +22 -0
- package/dist/compiled/ajv/package.json +1 -0
- package/dist/compiled/ajv/types/ajv.d.ts +16 -0
- package/dist/compiled/ajv/types/compile/codegen/code.d.ts +40 -0
- package/dist/compiled/ajv/types/compile/codegen/index.d.ts +79 -0
- package/dist/compiled/ajv/types/compile/codegen/scope.d.ts +79 -0
- package/dist/compiled/ajv/types/compile/errors.d.ts +13 -0
- package/dist/compiled/ajv/types/compile/index.d.ts +80 -0
- package/dist/compiled/ajv/types/compile/ref_error.d.ts +6 -0
- package/dist/compiled/ajv/types/compile/resolve.d.ts +12 -0
- package/dist/compiled/ajv/types/compile/rules.d.ts +28 -0
- package/dist/compiled/ajv/types/compile/util.d.ts +40 -0
- package/dist/compiled/ajv/types/compile/validate/index.d.ts +42 -0
- package/dist/compiled/ajv/types/compile/validate/subschema.d.ts +47 -0
- package/dist/compiled/ajv/types/core.d.ts +173 -0
- package/dist/compiled/ajv/types/runtime/validation_error.d.ts +7 -0
- package/dist/compiled/ajv/types/types/index.d.ts +183 -0
- package/dist/compiled/ajv/types/types/json-schema.d.ts +124 -0
- package/dist/compiled/ajv/types/types/jtd-schema.d.ts +169 -0
- package/dist/compiled/ajv/types/vocabularies/errors.d.ts +1 -0
- package/dist/compiled/ajv/uri-js.d.ts +59 -0
- package/dist/compiled/ajv-keywords/index.d.ts +1 -0
- package/dist/compiled/ajv-keywords/index.js +1 -0
- package/dist/compiled/ajv-keywords/license +21 -0
- package/dist/compiled/ajv-keywords/package.json +1 -0
- package/dist/compiled/better-ajv-errors/index.d.ts +1 -0
- package/dist/compiled/better-ajv-errors/index.js +1 -0
- package/dist/compiled/better-ajv-errors/license +13 -0
- package/dist/compiled/better-ajv-errors/package.json +1 -0
- package/dist/compiled/recursive-readdir/index.d.ts +21 -0
- package/dist/compiled/recursive-readdir/index.js +1 -0
- package/dist/compiled/recursive-readdir/license +21 -0
- package/dist/compiled/recursive-readdir/package.json +1 -0
- package/dist/compiled/schema-utils3/index.d.ts +1 -0
- package/dist/compiled/schema-utils3/index.js +3 -0
- package/dist/compiled/schema-utils3/license +20 -0
- package/dist/compiled/schema-utils3/package.json +1 -0
- package/dist/compiled/webpack-dev-middleware/index.js +7 -0
- package/dist/compiled/webpack-dev-middleware/license +20 -0
- package/dist/compiled/webpack-dev-middleware/package.json +1 -0
- package/dist/compiled/webpack-dev-middleware/types/index.d.ts +262 -0
- package/dist/esm/cli/is/project.js +26 -19
- package/dist/esm-node/cli/is/project.js +26 -25
- package/dist/types/cli/is/project.d.ts +1 -0
- package/package.json +5 -6
@@ -41,7 +41,7 @@ const isWebOnly = async () => {
|
|
41
41
|
const isVersionBeyond17 = (version) => {
|
42
42
|
return semver.gte(semver.minVersion(version), "17.0.0");
|
43
43
|
};
|
44
|
-
const
|
44
|
+
const getReactVersion = (cwd) => {
|
45
45
|
const pkgPath = pkgUp.sync({
|
46
46
|
cwd
|
47
47
|
});
|
@@ -56,42 +56,43 @@ const isBeyondReact17 = (cwd) => {
|
|
56
56
|
if (typeof deps.react !== "string") {
|
57
57
|
return false;
|
58
58
|
}
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
try {
|
60
|
+
const reactPath = require.resolve("react/package.json", {
|
61
|
+
paths: [
|
62
|
+
cwd
|
63
|
+
]
|
64
|
+
});
|
65
|
+
const reactVersion = JSON.parse(fs.readFileSync(reactPath, "utf8")).version;
|
66
|
+
return reactVersion;
|
67
|
+
} catch (error) {
|
68
|
+
console.error("Failed to resolve React version:", error);
|
66
69
|
return false;
|
67
70
|
}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
};
|
73
|
-
if (typeof deps.react !== "string") {
|
71
|
+
};
|
72
|
+
const isBeyondReact17 = (cwd) => {
|
73
|
+
const reactVersion = getReactVersion(cwd);
|
74
|
+
if (!reactVersion) {
|
74
75
|
return false;
|
75
76
|
}
|
76
|
-
return
|
77
|
+
return isVersionBeyond17(reactVersion);
|
77
78
|
};
|
78
|
-
const
|
79
|
-
const
|
80
|
-
if (!
|
79
|
+
const isSupportAutomaticJsx = (cwd) => {
|
80
|
+
const reactVersion = getReactVersion(cwd);
|
81
|
+
if (!reactVersion) {
|
81
82
|
return false;
|
82
83
|
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
if (typeof deps.react !== "string") {
|
84
|
+
return semver.satisfies(semver.minVersion(reactVersion), ">=16.14.0");
|
85
|
+
};
|
86
|
+
const isReact18 = (cwd = process.cwd()) => {
|
87
|
+
const reactVersion = getReactVersion(cwd);
|
88
|
+
if (!reactVersion) {
|
89
89
|
return false;
|
90
90
|
}
|
91
|
-
return semver.gte(semver.minVersion(
|
91
|
+
return semver.gte(semver.minVersion(reactVersion), "18.0.0");
|
92
92
|
};
|
93
93
|
const isTypescript = (root) => fs.existsSync(path.resolve(root, "./tsconfig.json"));
|
94
94
|
export {
|
95
|
+
getReactVersion,
|
95
96
|
isApiOnly,
|
96
97
|
isBeyondReact17,
|
97
98
|
isDepExists,
|
@@ -23,6 +23,7 @@ export declare const isPackageInstalled: (name: string, resolvePaths: string | s
|
|
23
23
|
export declare const isApiOnly: (appDirectory: string, entryDir?: string, apiDir?: string) => Promise<boolean>;
|
24
24
|
export declare const isWebOnly: () => Promise<boolean>;
|
25
25
|
export declare const isVersionBeyond17: (version: string) => boolean;
|
26
|
+
export declare const getReactVersion: (cwd: string) => string | false;
|
26
27
|
/**
|
27
28
|
* @deprecated Use {@link isSupportAutomaticJsx} to check if the project supports automatic JSX instead.
|
28
29
|
*/
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.65.
|
18
|
+
"version": "2.65.5",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -103,8 +103,7 @@
|
|
103
103
|
},
|
104
104
|
"publishConfig": {
|
105
105
|
"registry": "https://registry.npmjs.org/",
|
106
|
-
"access": "public"
|
107
|
-
"provenance": true
|
106
|
+
"access": "public"
|
108
107
|
},
|
109
108
|
"typesVersions": {
|
110
109
|
"*": {
|
@@ -191,9 +190,9 @@
|
|
191
190
|
"jest": "^29",
|
192
191
|
"typescript": "^5",
|
193
192
|
"webpack": "^5.98.0",
|
194
|
-
"@
|
195
|
-
"@
|
196
|
-
"@scripts/
|
193
|
+
"@scripts/build": "2.65.5",
|
194
|
+
"@modern-js/types": "2.65.5",
|
195
|
+
"@scripts/jest-config": "2.65.5"
|
197
196
|
},
|
198
197
|
"sideEffects": false,
|
199
198
|
"scripts": {
|