react-doctor 0.2.15-dev.17e722e → 0.2.15-dev.520b0a9
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 +116 -17
- package/dist/index.d.ts +7 -6
- package/dist/index.js +92 -13
- package/package.json +4 -4
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]="c8bf2d99-8f0b-55f1-a894-63e600bf000b")}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";
|
|
@@ -8975,6 +8975,11 @@ const trimOrNull = (value) => {
|
|
|
8975
8975
|
* `@{` reflog suffix, or any character outside `[A-Za-z0-9_./-]`.
|
|
8976
8976
|
*/
|
|
8977
8977
|
const SAFE_GIT_REVISION_PATTERN = /^[A-Za-z0-9_./-]+$/;
|
|
8978
|
+
/** Human-readable summary of the `isSafeGitRevision` contract, reused across error details. */
|
|
8979
|
+
const GIT_REF_NAME_RULE = "must match [A-Za-z0-9_./-] without leading '-', '..', or '@{'";
|
|
8980
|
+
/** git's two range operators: two-dot (direct) and three-dot (merge-base). */
|
|
8981
|
+
const DIFF_RANGE_OPERATOR = "..";
|
|
8982
|
+
const SYMMETRIC_DIFF_RANGE_OPERATOR = "...";
|
|
8978
8983
|
const isSafeGitRevision = (candidate) => {
|
|
8979
8984
|
if (candidate.length === 0) return false;
|
|
8980
8985
|
if (candidate.startsWith("-")) return false;
|
|
@@ -8982,6 +8987,31 @@ const isSafeGitRevision = (candidate) => {
|
|
|
8982
8987
|
if (candidate.includes("..") || candidate.includes("@{")) return false;
|
|
8983
8988
|
return SAFE_GIT_REVISION_PATTERN.test(candidate);
|
|
8984
8989
|
};
|
|
8990
|
+
/**
|
|
8991
|
+
* Splits a git revision range into its endpoints: three-dot `A...B`
|
|
8992
|
+
* (symmetric, merge-base) or two-dot `A..B` (direct). Returns `null`
|
|
8993
|
+
* when `value` carries no range operator so the caller falls back to
|
|
8994
|
+
* single-base resolution.
|
|
8995
|
+
*
|
|
8996
|
+
* Only the first operator is split on; any leftover `..` stays inside an
|
|
8997
|
+
* endpoint so `isSafeGitRevision` rejects malformed input like
|
|
8998
|
+
* `A..B..C` instead of silently guessing which pair the user meant.
|
|
8999
|
+
*/
|
|
9000
|
+
const parseGitDiffRange = (value) => {
|
|
9001
|
+
const symmetricIndex = value.indexOf(SYMMETRIC_DIFF_RANGE_OPERATOR);
|
|
9002
|
+
if (symmetricIndex !== -1) return {
|
|
9003
|
+
base: value.slice(0, symmetricIndex),
|
|
9004
|
+
head: value.slice(symmetricIndex + 3),
|
|
9005
|
+
symmetric: true
|
|
9006
|
+
};
|
|
9007
|
+
const rangeIndex = value.indexOf(DIFF_RANGE_OPERATOR);
|
|
9008
|
+
if (rangeIndex !== -1) return {
|
|
9009
|
+
base: value.slice(0, rangeIndex),
|
|
9010
|
+
head: value.slice(rangeIndex + 2),
|
|
9011
|
+
symmetric: false
|
|
9012
|
+
};
|
|
9013
|
+
return null;
|
|
9014
|
+
};
|
|
8985
9015
|
const parseGithubRepoFromRemoteUrl = (remoteUrl) => {
|
|
8986
9016
|
const withoutGitSuffix = remoteUrl.trim().replace(/\.git$/, "");
|
|
8987
9017
|
const sshMatch = /^git@github\.com:([^/\s]+)\/([^/\s]+)$/.exec(withoutGitSuffix);
|
|
@@ -9133,6 +9163,49 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
9133
9163
|
if (result.status !== 0) return null;
|
|
9134
9164
|
return parseGithubViewerPermission(result.stdout);
|
|
9135
9165
|
}).pipe(Effect.catch(() => Effect.succeed(null)));
|
|
9166
|
+
/**
|
|
9167
|
+
* Resolves a `--diff A..B` / `A...B` commit range into a changed-file
|
|
9168
|
+
* selection. Each endpoint is validated with `isSafeGitRevision`
|
|
9169
|
+
* BEFORE it reaches `git` (so the range syntax can't smuggle a
|
|
9170
|
+
* `--upload-pack=…`-style option past the CVE-2018-17456 guard) and
|
|
9171
|
+
* verified to exist, then the diff runs between the two commits with
|
|
9172
|
+
* the same `--diff-filter=ACMR` shape the single-base path uses.
|
|
9173
|
+
*/
|
|
9174
|
+
const resolveDiffRange = (input) => Effect.gen(function* () {
|
|
9175
|
+
if (input.range.base.length === 0 && input.range.head.length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" must name at least one commit (e.g. "main..feature").` }) }));
|
|
9176
|
+
const baseRef = input.range.base.length === 0 ? "HEAD" : input.range.base;
|
|
9177
|
+
const headRef = input.range.head.length === 0 ? "HEAD" : input.range.head;
|
|
9178
|
+
for (const endpoint of [baseRef, headRef]) if (!isSafeGitRevision(endpoint)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" has an invalid endpoint "${endpoint}" (${GIT_REF_NAME_RULE}).` }) }));
|
|
9179
|
+
for (const endpoint of [baseRef, headRef]) if (!(yield* branchExists(input.directory, endpoint))) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchMissing({ branch: endpoint }) }));
|
|
9180
|
+
let diffBaseRef = baseRef;
|
|
9181
|
+
if (input.range.symmetric) {
|
|
9182
|
+
const mergeBase = yield* runGit(input.directory, [
|
|
9183
|
+
"merge-base",
|
|
9184
|
+
baseRef,
|
|
9185
|
+
headRef
|
|
9186
|
+
]);
|
|
9187
|
+
if (mergeBase.status !== 0) return null;
|
|
9188
|
+
const mergeBaseRef = trimOrNull(mergeBase.stdout);
|
|
9189
|
+
if (mergeBaseRef === null) return null;
|
|
9190
|
+
diffBaseRef = mergeBaseRef;
|
|
9191
|
+
}
|
|
9192
|
+
const diff = yield* runGit(input.directory, [
|
|
9193
|
+
"diff",
|
|
9194
|
+
"-z",
|
|
9195
|
+
"--name-only",
|
|
9196
|
+
"--diff-filter=ACMR",
|
|
9197
|
+
"--relative",
|
|
9198
|
+
diffBaseRef,
|
|
9199
|
+
headRef
|
|
9200
|
+
]);
|
|
9201
|
+
if (diff.status !== 0) return null;
|
|
9202
|
+
return {
|
|
9203
|
+
currentBranch: yield* currentBranch(input.directory),
|
|
9204
|
+
baseBranch: baseRef,
|
|
9205
|
+
changedFiles: splitNullSeparated(diff.stdout),
|
|
9206
|
+
isCurrentChanges: false
|
|
9207
|
+
};
|
|
9208
|
+
});
|
|
9136
9209
|
return Git.of({
|
|
9137
9210
|
currentBranch,
|
|
9138
9211
|
defaultBranch,
|
|
@@ -9142,7 +9215,15 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
9142
9215
|
branchExists,
|
|
9143
9216
|
diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
|
|
9144
9217
|
if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
|
|
9145
|
-
if (explicitBaseBranch !== void 0
|
|
9218
|
+
if (explicitBaseBranch !== void 0) {
|
|
9219
|
+
const range = parseGitDiffRange(explicitBaseBranch);
|
|
9220
|
+
if (range !== null) return yield* resolveDiffRange({
|
|
9221
|
+
directory,
|
|
9222
|
+
range,
|
|
9223
|
+
raw: explicitBaseBranch
|
|
9224
|
+
});
|
|
9225
|
+
if (!isSafeGitRevision(explicitBaseBranch)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff base branch "${explicitBaseBranch}" is not a valid git ref name (${GIT_REF_NAME_RULE}).` }) }));
|
|
9226
|
+
}
|
|
9146
9227
|
const resolvedCurrentBranch = yield* currentBranch(directory);
|
|
9147
9228
|
if (resolvedCurrentBranch === null && explicitBaseBranch === void 0) return null;
|
|
9148
9229
|
const baseBranch = explicitBaseBranch ?? (yield* defaultBranch(directory));
|
|
@@ -11524,12 +11605,13 @@ const buildSkippedChecks = (input) => {
|
|
|
11524
11605
|
* Git service runs through Effect's `ChildProcess` (true subprocess
|
|
11525
11606
|
* spawn, not `spawnSync`).
|
|
11526
11607
|
*
|
|
11527
|
-
*
|
|
11528
|
-
*
|
|
11529
|
-
*
|
|
11530
|
-
*
|
|
11531
|
-
*
|
|
11532
|
-
*
|
|
11608
|
+
* Failures propagate as the tagged `ReactDoctorError` (rejected by
|
|
11609
|
+
* `Effect.runPromise`) rather than being flattened into a plain
|
|
11610
|
+
* `Error`. The message is unchanged — `ReactDoctorError.message`
|
|
11611
|
+
* defers to `reason.message` — so message-matching callers keep
|
|
11612
|
+
* working, while the CLI can now dispatch on `error.reason._tag` to
|
|
11613
|
+
* render diff-base mistakes (`GitBaseBranchInvalid` /
|
|
11614
|
+
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
11533
11615
|
*/
|
|
11534
11616
|
const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.gen(function* () {
|
|
11535
11617
|
const selection = yield* (yield* Git).diffSelection({
|
|
@@ -11543,10 +11625,7 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
|
|
|
11543
11625
|
changedFiles: [...selection.changedFiles],
|
|
11544
11626
|
...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
|
|
11545
11627
|
};
|
|
11546
|
-
}).pipe(Effect.provide(Git.layerNode)
|
|
11547
|
-
GitBaseBranchInvalid: (reason) => Effect.die(new Error(reason.detail)),
|
|
11548
|
-
GitBaseBranchMissing: (reason) => Effect.die(new Error(reason.message))
|
|
11549
|
-
})));
|
|
11628
|
+
}).pipe(Effect.provide(Git.layerNode)));
|
|
11550
11629
|
const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
|
|
11551
11630
|
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11552
11631
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
@@ -11828,7 +11907,7 @@ const makeNoopConsole = () => ({
|
|
|
11828
11907
|
});
|
|
11829
11908
|
//#endregion
|
|
11830
11909
|
//#region src/cli/utils/version.ts
|
|
11831
|
-
const VERSION = "0.2.15-dev.
|
|
11910
|
+
const VERSION = "0.2.15-dev.520b0a9";
|
|
11832
11911
|
//#endregion
|
|
11833
11912
|
//#region src/cli/utils/json-mode.ts
|
|
11834
11913
|
let context = null;
|
|
@@ -12174,13 +12253,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12174
12253
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12175
12254
|
* standard `SENTRY_RELEASE` override.
|
|
12176
12255
|
*/
|
|
12177
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.15-dev.
|
|
12256
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.15-dev.520b0a9`;
|
|
12178
12257
|
/**
|
|
12179
12258
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12180
12259
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12181
12260
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12182
12261
|
*/
|
|
12183
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.15-dev.
|
|
12262
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.15-dev.520b0a9") ? "development" : "production");
|
|
12184
12263
|
/**
|
|
12185
12264
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12186
12265
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -16778,6 +16857,21 @@ const handleError = (error, options = {}) => {
|
|
|
16778
16857
|
if (options.shouldExit !== false) process.exit(1);
|
|
16779
16858
|
process.exitCode = 1;
|
|
16780
16859
|
};
|
|
16860
|
+
/**
|
|
16861
|
+
* Renderer for expected, user-actionable failures — a bad `--diff` value or
|
|
16862
|
+
* a base branch that isn't fetched. Prints just the (already human-readable)
|
|
16863
|
+
* message — no "Something went wrong", prefilled issue, Discord link, or
|
|
16864
|
+
* Sentry reference — because there is no bug to report.
|
|
16865
|
+
*/
|
|
16866
|
+
const handleUserError = (error, options = {}) => {
|
|
16867
|
+
Effect.runSync(Effect.gen(function* () {
|
|
16868
|
+
yield* Console.error("");
|
|
16869
|
+
yield* Console.error(highlighter.error(formatErrorForReport(error)));
|
|
16870
|
+
yield* Console.error("");
|
|
16871
|
+
}));
|
|
16872
|
+
if (options.shouldExit !== false) process.exit(1);
|
|
16873
|
+
process.exitCode = 1;
|
|
16874
|
+
};
|
|
16781
16875
|
//#endregion
|
|
16782
16876
|
//#region src/cli/utils/build-handoff-payload.ts
|
|
16783
16877
|
const buildHandoffPayload = (input) => {
|
|
@@ -19022,12 +19116,17 @@ const inspectAction = async (directory, flags) => {
|
|
|
19022
19116
|
}
|
|
19023
19117
|
}
|
|
19024
19118
|
} catch (error) {
|
|
19025
|
-
const
|
|
19119
|
+
const isUserError = isReactDoctorError(error) && (error.reason._tag === "GitBaseBranchInvalid" || error.reason._tag === "GitBaseBranchMissing");
|
|
19120
|
+
const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
|
|
19026
19121
|
if (isJsonMode) {
|
|
19027
19122
|
writeJsonErrorReport(error);
|
|
19028
19123
|
process.exitCode = 1;
|
|
19029
19124
|
return;
|
|
19030
19125
|
}
|
|
19126
|
+
if (isUserError) {
|
|
19127
|
+
handleUserError(error);
|
|
19128
|
+
return;
|
|
19129
|
+
}
|
|
19031
19130
|
handleError(error, { sentryEventId });
|
|
19032
19131
|
}
|
|
19033
19132
|
};
|
|
@@ -19921,4 +20020,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
|
|
|
19921
20020
|
export {};
|
|
19922
20021
|
|
|
19923
20022
|
//# sourceMappingURL=cli.js.map
|
|
19924
|
-
//# debugId=
|
|
20023
|
+
//# debugId=c8bf2d99-8f0b-55f1-a894-63e600bf000b
|
package/dist/index.d.ts
CHANGED
|
@@ -772,12 +772,13 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#e
|
|
|
772
772
|
* Git service runs through Effect's `ChildProcess` (true subprocess
|
|
773
773
|
* spawn, not `spawnSync`).
|
|
774
774
|
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
775
|
+
* Failures propagate as the tagged `ReactDoctorError` (rejected by
|
|
776
|
+
* `Effect.runPromise`) rather than being flattened into a plain
|
|
777
|
+
* `Error`. The message is unchanged — `ReactDoctorError.message`
|
|
778
|
+
* defers to `reason.message` — so message-matching callers keep
|
|
779
|
+
* working, while the CLI can now dispatch on `error.reason._tag` to
|
|
780
|
+
* render diff-base mistakes (`GitBaseBranchInvalid` /
|
|
781
|
+
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
781
782
|
*/
|
|
782
783
|
declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
|
|
783
784
|
declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
|
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]="3967254f-df21-5398-99d5-ee0d17b33e7b")}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";
|
|
@@ -5928,6 +5928,11 @@ const trimOrNull = (value) => {
|
|
|
5928
5928
|
* `@{` reflog suffix, or any character outside `[A-Za-z0-9_./-]`.
|
|
5929
5929
|
*/
|
|
5930
5930
|
const SAFE_GIT_REVISION_PATTERN = /^[A-Za-z0-9_./-]+$/;
|
|
5931
|
+
/** Human-readable summary of the `isSafeGitRevision` contract, reused across error details. */
|
|
5932
|
+
const GIT_REF_NAME_RULE = "must match [A-Za-z0-9_./-] without leading '-', '..', or '@{'";
|
|
5933
|
+
/** git's two range operators: two-dot (direct) and three-dot (merge-base). */
|
|
5934
|
+
const DIFF_RANGE_OPERATOR = "..";
|
|
5935
|
+
const SYMMETRIC_DIFF_RANGE_OPERATOR = "...";
|
|
5931
5936
|
const isSafeGitRevision = (candidate) => {
|
|
5932
5937
|
if (candidate.length === 0) return false;
|
|
5933
5938
|
if (candidate.startsWith("-")) return false;
|
|
@@ -5935,6 +5940,31 @@ const isSafeGitRevision = (candidate) => {
|
|
|
5935
5940
|
if (candidate.includes("..") || candidate.includes("@{")) return false;
|
|
5936
5941
|
return SAFE_GIT_REVISION_PATTERN.test(candidate);
|
|
5937
5942
|
};
|
|
5943
|
+
/**
|
|
5944
|
+
* Splits a git revision range into its endpoints: three-dot `A...B`
|
|
5945
|
+
* (symmetric, merge-base) or two-dot `A..B` (direct). Returns `null`
|
|
5946
|
+
* when `value` carries no range operator so the caller falls back to
|
|
5947
|
+
* single-base resolution.
|
|
5948
|
+
*
|
|
5949
|
+
* Only the first operator is split on; any leftover `..` stays inside an
|
|
5950
|
+
* endpoint so `isSafeGitRevision` rejects malformed input like
|
|
5951
|
+
* `A..B..C` instead of silently guessing which pair the user meant.
|
|
5952
|
+
*/
|
|
5953
|
+
const parseGitDiffRange = (value) => {
|
|
5954
|
+
const symmetricIndex = value.indexOf(SYMMETRIC_DIFF_RANGE_OPERATOR);
|
|
5955
|
+
if (symmetricIndex !== -1) return {
|
|
5956
|
+
base: value.slice(0, symmetricIndex),
|
|
5957
|
+
head: value.slice(symmetricIndex + 3),
|
|
5958
|
+
symmetric: true
|
|
5959
|
+
};
|
|
5960
|
+
const rangeIndex = value.indexOf(DIFF_RANGE_OPERATOR);
|
|
5961
|
+
if (rangeIndex !== -1) return {
|
|
5962
|
+
base: value.slice(0, rangeIndex),
|
|
5963
|
+
head: value.slice(rangeIndex + 2),
|
|
5964
|
+
symmetric: false
|
|
5965
|
+
};
|
|
5966
|
+
return null;
|
|
5967
|
+
};
|
|
5938
5968
|
const parseGithubRepoFromRemoteUrl = (remoteUrl) => {
|
|
5939
5969
|
const withoutGitSuffix = remoteUrl.trim().replace(/\.git$/, "");
|
|
5940
5970
|
const sshMatch = /^git@github\.com:([^/\s]+)\/([^/\s]+)$/.exec(withoutGitSuffix);
|
|
@@ -6086,6 +6116,49 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6086
6116
|
if (result.status !== 0) return null;
|
|
6087
6117
|
return parseGithubViewerPermission(result.stdout);
|
|
6088
6118
|
}).pipe(Effect.catch(() => Effect.succeed(null)));
|
|
6119
|
+
/**
|
|
6120
|
+
* Resolves a `--diff A..B` / `A...B` commit range into a changed-file
|
|
6121
|
+
* selection. Each endpoint is validated with `isSafeGitRevision`
|
|
6122
|
+
* BEFORE it reaches `git` (so the range syntax can't smuggle a
|
|
6123
|
+
* `--upload-pack=…`-style option past the CVE-2018-17456 guard) and
|
|
6124
|
+
* verified to exist, then the diff runs between the two commits with
|
|
6125
|
+
* the same `--diff-filter=ACMR` shape the single-base path uses.
|
|
6126
|
+
*/
|
|
6127
|
+
const resolveDiffRange = (input) => Effect.gen(function* () {
|
|
6128
|
+
if (input.range.base.length === 0 && input.range.head.length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" must name at least one commit (e.g. "main..feature").` }) }));
|
|
6129
|
+
const baseRef = input.range.base.length === 0 ? "HEAD" : input.range.base;
|
|
6130
|
+
const headRef = input.range.head.length === 0 ? "HEAD" : input.range.head;
|
|
6131
|
+
for (const endpoint of [baseRef, headRef]) if (!isSafeGitRevision(endpoint)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff range "${input.raw}" has an invalid endpoint "${endpoint}" (${GIT_REF_NAME_RULE}).` }) }));
|
|
6132
|
+
for (const endpoint of [baseRef, headRef]) if (!(yield* branchExists(input.directory, endpoint))) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchMissing({ branch: endpoint }) }));
|
|
6133
|
+
let diffBaseRef = baseRef;
|
|
6134
|
+
if (input.range.symmetric) {
|
|
6135
|
+
const mergeBase = yield* runGit(input.directory, [
|
|
6136
|
+
"merge-base",
|
|
6137
|
+
baseRef,
|
|
6138
|
+
headRef
|
|
6139
|
+
]);
|
|
6140
|
+
if (mergeBase.status !== 0) return null;
|
|
6141
|
+
const mergeBaseRef = trimOrNull(mergeBase.stdout);
|
|
6142
|
+
if (mergeBaseRef === null) return null;
|
|
6143
|
+
diffBaseRef = mergeBaseRef;
|
|
6144
|
+
}
|
|
6145
|
+
const diff = yield* runGit(input.directory, [
|
|
6146
|
+
"diff",
|
|
6147
|
+
"-z",
|
|
6148
|
+
"--name-only",
|
|
6149
|
+
"--diff-filter=ACMR",
|
|
6150
|
+
"--relative",
|
|
6151
|
+
diffBaseRef,
|
|
6152
|
+
headRef
|
|
6153
|
+
]);
|
|
6154
|
+
if (diff.status !== 0) return null;
|
|
6155
|
+
return {
|
|
6156
|
+
currentBranch: yield* currentBranch(input.directory),
|
|
6157
|
+
baseBranch: baseRef,
|
|
6158
|
+
changedFiles: splitNullSeparated(diff.stdout),
|
|
6159
|
+
isCurrentChanges: false
|
|
6160
|
+
};
|
|
6161
|
+
});
|
|
6089
6162
|
return Git.of({
|
|
6090
6163
|
currentBranch,
|
|
6091
6164
|
defaultBranch,
|
|
@@ -6095,7 +6168,15 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6095
6168
|
branchExists,
|
|
6096
6169
|
diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
|
|
6097
6170
|
if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
|
|
6098
|
-
if (explicitBaseBranch !== void 0
|
|
6171
|
+
if (explicitBaseBranch !== void 0) {
|
|
6172
|
+
const range = parseGitDiffRange(explicitBaseBranch);
|
|
6173
|
+
if (range !== null) return yield* resolveDiffRange({
|
|
6174
|
+
directory,
|
|
6175
|
+
range,
|
|
6176
|
+
raw: explicitBaseBranch
|
|
6177
|
+
});
|
|
6178
|
+
if (!isSafeGitRevision(explicitBaseBranch)) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: `Diff base branch "${explicitBaseBranch}" is not a valid git ref name (${GIT_REF_NAME_RULE}).` }) }));
|
|
6179
|
+
}
|
|
6099
6180
|
const resolvedCurrentBranch = yield* currentBranch(directory);
|
|
6100
6181
|
if (resolvedCurrentBranch === null && explicitBaseBranch === void 0) return null;
|
|
6101
6182
|
const baseBranch = explicitBaseBranch ?? (yield* defaultBranch(directory));
|
|
@@ -8453,12 +8534,13 @@ const buildSkippedChecks = (input) => {
|
|
|
8453
8534
|
* Git service runs through Effect's `ChildProcess` (true subprocess
|
|
8454
8535
|
* spawn, not `spawnSync`).
|
|
8455
8536
|
*
|
|
8456
|
-
*
|
|
8457
|
-
*
|
|
8458
|
-
*
|
|
8459
|
-
*
|
|
8460
|
-
*
|
|
8461
|
-
*
|
|
8537
|
+
* Failures propagate as the tagged `ReactDoctorError` (rejected by
|
|
8538
|
+
* `Effect.runPromise`) rather than being flattened into a plain
|
|
8539
|
+
* `Error`. The message is unchanged — `ReactDoctorError.message`
|
|
8540
|
+
* defers to `reason.message` — so message-matching callers keep
|
|
8541
|
+
* working, while the CLI can now dispatch on `error.reason._tag` to
|
|
8542
|
+
* render diff-base mistakes (`GitBaseBranchInvalid` /
|
|
8543
|
+
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
8462
8544
|
*/
|
|
8463
8545
|
const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.gen(function* () {
|
|
8464
8546
|
const selection = yield* (yield* Git).diffSelection({
|
|
@@ -8472,10 +8554,7 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
|
|
|
8472
8554
|
changedFiles: [...selection.changedFiles],
|
|
8473
8555
|
...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
|
|
8474
8556
|
};
|
|
8475
|
-
}).pipe(Effect.provide(Git.layerNode)
|
|
8476
|
-
GitBaseBranchInvalid: (reason) => Effect.die(new Error(reason.detail)),
|
|
8477
|
-
GitBaseBranchMissing: (reason) => Effect.die(new Error(reason.message))
|
|
8478
|
-
})));
|
|
8557
|
+
}).pipe(Effect.provide(Git.layerNode)));
|
|
8479
8558
|
const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
|
|
8480
8559
|
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8481
8560
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
@@ -8620,4 +8699,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8620
8699
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8621
8700
|
|
|
8622
8701
|
//# sourceMappingURL=index.js.map
|
|
8623
|
-
//# debugId=
|
|
8702
|
+
//# debugId=3967254f-df21-5398-99d5-ee0d17b33e7b
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.2.15-dev.
|
|
3
|
+
"version": "0.2.15-dev.520b0a9",
|
|
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.15-dev.
|
|
66
|
+
"oxlint-plugin-react-doctor": "0.2.15-dev.520b0a9"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"@xterm/headless": "^6.0.0",
|
|
72
72
|
"commander": "^14.0.3",
|
|
73
73
|
"ora": "^9.4.0",
|
|
74
|
-
"@react-doctor/
|
|
75
|
-
"@react-doctor/
|
|
74
|
+
"@react-doctor/core": "0.2.15",
|
|
75
|
+
"@react-doctor/api": "0.2.15"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": "^20.19.0 || >=22.12.0"
|