Skip to content

fix(scripts): resolve repo root in strict-types generator after scripts/repo move#668

Closed
John-David Dalton (jdalton) wants to merge 1 commit into
mainfrom
fix/strict-types-generator-rootpath
Closed

fix(scripts): resolve repo root in strict-types generator after scripts/repo move#668
John-David Dalton (jdalton) wants to merge 1 commit into
mainfrom
fix/strict-types-generator-rootpath

Conversation

@jdalton

Copy link
Copy Markdown
Collaborator

What

getRootPath() in scripts/utils/path-helpers.mts walked up a fixed single directory level. That resolved the repo root correctly when the scripts lived one level deep, but the fleet migration moved them into scripts/repo/ (and scripts/utils/), so the strict-types generator then looked for openapi.json under scripts/ and could not run.

Fix

Walk up to the nearest package.json-bearing ancestor instead of a fixed depth, mirroring resolveRepoRoot() in scripts/fleet/paths.mts. This is depth-independent, so it stays correct across future directory moves and fixes every sibling script under scripts/repo/ that shares this helper.

Context

Found while landing PR #667 (the org-list/plan type fixes): the strict-types generator is auto-generated from openapi.json, but it could not be run straight because of this path bug — the fix there had to be validated by pointing the generator at the spec's expected path manually. This makes the generator runnable from its real location again.

Verification

Scoped to the one helper (+25/-2). CI runs typecheck, lint, and the generated-types-are-current check.

…fter scripts/repo move

getRootPath() walked up a fixed single level, which resolved the repo
root correctly when scripts lived one level deep but broke after the
fleet migration moved them into scripts/repo/ (and scripts/utils/).
The strict-types generator then looked for openapi.json under scripts/
and could not run.

Walk up to the nearest package.json-bearing ancestor instead, mirroring
resolveRepoRoot() in scripts/fleet/paths.mts. Depth-independent, so it
stays correct across future directory moves and fixes every sibling
script under scripts/repo/ that shares this helper.
@jdalton

Copy link
Copy Markdown
Collaborator Author

Closing — this patched a repo-local getRootPath in a non-segmented scripts/utils/ dir, which is the wrong boundary. Reworking correctly: repo-root resolution should use the existing @socketsecurity/lib path helpers (findUpSync / findPackageJson / walkUp) instead of a per-repo copy, and scripts/utils/ should be eliminated (scripts belong in scripts/fleet or scripts/repo per the root-scripts-are-segregated rule). A replacement PR will follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant