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

feat(init): support initializing npm projects #26896

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Nov 16, 2024

This commit adds support for deno init npm:<package>.

Running this will actually call to npm:create-<package> package that
is equivalent to running npm create <package>.

User will be prompted if they want to allow all permissions and lifecycle scripts
to be executed. It was discussed internally if we should accept permission flags here
but it will be really cumbersome and in most cases these creation scripts need to do
a lot of crazy stuff including reaching out to networks, reading and writing to file system,
reading env vars and spawning subprocesses.

Closes #26461

if dir.starts_with("jsr:") {
bail!("Initializing project from a jsr package is currently not supported.");
} else if dir.starts_with("npm:") {
// TODO: do prompt
Copy link
Member Author

Choose a reason for hiding this comment

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

BLOCKER FOR LANDING:

Do the confirmation prompt if user wants to allow all permissions and post-install scripts.

Copy link
Member Author

Choose a reason for hiding this comment

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

If user doesn't grant it, we should print a message how this could be executed manually using deno run subcommand - eg. deno run npm:create-vite

@bartlomieju bartlomieju added this to the 2.1.0 milestone Nov 17, 2024
@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Nov 18, 2024

Tried out the changes in this PR but ran into an issue where it doesn't seem to install the create-<package> dependency.

1. Create an empty folder and cd into that
2. Run deno-git init npm:preact

Output:

$ deno init npm:preact
error: Could not find a matching package for 'npm:create-preact' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `"nodeModulesDir": "auto"` in your deno.json file.

EDIT: Ignore what I wrote. I had a package.json in a parent directory.

@bartlomieju
Copy link
Member Author

Thanks, I know what the problem is, will fix it tonight.

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.

Deno equivalent for npm create ...
2 participants