Giter Club home page Giter Club logo

Comments (3)

aliemir avatar aliemir commented on June 2, 2024 2

Hey @buremba, that's a good idea really, and can inspire for more ideas around that. Unfortunately this is not planned in our roadmap due to limitations on SAO. We use SAO for compiling the templates in the files and moving etc and it does not support such dynamic structure. (I guess it won't be because its archived already by the owner of the project 😅)

Still, I think we can do a workaround here, we already have extend.js for the plugins which allows them to pass conditional values and ignore files conditionally.

We can add some field like files with type Array<{ path: string; filename: string; content: string; encoding: string; }> which can be created dynamically by the answers to the prompts.

Then, we should create those files inside the plugin file (already stored in a temporary directory after cloning). This way we can trick SAO to handle those files like the regular plugin files (compiling and moving to the target).

As the result, we can create files dynamically. 🎉 🎉

While doing so, we might need to check and update our code for handling prompts, for dynamic files we might want to support wider range of prompt types 🤔

Currently, this is not planned but hypothetically it looks like something achievable 😅 If you want to give it a try, We'll be happy to help 🙏

from superplate.

buremba avatar buremba commented on June 2, 2024

Thanks for the quick answer @aliemir! I understand the limitation and I feel like this is not Refine/Superplate's focus and the solution that you suggested makes sense.

What would you think about implementing something more generic such as a post_hook in ArrayPromptOptions? It can be a function with the following signature:

{ choice: Choice; path: string; }

Superplate can call this callback function/hook when the user selects a choice and the template files are generated automatically. That way, the post_hook can generate files or do something else as it's just a function. My assumption is that this is easier to implement and also generic enough to cover different use cases. WDYT?

from superplate.

aliemir avatar aliemir commented on June 2, 2024

Hey @buremba sorry for the late response 🙏 post_hook is a better generic to handle 🚀 I think there's no limitation on the current codebase to conflict with this implementation 🤔 We might need to provide a richer context to post_hook to enable wider range of use cases maybe? (Just thinking out loud 😅)

Thanks again for the issue, I'll definitely try to spare some time for this. This can provide a great flexibility to plugins 💪

from superplate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.