fix(scripts): make the backfill scripts actually runnable - #161
Merged
Merged
Conversation
- tsconfig: drop explicit typeRoots so TS's default upward @types search works under both hoisted-to-root and installed-in-backend npm layouts (fixes TS2580 'Cannot find name process' when node_modules is hoisted) - entry guard: detect CJS (require.main === module) vs native ESM (typeof require === 'undefined') so main() runs under both ts-node and Node's native .ts execution, instead of only ts-node/CommonJS - wire canonical, directory-independent npm scripts: backfill:org-ids and backfill:org-name-reservations - add a subprocess smoke test that executes each script as a real CLI (npm run / ts-node / native node) and asserts on exit code + stderr, since unit-testing exported functions alone let this ship unrunnable - tighten pre-existing 'any' types in backfill-org-ids.ts (blocked lint-staged's --max-warnings 0 gate on this now-touched file) Sibling scripts/backfill-app-stage-vars.ts already uses the same require.main guard shape but was out of scope (not named in the defect report); noted for follow-up. src/lambda/backfill-project-org.ts has no CLI entry point (Lambda-only, manually invoked), so causes (a)/(b) do not apply to 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
backfill-org-name-reservations.tscould not be run. Operational failures when trying, because three separate defects stacked - and none was caught in review, since the script was verified by unit-testing its exported functions and never executed as a CLI.backend/tsconfig-jsonpinnedtypeRoots: ["-/node_modules/@types"], resolving tobackend/node_modules/@types- nonexistent when pm hoists the workspace install to the repo root. Result:TS2580: Cannot find name 'process'This was invisible in a clone that installs inside backend/, which is exactly why it shippedimportstatements with a Commonsrequire.main === moduleentry guard. Fine underts-node; under Node's native TypeScript execution (23+) the file is ESM andrequireis undefinednpxresolution and the current directory