Releases: vuejs/vue-cli
v2.6.0
New
-
In
meta.js
, thedefault
field for a prompt can now be a function which will receive the answers data as the argument, which enables usage like the following:module.exports = { prompts: { library: { type: 'string', required: true, message: 'Library name for browser usage', default (answers) { if (answers.name) { return kebabToCamel(answers.name) } else { return '' } } } } }
v2.5.0
v2.1.0
v2.0.0
Note: although there are many changes, [email protected]
is largely compatible with 1.x templates. Special thanks to @zigomir for the contribution.
Changes
- Use
prompts
instead ofschema
for user prompts inmeta.json
. vue-cli
no longer auto-scan template files to look for prompt variables. Now it is required to explicitly list prompts inmeta.json
.- User prompts now uses Inquirer.js, so
prompts
should follow Inquirer.js' question object format. - For official templates,
vue-cli
will first check if the template has adist
branch, if there is one, it will use thedist
branch by default.
New
-
A prompt can be made conditional by adding a
when
field, which is a JavaScript expression evaluated in the context of existing prompt answer data. Example:{ "prompts": { "lint": { "type": "confirm", "message": "Use a linter?" }, "lintConfig": { "when": "lint", "type": "list", "message": "Pick a lint config", "choices": [ "standard", "airbnb", "none" ] } } }
-
Conditional files by using the
filters
field inmeta.json
.filters
should be an object hash containing file filtering rules. For each entry, the key is a minimatch glob pattern and the value is a JavaScript expression evaluated in the context of prompt answers data. Example:{ "filters": { "test/**/*": "needTests" } }
Files under
test
will only be generated if the user answered yes to the prompt forneedTests
.Note that the
dot
option for minimatch is set totrue
so glob patterns would also match dotfiles by default.