paritytech / substrate-up

Scripts for working with new Substrate projects
Apache License 2.0
67 stars 21 forks source link

Make everything use `substrate-package` #39

Closed shawntabrizi closed 3 years ago

shawntabrizi commented 4 years ago

Here is a proposed change to all the scripts, hopefully making them less magic, and depending more on Git.

Open questions:

CC @xlc

JoshOrndorff commented 4 years ago

I really like that more of the work is pushed back to git and I really like that the git history is kept in tact. These are both positive changes.

I miss the ability to specify the name of the module when using substrate-module-new but it sounds like you're addressing that by having a script in the module template that will allow me to give the new module a meaningful name, right? If so I'm comfortable with that :+1:

The biggest outstanding question/concern I have is how the substrate-package branches will be managed in each template repository. Cloning from a simple branch called substrate-package which move as new features are included in the package is quite dangerous. Consider this scenario

  1. Alice starts a new project and uses substrate-node-new, substrate-module-new, and substrate-ui-new to get started. They all pull from known-compatible branches.
  2. Alice codes happily on her new project for several weeks during which time new Substrate features have become stable and included in the substrate-package branches of several of these templates.
  3. Alice realizes she needs another module in her runtime, so she runs the exact same substrate-module-new command as before but now gets a different module template; potentially one that isn't even compatible with the node template she has been working on.

I think a nicer solution would be to have each script have an option parameter for a git reference (branch, tag, commit, etc) to clone from. If a user omits that flag then the default behavior is to clone from the substrate-package branch just as it does now. The script should also tell the user what reference they can use in the future to get the exact same version of the template they just got.

So in the above scenario Alice would run substrate-module-new first-module the first time and see text like, "Creating a new module template from tag package-02-Sept-2019. Then in step three she would run substrate-module-new second-module package-02-Sept-2019 to ensure she gets the same exact template she got the first time.

shawntabrizi commented 4 years ago

@JoshOrndorff A fair concern.

Adding a git commit makes sense to me as a second (optional) parameter.

Two things I do want to note:

I think we should look into the renaming thing next, but as the PR points out, this can be handled on the individual repository level, which again is nice to separate from these scripts because it may be updated in the future.

xlc commented 4 years ago

I think we should still keep some handholding messages such as how to push the repo to a new git repo and detect if yarn is installed. It should also rename remote from origin to upstream, checkout new master branch and ensure it is not tracking upstream master. You don't want people accidentally trying to push template repo. not that it will success, but still can be confusing. I still find the rename functionality useful. It makes the generated project more personalised, not just a generic template project.

shawntabrizi commented 4 years ago

@xlc I find the rename thing the absolute worst part of the script. If someone really feels "special" that the project is renamed, they can do it themselves.

Having generic find/replace things in a script is totally set up to fail at some point in some way we wont expect.

I agree about the upstream thing, what is the best way to do that?

How about we just get rid of these scripts all together?

riusricardo commented 4 years ago

I think that this scripts are a great way to start developing on Substrate. I also see that maintenance will get more complex every time we add more scripts. What will happen if we deprecate a script? We'll need to find the best way to delete it because we are not using a package manager.

I think that it will be better if the scripts become one single tool like NVM instead of installing many scripts and loosing control of what the user has installed. It will be more complex to create a NVM equivalent but it will give us more control and we can handle versioning in a better way.

shawntabrizi commented 4 years ago

There is not much difference in updating or deleting a script.

Users who have installed the script on their machine will not get updates to the script unless they manually reinstall the script on their machine.

This is the fundamental problem with any of these scripts is that they do not scale well over time when we want to tweak the behavior.

This is why I am a fan of either: