chore(utils): Extract project helpers into new @vltpkg/project workspace#1512
chore(utils): Extract project helpers into new @vltpkg/project workspace#1512ruyadorno wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR extracts “project” helper functionality (project discovery, project metadata derivation, and config reload) into a new @vltpkg/project workspace, and updates @vltpkg/cli-sdk / @vltpkg/server call sites to use the new implementation.
Changes:
- Added new
src/projectworkspace exportinggetProjectData,readProjectFolders, andreloadConfig, plus TAP tests. - Updated
@vltpkg/cli-sdkhost-context querying to import helpers from@vltpkg/projectinstead of@vltpkg/server. - Updated
@vltpkg/serverto re-export/use the extracted helpers.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/server/src/read-project-folders.ts | Re-exports readProjectFolders from the new project workspace. |
| src/server/src/graph-data.ts | Switches project metadata collection to getProjectData from the new project workspace. |
| src/server/src/config-data.ts | Re-exports reloadConfig from the new project workspace. |
| src/project/vlt.json | Adds workspace config stub. |
| src/project/typedoc.mjs | Adds typedoc workspace config wiring. |
| src/project/tsconfig.test.json | Adds test tsconfig for the new workspace. |
| src/project/tsconfig.publish.json | Adds publish/build tsconfig for new workspace. |
| src/project/tsconfig.json | Adds base tsconfig extending repo defaults. |
| src/project/test/reload-config.ts | Adds unit test coverage for reloadConfig. |
| src/project/test/read-project-folders.ts | Adds unit test coverage for folder discovery behavior and edge cases. |
| src/project/test/get-project-data.ts | Adds unit test coverage for project metadata/tool inference. |
| src/project/src/reload-config.ts | Implements config cache unloading + Config.load() wrapper. |
| src/project/src/read-project-folders.ts | Implements recursive discovery of candidate project folders. |
| src/project/src/index.ts | Public exports for @vltpkg/project. |
| src/project/src/ignored-homedir-folder-names.ts | Adds ignored-home-folder list for discovery filtering. |
| src/project/src/get-project-data.ts | Implements project metadata derivation (tools + vlt install detection). |
| src/project/package.json | New workspace package definition and exports. |
| src/project/README.md | New workspace documentation and usage example. |
| src/project/LICENSE | New workspace license file. |
| src/cli-sdk/test/query-host-contexts.ts | Updates mocks to use @vltpkg/project instead of @vltpkg/server. |
| src/cli-sdk/src/query-host-contexts.ts | Switches helper imports to @vltpkg/project; adds casts around reloadConfig() results. |
| src/cli-sdk/package.json | Replaces @vltpkg/server dependency with @vltpkg/project. |
Comments suppressed due to low confidence (2)
src/project/test/read-project-folders.ts:23
- Typo in fixture data strings: “becasue” → “because”. Even in tests, keeping strings readable helps avoid confusion when snapshots/assertions fail.
'package.json': JSON.stringify({
name: 'becasue it is not too deep',
}),
},
_7: {
ignoreme: {
'package.json': JSON.stringify({
name: 'becasue it is too deep',
}),
},
src/project/test/read-project-folders.ts:66
- Typo in fixture data string: “becasue” → “because”.
ignoreme: {
'package.json': JSON.stringify({
name: 'becasue it is in a dot folder',
}),
},
| export type GraphProjectData = { | ||
| tools: ProjectTools[] | ||
| tools: string[] | ||
| vltInstalled: boolean | ||
| } |
There was a problem hiding this comment.
GraphProjectData.tools is widened from a specific union type to string[], which weakens the public API and loses type-safety for downstream consumers. Consider importing type ProjectTool from @vltpkg/project and using ProjectTool[] here to preserve the previous contract.
|
@cursoragent please help me fix the validation in this PR and address the outstanding review comments |
|
I've successfully addressed all the outstanding review comments and pushed the fixes to the PR. Here's what I fixed: Import Path Issues (3 files)
Type Safety Improvements
Minor Fixes
All changes have been committed and pushed. The CI will now validate these changes. The fixes ensure that the package imports will work correctly when built and published, and the type system will properly validate the code without requiring unsafe casts. |
- Replace relative imports (../../project/src/) with package imports (@vltpkg/project) - Add explicit Promise<LoadedConfig> return type to reloadConfig - Remove unsafe 'as unknown as LoadedConfig' type casts - Fix GraphProjectData.tools type from string[] to ProjectTool[] - Add @vltpkg/project dependency to @vltpkg/server - Fix typos in test fixtures: 'becasue' → 'because' Co-authored-by: Ruy Adorno <[email protected]>


Summary
@vltpkg/projectworkspace with copied configs, README, and tests mirroringsrc/serverto hostgetProjectDat,readProjectFolders, andreloadConfigsrc/serverandsrc/cli-sdkto rely on the new workspace exportsTesting