SamKirkland / plop-templates

VSCode extension for plop.js file templates
MIT License
23 stars 5 forks source link

Integrate into VSCode UI #11

Closed dantman closed 3 years ago

dantman commented 3 years ago

Right now after selecting what generator to use plop-templates leaves the vscode UI and just opens up a terminal to use. It is nice that the templates use a cli tool that anyone can use (not exclusive to vscode users with a specific extension). But leaving the vscode UI and going into the terminal beaks the flow of file creation a bit to much to use for regular file creation.

Would you be interested in using node-plop to integrate plop into the extension and handle the prompts using showInputBox/showQuickPick/showInformationMessage for the generators only using the limited set of inquirer prompt types that can be mapped to vscode inputs?

SamKirkland commented 3 years ago

Hey Dan,

I actually started implementing the extension that way to begin with. Before long I realized I was re-implementing a large portion of plops logic in vscode. Also at the time I wasn't able to find a vscode equivalent for each inquirer method.

In the end I decided I was heading down the wrong path. I decided to stay focused and solved the main issues I had with plop. Low discoverability and setting a destination path.

I'm going to close this issue. But feel free to leave another comment if you disagree or want to discuss more!

dantman commented 3 years ago

Also at the time I wasn't able to find a vscode equivalent for each inquirer method.

I'm fine with it falling back to cli if a generator's prompts are too complex to handle in the vscode UI. However IMHO for 90%+ of the generator prompts that I can think of using I can't think of any Inquirer type I'd actually use that couldn't be represented using one of the vscode prompts.

setting a destination path.

I actually have the opposite issue. I got interested in file template creation because I need to jump around in the vscode view creating files sometimes. e.g. I'm working on a route and realize I need to jump to the form/partials folder and create a new partial. Because the project is large this results in a lot of scrolling in the file explorer to find the right folder to create a new file in. I realized that this is a specific class of file with a known filename pattern, a defined destination, and some common boilerplate and would work great with a prompt based template creation where I can be prompted for the name and have it automatically created where I expect. So I'd actually like to fix the broken New File from Template palette command and double check that the extension doesn't break if destinationpath is not used in the prompts.

want to discuss more

I can think of a good feature requests that would be difficult to do without using node-plop. I expect most users would prefer it if the files they just created using the generator would open in vscode so they can start editing them. I can't think of any way to get that info from the cli, but I expect node-plop probably exposes that info.