@oxog/react-check 1.2.0 → 1.3.1
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 +129 -0
- package/README.md +177 -62
- package/dist/browser-inject.global.js +13 -13
- package/dist/chain.cjs +8 -531
- package/dist/chain.cjs.map +1 -1
- package/dist/chain.d.cts +2 -2
- package/dist/chain.d.ts +2 -2
- package/dist/chain.js +2 -533
- package/dist/chain.js.map +1 -1
- package/dist/chunk-35I3PLS3.js +751 -0
- package/dist/chunk-35I3PLS3.js.map +1 -0
- package/dist/chunk-7R4KKJTW.cjs +255 -0
- package/dist/chunk-7R4KKJTW.cjs.map +1 -0
- package/dist/chunk-DSXOHC6R.cjs +755 -0
- package/dist/chunk-DSXOHC6R.cjs.map +1 -0
- package/dist/chunk-DWM55ACO.cjs +294 -0
- package/dist/chunk-DWM55ACO.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs +9 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -0
- package/dist/chunk-LFY7MUHJ.cjs +483 -0
- package/dist/chunk-LFY7MUHJ.cjs.map +1 -0
- package/dist/chunk-NLWGB4IE.cjs +380 -0
- package/dist/chunk-NLWGB4IE.cjs.map +1 -0
- package/dist/chunk-PIXJPQO7.js +481 -0
- package/dist/chunk-PIXJPQO7.js.map +1 -0
- package/dist/chunk-REEPUD73.js +362 -0
- package/dist/chunk-REEPUD73.js.map +1 -0
- package/dist/chunk-RQYHXWUC.js +292 -0
- package/dist/chunk-RQYHXWUC.js.map +1 -0
- package/dist/chunk-WLN7ZVO4.js +253 -0
- package/dist/chunk-WLN7ZVO4.js.map +1 -0
- package/dist/cli.js +1195 -297
- package/dist/cli.js.map +1 -1
- package/dist/detect.cjs +22 -324
- package/dist/detect.cjs.map +1 -1
- package/dist/detect.d.cts +8 -2
- package/dist/detect.d.ts +8 -2
- package/dist/detect.js +1 -324
- package/dist/detect.js.map +1 -1
- package/dist/{event-emitter-CxKUDo9q.d.cts → event-emitter-BVYUPYLd.d.cts} +3 -2
- package/dist/{event-emitter-CxKUDo9q.d.ts → event-emitter-BVYUPYLd.d.ts} +3 -2
- package/dist/fix.cjs +6 -715
- package/dist/fix.cjs.map +1 -1
- package/dist/fix.d.cts +8 -2
- package/dist/fix.d.ts +8 -2
- package/dist/fix.js +2 -719
- package/dist/fix.js.map +1 -1
- package/dist/index.cjs +1400 -3075
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +237 -57
- package/dist/index.d.ts +237 -57
- package/dist/index.js +1222 -2970
- package/dist/index.js.map +1 -1
- package/dist/{scanner-Cc2187fH.d.ts → scanner-BJFA0354.d.ts} +33 -4
- package/dist/{scanner-S7BtVIpW.d.cts → scanner-DZL2rIFv.d.cts} +33 -4
- package/dist/scanner.cjs +8 -1652
- package/dist/scanner.cjs.map +1 -1
- package/dist/scanner.d.cts +3 -3
- package/dist/scanner.d.ts +3 -3
- package/dist/scanner.js +4 -1656
- package/dist/scanner.js.map +1 -1
- package/dist/{types-DuZyBVVV.d.cts → types-BMDemwIs.d.cts} +35 -10
- package/dist/{types-DuZyBVVV.d.ts → types-BMDemwIs.d.ts} +35 -10
- package/package.json +16 -9
package/dist/detect.cjs
CHANGED
|
@@ -1,331 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var path = require('path');
|
|
3
|
+
var chunkNLWGB4IE_cjs = require('./chunk-NLWGB4IE.cjs');
|
|
4
|
+
require('./chunk-GS7T56RP.cjs');
|
|
6
5
|
|
|
7
|
-
// src/utils/fs.ts
|
|
8
|
-
async function exists(path) {
|
|
9
|
-
try {
|
|
10
|
-
await promises.access(path, fs.constants.F_OK);
|
|
11
|
-
return true;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
async function readTextFile(path, encoding = "utf-8") {
|
|
17
|
-
return promises.readFile(path, { encoding });
|
|
18
|
-
}
|
|
19
|
-
async function readJsonFile(path) {
|
|
20
|
-
const content = await readTextFile(path);
|
|
21
|
-
return JSON.parse(content);
|
|
22
|
-
}
|
|
23
|
-
function joinPath(...paths) {
|
|
24
|
-
return path.join(...paths);
|
|
25
|
-
}
|
|
26
|
-
function getDirName(path$1) {
|
|
27
|
-
return path.dirname(path$1);
|
|
28
|
-
}
|
|
29
|
-
async function findUp(filename, startDir = process.cwd()) {
|
|
30
|
-
let currentDir = path.resolve(startDir);
|
|
31
|
-
const root = path.dirname(currentDir);
|
|
32
|
-
while (currentDir !== root) {
|
|
33
|
-
const filePath = path.join(currentDir, filename);
|
|
34
|
-
if (await exists(filePath)) {
|
|
35
|
-
return filePath;
|
|
36
|
-
}
|
|
37
|
-
const parentDir = path.dirname(currentDir);
|
|
38
|
-
if (parentDir === currentDir) {
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
currentDir = parentDir;
|
|
42
|
-
}
|
|
43
|
-
const rootFilePath = path.join(currentDir, filename);
|
|
44
|
-
if (await exists(rootFilePath)) {
|
|
45
|
-
return rootFilePath;
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
6
|
|
|
50
|
-
// src/detect/framework.ts
|
|
51
|
-
var FRAMEWORK_DETECTORS = [
|
|
52
|
-
// Next.js
|
|
53
|
-
{
|
|
54
|
-
name: "next",
|
|
55
|
-
dependencies: ["next"],
|
|
56
|
-
features: [
|
|
57
|
-
{
|
|
58
|
-
name: "app-router",
|
|
59
|
-
detect: async (_, dir) => exists(joinPath(dir, "app"))
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: "pages-router",
|
|
63
|
-
detect: async (_, dir) => exists(joinPath(dir, "pages"))
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "rsc",
|
|
67
|
-
deps: ["next"],
|
|
68
|
-
detect: async (pkg) => {
|
|
69
|
-
const version = pkg.dependencies?.["next"] ?? "";
|
|
70
|
-
const major = parseInt(version.replace(/[^0-9]/g, "").slice(0, 2), 10);
|
|
71
|
-
return major >= 13;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: "middleware",
|
|
76
|
-
detect: async (_, dir) => exists(joinPath(dir, "middleware.ts")) || exists(joinPath(dir, "middleware.js"))
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
tips: [
|
|
80
|
-
'Use "use client" directive only for interactive components',
|
|
81
|
-
"Keep server components as the default for better performance",
|
|
82
|
-
"Consider using Server Actions for mutations",
|
|
83
|
-
"Use next/dynamic for code splitting heavy components",
|
|
84
|
-
"Avoid passing serializable props through server/client boundary"
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
// Remix
|
|
88
|
-
{
|
|
89
|
-
name: "remix",
|
|
90
|
-
dependencies: ["@remix-run/react", "@remix-run/node", "@remix-run/cloudflare"],
|
|
91
|
-
features: [
|
|
92
|
-
{
|
|
93
|
-
name: "v2-routes",
|
|
94
|
-
detect: async (_, dir) => exists(joinPath(dir, "app", "routes"))
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
name: "defer",
|
|
98
|
-
deps: ["@remix-run/react"],
|
|
99
|
-
detect: async (pkg) => {
|
|
100
|
-
const version = pkg.dependencies?.["@remix-run/react"] ?? "";
|
|
101
|
-
return version.includes("1.") || version.includes("2.");
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
],
|
|
105
|
-
tips: [
|
|
106
|
-
"Use loader data efficiently to minimize client state",
|
|
107
|
-
"Prefer fetcher over useNavigate for non-navigation mutations",
|
|
108
|
-
"Use defer for streaming slow data",
|
|
109
|
-
"Consider using useFetcher.load for background data fetching",
|
|
110
|
-
"Avoid useEffect for data fetching, use loaders instead"
|
|
111
|
-
]
|
|
112
|
-
},
|
|
113
|
-
// Vite
|
|
114
|
-
{
|
|
115
|
-
name: "vite",
|
|
116
|
-
dependencies: [],
|
|
117
|
-
devDependencies: ["vite"],
|
|
118
|
-
features: [
|
|
119
|
-
{
|
|
120
|
-
name: "react-plugin",
|
|
121
|
-
deps: ["@vitejs/plugin-react", "@vitejs/plugin-react-swc"]
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: "ssr",
|
|
125
|
-
detect: async (_, dir) => exists(joinPath(dir, "vite.config.ts")) || exists(joinPath(dir, "vite.config.js"))
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
tips: [
|
|
129
|
-
"Use React.lazy with Suspense for code splitting",
|
|
130
|
-
"Configure build.rollupOptions.output.manualChunks for optimal chunking",
|
|
131
|
-
"Enable build.sourcemap only in development",
|
|
132
|
-
"Use @vitejs/plugin-react-swc for faster builds",
|
|
133
|
-
"Consider using vite-plugin-pwa for PWA support"
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
|
-
// Create React App
|
|
137
|
-
{
|
|
138
|
-
name: "cra",
|
|
139
|
-
dependencies: ["react-scripts"],
|
|
140
|
-
features: [
|
|
141
|
-
{
|
|
142
|
-
name: "typescript",
|
|
143
|
-
deps: ["typescript"]
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
name: "testing-library",
|
|
147
|
-
deps: ["@testing-library/react"]
|
|
148
|
-
}
|
|
149
|
-
],
|
|
150
|
-
tips: [
|
|
151
|
-
"Consider migrating to Vite for faster development builds",
|
|
152
|
-
"Use React.lazy for code splitting",
|
|
153
|
-
'Run "npm run build -- --stats" to analyze bundle size',
|
|
154
|
-
"Use REACT_APP_ prefix for environment variables",
|
|
155
|
-
"Consider ejecting only if absolutely necessary"
|
|
156
|
-
]
|
|
157
|
-
},
|
|
158
|
-
// Gatsby
|
|
159
|
-
{
|
|
160
|
-
name: "gatsby",
|
|
161
|
-
dependencies: ["gatsby"],
|
|
162
|
-
features: [
|
|
163
|
-
{
|
|
164
|
-
name: "v5",
|
|
165
|
-
deps: ["gatsby"],
|
|
166
|
-
detect: async (pkg) => {
|
|
167
|
-
const version = pkg.dependencies?.["gatsby"] ?? "";
|
|
168
|
-
return version.includes("5.") || version.includes("^5");
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: "image",
|
|
173
|
-
deps: ["gatsby-plugin-image"]
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
name: "graphql",
|
|
177
|
-
deps: ["gatsby"]
|
|
178
|
-
}
|
|
179
|
-
],
|
|
180
|
-
tips: [
|
|
181
|
-
"Use gatsby-plugin-image for optimized images",
|
|
182
|
-
"Prefer StaticQuery over page queries for reusable components",
|
|
183
|
-
"Use incremental builds for faster development",
|
|
184
|
-
"Configure proper caching headers for static assets",
|
|
185
|
-
"Consider using DSG (Deferred Static Generation) for large sites"
|
|
186
|
-
]
|
|
187
|
-
}
|
|
188
|
-
];
|
|
189
|
-
async function detectFramework(packageJsonPath) {
|
|
190
|
-
let pkgPath = packageJsonPath;
|
|
191
|
-
if (!pkgPath) {
|
|
192
|
-
pkgPath = await findUp("package.json") ?? void 0;
|
|
193
|
-
}
|
|
194
|
-
if (!pkgPath || !await exists(pkgPath)) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
let packageJson;
|
|
198
|
-
try {
|
|
199
|
-
packageJson = await readJsonFile(pkgPath);
|
|
200
|
-
} catch {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
const projectDir = getDirName(pkgPath);
|
|
204
|
-
for (const detector of FRAMEWORK_DETECTORS) {
|
|
205
|
-
const match = await matchFramework(detector, packageJson, projectDir);
|
|
206
|
-
if (match) {
|
|
207
|
-
return match;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
name: "unknown",
|
|
212
|
-
version: "",
|
|
213
|
-
features: [],
|
|
214
|
-
tips: [
|
|
215
|
-
"Consider using React.memo for frequently re-rendering components",
|
|
216
|
-
"Use useCallback for event handlers passed to child components",
|
|
217
|
-
"Use useMemo for expensive computations",
|
|
218
|
-
"Avoid inline object/array creation in render"
|
|
219
|
-
]
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
async function matchFramework(detector, packageJson, projectDir) {
|
|
223
|
-
const allDeps = {
|
|
224
|
-
...packageJson.dependencies,
|
|
225
|
-
...packageJson.devDependencies
|
|
226
|
-
};
|
|
227
|
-
const mainDep = detector.dependencies.find((dep) => dep in allDeps) ?? detector.devDependencies?.find((dep) => dep in (packageJson.devDependencies ?? {}));
|
|
228
|
-
if (!mainDep) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
const version = allDeps[mainDep]?.replace(/[\^~]/g, "") ?? "unknown";
|
|
232
|
-
const features = [];
|
|
233
|
-
for (const feature of detector.features) {
|
|
234
|
-
let detected = false;
|
|
235
|
-
if (feature.deps) {
|
|
236
|
-
detected = feature.deps.some((dep) => dep in allDeps);
|
|
237
|
-
}
|
|
238
|
-
if (feature.files && !detected) {
|
|
239
|
-
for (const file of feature.files) {
|
|
240
|
-
if (await exists(joinPath(projectDir, file))) {
|
|
241
|
-
detected = true;
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (feature.detect && !detected) {
|
|
247
|
-
try {
|
|
248
|
-
detected = await feature.detect(packageJson, projectDir);
|
|
249
|
-
} catch {
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (detected) {
|
|
253
|
-
features.push(feature.name);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return {
|
|
257
|
-
name: detector.name,
|
|
258
|
-
version,
|
|
259
|
-
features,
|
|
260
|
-
tips: detector.tips
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function getFrameworkTips(framework, issues) {
|
|
264
|
-
const tips = [];
|
|
265
|
-
tips.push(...framework.tips.slice(0, 3));
|
|
266
|
-
if (issues.some((i) => i.type === "context-over-subscription")) {
|
|
267
|
-
switch (framework.name) {
|
|
268
|
-
case "next":
|
|
269
|
-
tips.push("Consider using server components to avoid client-side context re-renders");
|
|
270
|
-
break;
|
|
271
|
-
case "remix":
|
|
272
|
-
tips.push("Use loader data instead of context for server data");
|
|
273
|
-
break;
|
|
274
|
-
default:
|
|
275
|
-
tips.push("Split large contexts into smaller, focused contexts");
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (issues.some((i) => i.type === "expensive-computation")) {
|
|
279
|
-
switch (framework.name) {
|
|
280
|
-
case "next":
|
|
281
|
-
tips.push("Move expensive computations to server components");
|
|
282
|
-
break;
|
|
283
|
-
case "gatsby":
|
|
284
|
-
tips.push("Use GraphQL for data transformation at build time");
|
|
285
|
-
break;
|
|
286
|
-
default:
|
|
287
|
-
tips.push("Use useMemo to cache expensive computations");
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return [...new Set(tips)];
|
|
291
|
-
}
|
|
292
|
-
function detectFrameworkFromWindow() {
|
|
293
|
-
if (typeof window === "undefined") {
|
|
294
|
-
return null;
|
|
295
|
-
}
|
|
296
|
-
const win = window;
|
|
297
|
-
if (win["__NEXT_DATA__"] !== void 0) {
|
|
298
|
-
const doc = win["document"] ?? (typeof document !== "undefined" ? document : null);
|
|
299
|
-
const isAppRouter = doc?.querySelector("[data-nextjs-scroll-focus-boundary]") !== null;
|
|
300
|
-
return {
|
|
301
|
-
name: "next",
|
|
302
|
-
version: "unknown",
|
|
303
|
-
features: isAppRouter ? ["app-router", "rsc"] : ["pages-router"],
|
|
304
|
-
tips: []
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
if (win["___gatsby"] !== void 0) {
|
|
308
|
-
return {
|
|
309
|
-
name: "gatsby",
|
|
310
|
-
version: "unknown",
|
|
311
|
-
features: [],
|
|
312
|
-
tips: []
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
if (win["__remixContext"] !== void 0) {
|
|
316
|
-
return {
|
|
317
|
-
name: "remix",
|
|
318
|
-
version: "unknown",
|
|
319
|
-
features: [],
|
|
320
|
-
tips: []
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
7
|
|
|
326
|
-
exports
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
8
|
+
Object.defineProperty(exports, "detectFramework", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkNLWGB4IE_cjs.detectFramework; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "detectFrameworkFromWindow", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkNLWGB4IE_cjs.detectFrameworkFromWindow; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "frameworkDetectors", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkNLWGB4IE_cjs.FRAMEWORK_DETECTORS; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "getFrameworkTips", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkNLWGB4IE_cjs.getFrameworkTips; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "getMajorVersion", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkNLWGB4IE_cjs.getMajorVersion; }
|
|
27
|
+
});
|
|
330
28
|
//# sourceMappingURL=detect.cjs.map
|
|
331
29
|
//# sourceMappingURL=detect.cjs.map
|
package/dist/detect.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/fs.ts","../src/detect/framework.ts"],"names":["access","constants","readFile","join","path","dirname","resolve"],"mappings":";;;;;;;AAcA,eAAsB,OAAO,IAAA,EAAgC;AAC3D,EAAA,IAAI;AACF,IAAA,MAAMA,eAAA,CAAO,IAAA,EAAMC,YAAA,CAAU,IAAI,CAAA;AACjC,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAoCA,eAAsB,YAAA,CAAa,IAAA,EAAc,QAAA,GAA2B,OAAA,E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AAA,MACN,OAAA,EAAS,SAAA;AAAA,MACT,UAAU,WAAA,GAAc,CAAC,cAAc,KAAK,CAAA,GAAI,CAAC,cAAc,CAAA;AAAA,MAC/D,MAAM;AAAC,KACT;AAAA,EACF;AAGA,EAAA,IAAI,GAAA,CAAI,WAAW,CAAA,KAAM,MAAA,EAAW;AAClC,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,QAAA;AAAA,MACN,OAAA,EAAS,SAAA;AAAA,MACT,UAAU,EAAC;AAAA,MACX,MAAM;AAAC,KACT;AAAA,EACF;AAGA,EAAA,IAAI,GAAA,CAAI,gBAAgB,CAAA,KAAM,MAAA,EAAW;AACvC,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,OAAA;AAAA,MACN,OAAA,EAAS,SAAA;AAAA,MACT,UAAU,EAAC;AAAA,MACX,MAAM;AAAC,KACT;AAAA,EACF;AAEA,EAAA,OAAO,IAAA;AACT","file":"detect.cjs","sourcesContent":["/**\n * File system utilities\n * @packageDocumentation\n */\n\nimport { readFile, writeFile, mkdir, stat, access, readdir, rm } from 'node:fs/promises';\nimport { constants } from 'node:fs';\nimport { dirname, join, resolve, extname, basename } from 'node:path';\n\n/**\n * Check if a file or directory exists\n * @param path - Path to check\n * @returns true if exists\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if a path is a directory\n * @param path - Path to check\n * @returns true if directory\n */\nexport async function isDirectory(path: string): Promise<boolean> {\n try {\n const stats = await stat(path);\n return stats.isDirectory();\n } catch {\n return false;\n }\n}\n\n/**\n * Check if a path is a file\n * @param path - Path to check\n * @returns true if file\n */\nexport async function isFile(path: string): Promise<boolean> {\n try {\n const stats = await stat(path);\n return stats.isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * Read a text file\n * @param path - File path\n * @param encoding - Text encoding\n * @returns File contents\n */\nexport async function readTextFile(path: string, encoding: BufferEncoding = 'utf-8'): Promise<string> {\n return readFile(path, { encoding });\n}\n\n/**\n * Write a text file\n * @param path - File path\n * @param content - File contents\n * @param encoding - Text encoding\n */\nexport async function writeTextFile(\n path: string,\n content: string,\n encoding: BufferEncoding = 'utf-8'\n): Promise<void> {\n const dir = dirname(path);\n await ensureDir(dir);\n await writeFile(path, content, { encoding });\n}\n\n/**\n * Read a JSON file\n * @param path - File path\n * @returns Parsed JSON\n */\nexport async function readJsonFile<T = unknown>(path: string): Promise<T> {\n const content = await readTextFile(path);\n return JSON.parse(content) as T;\n}\n\n/**\n * Write a JSON file\n * @param path - File path\n * @param data - Data to write\n * @param pretty - Whether to format with indentation\n */\nexport async function writeJsonFile(path: string, data: unknown, pretty: boolean = true): Promise<void> {\n const content = pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);\n await writeTextFile(path, content);\n}\n\n/**\n * Ensure a directory exists, creating it if necessary\n * @param path - Directory path\n */\nexport async function ensureDir(path: string): Promise<void> {\n if (!(await exists(path))) {\n await mkdir(path, { recursive: true });\n }\n}\n\n/**\n * Remove a file or directory\n * @param path - Path to remove\n * @param options - Removal options\n */\nexport async function remove(\n path: string,\n options: { recursive?: boolean; force?: boolean } = {}\n): Promise<void> {\n const { recursive = true, force = true } = options;\n await rm(path, { recursive, force });\n}\n\n/**\n * List files in a directory\n * @param path - Directory path\n * @param options - List options\n * @returns Array of file/directory names\n */\nexport async function listDir(\n path: string,\n options: { recursive?: boolean; filesOnly?: boolean; dirsOnly?: boolean } = {}\n): Promise<string[]> {\n const { recursive = false, filesOnly = false, dirsOnly = false } = options;\n\n const entries = await readdir(path, { withFileTypes: true });\n const results: string[] = [];\n\n for (const entry of entries) {\n const fullPath = join(path, entry.name);\n\n if (entry.isDirectory()) {\n if (!filesOnly) {\n results.push(fullPath);\n }\n if (recursive) {\n const subEntries = await listDir(fullPath, options);\n results.push(...subEntries);\n }\n } else if (entry.isFile()) {\n if (!dirsOnly) {\n results.push(fullPath);\n }\n }\n }\n\n return results;\n}\n\n/**\n * Get file extension\n * @param path - File path\n * @returns Extension without dot\n */\nexport function getExtension(path: string): string {\n return extname(path).slice(1);\n}\n\n/**\n * Get file name without extension\n * @param path - File path\n * @returns Filename without extension\n */\nexport function getBaseName(path: string): string {\n const ext = extname(path);\n return basename(path, ext);\n}\n\n/**\n * Resolve a path relative to a base\n * @param base - Base path\n * @param paths - Path segments\n * @returns Resolved path\n */\nexport function resolvePath(base: string, ...paths: string[]): string {\n return resolve(base, ...paths);\n}\n\n/**\n * Join path segments\n * @param paths - Path segments\n * @returns Joined path\n */\nexport function joinPath(...paths: string[]): string {\n return join(...paths);\n}\n\n/**\n * Get directory name\n * @param path - File path\n * @returns Directory name\n */\nexport function getDirName(path: string): string {\n return dirname(path);\n}\n\n/**\n * Find a file by walking up the directory tree\n * @param filename - File to find\n * @param startDir - Starting directory\n * @returns File path if found, null otherwise\n */\nexport async function findUp(filename: string, startDir: string = process.cwd()): Promise<string | null> {\n let currentDir = resolve(startDir);\n const root = dirname(currentDir);\n\n while (currentDir !== root) {\n const filePath = join(currentDir, filename);\n if (await exists(filePath)) {\n return filePath;\n }\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n // Check root\n const rootFilePath = join(currentDir, filename);\n if (await exists(rootFilePath)) {\n return rootFilePath;\n }\n\n return null;\n}\n\n/**\n * Copy a file\n * @param src - Source path\n * @param dest - Destination path\n */\nexport async function copyFile(src: string, dest: string): Promise<void> {\n const content = await readFile(src);\n await ensureDir(dirname(dest));\n await writeFile(dest, content);\n}\n\n/**\n * Get file size in bytes\n * @param path - File path\n * @returns File size\n */\nexport async function getFileSize(path: string): Promise<number> {\n const stats = await stat(path);\n return stats.size;\n}\n\n/**\n * Get file modification time\n * @param path - File path\n * @returns Modification time\n */\nexport async function getModifiedTime(path: string): Promise<Date> {\n const stats = await stat(path);\n return stats.mtime;\n}\n\n/**\n * Create a temporary file path\n * @param prefix - Filename prefix\n * @param ext - File extension\n * @returns Temporary file path\n */\nexport function getTempFilePath(prefix: string = 'reactcheck', ext: string = 'tmp'): string {\n const timestamp = Date.now();\n const random = Math.random().toString(36).slice(2, 8);\n const filename = `${prefix}-${timestamp}-${random}.${ext}`;\n\n // Use OS temp directory\n const tmpDir = process.env['TMPDIR'] ?? process.env['TMP'] ?? process.env['TEMP'] ?? '/tmp';\n return join(tmpDir, filename);\n}\n\n/**\n * Safely parse a JSON file, returning null on error\n * @param path - File path\n * @returns Parsed JSON or null\n */\nexport async function safeReadJsonFile<T = unknown>(path: string): Promise<T | null> {\n try {\n return await readJsonFile<T>(path);\n } catch {\n return null;\n }\n}\n\n/**\n * Watch options for file watching (placeholder for future implementation)\n */\nexport interface WatchOptions {\n /** Watch recursively */\n recursive?: boolean;\n /** Debounce delay in ms */\n debounce?: number;\n /** File patterns to include */\n include?: string[];\n /** File patterns to exclude */\n exclude?: string[];\n}\n","/**\n * Framework detection module\n * @packageDocumentation\n */\n\nimport type { FrameworkInfo } from '../types.js';\nimport { exists, readJsonFile, findUp, joinPath, getDirName } from '../utils/fs.js';\n\n/**\n * Framework detector configuration\n */\ninterface FrameworkDetector {\n /** Framework name */\n name: FrameworkInfo['name'];\n /** Dependencies to look for */\n dependencies: string[];\n /** DevDependencies to look for */\n devDependencies?: string[];\n /** Features to detect */\n features: Array<{\n /** Feature name */\n name: string;\n /** File patterns to check */\n files?: string[];\n /** Dependencies to check */\n deps?: string[];\n /** Detection function */\n detect?: (packageJson: PackageJson, dir: string) => Promise<boolean>;\n }>;\n /** Framework-specific tips */\n tips: string[];\n}\n\n/**\n * Package.json structure\n */\ninterface PackageJson {\n name?: string;\n version?: string;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n scripts?: Record<string, string>;\n}\n\n/**\n * Framework detectors configuration\n */\nconst FRAMEWORK_DETECTORS: FrameworkDetector[] = [\n // Next.js\n {\n name: 'next',\n dependencies: ['next'],\n features: [\n {\n name: 'app-router',\n detect: async (_, dir) => exists(joinPath(dir, 'app')),\n },\n {\n name: 'pages-router',\n detect: async (_, dir) => exists(joinPath(dir, 'pages')),\n },\n {\n name: 'rsc',\n deps: ['next'],\n detect: async (pkg) => {\n const version = pkg.dependencies?.['next'] ?? '';\n const major = parseInt(version.replace(/[^0-9]/g, '').slice(0, 2), 10);\n return major >= 13;\n },\n },\n {\n name: 'middleware',\n detect: async (_, dir) => exists(joinPath(dir, 'middleware.ts')) ||\n exists(joinPath(dir, 'middleware.js')),\n },\n ],\n tips: [\n 'Use \"use client\" directive only for interactive components',\n 'Keep server components as the default for better performance',\n 'Consider using Server Actions for mutations',\n 'Use next/dynamic for code splitting heavy components',\n 'Avoid passing serializable props through server/client boundary',\n ],\n },\n\n // Remix\n {\n name: 'remix',\n dependencies: ['@remix-run/react', '@remix-run/node', '@remix-run/cloudflare'],\n features: [\n {\n name: 'v2-routes',\n detect: async (_, dir) =>\n exists(joinPath(dir, 'app', 'routes')),\n },\n {\n name: 'defer',\n deps: ['@remix-run/react'],\n detect: async (pkg) => {\n const version = pkg.dependencies?.['@remix-run/react'] ?? '';\n return version.includes('1.') || version.includes('2.');\n },\n },\n ],\n tips: [\n 'Use loader data efficiently to minimize client state',\n 'Prefer fetcher over useNavigate for non-navigation mutations',\n 'Use defer for streaming slow data',\n 'Consider using useFetcher.load for background data fetching',\n 'Avoid useEffect for data fetching, use loaders instead',\n ],\n },\n\n // Vite\n {\n name: 'vite',\n dependencies: [],\n devDependencies: ['vite'],\n features: [\n {\n name: 'react-plugin',\n deps: ['@vitejs/plugin-react', '@vitejs/plugin-react-swc'],\n },\n {\n name: 'ssr',\n detect: async (_, dir) =>\n exists(joinPath(dir, 'vite.config.ts')) ||\n exists(joinPath(dir, 'vite.config.js')),\n },\n ],\n tips: [\n 'Use React.lazy with Suspense for code splitting',\n 'Configure build.rollupOptions.output.manualChunks for optimal chunking',\n 'Enable build.sourcemap only in development',\n 'Use @vitejs/plugin-react-swc for faster builds',\n 'Consider using vite-plugin-pwa for PWA support',\n ],\n },\n\n // Create React App\n {\n name: 'cra',\n dependencies: ['react-scripts'],\n features: [\n {\n name: 'typescript',\n deps: ['typescript'],\n },\n {\n name: 'testing-library',\n deps: ['@testing-library/react'],\n },\n ],\n tips: [\n 'Consider migrating to Vite for faster development builds',\n 'Use React.lazy for code splitting',\n 'Run \"npm run build -- --stats\" to analyze bundle size',\n 'Use REACT_APP_ prefix for environment variables',\n 'Consider ejecting only if absolutely necessary',\n ],\n },\n\n // Gatsby\n {\n name: 'gatsby',\n dependencies: ['gatsby'],\n features: [\n {\n name: 'v5',\n deps: ['gatsby'],\n detect: async (pkg) => {\n const version = pkg.dependencies?.['gatsby'] ?? '';\n return version.includes('5.') || version.includes('^5');\n },\n },\n {\n name: 'image',\n deps: ['gatsby-plugin-image'],\n },\n {\n name: 'graphql',\n deps: ['gatsby'],\n },\n ],\n tips: [\n 'Use gatsby-plugin-image for optimized images',\n 'Prefer StaticQuery over page queries for reusable components',\n 'Use incremental builds for faster development',\n 'Configure proper caching headers for static assets',\n 'Consider using DSG (Deferred Static Generation) for large sites',\n ],\n },\n];\n\n/**\n * Detect framework from package.json\n * @param packageJsonPath - Path to package.json\n * @returns Framework info or null\n */\nexport async function detectFramework(packageJsonPath?: string): Promise<FrameworkInfo | null> {\n // Find package.json if not provided\n let pkgPath: string | undefined = packageJsonPath;\n if (!pkgPath) {\n pkgPath = (await findUp('package.json')) ?? undefined;\n }\n\n if (!pkgPath || !(await exists(pkgPath))) {\n return null;\n }\n\n // Read package.json\n let packageJson: PackageJson;\n try {\n packageJson = await readJsonFile<PackageJson>(pkgPath);\n } catch {\n return null;\n }\n\n const projectDir = getDirName(pkgPath);\n\n // Check each framework detector\n for (const detector of FRAMEWORK_DETECTORS) {\n const match = await matchFramework(detector, packageJson, projectDir);\n if (match) {\n return match;\n }\n }\n\n return {\n name: 'unknown',\n version: '',\n features: [],\n tips: [\n 'Consider using React.memo for frequently re-rendering components',\n 'Use useCallback for event handlers passed to child components',\n 'Use useMemo for expensive computations',\n 'Avoid inline object/array creation in render',\n ],\n };\n}\n\n/**\n * Check if a framework matches\n * @param detector - Framework detector\n * @param packageJson - Package.json data\n * @param projectDir - Project directory\n * @returns Framework info if matched\n */\nasync function matchFramework(\n detector: FrameworkDetector,\n packageJson: PackageJson,\n projectDir: string\n): Promise<FrameworkInfo | null> {\n const allDeps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any dependency matches\n const mainDep = detector.dependencies.find((dep) => dep in allDeps) ??\n detector.devDependencies?.find((dep) => dep in (packageJson.devDependencies ?? {}));\n\n if (!mainDep) {\n return null;\n }\n\n // Get version\n const version = allDeps[mainDep]?.replace(/[\\^~]/g, '') ?? 'unknown';\n\n // Detect features\n const features: string[] = [];\n for (const feature of detector.features) {\n let detected = false;\n\n // Check dependencies\n if (feature.deps) {\n detected = feature.deps.some((dep) => dep in allDeps);\n }\n\n // Check files\n if (feature.files && !detected) {\n for (const file of feature.files) {\n if (await exists(joinPath(projectDir, file))) {\n detected = true;\n break;\n }\n }\n }\n\n // Custom detection\n if (feature.detect && !detected) {\n try {\n detected = await feature.detect(packageJson, projectDir);\n } catch {\n // Ignore detection errors\n }\n }\n\n if (detected) {\n features.push(feature.name);\n }\n }\n\n return {\n name: detector.name,\n version,\n features,\n tips: detector.tips,\n };\n}\n\n/**\n * Get framework-specific tips based on detected issues\n * @param framework - Detected framework\n * @param issues - Detected performance issues\n * @returns Relevant tips\n */\nexport function getFrameworkTips(\n framework: FrameworkInfo,\n issues: Array<{ type: string; component: string }>\n): string[] {\n const tips: string[] = [];\n\n // Add general framework tips\n tips.push(...framework.tips.slice(0, 3));\n\n // Add issue-specific tips\n if (issues.some((i) => i.type === 'context-over-subscription')) {\n switch (framework.name) {\n case 'next':\n tips.push('Consider using server components to avoid client-side context re-renders');\n break;\n case 'remix':\n tips.push('Use loader data instead of context for server data');\n break;\n default:\n tips.push('Split large contexts into smaller, focused contexts');\n }\n }\n\n if (issues.some((i) => i.type === 'expensive-computation')) {\n switch (framework.name) {\n case 'next':\n tips.push('Move expensive computations to server components');\n break;\n case 'gatsby':\n tips.push('Use GraphQL for data transformation at build time');\n break;\n default:\n tips.push('Use useMemo to cache expensive computations');\n }\n }\n\n return [...new Set(tips)]; // Remove duplicates\n}\n\n/**\n * Detect framework from window object (browser-side)\n * @returns Framework info based on global variables\n */\nexport function detectFrameworkFromWindow(): FrameworkInfo | null {\n if (typeof window === 'undefined') {\n return null;\n }\n\n const win = window as unknown as Record<string, unknown>;\n\n // Check for Next.js\n if (win['__NEXT_DATA__'] !== undefined) {\n const doc = (win['document'] as Document | undefined) ?? (typeof document !== 'undefined' ? document : null);\n const isAppRouter = doc?.querySelector('[data-nextjs-scroll-focus-boundary]') !== null;\n\n return {\n name: 'next',\n version: 'unknown',\n features: isAppRouter ? ['app-router', 'rsc'] : ['pages-router'],\n tips: [],\n };\n }\n\n // Check for Gatsby\n if (win['___gatsby'] !== undefined) {\n return {\n name: 'gatsby',\n version: 'unknown',\n features: [],\n tips: [],\n };\n }\n\n // Check for Remix\n if (win['__remixContext'] !== undefined) {\n return {\n name: 'remix',\n version: 'unknown',\n features: [],\n tips: [],\n };\n }\n\n return null;\n}\n\n/**\n * Export framework detector for use in CLI\n */\nexport { FRAMEWORK_DETECTORS as frameworkDetectors };\n"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"detect.cjs"}
|
package/dist/detect.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as FrameworkInfo } from './types-
|
|
1
|
+
import { k as FrameworkInfo } from './types-BMDemwIs.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Framework detection module
|
|
@@ -48,6 +48,12 @@ declare const FRAMEWORK_DETECTORS: FrameworkDetector[];
|
|
|
48
48
|
* @param packageJsonPath - Path to package.json
|
|
49
49
|
* @returns Framework info or null
|
|
50
50
|
*/
|
|
51
|
+
/**
|
|
52
|
+
* Major version of a dependency range such as `^14.1.0`, `~9.5.0` or `>=13`
|
|
53
|
+
* @param range - Version range from package.json
|
|
54
|
+
* @returns Major version, or NaN when it cannot be determined (e.g. `latest`)
|
|
55
|
+
*/
|
|
56
|
+
declare function getMajorVersion(range: unknown): number;
|
|
51
57
|
declare function detectFramework(packageJsonPath?: string): Promise<FrameworkInfo | null>;
|
|
52
58
|
/**
|
|
53
59
|
* Get framework-specific tips based on detected issues
|
|
@@ -65,4 +71,4 @@ declare function getFrameworkTips(framework: FrameworkInfo, issues: Array<{
|
|
|
65
71
|
*/
|
|
66
72
|
declare function detectFrameworkFromWindow(): FrameworkInfo | null;
|
|
67
73
|
|
|
68
|
-
export { detectFramework, detectFrameworkFromWindow, FRAMEWORK_DETECTORS as frameworkDetectors, getFrameworkTips };
|
|
74
|
+
export { detectFramework, detectFrameworkFromWindow, FRAMEWORK_DETECTORS as frameworkDetectors, getFrameworkTips, getMajorVersion };
|
package/dist/detect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as FrameworkInfo } from './types-
|
|
1
|
+
import { k as FrameworkInfo } from './types-BMDemwIs.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Framework detection module
|
|
@@ -48,6 +48,12 @@ declare const FRAMEWORK_DETECTORS: FrameworkDetector[];
|
|
|
48
48
|
* @param packageJsonPath - Path to package.json
|
|
49
49
|
* @returns Framework info or null
|
|
50
50
|
*/
|
|
51
|
+
/**
|
|
52
|
+
* Major version of a dependency range such as `^14.1.0`, `~9.5.0` or `>=13`
|
|
53
|
+
* @param range - Version range from package.json
|
|
54
|
+
* @returns Major version, or NaN when it cannot be determined (e.g. `latest`)
|
|
55
|
+
*/
|
|
56
|
+
declare function getMajorVersion(range: unknown): number;
|
|
51
57
|
declare function detectFramework(packageJsonPath?: string): Promise<FrameworkInfo | null>;
|
|
52
58
|
/**
|
|
53
59
|
* Get framework-specific tips based on detected issues
|
|
@@ -65,4 +71,4 @@ declare function getFrameworkTips(framework: FrameworkInfo, issues: Array<{
|
|
|
65
71
|
*/
|
|
66
72
|
declare function detectFrameworkFromWindow(): FrameworkInfo | null;
|
|
67
73
|
|
|
68
|
-
export { detectFramework, detectFrameworkFromWindow, FRAMEWORK_DETECTORS as frameworkDetectors, getFrameworkTips };
|
|
74
|
+
export { detectFramework, detectFrameworkFromWindow, FRAMEWORK_DETECTORS as frameworkDetectors, getFrameworkTips, getMajorVersion };
|