saojs / sao

⚔ Futuristic scaffolding tool
https://sao.vercel.app
MIT License
1.05k stars 61 forks source link

Plans for the next major version (v2.0) #135

Open egoist opened 5 years ago

egoist commented 5 years ago
cannap commented 4 years ago

hi, thanks for sao whats about parsing args? directly witout using third party lib :D

metasean commented 4 years ago

@egoist - Do you have a rough timeline for version 2.0?

madeleineostoja commented 4 years ago

Just chiming in to say that I think the current saofile.js format is more intuitive than the proposed format.

Personally I love Hygen's approach to prompts and copying files. Have a basic mode for just parsing all the files in template with EJS, and then a more advanced mode for fine-tuning the actions.

But that said I think the current format is great 👍

madeleineostoja commented 4 years ago

And the scaffolded project upgrade tool would be amazing

egoist commented 4 years ago

@seaneking loading generators based on folder structure and using inline front matter instead of config file look pretty interesting 👀 maybe we should consider that too.

madeleineostoja commented 4 years ago

I don't think the inline frontmatter would be a good approach for sao, since it really breaks down once you have more than a couple of files. It's great for mini generators for new components/etc like Hygen was designed for, but not for whole projects like sao is designed for. They're complimentary tools/approaches and I use both.

For example I use sao to scaffold out client Gatsby projects, and having to write frontmatter for the 93 files in that template would be really painful.

Using folder structure for generators and the rest is really lovely though. I just think sao should use folder structure within template to dicate output as it currently does. Maybe with override options in an optional sao.config.js or whatever file for more advanced control

madeleineostoja commented 4 years ago

Just rewriting the aforementioned Gatsby generator (coming from Yeoman) and one change I think sao should make for v2 is taking a function for the filter argument to add, passing the answers hash and expecting to return an array of files to exclude. Right now the key:value object is pretty limiting.

egoist commented 4 years ago

@seaneking: passing the answers hash and expecting to return an array of files to exclude.

You can use files to achieve this:

actions() {
  return [
    {
        type: 'add',
        files: ['*', !this.answers.ts && '!tsconfig.json'].filter(Boolean)
    }
  ]
}
madeleineostoja commented 4 years ago

Oh nice. I didn't realise you could pass a function with the generator instance to actions. In that case I think that should be better documented, and maybe the filter and similar methods deprecated, because you can acheive all that more succinctly by returning a function like this.

FWIW sao errored when I tried to access this.answers in actions, I had to pass access it from the generator instance passed in, ie:

actions({ answers }) => [ ... ]
egoist commented 4 years ago

Started the work #145