diff --git a/lib/commands/init.js b/lib/commands/init.js index bef54b0e4138d..db33345d9427e 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -19,6 +19,7 @@ class Init extends BaseCommand { 'init-author-url', 'init-license', 'init-module', + 'init-type', 'init-version', 'yes', 'force', diff --git a/tap-snapshots/test/lib/commands/config.js.test.cjs b/tap-snapshots/test/lib/commands/config.js.test.cjs index df1505cea26a3..f4058ee9c600f 100644 --- a/tap-snapshots/test/lib/commands/config.js.test.cjs +++ b/tap-snapshots/test/lib/commands/config.js.test.cjs @@ -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": "", @@ -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 = "" diff --git a/tap-snapshots/test/lib/docs.js.test.cjs b/tap-snapshots/test/lib/docs.js.test.cjs index e43577271929f..28e150390dc1e 100644 --- a/tap-snapshots/test/lib/docs.js.test.cjs +++ b/tap-snapshots/test/lib/docs.js.test.cjs @@ -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" @@ -2123,6 +2133,7 @@ Array [ "init-author-url", "init-license", "init-module", + "init-type", "init-version", "init.author.email", "init.author.name", @@ -2357,6 +2368,7 @@ Array [ "init-author-url", "init-license", "init-module", + "init-type", "init-version", "init.author.email", "init.author.name", @@ -3210,8 +3222,8 @@ npm init <@scope> (same as \`npx <@scope>/create\`) Options: [--init-author-name ] [--init-author-url ] [--init-license ] -[--init-module ] [--init-version ] [-y|--yes] [-f|--force] -[--scope <@scope>] +[--init-module ] [--init-type ] [--init-version ] +[-y|--yes] [-f|--force] [--scope <@scope>] [-w|--workspace [-w|--workspace ...]] [--workspaces] [--no-workspaces-update] [--include-workspace-root] @@ -3230,6 +3242,7 @@ aliases: create, innit #### \`init-author-url\` #### \`init-license\` #### \`init-module\` +#### \`init-type\` #### \`init-version\` #### \`yes\` #### \`force\` diff --git a/workspaces/config/lib/definitions/definitions.js b/workspaces/config/lib/definitions/definitions.js index 8b7ca2d30dd29..42d15a25db05b 100644 --- a/workspaces/config/lib/definitions/definitions.js +++ b/workspaces/config/lib/definitions/definitions.js @@ -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: '', + 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, diff --git a/workspaces/config/tap-snapshots/test/type-description.js.test.cjs b/workspaces/config/tap-snapshots/test/type-description.js.test.cjs index a78afd3d4ba75..cf398b47ae293 100644 --- a/workspaces/config/tap-snapshots/test/type-description.js.test.cjs +++ b/workspaces/config/tap-snapshots/test/type-description.js.test.cjs @@ -231,6 +231,9 @@ Object { "init-module": Array [ "valid filesystem path", ], + "init-type": Array [ + Function String(), + ], "init-version": Array [ "full valid SemVer string", ],