Problem:
When testing templates, it's a frequent cause of headaches when testing.
Currently in the template test.sh scripts, they use the yes command piped to the vue init, which doesn't work.
Solution
To workaround this, we could add a --force flag that will send a new line character to each inquirer prompt.
We could use the mock-stdin package for sending the input to the prompt.
There is a PR coming shortly, fully tested with the Vue Webpack template using both the --force and the -f flag.
Imho we should rather provide a way to skip the inquirer prompt completely and load some predefined answers from some .json file or something. Kind of what I implemented in https://github.com/vuejs-templates/webpack/pull/1218
The new version in next branch supports that:
$ vue create --help
Usage: create [options] <app-name>
create a new project powered by vue-cli-service
Options:
-p, --preset <presetName> Skip prompts and use saved preset
-d, --default Skip prompts and use default preset
-i, --inlinePreset <json> Skip prompts and use inline JSON string as preset
-r, --registry <url> Use specified NPM registry when installing dependencies
-m, --packageManager <command> Use specified NPM client when installing dependencies
-f, --force Overwrite target directory if it exists
-h, --help output usage information
@yyx990803 or @LinusBorg But i can't use vue create template-url ? So what i'm going to do if i need to init template from repo and skip prompts?
The old 2.x functionality can be re-added with a plugin:
https://cli.vuejs.org/guide/creating-a-project.html#using-the-gui
We won't add any new features to it, though.
Most helpful comment
@yyx990803 or @LinusBorg But i can't use vue create template-url ? So what i'm going to do if i need to init template from repo and skip prompts?