spago icon indicating copy to clipboard operation
spago copied to clipboard

Convenience command for local package override

Open milesfrain opened this issue 4 years ago • 2 comments

Thinking of adding a command such as spago dev that automates many of the steps listed in https://github.com/purescript/spago#override-a-package-in-the-package-set-with-a-local-one . For example, spago dev simple-json would:

  • Clone simple-json to a local directory, such as ./spago-local
  • Edit overrides in packages.dhall to point to this local copy.

This is inspired by Julia's workflow, which is really nice for lowering the friction of fixing dependencies. They use a global location for all overridden packages (by default, but can be changed), which is convenient if you tend to use the same overrides across projects, but I think a per-project copy would be more appropriate for PS projects.

milesfrain avatar Jan 09 '21 04:01 milesfrain

Clone simple-json to a local directory, such as ./spago-local

Clone from where?

Edit overrides in packages.dhall to point to this local copy.

And eventually, it also should bring back changes it made? What is the full workflow?

wclr avatar Jan 09 '21 14:01 wclr

Clone from where?

From the same location that spago install would clone/copy from.

And eventually, it also should bring back changes it made?

Are you referring to upstreaming local modifications?

What is the full workflow?

For example:

# Initial project creation and development
spago init
spago install simple-json
spago build

# Decide you wish to add a feature to simple-json
spago dev simple-json

# In second terminal
cd .spago-local/simple-json
# Make whatever changes you need. Could optionally build and run tests for that modified package.

# (first terminal) Rebuild with your edits to the local dependency
spago install # seems necessary to pick-up new local changes
spago build

# Once you're satisfied with your local edits, make a commit and push to your local branch.
# Fork repo on github (or other)
# (in second terminal) Add your branch as a remote
git remote add mine [email protected]:my-user-name/simple-json.git
# Upload your changes as a feature branch
git checkout -b new-feature
git commit -am "Added a feature"
git push mine new-feature
# Make the PR

# Once the new feature is upstreamed, you can delete the `simple-json` entry from `packages.dhall`.
# You can either do this manually, or we could add another convenience function, such as:
spago reset simple-json
# Julia uses the `free` command for this purpose

If you create another project where you want to use your customization that still hasn't been merged into upstream yet (or into the package set), you can follow these steps to override https://github.com/purescript/spago/#override-a-package-in-the-package-set-with-a-remote-one. It might also be nice to offer a more convenient shortand to automate those steps, such as:

# Waiting for merge, so use my fork:
spago install github.com:my-user-name/simple-json.git@new-feature

# Merged, but waiting for package set:
spago install simple-json@main

milesfrain avatar Jan 09 '21 19:01 milesfrain