-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow passing non interactive options #291
Allow passing non interactive options #291
Comments
Why do you use vue-cli inside of a template? |
I have a project recipe where vue-cli is used to build the frontend, so, I kind of would like to create the vue project in a non-interactive fashion. My project structure:
|
I think that's not the goal of vue-cli. vue-cli is meant to scaffold the whole project. Is there a reason you cannot scaffold the whole project with it? |
Vue Cli would still scaffold. It would just make it possible to do so in a non-interactive way. |
Looking for this especially to build docker images where the templates and dependencies are cached. |
I had a look at this issue and unfortunately 'commander.js' does not support arbitrary/dynamic options. Hence running a command like the one below is not possible (commander.js#609). possible solutions:
If we could agree on the approach, I could give it a shot and submit a PR. |
'yargs' seems like a safe bet. |
I was thinking this myself 🤔 to test my template, I run
if it exists, (or a better damn way of testing my template!) 😂 |
In the meanwhile you can still use old-good #!/usr/bin/env expect
set timeout 360
spawn ./node_modules/.bin/vue init . test-project
# This happens because of
# https://github.com/vuejs/vue-cli/issues/291
expect "Project name" { send "\n" }
expect "Project description" { send "\n" }
expect "Project URL" { send "\n" }
expect "Organization" { send "\n" }
expect "vue-cli · Generated" { send "\n" } |
@sobolevn how would I use this within a Dockerfile? |
@Harti you need to make sure that |
@sobolevn Appreciate your input, it doesn't truly help me though. Dockerfile:
vue-cli-interaction.exp: (note: quotes or not after spawn command did NOT matter)
Output:
There is nothing created and I don't know how to debug this. |
Some vue-init usages spit out ANSI color codes too. I'm not able to get unix's |
making my expect script a bit more patient made it work
|
@jukefr - your execution environment doen't have ANSI colors turned on, does it.. ? |
Actually I do have colours in my output, haven't done anything settings wise to achieve this though. What you can try is simply expect the parts without colours as expect will only loosely wait for a match, simply omit the weird parts. |
Cool. It might be possible to write something with http://pexpect.readthedocs.io in order to wholly deliver the ask of #291. |
Using @vue/cli 3.0+, I think we can put the pitchforks away now:
https://cli.vuejs.org/guide/plugins-and-presets.html#presets |
I saw that v3 has this option, however from what I saw it is 100% incompatible with v2 templates, and nobody has converted their templates yet obviously so this is pretty much useless for me as of yet. |
Nobody will convert their template because there is no template system anymore. On the other hand, the new system is plugin-based and we have a rapidly growing list of community plugins plus all the built-in plugins like pwa or typescript. |
Alright, thank you for taking some time to answer. |
Thanks a lot @jukefr expect works very nicely. |
for anyone interested in this, i have put together some of the proposals here into a single script, that can be run as an NPM script. here is the repository, see the readme setup section for a quick start. 💜 @Joshfindit @italomaia @shailendher @wdmtech @sobolevn @Harti @paul-hammant @jukefr @gabrielstuff |
It would be quite nice if it was possible to pass the prompt responses from the command line. This way, it would be possible to create a new vue project in a non-interactive way, which is quite convenient for templates that use vue-cli as part of it.
The text was updated successfully, but these errors were encountered: