Skip to content

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

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

feat: validate the positional name argument against the project name rules#276
beeman wants to merge 1 commit into
beeman/project-name-schemafrom
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: 4c6f0a9

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: 4c6f0a9

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown

Greptile Summary

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

  • Applies the existing project-name validator to positional input.
  • Ensures invalid names fail before template data is fetched.
  • Adds rejection and informational-command regression coverage.
  • Adds a minor release changeset.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported validation-order and informational-command issues are fixed, and the author reports that the head commit is signed and verified.

Important Files Changed

Filename Overview
src/utils/get-args.ts Positional-name validation now precedes remote template retrieval, and all three informational list commands bypass it as intended.
test/get-args.test.ts Adds coverage for invalid names, existing directories, pre-fetch rejection, and the informational-command exemption.
.changeset/validate-positional-name.md Records the positional-name validation behavior as a minor package change.

Reviews (5): Last reviewed commit: "feat: validate the positional name argum..." | Re-trigger Greptile

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

…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/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
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