ignite icon indicating copy to clipboard operation
ignite copied to clipboard

Generate a component in specific path/subfolder

Open scinfu opened this issue 3 years ago • 6 comments

how can i generate a component or other with generate in a specific folder? My project is split into several sub folders and is not flat like the boilerplate. I tried ignite generate component path1/path2/Name but do not work

Thank you

scinfu avatar Jul 27 '21 07:07 scinfu

I want the same thing! can this be supported?

cengit avatar Sep 01 '21 03:09 cengit

I believe that isn't possible at the moment, but would be a great pull request 😄

ibrahimelaradi avatar Oct 01 '21 15:10 ibrahimelaradi

Yeah, this is a great idea.

jamonholmgren avatar Oct 22 '21 18:10 jamonholmgren

This is how we could approach it.

Here, we need to have an option to pass through the specified path (will need to add a field to GeneratorOptions too):

https://github.com/infinitered/ignite/blob/ef5810aac792794ee9102e4e563862145d098ea0/src/tools/generators.ts#L116-L117

We would need to pass that through here:

https://github.com/infinitered/ignite/blob/ef5810aac792794ee9102e4e563862145d098ea0/src/commands/generate.ts#L78-L81

And of course we need to be able to pass that through. That would happen somewhere around here:

https://github.com/infinitered/ignite/blob/ef5810aac792794ee9102e4e563862145d098ea0/src/commands/generate.ts#L58-L74

Various ideas:

npx ignite-cli generate component MyButton --folder=app/buttons

You'd pull this from parameters.options.folder (or maybe dest or path?)

We could also just use the third parameter.

npx ignite-cli generate component MyButton app/buttons

This would be parameters.third.

Thoughts?

jamonholmgren avatar Oct 22 '21 18:10 jamonholmgren

Another good option would be to support frontmatter to our template files. We already have a PR in-flight for this.

https://github.com/infinitered/ignite/pull/1630

jamonholmgren avatar Oct 22 '21 19:10 jamonholmgren

This is how we could approach it.

Here, we need to have an option to pass through the specified path (will need to add a field to GeneratorOptions too):

https://github.com/infinitered/ignite/blob/ef5810aac792794ee9102e4e563862145d098ea0/src/tools/generators.ts#L116-L117

We would need to pass that through here:

https://github.com/infinitered/ignite/blob/ef5810aac792794ee9102e4e563862145d098ea0/src/commands/generate.ts#L78-L81

And of course we need to be able to pass that through. That would happen somewhere around here:

https://github.com/infinitered/ignite/blob/ef5810aac792794ee9102e4e563862145d098ea0/src/commands/generate.ts#L58-L74

Various ideas:

npx ignite-cli generate component MyButton --folder=app/buttons

You'd pull this from parameters.options.folder (or maybe dest or path?)

We could also just use the third parameter.

npx ignite-cli generate component MyButton app/buttons

This would be parameters.third.

Thoughts?

Wouldn't it be better to try and infer the path from one argument instead of several (for convenience) That way before we generate the template, we check the name and resolve the component name, and the folder it should be generated in, ofcourse if there are no / characters in the name the script will work the same way as before, I'm not sure if this solution can be integrated with what we already have now though 😅

ibrahimelaradi avatar Nov 21 '21 07:11 ibrahimelaradi

:tada: This issue has been resolved in version 8.6.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

infinitered-circleci avatar Mar 29 '23 02:03 infinitered-circleci