Skip to content

feat: add --init-type flag #8081

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

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Init extends BaseCommand {
'init-author-url',
'init-license',
'init-module',
'init-type',
'init-version',
'yes',
'force',
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test/lib/commands/config.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"init-author-url": "",
"init-license": "ISC",
"init-module": "{CWD}/home/.npm-init.js",
"init-type": "commonjs",
"init-version": "1.0.0",
"init.author.email": "",
"init.author.name": "",
Expand Down Expand Up @@ -237,6 +238,7 @@ init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "{CWD}/home/.npm-init.js"
init-type = "commonjs"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
Expand Down
17 changes: 15 additions & 2 deletions tap-snapshots/test/lib/docs.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,16 @@ more information, or [npm init](/commands/npm-init).



#### \`init-type\`

* Default: "commonjs"
* Type: String

The value that \`npm init\` should use by default for the package.json type
field.



#### \`init-version\`

* Default: "1.0.0"
Expand Down Expand Up @@ -2123,6 +2133,7 @@ Array [
"init-author-url",
"init-license",
"init-module",
"init-type",
"init-version",
"init.author.email",
"init.author.name",
Expand Down Expand Up @@ -2357,6 +2368,7 @@ Array [
"init-author-url",
"init-license",
"init-module",
"init-type",
"init-version",
"init.author.email",
"init.author.name",
Expand Down Expand Up @@ -3210,8 +3222,8 @@ npm init <@scope> (same as \`npx <@scope>/create\`)

Options:
[--init-author-name <name>] [--init-author-url <url>] [--init-license <license>]
[--init-module <module>] [--init-version <version>] [-y|--yes] [-f|--force]
[--scope <@scope>]
[--init-module <module>] [--init-type <type>] [--init-version <version>]
[-y|--yes] [-f|--force] [--scope <@scope>]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[--workspaces] [--no-workspaces-update] [--include-workspace-root]

Expand All @@ -3230,6 +3242,7 @@ aliases: create, innit
#### \`init-author-url\`
#### \`init-license\`
#### \`init-module\`
#### \`init-type\`
#### \`init-version\`
#### \`yes\`
#### \`force\`
Expand Down
8 changes: 8 additions & 0 deletions workspaces/config/lib/definitions/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,14 @@ const definitions = {
more information, or [npm init](/commands/npm-init).
`,
}),
'init-type': new Definition('init-type', {
default: 'commonjs',
type: String,
hint: '<type>',
description: `
The value that \`npm init\` should use by default for the package.json type field.
`,
}),
'init-version': new Definition('init-version', {
default: '1.0.0',
type: Semver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ Object {
"init-module": Array [
"valid filesystem path",
],
"init-type": Array [
Function String(),
],
"init-version": Array [
"full valid SemVer string",
],
Expand Down
Loading