Skip to content

fix(cli): recognise the --pm long alias when extracting template flags - #280

Open
latent-9 wants to merge 1 commit into
solana-foundation:mainfrom
latent-9:fix/pm-alias-flag
Open

fix(cli): recognise the --pm long alias when extracting template flags#280
latent-9 wants to merge 1 commit into
solana-foundation:mainfrom
latent-9:fix/pm-alias-flag

Conversation

@latent-9

Copy link
Copy Markdown

Summary

The documented --pm alias for --package-manager does not work. create-solana-dapp my-app --pm pnpm (the form shown in the CLI help: --package-manager pnpm # or --pm pnpm/yarn) does not set the package manager, and --pm=pnpm throws. --package-manager itself works.

extractTemplateOptionFlags splits argv into flags Commander knows and template flags before Commander parses them. For a two-long-token option (--pm, --package-manager <package-manager>), Commander 14 stores the canonical long (--package-manager) in option.long and the alias (--pm) in option.short. findKnownOption only compares a ---prefixed arg against option.long, so --pm is not recognised as a known option: it is stripped into templateOptions and its value (pnpm) is left as a stray positional.

hasInlineValue has the same blind spot: it checks the inline value against the canonical long (arg.startsWith(--package-manager=)), so --pm=pnpm is not detected as carrying a value. The parser then preserves the following token, so a template flag written after an inline alias (e.g. --pm=pnpm --ollama) is misrouted into the known argv instead of the template options.

Fix

  • findKnownOption: also match the ---arg against option.short, where Commander keeps the long alias.
  • hasInlineValue: detect the inline = on the arg itself rather than against the canonical long.

Tests

Adds two cases using a command with a --pm, --package-manager option: the space form (--pm pnpm) is preserved as a known flag, and the inline form followed by a template flag (--pm=pnpm --ollama) keeps --pm=pnpm in argv and routes --ollama to template options. Both fail before the fix and pass after. The full suite stays green.

extractTemplateOptionFlags splits argv into known CLI flags and template
flags before Commander parses them. Commander stores the alias of a
two-long-token option (--pm, --package-manager) in option.short, but
findKnownOption only compared --prefixed args against option.long, so --pm
was never recognised: it was stripped into templateOptions and its value
became a stray positional, leaving the documented "--pm pnpm/yarn" alias
broken while --package-manager kept working. hasInlineValue had the same
blind spot, matching the inline value against the canonical long, so
"--pm=pnpm" followed by a template flag misrouted that flag.

Match the arg against option.short as well, and detect the inline value on
the arg itself. Adds tests for the space and inline alias forms.
@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

鈿狅笍 No Changeset found

Latest commit: 8b7b707

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown

Greptile Summary

Fixes extraction of Commander options declared with two long tokens so the documented --pm package-manager alias works with both space-separated and inline values.

  • Recognizes a long alias stored in Commander鈥檚 option.short field.
  • Detects inline values from the actual argument token.
  • Adds regression coverage for --pm pnpm and --pm=pnpm followed by a template option.

Confidence Score: 5/5

The PR appears safe to merge, with the alias handling covered by focused regression tests and no actionable defects identified.

The extraction logic now preserves Commander鈥檚 long alias and correctly treats its inline assignment as self-contained while continuing to route the following template flag separately.

Important Files Changed

Filename Overview
src/utils/extract-template-option-flags.ts Correctly broadens known-option and inline-value recognition for Commander鈥檚 two-long-token alias representation without an identified behavioral regression.
test/extract-template-option-flags.test.ts Adds focused regression tests covering the space-separated and inline forms of the --pm alias.

Reviews (1): Last reviewed commit: "fix(cli): recognise the --pm long alias ..." | Re-trigger Greptile

@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/create-solana-dapp@280

commit: 8b7b707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant