diff options
author | isaacs <i@izs.me> | 2013-04-29 20:04:23 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-04-29 20:04:23 +0400 |
commit | 8510862bf24fbe6e10a1c006a32831362d6bf128 (patch) | |
tree | 22d52611b280b1902457c82d7f670b6d65161532 /node_modules | |
parent | 40872359bf2e3aa9927756900e903f7d35c539fa (diff) |
init-package-json@0.0.8
Diffstat (limited to 'node_modules')
4 files changed, 28 insertions, 9 deletions
diff --git a/node_modules/init-package-json/default-input.js b/node_modules/init-package-json/default-input.js index ba4270263..d501b0644 100644 --- a/node_modules/init-package-json/default-input.js +++ b/node_modules/init-package-json/default-input.js @@ -16,6 +16,7 @@ function readDeps (test) { return function (cb) { if (er) return cb() var deps = {} var n = dir.length + if (n === 0) return cb(null, deps) dir.forEach(function (d) { if (d.match(/^\./)) return next() if (test !== isTestPkg(d)) @@ -166,11 +167,11 @@ if (!package.keywords) { } if (!package.author) { - exports.author = config['init.author.name'] + exports.author = config.get('init.author.name') ? { - "name" : config['init.author.name'], - "email" : config['init.author.email'], - "url" : config['init.author.url'] + "name" : config.get('init.author.name'), + "email" : config.get('init.author.email'), + "url" : config.get('init.author.url') } : prompt('author') } diff --git a/node_modules/init-package-json/init-package-json.js b/node_modules/init-package-json/init-package-json.js index 2406cd9f8..dafc4d324 100644 --- a/node_modules/init-package-json/init-package-json.js +++ b/node_modules/init-package-json/init-package-json.js @@ -17,6 +17,21 @@ var readJson = require('read-package-json') function init (dir, input, config, cb) { if (typeof config === 'function') cb = config, config = {} + + // accept either a plain-jane object, or a config object + // with a "get" method. + if (typeof config.get !== 'function') { + var data = config + config = { + get: function (k) { + return data[k] + }, + toJSON: function () { + return data + } + } + } + var package = path.resolve(dir, 'package.json') input = path.resolve(input) var pkg diff --git a/node_modules/init-package-json/node_modules/promzard/package.json b/node_modules/init-package-json/node_modules/promzard/package.json index ee9e8ea1e..3cf38bf80 100644 --- a/node_modules/init-package-json/node_modules/promzard/package.json +++ b/node_modules/init-package-json/node_modules/promzard/package.json @@ -22,6 +22,9 @@ }, "readme": "# promzard\n\nA prompting wizard for building files from specialized PromZard modules.\nUsed by `npm init`.\n\nA reimplementation of @SubStack's\n[prompter](https://github.com/substack/node-prompter), which does not\nuse AST traversal.\n\nFrom another point of view, it's a reimplementation of\n[@Marak](https://github.com/marak)'s\n[wizard](https://github.com/Marak/wizard) which doesn't use schemas.\n\nThe goal is a nice drop-in enhancement for `npm init`.\n\n## Usage\n\n```javascript\nvar promzard = require('promzard')\npromzard(inputFile, optionalContextAdditions, function (er, data) {\n // .. you know what you doing ..\n})\n```\n\nIn the `inputFile` you can have something like this:\n\n```javascript\nvar fs = require('fs')\nmodule.exports = {\n \"greeting\": prompt(\"Who shall you greet?\", \"world\", function (who) {\n return \"Hello, \" + who\n }),\n \"filename\": __filename,\n \"directory\": function (cb) {\n fs.readdir(__dirname, cb)\n }\n}\n```\n\nWhen run, promzard will display the prompts and resolve the async\nfunctions in order, and then either give you an error, or the resolved\ndata, ready to be dropped into a JSON file or some other place.\n\n\n### promzard(inputFile, ctx, callback)\n\nThe inputFile is just a node module. You can require() things, set\nmodule.exports, etc. Whatever that module exports is the result, and it\nis walked over to call any functions as described below.\n\nThe only caveat is that you must give PromZard the full absolute path\nto the module (you can get this via Node's `require.resolve`.) Also,\nthe `prompt` function is injected into the context object, so watch out.\n\nWhatever you put in that `ctx` will of course also be available in the\nmodule. You can get quite fancy with this, passing in existing configs\nand so on.\n\n### Class: promzard.PromZard(file, ctx)\n\nJust like the `promzard` function, but the EventEmitter that makes it\nall happen. Emits either a `data` event with the data, or a `error`\nevent if it blows up.\n\nIf `error` is emitted, then `data` never will be.\n\n### prompt(...)\n\nIn the promzard input module, you can call the `prompt` function.\nThis prompts the user to input some data. The arguments are interpreted\nbased on type:\n\n1. `string` The first string encountered is the prompt. The second is\n the default value.\n2. `function` A transformer function which receives the data and returns\n something else. More than meets the eye.\n3. `object` The `prompt` member is the prompt, the `default` member is\n the default value, and the `transform` is the transformer.\n\nWhatever the final value is, that's what will be put on the resulting\nobject.\n\n### Functions\n\nIf there are any functions on the promzard input module's exports, then\npromzard will call each of them with a callback. This way, your module\ncan do asynchronous actions if necessary to validate or ascertain\nwhatever needs verification.\n\nThe functions are called in the context of the ctx object, and are given\na single argument, which is a callback that should be called with either\nan error, or the result to assign to that spot.\n\nIn the async function, you can also call prompt() and return the result\nof the prompt in the callback.\n\nFor example, this works fine in a promzard module:\n\n```\nexports.asyncPrompt = function (cb) {\n fs.stat(someFile, function (er, st) {\n // if there's an error, no prompt, just error\n // otherwise prompt and use the actual file size as the default\n cb(er, prompt('file size', st.size))\n })\n}\n```\n\nYou can also return other async functions in the async function\ncallback. Though that's a bit silly, it could be a handy way to reuse\nfunctionality in some cases.\n\n### Sync vs Async\n\nThe `prompt()` function is not synchronous, though it appears that way.\nIt just returns a token that is swapped out when the data object is\nwalked over asynchronously later, and returns a token.\n\nFor that reason, prompt() calls whose results don't end up on the data\nobject are never shown to the user. For example, this will only prompt\nonce:\n\n```\nexports.promptThreeTimes = prompt('prompt me once', 'shame on you')\nexports.promptThreeTimes = prompt('prompt me twice', 'um....')\nexports.promptThreeTimes = prompt('you cant prompt me again')\n```\n\n### Isn't this exactly the sort of 'looks sync' that you said was bad about other libraries?\n\nYeah, sorta. I wouldn't use promzard for anything more complicated than\na wizard that spits out prompts to set up a config file or something.\nMaybe there are other use cases I haven't considered.\n", "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/isaacs/promzard/issues" + }, "_id": "promzard@0.2.0", "_from": "promzard@~0.2.0" } diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json index a9848343e..c0301ff02 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": "0.0.6", + "version": "0.0.8", "main": "init-package-json.js", "scripts": { "test": "tap test/*.js" @@ -38,9 +38,9 @@ ], "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", - "_id": "init-package-json@0.0.6", - "dist": { - "shasum": "3d16465b07d401b8ec2a5df1bd379dccc2dd6a37" + "bugs": { + "url": "https://github.com/isaacs/init-package-json/issues" }, - "_from": "init-package-json@0.0.6" + "_id": "init-package-json@0.0.8", + "_from": "init-package-json@latest" } |