FormidableLabs / builder-init

A project generator for builder archetypes.
MIT License
12 stars 2 forks source link

Multiple init folders - select by choice in init.js? #36

Closed flipace closed 7 years ago

flipace commented 8 years ago

I don't know if this is already possible and I missed it.

I'd like to have multiple different init folders like

+ init-react
+ init-reactwithrouter
+ init-somethinelse

and I'd like to allow the user when running builder-init to choose which one to use.

Is this possible already or would this need to be implemented?

ryan-roemer commented 8 years ago

This would need to be implemented. Offhand we could do it with maybe a top-level built-in prompt like destination (see https://github.com/FormidableLabs/builder-init#archetype-data) or a default derived data like eslintrc that could be swapped for a prompt.

So as a strawman, we could have a default provided (automatically):

{
  derived: {
    initTemplatesDir: function (data, cb) { cb(null, "init"); }
  }
}

that you could override like:

// init.js
{
  derived: {
    initTemplatesDir: function (data, cb) { cb(null, "init-somethinelse"); }
  }
}

OR

// init.js
{
  prompts: {
    initTemplatesDir: {
      // Using https://github.com/SBoudrias/Inquirer.js#list---type-list
      type: "list",
      message: "Choose your project type",
      choices: [
        "init-react",
        "init-reactwithrouter",
        "init-somethinelse" 
      ]
    }
  }
}

Does that sound workable? Would you have alternative ideas for how to present the options to the user?

flipace commented 8 years ago

I think the second option sounds rad!

dstevensio commented 7 years ago

👍 for option 2, an elegant implementation of something I have wanted for a specific use-case for a little while.

flipace commented 7 years ago

@shakefon @ryan-roemer i actually went ahead and found a workaround to just do it myself without touching builder-init itself. i think i could port it into the "core" and make a PR! I'll give it a spin.

ryan-roemer commented 7 years ago

Also see https://github.com/FormidableLabs/denim/pull/5 in the underlying denim engine that will soon support filtering arbitrary file paths with an include / exclude function.