react-doctor 0.2.18-dev.eba20ae → 0.3.0-dev.6130583
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/cli.js +781 -408
- package/dist/index.d.ts +0 -1
- package/dist/index.js +179 -179
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="78466bb6-1333-5899-a21b-ca9ce49351a3")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as fs$1 from "node:fs";
|
|
6
|
-
import fs
|
|
7
|
-
import * as
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import * as path$1 from "node:path";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { spawn, spawnSync } from "node:child_process";
|
|
10
10
|
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES } from "oxlint-plugin-react-doctor";
|
|
@@ -2075,7 +2075,7 @@ var AmbiguousProjectError = class extends Error {
|
|
|
2075
2075
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
2076
2076
|
const isFile = (filePath) => {
|
|
2077
2077
|
try {
|
|
2078
|
-
return fs.statSync(filePath).isFile();
|
|
2078
|
+
return fs$1.statSync(filePath).isFile();
|
|
2079
2079
|
} catch {
|
|
2080
2080
|
return false;
|
|
2081
2081
|
}
|
|
@@ -2102,9 +2102,9 @@ const isLintableSourceFile = (filePath) => SOURCE_FILE_PATTERN.test(filePath) &&
|
|
|
2102
2102
|
const isMinifiedSource = (absolutePath) => {
|
|
2103
2103
|
let fileDescriptor;
|
|
2104
2104
|
try {
|
|
2105
|
-
fileDescriptor = fs.openSync(absolutePath, "r");
|
|
2105
|
+
fileDescriptor = fs$1.openSync(absolutePath, "r");
|
|
2106
2106
|
const buffer = Buffer.alloc(MINIFIED_SNIFF_BYTES);
|
|
2107
|
-
const bytesRead = fs.readSync(fileDescriptor, buffer, 0, MINIFIED_SNIFF_BYTES, 0);
|
|
2107
|
+
const bytesRead = fs$1.readSync(fileDescriptor, buffer, 0, MINIFIED_SNIFF_BYTES, 0);
|
|
2108
2108
|
const prefix = buffer.toString("utf8", 0, bytesRead);
|
|
2109
2109
|
const lines = prefix.split("\n");
|
|
2110
2110
|
const longestLineLength = lines.reduce((longest, line) => Math.max(longest, line.length), 0);
|
|
@@ -2113,13 +2113,13 @@ const isMinifiedSource = (absolutePath) => {
|
|
|
2113
2113
|
} catch {
|
|
2114
2114
|
return false;
|
|
2115
2115
|
} finally {
|
|
2116
|
-
if (fileDescriptor !== void 0) fs.closeSync(fileDescriptor);
|
|
2116
|
+
if (fileDescriptor !== void 0) fs$1.closeSync(fileDescriptor);
|
|
2117
2117
|
}
|
|
2118
2118
|
};
|
|
2119
2119
|
const isLargeMinifiedFile = (absolutePath) => {
|
|
2120
2120
|
let sizeBytes;
|
|
2121
2121
|
try {
|
|
2122
|
-
sizeBytes = fs.statSync(absolutePath).size;
|
|
2122
|
+
sizeBytes = fs$1.statSync(absolutePath).size;
|
|
2123
2123
|
} catch {
|
|
2124
2124
|
return false;
|
|
2125
2125
|
}
|
|
@@ -2142,7 +2142,7 @@ const isIgnorableReaddirError = (error) => {
|
|
|
2142
2142
|
};
|
|
2143
2143
|
const readDirectoryEntries = (directoryPath) => {
|
|
2144
2144
|
try {
|
|
2145
|
-
return fs.readdirSync(directoryPath, { withFileTypes: true });
|
|
2145
|
+
return fs$1.readdirSync(directoryPath, { withFileTypes: true });
|
|
2146
2146
|
} catch (error) {
|
|
2147
2147
|
if (isIgnorableReaddirError(error)) return [];
|
|
2148
2148
|
throw error;
|
|
@@ -2156,10 +2156,10 @@ const countSourceFilesViaFilesystem = (rootDirectory) => {
|
|
|
2156
2156
|
const entries = readDirectoryEntries(currentDirectory);
|
|
2157
2157
|
for (const entry of entries) {
|
|
2158
2158
|
if (entry.isDirectory()) {
|
|
2159
|
-
if (!entry.name.startsWith(".") && !IGNORED_DIRECTORIES.has(entry.name)) stack.push(path.join(currentDirectory, entry.name));
|
|
2159
|
+
if (!entry.name.startsWith(".") && !IGNORED_DIRECTORIES.has(entry.name)) stack.push(path$1.join(currentDirectory, entry.name));
|
|
2160
2160
|
continue;
|
|
2161
2161
|
}
|
|
2162
|
-
if (entry.isFile() && isLintableSourceFile(entry.name) && !isLargeMinifiedFile(path.join(currentDirectory, entry.name))) count++;
|
|
2162
|
+
if (entry.isFile() && isLintableSourceFile(entry.name) && !isLargeMinifiedFile(path$1.join(currentDirectory, entry.name))) count++;
|
|
2163
2163
|
}
|
|
2164
2164
|
}
|
|
2165
2165
|
return count;
|
|
@@ -2177,7 +2177,7 @@ const countSourceFilesViaGit = (rootDirectory) => {
|
|
|
2177
2177
|
maxBuffer: GIT_LS_FILES_MAX_BUFFER_BYTES
|
|
2178
2178
|
});
|
|
2179
2179
|
if (result.error || result.status !== 0) return null;
|
|
2180
|
-
return result.stdout.split("\0").filter((filePath) => filePath.length > 0 && isLintableSourceFile(filePath) && !isLargeMinifiedFile(path.resolve(rootDirectory, filePath))).length;
|
|
2180
|
+
return result.stdout.split("\0").filter((filePath) => filePath.length > 0 && isLintableSourceFile(filePath) && !isLargeMinifiedFile(path$1.resolve(rootDirectory, filePath))).length;
|
|
2181
2181
|
};
|
|
2182
2182
|
const countSourceFiles = (rootDirectory) => countSourceFilesViaGit(rootDirectory) ?? countSourceFilesViaFilesystem(rootDirectory);
|
|
2183
2183
|
const cachedPackageJsons = /* @__PURE__ */ new Map();
|
|
@@ -2186,7 +2186,7 @@ const clearPackageJsonCache = () => {
|
|
|
2186
2186
|
};
|
|
2187
2187
|
const readPackageJsonUncached = (packageJsonPath) => {
|
|
2188
2188
|
try {
|
|
2189
|
-
return JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
2189
|
+
return JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8"));
|
|
2190
2190
|
} catch (error) {
|
|
2191
2191
|
if (error instanceof SyntaxError) return {};
|
|
2192
2192
|
if (error instanceof Error && "code" in error) {
|
|
@@ -2197,7 +2197,7 @@ const readPackageJsonUncached = (packageJsonPath) => {
|
|
|
2197
2197
|
}
|
|
2198
2198
|
};
|
|
2199
2199
|
const readPackageJson = (packageJsonPath) => {
|
|
2200
|
-
const absolutePath = path.resolve(packageJsonPath);
|
|
2200
|
+
const absolutePath = path$1.resolve(packageJsonPath);
|
|
2201
2201
|
const cached = cachedPackageJsons.get(absolutePath);
|
|
2202
2202
|
if (cached !== void 0) return cached;
|
|
2203
2203
|
const result = readPackageJsonUncached(absolutePath);
|
|
@@ -2205,18 +2205,18 @@ const readPackageJson = (packageJsonPath) => {
|
|
|
2205
2205
|
return result;
|
|
2206
2206
|
};
|
|
2207
2207
|
const isMonorepoRoot = (directory) => {
|
|
2208
|
-
if (isFile(path.join(directory, "pnpm-workspace.yaml"))) return true;
|
|
2209
|
-
if (isFile(path.join(directory, "nx.json"))) return true;
|
|
2210
|
-
const packageJsonPath = path.join(directory, "package.json");
|
|
2208
|
+
if (isFile(path$1.join(directory, "pnpm-workspace.yaml"))) return true;
|
|
2209
|
+
if (isFile(path$1.join(directory, "nx.json"))) return true;
|
|
2210
|
+
const packageJsonPath = path$1.join(directory, "package.json");
|
|
2211
2211
|
if (!isFile(packageJsonPath)) return false;
|
|
2212
2212
|
const packageJson = readPackageJson(packageJsonPath);
|
|
2213
2213
|
return Array.isArray(packageJson.workspaces) || Boolean(packageJson.workspaces?.packages);
|
|
2214
2214
|
};
|
|
2215
2215
|
const findMonorepoRoot = (startDirectory) => {
|
|
2216
|
-
let currentDirectory = path.dirname(startDirectory);
|
|
2217
|
-
while (currentDirectory !== path.dirname(currentDirectory)) {
|
|
2216
|
+
let currentDirectory = path$1.dirname(startDirectory);
|
|
2217
|
+
while (currentDirectory !== path$1.dirname(currentDirectory)) {
|
|
2218
2218
|
if (isMonorepoRoot(currentDirectory)) return currentDirectory;
|
|
2219
|
-
currentDirectory = path.dirname(currentDirectory);
|
|
2219
|
+
currentDirectory = path$1.dirname(currentDirectory);
|
|
2220
2220
|
}
|
|
2221
2221
|
return null;
|
|
2222
2222
|
};
|
|
@@ -2230,7 +2230,7 @@ const findMonorepoRoot = (startDirectory) => {
|
|
|
2230
2230
|
* `detectReactCompiler`. All three previously inlined their own
|
|
2231
2231
|
* byte-equivalent copy.
|
|
2232
2232
|
*/
|
|
2233
|
-
const isProjectBoundary = (directory) => fs.existsSync(path.join(directory, ".git")) || isMonorepoRoot(directory);
|
|
2233
|
+
const isProjectBoundary = (directory) => fs$1.existsSync(path$1.join(directory, ".git")) || isMonorepoRoot(directory);
|
|
2234
2234
|
const REACT_COMPILER_PACKAGES = new Set([
|
|
2235
2235
|
"babel-plugin-react-compiler",
|
|
2236
2236
|
"react-compiler-runtime",
|
|
@@ -2277,10 +2277,10 @@ const hasCompilerPackage = (packageJson) => {
|
|
|
2277
2277
|
};
|
|
2278
2278
|
const hasCompilerInConfigFile = (filePath) => {
|
|
2279
2279
|
if (!isFile(filePath)) return false;
|
|
2280
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
2280
|
+
const content = fs$1.readFileSync(filePath, "utf-8");
|
|
2281
2281
|
return REACT_COMPILER_ENABLED_FLAG_PATTERN.test(content) || REACT_COMPILER_PACKAGE_REFERENCE_PATTERN.test(content);
|
|
2282
2282
|
};
|
|
2283
|
-
const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(path.join(directory, filename)));
|
|
2283
|
+
const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(path$1.join(directory, filename)));
|
|
2284
2284
|
const detectReactCompiler = (directory, packageJson) => {
|
|
2285
2285
|
if (hasCompilerPackage(packageJson)) return true;
|
|
2286
2286
|
if (hasCompilerInConfigFiles(directory, NEXT_CONFIG_FILENAMES)) return true;
|
|
@@ -2288,14 +2288,14 @@ const detectReactCompiler = (directory, packageJson) => {
|
|
|
2288
2288
|
if (hasCompilerInConfigFiles(directory, VITE_CONFIG_FILENAMES)) return true;
|
|
2289
2289
|
if (hasCompilerInConfigFiles(directory, EXPO_APP_CONFIG_FILENAMES)) return true;
|
|
2290
2290
|
if (isProjectBoundary(directory)) return false;
|
|
2291
|
-
let ancestorDirectory = path.dirname(directory);
|
|
2292
|
-
while (ancestorDirectory !== path.dirname(ancestorDirectory)) {
|
|
2293
|
-
const ancestorPackagePath = path.join(ancestorDirectory, "package.json");
|
|
2291
|
+
let ancestorDirectory = path$1.dirname(directory);
|
|
2292
|
+
while (ancestorDirectory !== path$1.dirname(ancestorDirectory)) {
|
|
2293
|
+
const ancestorPackagePath = path$1.join(ancestorDirectory, "package.json");
|
|
2294
2294
|
if (isFile(ancestorPackagePath)) {
|
|
2295
2295
|
if (hasCompilerPackage(readPackageJson(ancestorPackagePath))) return true;
|
|
2296
2296
|
}
|
|
2297
2297
|
if (isProjectBoundary(ancestorDirectory)) return false;
|
|
2298
|
-
ancestorDirectory = path.dirname(ancestorDirectory);
|
|
2298
|
+
ancestorDirectory = path$1.dirname(ancestorDirectory);
|
|
2299
2299
|
}
|
|
2300
2300
|
return false;
|
|
2301
2301
|
};
|
|
@@ -2481,12 +2481,12 @@ const resolveVersionFromCatalog = (catalog, packageName) => {
|
|
|
2481
2481
|
return null;
|
|
2482
2482
|
};
|
|
2483
2483
|
const parsePnpmWorkspaceCatalogs = (rootDirectory) => {
|
|
2484
|
-
const workspacePath = path.join(rootDirectory, "pnpm-workspace.yaml");
|
|
2484
|
+
const workspacePath = path$1.join(rootDirectory, "pnpm-workspace.yaml");
|
|
2485
2485
|
if (!isFile(workspacePath)) return {
|
|
2486
2486
|
defaultCatalog: {},
|
|
2487
2487
|
namedCatalogs: {}
|
|
2488
2488
|
};
|
|
2489
|
-
const content = fs.readFileSync(workspacePath, "utf-8");
|
|
2489
|
+
const content = fs$1.readFileSync(workspacePath, "utf-8");
|
|
2490
2490
|
const defaultCatalog = {};
|
|
2491
2491
|
const namedCatalogs = {};
|
|
2492
2492
|
let currentSection = "none";
|
|
@@ -2667,7 +2667,7 @@ const getDependencyDeclaration = ({ packageJson, packageName, sections }) => {
|
|
|
2667
2667
|
};
|
|
2668
2668
|
const isDirectory = (directoryPath) => {
|
|
2669
2669
|
try {
|
|
2670
|
-
return fs.statSync(directoryPath).isDirectory();
|
|
2670
|
+
return fs$1.statSync(directoryPath).isDirectory();
|
|
2671
2671
|
} catch {
|
|
2672
2672
|
return false;
|
|
2673
2673
|
}
|
|
@@ -2678,23 +2678,23 @@ const NX_PROJECT_DISCOVERY_DIRS = [
|
|
|
2678
2678
|
"packages"
|
|
2679
2679
|
];
|
|
2680
2680
|
const getNxWorkspaceDirectories = (rootDirectory) => {
|
|
2681
|
-
if (!isFile(path.join(rootDirectory, "nx.json"))) return [];
|
|
2681
|
+
if (!isFile(path$1.join(rootDirectory, "nx.json"))) return [];
|
|
2682
2682
|
const collected = [];
|
|
2683
2683
|
for (const candidate of NX_PROJECT_DISCOVERY_DIRS) {
|
|
2684
|
-
const candidatePath = path.join(rootDirectory, candidate);
|
|
2684
|
+
const candidatePath = path$1.join(rootDirectory, candidate);
|
|
2685
2685
|
if (!isDirectory(candidatePath)) continue;
|
|
2686
2686
|
for (const entry of readDirectoryEntries(candidatePath)) {
|
|
2687
2687
|
if (!entry.isDirectory()) continue;
|
|
2688
|
-
const projectDirectory = path.join(candidatePath, entry.name);
|
|
2689
|
-
if (isFile(path.join(projectDirectory, "project.json")) || isFile(path.join(projectDirectory, "package.json"))) collected.push(`${candidate}/${entry.name}`);
|
|
2688
|
+
const projectDirectory = path$1.join(candidatePath, entry.name);
|
|
2689
|
+
if (isFile(path$1.join(projectDirectory, "project.json")) || isFile(path$1.join(projectDirectory, "package.json"))) collected.push(`${candidate}/${entry.name}`);
|
|
2690
2690
|
}
|
|
2691
2691
|
}
|
|
2692
2692
|
return collected;
|
|
2693
2693
|
};
|
|
2694
2694
|
const parsePnpmWorkspacePatterns = (rootDirectory) => {
|
|
2695
|
-
const workspacePath = path.join(rootDirectory, "pnpm-workspace.yaml");
|
|
2695
|
+
const workspacePath = path$1.join(rootDirectory, "pnpm-workspace.yaml");
|
|
2696
2696
|
if (!isFile(workspacePath)) return [];
|
|
2697
|
-
const content = fs.readFileSync(workspacePath, "utf-8");
|
|
2697
|
+
const content = fs$1.readFileSync(workspacePath, "utf-8");
|
|
2698
2698
|
const patterns = [];
|
|
2699
2699
|
let isInsidePackagesBlock = false;
|
|
2700
2700
|
for (const line of content.split("\n")) {
|
|
@@ -2724,18 +2724,18 @@ const parseReactMajor = (reactVersion) => {
|
|
|
2724
2724
|
const resolveWorkspaceDirectories = (rootDirectory, pattern) => {
|
|
2725
2725
|
const cleanPattern = pattern.replace(/["']/g, "").replace(/\/\*\*$/, "/*");
|
|
2726
2726
|
if (!cleanPattern.includes("*")) {
|
|
2727
|
-
const directoryPath = path.join(rootDirectory, cleanPattern);
|
|
2728
|
-
if (isDirectory(directoryPath) && isFile(path.join(directoryPath, "package.json"))) return [directoryPath];
|
|
2727
|
+
const directoryPath = path$1.join(rootDirectory, cleanPattern);
|
|
2728
|
+
if (isDirectory(directoryPath) && isFile(path$1.join(directoryPath, "package.json"))) return [directoryPath];
|
|
2729
2729
|
return [];
|
|
2730
2730
|
}
|
|
2731
2731
|
const wildcardIndex = cleanPattern.indexOf("*");
|
|
2732
|
-
const baseDirectory = path.join(rootDirectory, cleanPattern.slice(0, wildcardIndex));
|
|
2732
|
+
const baseDirectory = path$1.join(rootDirectory, cleanPattern.slice(0, wildcardIndex));
|
|
2733
2733
|
const suffixAfterWildcard = cleanPattern.slice(wildcardIndex + 1);
|
|
2734
2734
|
if (!isDirectory(baseDirectory)) return [];
|
|
2735
2735
|
const resolved = [];
|
|
2736
2736
|
for (const entry of readDirectoryEntries(baseDirectory)) {
|
|
2737
|
-
const entryPath = path.join(baseDirectory, entry.name, suffixAfterWildcard);
|
|
2738
|
-
if (isDirectory(entryPath) && isFile(path.join(entryPath, "package.json"))) resolved.push(entryPath);
|
|
2737
|
+
const entryPath = path$1.join(baseDirectory, entry.name, suffixAfterWildcard);
|
|
2738
|
+
if (isDirectory(entryPath) && isFile(path$1.join(entryPath, "package.json"))) resolved.push(entryPath);
|
|
2739
2739
|
}
|
|
2740
2740
|
return resolved;
|
|
2741
2741
|
};
|
|
@@ -2762,7 +2762,7 @@ const findReactInWorkspaces = (rootDirectory, packageJson) => {
|
|
|
2762
2762
|
for (const pattern of patterns) {
|
|
2763
2763
|
const directories = resolveWorkspaceDirectories(rootDirectory, pattern);
|
|
2764
2764
|
for (const workspaceDirectory of directories) {
|
|
2765
|
-
const workspacePackageJson = readPackageJson(path.join(workspaceDirectory, "package.json"));
|
|
2765
|
+
const workspacePackageJson = readPackageJson(path$1.join(workspaceDirectory, "package.json"));
|
|
2766
2766
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
2767
2767
|
const reactVersion = resolveWorkspaceDependencyVersion({
|
|
2768
2768
|
concreteVersion: info.reactVersion,
|
|
@@ -2816,11 +2816,11 @@ const findReactInWorkspaces = (rootDirectory, packageJson) => {
|
|
|
2816
2816
|
const findDependencyInfoFromMonorepoRoot = (directory) => {
|
|
2817
2817
|
const monorepoRoot = findMonorepoRoot(directory);
|
|
2818
2818
|
if (!monorepoRoot) return EMPTY_DEPENDENCY_INFO;
|
|
2819
|
-
const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
|
|
2819
|
+
const monorepoPackageJsonPath = path$1.join(monorepoRoot, "package.json");
|
|
2820
2820
|
if (!isFile(monorepoPackageJsonPath)) return EMPTY_DEPENDENCY_INFO;
|
|
2821
2821
|
const rootPackageJson = readPackageJson(monorepoPackageJsonPath);
|
|
2822
2822
|
const rootInfo = extractDependencyInfo(rootPackageJson);
|
|
2823
|
-
const leafPackageJsonPath = path.join(directory, "package.json");
|
|
2823
|
+
const leafPackageJsonPath = path$1.join(directory, "package.json");
|
|
2824
2824
|
const leafPackageJson = isFile(leafPackageJsonPath) ? readPackageJson(leafPackageJsonPath) : null;
|
|
2825
2825
|
const leafReactDeclaration = leafPackageJson ? getDependencyDeclaration({
|
|
2826
2826
|
packageJson: leafPackageJson,
|
|
@@ -2874,7 +2874,7 @@ const findInWorkspacePackageJsons = (rootDirectory, rootPackageJson, select) =>
|
|
|
2874
2874
|
for (const workspaceDirectory of directories) {
|
|
2875
2875
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
2876
2876
|
visitedDirectories.add(workspaceDirectory);
|
|
2877
|
-
const value = select(readPackageJson(path.join(workspaceDirectory, "package.json")));
|
|
2877
|
+
const value = select(readPackageJson(path$1.join(workspaceDirectory, "package.json")));
|
|
2878
2878
|
if (value !== null) return value;
|
|
2879
2879
|
}
|
|
2880
2880
|
}
|
|
@@ -3006,7 +3006,7 @@ const hasReactDependency = (packageJson) => {
|
|
|
3006
3006
|
return Object.keys(allDependencies).some((packageName) => REACT_DEPENDENCY_NAMES.has(packageName));
|
|
3007
3007
|
};
|
|
3008
3008
|
const listWorkspacePackages = (rootDirectory) => {
|
|
3009
|
-
const packageJsonPath = path.join(rootDirectory, "package.json");
|
|
3009
|
+
const packageJsonPath = path$1.join(rootDirectory, "package.json");
|
|
3010
3010
|
if (!isFile(packageJsonPath)) return [];
|
|
3011
3011
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3012
3012
|
const patterns = getWorkspacePatterns(rootDirectory, packageJson);
|
|
@@ -3019,16 +3019,16 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
3019
3019
|
packages.push(workspacePackage);
|
|
3020
3020
|
};
|
|
3021
3021
|
if (hasReactDependency(packageJson)) pushIfNew({
|
|
3022
|
-
name: packageJson.name ?? path.basename(rootDirectory),
|
|
3022
|
+
name: packageJson.name ?? path$1.basename(rootDirectory),
|
|
3023
3023
|
directory: rootDirectory
|
|
3024
3024
|
});
|
|
3025
3025
|
for (const pattern of patterns) {
|
|
3026
3026
|
const directories = resolveWorkspaceDirectories(rootDirectory, pattern);
|
|
3027
3027
|
for (const workspaceDirectory of directories) {
|
|
3028
|
-
const workspacePackageJson = readPackageJson(path.join(workspaceDirectory, "package.json"));
|
|
3028
|
+
const workspacePackageJson = readPackageJson(path$1.join(workspaceDirectory, "package.json"));
|
|
3029
3029
|
if (!hasReactDependency(workspacePackageJson)) continue;
|
|
3030
3030
|
pushIfNew({
|
|
3031
|
-
name: workspacePackageJson.name ?? path.basename(workspaceDirectory),
|
|
3031
|
+
name: workspacePackageJson.name ?? path$1.basename(workspaceDirectory),
|
|
3032
3032
|
directory: workspaceDirectory
|
|
3033
3033
|
});
|
|
3034
3034
|
}
|
|
@@ -3038,11 +3038,11 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
3038
3038
|
const toReactWorkspacePackages = (directories) => {
|
|
3039
3039
|
const packages = [];
|
|
3040
3040
|
for (const directory of directories) {
|
|
3041
|
-
const packageJsonPath = path.join(directory, "package.json");
|
|
3041
|
+
const packageJsonPath = path$1.join(directory, "package.json");
|
|
3042
3042
|
if (!isFile(packageJsonPath)) continue;
|
|
3043
3043
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3044
3044
|
if (!hasReactDependency(packageJson)) continue;
|
|
3045
|
-
const name = packageJson.name ?? path.basename(directory);
|
|
3045
|
+
const name = packageJson.name ?? path$1.basename(directory);
|
|
3046
3046
|
packages.push({
|
|
3047
3047
|
name,
|
|
3048
3048
|
directory
|
|
@@ -3051,7 +3051,7 @@ const toReactWorkspacePackages = (directories) => {
|
|
|
3051
3051
|
return packages;
|
|
3052
3052
|
};
|
|
3053
3053
|
const listManifestWorkspacePackages = (rootDirectory) => {
|
|
3054
|
-
if (isFile(path.join(rootDirectory, "package.json"))) return listWorkspacePackages(rootDirectory);
|
|
3054
|
+
if (isFile(path$1.join(rootDirectory, "package.json"))) return listWorkspacePackages(rootDirectory);
|
|
3055
3055
|
const patterns = parsePnpmWorkspacePatterns(rootDirectory);
|
|
3056
3056
|
const nxPatterns = patterns.length > 0 ? [] : getNxWorkspaceDirectories(rootDirectory);
|
|
3057
3057
|
return toReactWorkspacePackages((patterns.length > 0 ? patterns : nxPatterns).flatMap((pattern) => resolveWorkspaceDirectories(rootDirectory, pattern)));
|
|
@@ -3072,11 +3072,11 @@ const discoverReactSubprojectsByFilesystem = (rootDirectory) => {
|
|
|
3072
3072
|
const current = pendingDirectories.pop();
|
|
3073
3073
|
if (!current) continue;
|
|
3074
3074
|
const { directory: currentDirectory, depth } = current;
|
|
3075
|
-
const packageJsonPath = path.join(currentDirectory, "package.json");
|
|
3075
|
+
const packageJsonPath = path$1.join(currentDirectory, "package.json");
|
|
3076
3076
|
if (isFile(packageJsonPath)) {
|
|
3077
3077
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3078
3078
|
if (hasReactDependency(packageJson)) {
|
|
3079
|
-
const name = packageJson.name ?? path.basename(currentDirectory);
|
|
3079
|
+
const name = packageJson.name ?? path$1.basename(currentDirectory);
|
|
3080
3080
|
packages.push({
|
|
3081
3081
|
name,
|
|
3082
3082
|
directory: currentDirectory
|
|
@@ -3088,7 +3088,7 @@ const discoverReactSubprojectsByFilesystem = (rootDirectory) => {
|
|
|
3088
3088
|
for (const entry of entries) {
|
|
3089
3089
|
if (!entry.isDirectory() || entry.name.startsWith(".") || IGNORED_DIRECTORIES.has(entry.name) || NON_PROJECT_DIRECTORIES.has(entry.name)) continue;
|
|
3090
3090
|
pendingDirectories.push({
|
|
3091
|
-
directory: path.join(currentDirectory, entry.name),
|
|
3091
|
+
directory: path$1.join(currentDirectory, entry.name),
|
|
3092
3092
|
depth: depth + 1
|
|
3093
3093
|
});
|
|
3094
3094
|
}
|
|
@@ -3108,7 +3108,7 @@ const clearProjectCache = () => {
|
|
|
3108
3108
|
const discoverProject = (directory) => {
|
|
3109
3109
|
const cached = cachedProjectInfos.get(directory);
|
|
3110
3110
|
if (cached !== void 0) return cached;
|
|
3111
|
-
const packageJsonPath = path.join(directory, "package.json");
|
|
3111
|
+
const packageJsonPath = path$1.join(directory, "package.json");
|
|
3112
3112
|
if (!isFile(packageJsonPath)) throw new PackageJsonNotFoundError(directory);
|
|
3113
3113
|
const packageJson = readPackageJson(packageJsonPath);
|
|
3114
3114
|
let { reactVersion, tailwindVersion, zodVersion, framework } = extractDependencyInfo(packageJson);
|
|
@@ -3145,7 +3145,7 @@ const discoverProject = (directory) => {
|
|
|
3145
3145
|
if (!reactVersion || !tailwindVersion || !zodVersion) {
|
|
3146
3146
|
const monorepoRoot = findMonorepoRoot(directory);
|
|
3147
3147
|
if (monorepoRoot) {
|
|
3148
|
-
const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
|
|
3148
|
+
const monorepoPackageJsonPath = path$1.join(monorepoRoot, "package.json");
|
|
3149
3149
|
if (isFile(monorepoPackageJsonPath)) {
|
|
3150
3150
|
const rootPackageJson = readPackageJson(monorepoPackageJsonPath);
|
|
3151
3151
|
if (!reactVersion && reactDeclaration.hasDeclaration) reactVersion = resolveCatalogVersion(rootPackageJson, "react", monorepoRoot, reactDeclaration.catalogReference);
|
|
@@ -3171,8 +3171,8 @@ const discoverProject = (directory) => {
|
|
|
3171
3171
|
if (!reactVersion && reactDeclaration.version && !isCatalogReference(reactDeclaration.version)) reactVersion = reactDeclaration.version;
|
|
3172
3172
|
if (!tailwindVersion && tailwindDeclaration.version && !isCatalogReference(tailwindDeclaration.version)) tailwindVersion = tailwindDeclaration.version;
|
|
3173
3173
|
if (!zodVersion && zodDeclaration.version && !isCatalogReference(zodDeclaration.version)) zodVersion = zodDeclaration.version;
|
|
3174
|
-
const projectName = packageJson.name ?? path.basename(directory);
|
|
3175
|
-
const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
|
|
3174
|
+
const projectName = packageJson.name ?? path$1.basename(directory);
|
|
3175
|
+
const hasTypeScript = fs$1.existsSync(path$1.join(directory, "tsconfig.json"));
|
|
3176
3176
|
const sourceFileCount = countSourceFiles(directory);
|
|
3177
3177
|
const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
|
|
3178
3178
|
const expoVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
@@ -3814,12 +3814,12 @@ const findNearestPackageDirectory = (filename) => {
|
|
|
3814
3814
|
if (!filename) return null;
|
|
3815
3815
|
const fromCache = cachedPackageDirectoryByFilename.get(filename);
|
|
3816
3816
|
if (fromCache !== void 0) return fromCache;
|
|
3817
|
-
let currentDirectory = path.dirname(filename);
|
|
3817
|
+
let currentDirectory = path$1.dirname(filename);
|
|
3818
3818
|
while (true) {
|
|
3819
|
-
const candidatePackageJsonPath = path.join(currentDirectory, "package.json");
|
|
3819
|
+
const candidatePackageJsonPath = path$1.join(currentDirectory, "package.json");
|
|
3820
3820
|
let hasPackageJson = false;
|
|
3821
3821
|
try {
|
|
3822
|
-
hasPackageJson = fs.statSync(candidatePackageJsonPath).isFile();
|
|
3822
|
+
hasPackageJson = fs$1.statSync(candidatePackageJsonPath).isFile();
|
|
3823
3823
|
} catch {
|
|
3824
3824
|
hasPackageJson = false;
|
|
3825
3825
|
}
|
|
@@ -3827,7 +3827,7 @@ const findNearestPackageDirectory = (filename) => {
|
|
|
3827
3827
|
cachedPackageDirectoryByFilename.set(filename, currentDirectory);
|
|
3828
3828
|
return currentDirectory;
|
|
3829
3829
|
}
|
|
3830
|
-
const parentDirectory = path.dirname(currentDirectory);
|
|
3830
|
+
const parentDirectory = path$1.dirname(currentDirectory);
|
|
3831
3831
|
if (parentDirectory === currentDirectory) {
|
|
3832
3832
|
cachedPackageDirectoryByFilename.set(filename, null);
|
|
3833
3833
|
return null;
|
|
@@ -3837,7 +3837,7 @@ const findNearestPackageDirectory = (filename) => {
|
|
|
3837
3837
|
};
|
|
3838
3838
|
const readManifest = (packageJsonPath) => {
|
|
3839
3839
|
try {
|
|
3840
|
-
const parsed = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
3840
|
+
const parsed = JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8"));
|
|
3841
3841
|
if (typeof parsed === "object" && parsed !== null) return parsed;
|
|
3842
3842
|
return null;
|
|
3843
3843
|
} catch {
|
|
@@ -3848,8 +3848,8 @@ const hasPublishContract = (manifest) => typeof manifest.name === "string" && ma
|
|
|
3848
3848
|
const classifyByDirectoryCohort = (packageDirectory) => {
|
|
3849
3849
|
let current = packageDirectory;
|
|
3850
3850
|
while (true) {
|
|
3851
|
-
if (path.basename(current) === "apps") return "app";
|
|
3852
|
-
const parent = path.dirname(current);
|
|
3851
|
+
if (path$1.basename(current) === "apps") return "app";
|
|
3852
|
+
const parent = path$1.dirname(current);
|
|
3853
3853
|
if (parent === current) return null;
|
|
3854
3854
|
current = parent;
|
|
3855
3855
|
}
|
|
@@ -3864,10 +3864,10 @@ const classifyPackageRole = (filename) => {
|
|
|
3864
3864
|
if (!packageDirectory) return "unknown";
|
|
3865
3865
|
const cached = cachedRoleByPackageDirectory.get(packageDirectory);
|
|
3866
3866
|
if (cached !== void 0) return cached;
|
|
3867
|
-
const manifest = readManifest(path.join(packageDirectory, "package.json"));
|
|
3867
|
+
const manifest = readManifest(path$1.join(packageDirectory, "package.json"));
|
|
3868
3868
|
let result;
|
|
3869
3869
|
if (manifest && hasPublishContract(manifest)) result = "library";
|
|
3870
|
-
else result = classifyByDirectoryCohort(path.dirname(packageDirectory)) ?? "unknown";
|
|
3870
|
+
else result = classifyByDirectoryCohort(path$1.dirname(packageDirectory)) ?? "unknown";
|
|
3871
3871
|
cachedRoleByPackageDirectory.set(packageDirectory, result);
|
|
3872
3872
|
return result;
|
|
3873
3873
|
};
|
|
@@ -4519,12 +4519,12 @@ const loadModuleConfig = async (filePath) => {
|
|
|
4519
4519
|
const imported = await jiti.import(filePath);
|
|
4520
4520
|
return imported?.default ?? imported;
|
|
4521
4521
|
};
|
|
4522
|
-
const readDataConfig = (filePath) => parseJSON5(fs.readFileSync(filePath, "utf-8"));
|
|
4522
|
+
const readDataConfig = (filePath) => parseJSON5(fs$1.readFileSync(filePath, "utf-8"));
|
|
4523
4523
|
const readEmbeddedPackageJsonConfig = (directory) => {
|
|
4524
|
-
const packageJsonPath = path.join(directory, PACKAGE_JSON_FILENAME);
|
|
4524
|
+
const packageJsonPath = path$1.join(directory, PACKAGE_JSON_FILENAME);
|
|
4525
4525
|
if (!isFile(packageJsonPath)) return null;
|
|
4526
4526
|
try {
|
|
4527
|
-
const packageJson = parseJSON5(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
4527
|
+
const packageJson = parseJSON5(fs$1.readFileSync(packageJsonPath, "utf-8"));
|
|
4528
4528
|
if (isPlainObject(packageJson)) {
|
|
4529
4529
|
const embeddedConfig = packageJson[PACKAGE_JSON_CONFIG_KEY];
|
|
4530
4530
|
if (isPlainObject(embeddedConfig)) return embeddedConfig;
|
|
@@ -4538,14 +4538,14 @@ const loadPackageJsonConfig = (directory) => {
|
|
|
4538
4538
|
return {
|
|
4539
4539
|
config: validateConfigTypes(embeddedConfig),
|
|
4540
4540
|
sourceDirectory: directory,
|
|
4541
|
-
configFilePath: path.join(directory, PACKAGE_JSON_FILENAME),
|
|
4541
|
+
configFilePath: path$1.join(directory, PACKAGE_JSON_FILENAME),
|
|
4542
4542
|
format: "package-json"
|
|
4543
4543
|
};
|
|
4544
4544
|
};
|
|
4545
4545
|
const loadConfigFromDirectory = async (directory) => {
|
|
4546
4546
|
let sawBrokenConfigFile = false;
|
|
4547
4547
|
for (const extension of CONFIG_EXTENSIONS) {
|
|
4548
|
-
const filePath = path.join(directory, `${CONFIG_BASENAME}.${extension}`);
|
|
4548
|
+
const filePath = path$1.join(directory, `${CONFIG_BASENAME}.${extension}`);
|
|
4549
4549
|
if (!isFile(filePath)) continue;
|
|
4550
4550
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
4551
4551
|
try {
|
|
@@ -4571,7 +4571,7 @@ const loadConfigFromDirectory = async (directory) => {
|
|
|
4571
4571
|
status: "found",
|
|
4572
4572
|
loaded: packageJsonConfig
|
|
4573
4573
|
};
|
|
4574
|
-
if (isFile(path.join(directory, LEGACY_CONFIG_FILENAME))) warn(`${LEGACY_CONFIG_FILENAME} is no longer read — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts).`);
|
|
4574
|
+
if (isFile(path$1.join(directory, LEGACY_CONFIG_FILENAME))) warn(`${LEGACY_CONFIG_FILENAME} is no longer read — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts).`);
|
|
4575
4575
|
return {
|
|
4576
4576
|
status: sawBrokenConfigFile ? "invalid" : "absent",
|
|
4577
4577
|
loaded: null
|
|
@@ -4585,12 +4585,12 @@ const loadConfigWalkingUp = async (rootDirectory) => {
|
|
|
4585
4585
|
const localResult = await loadConfigFromDirectory(rootDirectory);
|
|
4586
4586
|
if (localResult.status === "found") return localResult.loaded;
|
|
4587
4587
|
if (localResult.status === "invalid" || isProjectBoundary(rootDirectory)) return null;
|
|
4588
|
-
let ancestorDirectory = path.dirname(rootDirectory);
|
|
4589
|
-
while (ancestorDirectory !== path.dirname(ancestorDirectory)) {
|
|
4588
|
+
let ancestorDirectory = path$1.dirname(rootDirectory);
|
|
4589
|
+
while (ancestorDirectory !== path$1.dirname(ancestorDirectory)) {
|
|
4590
4590
|
const ancestorResult = await loadConfigFromDirectory(ancestorDirectory);
|
|
4591
4591
|
if (ancestorResult.status === "found") return ancestorResult.loaded;
|
|
4592
4592
|
if (isProjectBoundary(ancestorDirectory)) return null;
|
|
4593
|
-
ancestorDirectory = path.dirname(ancestorDirectory);
|
|
4593
|
+
ancestorDirectory = path$1.dirname(ancestorDirectory);
|
|
4594
4594
|
}
|
|
4595
4595
|
return null;
|
|
4596
4596
|
};
|
|
@@ -4607,7 +4607,7 @@ const resolveConfigRootDir = (config, configSourceDirectory) => {
|
|
|
4607
4607
|
if (typeof rawRootDir !== "string") return null;
|
|
4608
4608
|
const trimmedRootDir = rawRootDir.trim();
|
|
4609
4609
|
if (trimmedRootDir.length === 0) return null;
|
|
4610
|
-
const resolvedRootDir = path.isAbsolute(trimmedRootDir) ? trimmedRootDir : path.resolve(configSourceDirectory, trimmedRootDir);
|
|
4610
|
+
const resolvedRootDir = path$1.isAbsolute(trimmedRootDir) ? trimmedRootDir : path$1.resolve(configSourceDirectory, trimmedRootDir);
|
|
4611
4611
|
if (resolvedRootDir === configSourceDirectory) return null;
|
|
4612
4612
|
if (!isDirectory(resolvedRootDir)) {
|
|
4613
4613
|
Effect.runSync(Console.warn(`react-doctor config "rootDir" points to "${rawRootDir}" (resolved to ${resolvedRootDir}), which is not a directory. Ignoring.`));
|
|
@@ -4616,12 +4616,12 @@ const resolveConfigRootDir = (config, configSourceDirectory) => {
|
|
|
4616
4616
|
return resolvedRootDir;
|
|
4617
4617
|
};
|
|
4618
4618
|
const resolveDiagnoseTarget = (directory, options = {}) => {
|
|
4619
|
-
if (isFile(path.join(directory, "package.json"))) return directory;
|
|
4619
|
+
if (isFile(path$1.join(directory, "package.json"))) return directory;
|
|
4620
4620
|
const reactSubprojects = discoverReactSubprojects(directory);
|
|
4621
4621
|
if (reactSubprojects.length === 0) return null;
|
|
4622
4622
|
if (reactSubprojects.length === 1) return reactSubprojects[0].directory;
|
|
4623
4623
|
if (options.allowAmbiguous === true) return null;
|
|
4624
|
-
throw new AmbiguousProjectError(directory, reactSubprojects.map((subproject) => path.relative(directory, subproject.directory)).toSorted());
|
|
4624
|
+
throw new AmbiguousProjectError(directory, reactSubprojects.map((subproject) => path$1.relative(directory, subproject.directory)).toSorted());
|
|
4625
4625
|
};
|
|
4626
4626
|
/**
|
|
4627
4627
|
* The canonical entry-point translation shared by every public shell
|
|
@@ -4647,14 +4647,14 @@ const resolveDiagnoseTarget = (directory, options = {}) => {
|
|
|
4647
4647
|
* shell in agreement on what "the scan directory" means.
|
|
4648
4648
|
*/
|
|
4649
4649
|
const resolveScanTarget = async (requestedDirectory, options = {}) => {
|
|
4650
|
-
const absoluteRequested = path.resolve(requestedDirectory);
|
|
4650
|
+
const absoluteRequested = path$1.resolve(requestedDirectory);
|
|
4651
4651
|
const loadedConfig = await loadConfigWithSource(absoluteRequested);
|
|
4652
4652
|
const userConfig = loadedConfig?.config ?? null;
|
|
4653
4653
|
const configSourceDirectory = loadedConfig?.sourceDirectory ?? null;
|
|
4654
4654
|
const redirectedDirectory = resolveConfigRootDir(userConfig, configSourceDirectory);
|
|
4655
4655
|
const directoryAfterRedirect = redirectedDirectory ?? absoluteRequested;
|
|
4656
4656
|
const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect, options) ?? directoryAfterRedirect;
|
|
4657
|
-
if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
|
|
4657
|
+
if (!isDirectory(resolvedDirectory)) throw fs$1.existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
|
|
4658
4658
|
return {
|
|
4659
4659
|
resolvedDirectory,
|
|
4660
4660
|
requestedDirectory: absoluteRequested,
|
|
@@ -4665,7 +4665,7 @@ const resolveScanTarget = async (requestedDirectory, options = {}) => {
|
|
|
4665
4665
|
};
|
|
4666
4666
|
const getDirectDependencyNames = (packageJson) => new Set([...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.devDependencies ?? {})]);
|
|
4667
4667
|
const buildExpoCheckContext = (rootDirectory, expoVersion) => {
|
|
4668
|
-
const packageJson = readPackageJson(path.join(rootDirectory, "package.json"));
|
|
4668
|
+
const packageJson = readPackageJson(path$1.join(rootDirectory, "package.json"));
|
|
4669
4669
|
return {
|
|
4670
4670
|
rootDirectory,
|
|
4671
4671
|
packageJson,
|
|
@@ -4735,7 +4735,7 @@ const LOCAL_ENV_FILE_NAMES = [
|
|
|
4735
4735
|
const checkExpoEnvLocalFiles = (context) => {
|
|
4736
4736
|
const { rootDirectory } = context;
|
|
4737
4737
|
const committedEnvFiles = LOCAL_ENV_FILE_NAMES.filter((fileName) => {
|
|
4738
|
-
const filePath = path.join(rootDirectory, fileName);
|
|
4738
|
+
const filePath = path$1.join(rootDirectory, fileName);
|
|
4739
4739
|
if (!isFile(filePath)) return false;
|
|
4740
4740
|
return isPathGitIgnored(rootDirectory, filePath) === false;
|
|
4741
4741
|
});
|
|
@@ -4869,17 +4869,17 @@ const checkExpoFlaggedDependencies = (context) => FLAGGED_DEPENDENCIES.filter((f
|
|
|
4869
4869
|
help: flaggedDependency.help
|
|
4870
4870
|
}));
|
|
4871
4871
|
const findLocalModuleNativeFiles = (rootDirectory) => {
|
|
4872
|
-
const modulesDirectory = path.join(rootDirectory, "modules");
|
|
4872
|
+
const modulesDirectory = path$1.join(rootDirectory, "modules");
|
|
4873
4873
|
if (!isDirectory(modulesDirectory)) return [];
|
|
4874
4874
|
const nativeFilePaths = [];
|
|
4875
4875
|
for (const moduleEntry of readDirectoryEntries(modulesDirectory)) {
|
|
4876
4876
|
if (!moduleEntry.isDirectory()) continue;
|
|
4877
|
-
const moduleDirectory = path.join(modulesDirectory, moduleEntry.name);
|
|
4878
|
-
const gradlePath = path.join(moduleDirectory, "android", "build.gradle");
|
|
4877
|
+
const moduleDirectory = path$1.join(modulesDirectory, moduleEntry.name);
|
|
4878
|
+
const gradlePath = path$1.join(moduleDirectory, "android", "build.gradle");
|
|
4879
4879
|
if (isFile(gradlePath)) nativeFilePaths.push(gradlePath);
|
|
4880
|
-
const iosDirectory = path.join(moduleDirectory, "ios");
|
|
4880
|
+
const iosDirectory = path$1.join(moduleDirectory, "ios");
|
|
4881
4881
|
if (isDirectory(iosDirectory)) {
|
|
4882
|
-
for (const iosEntry of readDirectoryEntries(iosDirectory)) if (iosEntry.isFile() && iosEntry.name.endsWith(".podspec")) nativeFilePaths.push(path.join(iosDirectory, iosEntry.name));
|
|
4882
|
+
for (const iosEntry of readDirectoryEntries(iosDirectory)) if (iosEntry.isFile() && iosEntry.name.endsWith(".podspec")) nativeFilePaths.push(path$1.join(iosDirectory, iosEntry.name));
|
|
4883
4883
|
}
|
|
4884
4884
|
}
|
|
4885
4885
|
return nativeFilePaths;
|
|
@@ -4887,7 +4887,7 @@ const findLocalModuleNativeFiles = (rootDirectory) => {
|
|
|
4887
4887
|
const checkExpoGitignore = (context) => {
|
|
4888
4888
|
const { rootDirectory } = context;
|
|
4889
4889
|
const diagnostics = [];
|
|
4890
|
-
const expoStateDirectory = path.join(rootDirectory, ".expo");
|
|
4890
|
+
const expoStateDirectory = path$1.join(rootDirectory, ".expo");
|
|
4891
4891
|
if (isDirectory(expoStateDirectory) && isPathGitIgnored(rootDirectory, expoStateDirectory) === false) diagnostics.push(buildExpoDiagnostic({
|
|
4892
4892
|
rule: "expo-gitignore",
|
|
4893
4893
|
message: "The `.expo` directory is not ignored by Git — it holds machine-specific device history and dev-server settings that should not be committed",
|
|
@@ -4909,7 +4909,7 @@ const LOCKFILE_NAMES = [
|
|
|
4909
4909
|
];
|
|
4910
4910
|
const checkExpoLockfile = (context) => {
|
|
4911
4911
|
const workspaceRoot = isMonorepoRoot(context.rootDirectory) ? context.rootDirectory : findMonorepoRoot(context.rootDirectory) ?? context.rootDirectory;
|
|
4912
|
-
const presentLockfiles = LOCKFILE_NAMES.filter((lockfileName) => isFile(path.join(workspaceRoot, lockfileName)));
|
|
4912
|
+
const presentLockfiles = LOCKFILE_NAMES.filter((lockfileName) => isFile(path$1.join(workspaceRoot, lockfileName)));
|
|
4913
4913
|
if (presentLockfiles.length === 0) return [buildExpoDiagnostic({
|
|
4914
4914
|
rule: "expo-lockfile",
|
|
4915
4915
|
message: "No lock file detected at the project root — installs are not reproducible, and EAS Build cannot infer your package manager",
|
|
@@ -4934,18 +4934,18 @@ const EXPO_METRO_CONFIG_EXTEND_SIGNALS = [
|
|
|
4934
4934
|
"getSentryExpoConfig"
|
|
4935
4935
|
];
|
|
4936
4936
|
const checkExpoMetroConfig = (context) => {
|
|
4937
|
-
const metroConfigPath = METRO_CONFIG_FILE_NAMES.map((fileName) => path.join(context.rootDirectory, fileName)).find((candidatePath) => isFile(candidatePath));
|
|
4937
|
+
const metroConfigPath = METRO_CONFIG_FILE_NAMES.map((fileName) => path$1.join(context.rootDirectory, fileName)).find((candidatePath) => isFile(candidatePath));
|
|
4938
4938
|
if (metroConfigPath === void 0) return [];
|
|
4939
4939
|
let contents;
|
|
4940
4940
|
try {
|
|
4941
|
-
contents = fs.readFileSync(metroConfigPath, "utf-8");
|
|
4941
|
+
contents = fs$1.readFileSync(metroConfigPath, "utf-8");
|
|
4942
4942
|
} catch {
|
|
4943
4943
|
return [];
|
|
4944
4944
|
}
|
|
4945
4945
|
if (EXPO_METRO_CONFIG_EXTEND_SIGNALS.some((signal) => contents.includes(signal))) return [];
|
|
4946
4946
|
return [buildExpoDiagnostic({
|
|
4947
4947
|
rule: "expo-metro-config",
|
|
4948
|
-
filePath: path.basename(metroConfigPath),
|
|
4948
|
+
filePath: path$1.basename(metroConfigPath),
|
|
4949
4949
|
message: "Your metro.config does not extend `expo/metro-config` — a custom Metro config that doesn't extend Expo's leads to unexpected, hard-to-debug bundling issues",
|
|
4950
4950
|
help: "Update your metro config to extend `expo/metro-config`. See https://docs.expo.dev/guides/customizing-metro/"
|
|
4951
4951
|
})];
|
|
@@ -4991,16 +4991,16 @@ const NO_CONFIG = {
|
|
|
4991
4991
|
const decodeExpoConfig = (filePath) => {
|
|
4992
4992
|
let raw;
|
|
4993
4993
|
try {
|
|
4994
|
-
raw = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
4994
|
+
raw = JSON.parse(fs$1.readFileSync(filePath, "utf-8"));
|
|
4995
4995
|
} catch {
|
|
4996
4996
|
return null;
|
|
4997
4997
|
}
|
|
4998
4998
|
return Option.getOrNull(Schema.decodeUnknownOption(AppManifestSchema)(raw))?.expo ?? null;
|
|
4999
4999
|
};
|
|
5000
5000
|
const readExpoAppConfig = (rootDirectory) => {
|
|
5001
|
-
if (APP_CONFIG_DYNAMIC_FILES.some((fileName) => isFile(path.join(rootDirectory, fileName)))) return NO_CONFIG;
|
|
5001
|
+
if (APP_CONFIG_DYNAMIC_FILES.some((fileName) => isFile(path$1.join(rootDirectory, fileName)))) return NO_CONFIG;
|
|
5002
5002
|
for (const fileName of APP_CONFIG_JSON_FILES) {
|
|
5003
|
-
const filePath = path.join(rootDirectory, fileName);
|
|
5003
|
+
const filePath = path$1.join(rootDirectory, fileName);
|
|
5004
5004
|
if (!isFile(filePath)) continue;
|
|
5005
5005
|
const config = decodeExpoConfig(filePath);
|
|
5006
5006
|
if (config) return {
|
|
@@ -5147,12 +5147,12 @@ const parseHardeningSettings = (content) => {
|
|
|
5147
5147
|
};
|
|
5148
5148
|
};
|
|
5149
5149
|
const isPnpmManagedProject = (rootDirectory) => {
|
|
5150
|
-
if (isFile(path.join(rootDirectory, PNPM_LOCKFILE))) return true;
|
|
5151
|
-
if (isFile(path.join(rootDirectory, PNPM_WORKSPACE_FILE))) return true;
|
|
5152
|
-
const packageJsonPath = path.join(rootDirectory, PACKAGE_JSON_FILE);
|
|
5150
|
+
if (isFile(path$1.join(rootDirectory, PNPM_LOCKFILE))) return true;
|
|
5151
|
+
if (isFile(path$1.join(rootDirectory, PNPM_WORKSPACE_FILE))) return true;
|
|
5152
|
+
const packageJsonPath = path$1.join(rootDirectory, PACKAGE_JSON_FILE);
|
|
5153
5153
|
if (!isFile(packageJsonPath)) return false;
|
|
5154
5154
|
try {
|
|
5155
|
-
const packageJsonRaw = fs.readFileSync(packageJsonPath, "utf-8");
|
|
5155
|
+
const packageJsonRaw = fs$1.readFileSync(packageJsonPath, "utf-8");
|
|
5156
5156
|
const packageJson = JSON.parse(packageJsonRaw);
|
|
5157
5157
|
if (packageJson !== null && typeof packageJson === "object" && "packageManager" in packageJson && typeof packageJson.packageManager === "string" && packageJson.packageManager.startsWith("pnpm@")) return true;
|
|
5158
5158
|
} catch {
|
|
@@ -5173,8 +5173,8 @@ const buildHardeningDiagnostic = (input) => ({
|
|
|
5173
5173
|
});
|
|
5174
5174
|
const checkPnpmHardening = (rootDirectory) => {
|
|
5175
5175
|
if (!isPnpmManagedProject(rootDirectory)) return [];
|
|
5176
|
-
const workspacePath = path.join(rootDirectory, PNPM_WORKSPACE_FILE);
|
|
5177
|
-
const settings = parseHardeningSettings(isFile(workspacePath) ? fs.readFileSync(workspacePath, "utf-8") : "");
|
|
5176
|
+
const workspacePath = path$1.join(rootDirectory, PNPM_WORKSPACE_FILE);
|
|
5177
|
+
const settings = parseHardeningSettings(isFile(workspacePath) ? fs$1.readFileSync(workspacePath, "utf-8") : "");
|
|
5178
5178
|
const diagnostics = [];
|
|
5179
5179
|
if (settings.minimumReleaseAge === null) diagnostics.push(buildHardeningDiagnostic({
|
|
5180
5180
|
message: "pnpm-workspace.yaml is missing `minimumReleaseAge` — newly published versions can ship malware that gets caught and unpublished within hours",
|
|
@@ -5204,7 +5204,7 @@ const isBuilderBobLibrary = (packageJson) => {
|
|
|
5204
5204
|
return typeof bobConfig === "object" && bobConfig !== null;
|
|
5205
5205
|
};
|
|
5206
5206
|
const checkReactNativeLibraryDependencies = (rootDirectory) => {
|
|
5207
|
-
const packageJson = readPackageJson(path.join(rootDirectory, "package.json"));
|
|
5207
|
+
const packageJson = readPackageJson(path$1.join(rootDirectory, "package.json"));
|
|
5208
5208
|
if (!isBuilderBobLibrary(packageJson)) return [];
|
|
5209
5209
|
const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
|
|
5210
5210
|
if (misplaced.length === 0) return [];
|
|
@@ -5233,11 +5233,11 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
5233
5233
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
5234
5234
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
5235
5235
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
5236
|
-
const filePath = path.join(rootDirectory, fileName);
|
|
5236
|
+
const filePath = path$1.join(rootDirectory, fileName);
|
|
5237
5237
|
if (!isFile(filePath)) continue;
|
|
5238
5238
|
let contents;
|
|
5239
5239
|
try {
|
|
5240
|
-
contents = fs.readFileSync(filePath, "utf-8");
|
|
5240
|
+
contents = fs$1.readFileSync(filePath, "utf-8");
|
|
5241
5241
|
} catch {
|
|
5242
5242
|
continue;
|
|
5243
5243
|
}
|
|
@@ -5282,7 +5282,7 @@ const MISSING_REDUCED_MOTION_DIAGNOSTIC = {
|
|
|
5282
5282
|
category: "Accessibility"
|
|
5283
5283
|
};
|
|
5284
5284
|
const checkReducedMotion = (rootDirectory) => {
|
|
5285
|
-
const packageJsonPath = path.join(rootDirectory, "package.json");
|
|
5285
|
+
const packageJsonPath = path$1.join(rootDirectory, "package.json");
|
|
5286
5286
|
if (!isFile(packageJsonPath)) return [];
|
|
5287
5287
|
let hasMotionLibrary = false;
|
|
5288
5288
|
try {
|
|
@@ -5407,7 +5407,7 @@ const isTruthyLinguistAttribute = (token) => {
|
|
|
5407
5407
|
const parseGitattributesLinguistPaths = (filePath) => {
|
|
5408
5408
|
let content;
|
|
5409
5409
|
try {
|
|
5410
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
5410
|
+
content = fs$1.readFileSync(filePath, "utf-8");
|
|
5411
5411
|
} catch {
|
|
5412
5412
|
return [];
|
|
5413
5413
|
}
|
|
@@ -5429,7 +5429,7 @@ const stripGitignoreEscape = (pattern) => {
|
|
|
5429
5429
|
const readIgnoreFile = (filePath) => {
|
|
5430
5430
|
let content;
|
|
5431
5431
|
try {
|
|
5432
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
5432
|
+
content = fs$1.readFileSync(filePath, "utf-8");
|
|
5433
5433
|
} catch (error) {
|
|
5434
5434
|
const errnoCode = error?.code;
|
|
5435
5435
|
if (errnoCode && errnoCode !== "ENOENT") Effect.runSync(Console.warn(`Could not read ignore file ${filePath}: ${errnoCode}`));
|
|
@@ -5461,8 +5461,8 @@ const computeIgnorePatterns = (rootDirectory) => {
|
|
|
5461
5461
|
seen.add(pattern);
|
|
5462
5462
|
patterns.push(pattern);
|
|
5463
5463
|
};
|
|
5464
|
-
for (const filename of IGNORE_FILENAMES) for (const pattern of readIgnoreFile(path.join(rootDirectory, filename))) addPattern(pattern);
|
|
5465
|
-
for (const linguistPath of parseGitattributesLinguistPaths(path.join(rootDirectory, ".gitattributes"))) addPattern(linguistPath);
|
|
5464
|
+
for (const filename of IGNORE_FILENAMES) for (const pattern of readIgnoreFile(path$1.join(rootDirectory, filename))) addPattern(pattern);
|
|
5465
|
+
for (const linguistPath of parseGitattributesLinguistPaths(path$1.join(rootDirectory, ".gitattributes"))) addPattern(linguistPath);
|
|
5466
5466
|
return patterns;
|
|
5467
5467
|
};
|
|
5468
5468
|
const collectIgnorePatterns = (rootDirectory) => {
|
|
@@ -5546,7 +5546,7 @@ const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipP
|
|
|
5546
5546
|
*/
|
|
5547
5547
|
const toCanonicalPath = (filePath) => {
|
|
5548
5548
|
try {
|
|
5549
|
-
return fs.realpathSync(filePath);
|
|
5549
|
+
return fs$1.realpathSync(filePath);
|
|
5550
5550
|
} catch {
|
|
5551
5551
|
return filePath;
|
|
5552
5552
|
}
|
|
@@ -5613,8 +5613,8 @@ process.stdin.on("end", () => {
|
|
|
5613
5613
|
`;
|
|
5614
5614
|
const resolveTsConfigPath = (rootDirectory) => {
|
|
5615
5615
|
for (const filename of TSCONFIG_FILENAMES$1) {
|
|
5616
|
-
const candidate = path.join(rootDirectory, filename);
|
|
5617
|
-
if (fs.existsSync(candidate)) return candidate;
|
|
5616
|
+
const candidate = path$1.join(rootDirectory, filename);
|
|
5617
|
+
if (fs$1.existsSync(candidate)) return candidate;
|
|
5618
5618
|
}
|
|
5619
5619
|
};
|
|
5620
5620
|
const toRelativeFilePath = (rootDirectory, filePath) => {
|
|
@@ -5802,7 +5802,7 @@ const runDeadCodeWorkerWithTimeout = (handle, timeoutMs) => new Promise((resolve
|
|
|
5802
5802
|
const checkDeadCode = async (options) => {
|
|
5803
5803
|
const { userConfig } = options;
|
|
5804
5804
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
5805
|
-
if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
|
|
5805
|
+
if (!fs$1.existsSync(path$1.join(rootDirectory, "package.json"))) return [];
|
|
5806
5806
|
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
5807
5807
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
|
|
5808
5808
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
@@ -5909,7 +5909,7 @@ const isDiagnosticOnSurface = (diagnostic, surface, config) => {
|
|
|
5909
5909
|
return true;
|
|
5910
5910
|
};
|
|
5911
5911
|
const filterDiagnosticsForSurface = (diagnostics, surface, config) => diagnostics.filter((diagnostic) => isDiagnosticOnSurface(diagnostic, surface, config));
|
|
5912
|
-
const excludeMinifiedFiles = (rootDirectory, relativePaths) => relativePaths.filter((relativePath) => !isLargeMinifiedFile(path.resolve(rootDirectory, relativePath)));
|
|
5912
|
+
const excludeMinifiedFiles = (rootDirectory, relativePaths) => relativePaths.filter((relativePath) => !isLargeMinifiedFile(path$1.resolve(rootDirectory, relativePath)));
|
|
5913
5913
|
const listSourceFilesViaGit = (rootDirectory) => {
|
|
5914
5914
|
const result = spawnSync("git", [
|
|
5915
5915
|
"ls-files",
|
|
@@ -5932,12 +5932,12 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
|
|
|
5932
5932
|
const currentDirectory = stack.pop();
|
|
5933
5933
|
const entries = readDirectoryEntries(currentDirectory);
|
|
5934
5934
|
for (const entry of entries) {
|
|
5935
|
-
const absolutePath = path.join(currentDirectory, entry.name);
|
|
5935
|
+
const absolutePath = path$1.join(currentDirectory, entry.name);
|
|
5936
5936
|
if (entry.isDirectory()) {
|
|
5937
5937
|
if (!entry.name.startsWith(".") && !IGNORED_DIRECTORIES.has(entry.name)) stack.push(absolutePath);
|
|
5938
5938
|
continue;
|
|
5939
5939
|
}
|
|
5940
|
-
if (entry.isFile() && isLintableSourceFile(entry.name)) filePaths.push(path.relative(rootDirectory, absolutePath).replace(/\\/g, "/"));
|
|
5940
|
+
if (entry.isFile() && isLintableSourceFile(entry.name)) filePaths.push(path$1.relative(rootDirectory, absolutePath).replace(/\\/g, "/"));
|
|
5941
5941
|
}
|
|
5942
5942
|
}
|
|
5943
5943
|
return filePaths;
|
|
@@ -5996,9 +5996,9 @@ var DeadCode = class DeadCode extends Context.Service()("react-doctor/DeadCode")
|
|
|
5996
5996
|
};
|
|
5997
5997
|
const createNodeReadFileLinesSync = (rootDirectory) => {
|
|
5998
5998
|
return (filePath) => {
|
|
5999
|
-
const absolutePath = path.isAbsolute(filePath) ? filePath : path.join(rootDirectory, filePath);
|
|
5999
|
+
const absolutePath = path$1.isAbsolute(filePath) ? filePath : path$1.join(rootDirectory, filePath);
|
|
6000
6000
|
try {
|
|
6001
|
-
return fs.readFileSync(absolutePath, "utf-8").split("\n");
|
|
6001
|
+
return fs$1.readFileSync(absolutePath, "utf-8").split("\n");
|
|
6002
6002
|
} catch {
|
|
6003
6003
|
return null;
|
|
6004
6004
|
}
|
|
@@ -6018,7 +6018,7 @@ var Files = class Files extends Context.Service()("react-doctor/Files") {
|
|
|
6018
6018
|
* pattern in react-doctor-evals' test layers.
|
|
6019
6019
|
*/
|
|
6020
6020
|
static layerInMemory = (tree) => {
|
|
6021
|
-
const resolveAbsolute = (filePath, rootDirectory) =>
|
|
6021
|
+
const resolveAbsolute = (filePath, rootDirectory) => path$1.isAbsolute(filePath) ? filePath : `${rootDirectory}/${filePath}`;
|
|
6022
6022
|
return Layer.succeed(Files, Files.of({
|
|
6023
6023
|
readLines: (input) => Effect.sync(() => {
|
|
6024
6024
|
const absolute = resolveAbsolute(input.filePath, input.rootDirectory);
|
|
@@ -6508,7 +6508,7 @@ const canOxlintExtendConfig = (configPath) => {
|
|
|
6508
6508
|
if (!configPath.endsWith(".eslintrc.json")) return true;
|
|
6509
6509
|
let parsed;
|
|
6510
6510
|
try {
|
|
6511
|
-
parsed = parseJsonOrJsonc(fs.readFileSync(configPath, "utf-8"));
|
|
6511
|
+
parsed = parseJsonOrJsonc(fs$1.readFileSync(configPath, "utf-8"));
|
|
6512
6512
|
} catch {
|
|
6513
6513
|
return true;
|
|
6514
6514
|
}
|
|
@@ -6521,7 +6521,7 @@ const canOxlintExtendConfig = (configPath) => {
|
|
|
6521
6521
|
};
|
|
6522
6522
|
const findFirstLintConfigInDirectory = (directory) => {
|
|
6523
6523
|
for (const filename of ADOPTABLE_LINT_CONFIG_FILENAMES) {
|
|
6524
|
-
const candidatePath = path.join(directory, filename);
|
|
6524
|
+
const candidatePath = path$1.join(directory, filename);
|
|
6525
6525
|
if (isFile(candidatePath)) return candidatePath;
|
|
6526
6526
|
}
|
|
6527
6527
|
return null;
|
|
@@ -6530,12 +6530,12 @@ const detectUserLintConfigPaths = (rootDirectory) => {
|
|
|
6530
6530
|
const directLintConfig = findFirstLintConfigInDirectory(rootDirectory);
|
|
6531
6531
|
if (directLintConfig) return [directLintConfig];
|
|
6532
6532
|
if (isProjectBoundary(rootDirectory)) return [];
|
|
6533
|
-
let ancestorDirectory = path.dirname(rootDirectory);
|
|
6534
|
-
while (ancestorDirectory !== path.dirname(ancestorDirectory)) {
|
|
6533
|
+
let ancestorDirectory = path$1.dirname(rootDirectory);
|
|
6534
|
+
while (ancestorDirectory !== path$1.dirname(ancestorDirectory)) {
|
|
6535
6535
|
const ancestorLintConfig = findFirstLintConfigInDirectory(ancestorDirectory);
|
|
6536
6536
|
if (ancestorLintConfig) return [ancestorLintConfig];
|
|
6537
6537
|
if (isProjectBoundary(ancestorDirectory)) return [];
|
|
6538
|
-
ancestorDirectory = path.dirname(ancestorDirectory);
|
|
6538
|
+
ancestorDirectory = path$1.dirname(ancestorDirectory);
|
|
6539
6539
|
}
|
|
6540
6540
|
return [];
|
|
6541
6541
|
};
|
|
@@ -6564,10 +6564,10 @@ const findFilesWithDisableDirectivesViaFilesystem = (rootDirectory, includePaths
|
|
|
6564
6564
|
const matches = [];
|
|
6565
6565
|
const checkFile = (relativePath) => {
|
|
6566
6566
|
if (!isLintableSourceFile(relativePath)) return;
|
|
6567
|
-
const absolutePath = path.join(rootDirectory, relativePath);
|
|
6567
|
+
const absolutePath = path$1.join(rootDirectory, relativePath);
|
|
6568
6568
|
let content;
|
|
6569
6569
|
try {
|
|
6570
|
-
content = fs.readFileSync(absolutePath, "utf-8");
|
|
6570
|
+
content = fs$1.readFileSync(absolutePath, "utf-8");
|
|
6571
6571
|
} catch {
|
|
6572
6572
|
return;
|
|
6573
6573
|
}
|
|
@@ -6585,12 +6585,12 @@ const findFilesWithDisableDirectivesViaFilesystem = (rootDirectory, includePaths
|
|
|
6585
6585
|
for (const entry of entries) {
|
|
6586
6586
|
if (entry.isDirectory()) {
|
|
6587
6587
|
if (entry.name.startsWith(".") || IGNORED_DIRECTORIES.has(entry.name)) continue;
|
|
6588
|
-
stack.push(path.join(current, entry.name));
|
|
6588
|
+
stack.push(path$1.join(current, entry.name));
|
|
6589
6589
|
continue;
|
|
6590
6590
|
}
|
|
6591
6591
|
if (!entry.isFile()) continue;
|
|
6592
|
-
const absolute = path.join(current, entry.name);
|
|
6593
|
-
checkFile(path.relative(rootDirectory, absolute));
|
|
6592
|
+
const absolute = path$1.join(current, entry.name);
|
|
6593
|
+
checkFile(path$1.relative(rootDirectory, absolute));
|
|
6594
6594
|
}
|
|
6595
6595
|
}
|
|
6596
6596
|
return matches;
|
|
@@ -6605,7 +6605,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
6605
6605
|
if (isRestored) return;
|
|
6606
6606
|
isRestored = true;
|
|
6607
6607
|
for (const [absolutePath, originalContent] of originalContents) try {
|
|
6608
|
-
fs.writeFileSync(absolutePath, originalContent);
|
|
6608
|
+
fs$1.writeFileSync(absolutePath, originalContent);
|
|
6609
6609
|
} catch (error) {
|
|
6610
6610
|
process.stderr.write(`[react-doctor] Failed to restore inline disable directives in ${absolutePath}: ${error instanceof Error ? error.message : String(error)}\n[react-doctor] Run: git checkout -- ${absolutePath}\n`);
|
|
6611
6611
|
}
|
|
@@ -6613,17 +6613,17 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
6613
6613
|
const onExit = () => restore();
|
|
6614
6614
|
process.once("exit", onExit);
|
|
6615
6615
|
for (const relativePath of filePaths) {
|
|
6616
|
-
const absolutePath = path.join(rootDirectory, relativePath);
|
|
6616
|
+
const absolutePath = path$1.join(rootDirectory, relativePath);
|
|
6617
6617
|
let originalContent;
|
|
6618
6618
|
try {
|
|
6619
|
-
originalContent = fs.readFileSync(absolutePath, "utf-8");
|
|
6619
|
+
originalContent = fs$1.readFileSync(absolutePath, "utf-8");
|
|
6620
6620
|
} catch {
|
|
6621
6621
|
continue;
|
|
6622
6622
|
}
|
|
6623
6623
|
const neutralizedContent = neutralizeContent(originalContent);
|
|
6624
6624
|
if (neutralizedContent !== originalContent) {
|
|
6625
6625
|
originalContents.set(absolutePath, originalContent);
|
|
6626
|
-
fs.writeFileSync(absolutePath, neutralizedContent);
|
|
6626
|
+
fs$1.writeFileSync(absolutePath, neutralizedContent);
|
|
6627
6627
|
}
|
|
6628
6628
|
}
|
|
6629
6629
|
return () => {
|
|
@@ -6760,11 +6760,11 @@ const filterRulesToAvailable = (rules, pluginNamespace, availableRuleNames) => {
|
|
|
6760
6760
|
* renamed.
|
|
6761
6761
|
*/
|
|
6762
6762
|
const resolveUserPlugin = (spec, configSourceDirectory) => {
|
|
6763
|
-
const isRelative = spec.startsWith("./") || spec.startsWith("../") || path.isAbsolute(spec);
|
|
6764
|
-
const candidateRequire = createRequire(path.join(configSourceDirectory, "noop.js"));
|
|
6763
|
+
const isRelative = spec.startsWith("./") || spec.startsWith("../") || path$1.isAbsolute(spec);
|
|
6764
|
+
const candidateRequire = createRequire(path$1.join(configSourceDirectory, "noop.js"));
|
|
6765
6765
|
let resolvedSpecifier;
|
|
6766
6766
|
try {
|
|
6767
|
-
resolvedSpecifier = isRelative ? path.resolve(configSourceDirectory, spec) : candidateRequire.resolve(spec);
|
|
6767
|
+
resolvedSpecifier = isRelative ? path$1.resolve(configSourceDirectory, spec) : candidateRequire.resolve(spec);
|
|
6768
6768
|
} catch (error) {
|
|
6769
6769
|
warnConfigIssue(`config.plugins entry "${spec}" could not be resolved from ${configSourceDirectory}: ${error instanceof Error ? error.message : String(error)}`);
|
|
6770
6770
|
return null;
|
|
@@ -6804,8 +6804,8 @@ const resolveUserPlugins = (specs, configSourceDirectory) => {
|
|
|
6804
6804
|
return resolved;
|
|
6805
6805
|
};
|
|
6806
6806
|
const resolveSettingsRootDirectory = (rootDirectory) => {
|
|
6807
|
-
if (!fs.existsSync(rootDirectory)) return rootDirectory;
|
|
6808
|
-
return fs.realpathSync(rootDirectory);
|
|
6807
|
+
if (!fs$1.existsSync(rootDirectory)) return rootDirectory;
|
|
6808
|
+
return fs$1.realpathSync(rootDirectory);
|
|
6809
6809
|
};
|
|
6810
6810
|
const resolveCompilerCleanupBucketSeverity = (ruleKey, severityControls) => {
|
|
6811
6811
|
if (!COMPILER_CLEANUP_RULE_KEYS.has(ruleKey)) return void 0;
|
|
@@ -6894,13 +6894,13 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
6894
6894
|
const esmRequire = createRequire(import.meta.url);
|
|
6895
6895
|
const resolveOxlintBinary = () => {
|
|
6896
6896
|
const oxlintMainPath = esmRequire.resolve("oxlint");
|
|
6897
|
-
const oxlintPackageDirectory = path.resolve(path.dirname(oxlintMainPath), "..");
|
|
6898
|
-
return path.join(oxlintPackageDirectory, "bin", "oxlint");
|
|
6897
|
+
const oxlintPackageDirectory = path$1.resolve(path$1.dirname(oxlintMainPath), "..");
|
|
6898
|
+
return path$1.join(oxlintPackageDirectory, "bin", "oxlint");
|
|
6899
6899
|
};
|
|
6900
6900
|
const resolvePluginPath = () => esmRequire.resolve("oxlint-plugin-react-doctor");
|
|
6901
6901
|
const TSCONFIG_FILENAMES = ["tsconfig.json", "tsconfig.base.json"];
|
|
6902
6902
|
const resolveTsConfigRelativePath = (rootDirectory) => {
|
|
6903
|
-
for (const filename of TSCONFIG_FILENAMES) if (fs.existsSync(path.join(rootDirectory, filename))) return `./${filename}`;
|
|
6903
|
+
for (const filename of TSCONFIG_FILENAMES) if (fs$1.existsSync(path$1.join(rootDirectory, filename))) return `./${filename}`;
|
|
6904
6904
|
return null;
|
|
6905
6905
|
};
|
|
6906
6906
|
const dedupeDiagnostics = (diagnostics) => {
|
|
@@ -7400,10 +7400,10 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
7400
7400
|
if (!diagnostic.message.startsWith(REACT_HOOK_USE_MESSAGE_PREFIX)) return false;
|
|
7401
7401
|
const primaryLabel = diagnostic.labels[0];
|
|
7402
7402
|
if (!primaryLabel) return false;
|
|
7403
|
-
const absolutePath = path.isAbsolute(diagnostic.filename) ? diagnostic.filename : path.join(rootDirectory, diagnostic.filename);
|
|
7403
|
+
const absolutePath = path$1.isAbsolute(diagnostic.filename) ? diagnostic.filename : path$1.join(rootDirectory, diagnostic.filename);
|
|
7404
7404
|
let sourceText;
|
|
7405
7405
|
try {
|
|
7406
|
-
sourceText = fs.readFileSync(absolutePath, "utf-8");
|
|
7406
|
+
sourceText = fs$1.readFileSync(absolutePath, "utf-8");
|
|
7407
7407
|
} catch {
|
|
7408
7408
|
return false;
|
|
7409
7409
|
}
|
|
@@ -7494,7 +7494,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
7494
7494
|
if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 200) }) });
|
|
7495
7495
|
const minifiedFileCache = /* @__PURE__ */ new Map();
|
|
7496
7496
|
const isMinifiedDiagnosticFile = (filename) => {
|
|
7497
|
-
const absolutePath = path.isAbsolute(filename) ? filename : path.resolve(rootDirectory || ".", filename);
|
|
7497
|
+
const absolutePath = path$1.isAbsolute(filename) ? filename : path$1.resolve(rootDirectory || ".", filename);
|
|
7498
7498
|
const cached = minifiedFileCache.get(absolutePath);
|
|
7499
7499
|
if (cached !== void 0) return cached;
|
|
7500
7500
|
const minified = isMinifiedSource(absolutePath);
|
|
@@ -7761,12 +7761,12 @@ const validateRuleRegistration = () => {
|
|
|
7761
7761
|
* legitimate overwriter is `this` runner inside the same temp dir.
|
|
7762
7762
|
*/
|
|
7763
7763
|
const writeOxlintConfig = (configPath, configToWrite) => {
|
|
7764
|
-
fs.rmSync(configPath, { force: true });
|
|
7765
|
-
const fileHandle = fs.openSync(configPath, "wx", 384);
|
|
7764
|
+
fs$1.rmSync(configPath, { force: true });
|
|
7765
|
+
const fileHandle = fs$1.openSync(configPath, "wx", 384);
|
|
7766
7766
|
try {
|
|
7767
|
-
fs.writeFileSync(fileHandle, JSON.stringify(configToWrite));
|
|
7767
|
+
fs$1.writeFileSync(fileHandle, JSON.stringify(configToWrite));
|
|
7768
7768
|
} finally {
|
|
7769
|
-
fs.closeSync(fileHandle);
|
|
7769
|
+
fs$1.closeSync(fileHandle);
|
|
7770
7770
|
}
|
|
7771
7771
|
};
|
|
7772
7772
|
/**
|
|
@@ -7807,8 +7807,8 @@ const runOxlint = async (options) => {
|
|
|
7807
7807
|
userPlugins
|
|
7808
7808
|
});
|
|
7809
7809
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
7810
|
-
const configDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
7811
|
-
const configPath = path.join(configDirectory, "oxlintrc.json");
|
|
7810
|
+
const configDirectory = fs$1.mkdtempSync(path$1.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
7811
|
+
const configPath = path$1.join(configDirectory, "oxlintrc.json");
|
|
7812
7812
|
try {
|
|
7813
7813
|
const baseArgs = [
|
|
7814
7814
|
resolveOxlintBinary(),
|
|
@@ -7823,8 +7823,8 @@ const runOxlint = async (options) => {
|
|
|
7823
7823
|
}
|
|
7824
7824
|
const combinedPatterns = collectIgnorePatterns(rootDirectory);
|
|
7825
7825
|
if (combinedPatterns.length > 0) {
|
|
7826
|
-
const combinedIgnorePath = path.join(configDirectory, "combined.ignore");
|
|
7827
|
-
fs.writeFileSync(combinedIgnorePath, `${combinedPatterns.join("\n")}\n`);
|
|
7826
|
+
const combinedIgnorePath = path$1.join(configDirectory, "combined.ignore");
|
|
7827
|
+
fs$1.writeFileSync(combinedIgnorePath, `${combinedPatterns.join("\n")}\n`);
|
|
7828
7828
|
baseArgs.push("--ignore-path", combinedIgnorePath);
|
|
7829
7829
|
}
|
|
7830
7830
|
const fileBatches = batchIncludePaths(baseArgs, includePaths !== void 0 ? includePaths : listSourceFiles(rootDirectory));
|
|
@@ -7850,7 +7850,7 @@ const runOxlint = async (options) => {
|
|
|
7850
7850
|
}
|
|
7851
7851
|
} finally {
|
|
7852
7852
|
restoreDisableDirectives();
|
|
7853
|
-
fs.rmSync(configDirectory, {
|
|
7853
|
+
fs$1.rmSync(configDirectory, {
|
|
7854
7854
|
recursive: true,
|
|
7855
7855
|
force: true
|
|
7856
7856
|
});
|
|
@@ -8052,7 +8052,7 @@ var Reporter = class Reporter extends Context.Service()("react-doctor/Reporter")
|
|
|
8052
8052
|
* `Diagnostic` schema.
|
|
8053
8053
|
*/
|
|
8054
8054
|
static layerNdjson = (filePath) => Layer.effect(Reporter, Effect.sync(() => {
|
|
8055
|
-
fs$1.mkdirSync(
|
|
8055
|
+
fs$1.mkdirSync(path$1.dirname(filePath), { recursive: true });
|
|
8056
8056
|
const handle = fs$1.openSync(filePath, "a");
|
|
8057
8057
|
const encode = Schema.encodeUnknownSync(Diagnostic);
|
|
8058
8058
|
const emit = (diagnostic) => Effect.sync(() => {
|
|
@@ -8162,7 +8162,7 @@ const getStringProperty = (value, propertyName) => {
|
|
|
8162
8162
|
const readGithubEventPayload = (eventPath) => {
|
|
8163
8163
|
if (eventPath === void 0 || eventPath.length === 0) return null;
|
|
8164
8164
|
try {
|
|
8165
|
-
return JSON.parse(readFileSync(eventPath, "utf8"));
|
|
8165
|
+
return JSON.parse(fs$1.readFileSync(eventPath, "utf8"));
|
|
8166
8166
|
} catch {
|
|
8167
8167
|
return null;
|
|
8168
8168
|
}
|
|
@@ -8246,7 +8246,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8246
8246
|
repo
|
|
8247
8247
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
8248
8248
|
const lintIncludePaths = computeJsxIncludePaths([...input.includePaths]) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
|
|
8249
|
-
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path.resolve(scanDirectory, relativePath)) : [];
|
|
8249
|
+
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
8250
8250
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
8251
8251
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
8252
8252
|
yield* beforeLint(project, lintIncludePaths ?? void 0);
|
|
@@ -8397,25 +8397,25 @@ const isNodeVersionCompatibleWithOxlint = ({ major, minor }) => {
|
|
|
8397
8397
|
const isCurrentNodeCompatibleWithOxlint = () => isNodeVersionCompatibleWithOxlint(parseNodeVersion(process.version));
|
|
8398
8398
|
const getNvmDirectory = () => {
|
|
8399
8399
|
const envNvmDirectory = process.env.NVM_DIR;
|
|
8400
|
-
if (envNvmDirectory && existsSync(envNvmDirectory)) return envNvmDirectory;
|
|
8401
|
-
const defaultNvmDirectory = path.join(os.homedir(), ".nvm");
|
|
8402
|
-
if (existsSync(defaultNvmDirectory)) return defaultNvmDirectory;
|
|
8400
|
+
if (envNvmDirectory && fs$1.existsSync(envNvmDirectory)) return envNvmDirectory;
|
|
8401
|
+
const defaultNvmDirectory = path$1.join(os.homedir(), ".nvm");
|
|
8402
|
+
if (fs$1.existsSync(defaultNvmDirectory)) return defaultNvmDirectory;
|
|
8403
8403
|
return null;
|
|
8404
8404
|
};
|
|
8405
8405
|
const isNvmInstalled = () => getNvmDirectory() !== null;
|
|
8406
8406
|
const findCompatibleNvmBinary = () => {
|
|
8407
8407
|
const nvmDirectory = getNvmDirectory();
|
|
8408
8408
|
if (!nvmDirectory) return null;
|
|
8409
|
-
const versionsDirectory = path.join(nvmDirectory, "versions", "node");
|
|
8410
|
-
if (!existsSync(versionsDirectory)) return null;
|
|
8411
|
-
const compatibleVersions = readdirSync(versionsDirectory).filter((directoryName) => directoryName.startsWith("v")).map((directoryName) => ({
|
|
8409
|
+
const versionsDirectory = path$1.join(nvmDirectory, "versions", "node");
|
|
8410
|
+
if (!fs$1.existsSync(versionsDirectory)) return null;
|
|
8411
|
+
const compatibleVersions = fs$1.readdirSync(versionsDirectory).filter((directoryName) => directoryName.startsWith("v")).map((directoryName) => ({
|
|
8412
8412
|
directoryName,
|
|
8413
8413
|
...parseNodeVersion(directoryName)
|
|
8414
8414
|
})).filter((version) => isNodeVersionCompatibleWithOxlint(version)).sort((versionA, versionB) => versionB.major - versionA.major || versionB.minor - versionA.minor || versionB.patch - versionA.patch);
|
|
8415
8415
|
if (compatibleVersions.length === 0) return null;
|
|
8416
8416
|
const bestVersion = compatibleVersions[0];
|
|
8417
|
-
const binaryPath = path.join(versionsDirectory, bestVersion.directoryName, "bin", "node");
|
|
8418
|
-
return existsSync(binaryPath) ? binaryPath : null;
|
|
8417
|
+
const binaryPath = path$1.join(versionsDirectory, bestVersion.directoryName, "bin", "node");
|
|
8418
|
+
return fs$1.existsSync(binaryPath) ? binaryPath : null;
|
|
8419
8419
|
};
|
|
8420
8420
|
const getNodeVersionFromBinary = (binaryPath) => {
|
|
8421
8421
|
const result = spawnSync(binaryPath, ["--version"], { encoding: "utf-8" });
|
|
@@ -8425,8 +8425,8 @@ const getNodeVersionFromBinary = (binaryPath) => {
|
|
|
8425
8425
|
const installNodeViaNvm = () => {
|
|
8426
8426
|
const nvmDirectory = getNvmDirectory();
|
|
8427
8427
|
if (!nvmDirectory) return false;
|
|
8428
|
-
const nvmScript = path.join(nvmDirectory, "nvm.sh");
|
|
8429
|
-
if (!existsSync(nvmScript)) return false;
|
|
8428
|
+
const nvmScript = path$1.join(nvmDirectory, "nvm.sh");
|
|
8429
|
+
if (!fs$1.existsSync(nvmScript)) return false;
|
|
8430
8430
|
const result = spawnSync("bash", ["-c", ". \"$NVM_SCRIPT\" && nvm install \"$NODE_MAJOR\""], {
|
|
8431
8431
|
stdio: "inherit",
|
|
8432
8432
|
env: {
|
|
@@ -8489,8 +8489,8 @@ const resolveNodeForOxlint = () => {
|
|
|
8489
8489
|
* result that lands outside it before `writeFileSync` runs.
|
|
8490
8490
|
*/
|
|
8491
8491
|
const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
8492
|
-
const relative = path.relative(parentAbsolutePath, childAbsolutePath);
|
|
8493
|
-
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
8492
|
+
const relative = path$1.relative(parentAbsolutePath, childAbsolutePath);
|
|
8493
|
+
return Boolean(relative) && !relative.startsWith("..") && !path$1.isAbsolute(relative);
|
|
8494
8494
|
};
|
|
8495
8495
|
(class StagedFiles extends Context.Service()("react-doctor/StagedFiles") {
|
|
8496
8496
|
static layerNode = Layer.effect(StagedFiles, Effect.gen(function* () {
|
|
@@ -8499,23 +8499,23 @@ const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
|
8499
8499
|
discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(Effect.map((entries) => entries.filter(isLintableSourceFile))),
|
|
8500
8500
|
materialize: ({ directory, stagedFiles, tempDirectory }) => Effect.gen(function* () {
|
|
8501
8501
|
const materializedFiles = [];
|
|
8502
|
-
const resolvedTempDirectory = path.resolve(tempDirectory);
|
|
8502
|
+
const resolvedTempDirectory = path$1.resolve(tempDirectory);
|
|
8503
8503
|
for (const relativePath of stagedFiles) {
|
|
8504
8504
|
const content = yield* git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES }).pipe(Effect.orElseSucceed(() => null));
|
|
8505
8505
|
if (content === null) continue;
|
|
8506
|
-
const candidateTargetPath = path.resolve(resolvedTempDirectory, relativePath);
|
|
8506
|
+
const candidateTargetPath = path$1.resolve(resolvedTempDirectory, relativePath);
|
|
8507
8507
|
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
|
|
8508
8508
|
yield* Effect.sync(() => {
|
|
8509
|
-
fs.mkdirSync(path.dirname(candidateTargetPath), { recursive: true });
|
|
8510
|
-
fs.writeFileSync(candidateTargetPath, content);
|
|
8509
|
+
fs$1.mkdirSync(path$1.dirname(candidateTargetPath), { recursive: true });
|
|
8510
|
+
fs$1.writeFileSync(candidateTargetPath, content);
|
|
8511
8511
|
});
|
|
8512
8512
|
materializedFiles.push(relativePath);
|
|
8513
8513
|
}
|
|
8514
8514
|
yield* Effect.sync(() => {
|
|
8515
8515
|
for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
8516
|
-
const sourcePath = path.join(directory, configFilename);
|
|
8517
|
-
const targetPath = path.join(resolvedTempDirectory, configFilename);
|
|
8518
|
-
if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) fs.cpSync(sourcePath, targetPath);
|
|
8516
|
+
const sourcePath = path$1.join(directory, configFilename);
|
|
8517
|
+
const targetPath = path$1.join(resolvedTempDirectory, configFilename);
|
|
8518
|
+
if (fs$1.existsSync(sourcePath) && !fs$1.existsSync(targetPath)) fs$1.cpSync(sourcePath, targetPath);
|
|
8519
8519
|
}
|
|
8520
8520
|
});
|
|
8521
8521
|
return {
|
|
@@ -8523,7 +8523,7 @@ const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
|
8523
8523
|
stagedFiles: materializedFiles,
|
|
8524
8524
|
cleanup: () => {
|
|
8525
8525
|
try {
|
|
8526
|
-
fs.rmSync(tempDirectory, {
|
|
8526
|
+
fs$1.rmSync(tempDirectory, {
|
|
8527
8527
|
recursive: true,
|
|
8528
8528
|
force: true
|
|
8529
8529
|
});
|
|
@@ -8800,4 +8800,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8800
8800
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8801
8801
|
|
|
8802
8802
|
//# sourceMappingURL=index.js.map
|
|
8803
|
-
//# debugId=
|
|
8803
|
+
//# debugId=78466bb6-1333-5899-a21b-ca9ce49351a3
|