Skip to content

feat: validate the positional name argument against the project name rules - #276

Open
beeman wants to merge 1 commit into
mainfrom
beeman/validate-positional-name
Open

beeman wants to merge 1 commit into
mainfrom
beeman/validate-positional-name

Conversation

@beeman

@beeman beeman commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The positional CLI name argument flowed straight from input.args[0] into the generated package.json name and the init-script rename search key without ever passing through validateProjectName — only the interactive prompt path validated. So npx create-solana-dapp My_App bypassed validation entirely and produced an invalid npm package name and a degenerate rename search key.

What

  • Run validateProjectName on the positional argument in getArgs when it is provided (the same rule as the interactive prompt, including the Directory already exists check) and throw with the validation message on failure, matching the existing log.error + throw pattern.
  • Validation runs immediately after argument parsing, before fetchTemplateData, so a network failure can't mask the name-validation error. The informational --list-* commands skip it, since they only use the name to build a hint.
  • Test coverage for both rejection paths (including asserting the template fetch is never reached) and for the list-command exemption, plus a minor changeset.

Notes

Stacked on #274 (targets beeman/project-name-schema); retarget to main or rebase once that merges.

@changeset-bot

changeset-bot Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d87885

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-solana-dapp Minor

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 1d87885

@greptile-apps

greptile-apps Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the previously reported ordering and informational-command issues fully addressed.

Summary

This PR validates positional project names before template retrieval while exempting informational list commands.

  • Applies the same project-name and existing-directory checks used by the interactive flow.
  • Ensures invalid names fail before any template network request.
  • Adds regression coverage for invalid names, existing directories, and list-command behavior.
  • Adds a minor release changeset.

Reviews (6) · Last reviewed commit: "feat: validate the positional name argum..."

Comment thread src/utils/get-args.ts Outdated
Comment thread src/utils/get-args.ts Outdated
@beeman
beeman force-pushed the beeman/validate-positional-name branch from 7818d5c to 31a730c Compare August 6, 2026 00:10
Comment thread src/utils/get-args.ts Outdated
@beeman

beeman commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@beeman
beeman force-pushed the beeman/validate-positional-name branch from 31a730c to 77ebfd9 Compare August 6, 2026 00:18
@beeman

beeman commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@beeman
beeman force-pushed the beeman/project-name-schema branch from 05a3e01 to 5d18ad4 Compare August 7, 2026 13:50
@beeman
beeman force-pushed the beeman/validate-positional-name branch from 77ebfd9 to 4c6f0a9 Compare August 7, 2026 13:51
Base automatically changed from beeman/project-name-schema to main September 18, 2026 15:10
…rules

The positional CLI name argument flowed straight from input.args[0] into the generated package.json name and the init-script rename search key without ever passing through validateProjectName — only the interactive prompt path validated. Run the same validation on the positional argument in getArgs and throw with the validation message on failure, matching the other getArgs errors. Validation runs immediately after argument parsing, before fetching template data, so a network failure can't mask the name error, but is skipped for the informational --list-* commands, which only use the name to build a hint.
@beeman
beeman force-pushed the beeman/validate-positional-name branch from 4c6f0a9 to 1d87885 Compare September 19, 2026 19:20
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