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(plugin-commands-init): add init configs and flags w/ npm compat #8113

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

josh-hemphill
Copy link

closes #7711

Still working on adding the documentation and tests, but wanted to get some feedback in the meantime.
Added all the settings npm exposes from npmrc and cli flags, as well as adding the interactive prompts behind a flag, so the default behavior should not have changed, but can in a future major version if people want it to.

I did add a few more settings that npm wasn't exposing that would make sense to control from npmrc settings, like using the global npmrc to set a policy of "type":"module" for new projects

Copy link

welcome bot commented May 22, 2024

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.

@zkochan
Copy link
Member

zkochan commented May 31, 2024

I wonder if we want this.

We already have the pnpm create command for bootstrapping projects. npm supports the same functionality via npm init <initializer>. We could just recommend some good initializers to run instead of maintaining our own. We may even add a config to run a given initializer by default, when running pnpm init.

@josh-hemphill
Copy link
Author

I wouldn't consider this an initializer like pnpm create since this only covers setting default values for package.json. pnpm is missing some of the basic settings npm has, and this fixes that and just adds a few more flags so people can set a system-wide policy of certain defaults that I think npm didn't have when they were writing their init command.

@@ -1,6 +1,6 @@
{
"name": "@pnpm/plugin-commands-init",
"version": "4.0.5",
"version": "4.1.0",
Copy link
Member

Choose a reason for hiding this comment

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

Version updates happen automatically. You just need to add changesets as described in CONTRIBUTING.md. No need to change the version fields.

Copy link
Member

Choose a reason for hiding this comment

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

we use camelCase for file names.

// The custom cancel function prevents that behavior.
// Otherwise, pnpm CLI would print an error and confuse users.
// See related issue: https://github.com/enquirer/enquirer/issues/225
globalInfo('Package.json Init canceled')
Copy link
Member

Choose a reason for hiding this comment

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

probably it should be

Suggested change
globalInfo('Package.json Init canceled')
globalInfo('package.json Init canceled')

usages: ['pnpm init'],
})
}
const getManifestDefaults = () => ({
Copy link
Member

Choose a reason for hiding this comment

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

our convention is to use regular functions

Suggested change
const getManifestDefaults = () => ({
function getManifestDefaults () {

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.

Complete pnpm init command
2 participants