fix(scripts): resolve repo root via shared lib helper, eliminate scripts/utils - #669
Merged
Merged
Conversation
…pts/utils Root resolution no longer uses a hand-rolled getRootPath. The old scripts/utils/path-helpers.mts computed the repo root as dirname(script)/.. — correct only for scripts directly in scripts/. After scripts moved into scripts/repo/ that returned scripts/, so the generators looked for openapi.json (and other root files) in the wrong place. The 7 call sites now walk up for the nearest package.json with findUpSync from @socketsecurity/lib-stable/fs/find and take its dirname, which is correct no matter how deep the script lives. No socket-lib change and no new export — findUpSync is already the public "walk up parent directories to locate a file" helper. scripts/utils/ is removed so every script lives under scripts/fleet/ or scripts/repo/: - path-helpers.mts deleted (its job is now the lib helper). - run-command.mts and changed-test-mapper.mts moved to scripts/repo/ (both are only consumed by repo scripts). - All importers updated.
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.
What this does
Repo scripts now find the repository root with the shared
@socketsecurity/lib-stablehelper instead of a hand-rolled path helper,and the non-segmented
scripts/utils/directory is removed.This supersedes #668 and does it the way the maintainer asked:
getRootPath.scripts/fleet/orscripts/repo/.The bug it fixes
scripts/utils/path-helpers.mtscomputed the repo root asdirname(script)/... That only works for a script sitting directly inscripts/. Once these scripts moved intoscripts/repo/, the helperreturned
scripts/instead of the repo root, so the generators lookedfor
openapi.json(and the other root files) in the wrong directory.How root resolution works now
Each of the 7 call sites walks up from its own location to the nearest
package.jsonand takes that directory:findUpSyncis already a public export of@socketsecurity/lib-stable("walk up parent directories to locate a file"). No socket-lib change and
no new export were needed, so there is no publish step.
Eliminating scripts/utils/
scripts/utils/was a third top-level script namespace alongsidescripts/fleet/andscripts/repo/. It is now gone:path-helpers.mtsdeleted — its job is now the lib helper.run-command.mts->scripts/repo/run-command.mts(only imported byscripts/repo/build.mtsandscripts/repo/generate-sdk.mts).changed-test-mapper.mts->scripts/repo/changed-test-mapper.mts(repo-scoped: it maps this repo's
src/files to itstest/files).Nothing under
scripts/fleet/imported either moved file (the onelookalike,
scripts/fleet/ai-lint-fix/util/run-command.mts, is aseparate file), so
scripts/repo/is the correct home.Verification
All run with Node 24.
pnpm run type(tsgo --noEmit)pnpm run lintroot-scripts-are-segregatedscript-paths-resolvetests-are-mirror-namedgenerated-globs-are-consistentgenerated-outputs-are-untrackeddocs:api:check(gen-api-docs + gen-api-docs-lib)check:quota-sync(validate-quota-sync)generate-types/generate-strict-typesAbout the 6 pre-existing test failures
They are environmental, not from this change (which only touches
scripts/repo/*):test/repo/unit/utils.test.mts(3): assert the resolved path containsthe literal string
socket-sdk-js; the CI/worktree checkout dir is notnamed that. Tests
src/utils.mts, untouched here.test/repo/unit/bundle-validation.test.mts(3): validatedist/index.js/
dist/index.browser.js, which require a build that was not run.The generated
types/api.d.tsandsrc/types-strict.mtsare left as-is:running
generate-typesstandalone emits unformatted output (thecommitted file is the oxfmt-formatted result of the full
generate-sdkpipeline), so its diff is a formatting artifact, not a content change.