feat: add working-directory input#21
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a working-directory input to the GitHub Action so relative paths (lockfile detection, node-version-file, and default vp install execution) can be scoped to a project subdirectory—addressing cases where the workflow step working-directory doesn’t apply to uses: actions.
Changes:
- Introduce
working-directoryinput (action.yml + inputs/types) and thread it through install/cache/version resolution flows. - Refactor path handling utilities to support configurable base directories (
resolvePath,getConfiguredProjectDir,getInstallCwd,detectLockFile(searchDir)). - Update docs/tests to cover working-directory behavior and correct version printing by running
vp --versionin the configured project directory.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils.ts | Adds path/base-dir helpers and project-dir resolution used by install/cache/version logic. |
| src/utils.test.ts | Adds/adjusts unit tests for new path and working-directory behaviors. |
| src/types.ts | Extends Inputs with workingDirectory. |
| src/run-install.ts | Runs vp install in a cwd derived from working-directory + optional per-step override. |
| src/node-version-file.ts | Resolves version files relative to an explicit base directory (projectDir). |
| src/node-version-file.test.ts | Adds a unit test for base-directory path resolution. |
| src/inputs.ts | Parses the new working-directory input. |
| src/inputs.test.ts | Updates input parsing tests for the new field. |
| src/index.ts | Uses configured project dir for node-version file resolution and vp --version output. |
| src/cache-restore.ts | Runs lockfile detection relative to configured project dir; derives cache cwd from lockfile dir. |
| action.yml | Declares the new working-directory input. |
| README.md | Documents working-directory usage and semantics. |
Comments suppressed due to low confidence (1)
src/inputs.test.ts:34
- This assertion expects only a subset of the
Inputsobject, butgetInputs()currently includesregistryUrlandscopefields as well. As written,toEqualwill fail due to the extra keys; either includeregistryUrl/scope(asundefined) in the expected object, or switch to an assertion that matches only the fields you care about (e.g.,toMatchObject).
expect(inputs).toEqual({
version: "latest",
nodeVersion: undefined,
nodeVersionFile: undefined,
workingDirectory: undefined,
runInstall: [],
cache: false,
cacheDependencyPath: undefined,
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Follow #20
I found that the version printed by vite+ is also incorrect. I'm thinking that adding a
working-directorymight be better, which could also simplify the configuration.It looks like the
working-directoryfrom the GitHub action does not work withuses. https://github.com/orgs/community/discussions/25742Feel free to close this PR if you do not want to introduce another "cwd" input.