quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Preset option in quasar create

Open adrianreutter opened this issue 4 years ago • 10 comments

I want to automate the creation of quasar projects. Therefore a configuration for the starter template over JSON would be very nice. The Vue CLI supports presets and makes it easy to automate the creation.

I know I could create a vue cli project but I want to use the quasar cli. Are there any plans for the future to implement this? Or are there reasons why this isn't implemented yet?

adrianreutter avatar Nov 11 '19 09:11 adrianreutter

For the moment you can create new projects from a template by specifying the source template (https://quasar.dev/quasar-cli/cli-documentation/commands-list#create).

Can you help us and add some more details on what options do you need?

pdanpdan avatar Nov 11 '19 10:11 pdanpdan

Hi,

Yes, presets saving is planned.

rstoenescu avatar Nov 11 '19 10:11 rstoenescu

For the moment you can create new projects from a template by specifying the source template (https://quasar.dev/quasar-cli/cli-documentation/commands-list#create).

Can you help us and add some more details on what options do you need?

Yes thats the way I do it. But when I want to generate a new project programmatically then I get problems because I have to select different options (like SCSS, CSS or STYLUS etc.) with my keyboard.

I want to type quasar create <projectname> --preset <linkToJsonConfiguration> pointing a JSON file which holds the whole configuration.

adrianreutter avatar Nov 12 '19 13:11 adrianreutter

I'm looking for the same thing. I'm creating multiple smaller projects and I'd like to automate quasar create. That way I can create a project without any user interaction, and make some standard changes to the new project as well. For instance the default layout will need to be replaced and some common npm packages can be installed as well. The forced interactive nature of quasar create makes this currently impossible.

Richie765 avatar Aug 05 '20 07:08 Richie765

Ideally permit --preset <JsonFile> OR --preset <JsonValue>

I think this is useful in many contexts e.g. Code samples / blog posts were you just want to say "run this one step" to create a new Quasar project.

tohagan avatar Aug 20 '21 03:08 tohagan

More examples:

  • I use the same eslint settings for all my projects so add a copy of my template eslint rc file.
  • I use chrome to debug, so change quasar conf to use chrome for devServer
  • provide answers to all the questions that quasar create asks, because my name doesn't change, and I alway use eslint, scss, etc.

Creating my own quasar starter template would be usable, but there are cases where I want to use the available templates to create different kinds of quasar apps, but with my customization. I don't want to create a custom copy of every quasar template.

A side note, hopefully, quasar will have a growing repository of starter templates to make it even easier for users to create common types of apps. And/or, there could be a set of post create customization packs, which would reduce the number of starter packs. If you will imagine that the changes that are part of quasar create to use vuex could be extacted to a starter pack add on, and an amplify datastore addon created, and my custom addon pack to add the custom directives I use, or maybe I always use some vue add-ons like vuex-pathify.

I like the idea of having quasar-framework/starter-kits which has all the various kinds of things I would build with quasar (ui-component, app-extension, umd-app, pwa, etc.) And quasar-framework/extensions which includes many standard extensions such as eslint, vuex, vue-router, etc. where an extension always has an install file that can be used by quasar create to do the setup work. For my custom extions, I just need to tell quasar create where to find my extension in addition to the name. This allows any post create steps to be encapsulated in an extension. There are already extensions, some built in such as eslint and vuex and some external such as quasar testing.

I'm sorry, I got a little carried away and probably I just created a new feature request.

julie777 avatar Oct 10 '21 16:10 julie777

I'm working on this feature, do anyone have examples of other frameworks which already implement this pattern?

Aside Vue CLI I'm not finding much around, probably because I'm searching the wrong keywords

IlCallo avatar Aug 10 '22 14:08 IlCallo

Another suggestion ... when you create a project using the current interactive UX, it would be great to always save a create-quasar.json file as part of the new project that can then just be used next time to quickly create another project with the same settings. This makes it quick and easy to discover and configure setting values rather than killing time reading docs.

tohagan avatar Aug 11 '22 05:08 tohagan

After a bit of reading and asking around, I've come to the conclusion that adding a preset system in Quasar CLI may not be a good idea

If added, CLI prompts would become part of our public API and as such we would need to manage versioning and avoid breaking changes, limiting what we can do without bumping a major version Both Svelte and Vue guys shared the same opinion on the topic, so I'm pretty sure it's the correct one Angular and React too don't have any preset system in place and don't seem interested into adding one

What IS a good idea is adding a --default option which automatically accept the default value for all prompts It COULD be a good idea to add a couple of shortcut options too, eg --vite/--webpack/--pinia/--ts/etc, but I haven't made a list of the most used ones

An better idea would be to expose a create method from Quasar CLI when imported into code able to manage presets, but the effort to do this is unknown

Meanwhile, I created a simple helper which can be used with any create-xxx package, using this moves the responsability of checking changing prompts on the dev automating the generation, instead of Quasar team

Check it out: https://gist.github.com/IlCallo/288ccdc2cac782854bb4d78783389fd5

IlCallo avatar Aug 11 '22 18:08 IlCallo

Here's the script as an installable package: https://github.com/dreamonkey/cli-ghostwriter

IlCallo avatar Aug 12 '22 13:08 IlCallo