fix(scripts): source-attribution CLI silently no-ops on Windows - #7334
Open
m114720025-wq wants to merge 1 commit into
Open
fix(scripts): source-attribution CLI silently no-ops on Windows#7334m114720025-wq wants to merge 1 commit into
m114720025-wq wants to merge 1 commit into
Conversation
## What
On Windows, `process.argv[1]` is an absolute path with backslash separators
(e.g. `C:\Users\me\worldmonitor\scripts\source-attribution.mjs`), so this file's
entrypoint guard
process.argv[1].endsWith('scripts/source-attribution.mjs')
is always false. The CLI body never executes: `node scripts/source-attribution.mjs --write`
prints nothing and exits 0, silently pretending to have succeeded.
## Why it matters
Because the manifest is never regenerated on Windows, `npm run inventory:facts` fails
during `postinstall`, `api/_inventory-facts.generated.js` is never produced, and
`npm run dev` dies with:
[plugin:vite:import-analysis] Failed to resolve import
"./_inventory-facts.generated.js" from "api/product-catalog.js"
That is exactly the failure reported in koala73#6885, which was closed without a code change.
The guidance embedded in that failure's own error message tells the user to
"run node scripts/source-attribution.mjs --write" — the one command that cannot work
on the platform hitting the bug.
Net effect: the README Quick Start does not work on a clean Windows checkout.
## Same bug class as koala73#7168
koala73#7168 fixed the identical pattern in the Dockerfile-COPY guards — a `/`-assuming path
comparison that silently no-ops on Windows. This is that same bug, in the
source-attribution entrypoint guard.
## Fix
Normalise separators before the suffix comparison. No behaviour change on macOS/Linux.
## Verification
Windows 11, Node v24.18.0, npm 11.16.0.
Before: `node scripts/source-attribution.mjs --write` produced no output, exited 0,
and left the manifest untouched.
After: the same command reports
`source-attribution: 578 active hosts across 574 providers` and writes the manifest;
`node scripts/generate-inventory-facts.mjs` then succeeds, and `npm run dev` starts cleanly.
|
@m114720025-wq is attempting to deploy a commit to the World Monitor Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Windows,
process.argv[1]is an absolute path with backslash separators(e.g.
C:\Users\me\worldmonitor\scripts\source-attribution.mjs), so this file'sentrypoint guard
is always false. The CLI body never executes:
node scripts/source-attribution.mjs --writeprints nothing and exits 0, silently pretending to have succeeded.
Why it matters
Because the manifest is never regenerated on Windows,
npm run inventory:factsfailsduring
postinstall,api/_inventory-facts.generated.jsis never produced, andnpm run devdies with:That is exactly the failure reported in #6885, which was closed without a code change.
The guidance embedded in that failure's own error message tells the user to
"run node scripts/source-attribution.mjs --write" — the one command that cannot work
on the platform hitting the bug.
Net effect: the README Quick Start does not work on a clean Windows checkout.
Same bug class as #7168
#7168 fixed the identical pattern in the Dockerfile-COPY guards — a
/-assuming pathcomparison that silently no-ops on Windows. This is that same bug, in the
source-attribution entrypoint guard.
Fix
Normalise separators before the suffix comparison. No behaviour change on macOS/Linux,
where paths contain no backslashes and the
replaceis a no-op.Verification
Windows 11, Node v24.18.0, npm 11.16.0.
Before:
node scripts/source-attribution.mjs --writeproduced no output, exited 0,and left the manifest untouched.
After: the same command reports
source-attribution: 578 active hosts across 574 providersand writes the manifest;node scripts/generate-inventory-facts.mjsthen succeeds, andnpm run devstarts cleanly.Type of change
Affected areas
/api/*)scripts/source-attribution.mjsentrypoint guardChecklist
api/rss-proxy.jsallowlist — N/A: no feeds addednpm run typecheck) — N/A: plain.mjsbuild script, not part of the TypeScript projectDocumentation Alignment Checklist
N/A — this PR does not publish or change any documentation claims.
Screenshots
N/A — terminal output is included in the Verification section above.
Note
Diagnosed and drafted with AI assistance (Claude), per CONTRIBUTING.md's AI-assisted
development policy. I reproduced the failure on my own Windows machine, confirmed the
root cause by printing the guard's comparison result, and can explain the change.