diff --git a/packages/vx/docs/cli.md b/packages/vx/docs/cli.md index 415146dedf..bb9e089e08 100644 --- a/packages/vx/docs/cli.md +++ b/packages/vx/docs/cli.md @@ -3705,6 +3705,8 @@ So a config that reads the environment keeps its lock-time values. (an install's `node_modules`), a config-less project's too. - Under `--affected`, only when a task the diff reaches is its, or depends on one of its: a change elsewhere runs as usual. +- `vx show` and the picker list it as the lock holds it; picked, the run + is refused. - Only a repository where a sparse checkout was set asks git about a config-less project's directory: one spawn per run. - The refusal names every such project, and the one diff --git a/packages/vx/src/cli/select.ts b/packages/vx/src/cli/select.ts index 2946717b61..52007ce702 100644 --- a/packages/vx/src/cli/select.ts +++ b/packages/vx/src/cli/select.ts @@ -731,7 +731,9 @@ export async function pickTask( // The staged load: a task a `project` plugin gave a config-less package // is on the menu, as it is in a run. const root = await findWorkspaceRoot(cwd) - const staged = await loadCliProjects(root, projects, 'all', load) + // A task of a project a sparse checkout left out is listed: picked, the + // run names the checkout. + const staged = await loadCliProjects(root, projects, 'all', { ...load, sparseLeft: new Map() }) const entries: PickedTask[] = [] for (const meta of projects) { if (only !== undefined && !only.has(meta.name)) continue diff --git a/packages/vx/src/cli/show.ts b/packages/vx/src/cli/show.ts index 79b24aa18c..1965440b7e 100644 --- a/packages/vx/src/cli/show.ts +++ b/packages/vx/src/cli/show.ts @@ -211,7 +211,12 @@ export async function showCmd(args: readonly string[]): Promise { } } - const projects = await loadCliProjects(root, metas, scope, { closure: true }) + // A project a sparse checkout left out is shown as the lock holds it: what + // a run would read once it is checked out. + const projects = await loadCliProjects(root, metas, scope, { + closure: true, + sparseLeft: new Map(), + }) if (parsed.target === undefined) { if (metas.length === 0) diff --git a/packages/vx/tests/sparse-checkout-config.test.ts b/packages/vx/tests/sparse-checkout-config.test.ts index f4cdd53163..c1861080c4 100644 --- a/packages/vx/tests/sparse-checkout-config.test.ts +++ b/packages/vx/tests/sparse-checkout-config.test.ts @@ -128,6 +128,19 @@ it('--affected refuses the excluded project only when what it reaches needs it', expect([app.code, app.out.includes('built'), app.err.trim()]).toEqual([1, false, REFUSAL]) }, 30_000) +it('vx show lists and prints the excluded project as the lock holds it', async () => { + // Every `vx show` but one of a kept project was refused. + const list = await vx(root, ['show', '--format', 'json']) + expect([list.code, JSON.parse(list.out).map((p: { name: string }) => p.name)]).toEqual([ + 0, + ['app', 'lib', 'other'], + ]) + for (const target of ['lib', 'lib#build', 'build']) { + const r = await vx(root, ['show', target]) + expect([target, r.code, r.out.includes('lib#build'), r.err]).toEqual([target, 0, true, '']) + } +}, 30_000) + it('vx lock and its --check refuse what the sparse checkout left out, the lock untouched', async () => { const lockFile = path.join(root, '.vx/projects.lock') const before = await Bun.file(lockFile).text()