Repository navigation
feat(engine): a command can also have subcommands, so prisma dev <entry> and prisma dev url can coexist - #349
Open
wmadden-electric wants to merge 8 commits into
Open
wmadden-electric wants to merge 8 commits into
wmadden-electric wants to merge 8 commits into
Conversation
Stand-in dev, dev url and dev stop commands. These fail until the engine accepts the shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
createCli accepted 'dev url' only if nothing was mounted at 'dev'. Now 'dev' can be a command too: 'dev module.ts' runs it, 'dev url' runs the child, and a child's name wins over a positional spelled the same. 'dev --help' shows the command's help and lists the children. The group's own command sits on the group's node in the command tree, and Stricli routes to it as the route map's default command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
The engine README shows the mount, and the style guide says what the combined help card shows and how a child's name wins over a positional. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
A patch release: a path that is also a group is new behaviour, and nothing that built before changes. The conformance check's two temporary exceptions move from 0.6.3/0.7.0 to 0.7.0/0.7.1. @prisma/composer-cli and @prisma/orm-toolchain now peer 0.7.0, so the old exceptions no longer matched anything, and the new ones last until both release against 0.7.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…cement With a redirect from 'dev up', 'dev up' ran 'dev' with the entry 'up': redirects were consulted only when routing failed, and under a group's own command it never fails. The engine now matches the redirect before parsing, so a retired child's name wins over the positional the way a live child's name does. Also: - the hidden route the own command sits under is dropped from the reported path, so a literally typed '<own command>' never shows up in a commandId - CommandTreeNode.command is now ownCommand, and the help target for a command is kind 'command' with 'subcommands' - a test pins that '--' passes a word spelled like a child as the positional Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
A tree that 0.7.0 refused now builds. That is a new capability, which takes a minor bump, as the statement prompts did for 0.7.0. The conformance exceptions move to 0.7.0/0.8.0 to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
commit: |
4 tasks done
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.
At a glance
A CLI can now mount a command at a path that also has subcommands:
Before this PR,
createClirefused this shape: "command path 'dev url' collides with a command mounted at a prefix of it".What this PR changes
prisma dev upreports that the command moved instead of runningdevwith entryup.@prisma/cli-enginegoes from 0.7.0 to 0.8.0.No command in the
prismabinary uses the new shape yet.Why
Composer's
prisma dev <entry>runs an app on local stand-ins for Prisma Cloud. Composer is addingprisma dev url <address>, which prints the local URL of one of that app's services, andprisma dev stop, which stops the app's local processes. A baredevthat also has subcommands is the usual shape for this (pnpm dev,next dev), and it keeps every existingprisma dev module.tsin docs and scripts working. Those commands mount in a later PR, once a Composer release has them.How it works
The tree.
command-tree.tsbuilds a tree of groups and commands from the mounted paths. A group node can now hold its own command (CommandTreeNode.ownCommand), alongside its children. The group still needs an entry ingroups, because it has children. Every other construction check applies to the own command and to each child. The old prefix-collision refusal is removed. Two commands at one exact path still can't exist, because mounts are a record keyed by path, so there is no check (and no test) for that case.Routing. The engine routes through Stricli, whose route maps take a
defaultCommand: the command that runs when the next word names no route. The own command is registered under a hidden route name,OWN_COMMAND_ROUTE, and used as that default. A child's name is one word and can't contain the hidden name's characters, so they never collide. The hidden name never appears in help, listings, suggestions orcommandId.The rule for words. A child's name wins over a positional spelled the same. That is harmless for
dev, whose positional is a file path with an extension.--passes such a word as the positional (prisma dev -- url).Redirects. Redirects are normally checked only when the typed words reach no command. Under a path with its own command, every word reaches one, because an unknown word becomes the positional. So the engine now checks the typed words against redirects before parsing. A redirect that matches a longer path than the command those words reach ends the run with
CLI.COMMAND_MOVED. This also applies to a redirect under a plain command, such as one fromproject link old, which used to be passed through as a positional. No shipped redirect is affected: the ORM's redirects sit undermigration, which has no command of its own.Help.
prisma dev --helpshowsdev's own help card with a Commands section after the description. A bareprisma devruns the command; it does not print help. The style guide now says that the group's own description doesn't appear on the combined card, so the command's description must define the terms its children rely on.Version. Engine changes ship with
pnpm bump-cli-engine-versionin the same PR. This adds a capability, so it is a minor bump, as with ADR 0006.@prisma/composer-cli0.29.1 and@prisma/orm-toolchain8.0.0-rc.17 declare an exact peer on engine 0.7.0, so the conformance exceptions inpackages/cli/scripts/conformance.tsmove to 0.7.0 → 0.8.0 until both release against it.Tests
packages/cli-engine/tests/command-groups.test.tsmounts stand-indev,dev urlanddev stopcommands and checks:dev module.tsrunsdev, anddev url gatewayrunsdev url;--helpondevand ondev url;--overrides it;dev upexits 2 withCLI.COMMAND_MOVED, whiledev module.tsstill runsdev;commandIddev.pnpm --filter @prisma/cli-engine test(1163 passed),pnpm --filter @prisma/cli test(1027 passed, 1 skipped),pnpm typecheck, and Biome all pass.Alternatives considered
prisma dev start. No engine change, but it breaks everyprisma dev module.tsin docs, guides and scripts, and reverses Composer's decision to mountdevas a bare verb at the root.prisma emulator url. It works today, buturlanswers a question about the appprisma devruns from this directory, so it belongs underdev.defaultCommand. More code for the same behaviour.devsubcommand.Agent: attila-51
🤖 Generated with Claude Code