tmattio / spin

OCaml project generator.
ISC License
297 stars 15 forks source link

Support specifying the files that are actual templates and just copy the rest of the files mode? #90

Closed fakenickels closed 3 years ago

fakenickels commented 3 years ago

First of all, thanks for the awesome piece of software πŸ™.


As far as I tested it spin seems to try to map over all the files in the project. If you are trying to spin up a relatively more complex or big project it takes some time to just load the files and then after the set up prompts and fails due to some different named files, for instance asset names within a iOS project or Android like it was in my case (I'm trying to use it to spin up a React Native project based on a internal company template).

Is there a way to point out in the config file which files are actually holding the interpolation tags and tell spin to just copy the rest of the files?

tmattio commented 3 years ago

Hey @fakenickels πŸ™‚

There's no way to do this at the moment, but I think that's a great idea! Something like a raw_files stanza in the spin template config that will instruct the generator engine to just copy the files, without processing them.

A PR for this would be very much welcomed if you want, otherwise, I'll look into it πŸ‘

tmattio commented 3 years ago

Although, to be sure I understand the issue:

Is the issue that the generation fails after the prompt, or is it that the generation takes too much time?

Also, could you copy the error that you're encountering here? I'm not sure why Spin would fail because of the filenames.

fakenickels commented 3 years ago

Hey! Sorry, I just tried again and I realized I misread the error. The actual error is something else

? Project name NewApp
? Project slug used in package.json [newapp]
? Project bundle id (eg astroapp.company) astroapp.newapp
? Project Astro's product id 20

πŸ—οΈ  Creating a new project from spin-rescript in packages/newapp
spin: [ERROR] The template generation failed:
Error while running the template engine on content of "packages/newapp/android/app/src/main/assets/fonts/Montserrat-BoldItalic.ttf".
fakenickels commented 3 years ago

Looks like it fails while trying to apply the template in a font file. But I also got the same error with some images. Looks like it happens with binary files

tmattio commented 3 years ago

Thanks for the details!

So yeah, I think what you were suggesting is a good solution here: let's have a stanza that instructs spin to not parse a list of files. In addition to that, it would probably make sense to have a list of extensions to not parse by default (everything binary)

fakenickels commented 3 years ago

That would be amazing! For now I'll try to use the ignore stanza and then add a post command to copy over the ignored files to the new destination.

If you want I can go ahead and submit a PR to include the new "raw_files" stanza!

tmattio commented 3 years ago

I'm not sure the post commands can access the template files, so that might not be possible.

If you want I can go ahead and submit a PR to include the new "raw_files" stanza!

Sure, a PR for this, if you have time to look into it, would be very appreciated πŸ™‚

tmattio commented 3 years ago

Hey @fakenickels! I went ahead and implemented it. Let me know if you have any other issue πŸ™‚

fakenickels commented 3 years ago

Wow! Thanks a lot ☺️