Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-prompt

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-prompt - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.idea/libraries/Node_js_Dependencies_for_grunt_prompt.xml

187

Gruntfile.js

@@ -11,6 +11,9 @@ /*

var semver = require('semver');
var currentVersion = require('./package.json').version;
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-mocha-cli');

@@ -21,10 +24,14 @@ grunt.loadTasks('tasks');

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>'
'tasks/**/*.js',
'test/*.js'
],
options: {
jshintrc: '.jshintrc'
jshintrc: '.jshintrc',
ignores: []
}

@@ -35,22 +42,112 @@ },

prompt: {
bump: {
examples: {
options: {
questions: [
{
config: 'bump.increment',
config: 'echo.list',
type: 'list',
message: 'Bump version from ' + '1.2.3'.cyan + ' to:',
message: 'Choose an item from a list, returns the value',
choices: [
'1.2.4-? ❘❙❚ Build: unstable, betas, and release candidates.',
'1.2.4 ❘❙❚ Patch: backwards-compatible bug fixes.',
'1.3.0 ❘❙❚ Minor: add functionality in a backwards-compatible manner.',
'2.0.0 ❘❙❚ Major: incompatible API changes.',
'?.?.? ❘❙❚ Custom: Specify version...'
{ name: 'White'.white },
{ name: 'Grey'.grey },
{ name: 'Blue'.blue },
{ name: 'Cyan'.cyan },
{ name: 'Green'.green },
{ name: 'Magenta'.magenta },
{ name: 'Red'.red },
{ name: 'Yellow'.yellow },
{ name: 'Rainbow'.rainbow }
],
filter: String.toLowerCase
},
{
config: 'echo.checkbox',
type: 'checkbox',
message: 'Choose multiple items, returns an array of values',
choices: [
{ name: 'Bold'.bold },
{ name: 'Italic'.italic },
{ name: 'Underline'.underline },
{ name: 'Inverse'.inverse, value: 'inverse' },
{ name: 'Zebra'.zebra, value: 'zebra' }
],
filter: function(value) {
var matches = value.match(/([^(\s)]*):/);
return matches && matches[1].toLowerCase();
return grunt.util._(value).map(String.toLowerCase);
},
validate: function(value) {
var inverseAndZebra = grunt.util._(['inverse', 'zebra']).all(function(val){
return grunt.util._(value).contains(val);
});
if (inverseAndZebra) {
return 'You can choose Inverse or Zebra but not both';
}
return true;
}
},
{
config: 'echo.confirm',
type: 'confirm',
message: 'Choose yes or no, returns a boolean'
},
{
config: 'echo.input',
type: 'input',
message: 'Text input',
validate: function(value) {
if (value === '') {
return 'A value is required.';
}
return true;
}
},
{
config: 'echo.password',
type: 'password',
message: 'Password input',
validate: function(value) {
if (value.length < 5) {
return 'Password should be at least 5 characters.';
}
return true;
}
}
]
}
},
bump: {
options: {
questions: [
{
config: 'bump.increment',
type: 'list',
message: 'Bump version from ' + '<%= pkg.version %>'.cyan + ' to:',
choices: [
{
value: 'build',
name: 'Build: '.yellow + (currentVersion + '-?').yellow +
' Unstable, betas, and release candidates.'
},
{
value: 'patch',
name: 'Patch: '.yellow + semver.inc(currentVersion, 'patch').yellow +
' Backwards-compatible bug fixes.'
},
{
value: 'minor',
name: 'Minor: '.yellow + semver.inc(currentVersion, 'minor').yellow +
' Add functionality in a backwards-compatible manner.'
},
{
value: 'major',
name: 'Major: '.yellow + semver.inc(currentVersion, 'major').yellow +
' Incompatible API changes.'
},
{
value: 'custom',
name: 'Custom: ?.?.?'.yellow +
' Specify version...'
}
]
},
{
config: 'bump.version',

@@ -63,4 +160,4 @@ type: 'input',

validate: function (value) {
var valid = require('semver').valid(value) && true;
return valid || 'Must be a valid semver, such as 1.2.3. See http://semver.org/';
var valid = semver.valid(value) && true;
return valid || 'Must be a valid semver, such as 1.2.3-rc1. See ' + 'http://semver.org/'.blue.underline + ' for more details.';
}

@@ -74,10 +171,13 @@ },

{
name: 'package.json',
value: 'package',
name: 'package.json' + (!grunt.file.isFile('package.json') ? ' file not found, will create one'.grey : ''),
checked: grunt.file.isFile('package.json')
},
{
name: 'bower.json',
value: 'bower',
name: 'bower.json' + (!grunt.file.isFile('bower.json') ? ' file not found, will create one'.grey : ''),
checked: grunt.file.isFile('bower.json')
},
{
value: 'git',
name: 'git tag',

@@ -93,20 +193,45 @@ checked: grunt.file.isDir('.git')

// Unit tests.
nodeunit: {
tests: ['test/*_test.js']
mochacli: {
options: {
reporter: 'spec'
},
all: ['test/*.test.js']
}
});
grunt.registerTask('echo', '', function(){
grunt.log.ok('bump.increment: ' + grunt.config('bump.increment') + '.');
grunt.log.ok('bump.version: ' + grunt.config('bump.version') + '.');
grunt.log.ok('bump.files: ' + grunt.config('bump.files') + '.');
// Fake Grunt Bump task
grunt.registerTask('bump', '', function () {
if (grunt.config('bump.increment') === 'custom') {
grunt.log.ok('Bumping version to ' + grunt.config('bump.version').yellow + ':');
} else {
grunt.log.ok('Bumping up ' + grunt.config('bump.increment').yellow + ' version number.');
}
if (grunt.util._(grunt.config('bump.files')).contains('package')) {
grunt.log.ok('Updating ' + 'package.json'.yellow + '.');
}
if (grunt.util._(grunt.config('bump.files')).contains('bower')) {
if (!grunt.file.isFile('bower.json')) {
grunt.log.ok('Creating ' + 'bower.json'.yellow + '.');
}
grunt.log.ok('Updating ' + 'bower.json'.yellow + '.');
}
if (grunt.util._(grunt.config('bump.files')).contains('git')) {
grunt.log.ok('Updating ' + 'git tag'.yellow + '.');
}
});
grunt.registerTask('bump',
[
//'jshint',
'prompt:bump',
'bump'
]);
grunt.registerTask('test',
[
'jshint',
'prompt',
'echo'//,
//'nodeunit'
'mochacli'
]);

@@ -117,6 +242,4 @@

'jshint',
'prompt:bump',
'echo'
'prompt:examples'
]);
};
};

8

package.json
{
"name": "grunt-prompt",
"description": "Add interactive UI to your Gruntfile such as lists, checkboxes, text input with filtering, and password fields, all on the command line.",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/dylang/grunt-prompt",

@@ -29,9 +29,9 @@ "author": {

"scripts": {
"test": "grunt test"
"test": "grunt test --stack"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6",
"grunt-contrib-nodeunit": "~0.2",
"grunt": "~0.4.1",
"semver": "~2.0.10"
"semver": "~2.0.10",
"grunt-mocha-cli": "~1.0.6"
},

@@ -38,0 +38,0 @@ "peerDependencies": {

@@ -1,16 +0,7 @@

# grunt-prompt
# grunt-prompt [![Build Status](https://travis-ci.org/dylang/grunt-prompt.png?branch=master)](https://travis-ci.org/dylang/grunt-prompt)
> Ask questions during your Grunt workflow. Use user input for later tasks
> Add interactive UI to your Gruntfile such as lists, checkboxes, text input with filtering, and password fields, all on the command line.
![grunt-prompt-example](https://f.cloud.github.com/assets/51505/867636/e727abfc-f717-11e2-997e-6b97e24593c3.gif)
#### Choose from a list:
![List](https://f.cloud.github.com/assets/51505/823607/6549de22-f017-11e2-8a70-04bf663d5876.png)
#### Select more than one:
![Choices](https://f.cloud.github.com/assets/51505/823611/92c06a10-f017-11e2-82cf-24b1b8e5601d.png)
#### Text input with validation and filtering:
![Input](https://f.cloud.github.com/assets/51505/823612/aa893c08-f017-11e2-97bb-f5eef6c1e845.png)
## Getting Started

@@ -42,10 +33,10 @@ This plugin requires Grunt `~0.4.1`

questions: [
config: 'config.name', // arbitray name or config for any other grunt task
type: '<question type>', // list, checkbox, confirm, input, password
message: 'Question to ask the user',
default: 'value', // default value if nothing is entered
choices: 'Array|Function(answers)',
validate: Function(value), // return true if valid, error message if invalid
filter: Function(value), // modify the answer
when: Function(answers) // only ask this question when this function returns true
config: 'config.name', // arbitray name or config for any other grunt task
type: '<question type>', // list, checkbox, confirm, input, password
message: 'Question to ask the user',
default: 'value', // default value if nothing is entered
choices: 'Array|Function(answers)',
validate: Function(value), // return true if valid, error message if invalid
filter: Function(value), // modify the answer
when: Function(answers) // only ask this question when this function returns true
]

@@ -58,2 +49,5 @@ }

The interactive prompts in `grunt-prompt` are generated by [Inquirer](https://github.com/SBoudrias/Inquirer.js) by @SBoudrias.
### Options

@@ -83,4 +77,8 @@

The documentation for Inquiry has [more details about type](https://github.com/SBoudrias/Inquirer.js#prompts-type) as well as additional typess.
Here's an example of each type:
![grunt-prompt-example](https://f.cloud.github.com/assets/51505/867636/e727abfc-f717-11e2-997e-6b97e24593c3.gif)
The documentation for **Inquiry** has [more details about type](https://github.com/SBoudrias/Inquirer.js#prompts-type) as well as additional typess.
#### message

@@ -108,12 +106,17 @@

For `question type 'checkbox'`: Type: `array of hashes`
If you want to specify the value for the choices then use this format:
Include `checked: true` to select it by default.
For `question types 'checkbox' and 'list'`: Type: `array of hashes`
* `name` The label that is displayed in the UI.
* `value` _optional_ Value returned. When not used the name is used instead.
* `checked` Choosed the option by default.
```
choices: [
{name: 'jshint', checked: true},
{name: 'jslint'},
{name: 'eslint'}
]
{ name: 'jshint', checked: true },
{ name: 'jslint' },
{ name: 'eslint' },
{ name: 'something else', value: 'other' }
]
```

@@ -132,3 +135,3 @@

Use a modified version of the input for the answer. Useful for stripping extra characters, converting strings to integers, etc.
Use a modified version of the input for the answer. Useful for stripping extra characters, converting strings to integers.

@@ -144,4 +147,4 @@ #### when

![grunt-prompt-example-bump](https://f.cloud.github.com/assets/51505/867601/b3200cb6-f710-11e2-89da-675c831c218a.gif)
This is an example of how `grunt-prompt` for something like [grunt-bump](https://github.com/vojtajina/grunt-bump) which makes it easy to

@@ -152,63 +155,82 @@ update your project's version in the `package.json`, `bower.json`, and `git tag`.

prompt: {
prompt: {
bump: {
options: {
questions: [
{
config: 'bump.increment',
type: 'list',
// normally these versions wouldn't be hardcoded
message: 'Bump version from ' + '1.2.3'.cyan + ' to:',
choices: [
'1.2.4-? ❘❙❚ Build: unstable, betas, and release candidates.',
'1.2.4 ❘❙❚ Patch: backwards-compatible bug fixes.',
'1.3.0 ❘❙❚ Minor: add functionality in a backwards-compatible manner.',
'2.0.0 ❘❙❚ Major: incompatible API changes.',
'?.?.? ❘❙❚ Custom: Specify version...'
],
filter: function (value) {
var matches = value.match(/([^(\s)]*):/);
return matches && matches[1].toLowerCase();
bump: {
options: {
questions: [
{
config: 'bump.increment',
type: 'list',
message: 'Bump version from ' + '<%= pkg.version %>'.cyan + ' to:',
choices: [
{
value: 'build',
name: 'Build: '.yellow + (currentVersion + '-?').yellow +
' Unstable, betas, and release candidates.'
},
{
value: 'patch',
name: 'Patch: '.yellow + semver.inc(currentVersion, 'patch').yellow +
' Backwards-compatible bug fixes.'
},
{
value: 'minor',
name: 'Minor: '.yellow + semver.inc(currentVersion, 'minor').yellow +
' Add functionality in a backwards-compatible manner.'
},
{
value: 'major',
name: 'Major: '.yellow + semver.inc(currentVersion, 'major').yellow +
' Incompatible API changes.'
},
{
value: 'custom',
name: 'Custom: ?.?.?'.yellow +
' Specify version...'
}
]
},
{
config: 'bump.version',
type: 'input',
message: 'What specific version would you like',
when: function (answers) {
return answers['bump.increment'] === 'custom';
},
{
config: 'bump.version',
type: 'input',
message: 'What specific version would you like',
when: function (answers) {
return answers['bump.increment'] === 'custom';
validate: function (value) {
var valid = semver.valid(value) && true;
return valid || 'Must be a valid semver, such as 1.2.3-rc1. See ' +
'http://semver.org/'.blue.underline + ' for more details.';
}
},
{
config: 'bump.files',
type: 'checkbox',
message: 'What should get the new version:',
choices: [
{
value: 'package',
name: 'package.json' +
(!grunt.file.isFile('package.json') ? ' file not found, will create one'.grey : ''),
checked: grunt.file.isFile('package.json')
},
validate: function (value) {
var valid = require('semver').valid(value) && true;
return valid || 'Must be a valid semver, such as 1.2.3. See http://semver.org/';
{
value: 'bower',
name: 'bower.json' +
(!grunt.file.isFile('bower.json') ? ' file not found, will create one'.grey : ''),
checked: grunt.file.isFile('bower.json')
},
{
value: 'git',
name: 'git tag',
checked: grunt.file.isDir('.git')
}
},
{
config: 'bump.files',
type: 'checkbox',
message: 'What should get the new version:',
choices: [
{
name: 'package.json',
checked: grunt.file.isFile('package.json')
},
{
name: 'bower.json',
checked: grunt.file.isFile('bower.json')
},
{
name: 'git tag',
checked: grunt.file.isDir('.git')
}
]
}
]
}
]
}
]
}
}
}```
}
```
## Release History
* **0.1.1** - 27 July 2013 - Some documentation cleanup, better screenshots, new example code in the gruntfile, reomved unused tests.
* **0.1.0** - 18 July 2013 - First version, after an exhausting but fun day with the family at Hershey Park.

@@ -23,2 +23,3 @@ /*

questions = questions.map(function(question){
// config just made more sense than name, but we accept both
question.name = question.config || question.name;

@@ -28,8 +29,7 @@ return question;

var done = this.async();
inquirer.prompt( questions, function( answers ) {
_(answers).forEach(function(answer, name){
grunt.config(name, answer);
_(answers).forEach(function(answer, configName){
grunt.config(configName, answer);
});

@@ -36,0 +36,0 @@ done();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc