extism / cli

The extism CLI is used to generate plugin scaffolding and manage Extism installations
BSD 3-Clause "New" or "Revised" License
19 stars 5 forks source link

feat: add plugin scaffold generator #74

Closed nilslice closed 2 months ago

nilslice commented 3 months ago
cd extism
go run . generate plugin -o count_vowels
  Select a PDK language to use for your plugin:  

  > 1. Rust                                      
    2. JavaScript                                
    3. Go                                        
    4. Zig                                       
    5. C#                                        
    6. F#                                        
    7. C                                         
    8. Haskell                                   
    9. AssemblyScript                            

    ↑/k up • ↓/j down • q quit • ? more  

you can also pass -l or -lang with one of the pdk languages listed in pdk-templates.json to choose non-interactively

There is only one template implemented (and template is generous.. there's no interpolation etc, just clone) at https://github.com/extism/rust-pdk-template

(Update, now also JS https://github.com/extism/js-pdk-template, will update more down below in TODO list)

TODO:

nilslice commented 3 months ago

@mhmd-azeez if you wanted to set up similar "templates" for c-sharp and f-sharp (or any other languages!), take a look at the pdk-templates.json for the expected repo URL to host them :)

mhmd-azeez commented 3 months ago

Nice!

zshipko commented 2 months ago

I've set up most of the repos, everything seems to be working - having the templates available like this is super convenient!

@mhmd-azeez C#/F# are the only templates left, would you be able to set those up when you get the chance?

@nilslice the only task left is to fetch the repo list from the network instead of embedding it - did you have plans for that? should we just fetch the file from the repo?

mhmd-azeez commented 2 months ago

@zshipko yes, I have some time this week

nilslice commented 2 months ago

@zshipko ya I was thinking we'd just GET the file at some resolved path in the main branch so it's always up to date when a CLI makes a request.

mhmd-azeez commented 2 months ago

Sweet! F# and C# are now also available

P.S: currently the csproj/fsproj is always called Plugin. Having interpolation is really important for .NET projects, as the assembly name depends on it and people are very particular about project names. But this can be done later on, for now it's a pretty good experience

nilslice commented 2 months ago

@mhmd-azeez

P.S: currently the csproj/fsproj is always called Plugin. Having interpolation is really important for .NET projects, as the assembly name depends on it and people are very particular about project names. But this can be done later on, for now it's a pretty good experience

Is there a note or some call-out in these project README/code somewhere that indicates what needs to be changed, or does this just still work out of the box, and a user will likely know to change whatever they need to in order to fit their own needs?

mhmd-azeez commented 2 months ago

@nilslice it works out of the box and people can easily change it. It just provides a nicer experience as people are most likely going to change it anyway

zshipko commented 2 months ago

Awesome, thanks @mhmd-azeez!

P.S: currently the csproj/fsproj is always called Plugin. Having interpolation is really important for .NET projects, as the assembly name depends on it and people are very particular about project names. But this can be done later on, for now it's a pretty good experience

This is an issue with almost all the repos - next step would probably be to list out what needs to be changed in the READMEs like @nilslice mentioned, or adding some way to do search and replace with a standardized interpolation key for the project name.

nilslice commented 2 months ago

Ok, I can't approve this since I opened it, but it LGTM and I'm fine w/ the embedded fallback.

Thanks for the great work on this!