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(cli): project template scaffold cli command #533

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

muhammad-asghar-ali
Copy link

@muhammad-asghar-ali muhammad-asghar-ali commented Jan 20, 2025

Description:

  1. Resonate command to create the template setup project for user on local.
  2. Supported SDK is python.
  3. Example command
    - resonate project create --name my-app --template py
    - resonate project create -n my-app -t py
  4. Template list command
    - resonate project list

@muhammad-asghar-ali muhammad-asghar-ali changed the title feat: project template scaffold cli command feat(cli): project template scaffold cli command Jan 20, 2025
cmd/create/create.go Outdated Show resolved Hide resolved
cmd/create/scaffold.go Outdated Show resolved Hide resolved
cmd/create/scaffold.go Outdated Show resolved Hide resolved
cmd/create/scaffold.go Outdated Show resolved Hide resolved
@dfarr
Copy link
Member

dfarr commented Jan 23, 2025

Wow I am shocked that go doesn't have a higher level library function for unzipping a file. I am super impressed with this, that was way more work than it should have been!

I think we need to namespace these commands under something, I am thinking "templates", what do you think?

resonate templates create ...
resonate templates list ...

We have been discussing this feature on our team, and we feel there should be a discovery mechanism so that we can add more templates as we go without having to release a new version of the sdk. We came up with the following strategy:

  1. make an http request to get a known json file in known repo (I have set up resonatehq/templates for this purpose, you can download the raw json file here)
  2. add a new command resonate templates list to list all templates with descriptions
  3. create stays more or less the same

What do you think?

@muhammad-asghar-ali
Copy link
Author

Wow I am shocked that go doesn't have a higher level library function for unzipping a file. I am super impressed with this, that was way more work than it should have been!

I think we need to namespace these commands under something, I am thinking "templates", what do you think?

resonate templates create ...
resonate templates list ...

We have been discussing this feature on our team, and we feel there should be a discovery mechanism so that we can add more templates as we go without having to release a new version of the sdk. We came up with the following strategy:

  1. make an http request to get a known json file in known repo (I have set up resonatehq/templates for this purpose, you can download the raw json file here)
  2. add a new command resonate templates list to list all templates with descriptions
  3. create stays more or less the same

What do you think?

Thank you @dfarr, awesome feels super interesting and I'm more understand this proposal and come up with some raw diagram. And I understand what we want but give me some time to make a proper flow and then start implementation it. And regarding to higher level library function for unzip, so i read some stackoverflow and there mostly implement the unzip function by self but I can also double check the unzip function which makes the code easy to understand.

@muhammad-asghar-ali
Copy link
Author

muhammad-asghar-ali commented Jan 27, 2025

Hey @dfarr, after understanding your idea, I think the existing create command resonate create --name my-python-app --sdk python will replace with the resonate templates create --name template_name --sdk sdk_name and the list command will work to show the supported templates in supported sdks. e.g.

command: resonate templates list

Template Name SDK Name
simple_setup py
simple_setup ts
gateway_app py

Any suggestions or improvements?

@dfarr
Copy link
Member

dfarr commented Jan 28, 2025

Looks good! I don't even think we need a name, we could just have a single name which can be the key in the map here we could print it with the descriptions (the desc key). I thought the name could be the local folder we copy the codebase to?

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 0% with 238 lines in your changes missing coverage. Please review.

Project coverage is 55.15%. Comparing base (1735b6c) to head (876d233).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/templates/scaffold.go 0.00% 120 Missing ⚠️
cmd/templates/create.go 0.00% 55 Missing ⚠️
cmd/templates/templates.go 0.00% 46 Missing ⚠️
cmd/templates/list.go 0.00% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #533      +/-   ##
==========================================
- Coverage   56.00%   55.15%   -0.86%     
==========================================
  Files         129      133       +4     
  Lines       13928    14166     +238     
==========================================
+ Hits         7801     7813      +12     
- Misses       5663     5891     +228     
+ Partials      464      462       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@muhammad-asghar-ali
Copy link
Author

Looks good! I don't even think we need a name, we could just have a single name which can be the key in the map here we could print it with the descriptions (the desc key). I thought the name could be the local folder we copy the codebase to?

Yes @dfarr you are right, so the idea is if the user want to create the basic scaffold-py project with the local dir name (folder) e.g. my-app and add the sdk py. So what we are doing is download and unzip the the project and the restructure the folder structure to map to the given name my-app

Here are some future thinking.

  1. How to handle multiple templated for one sdk

One possible way is to replace the --sdk with some other flag which represent the template nature.

@dfarr
Copy link
Member

dfarr commented Jan 29, 2025

Exactly! Let's just decouple the idea of an sdk from a template - a template can be anything, any language, pattern, etc (that's where the description can help us, and that is specified in the templates repo) so all the user has to do is specify the key that corresponds to the template.

@muhammad-asghar-ali
Copy link
Author

so all the user has to do is specify the key that corresponds to the template.

Awesome, great idea some the template can be anything which is listed in the json file as key along corresponding href. Will work on it

Copy link
Member

@dfarr dfarr left a comment

Choose a reason for hiding this comment

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

This looks so great! My comments at this point are more about just crossing our t's and dotting our i's, otherwise I think we have it!!!

cmd/templates/list.go Outdated Show resolved Hide resolved
cmd/templates/list.go Outdated Show resolved Hide resolved
cmd/templates/create.go Outdated Show resolved Hide resolved
cmd/templates/create.go Outdated Show resolved Hide resolved
cmd/templates/create.go Outdated Show resolved Hide resolved
cmd/templates/scaffold.go Outdated Show resolved Hide resolved
cmd/templates/create.go Outdated Show resolved Hide resolved
cmd/templates/list.go Outdated Show resolved Hide resolved
cmd/templates/create.go Outdated Show resolved Hide resolved
Copy link
Contributor

@flossypurse flossypurse left a comment

Choose a reason for hiding this comment

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

Suggesting adding "Application Node" to the descriptions so it is clear what project type and template is getting created just for explicit clarity - someone might think they are creating a server project perhaps?

cmd/templates/templates.go Outdated Show resolved Hide resolved
cmd/templates/list.go Outdated Show resolved Hide resolved
cmd/templates/create.go Outdated Show resolved Hide resolved
@flossypurse
Copy link
Contributor

@muhammad-asghar-ali this is so awesome!

If you have bandwidth, would you be willing to post a screen capture of this functionality for us to review?

Overall, this is looking fantastic - connecting with @dfarr about getting this in!

@flossypurse
Copy link
Contributor

@muhammad-asghar-ali - I actually just tried this out by pulling your fork.
Awesome work!

My main suggestion would be switch the top-level command from template to project

This is the command I used:

resonate template create --name test-app --template py

I think it would make more sense if it was:

resonate project create --name test-app --template py

For a moment I was confused about whether I was creating a new template for the cli or a new resonate project.

@muhammad-asghar-ali
Copy link
Author

@muhammad-asghar-ali this is so awesome!

If you have bandwidth, would you be willing to post a screen capture of this functionality for us to review?

Overall, this is looking fantastic - connecting with @dfarr about getting this in!

I’ll capture a screen recording of the functionality and share it with you asap.

@muhammad-asghar-ali
Copy link
Author

@muhammad-asghar-ali - I actually just tried this out by pulling your fork. Awesome work!

My main suggestion would be switch the top-level command from template to project

This is the command I used:

resonate template create --name test-app --template py

I think it would make more sense if it was:

resonate project create --name test-app --template py

For a moment I was confused about whether I was creating a new template for the cli or a new resonate project.

Awesome, I think It is good suggestion to add and replace the top-level command from template to project and I'll replace this asap and then share the screen recording of the functionality.

@flossypurse flossypurse linked an issue Feb 6, 2025 that may be closed by this pull request
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.

Project template scaffold CLI
3 participants