hay-kot / scaffold

A cookie cutter alternative with in-project scaffolding for generating components, controllers, or other common code patterns.
https://hay-kot.github.io/scaffold/
MIT License
51 stars 5 forks source link

feat: support FS injection into the scaffold config #165

Closed thomaschow closed 3 months ago

thomaschow commented 3 months ago

Description

This feature allows users to supply their own FS as part of the CLI configuration. This makes it easy for programmatic use of the scaffold generation tool.

scaffoldFS is of course not exposed as a CLI argument. It takes precedence over scaffoldDir, but since it cannot be populated via CLI we should be OK.

Open to suggestions on the implementation here, please review when you can!

thomaschow commented 3 months ago

@hay-kot please take a look

hay-kot commented 3 months ago

Can you explain a little bit more on the problem you're trying to solve here? An example or two would be really helpful.

Couldn't you just pass an absolute path to new and then it would accomplish the same thing without these changes? e.g. scaffold new /path/to/some/scaffold/ ?

thomaschow commented 3 months ago

Can you explain a little bit more on the problem you're trying to solve here? An example or two would be really helpful.

@hay-kot so I'm actually wrapping this with a more opinionated CLI that will generate scaffolding based on a project structure I've embedded as part of the CLI binary itself, using the standard embed library. In this scenario, I'm not shelling out at all and I'd like to just be able to pass the FS handle to the underlying scaffolding code. The scaffolding templates do not exist on the local filesystem, they are part of the binary.

hay-kot commented 3 months ago

Ahh, I see. It sounds like from your comment https://github.com/hay-kot/scaffold/issues/48 you're actually using the controller directly which I don't support right now. I don't intend to guarantee any APIs there and will likely refactor them a few more times as I restructure this repository and clean things up.

Given that, I'm going to close this PR. I think if you're wanting to consume the controller directly and need modifications to support that you'll have to maintain a fork. Alternatively, you may be able to just dump your embedded contents to a temporary location on the file system and pass that to the controller and use it without modification. Like I said though, you may experience breakages with updates.