react-doctor 0.2.18-dev.8691177 → 0.2.18-dev.87440ab
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 +314 -45
- package/dist/index.d.ts +9 -0
- package/dist/index.js +99 -26
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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]="abae260a-5485-52a6-9af5-5259ba942f1b")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
5
|
import * as Path from "node:path";
|
|
@@ -36,13 +36,13 @@ import * as ts from "typescript";
|
|
|
36
36
|
import { gzipSync } from "node:zlib";
|
|
37
37
|
import * as Sentry from "@sentry/node";
|
|
38
38
|
import { performance } from "node:perf_hooks";
|
|
39
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
39
40
|
import * as Tracer from "effect/Tracer";
|
|
40
41
|
import * as Exit from "effect/Exit";
|
|
41
42
|
import { stripVTControlCharacters } from "node:util";
|
|
42
43
|
import tty from "node:tty";
|
|
43
44
|
import { codeFrameColumns } from "@babel/code-frame";
|
|
44
45
|
import Conf from "conf";
|
|
45
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
46
46
|
import basePrompts from "prompts";
|
|
47
47
|
import { SKILL_MANIFEST_FILE, detectInstalledSkillAgents, getSkillAgentConfig, getSkillAgentTypes, installSkillsFromSource } from "agent-install";
|
|
48
48
|
import { fileURLToPath } from "node:url";
|
|
@@ -5943,6 +5943,23 @@ const getExpoDependencySpec = (packageJson) => {
|
|
|
5943
5943
|
return typeof spec === "string" ? spec : null;
|
|
5944
5944
|
};
|
|
5945
5945
|
const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
|
|
5946
|
+
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
5947
|
+
const getShopifyFlashListDependencySpec = (packageJson) => {
|
|
5948
|
+
const spec = packageJson.dependencies?.["@shopify/flash-list"] ?? packageJson.devDependencies?.["@shopify/flash-list"] ?? packageJson.peerDependencies?.["@shopify/flash-list"] ?? packageJson.optionalDependencies?.["@shopify/flash-list"];
|
|
5949
|
+
return typeof spec === "string" ? spec : null;
|
|
5950
|
+
};
|
|
5951
|
+
const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getShopifyFlashListDependencySpec);
|
|
5952
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
5953
|
+
if (version === null || !isCatalogReference(version)) return version;
|
|
5954
|
+
const catalogName = extractCatalogName(version);
|
|
5955
|
+
const resolvedLocalVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
5956
|
+
if (resolvedLocalVersion) return resolvedLocalVersion;
|
|
5957
|
+
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
5958
|
+
if (!monorepoRoot) return version;
|
|
5959
|
+
const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
|
|
5960
|
+
if (!isFile(monorepoPackageJsonPath)) return version;
|
|
5961
|
+
return resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
|
|
5962
|
+
};
|
|
5946
5963
|
const getPreactVersion = (packageJson) => {
|
|
5947
5964
|
return {
|
|
5948
5965
|
...packageJson.peerDependencies,
|
|
@@ -6179,19 +6196,18 @@ const discoverProject = (directory) => {
|
|
|
6179
6196
|
const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
|
|
6180
6197
|
const sourceFileCount = countSourceFiles(directory);
|
|
6181
6198
|
const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
}
|
|
6199
|
+
const expoVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
6200
|
+
rootDirectory: directory,
|
|
6201
|
+
rootPackageJson: packageJson,
|
|
6202
|
+
packageName: "expo",
|
|
6203
|
+
version: findExpoVersion(directory, packageJson)
|
|
6204
|
+
}) : null;
|
|
6205
|
+
const shopifyFlashListVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
6206
|
+
rootDirectory: directory,
|
|
6207
|
+
rootPackageJson: packageJson,
|
|
6208
|
+
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
6209
|
+
version: findShopifyFlashListVersion(directory, packageJson)
|
|
6210
|
+
}) : null;
|
|
6195
6211
|
const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
|
|
6196
6212
|
const preactVersion = getPreactVersion(packageJson);
|
|
6197
6213
|
const projectInfo = {
|
|
@@ -6210,6 +6226,8 @@ const discoverProject = (directory) => {
|
|
|
6210
6226
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
6211
6227
|
hasReactNativeWorkspace,
|
|
6212
6228
|
expoVersion,
|
|
6229
|
+
shopifyFlashListVersion,
|
|
6230
|
+
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
6213
6231
|
hasReanimated,
|
|
6214
6232
|
sourceFileCount
|
|
6215
6233
|
};
|
|
@@ -8521,6 +8539,63 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
8521
8539
|
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
8522
8540
|
return patterns;
|
|
8523
8541
|
};
|
|
8542
|
+
const KNIP_JSON_FILENAME = "knip.json";
|
|
8543
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8544
|
+
const readJsonFileSafe = (filePath) => {
|
|
8545
|
+
let rawContents;
|
|
8546
|
+
try {
|
|
8547
|
+
rawContents = fs.readFileSync(filePath, "utf-8");
|
|
8548
|
+
} catch {
|
|
8549
|
+
return null;
|
|
8550
|
+
}
|
|
8551
|
+
try {
|
|
8552
|
+
return JSON.parse(rawContents);
|
|
8553
|
+
} catch {
|
|
8554
|
+
return null;
|
|
8555
|
+
}
|
|
8556
|
+
};
|
|
8557
|
+
const readKnipConfig = (rootDirectory) => {
|
|
8558
|
+
const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
|
|
8559
|
+
if (isRecord$1(knipJson)) return knipJson;
|
|
8560
|
+
const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
|
|
8561
|
+
const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
|
|
8562
|
+
return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
|
|
8563
|
+
};
|
|
8564
|
+
const normalizePatternList = (value) => {
|
|
8565
|
+
if (typeof value === "string" && value.length > 0) return [value];
|
|
8566
|
+
if (!Array.isArray(value)) return [];
|
|
8567
|
+
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
8568
|
+
};
|
|
8569
|
+
const prefixWorkspacePatterns = (workspacePattern, patterns) => {
|
|
8570
|
+
const normalizedWorkspacePattern = workspacePattern.replace(/\/+$/, "");
|
|
8571
|
+
return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
|
|
8572
|
+
};
|
|
8573
|
+
const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
8574
|
+
if (!isRecord$1(workspaces)) return [];
|
|
8575
|
+
const patterns = [];
|
|
8576
|
+
for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
|
|
8577
|
+
if (!isRecord$1(workspaceConfig)) continue;
|
|
8578
|
+
patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
|
|
8579
|
+
}
|
|
8580
|
+
return patterns;
|
|
8581
|
+
};
|
|
8582
|
+
const collectKnipPatterns = (rootDirectory, settingName) => {
|
|
8583
|
+
const config = readKnipConfig(rootDirectory);
|
|
8584
|
+
if (!config) return [];
|
|
8585
|
+
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
8586
|
+
};
|
|
8587
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
8588
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8589
|
+
const sources = [
|
|
8590
|
+
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
8591
|
+
collectIgnorePatterns(rootDirectory),
|
|
8592
|
+
userConfig?.ignore?.files ?? [],
|
|
8593
|
+
collectKnipPatterns(rootDirectory, "ignore")
|
|
8594
|
+
];
|
|
8595
|
+
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
8596
|
+
return [...seen].filter((pattern) => pattern.length > 0);
|
|
8597
|
+
};
|
|
8598
|
+
const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipPatterns(rootDirectory, "entry"))].filter((pattern) => pattern.length > 0);
|
|
8524
8599
|
/**
|
|
8525
8600
|
* Resolves a path to its canonical, symlink-free form, falling back to
|
|
8526
8601
|
* the input when it cannot be realpath'd (broken symlink, permission
|
|
@@ -8546,6 +8621,7 @@ const toCanonicalPath = (filePath) => {
|
|
|
8546
8621
|
const DEAD_CODE_PLUGIN = "deslop";
|
|
8547
8622
|
const DEAD_CODE_CATEGORY = "Maintainability";
|
|
8548
8623
|
const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
|
|
8624
|
+
const isRecord$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8549
8625
|
const DEAD_CODE_WORKER_SCRIPT = `
|
|
8550
8626
|
const inputChunks = [];
|
|
8551
8627
|
process.stdin.on("data", (chunk) => inputChunks.push(chunk));
|
|
@@ -8586,6 +8662,9 @@ process.stdin.on("end", () => {
|
|
|
8586
8662
|
const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
|
|
8587
8663
|
const config = {
|
|
8588
8664
|
rootDir: workerInput.rootDirectory,
|
|
8665
|
+
...(workerInput.entryPatterns.length > 0
|
|
8666
|
+
? { entryPatterns: workerInput.entryPatterns }
|
|
8667
|
+
: {}),
|
|
8589
8668
|
...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
|
|
8590
8669
|
...(workerInput.ignorePatterns.length > 0
|
|
8591
8670
|
? { ignorePatterns: workerInput.ignorePatterns }
|
|
@@ -8605,21 +8684,10 @@ const resolveTsConfigPath = (rootDirectory) => {
|
|
|
8605
8684
|
if (fs.existsSync(candidate)) return candidate;
|
|
8606
8685
|
}
|
|
8607
8686
|
};
|
|
8608
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
8609
|
-
const seen = /* @__PURE__ */ new Set();
|
|
8610
|
-
const sources = [
|
|
8611
|
-
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
8612
|
-
collectIgnorePatterns(rootDirectory),
|
|
8613
|
-
userConfig?.ignore?.files ?? []
|
|
8614
|
-
];
|
|
8615
|
-
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
8616
|
-
return [...seen].filter((pattern) => pattern.length > 0);
|
|
8617
|
-
};
|
|
8618
8687
|
const toRelativeFilePath = (rootDirectory, filePath) => {
|
|
8619
8688
|
const relative = toRelativePath(filePath, rootDirectory);
|
|
8620
8689
|
return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
|
|
8621
8690
|
};
|
|
8622
|
-
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8623
8691
|
const parseArray = (value, label) => {
|
|
8624
8692
|
if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
|
|
8625
8693
|
return value;
|
|
@@ -8643,7 +8711,7 @@ const parseUnusedFiles = (value) => {
|
|
|
8643
8711
|
const values = parseArray(value, "unusedFiles");
|
|
8644
8712
|
const unusedFiles = [];
|
|
8645
8713
|
for (const [index, entry] of values.entries()) {
|
|
8646
|
-
if (!isRecord$
|
|
8714
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedFiles[${index}].`);
|
|
8647
8715
|
unusedFiles.push({ path: parseString(entry.path, `unusedFiles[${index}].path`) });
|
|
8648
8716
|
}
|
|
8649
8717
|
return unusedFiles;
|
|
@@ -8652,7 +8720,7 @@ const parseUnusedExports = (value) => {
|
|
|
8652
8720
|
const values = parseArray(value, "unusedExports");
|
|
8653
8721
|
const unusedExports = [];
|
|
8654
8722
|
for (const [index, entry] of values.entries()) {
|
|
8655
|
-
if (!isRecord$
|
|
8723
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedExports[${index}].`);
|
|
8656
8724
|
unusedExports.push({
|
|
8657
8725
|
path: parseString(entry.path, `unusedExports[${index}].path`),
|
|
8658
8726
|
name: parseString(entry.name, `unusedExports[${index}].name`),
|
|
@@ -8667,7 +8735,7 @@ const parseUnusedDependencies = (value) => {
|
|
|
8667
8735
|
const values = parseArray(value, "unusedDependencies");
|
|
8668
8736
|
const unusedDependencies = [];
|
|
8669
8737
|
for (const [index, entry] of values.entries()) {
|
|
8670
|
-
if (!isRecord$
|
|
8738
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedDependencies[${index}].`);
|
|
8671
8739
|
unusedDependencies.push({
|
|
8672
8740
|
name: parseString(entry.name, `unusedDependencies[${index}].name`),
|
|
8673
8741
|
isDevDependency: parseBoolean(entry.isDevDependency, `unusedDependencies[${index}].isDevDependency`)
|
|
@@ -8679,13 +8747,13 @@ const parseCircularDependencies = (value) => {
|
|
|
8679
8747
|
const values = parseArray(value, "circularDependencies");
|
|
8680
8748
|
const circularDependencies = [];
|
|
8681
8749
|
for (const [index, entry] of values.entries()) {
|
|
8682
|
-
if (!isRecord$
|
|
8750
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid circularDependencies[${index}].`);
|
|
8683
8751
|
circularDependencies.push({ files: parseStringArray(entry.files, `circularDependencies[${index}].files`) });
|
|
8684
8752
|
}
|
|
8685
8753
|
return circularDependencies;
|
|
8686
8754
|
};
|
|
8687
8755
|
const parseDeadCodeWorkerResult = (value) => {
|
|
8688
|
-
if (!isRecord$
|
|
8756
|
+
if (!isRecord$2(value)) throw new Error("Dead-code worker returned an invalid result.");
|
|
8689
8757
|
return {
|
|
8690
8758
|
unusedFiles: parseUnusedFiles(value.unusedFiles),
|
|
8691
8759
|
unusedExports: parseUnusedExports(value.unusedExports),
|
|
@@ -8694,7 +8762,7 @@ const parseDeadCodeWorkerResult = (value) => {
|
|
|
8694
8762
|
};
|
|
8695
8763
|
};
|
|
8696
8764
|
const parseDeadCodeWorkerError = (value) => {
|
|
8697
|
-
if (!isRecord$
|
|
8765
|
+
if (!isRecord$2(value) || typeof value.message !== "string") return { message: "Dead-code worker failed." };
|
|
8698
8766
|
return {
|
|
8699
8767
|
...typeof value.name === "string" ? { name: value.name } : {},
|
|
8700
8768
|
message: value.message,
|
|
@@ -8702,7 +8770,7 @@ const parseDeadCodeWorkerError = (value) => {
|
|
|
8702
8770
|
};
|
|
8703
8771
|
};
|
|
8704
8772
|
const parseDeadCodeWorkerMessage = (value) => {
|
|
8705
|
-
if (!isRecord$
|
|
8773
|
+
if (!isRecord$2(value)) throw new Error("Dead-code worker returned an invalid message.");
|
|
8706
8774
|
if (value.ok === true) return {
|
|
8707
8775
|
ok: true,
|
|
8708
8776
|
result: value.result
|
|
@@ -8802,9 +8870,11 @@ const checkDeadCode = async (options) => {
|
|
|
8802
8870
|
const { userConfig } = options;
|
|
8803
8871
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
8804
8872
|
if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
|
|
8873
|
+
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
8805
8874
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
|
|
8806
8875
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
8807
8876
|
rootDirectory,
|
|
8877
|
+
entryPatterns,
|
|
8808
8878
|
tsConfigPath: resolveTsConfigPath(rootDirectory),
|
|
8809
8879
|
ignorePatterns,
|
|
8810
8880
|
deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
|
|
@@ -9878,6 +9948,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
9878
9948
|
settings: { "react-doctor": {
|
|
9879
9949
|
framework: project.framework,
|
|
9880
9950
|
rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
|
|
9951
|
+
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
9881
9952
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
9882
9953
|
} },
|
|
9883
9954
|
rules: {
|
|
@@ -11099,6 +11170,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
11099
11170
|
...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
|
|
11100
11171
|
...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
|
|
11101
11172
|
...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
|
|
11173
|
+
...options.metadata?.runId ? { runId: options.metadata.runId } : {},
|
|
11102
11174
|
...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
|
|
11103
11175
|
...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
|
|
11104
11176
|
...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
|
|
@@ -11338,6 +11410,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
11338
11410
|
sourceFileCount: project.sourceFileCount,
|
|
11339
11411
|
...defaultBranch !== null ? { defaultBranch } : {},
|
|
11340
11412
|
...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
|
|
11413
|
+
...input.runId !== void 0 ? { runId: input.runId } : {},
|
|
11341
11414
|
...githubActionsScoreMetadata,
|
|
11342
11415
|
...githubViewerPermission !== null ? { githubViewerPermission } : {}
|
|
11343
11416
|
};
|
|
@@ -11794,6 +11867,14 @@ const CI_PROVIDER_BY_ENVIRONMENT_VARIABLE = [
|
|
|
11794
11867
|
["TRAVIS", "travis"],
|
|
11795
11868
|
["DRONE", "drone"]
|
|
11796
11869
|
];
|
|
11870
|
+
const GITHUB_ACTION_MARKER_ENVIRONMENT_VARIABLE = "REACT_DOCTOR_GITHUB_ACTION";
|
|
11871
|
+
const ACTION_INPUT_ENVIRONMENT_VARIABLES = {
|
|
11872
|
+
failOn: "REACT_DOCTOR_ACTION_FAIL_ON",
|
|
11873
|
+
nonBlocking: "REACT_DOCTOR_ACTION_NON_BLOCKING",
|
|
11874
|
+
comment: "REACT_DOCTOR_ACTION_COMMENT",
|
|
11875
|
+
annotations: "REACT_DOCTOR_ACTION_ANNOTATIONS",
|
|
11876
|
+
version: "REACT_DOCTOR_ACTION_VERSION"
|
|
11877
|
+
};
|
|
11797
11878
|
const CODING_AGENT_BY_ENVIRONMENT_VARIABLE = [
|
|
11798
11879
|
["CLAUDECODE", "claude-code"],
|
|
11799
11880
|
["CLAUDE_CODE", "claude-code"],
|
|
@@ -11820,6 +11901,9 @@ const detectCiProvider = () => {
|
|
|
11820
11901
|
for (const [environmentVariable, provider] of CI_PROVIDER_BY_ENVIRONMENT_VARIABLE) if (process.env[environmentVariable]) return provider;
|
|
11821
11902
|
return isCiFlagSet(process.env.CI) ? "unknown" : null;
|
|
11822
11903
|
};
|
|
11904
|
+
const isOfficialGithubAction = () => Boolean(process.env[GITHUB_ACTION_MARKER_ENVIRONMENT_VARIABLE]);
|
|
11905
|
+
const detectCiEventName = () => process.env.GITHUB_EVENT_NAME?.trim() || null;
|
|
11906
|
+
const detectRunnerOs = () => process.env.RUNNER_OS?.trim() || null;
|
|
11823
11907
|
const detectCodingAgentFromValue = () => {
|
|
11824
11908
|
for (const environmentVariable of CODING_AGENT_ENVIRONMENT_VALUE_VARIABLES) {
|
|
11825
11909
|
const value = process.env[environmentVariable]?.toLowerCase();
|
|
@@ -11934,7 +12018,7 @@ const makeNoopConsole = () => ({
|
|
|
11934
12018
|
});
|
|
11935
12019
|
//#endregion
|
|
11936
12020
|
//#region src/cli/utils/version.ts
|
|
11937
|
-
const VERSION = "0.2.18-dev.
|
|
12021
|
+
const VERSION = "0.2.18-dev.87440ab";
|
|
11938
12022
|
//#endregion
|
|
11939
12023
|
//#region src/cli/utils/json-mode.ts
|
|
11940
12024
|
let context = null;
|
|
@@ -12007,6 +12091,13 @@ const writeJsonErrorReport = (error) => {
|
|
|
12007
12091
|
}
|
|
12008
12092
|
};
|
|
12009
12093
|
//#endregion
|
|
12094
|
+
//#region src/cli/utils/run-id.ts
|
|
12095
|
+
let cachedRunId;
|
|
12096
|
+
const getRunId = () => {
|
|
12097
|
+
cachedRunId ??= randomUUID();
|
|
12098
|
+
return cachedRunId;
|
|
12099
|
+
};
|
|
12100
|
+
//#endregion
|
|
12010
12101
|
//#region src/cli/utils/scrub-sensitive-text.ts
|
|
12011
12102
|
const HOME_DIRECTORY = os.homedir();
|
|
12012
12103
|
const USER_HOME_PATTERNS = [/[A-Za-z]:[\\/]Users[\\/][^\\/]+/gi, /(?:\/Users\/|\/home\/)[^/\\]+/gi];
|
|
@@ -12061,6 +12152,7 @@ const buildRunContext = () => {
|
|
|
12061
12152
|
const userArguments = process.argv.slice(2);
|
|
12062
12153
|
return {
|
|
12063
12154
|
version: VERSION,
|
|
12155
|
+
runId: getRunId(),
|
|
12064
12156
|
origin: detectOrigin(),
|
|
12065
12157
|
command: detectCommand(userArguments),
|
|
12066
12158
|
argv: scrubSensitivePaths(userArguments.join(" ")),
|
|
@@ -12071,6 +12163,8 @@ const buildRunContext = () => {
|
|
|
12071
12163
|
arch: process.arch,
|
|
12072
12164
|
ci: isCiEnvironment(),
|
|
12073
12165
|
ciProvider: detectCiProvider(),
|
|
12166
|
+
eventName: detectCiEventName(),
|
|
12167
|
+
viaAction: isOfficialGithubAction(),
|
|
12074
12168
|
codingAgent: detectCodingAgent(),
|
|
12075
12169
|
interactive: !isNonInteractiveEnvironment(),
|
|
12076
12170
|
jsonMode: isJsonModeActive(),
|
|
@@ -12139,6 +12233,8 @@ const buildSentryScope = (runContext = buildRunContext()) => {
|
|
|
12139
12233
|
command: runContext.command,
|
|
12140
12234
|
ci: runContext.ci,
|
|
12141
12235
|
ciProvider: runContext.ciProvider,
|
|
12236
|
+
eventName: runContext.eventName,
|
|
12237
|
+
viaAction: runContext.viaAction,
|
|
12142
12238
|
codingAgent: runContext.codingAgent,
|
|
12143
12239
|
interactive: runContext.interactive,
|
|
12144
12240
|
jsonMode: runContext.jsonMode,
|
|
@@ -12280,13 +12376,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12280
12376
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12281
12377
|
* standard `SENTRY_RELEASE` override.
|
|
12282
12378
|
*/
|
|
12283
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.
|
|
12379
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.87440ab`;
|
|
12284
12380
|
/**
|
|
12285
12381
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12286
12382
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12287
12383
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12288
12384
|
*/
|
|
12289
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.
|
|
12385
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.87440ab") ? "development" : "production");
|
|
12290
12386
|
/**
|
|
12291
12387
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12292
12388
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -15743,6 +15839,152 @@ const recordScanMetrics = (input) => {
|
|
|
15743
15839
|
});
|
|
15744
15840
|
};
|
|
15745
15841
|
//#endregion
|
|
15842
|
+
//#region src/cli/utils/should-fail-for-diagnostics.ts
|
|
15843
|
+
const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
|
|
15844
|
+
if (failOnLevel === "none") return false;
|
|
15845
|
+
if (failOnLevel === "warning") return diagnostics.length > 0;
|
|
15846
|
+
return diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
15847
|
+
};
|
|
15848
|
+
//#endregion
|
|
15849
|
+
//#region src/cli/utils/build-run-event.ts
|
|
15850
|
+
const FAIL_ON_LEVELS = new Set([
|
|
15851
|
+
"error",
|
|
15852
|
+
"warning",
|
|
15853
|
+
"none"
|
|
15854
|
+
]);
|
|
15855
|
+
const readEnvBoolean = (name) => {
|
|
15856
|
+
const value = process.env[name];
|
|
15857
|
+
if (value === void 0) return null;
|
|
15858
|
+
return value.toLowerCase() === "true" || value === "1";
|
|
15859
|
+
};
|
|
15860
|
+
const resolveVersionPin = (versionInput) => {
|
|
15861
|
+
if (versionInput === void 0 || versionInput.trim() === "") return null;
|
|
15862
|
+
if (versionInput === "latest") return "latest";
|
|
15863
|
+
if (/^(\.\.?\/|\/)/.test(versionInput)) return "local";
|
|
15864
|
+
return "pinned";
|
|
15865
|
+
};
|
|
15866
|
+
const resolveTelemetryFailOn = (userConfig) => {
|
|
15867
|
+
const fromAction = process.env[ACTION_INPUT_ENVIRONMENT_VARIABLES.failOn];
|
|
15868
|
+
if (fromAction !== void 0 && FAIL_ON_LEVELS.has(fromAction)) return fromAction;
|
|
15869
|
+
return userConfig?.failOn ?? "none";
|
|
15870
|
+
};
|
|
15871
|
+
const toCategoryKey = (category) => category.toLowerCase().replace(/[^a-z0-9]+/g, "_");
|
|
15872
|
+
const buildOutcomeAttributes = (input) => {
|
|
15873
|
+
if (input.result === void 0) {
|
|
15874
|
+
const error = input.error;
|
|
15875
|
+
const known = isReactDoctorError(error);
|
|
15876
|
+
return {
|
|
15877
|
+
outcome: "error",
|
|
15878
|
+
exitCode: 1,
|
|
15879
|
+
knownError: known,
|
|
15880
|
+
errorTag: known ? error.reason._tag : error instanceof Error ? error.name : null
|
|
15881
|
+
};
|
|
15882
|
+
}
|
|
15883
|
+
const result = input.result;
|
|
15884
|
+
const summary = summarizeDiagnostics(result.diagnostics);
|
|
15885
|
+
const failOnLevel = resolveTelemetryFailOn(input.userConfig);
|
|
15886
|
+
const gateDiagnostics = filterDiagnosticsForSurface(result.diagnostics, "ciFailure", input.userConfig);
|
|
15887
|
+
const wouldBlock = !input.scoreOnly && shouldFailForDiagnostics(gateDiagnostics, failOnLevel);
|
|
15888
|
+
const hasSkippedChecks = result.skippedChecks.length > 0;
|
|
15889
|
+
const isClean = result.diagnostics.length === 0 && !hasSkippedChecks;
|
|
15890
|
+
const outcome = wouldBlock ? "blocked" : isClean ? "clean" : "ok";
|
|
15891
|
+
const firings = summarizeRuleFirings(result.diagnostics);
|
|
15892
|
+
const countByRule = /* @__PURE__ */ new Map();
|
|
15893
|
+
const countByCategory = /* @__PURE__ */ new Map();
|
|
15894
|
+
for (const firing of firings) {
|
|
15895
|
+
countByRule.set(firing.rule, (countByRule.get(firing.rule) ?? 0) + firing.count);
|
|
15896
|
+
countByCategory.set(firing.category, (countByCategory.get(firing.category) ?? 0) + firing.count);
|
|
15897
|
+
}
|
|
15898
|
+
let topRule = null;
|
|
15899
|
+
let topRuleCount = 0;
|
|
15900
|
+
for (const [rule, count] of countByRule) if (count > topRuleCount) {
|
|
15901
|
+
topRule = rule;
|
|
15902
|
+
topRuleCount = count;
|
|
15903
|
+
}
|
|
15904
|
+
const attributes = {
|
|
15905
|
+
outcome,
|
|
15906
|
+
exitCode: wouldBlock ? 1 : 0,
|
|
15907
|
+
wouldBlock,
|
|
15908
|
+
failOn: failOnLevel,
|
|
15909
|
+
scanClean: isClean,
|
|
15910
|
+
totalDiagnostics: summary.totalDiagnosticCount,
|
|
15911
|
+
errorCount: summary.errorCount,
|
|
15912
|
+
warningCount: summary.warningCount,
|
|
15913
|
+
affectedFiles: summary.affectedFileCount,
|
|
15914
|
+
distinctRulesFired: countByRule.size,
|
|
15915
|
+
topRule,
|
|
15916
|
+
scannedFileCount: result.scannedFileCount ?? null,
|
|
15917
|
+
elapsedMs: result.elapsedMilliseconds,
|
|
15918
|
+
scanPhaseMs: result.scanElapsedMilliseconds ?? null,
|
|
15919
|
+
score: result.score ? result.score.score : null,
|
|
15920
|
+
scoreLabel: result.score ? result.score.label : null,
|
|
15921
|
+
scoreAvailable: result.score !== null,
|
|
15922
|
+
skippedCheckCount: result.skippedChecks.length,
|
|
15923
|
+
didLintFail: input.didLintFail ?? null,
|
|
15924
|
+
lintFailureReasonKind: input.lintFailureReasonKind ?? null,
|
|
15925
|
+
lintPartialFailureCount: input.lintPartialFailureCount ?? null,
|
|
15926
|
+
didDeadCodeFail: input.didDeadCodeFail ?? null
|
|
15927
|
+
};
|
|
15928
|
+
for (const [category, count] of countByCategory) attributes[`diag.category.${toCategoryKey(category)}`] = count;
|
|
15929
|
+
return attributes;
|
|
15930
|
+
};
|
|
15931
|
+
const buildCiAttributes = () => {
|
|
15932
|
+
const { githubActorAssociation } = resolveGithubActionsScoreMetadata();
|
|
15933
|
+
return {
|
|
15934
|
+
actorAssociation: githubActorAssociation ?? null,
|
|
15935
|
+
runnerOs: detectRunnerOs(),
|
|
15936
|
+
nonBlocking: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.nonBlocking),
|
|
15937
|
+
comment: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.comment),
|
|
15938
|
+
annotations: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.annotations),
|
|
15939
|
+
versionPin: resolveVersionPin(process.env[ACTION_INPUT_ENVIRONMENT_VARIABLES.version])
|
|
15940
|
+
};
|
|
15941
|
+
};
|
|
15942
|
+
const buildConfigAttributes = (input) => {
|
|
15943
|
+
const ruleOverrides = input.userConfig?.rules ?? {};
|
|
15944
|
+
const ruleKeys = Object.keys(ruleOverrides);
|
|
15945
|
+
return {
|
|
15946
|
+
mode: input.mode,
|
|
15947
|
+
parallel: input.parallel,
|
|
15948
|
+
workerCount: input.workerCount ?? null,
|
|
15949
|
+
lint: input.lint,
|
|
15950
|
+
deadCode: input.deadCode,
|
|
15951
|
+
scoreOnly: input.scoreOnly,
|
|
15952
|
+
noScore: input.noScore,
|
|
15953
|
+
respectInlineDisables: input.respectInlineDisables,
|
|
15954
|
+
showWarnings: input.showWarnings,
|
|
15955
|
+
ignoredTagCount: input.ignoredTagCount,
|
|
15956
|
+
hasCustomConfig: input.hasCustomConfig,
|
|
15957
|
+
rulesConfigured: ruleKeys.length,
|
|
15958
|
+
rulesDisabled: ruleKeys.filter((key) => ruleOverrides[key] === "off").length
|
|
15959
|
+
};
|
|
15960
|
+
};
|
|
15961
|
+
/**
|
|
15962
|
+
* Projects a scan into the flat attribute set for its root span — the canonical
|
|
15963
|
+
* per-scan "wide event". Pure and exported so the projection (outcome
|
|
15964
|
+
* precedence, rule/category rollups, CI knobs, config shape) is unit-testable
|
|
15965
|
+
* without a live Sentry client. `null` values are dropped so absent signals
|
|
15966
|
+
* never become misleading `"null"` attributes. The run + project base context
|
|
15967
|
+
* (version, command, ci/provider, framework, …) is already on the span from
|
|
15968
|
+
* `withSentryRunSpan` / `recordSentryProjectContext`, so this adds only what
|
|
15969
|
+
* those don't carry.
|
|
15970
|
+
*/
|
|
15971
|
+
const buildRunEventAttributes = (input) => toSpanAttributes({
|
|
15972
|
+
...buildConfigAttributes(input),
|
|
15973
|
+
...buildCiAttributes(),
|
|
15974
|
+
...buildOutcomeAttributes(input)
|
|
15975
|
+
});
|
|
15976
|
+
/**
|
|
15977
|
+
* Stamps the wide-event attributes onto the run's root span. A guarded no-op
|
|
15978
|
+
* when tracing is off (no `rootSpan`) and swallow-on-throw, so telemetry can
|
|
15979
|
+
* never break the run.
|
|
15980
|
+
*/
|
|
15981
|
+
const recordRunEvent = (rootSpan, input) => {
|
|
15982
|
+
if (!rootSpan) return;
|
|
15983
|
+
try {
|
|
15984
|
+
rootSpan.setAttributes(buildRunEventAttributes(input));
|
|
15985
|
+
} catch {}
|
|
15986
|
+
};
|
|
15987
|
+
//#endregion
|
|
15746
15988
|
//#region src/cli/utils/build-no-score-message.ts
|
|
15747
15989
|
const ENTERPRISE_CONTACT_HINT = `Want something custom to your company? Contact us at ${ENTERPRISE_CONTACT_URL}.`;
|
|
15748
15990
|
const buildNoScoreMessage = (isScoreDisabled) => {
|
|
@@ -16673,6 +16915,19 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
16673
16915
|
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
16674
16916
|
concurrency: inputOptions.concurrency
|
|
16675
16917
|
});
|
|
16918
|
+
const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
|
|
16919
|
+
parallel: options.concurrency !== void 0,
|
|
16920
|
+
workerCount: options.concurrency,
|
|
16921
|
+
lint: options.lint,
|
|
16922
|
+
deadCode: options.deadCode,
|
|
16923
|
+
scoreOnly: options.scoreOnly,
|
|
16924
|
+
noScore: options.noScore,
|
|
16925
|
+
respectInlineDisables: options.respectInlineDisables,
|
|
16926
|
+
showWarnings: options.warnings,
|
|
16927
|
+
ignoredTagCount: options.ignoredTags.size,
|
|
16928
|
+
hasCustomConfig,
|
|
16929
|
+
userConfig
|
|
16930
|
+
});
|
|
16676
16931
|
const inspect = async (directory, inputOptions = {}) => {
|
|
16677
16932
|
const startTime = performance.now();
|
|
16678
16933
|
resetSentryRunState();
|
|
@@ -16694,7 +16949,18 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
16694
16949
|
const wasSpinnerSilent = isSpinnerSilent();
|
|
16695
16950
|
if (options.silent) setSpinnerSilent(true);
|
|
16696
16951
|
try {
|
|
16697
|
-
const result = await withSentryRunSpan((rootSentrySpan) =>
|
|
16952
|
+
const result = await withSentryRunSpan(async (rootSentrySpan) => {
|
|
16953
|
+
try {
|
|
16954
|
+
return await runInspectWithRuntime(scanDirectory, options, userConfig, hasConfigOverride, configSourceDirectory, startTime, rootSentrySpan);
|
|
16955
|
+
} catch (error) {
|
|
16956
|
+
recordRunEvent(rootSentrySpan, {
|
|
16957
|
+
...buildRunEventConfig(options, userConfig, userConfig !== null),
|
|
16958
|
+
mode: options.includePaths.length > 0 ? "diff" : "full",
|
|
16959
|
+
error
|
|
16960
|
+
});
|
|
16961
|
+
throw error;
|
|
16962
|
+
}
|
|
16963
|
+
});
|
|
16698
16964
|
resetSentryRunState();
|
|
16699
16965
|
return result;
|
|
16700
16966
|
} finally {
|
|
@@ -16729,6 +16995,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
16729
16995
|
runDeadCode: options.deadCode,
|
|
16730
16996
|
isCi: options.isCi,
|
|
16731
16997
|
doctorVersion: VERSION,
|
|
16998
|
+
runId: getRunId(),
|
|
16732
16999
|
resolveLocalGithubViewerPermission: !options.noScore,
|
|
16733
17000
|
suppressScanSummary: options.suppressRendering
|
|
16734
17001
|
}, { beforeLint: (projectInfo, lintIncludePaths) => Effect.gen(function* () {
|
|
@@ -16792,6 +17059,15 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
16792
17059
|
lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
|
|
16793
17060
|
didDeadCodeFail: output.didDeadCodeFail
|
|
16794
17061
|
});
|
|
17062
|
+
recordRunEvent(rootSentrySpan, {
|
|
17063
|
+
...buildRunEventConfig(options, userConfig, userConfig !== null),
|
|
17064
|
+
result,
|
|
17065
|
+
mode: isDiffMode ? "diff" : "full",
|
|
17066
|
+
didLintFail,
|
|
17067
|
+
lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
|
|
17068
|
+
lintPartialFailureCount: output.lintPartialFailures.length,
|
|
17069
|
+
didDeadCodeFail: output.didDeadCodeFail
|
|
17070
|
+
});
|
|
16795
17071
|
return result;
|
|
16796
17072
|
};
|
|
16797
17073
|
const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
@@ -19043,13 +19319,6 @@ const runExplain = async (fileLineArgument, context) => {
|
|
|
19043
19319
|
}
|
|
19044
19320
|
};
|
|
19045
19321
|
//#endregion
|
|
19046
|
-
//#region src/cli/utils/should-fail-for-diagnostics.ts
|
|
19047
|
-
const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
|
|
19048
|
-
if (failOnLevel === "none") return false;
|
|
19049
|
-
if (failOnLevel === "warning") return diagnostics.length > 0;
|
|
19050
|
-
return diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
19051
|
-
};
|
|
19052
|
-
//#endregion
|
|
19053
19322
|
//#region src/cli/utils/validate-mode-flags.ts
|
|
19054
19323
|
const validateModeFlags = (flags) => {
|
|
19055
19324
|
const coercedDiff = coerceDiffValue(flags.diff);
|
|
@@ -20244,4 +20513,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
|
|
|
20244
20513
|
export {};
|
|
20245
20514
|
|
|
20246
20515
|
//# sourceMappingURL=cli.js.map
|
|
20247
|
-
//# debugId=
|
|
20516
|
+
//# debugId=abae260a-5485-52a6-9af5-5259ba942f1b
|
package/dist/index.d.ts
CHANGED
|
@@ -407,6 +407,15 @@ interface ProjectInfo {
|
|
|
407
407
|
* rule) and the ported expo-doctor checks.
|
|
408
408
|
*/
|
|
409
409
|
expoVersion: string | null;
|
|
410
|
+
/**
|
|
411
|
+
* The declared `@shopify/flash-list` package version spec, or `null` when
|
|
412
|
+
* absent. FlashList v2 removed the need for `estimatedItemSize`, so this
|
|
413
|
+
* lets the RN list sizing rule stay scoped to versions where the prop is
|
|
414
|
+
* still useful.
|
|
415
|
+
*/
|
|
416
|
+
shopifyFlashListVersion: string | null;
|
|
417
|
+
/** Parsed major from `shopifyFlashListVersion`, or `null` when absent/unparseable. */
|
|
418
|
+
shopifyFlashListMajorVersion: number | null;
|
|
410
419
|
/**
|
|
411
420
|
* `true` when the project (or any of its workspace packages) declares
|
|
412
421
|
* `react-native-reanimated`. Lets diagnostics surface reanimated's
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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]="ee53eb02-91ef-5d50-b736-4734e9a14f5d")}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";
|
|
@@ -2919,6 +2919,23 @@ const getExpoDependencySpec = (packageJson) => {
|
|
|
2919
2919
|
return typeof spec === "string" ? spec : null;
|
|
2920
2920
|
};
|
|
2921
2921
|
const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
|
|
2922
|
+
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
2923
|
+
const getShopifyFlashListDependencySpec = (packageJson) => {
|
|
2924
|
+
const spec = packageJson.dependencies?.["@shopify/flash-list"] ?? packageJson.devDependencies?.["@shopify/flash-list"] ?? packageJson.peerDependencies?.["@shopify/flash-list"] ?? packageJson.optionalDependencies?.["@shopify/flash-list"];
|
|
2925
|
+
return typeof spec === "string" ? spec : null;
|
|
2926
|
+
};
|
|
2927
|
+
const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getShopifyFlashListDependencySpec);
|
|
2928
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
2929
|
+
if (version === null || !isCatalogReference(version)) return version;
|
|
2930
|
+
const catalogName = extractCatalogName(version);
|
|
2931
|
+
const resolvedLocalVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
2932
|
+
if (resolvedLocalVersion) return resolvedLocalVersion;
|
|
2933
|
+
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
2934
|
+
if (!monorepoRoot) return version;
|
|
2935
|
+
const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
|
|
2936
|
+
if (!isFile(monorepoPackageJsonPath)) return version;
|
|
2937
|
+
return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
|
|
2938
|
+
};
|
|
2922
2939
|
const getPreactVersion = (packageJson) => {
|
|
2923
2940
|
return {
|
|
2924
2941
|
...packageJson.peerDependencies,
|
|
@@ -3158,19 +3175,18 @@ const discoverProject = (directory) => {
|
|
|
3158
3175
|
const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
|
|
3159
3176
|
const sourceFileCount = countSourceFiles(directory);
|
|
3160
3177
|
const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
}
|
|
3178
|
+
const expoVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
3179
|
+
rootDirectory: directory,
|
|
3180
|
+
rootPackageJson: packageJson,
|
|
3181
|
+
packageName: "expo",
|
|
3182
|
+
version: findExpoVersion(directory, packageJson)
|
|
3183
|
+
}) : null;
|
|
3184
|
+
const shopifyFlashListVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
3185
|
+
rootDirectory: directory,
|
|
3186
|
+
rootPackageJson: packageJson,
|
|
3187
|
+
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
3188
|
+
version: findShopifyFlashListVersion(directory, packageJson)
|
|
3189
|
+
}) : null;
|
|
3174
3190
|
const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
|
|
3175
3191
|
const preactVersion = getPreactVersion(packageJson);
|
|
3176
3192
|
const projectInfo = {
|
|
@@ -3189,6 +3205,8 @@ const discoverProject = (directory) => {
|
|
|
3189
3205
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
3190
3206
|
hasReactNativeWorkspace,
|
|
3191
3207
|
expoVersion,
|
|
3208
|
+
shopifyFlashListVersion,
|
|
3209
|
+
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
3192
3210
|
hasReanimated,
|
|
3193
3211
|
sourceFileCount
|
|
3194
3212
|
};
|
|
@@ -5454,6 +5472,63 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
5454
5472
|
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
5455
5473
|
return patterns;
|
|
5456
5474
|
};
|
|
5475
|
+
const KNIP_JSON_FILENAME = "knip.json";
|
|
5476
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5477
|
+
const readJsonFileSafe = (filePath) => {
|
|
5478
|
+
let rawContents;
|
|
5479
|
+
try {
|
|
5480
|
+
rawContents = fs.readFileSync(filePath, "utf-8");
|
|
5481
|
+
} catch {
|
|
5482
|
+
return null;
|
|
5483
|
+
}
|
|
5484
|
+
try {
|
|
5485
|
+
return JSON.parse(rawContents);
|
|
5486
|
+
} catch {
|
|
5487
|
+
return null;
|
|
5488
|
+
}
|
|
5489
|
+
};
|
|
5490
|
+
const readKnipConfig = (rootDirectory) => {
|
|
5491
|
+
const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
|
|
5492
|
+
if (isRecord$1(knipJson)) return knipJson;
|
|
5493
|
+
const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
|
|
5494
|
+
const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
|
|
5495
|
+
return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
|
|
5496
|
+
};
|
|
5497
|
+
const normalizePatternList = (value) => {
|
|
5498
|
+
if (typeof value === "string" && value.length > 0) return [value];
|
|
5499
|
+
if (!Array.isArray(value)) return [];
|
|
5500
|
+
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
5501
|
+
};
|
|
5502
|
+
const prefixWorkspacePatterns = (workspacePattern, patterns) => {
|
|
5503
|
+
const normalizedWorkspacePattern = workspacePattern.replace(/\/+$/, "");
|
|
5504
|
+
return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
|
|
5505
|
+
};
|
|
5506
|
+
const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
5507
|
+
if (!isRecord$1(workspaces)) return [];
|
|
5508
|
+
const patterns = [];
|
|
5509
|
+
for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
|
|
5510
|
+
if (!isRecord$1(workspaceConfig)) continue;
|
|
5511
|
+
patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
|
|
5512
|
+
}
|
|
5513
|
+
return patterns;
|
|
5514
|
+
};
|
|
5515
|
+
const collectKnipPatterns = (rootDirectory, settingName) => {
|
|
5516
|
+
const config = readKnipConfig(rootDirectory);
|
|
5517
|
+
if (!config) return [];
|
|
5518
|
+
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
5519
|
+
};
|
|
5520
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
5521
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5522
|
+
const sources = [
|
|
5523
|
+
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
5524
|
+
collectIgnorePatterns(rootDirectory),
|
|
5525
|
+
userConfig?.ignore?.files ?? [],
|
|
5526
|
+
collectKnipPatterns(rootDirectory, "ignore")
|
|
5527
|
+
];
|
|
5528
|
+
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
5529
|
+
return [...seen].filter((pattern) => pattern.length > 0);
|
|
5530
|
+
};
|
|
5531
|
+
const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipPatterns(rootDirectory, "entry"))].filter((pattern) => pattern.length > 0);
|
|
5457
5532
|
/**
|
|
5458
5533
|
* Resolves a path to its canonical, symlink-free form, falling back to
|
|
5459
5534
|
* the input when it cannot be realpath'd (broken symlink, permission
|
|
@@ -5479,6 +5554,7 @@ const toCanonicalPath = (filePath) => {
|
|
|
5479
5554
|
const DEAD_CODE_PLUGIN = "deslop";
|
|
5480
5555
|
const DEAD_CODE_CATEGORY = "Maintainability";
|
|
5481
5556
|
const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
|
|
5557
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5482
5558
|
const DEAD_CODE_WORKER_SCRIPT = `
|
|
5483
5559
|
const inputChunks = [];
|
|
5484
5560
|
process.stdin.on("data", (chunk) => inputChunks.push(chunk));
|
|
@@ -5519,6 +5595,9 @@ process.stdin.on("end", () => {
|
|
|
5519
5595
|
const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
|
|
5520
5596
|
const config = {
|
|
5521
5597
|
rootDir: workerInput.rootDirectory,
|
|
5598
|
+
...(workerInput.entryPatterns.length > 0
|
|
5599
|
+
? { entryPatterns: workerInput.entryPatterns }
|
|
5600
|
+
: {}),
|
|
5522
5601
|
...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
|
|
5523
5602
|
...(workerInput.ignorePatterns.length > 0
|
|
5524
5603
|
? { ignorePatterns: workerInput.ignorePatterns }
|
|
@@ -5538,21 +5617,10 @@ const resolveTsConfigPath = (rootDirectory) => {
|
|
|
5538
5617
|
if (fs.existsSync(candidate)) return candidate;
|
|
5539
5618
|
}
|
|
5540
5619
|
};
|
|
5541
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
5542
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5543
|
-
const sources = [
|
|
5544
|
-
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
5545
|
-
collectIgnorePatterns(rootDirectory),
|
|
5546
|
-
userConfig?.ignore?.files ?? []
|
|
5547
|
-
];
|
|
5548
|
-
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
5549
|
-
return [...seen].filter((pattern) => pattern.length > 0);
|
|
5550
|
-
};
|
|
5551
5620
|
const toRelativeFilePath = (rootDirectory, filePath) => {
|
|
5552
5621
|
const relative = toRelativePath(filePath, rootDirectory);
|
|
5553
5622
|
return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
|
|
5554
5623
|
};
|
|
5555
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5556
5624
|
const parseArray = (value, label) => {
|
|
5557
5625
|
if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
|
|
5558
5626
|
return value;
|
|
@@ -5735,9 +5803,11 @@ const checkDeadCode = async (options) => {
|
|
|
5735
5803
|
const { userConfig } = options;
|
|
5736
5804
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
5737
5805
|
if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
|
|
5806
|
+
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
5738
5807
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
|
|
5739
5808
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
5740
5809
|
rootDirectory,
|
|
5810
|
+
entryPatterns,
|
|
5741
5811
|
tsConfigPath: resolveTsConfigPath(rootDirectory),
|
|
5742
5812
|
ignorePatterns,
|
|
5743
5813
|
deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
|
|
@@ -6811,6 +6881,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
6811
6881
|
settings: { "react-doctor": {
|
|
6812
6882
|
framework: project.framework,
|
|
6813
6883
|
rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
|
|
6884
|
+
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
6814
6885
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
6815
6886
|
} },
|
|
6816
6887
|
rules: {
|
|
@@ -8032,6 +8103,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
8032
8103
|
...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
|
|
8033
8104
|
...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
|
|
8034
8105
|
...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
|
|
8106
|
+
...options.metadata?.runId ? { runId: options.metadata.runId } : {},
|
|
8035
8107
|
...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
|
|
8036
8108
|
...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
|
|
8037
8109
|
...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
|
|
@@ -8271,6 +8343,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8271
8343
|
sourceFileCount: project.sourceFileCount,
|
|
8272
8344
|
...defaultBranch !== null ? { defaultBranch } : {},
|
|
8273
8345
|
...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
|
|
8346
|
+
...input.runId !== void 0 ? { runId: input.runId } : {},
|
|
8274
8347
|
...githubActionsScoreMetadata,
|
|
8275
8348
|
...githubViewerPermission !== null ? { githubViewerPermission } : {}
|
|
8276
8349
|
};
|
|
@@ -8727,4 +8800,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8727
8800
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8728
8801
|
|
|
8729
8802
|
//# sourceMappingURL=index.js.map
|
|
8730
|
-
//# debugId=
|
|
8803
|
+
//# debugId=ee53eb02-91ef-5d50-b736-4734e9a14f5d
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.2.18-dev.
|
|
3
|
+
"version": "0.2.18-dev.87440ab",
|
|
4
4
|
"description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"oxlint": "^1.66.0",
|
|
64
64
|
"prompts": "^2.4.2",
|
|
65
65
|
"typescript": ">=5.0.4 <7",
|
|
66
|
-
"oxlint-plugin-react-doctor": "0.2.18-dev.
|
|
66
|
+
"oxlint-plugin-react-doctor": "0.2.18-dev.87440ab"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/babel__code-frame": "^7.27.0",
|