Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(create-neon): Explicit project type #1041

Merged
merged 9 commits into from
May 20, 2024

Conversation

dherman
Copy link
Collaborator

@dherman dherman commented May 12, 2024

This PR changes the syntax of create-neon to require the user to explicitly specify the Neon project type, either by passing --lib or --app at the command-line, or otherwise by interactively asking them via stdin.

The reason for this is a limitation of npm init: the only way it will forward an argument like --lib to create-neon is if the user remembers to prefix it with --:

npm init neon -- --lib my-project

Without the extra --, npm silently ignores the --lib, which is a subtle and surprising hazard. This pitfall is easy to stumble into and difficult to debug.

(I built a demonstration package called create-dherman that you can use to test this behavior. Test it out with npm init dherman --lib foobar vs npm init dherman -- --lib foobar, for example.)

With this PR, users still need the --, but if they forget it, they'll be asked the project type interactively.

- either by passing --app or --lib
- or by interactive dialog via stdin
@dherman dherman force-pushed the create-neon-requires-project-type branch from 4a71dee to 7661e45 Compare May 12, 2024 18:00
@dherman dherman requested a review from kjvalencik May 12, 2024 23:55
Copy link
Member

@kjvalencik kjvalencik left a comment

Choose a reason for hiding this comment

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

The templated JSON is a difficult to tell if it always results in valid JSON. In a future PR, it may be cleaner to generate it in JS and call JSON.stringify.

pkgs/create-neon/data/templates/manifest/scripts.json.hbs Outdated Show resolved Hide resolved
pkgs/create-neon/src/cache/npm.ts Outdated Show resolved Hide resolved
pkgs/create-neon/src/cache/npm.ts Outdated Show resolved Hide resolved
- small cleanups to `inferOrg` regexp logic
- revert the `"prepare"` hook for --app (see #1042 (comment) )
@kjvalencik kjvalencik self-requested a review May 20, 2024 18:59
@dherman dherman merged commit b57ab4f into main May 20, 2024
9 checks passed
@dherman dherman deleted the create-neon-requires-project-type branch May 20, 2024 19:03
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.

None yet

2 participants