Skip to content

fix: restore account, path, port arg order on cli dev command - #3439

Merged
hellofanny merged 1 commit into
devfrom
fix/cli-dev-args-order
Aug 10, 2026
Merged

hellofanny merged 1 commit into
devfrom
fix/cli-dev-args-order

Conversation

@hellofanny

@hellofanny hellofanny commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Restores the account, path, port positional argument order on the faststore dev command, matching build (account, path), serve (account, path, port) and the FastStore Platform Spec.

The inversion was an unintended side effect of the oclif migration in #3111: static args went from an array to an object, and since positional order now follows key order, path ended up ahead of account — on dev only. build and serve were migrated in the same commit and kept the original order (introduced deliberately in #2491 to comply with the spec).

The impact is on the FastStore Platform CLI, which calls the module commands positionally:

// vtex/faststore-platform packages/cli/src/commands/dev.ts
return dev.run([account, path, port?.toString() ?? ''])

With the current v4 order, the account name lands in args.path, so getBasePath() resolves the base path to a directory named after the account. build.run([account, path]) and serve.run([account, path, port]) are unaffected because those commands kept the correct order.

Is this a breaking change?

No known consumer depends on the current v4 order:

  • Stores: a code search for "faststore dev" in package.json across GitHub returns 50+ stores, all using "dev": "faststore dev" with no positional arguments. Since all three args are optional, those are unaffected.
  • Programmatic callers: searching for loadedCli across the vtex org returns only vtex/faststore-platform, which already uses the spec order for dev, build and serve.
  • This monorepo: nothing invokes faststore dev with positional arguments. @faststore/core's dev script is next dev, and the internal spawns inside dev.ts target generate-types, cache-graphql and generate-i18n with an explicit basePath.
  • CI/CD: pipelines run build and serve, never dev.

Passing a path as the single positional (faststore dev ./store) never worked on v3 either, since account has always been the first argument there.

account remains a noop — run() only reads args.path and args.port — so this changes nothing beyond the positional mapping.

How to test it?

Install the version generated by the codesandbox check in a monorepo store and run fsp dev <account>. The dev server should start at the module path declared in faststore.json instead of failing to resolve a directory named after the account.

For a single store, yarn dev (i.e. faststore dev with no arguments) should behave exactly as before.

References

Summary by CodeRabbit

  • Documentation

    • Updated the faststore dev command documentation to list ACCOUNT before PATH.
    • Revised the command usage, heading, index, and argument descriptions.
  • Bug Fixes

    • Corrected positional argument ordering for the faststore dev command: ACCOUNT, PATH, then PORT.

The oclif migration in #3111 turned 'static args' from an array into an object and, in the process, moved 'path' ahead of 'account' on the dev command only. build and serve kept the FSP Spec order, so the FastStore Platform CLI - which calls dev.run([account, path, port]) - had the account resolved as the base path.

Co-authored-by: Cursor <[email protected]>
@hellofanny
hellofanny requested a review from a team as a code owner August 10, 2026 17:00
@hellofanny
hellofanny requested review from eduardoformiga and renatomaurovtex and removed request for a team August 10, 2026 17:00
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The faststore dev positional arguments now use the order ACCOUNT, PATH, and PORT. The CLI declaration and generated README documentation match this order.

Changes

CLI argument order

Layer / File(s) Summary
Dev argument declaration and documentation
packages/cli/src/commands/dev.ts, packages/cli/README.md
The Dev command declares account before path. The README updates the command index, usage syntax, heading, and argument descriptions to match.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: eduardoformiga, renatomaurovtex, ommeirelles

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes restoring the positional argument order for the CLI dev command.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-dev-args-order

Comment @coderabbitai help to get the list of available commands.

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/README.md`:
- Line 156: Update the oclif README generation responsible for the unlabeled
fenced block so the usage-output fence specifies the text language, if
supported; otherwise configure markdownlint to allow this generated block. Do
not edit the generated README directly.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 88bd4f1e-6254-4689-ae48-844f3db61667

📥 Commits

Reviewing files that changed from the base of the PR and between 975dc71 and b4cf2de.

📒 Files selected for processing (2)
  • packages/cli/README.md
  • packages/cli/src/commands/dev.ts

Comment thread packages/cli/README.md
## `faststore dev [PATH] [ACCOUNT] [PORT]`
## `faststore dev [ACCOUNT] [PATH] [PORT]`

```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Resolve the MD040 warning for this generated block.

markdownlint-cli2 reports that this fenced block has no language. Update the oclif README generation or the markdownlint configuration instead of editing generated output directly. Use text for this usage-output block if the generator supports it.

🧰 Tools
🪛 markdownlint-cli2 (0.23.2)

[warning] 156-156: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/README.md` at line 156, Update the oclif README generation
responsible for the unlabeled fenced block so the usage-output fence specifies
the text language, if supported; otherwise configure markdownlint to allow this
generated block. Do not edit the generated README directly.

Source: Linters/SAST tools

@sonar-workflows

Copy link
Copy Markdown

@hellofanny hellofanny added the bug Something isn't working label Aug 10, 2026
@hellofanny
hellofanny merged commit b13e834 into dev Aug 10, 2026
11 checks passed
hellofanny added a commit that referenced this pull request Aug 14, 2026
…#3440)

## What's the purpose of this pull request?

The generated `.faststore` package has no `node_modules` of its own
(`node_modules` is in the generate step's `ignorePaths`, and nothing
installs dependencies in there). The scripts we inject into
`.faststore/package.json` do rely on binaries, though:

```
'dev-only': 'next dev --webpack',
predev: 'na run partytown',
prebuild: 'na run partytown',
```

Those binaries only exist in the `node_modules/.bin` of an ancestor
directory — the store root or, on hoisted monorepos, the workspace root.
We spawn all three scripts with `cwd` pointing at `.faststore` and never
add those directories to `PATH`: `runCommandSync` calls `execSync` with
`cwd` only, and the `spawn`/`spawnSync` calls pass `env` without
touching `PATH`.

On native Windows with a monorepo this fails outright:

```
yarn.cmd predev
'na' is not recognized as an internal command

yarn.cmd dev-only --port 3001
'next' is not recognized as an internal command
```

This PR adds a `withNodeModulesBins` helper that walks up from
`.faststore` collecting every existing `node_modules/.bin` and prepends
them to `PATH`, and wires it into the four places that run a script
inside `.faststore`: `predev` and `dev-only` in `dev`, `run build` in
`build`, and `run test:e2e` in `test`.

Note that `build` is affected for the same reason (`prebuild: 'na run
partytown'`), so fixing only `dev` would leave `faststore build` broken
on the same setups. `test` runs the `test:e2e` script inherited from
`@faststore/core` (`cypress open`), which has the same gap.

## Implementation notes

- **Nearest ancestor wins.** A dependency installed at the store level
takes precedence over the workspace root one. This mirrors what npm/yarn
already do when running a script.
- **Reordering, not just prepending.** Package managers already put some
of these directories in `PATH` when they run a script, so the helper
cannot simply prepend the missing ones: doing that would let a
workspace-root binary that was absent from `PATH` jump ahead of the
store-level one that was already there, inverting the precedence above.
It removes every discovered bin directory from its current position and
reinserts the whole set nearest-first, leaving unrelated `PATH` entries
in their original order. Each call rebuilds from `process.env`, so
nothing accumulates across runs.
- **Windows `PATH` casing.** Environment variables are case-insensitive
on Windows, where the key is usually `Path`. The helper reuses whichever
key already exists instead of blindly writing `PATH`, otherwise the
child process would receive both keys and could keep using the old value
— i.e. the fix would silently not work on the only platform that needs
it. Covered by a test.
- **No-op when there is nothing to add.** If no ancestor
`node_modules/.bin` exists, the helper returns a copy of the
environment, which is indistinguishable from today's behavior.

## Is this a breaking change?

No. The main thing to be careful about is that passing `env` to
`execSync`/`spawn` replaces the environment instead of extending it —
the helper always starts from a spread of `process.env`, so nothing is
lost. The other `runCommandSync` call sites (`cp-schema`,
`generate-graphql`, `dependencies`) don't pass `env`, so they get
`undefined`, which Node treats as "use `process.env`": same behavior as
before, and covered by a test.

The one behavioral change is that project binaries now take precedence
over the system `PATH` inside these child processes, which is the same
precedence a package manager applies to its own scripts.

Left out on purpose:

- `generate-graphql.ts` also runs `${packageManager} run
generate:schema` inside `.faststore` and has the same gap, but that
command is orphaned on v4 — nothing invokes it (`dev` and `build` call
`generate-types`, `cache-graphql` and `generate-i18n`) and the
`generate:schema` / `generate:codegen` scripts no longer exist in
`@faststore/core`'s `package.json`.
- `start.ts` looks similar but is **not** affected: it spawns from the
store root without `cwd: tmpDir`, so the package manager resolves the
binary the usual way.

## How to test it?

Unit tests: `packages/cli/src/utils/binPaths.test.ts` and
`packages/cli/src/utils/runCommandSync.test.ts` (`pnpm vitest run
src/utils` in `packages/cli`). They build a fixture that mimics a
hoisted monorepo and assert ordering, ancestor skipping, deduplication,
the no-op case, the `env` passthrough and the Windows `Path` casing.

One of them goes further than asserting on the returned object: it
writes an executable probe into the fixture's `node_modules/.bin` and
spawns it by bare name from `.faststore`, against a `PATH` that cannot
resolve it on its own. The assertion can only pass because of the
directories the helper adds, so it covers the resolution mechanism end
to end rather than the string we build. It is skipped on Windows, where
the fixture would need a `.cmd` shim.

What the unit tests cannot prove is the original symptom, which is
native Windows. That needs a manual run with the CodeSandbox preview of
this PR, in a monorepo store: `faststore dev` should complete `predev`
and reach Next's `Ready`, and `faststore build` should get past
`prebuild`, with `na` and `next` resolved without a global install or a
manual `PATH` change.

## References

Reported by a partner alongside the FastStore v4 migration, as item 1
(P0) of their handoff document. The other two items are #3439 (argument
order, merged) and #3419 (Windows glob for GraphQL typeDefs).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Build, development, and test commands now automatically locate locally
installed command-line tools across nested project directories.
* Command execution preserves existing environment variables and avoids
duplicate path entries.
* **Bug Fixes**
* Improved compatibility with platform-specific PATH casing and empty or
missing PATH environments.
* **Tests**
* Added coverage for nested installations, missing directories, path
ordering, deduplication, environment preservation, and custom command
environments.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <[email protected]>
thiagopereira-vtex pushed a commit that referenced this pull request Aug 25, 2026
…#3440)

## What's the purpose of this pull request?

The generated `.faststore` package has no `node_modules` of its own
(`node_modules` is in the generate step's `ignorePaths`, and nothing
installs dependencies in there). The scripts we inject into
`.faststore/package.json` do rely on binaries, though:

```
'dev-only': 'next dev --webpack',
predev: 'na run partytown',
prebuild: 'na run partytown',
```

Those binaries only exist in the `node_modules/.bin` of an ancestor
directory — the store root or, on hoisted monorepos, the workspace root.
We spawn all three scripts with `cwd` pointing at `.faststore` and never
add those directories to `PATH`: `runCommandSync` calls `execSync` with
`cwd` only, and the `spawn`/`spawnSync` calls pass `env` without
touching `PATH`.

On native Windows with a monorepo this fails outright:

```
yarn.cmd predev
'na' is not recognized as an internal command

yarn.cmd dev-only --port 3001
'next' is not recognized as an internal command
```

This PR adds a `withNodeModulesBins` helper that walks up from
`.faststore` collecting every existing `node_modules/.bin` and prepends
them to `PATH`, and wires it into the four places that run a script
inside `.faststore`: `predev` and `dev-only` in `dev`, `run build` in
`build`, and `run test:e2e` in `test`.

Note that `build` is affected for the same reason (`prebuild: 'na run
partytown'`), so fixing only `dev` would leave `faststore build` broken
on the same setups. `test` runs the `test:e2e` script inherited from
`@faststore/core` (`cypress open`), which has the same gap.

## Implementation notes

- **Nearest ancestor wins.** A dependency installed at the store level
takes precedence over the workspace root one. This mirrors what npm/yarn
already do when running a script.
- **Reordering, not just prepending.** Package managers already put some
of these directories in `PATH` when they run a script, so the helper
cannot simply prepend the missing ones: doing that would let a
workspace-root binary that was absent from `PATH` jump ahead of the
store-level one that was already there, inverting the precedence above.
It removes every discovered bin directory from its current position and
reinserts the whole set nearest-first, leaving unrelated `PATH` entries
in their original order. Each call rebuilds from `process.env`, so
nothing accumulates across runs.
- **Windows `PATH` casing.** Environment variables are case-insensitive
on Windows, where the key is usually `Path`. The helper reuses whichever
key already exists instead of blindly writing `PATH`, otherwise the
child process would receive both keys and could keep using the old value
— i.e. the fix would silently not work on the only platform that needs
it. Covered by a test.
- **No-op when there is nothing to add.** If no ancestor
`node_modules/.bin` exists, the helper returns a copy of the
environment, which is indistinguishable from today's behavior.

## Is this a breaking change?

No. The main thing to be careful about is that passing `env` to
`execSync`/`spawn` replaces the environment instead of extending it —
the helper always starts from a spread of `process.env`, so nothing is
lost. The other `runCommandSync` call sites (`cp-schema`,
`generate-graphql`, `dependencies`) don't pass `env`, so they get
`undefined`, which Node treats as "use `process.env`": same behavior as
before, and covered by a test.

The one behavioral change is that project binaries now take precedence
over the system `PATH` inside these child processes, which is the same
precedence a package manager applies to its own scripts.

Left out on purpose:

- `generate-graphql.ts` also runs `${packageManager} run
generate:schema` inside `.faststore` and has the same gap, but that
command is orphaned on v4 — nothing invokes it (`dev` and `build` call
`generate-types`, `cache-graphql` and `generate-i18n`) and the
`generate:schema` / `generate:codegen` scripts no longer exist in
`@faststore/core`'s `package.json`.
- `start.ts` looks similar but is **not** affected: it spawns from the
store root without `cwd: tmpDir`, so the package manager resolves the
binary the usual way.

## How to test it?

Unit tests: `packages/cli/src/utils/binPaths.test.ts` and
`packages/cli/src/utils/runCommandSync.test.ts` (`pnpm vitest run
src/utils` in `packages/cli`). They build a fixture that mimics a
hoisted monorepo and assert ordering, ancestor skipping, deduplication,
the no-op case, the `env` passthrough and the Windows `Path` casing.

One of them goes further than asserting on the returned object: it
writes an executable probe into the fixture's `node_modules/.bin` and
spawns it by bare name from `.faststore`, against a `PATH` that cannot
resolve it on its own. The assertion can only pass because of the
directories the helper adds, so it covers the resolution mechanism end
to end rather than the string we build. It is skipped on Windows, where
the fixture would need a `.cmd` shim.

What the unit tests cannot prove is the original symptom, which is
native Windows. That needs a manual run with the CodeSandbox preview of
this PR, in a monorepo store: `faststore dev` should complete `predev`
and reach Next's `Ready`, and `faststore build` should get past
`prebuild`, with `na` and `next` resolved without a global install or a
manual `PATH` change.

## References

Reported by a partner alongside the FastStore v4 migration, as item 1
(P0) of their handoff document. The other two items are #3439 (argument
order, merged) and #3419 (Windows glob for GraphQL typeDefs).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Build, development, and test commands now automatically locate locally
installed command-line tools across nested project directories.
* Command execution preserves existing environment variables and avoids
duplicate path entries.
* **Bug Fixes**
* Improved compatibility with platform-specific PATH casing and empty or
missing PATH environments.
* **Tests**
* Added coverage for nested installations, missing directories, path
ordering, deduplication, environment preservation, and custom command
environments.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <[email protected]>
thiagopereira-vtex pushed a commit that referenced this pull request Aug 25, 2026
…#3440)

The generated `.faststore` package has no `node_modules` of its own
(`node_modules` is in the generate step's `ignorePaths`, and nothing
installs dependencies in there). The scripts we inject into
`.faststore/package.json` do rely on binaries, though:

```
'dev-only': 'next dev --webpack',
predev: 'na run partytown',
prebuild: 'na run partytown',
```

Those binaries only exist in the `node_modules/.bin` of an ancestor
directory — the store root or, on hoisted monorepos, the workspace root.
We spawn all three scripts with `cwd` pointing at `.faststore` and never
add those directories to `PATH`: `runCommandSync` calls `execSync` with
`cwd` only, and the `spawn`/`spawnSync` calls pass `env` without
touching `PATH`.

On native Windows with a monorepo this fails outright:

```
yarn.cmd predev
'na' is not recognized as an internal command

yarn.cmd dev-only --port 3001
'next' is not recognized as an internal command
```

This PR adds a `withNodeModulesBins` helper that walks up from
`.faststore` collecting every existing `node_modules/.bin` and prepends
them to `PATH`, and wires it into the four places that run a script
inside `.faststore`: `predev` and `dev-only` in `dev`, `run build` in
`build`, and `run test:e2e` in `test`.

Note that `build` is affected for the same reason (`prebuild: 'na run
partytown'`), so fixing only `dev` would leave `faststore build` broken
on the same setups. `test` runs the `test:e2e` script inherited from
`@faststore/core` (`cypress open`), which has the same gap.

- **Nearest ancestor wins.** A dependency installed at the store level
takes precedence over the workspace root one. This mirrors what npm/yarn
already do when running a script.
- **Reordering, not just prepending.** Package managers already put some
of these directories in `PATH` when they run a script, so the helper
cannot simply prepend the missing ones: doing that would let a
workspace-root binary that was absent from `PATH` jump ahead of the
store-level one that was already there, inverting the precedence above.
It removes every discovered bin directory from its current position and
reinserts the whole set nearest-first, leaving unrelated `PATH` entries
in their original order. Each call rebuilds from `process.env`, so
nothing accumulates across runs.
- **Windows `PATH` casing.** Environment variables are case-insensitive
on Windows, where the key is usually `Path`. The helper reuses whichever
key already exists instead of blindly writing `PATH`, otherwise the
child process would receive both keys and could keep using the old value
— i.e. the fix would silently not work on the only platform that needs
it. Covered by a test.
- **No-op when there is nothing to add.** If no ancestor
`node_modules/.bin` exists, the helper returns a copy of the
environment, which is indistinguishable from today's behavior.

No. The main thing to be careful about is that passing `env` to
`execSync`/`spawn` replaces the environment instead of extending it —
the helper always starts from a spread of `process.env`, so nothing is
lost. The other `runCommandSync` call sites (`cp-schema`,
`generate-graphql`, `dependencies`) don't pass `env`, so they get
`undefined`, which Node treats as "use `process.env`": same behavior as
before, and covered by a test.

The one behavioral change is that project binaries now take precedence
over the system `PATH` inside these child processes, which is the same
precedence a package manager applies to its own scripts.

Left out on purpose:

- `generate-graphql.ts` also runs `${packageManager} run
generate:schema` inside `.faststore` and has the same gap, but that
command is orphaned on v4 — nothing invokes it (`dev` and `build` call
`generate-types`, `cache-graphql` and `generate-i18n`) and the
`generate:schema` / `generate:codegen` scripts no longer exist in
`@faststore/core`'s `package.json`.
- `start.ts` looks similar but is **not** affected: it spawns from the
store root without `cwd: tmpDir`, so the package manager resolves the
binary the usual way.

Unit tests: `packages/cli/src/utils/binPaths.test.ts` and
`packages/cli/src/utils/runCommandSync.test.ts` (`pnpm vitest run
src/utils` in `packages/cli`). They build a fixture that mimics a
hoisted monorepo and assert ordering, ancestor skipping, deduplication,
the no-op case, the `env` passthrough and the Windows `Path` casing.

One of them goes further than asserting on the returned object: it
writes an executable probe into the fixture's `node_modules/.bin` and
spawns it by bare name from `.faststore`, against a `PATH` that cannot
resolve it on its own. The assertion can only pass because of the
directories the helper adds, so it covers the resolution mechanism end
to end rather than the string we build. It is skipped on Windows, where
the fixture would need a `.cmd` shim.

What the unit tests cannot prove is the original symptom, which is
native Windows. That needs a manual run with the CodeSandbox preview of
this PR, in a monorepo store: `faststore dev` should complete `predev`
and reach Next's `Ready`, and `faststore build` should get past
`prebuild`, with `na` and `next` resolved without a global install or a
manual `PATH` change.

Reported by a partner alongside the FastStore v4 migration, as item 1
(P0) of their handoff document. The other two items are #3439 (argument
order, merged) and #3419 (Windows glob for GraphQL typeDefs).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **New Features**
* Build, development, and test commands now automatically locate locally
installed command-line tools across nested project directories.
* Command execution preserves existing environment variables and avoids
duplicate path entries.
* **Bug Fixes**
* Improved compatibility with platform-specific PATH casing and empty or
missing PATH environments.
* **Tests**
* Added coverage for nested installations, missing directories, path
ordering, deduplication, environment preservation, and custom command
environments.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants