Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-07-24 12:22:05 +0400
committerisaacs <i@izs.me>2012-07-24 12:22:05 +0400
commitcda5bf861411194d64095e365fbcc8c54f60515a (patch)
treef897717110f0d5e1b4d5c2d8e71749d01d8a01e4 /node_modules/init-package-json
parentafd2514dcf86c83422f6b46bc050bda248ea2b61 (diff)
upgrade init-package-json to pull in newer promzard
Diffstat (limited to 'node_modules/init-package-json')
-rw-r--r--node_modules/init-package-json/node_modules/promzard/README.md3
-rw-r--r--node_modules/init-package-json/node_modules/promzard/package.json12
-rw-r--r--node_modules/init-package-json/node_modules/promzard/promzard.js2
-rw-r--r--node_modules/init-package-json/node_modules/promzard/test/exports.js68
-rw-r--r--node_modules/init-package-json/node_modules/promzard/test/fn.js85
-rw-r--r--node_modules/init-package-json/package.json10
6 files changed, 109 insertions, 71 deletions
diff --git a/node_modules/init-package-json/node_modules/promzard/README.md b/node_modules/init-package-json/node_modules/promzard/README.md
index ba834eaeb..93c0418a6 100644
--- a/node_modules/init-package-json/node_modules/promzard/README.md
+++ b/node_modules/init-package-json/node_modules/promzard/README.md
@@ -1,5 +1,8 @@
# promzard
+A prompting wizard for building files from specialized PromZard modules.
+Used by `npm init`.
+
A reimplementation of @SubStack's
[prompter](https://github.com/substack/node-prompter), which does not
use AST traversal.
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 783c4a064..fd85e0cfd 100644
--- a/node_modules/init-package-json/node_modules/promzard/package.json
+++ b/node_modules/init-package-json/node_modules/promzard/package.json
@@ -5,13 +5,13 @@
"url": "http://blog.izs.me/"
},
"name": "promzard",
- "description": "A reimplementation of @SubStack's [prompter](https://github.com/substack/node-prompter), which does not use AST traversal.",
- "version": "0.1.5",
+ "description": "prompting wizardly",
+ "version": "0.2.0",
"repository": {
"url": "git://github.com/isaacs/promzard"
},
"dependencies": {
- "read": "0"
+ "read": "1"
},
"devDependencies": {
"tap": "~0.2.5"
@@ -20,7 +20,7 @@
"scripts": {
"test": "tap test/*.js"
},
- "readme": "# promzard\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",
- "_id": "promzard@0.1.5",
- "_from": "promzard@~0.1.5"
+ "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",
+ "_id": "promzard@0.2.0",
+ "_from": "promzard@~0.2.0"
}
diff --git a/node_modules/init-package-json/node_modules/promzard/promzard.js b/node_modules/init-package-json/node_modules/promzard/promzard.js
index 5ebebc547..ef41ff7ec 100644
--- a/node_modules/init-package-json/node_modules/promzard/promzard.js
+++ b/node_modules/init-package-json/node_modules/promzard/promzard.js
@@ -211,6 +211,6 @@ PromZard.prototype.prompt = function (pdt, cb) {
}}(cb).bind(this)
}
- read({ prompt: prompt + ': ' , default: def }, cb)
+ read({ prompt: prompt + ':' , default: def }, cb)
}
diff --git a/node_modules/init-package-json/node_modules/promzard/test/exports.js b/node_modules/init-package-json/node_modules/promzard/test/exports.js
index 06ecce47e..a5f72d8bd 100644
--- a/node_modules/init-package-json/node_modules/promzard/test/exports.js
+++ b/node_modules/init-package-json/node_modules/promzard/test/exports.js
@@ -1,30 +1,48 @@
var test = require('tap').test;
var promzard = require('../');
+if (process.argv[2] === 'child') {
+ return child()
+}
+
test('exports', function (t) {
- t.plan(1);
-
- var ctx = { tmpdir : '/tmp' }
- var file = __dirname + '/exports.input';
- promzard(file, ctx, function (err, output) {
- t.same(
- {
- a : 3,
- b : '!2b',
- c : {
- x : 55,
- y : '/tmp/y/file.txt',
- }
- },
- output
- );
- });
-
- setTimeout(function () {
- process.stdin.emit('data', '\n');
- }, 100);
-
- setTimeout(function () {
- process.stdin.emit('data', '55\n');
- }, 200);
+ t.plan(1);
+
+ var spawn = require('child_process').spawn
+ var child = spawn(process.execPath, [__filename, 'child'])
+
+ var output = ''
+ child.stderr.on('data', function (c) {
+ output += c
+ })
+
+ setTimeout(function () {
+ child.stdin.write('\n');
+ }, 100)
+ setTimeout(function () {
+ child.stdin.write('55\n');
+ }, 200)
+
+ child.on('close', function () {
+ console.error('output=%j', output)
+ output = JSON.parse(output)
+ t.same({
+ a : 3,
+ b : '!2b',
+ c : {
+ x : 55,
+ y : '/tmp/y/file.txt',
+ }
+ }, output);
+ t.end()
+ })
});
+
+function child () {
+ var ctx = { tmpdir : '/tmp' }
+ var file = __dirname + '/exports.input';
+
+ promzard(file, ctx, function (err, output) {
+ console.error(JSON.stringify(output))
+ });
+}
diff --git a/node_modules/init-package-json/node_modules/promzard/test/fn.js b/node_modules/init-package-json/node_modules/promzard/test/fn.js
index 59efcadc7..4ce803e73 100644
--- a/node_modules/init-package-json/node_modules/promzard/test/fn.js
+++ b/node_modules/init-package-json/node_modules/promzard/test/fn.js
@@ -1,39 +1,56 @@
var test = require('tap').test;
var promzard = require('../');
var fs = require('fs')
+var file = __dirname + '/fn.input';
+
+var expect = {
+ a : 3,
+ b : '!2B...',
+ c : {
+ x : 5500,
+ y : '/tmp/y/file.txt',
+ }
+}
+expect.a_function = fs.readFileSync(file, 'utf8')
+expect.asyncPrompt = 'async prompt'
+
+if (process.argv[2] === 'child') {
+ return child()
+}
test('prompt callback param', function (t) {
- t.plan(1);
-
- var ctx = { tmpdir : '/tmp' }
- var file = __dirname + '/fn.input';
- promzard(file, ctx, function (err, output) {
- var expect =
- {
- a : 3,
- b : '!2B...',
- c : {
- x : 5500,
- y : '/tmp/y/file.txt',
- }
- }
- expect.a_function = fs.readFileSync(file, 'utf8')
- expect.asyncPrompt = 'async prompt'
- t.same(
- output,
- expect
- );
- });
-
- setTimeout(function () {
- process.stdin.emit('data', '\n');
- }, 100);
-
- setTimeout(function () {
- process.stdin.emit('data', '55\n');
- }, 200);
-
- setTimeout(function () {
- process.stdin.emit('data', 'async prompt')
- }, 300)
-});
+ t.plan(1);
+
+ var spawn = require('child_process').spawn
+ var child = spawn(process.execPath, [__filename, 'child'])
+
+ var output = ''
+ child.stderr.on('data', function (c) {
+ output += c
+ })
+
+ child.on('close', function () {
+ console.error('output=%j', output)
+ output = JSON.parse(output)
+ t.same(output, expect);
+ t.end()
+ })
+
+ setTimeout(function () {
+ child.stdin.write('\n')
+ }, 100)
+ setTimeout(function () {
+ child.stdin.write('55\n')
+ }, 150)
+ setTimeout(function () {
+ child.stdin.write('async prompt\n')
+ }, 200)
+})
+
+function child () {
+ var ctx = { tmpdir : '/tmp' }
+ var file = __dirname + '/fn.input';
+ promzard(file, ctx, function (err, output) {
+ console.error(JSON.stringify(output))
+ })
+}
diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json
index 78c6a7626..3d85725ff 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.4",
+ "version": "0.0.5",
"main": "init-package-json.js",
"scripts": {
"test": "tap test/*.js"
@@ -15,10 +15,10 @@
"url": "http://blog.izs.me/"
},
"license": "BSD",
- "description": "A node module to get your node module started.",
+ "description": "A node module to get your node module started",
"dependencies": {
- "promzard": "~0.1.5",
- "read": "~0.1.0",
+ "promzard": "~0.2.0",
+ "read": "~1.0.1",
"read-package-json": "0",
"semver": "~1.0.14"
},
@@ -37,6 +37,6 @@
"start"
],
"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",
- "_id": "init-package-json@0.0.4",
+ "_id": "init-package-json@0.0.5",
"_from": "init-package-json@0"
}