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

Convenience command for local package override #731

Open
milesfrain opened this issue Jan 9, 2021 · 2 comments
Open

Convenience command for local package override #731

milesfrain opened this issue Jan 9, 2021 · 2 comments

Comments

@milesfrain
Copy link
Contributor

milesfrain commented Jan 9, 2021

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.

@wclr
Copy link
Contributor

wclr commented Jan 9, 2021

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?

@milesfrain
Copy link
Contributor Author

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

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

No branches or pull requests

2 participants