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

create-neon CLI tool #565

Closed
dherman opened this issue Jul 24, 2020 · 4 comments
Closed

create-neon CLI tool #565

dherman opened this issue Jul 24, 2020 · 4 comments

Comments

@dherman
Copy link
Collaborator

dherman commented Jul 24, 2020

Create the create-neon CLI tool so users can create Neon projects via npm init neon.


This is a tracking issue for the three neon-create-* CLI tools we'll need in order to enable developers to use npm init neon-* instead of neon new.

@kjvalencik
Copy link
Member

kjvalencik commented Feb 17, 2021

We will use process.versions.napi to get the current N-API version to default in Cargo.toml. We will need to include a maximum version that gets bumped along with new N-API versions used in Neon.

@dherman
Copy link
Collaborator Author

dherman commented Feb 17, 2021

After a bunch of discussion and prototyping, we have figured out a few key simplifying changes we can make to how Neon projects work, which will allow us to simplify the npm init story to just one single tool: create-neon, thanks to a few things:

  • With N-API, there's no longer any special build logic needed for different types of projects (e.g. Electron vs plain Node).
  • We have eliminated the index.js wrapper and the concept that a Neon project includes arbitrary wrapping logic in pure JS. A Neon project is just a .node plugin that you can embed anywhere, and the developer can decide what, if any, wrapping they want to do on the outside of that.
  • We are streamlining the directory layout to be much flatter as a result.
  • All of this makes for a simpler to understand mental model of Neon projects, and a simpler CLI UX.

This was referenced Feb 17, 2021
@dherman dherman changed the title neon-create-* CLI tools create-neon CLI tool Feb 17, 2021
@dherman
Copy link
Collaborator Author

dherman commented Feb 19, 2021

Work items for this issue:

  • Flattened directory layout, which is mostly described in the CLI RFC, but in summary:
    • It's basically just the result of the npm init logic + Cargo.toml and src/lib.rs in the root
    • The "postinstall" script calls "npm run build"
    • The "build" script calls "cargo-cp-artifact" to properly build and move the index.node into the root directory
  • Need logic for inferring NAPI version (see create-neon CLI tool #565 (comment))
    • Default to the N-API version of the current running Node
    • But no higher than the highest supported N-API version in Neon (can determine this from a text file we keep in the Neon repo)
    • Allow user to pass an optional flag to say explicitly what N-API version, hard error if they pick an unsupported version
  • Need to update the templates based on that directory layout
  • Needs the npm "build" script that calls cargo-cp-artifact
  • Need the updated cargo-cp-artifact command-line syntax
  • Use https://github.com/npm/init-package-json for most of the core logic

@dherman
Copy link
Collaborator Author

dherman commented Jul 1, 2021

Implemented in #690.

@dherman dherman closed this as completed Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants