Giter Site home page Giter Site logo

dylang / grunt-prompt Goto Github PK

View Code? Open in Web Editor NEW
367.0 15.0 31.0 87 KB

Add interactive UI to your Gruntfile such as lists, checkboxes, text input with filtering, and password fields, all on the command line.

Home Page: https://npmjs.org/package/grunt-prompt

License: MIT License

JavaScript 100.00%

grunt-prompt's Introduction

grunt-prompt Build Status grunt-prompt

Interactive prompt for your Grunt config using console checkboxes, text input with filtering, password fields.

grunt-prompt in action
grunt-prompt in action

Getting Started

This plugin recommends Grunt 0.4.1 or newer.

Installing

npm install grunt-prompt --save-dev

Once that's done, add this line to your project's Gruntfile.js:

grunt.loadNpmTasks('grunt-prompt');

Grunt-prompt's UI is powered by the amazing Inquirer, a project created by Simon Boudrias.

grunt-prompt in action
grunt-prompt in action

Overview

In your project's Gruntfile, add a section named prompt to the data object passed into grunt.initConfig().

grunt-prompt is a multi-task. This means you can create multiple prompts.

grunt.initConfig({
  prompt: {
    target: {
      options: {
        questions: [
          {
            config: 'config.name', // arbitrary name or config for any other grunt task
            type: '<question type>', // list, checkbox, confirm, input, password
            message: 'String|function(answers)', // Question to ask the user, function needs to return a string,
            default: 'value', // default value if nothing is entered
            choices: 'Array|function(answers)',
            validate: function(value), // return true if valid, error message if invalid. works only with type:input 
            filter:  function(value), // modify the answer
            when: function(answers) // only ask this question when this function returns true
          }
        ]
      }
    },
  },
})

Options

config

Type: String required

This is used for three things:

  • It will set or overwrite the config of other Grunt tasks: config: 'jshint.allFiles.reporter'
  • The key in the resulting answers object: if (answers['jshint.allFiles.reporter'] === 'custom') {...
  • It can be an arbitrary value read using grunt.config: grunt.config('jshint.allFiles.reporter')
type

Type: String required

Type of question to ask:

  • list: use arrow keys to pick one choice. Returns a string.
  • checkbox: use arrow keys and space bar to pick multiple items. Returns an array.
  • confirm: Yes/no. Returns a boolean.
  • input: Free text input. Returns a string.
  • password: Masked input. Returns a string.

Here's an example of each type:

grunt-prompt example
grunt-prompt example

The documentation for Inquiry has more details about type as well as additional typess.

message

Type: String|function(answers):String required

The question to ask the user. If it's a function, it needs to return a string. The first parameter of this function will be an array containing all previously supplied answers. This allows you to customize the message based on the results of previous questions.

Hint: keep it short, users hate to read.

default

Type: String/Array/Boolean/'function' optional

Default value used when the user just hits Enter. If a value field is not provided, the filter value must match the name exactly.

choices

For question types 'list' and 'checkbox': 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 optional Choose the option by default. Only for checkbox.
choices: [
  { name: 'jshint', checked: true },
  { name: 'jslint' },
  { name: 'eslint' },
  '---', // puts in a non-selectable separator. Can be a string or '---' for default.
  { name: 'I like to live dangerously', value: 'none' }
]
validate

Type: function(value) optional

Return true if it is valid (true true, not a truthy value). Return string message if it is not valid.

filter

Type: function(value) optional

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

when

Type: function(answers) optional

Choose when this question is asked. Perfect for asking questions based on the results of previous questions.

then

Type: function(results, done):Boolean optional

Runs after all questions have been asked.

The done parameter is optional, and can be used for async operations in your handler.

When you return true from this function, the grunt-prompt code will not complete the async, so you are able to do your own async operations and call done() yourself.

config:
  prompt: {
    demo: {
      options: {
        questions: [
          ..
        ],
        then: function(results, done) {
          someAsyncFunction(function () {
            done();
          });
          return true;
        }
      }
    }
  }

How to use the results in your Gruntfile

You can also modify how tasks will work by changing options for other tasks. You do not need to write code to do this, it's all in the config var.

Here we will let the user choose what Mocha reporter to use.

config:
  prompt: {
    mochacli: {
      options: {
        questions: [
          {
            config: 'mochacli.options.reporter'
            type: 'list'
            message: 'Which Mocha reporter would you like to use?',
            default: 'spec'
            choices: ['dot', 'spec', 'nyan', 'TAP', 'landing', 'list',
              'progress', 'json', 'JSONconv', 'HTMLconv', 'min', 'doc']
          }
        ]
      }
    }
  }

and create a shortcut:

grunt.registerTask('test',
  [
    'prompt:mochacli',
    'mochacli'
  ]);

And run it:

$ grunt test
grunt-prompt setting up Mocha
grunt-prompt setting up Mocha

How can values be accessed from my own code?

This config value is accessible to all other grunt tasks via grunt.config('<config name>').

If you had this:

config: 'validation'

Then later on in your custom task can access it like this:

var validation = grunt.config('validation');

Usage Examples

grunt-prompt with grunt-bump
grunt-prompt with grunt-bump

This is an example of how grunt-prompt for something like grunt-bump which makes it easy to update your project's version in the package.json, bower.json, and git tag.

prompt: {
  bump: {
    options: {
      questions: [
        {
          config:  'bump.increment',
          type:    'list',
          message: 'Bump version from ' + '<%= pkg.version %>' + ' to:',
          choices: [
            {
              value: 'build',
              name:  'Build:  '+ (currentVersion + '-?') + ' Unstable, betas, and release candidates.'
            },
            {
              value: 'patch',
              name:  'Patch:  ' + semver.inc(currentVersion, 'patch') + ' Backwards-compatible bug fixes.'
            },
            {
              value: 'minor',
              name:  'Minor:  ' + semver.inc(currentVersion, 'minor') + ' Add functionality in a backwards-compatible manner.'
            },
            {
              value: 'major',
              name:  'Major:  ' + semver.inc(currentVersion, 'major') + ' Incompatible API changes.'
            },
            {
              value: 'custom',
              name:  'Custom: ?.?.? Specify version...'
            }
          ]
        },
        {
          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);
            return !!valid || 'Must be a valid semver, such as 1.2.3-rc1. See http://semver.org/ 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') ? ' not found, will create one' : ''),
              checked: grunt.file.isFile('package.json')
            },
            {
              value:   'bower',
              name:    'bower.json' + (!grunt.file.isFile('bower.json') ? ' not found, will create one' : ''),
              checked: grunt.file.isFile('bower.json')
            },
            {
              value:   'git',
              name:    'git tag',
              checked: grunt.file.isDir('.git')
            }
          ]
        }
      ]
    }
  }
}

Release History

  • 1.3.0 - 26 Oct 2014 - Add {{done}} callback for {{then}}.
  • 1.2.1 - 4 Oct 2014 - Separator can be '' or { separator: 'any string' }. Fixed it so choices can be strings again.
  • 1.2.0 - 4 Oct 2014 - Separator in choices can be a falsey value or string
  • 1.1.0 - 4 Mar 2014 - Messages can be functions instead of strings for dynamic questions.
  • 1.0.0 - 4 Feb 2014 - Dropping support for Node 0.8.
  • 0.2.2 - 4 Feb 2014 - Updated readme to make it auto-generated.
  • 0.2.1 - 4 Feb 2014 - Fix bug when using a function to provide choices.
  • 0.2.0 - 26 Jan 2014 - Added then option which runs after questions. Improved docs.
  • 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.

About the Author

Hi! Thanks for checking out this project! My name is Dylan Greene. When not overwhelmed with my two young kids I enjoy contributing to the open source community. I'm also a tech lead at Opower. @dylang @dylang

Here's some of my other Node projects:

Name Description npm Downloads
grunt‑notify Automatic desktop notifications for Grunt errors and warnings using Growl for OS X or Windows, Mountain Lion and Mavericks Notification Center, and Notify-Send. grunt-notify
npm‑check Check for outdated, incorrect, and unused dependencies. npm-check
shortid Amazingly short non-sequential url-friendly unique id generator. shortid
rss RSS feed generator. Add RSS feeds to any project. Supports enclosures and GeoRSS. rss
xml Fast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples. xml
changelog Command line tool (and Node module) that generates a changelog in color output, markdown, or json for modules in npmjs.org's registry as well as any public github.com repo. changelog
grunt‑attention Display attention-grabbing messages in the terminal grunt-attention
observatory Beautiful UI for showing tasks running on the command line. observatory
anthology Module information and stats for any @npmjs user anthology
grunt‑cat Echo a file to the terminal. Works with text, figlets, ascii art, and full-color ansi. grunt-cat

This list was generated using anthology.

License

Copyright (c) 2015 Dylan Greene, contributors.

Released under the MIT license.

Screenshots are CC BY-SA (Attribution-ShareAlike).


Generated using grunt-readme with grunt-templates-dylang on Wednesday, November 11, 2015. _To make changes to this document look in /templates/readme/

grunt-prompt's People

Contributors

dylang avatar justin3636 avatar miroradenovic avatar nicbright avatar ronaldtreur avatar thanarie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-prompt's Issues

Reference Errors: currentVersion and semver

When trying to run the example you have for working with grunt-bump, I get the following errors:

ReferenceError: currentVersion is not defined and ReferenceError: semver is not defined

Any idea what I'm doing wrong? Thanks!

Lodash dependencies triggering vulnerabilities(high)

The current version of lodash in the package.json file is "^3.10.1". This is triggering a 'Prototype Pollution' High-level warning during install. According to the audit message, any version higher than 4.17.11 of lodash should resolve this issue.
https://www.npmjs.com/advisories/782
It appears this issue has been asked before, but the issuer closed the issue (I'm assuming he got tired of waiting for a response)

Non-string default value for Input results in config value being undefined

With a question defined like this
{ config: 'test_value', type: 'input', message: 'Enter value', default: 1, }
I will see a prompt Enter value (1). If I press enter to select default value grunt.config('test_value') will be undefined.

If I change the question to default: '1' everything works as expected.

Loose of parameters when using for options with other task

Really a great component. Thank you 👍

I am using grunt prompt to send option to other task. But the problem is in this case that I cannot pass any more option to the other task. Example if I have:
config:

        prompt: {
            askcommit:{
                options:{
                    questions:[{
                        config: 'dobuild.options.commit',
                        type: 'confirm',
                        message: 'Do you want to commit this build?'
                    }]
                }
            }
        }

       grunt.registerTask('build', ['prompt:askcommit', 'dobuild']);

Running this:

grunt build:prod

will not have anymore the prod parameter in the dobuild task.

Any idea?

Feature Request: config key supporting list of strings

I found myself using multitasks in combination with checkbox-style prompts, which I find very convenient. However, sometimes I want to run multiple multitask based off exactly the same selection, in which case I have to add a helper task (or some other fiddly hack) to copy the selection from the original value to multiple places.

Would a pull request implementing this feature be welcome?

The result would be that the selection is written to multiple places in the grunt config instead of just one.

Update lodash dependency to >=4.17.5

npm install bemoans two low severity vulnerabilities in connection with this package:

npm audit returns:

Visit https://go.npm.me/audit-guide for additional guidance

Low           │ Prototype Pollution    
Package       │ lodash  
Patched in    │ >=4.17.5    
Dependency of │ grunt-prompt         
Path          │ grunt-prompt > inquirer > lodash      
More info     │ https://nodesecurity.io/advisories/577        

Low           │ Prototype Pollution     
Package       │ lodash             
Patched in    │ >=4.17.5           
Dependency of │ grunt-prompt    
Path          │ grunt-prompt > lodash       
More info     │ https://nodesecurity.io/advisories/577      

found 2 low severity vulnerabilities in 13285 scanned packages
  2 vulnerabilities require manual review. See the full report for details.

As the used version is at 3, I am not sure how much work is required to update this to 4.17.5?

Latest build is not populating config values

Great grunt task, been using it for quite a while.

v1.3.2

sample:

prompt : {
            deploy : {
                options : {
                    questions : [
                        {
                            config : 'environment',
                            type : 'list',
                            message : 'Environment to deploy to:',
                            default : 'staging',
                            choices : ['staging', 'production']
                        }
                    ]
                }
            }
        }

using the following will log and empty string here:

    grunt.registerTask('logit', function() {
        console.log(grunt.template.process('the env is <%= environment %>'));
    });
    grunt.registerTask('deploy', [
        'prompt:deploy',
        'logit']);

the env is

1.3.0 logs staging

Colors?

I couldn't find how I use colors, bold, underline, etc.

Either here or @ Inquirer.

Then function not firing

Hi there,

I'm trying to use .then after a prompt, but it seems that the function is not firing/executing.
Here is the code :

module.exports = function (grunt, options) {

    return {

        // Check if salts are already configured in .env file
        // If not, prompt the user if they need to be configured
        wp_salts: {
            options: {
                questions: [
                    {
                        config: 'wp.salts.create',
                        type: 'confirm',
                        message: 'Create salts ?',
                        default: false,
                        when: function(){
                            return !('AUTH_KEY' in process.env);
                        },
                        then: function(results, done) {
                            grunt.log("results : " + results);
                            if(results['wp.salts.create'] === true) {
                                grunt.task.run('shell:wp_salts');
                            }
                        }
                    },
                    {
                        config: 'wp.salts.replace',
                        type: 'confirm',
                        message: 'Salts already found, regenerate ?',
                        default: false,
                        when: function(){
                            return ('AUTH_KEY' in process.env);
                        },
                        then: function(results, done) {
                            grunt.log("results : " + results);
                            if(results['wp.salts.replace'] === true) {
                                grunt.task.run('replace:wp_salts').then(function(){
                                    done();
                                });
                            }
                            return true;

                        }
                    }
                ]
            }
        }

    };

};

And the result from the console is

[...]
Running "prompt:wp_salts" (prompt) task
? Create salts ? Yes

Running "prompt:wp_theme " [ ... ]

I answer yes, but nothing gets executed after that. Even the log aren't echoed.

Thank you for any kind of help

`then` for each question

We currently have a then that runs at the end of each question list. What if we had such for each individual question? It'd be very useful for organizing code with the question instead of all lumped at the end.

I'd asked the core Inquirer team to implement this but they didn't see a use for it outside of a Grunt task, which I do agree. They'd suggested that it could be implemented here with wrapped inquirer.prompt() calls.

Confrim returns false in other tasks

Confirm is returning false in other tasks, regardless of the state.

Example:

{
              config: 'generate.confirm_generate_test_files',
              type: 'confirm',
              message: 'Should we generate phpunit test files for you?',
            }

generate.confirm_generate_test_files value used in a 'clean' task:

clean: (function( results ) {
            if ( ! grunt.config('generate.confirm_generate_test_files') ) {
                return {
                    cleanup_tests: [
                        'yikes-inc-plugin-boilerplate/.git',
                        'yikes-inc-plugin-boilerplate/tests',
                        'yikes-inc-plugin-boilerplate/bin',
                        'yikes-inc-plugin-boilerplate/phpunit.xml.dist'
                    ]
                };
            } else {
                return {
                    dont_cleanup_tests: ['yikes-inc-plugin-boilerplate/.git']
                };
            }
        }()),

The clean function always returns false, even if the confirm is set to 'Y' - and thus clean:dont_cleanup_tests is always executed.

Add support for inquirer.Separator()

Perhaps something like this:

choices: [
    { name:"asdf1", value:"asdf" },
    { name:"asdf2", value:"asdf" },
    { name:"asdf3", value:"asdf" },
    "separator",
    { name:"Exit", value:"exit" }
]

or:

choices: [
    { name:"asdf1", value:"asdf" },
    { name:"asdf2", value:"asdf" },
    { name:"asdf3", value:"asdf" },
    {},
    { name:"Exit", value:"exit" }
]

of:

choices: [
    { name:"asdf1", value:"asdf" },
    { name:"asdf2", value:"asdf" },
    { name:"asdf3", value:"asdf" },
    null,
    { name:"Exit", value:"exit" }
]

Arrow keys not functioning 75% of the time

Title pretty much says it all - sometimes I can select from list, sometimes I cannot.

Node version 4.1.1
Grunt version 0.4.5
Grunt-Prompt version 1.3.0
Windows 10
Tried windows CMD and ConEmu

set default list item

I would like to set the default item for question type list. I have a long alphabetically sorted list of items. By default I would like to have the selector / marker start at a different item than the top one. I think ideally I would be able to do this by using the default property of the question or otherwise the checked property of the choice.

Suggestion using question default property:

questions: [
    {
        config: 'nextTask.property',
        type: 'list',
        message: 'Select your team',
        choices: [
          { name: 'alpha' },
          { name: 'bravo' },
          { name: 'charlie' },
          { name: 'delta' },
          { name: 'echo' }
        ],
        default: 'delta'
    }
]

Suggestion using choice checked property:

questions: [
    {
        config: 'nextTask.property',
        type: 'list',
        message: 'Select your team',
        choices: [
          { name: 'alpha' },
          { name: 'bravo' },
          { name: 'charlie' },
          { name: 'delta', checked: true },
          { name: 'echo' }
        ]
    }
]

Feature request: finally function

It'd be great to be able to run some "finally" or cleanup code after a prompt task. The "finally" block allows the developer to do something additional with the user input before running the next task.

An example: prompt task which looks for some environment variables (VAR1, VAR2, VAR3), and if they don't exist, asks user to provide values for them, and in a "finally" block, the prompt task can format and write a shell script file for the user to run in the future to populate those variables:
export VAR1=foo
export VAR2=bar
export VAR3=baz

Thanks. Let me know if you'd like any more information.

Supporting more inquiry types?

So it says in the documentation here at Github:
"The documentation for Inquiry has more details about type as well as additional typess."

But I cannot use these types, I want to use 'datetime' but its not possible. Can I install these in anyway on the grunt-prompt by my self?

Will grunt-prompt be updated with newer inquirer?

Validate does not run

In the example below the validate function does not run (I've pasted your example validation function to make sure that I'm using the correct syntax). I'm using your plugin combined with grunt-load-config (hence the module.exports). Even though any answer to the first question should return the validation error message, nothing happens.

module.exports = {
  init: {
    options: {
      questions: [
        {
          // Ftppass reminder
          config: 'config.ftpass',
          type: 'confirm',
          message: 'Is .ftppass in the root of your local project folder?',
          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.';
          }
        },
        {
          // Set the name of the project
          config: 'config.name',
          type: 'input',
          message: 'What is the name of your project?'
        },
        {
          // Select templates to be used
          config: 'config.templates',
          type: 'checkbox',
          message: 'Which templates do you want to use?',
          choices: [
            { name: '404.php', checked: false },
            { name: 'archive.php', checked: false },
            { name: 'comments.php', checked: false },
            { name: 'footer.php', checked: true },
            { name: 'functions.php', checked: false },
            { name: 'header.php', checked: true },
            { name: 'index.php', checked: true },
            { name: 'page.php', checked: false },
            { name: 'search.php', checked: false },
            { name: 'sidebar.php', checked: false },
            { name: 'single.php', checked: false },
            { name: 'template-fullwidth.php', checked: false },
            { name: 'template-leftsidebar.php', checked: false },
            { name: 'template-twosidebar.php', checked: false }
          ]
        }
      ]
    }
  }
};

No "prompt" targets found.

I'm getting the above error when I call the grunt task from a gruntfile that calls the custom plugin that I created. The plugin works in a standalone fashion, but when I include it into my project via grunt.loadNpmTasks('grunt-svn-tagging') it gets the error mentioned. I'm not exactly sure what the problem is, any help would be great.

Thanks in advance!

Abort for yes/no questions

I'm using this super module to ask the user if they wish to continue. It's a simple y/n input and in my grunt task I check for the config to be y before allowing the grunt task chain to continue.

It would be great if this module supported simple y/n questions and provided the option to abort with zero code required in my grunt task.

alter default of the next question

Hi,

I'am currently designing a release process using grunt-prompt and want to change the default property of release.info.nextVersion based on the setting of release.info.version.

{
  config: 'release.info.version',
  type: 'input',
  message:  'What is the release version?',
  'default':  '<%= release.info.version %>'
}, {
  config: 'release.info.nextVersion',
  type: 'input',
  message:  'What is the next version for development?',
  'default':  '<%= release.info.nextVersion %>'
}

How to update question2 default with the input of question1?
Is it possible to set a default function?

By the way,
is it possible to provide an alias for default? The linter is always alerting...

kind regards

Password promt display characters

The password promt show the characters when entering the password. This is not really usual behavior for passwords..

I used this configuration:

`grunt.loadNpmTasks('grunt-prompt');
grunt.initConfig({
prompt: {
target: {
options: {
questions: [
{
config: 'password',
type: 'password',
message: 'password'

        }
      ]
    }
  }
}

})`

Custom separator value

Right now, to add a separator, you must use '---'. Would it be possible to change the logic to look for a string value? If the string value equals '---' or the length is 0, use the default inquirer.Separator() value. If the length is greater than 0, pass that value to the separator function as inquirer.Separator(string_value).

Code:
choices: [
    'HEADING',
    {name: 'Label 1'},
    {name: 'Label 2'},
    '---',
    {name: 'Label 3'},
    {name: 'Label 4'}
]
Result:
HEADING
[] Label 1
[] Label 2
--------
[] Label 3
[] Label 4

let `message`-function fall through to Inquirer instead of its result

In PR #14 support for message 'as a function' was added to grunt-prompt. Nowadays(?) Inquirer offers the same functionality, with an important improvement: An array of answers is provided to the function upon its execution.

To this end, it would be nice if the custom message-function handling code could be removed. Things will simply work (better) without it.

v1.2.0 arrow disappeared for list questions

1.1.0 shows the little arrow next to the choices for list questions,
in 1.2.0 I do not see the arrow (or the square brackets around the question mark) - but I do see the choices - and am getting an undefined error if I hit the down arrow and enter:

Fatal error: Cannot read property 'name' of undefined

e.g. config:

{
        config : 'environment',
        type : 'list', // list, checkbox, confirm, input, password
        message : 'Which environment would you like to use?',
        default : 'local', // default value if nothing is entered
        choices : ['local', 'staging', 'production']
}

Shell ui

1.2.0

Running "prompt:deploy" (prompt) task
? Which environment would you like to use? (Use arrow keys)
  local
  staging
  production

1.1.0

Running "prompt:deploy" (prompt) task
[?] Which environment would you like to use? (Use arrow keys)
❯ local 
  staging
  production 

Using data in config of another task

Hi,

Love this grunt module :)
I would like to use this module in combination with grunt-contrib-copy. I would like to copy and rename a folder based on a input given in the prompt. Here is my Gruntfile.js: http://pastebin.com/CXSBae6h.

As you can see in the 'copy.theme' scope, I would like to copy wp-content/themes/scaffold-child/* to wp-content/themes/' + grunt.config( 'conductor.project.name' ). When I run grunt, it creates a folder with name 'undefined'.

How can I use the prompt input within copy.theme?

Thanks! :)

How to choose, and then run tasks (and subtasks)?

I'm trying to set up grunt-prompt so that you can choose tasks to run. I have a site with four themes, and I'd like to be able to choose whether to build all four themes, or just one of them.

I have everything working manually (FYI I'm also using grunt-concurrent), so I have groups of tasks such as concurrent:fullBuild, concurrent:themeOneBuild etc.

I have the 'choosing' bit of grunt-prompt set up fine and I get a nice little prompt asking which theme I want to build, but I'm struggling to to figure out where to go from here to make it then run the specified subtask.

From the README I can see how you can pass options into a task, but I want to call a task and subtask.

I've played around a bit with when: function() { ..., but I just get error messages saying things like grunt is not defined.

Can anyone help point me in the right direction?

README grunt-prompt example out of date

Hi, I ran into a few troubles with the grunt-prompt example I thought I'd share:

1.) semver.valid(value) from the docs https://github.com/npm/node-semver, returns the parsed version (a string), or null if it's not valid. grunt-prompt's validate: function looks for true if valid, or a string message if invalid. I changed this to var valid = typeof semver.valid(value) == 'string';

2.) The grunt-bump property to set is bump.options.versionType, from this PR: vojtajina/grunt-bump#83

Missing commas in example

The example in results.md, is missing some commas between properties on the object in the questions array.

Also, I tried to just make a pull request for this, but grunt readme failed to build the template. Here is the error I received:

Warning: An error occurred while processing a template (repos is not defined). Use --force to continue.

Allow choices to be a function

If choices is a function you currently get an error:

Warning: Object function () {...} has no method 'map' Use --force to continue.

Strange behavior for prompts

I had an old version of prompt that I recently updated. After updating, the prompt started acting strangely. It still works as intended but outputs some strangeness to the console.

https://www.dropbox.com/s/a34ks345hy7cspu/2016-02-12%2011_54_58-Trajectory20Client%20-%20%5BF__Dropbox%20%28Personal%29_Dev_Trajectory20Client%5D%20-%20..._gruntf.png?dl=0

It seems to loop through the string re-asking the question one letter at a time until it gets to the end of the string. The value set in the config at the end is always the full string (hence this being more of a cosmetics issue than anything).

The code is dead simple so I assume this is cause by some change made to prompt that I'm just not seeing.

ViewName: {
    options: {
        questions: [
            {
                config: 'ViewFolder', 
                type: 'input', 
                message: 'The folder for your view: js/views/', 
                default: 'default',
                validate: function (value) {
                    return typeof value === "string";
                }, 
                filter: function (value) {
                    return value;
                }
            },{
                config: 'ViewName',
                type: 'input', 
                message: 'The filename of your view: js/views/',
                default: 'default', 
                validate: function (value) {
                    return typeof value === "string";
                },
                filter: function (value) {
                    return value.toString();
                } 
            }
        ]
    }
}

Just need a pointer in the right direction. Thanks.

Check for command arguments

It would be great if this plugin checked for arguments, so that you can answer the prompts without being prompted.

My use case is mainly for continuous integration, where prompts cannot be used.

For example

Without arguments:

$ grunt getMeSomeLunch
What would you like for lunch?
> Sushi
Getting you a sushi for lunch

With arguments

$ grunt getMeSomeLunch --iWant=burrito
Getting you a burrito for lunch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.