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

Add the pnpm create command #3829

Merged
merged 8 commits into from
Oct 9, 2021
Merged

Add the pnpm create command #3829

merged 8 commits into from
Oct 9, 2021

Conversation

illright
Copy link
Contributor

@illright illright commented Oct 6, 2021

I'd like to start a discussion about the init command for pnpm.

Here's how I see it:

  • pnpm init behaves similarly to npm init, produces an interactive wizard for creating a new Node project
    • With one exception: npm asks for a test command, and if you omit it, it creates a script "test": "echo \"Error: no test specified\" && exit 1". I believe this is unnecessary clutter since most of the time, it's too early to decide on the test command when the project is just initialized. And it's not like a Node project isn't valid unless it defines a test script.
  • pnpm init react-app behaves similarly to npm init react-app, essentially transforming the call into pnpm dlx create-react-app.

Command-line options:

  • -y, --yes: For pnpm init, skips all the questions and produces a default package.json. Ignored for pnpm init <pkg>.

Unlike npm, the --force option is not supported. I couldn't figure out what it does :p
Not sure what to do about workspaces. Should this option support being run in workspaces?

@illright
Copy link
Contributor Author

illright commented Oct 6, 2021

Oh wow, I just found out that enquirer has something called a Snippet Prompt and it looks so good.
In the example they even use it for a package.json file. I think we should use that for pnpm init.

@illright
Copy link
Contributor Author

illright commented Oct 6, 2021

For another thought, I kind of like Yarn's interface more with this. They have two commands:

  • yarn init mimics npm init
  • yarn create some-package mimics npm init some-package

There are two reasons why I like this:

  • npm's behaviour of prepending create- to initializer packages is kind of hidden away, at least Yarn has chosen a matching name:
    npm init react-app
    # vs
    yarn create react-app
    To me, the latter says create-react-app much more than the former
  • The behaviour of npm init and npm init <pkg> is completely different, it makes sense for those to be two separate commands.

All in all, I propose we have pnpm create and pnpm init.

@illright
Copy link
Contributor Author

illright commented Oct 6, 2021

I'm having trouble with pnpm run watch on this project. It goes well almost until the end but then fails. Here are the few log lines of the failure:

  dist/pnpm.cjs  4.9mb ⚠️

⚡ Done in 781ms

> pnpm@6.16.1 bundle:pnpx /home/illright/work/pnpm/packages/pnpm
> esbuild lib/pnpx.js --bundle --platform=node --outfile=dist/pnpx.cjs


  dist/pnpx.cjs  534.3kb

⚡ Done in 53ms
cp: dest is not a directory (too many sources)
/home/illright/work/pnpm/packages/pnpm:
 ERROR  pnpm@6.16.1 compile: `rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run lint -- --fix && rimraf dist bin/nodes && pnpm run bundle && shx cp -r node-gyp-bin dist/node-gyp-bin && shx cp -r node_modules/@pnpm/tabtab/lib/scripts dist/scripts && shx cp -r node_modules/ps-list/vendor dist/vendor "--watch"`
Exit status 1
 ERROR  Command failed with exit code 1.

Could you help me diagnose this?

@zkochan
Copy link
Member

zkochan commented Oct 6, 2021

All in all, I propose we have pnpm create and pnpm init.

Sounds good.

@zkochan
Copy link
Member

zkochan commented Oct 6, 2021

I'm having trouble with pnpm run watch on this project. It goes well almost until the end but then fails. Here are the few log lines of the failure:

I never used watch. Try running pnpm -w compile

@illright illright changed the title Add the pnpm init command Add the pnpm create command Oct 6, 2021
@illright illright marked this pull request as ready for review October 8, 2021 11:37
@illright illright requested a review from zkochan as a code owner October 8, 2021 11:37
@zkochan
Copy link
Member

zkochan commented Oct 9, 2021

it will be easier if you create a separate PR for pnpm init

@illright
Copy link
Contributor Author

illright commented Oct 9, 2021

Yeah, that was an accident. My bad

@zkochan zkochan merged commit c83488d into pnpm:main Oct 9, 2021
@illright illright deleted the feat/init-command branch October 10, 2021 06:59
@zkochan zkochan added this to the v6.17 milestone Oct 10, 2021
@TheKonka
Copy link

TheKonka commented Jul 4, 2023

I'm having trouble with pnpm run watch on this project. It goes well almost until the end but then fails. Here are the few log lines of the failure:

  dist/pnpm.cjs  4.9mb ⚠️

⚡ Done in 781ms

> pnpm@6.16.1 bundle:pnpx /home/illright/work/pnpm/packages/pnpm
> esbuild lib/pnpx.js --bundle --platform=node --outfile=dist/pnpx.cjs


  dist/pnpx.cjs  534.3kb

⚡ Done in 53ms
cp: dest is not a directory (too many sources)
/home/illright/work/pnpm/packages/pnpm:
 ERROR  pnpm@6.16.1 compile: `rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run lint -- --fix && rimraf dist bin/nodes && pnpm run bundle && shx cp -r node-gyp-bin dist/node-gyp-bin && shx cp -r node_modules/@pnpm/tabtab/lib/scripts dist/scripts && shx cp -r node_modules/ps-list/vendor dist/vendor "--watch"`
Exit status 1
 ERROR  Command failed with exit code 1.

Could you help me diagnose this?

Hello, I meet the same problem. Is there any solution can fix it?

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

3 participants