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): add --npm flag to initialize npm projects #26896

Merged
merged 18 commits into from
Nov 21, 2024

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

cli/main.rs Outdated Show resolved Hide resolved
@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.

@bartlomieju bartlomieju changed the title feat(init): support initializing npm projects feat(init): add --npm flag to initialize npm projects Nov 20, 2024
cli/tools/init/mod.rs Outdated Show resolved Hide resolved
cli/tools/init/mod.rs Outdated Show resolved Hide resolved
cli/tools/init/mod.rs Outdated Show resolved Hide resolved
cli/main.rs Show resolved Hide resolved
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM!

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
@bartlomieju bartlomieju enabled auto-merge (squash) November 20, 2024 22:59
@bartlomieju bartlomieju merged commit d17f459 into denoland:main Nov 21, 2024
17 checks passed
@bartlomieju bartlomieju deleted the deno_init_npm branch November 21, 2024 00:08
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 ...
5 participants