diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-02-27 14:25:40 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-02-27 14:25:40 +0300 |
commit | a5edc17d5ef1435b468a445156a4a109df80f92b (patch) | |
tree | 567b4f205026393fc88e2524c2eccf78719a9c9b | |
parent | 9748d5cd195d0269b32caf45129a93d29359a796 (diff) |
init-package-json@1.3.0
Closes #6749.
Support for passing scopes to `npm init` so packages are initialized as part
of that scope / organization / team.
-rw-r--r-- | doc/cli/npm-init.md | 10 | ||||
-rw-r--r-- | node_modules/init-package-json/default-input.js | 3 | ||||
-rw-r--r-- | node_modules/init-package-json/package.json | 34 | ||||
-rw-r--r-- | node_modules/init-package-json/test/npm-defaults.js | 2 | ||||
-rw-r--r-- | node_modules/init-package-json/test/scope.js | 35 | ||||
-rw-r--r-- | package.json | 2 |
6 files changed, 57 insertions, 29 deletions
diff --git a/doc/cli/npm-init.md b/doc/cli/npm-init.md index 08e517d79..ec4c25bed 100644 --- a/doc/cli/npm-init.md +++ b/doc/cli/npm-init.md @@ -21,8 +21,18 @@ without a really good reason to do so. If you invoke it with `-f`, `--force`, `-y`, or `--yes`, it will use only defaults and not prompt you for any options. +## CONFIGURATION + +### scope + +* Default: none +* Type: String + +The scope under which the new module should be created. + ## SEE ALSO * <https://github.com/isaacs/init-package-json> * package.json(5) * npm-version(1) +* npm-scope(7) diff --git a/node_modules/init-package-json/default-input.js b/node_modules/init-package-json/default-input.js index 1b7d2c063..95c799ebb 100644 --- a/node_modules/init-package-json/default-input.js +++ b/node_modules/init-package-json/default-input.js @@ -39,6 +39,9 @@ function readDeps (test) { return function (cb) { }} var name = package.name || basename +if (config.get('scope')) { + name = '@' + config.get('scope') + '/' + name +} exports.name = yes ? name : prompt('name', name) var version = package.version || diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json index f3cadb45e..34e10ef86 100644 --- a/node_modules/init-package-json/package.json +++ b/node_modules/init-package-json/package.json @@ -1,6 +1,6 @@ { "name": "init-package-json", - "version": "1.2.0", + "version": "1.3.0", "main": "init-package-json.js", "scripts": { "test": "tap test/*.js" @@ -38,34 +38,14 @@ "prompt", "start" ], - "gitHead": "6c0743199706494a190c0b47d2e2567dc86055a3", + "readme": "# init-package-json\n\nA node module to get your node module started.\n\n## Usage\n\n```javascript\nvar init = require('init-package-json')\nvar path = require('path')\n\n// a path to a promzard module. In the event that this file is\n// not found, one will be provided for you.\nvar initFile = path.resolve(process.env.HOME, '.npm-init')\n\n// the dir where we're doin stuff.\nvar dir = process.cwd()\n\n// extra stuff that gets put into the PromZard module's context.\n// In npm, this is the resolved config object. Exposed as 'config'\n// Optional.\nvar configData = { some: 'extra stuff' }\n\n// Any existing stuff from the package.json file is also exposed in the\n// PromZard module as the `package` object. There will also be free\n// vars for:\n// * `filename` path to the package.json file\n// * `basename` the tip of the package dir\n// * `dirname` the parent of the package dir\n\ninit(dir, initFile, configData, function (er, data) {\n // the data's already been written to {dir}/package.json\n // now you can do stuff with it\n})\n```\n\nOr from the command line:\n\n```\n$ npm-init\n```\n\nSee [PromZard](https://github.com/isaacs/promzard) for details about\nwhat can go in the config file.\n", + "readmeFilename": "README.md", + "gitHead": "53273513f3fbaa017435ca6254d717cc27a85ddc", "bugs": { "url": "https://github.com/isaacs/init-package-json/issues" }, "homepage": "https://github.com/isaacs/init-package-json", - "_id": "init-package-json@1.2.0", - "_shasum": "b9f027514403b3b3f582c148592ab75214003348", - "_from": "init-package-json@>=1.2.0 <1.3.0", - "_npmVersion": "2.3.0", - "_nodeVersion": "0.10.35", - "_npmUser": { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - } - ], - "dist": { - "shasum": "b9f027514403b3b3f582c148592ab75214003348", - "tarball": "http://registry.npmjs.org/init-package-json/-/init-package-json-1.2.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-1.2.0.tgz" + "_id": "init-package-json@1.3.0", + "_shasum": "6bb76ed69dd1359581a6f1507d37d309658074d6", + "_from": "init-package-json@>=1.3.0 <1.4.0" } diff --git a/node_modules/init-package-json/test/npm-defaults.js b/node_modules/init-package-json/test/npm-defaults.js index 666e9a1c4..f65f64631 100644 --- a/node_modules/init-package-json/test/npm-defaults.js +++ b/node_modules/init-package-json/test/npm-defaults.js @@ -14,7 +14,7 @@ var EXPECTED = { test : 'echo "Error: no test specified" && exit 1' }, keywords : [], - author : "npmbot <n@p.m> (http://npm.im/)", + author : "npmbot <n@p.m> (http://npm.im)", license : "WTFPL" } diff --git a/node_modules/init-package-json/test/scope.js b/node_modules/init-package-json/test/scope.js new file mode 100644 index 000000000..7049a4db4 --- /dev/null +++ b/node_modules/init-package-json/test/scope.js @@ -0,0 +1,35 @@ +var tap = require('tap') +var init = require('../') +var rimraf = require('rimraf') + +tap.test('the scope', function (t) { + var i = __dirname + '/basic.input' + var dir = __dirname + init(dir, i, {scope: 'foo'}, function (er, data) { + if (er) throw er + var expect = + { name: '@foo/test', + version: '1.2.5', + description: 'description', + author: 'me <em@i.l> (http://url)', + scripts: { test: 'make test' }, + main: 'main.js', + config: { scope: 'foo' }, + package: {} } + t.same(data, expect) + t.end() + }) + setTimeout(function () { + process.stdin.emit('data', '@foo/test\n') + }, 50) + setTimeout(function () { + process.stdin.emit('data', 'description\n') + }, 100) + setTimeout(function () { + process.stdin.emit('data', 'yes\n') + }, 150) +}) + +tap.test('teardown', function (t) { + rimraf(__dirname + '/package.json', t.end.bind(t)) +}) diff --git a/package.json b/package.json index 55a4ea72e..0308da4c9 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "inflight": "~1.0.4", "inherits": "~2.0.1", "ini": "~1.3.3", - "init-package-json": "~1.2.0", + "init-package-json": "~1.3.0", "lockfile": "~1.0.0", "lru-cache": "~2.5.0", "minimatch": "~2.0.1", |