Skip to content

v2.0.0

Compare
Choose a tag to compare
@yyx990803 yyx990803 released this 09 Apr 01:31
· 3531 commits to dev since this release

Note: although there are many changes, vue-cli@2.x is largely compatible with 1.x templates. Special thanks to @zigomir for the contribution.

Changes

  • Use prompts instead of schema for user prompts in meta.json.
  • vue-cli no longer auto-scan template files to look for prompt variables. Now it is required to explicitly list prompts in meta.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 a dist branch, if there is one, it will use the dist 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 in meta.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 for needTests.

    Note that the dot option for minimatch is set to true so glob patterns would also match dotfiles by default.