Skip to content

Commit

Permalink
feat: add --init-type flag (#8081)
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi authored Feb 4, 2025
1 parent 879303c commit 3a80a7b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
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

0 comments on commit 3a80a7b

Please sign in to comment.