Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add plugin scaffold generator #74

Merged
merged 11 commits into from
Apr 24, 2024
Merged

feat: add plugin scaffold generator #74

merged 11 commits into from
Apr 24, 2024

Conversation

nilslice
Copy link
Member

@nilslice nilslice commented Apr 2, 2024

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:

  • Fix ctrl-c closing of the menu errors with fatal: repository '' does not exist Error: exit status 128
  • don't //go:embed the pdk-template.json, but rather fetch it via network once we merge it (so its dynamic based on our live repo list, since templates are too)
  • maybe support --tag param to pin the clone to a git tag of any of the template repos
  • Rust PDK Template
  • JS PDK Template
  • Go PDK Template
  • Zig PDK Template
  • C# PDK Template
  • F# PDK Template
  • C PDK Template
  • Haskell PDK Template
  • AssemblyScript PDK Template

@nilslice
Copy link
Member Author

nilslice commented Apr 2, 2024

@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 :)

@@ -2,7 +2,7 @@ module github.com/extism/cli/extism

go 1.20

// replace github.com/extism/cli => ../
replace github.com/extism/cli => ../
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to figure out why I changed this a while back (we shouldn't use the published version in our own module, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can't remember why either, but this would be very helpful! we should uncomment this line for extism-dev too if we decide it's okay to keep it

@mhmd-azeez
Copy link
Contributor

Nice!

@zshipko
Copy link
Contributor

zshipko commented Apr 23, 2024

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
Copy link
Contributor

@zshipko yes, I have some time this week

@nilslice
Copy link
Member Author

@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
Copy link
Contributor

mhmd-azeez commented Apr 24, 2024

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

Copy link
Contributor

@mhmd-azeez mhmd-azeez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@nilslice
Copy link
Member Author

@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?

@zshipko zshipko marked this pull request as ready for review April 24, 2024 18:28
@mhmd-azeez
Copy link
Contributor

@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
Copy link
Contributor

zshipko commented Apr 24, 2024

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
Copy link
Member Author

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!

@zshipko zshipko merged commit 5e617c3 into main Apr 24, 2024
7 checks passed
@zshipko zshipko deleted the templates branch April 24, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants