Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c50cdd1
Enable user to specify a tag when initializing project
JordanMartinez Aug 14, 2020
596d98a
Add --tag option to `upgrade-set` command
JordanMartinez Aug 14, 2020
4a5d703
Update changelog: add --tag as new feature
JordanMartinez Aug 16, 2020
a2f1505
Refactor: `Text.Text` -> `Text`
JordanMartinez Aug 16, 2020
c643adc
Remove -t short-hand flag for --tag
JordanMartinez Aug 16, 2020
c65a34e
Refactor code: rename two functions
JordanMartinez Aug 16, 2020
0aa3afd
Refactor: `Text.Text` -> `Text`
JordanMartinez Aug 16, 2020
c8a80d7
Figure out the necessary path to produce correct error message
JordanMartinez Aug 19, 2020
cd28f08
Improve error message
JordanMartinez Aug 19, 2020
cd9d385
Further clean up error messages
JordanMartinez Aug 19, 2020
485129a
Only notify user that package set doesn't exist if get 404
JordanMartinez Aug 19, 2020
201f772
Stop exporting useSpecificReleaes and useLatestRelease
JordanMartinez Aug 19, 2020
27bba90
Unify upgradingPackageSet and changingTo... messages into one message
JordanMartinez Aug 19, 2020
f3f0c15
Prepare `updateTags` unification; remove `writeRawExprPostVerify`
JordanMartinez Aug 19, 2020
2b389a7
Move useLatestRelease to where clause in updatePackageSetVersion
JordanMartinez Aug 19, 2020
b8e160e
Inline common code into updatePackageSetVersion
JordanMartinez Aug 19, 2020
8765fd3
Remove 'revert' phrase and provide clearer message when set not exist
JordanMartinez Aug 19, 2020
14ee82f
Rename `mbTag` to `maybeTag`
JordanMartinez Aug 23, 2020
4207ade
Change header to 'breaking changes' and update note
JordanMartinez Aug 23, 2020
c3f806b
Implement tests for `--tag` parameter
JordanMartinez Aug 24, 2020
0cae4f9
Update readme to document --tag argument
JordanMartinez Aug 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

Breaking changes (😱!!!):
- **Specify the package set version via `--tag` (#680)**

Example usage: `spago init --tag psc-0.13.2-20190725` and `spago upgrade-set --tag psc-0.13.2-20190725`. This is a breaking change because we are removing support for the old spacchetti/spacchetti-style location (i.e. in the src/packages.dhall) for the upgrade-set command.

## [0.16.0] - 2020-08-14

Breaking changes (😱!!!):
Expand Down
54 changes: 47 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ you'll have to carefully:
- try to run `spago install some-package` for packages in the set
- [add the missing packages](#add-a-package-to-the-package-set) if not in the set


### See what commands and flags are supported

For an overview of the available commands, run:
Expand All @@ -252,6 +251,14 @@ $ spago build --help
This will give a detailed view of the command, and list any command-specific
(vs global) flags.

### Setup a new project using a specific package set

Since `spago init` does not necessarily use the latest package set. Fortunately, you can specify which package set to use via the `--tag` argument. See the [`purescript/package-sets` repo's releases](https://github.com/purescript/package-sets/releases) for tags you can use:

```bash
$ spago init --tag "psc-0.13.8-20200822"
```


### Install a direct dependency

Expand Down Expand Up @@ -557,23 +564,47 @@ if you could pull request it to the [Upstream package-set][package-sets] ❤️
If you decide so, you can read up on how to do it [here][package-sets-contributing].


### Automagically upgrade the package set
### Upgrade the package set...

The version of the package-set you depend on is fixed in the `packages.dhall` file
(look for the `upstream` var).

You can upgrade to the latest version of the package-set with the `upgrade-set`
command, that will automatically find out the latest version, download it, and write
command. It will download the package set and write
the new url and hashes in the `packages.dhall` file for you.

Spago can update the package set to the latest release or to a specific release automagically. If you wish to use a specific commit, you will have to manually edit one part of your `packages.dhall` file. Each is covered below.

#### ...to the latest release automatically

Running it would look something like this:

```bash
$ spago upgrade-set
Found the most recent tag for "purescript/package-sets": "psc-0.12.3-20190227"
Package-set upgraded to latest tag "psc-0.12.3-20190227"
$ spago upgrade-set
[info] Updating package-set tag to "psc-0.13.8-20200822"
Fetching the new one and generating hashes.. (this might take some time)
[info] Generating new hashes for the package set file so it will be cached.. (this might take some time)
```

#### ...to a specific release automatically

If the package set exists, running `upgrade-set` would look something like this:

```bash
$ spago upgrade-set --tag "psc-0.13.8-20200822"
[info] Updating package-set tag to "psc-0.13.8-20200822"
Fetching the new one and generating hashes.. (this might take some time)
Done. Updating the local package-set file..
[info] Generating new hashes for the package set file so it will be cached.. (this might take some time)
```

If the package set does not exist, your `packages.dhall` file will not be touched and you will see a warning:

```bash
spago upgrade-set --tag "whoops-i-made-a-big-typo"
[info] Updating package-set tag to "whoops-i-made-a-big-typo"
Fetching the new one and generating hashes.. (this might take some time)
[warn] Package-set tag "whoops-i-made-a-big-typo" in the repo "purescript/package-sets" does not exist.
Will ignore user-specified tag and continue using current tag: "psc-0.13.4-20191025"
```

If you wish to detach from tags for your package-set, you can of course point it to a
Expand All @@ -584,6 +615,15 @@ let upstream =
https://raw.githubusercontent.com/purescript/package-sets/bd72269fec59950404a380a46e293bde34b4618f/src/packages.dhall
```

#### ... to a specific tag manually

If you wish to detach from tags for your package-set, you can of course point it to a
specific commit. Just set your `upstream` to look something like this:

```haskell
let upstream =
https://raw.githubusercontent.com/purescript/package-sets/bd72269fec59950404a380a46e293bde34b4618f/src/packages.dhall
```

### Monorepo

Expand Down
10 changes: 5 additions & 5 deletions app/Spago.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ main = withUtf8 $ do
-> handleDefault shouldShowVersion

-- ### Commands that need only a basic global env
Init force noComments
-> void $ Spago.Packages.initProject force noComments
PackageSetUpgrade
-> Spago.PackageSet.upgradePackageSet
Freeze
Init force noComments tag
-> void $ Spago.Packages.initProject force noComments tag
PackageSetUpgrade tag
-> Spago.PackageSet.updatePackageSetVersion tag
Freeze
-> Spago.PackageSet.freeze Spago.PackageSet.packagesPath
Login
-> Spago.GitHub.login
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ library:
- fsnotify
- github
- Glob
- http-types
- http-client
- http-conduit
- lens-family-core
Expand Down
6 changes: 3 additions & 3 deletions src/Spago/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ repl newPackages sourcePaths pursArgs depsOnly = do
Temp.withTempDirectory cacheDir "spago-repl-tmp" $ \dir -> do
Turtle.cd (Turtle.decodeString dir)

config@Config{ packageSet = PackageSet{..}, ..}
<- Packages.initProject NoForce Dhall.WithComments
config@Config{ packageSet = PackageSet{..}, ..}
<- Packages.initProject NoForce Dhall.WithComments Nothing

let newConfig :: Config
newConfig = config { Config.dependencies = dependencies <> newPackages }
Run.withInstallEnv' (Just newConfig) (replAction purs)
Expand Down
9 changes: 5 additions & 4 deletions src/Spago/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data Command
= Default ShowVersion

-- | Initialize a new project
| Init Force TemplateComments
| Init Force TemplateComments (Maybe Text)

-- | Install (download) dependencies defined in spago.dhall
| Install [PackageName]
Expand All @@ -47,7 +47,7 @@ data Command
| Login

-- | Upgrade the package-set to the latest release
| PackageSetUpgrade
| PackageSetUpgrade (Maybe Text)

-- | Freeze the package-set so it will be cached
| Freeze
Expand Down Expand Up @@ -148,6 +148,7 @@ parser = do
usePsa = bool UsePsa NoPsa <$> CLI.switch "no-psa" 'P' "Don't build with `psa`, but use `purs`"
openDocs = bool NoOpenDocs DoOpenDocs <$> CLI.switch "open" 'o' "Open generated documentation in browser (for HTML format only)"
noComments = bool WithComments NoComments <$> CLI.switch "no-comments" 'C' "Generate package.dhall and spago.dhall files without tutorial comments"
tag = CLI.optional $ Opts.strOption (Opts.long "tag" <> Opts.help "Optional package set tag to be used instead of the latest one.")
configPath = CLI.optional $ CLI.optText "config" 'x' "Optional config path to be used instead of the default spago.dhall"
chkModsUniq = bool DoCheckModulesUnique NoCheckModulesUnique <$> CLI.switch "no-check-modules-unique" 'M' "Skip checking whether modules names are unique across all packages."
transitive = bool NoIncludeTransitive IncludeTransitive <$> CLI.switch "transitive" 't' "Include transitive dependencies"
Expand Down Expand Up @@ -180,7 +181,7 @@ parser = do
initProject =
( "init"
, "Initialize a new sample project, or migrate a psc-package one"
, Init <$> force <*> noComments
, Init <$> force <*> noComments <*> tag
)

build =
Expand Down Expand Up @@ -283,7 +284,7 @@ parser = do
upgradeSet =
( "upgrade-set"
, "Upgrade the upstream in packages.dhall to the latest package-sets release"
, pure PackageSetUpgrade
, PackageSetUpgrade <$> tag
)

freeze =
Expand Down
4 changes: 3 additions & 1 deletion src/Spago/Dhall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ readRawExpr pathText = do

writeRawExpr :: Text -> (Dhall.Header, DhallExpr Dhall.Import) -> IO ()
writeRawExpr pathText (header, expr) = do
-- Verify that the package set exists
-- If Dhall gets a 404, it will throw a PrettyHttpException
resolvedExpr <- Dhall.Import.load expr
-- After modifying the expression, we have to check if it still typechecks
-- if it doesn't we don't write to file.
resolvedExpr <- Dhall.Import.load expr
_ <- throws (Dhall.TypeCheck.typeOf resolvedExpr)
writeTextFile pathText $ prettyWithHeader header expr
format pathText
Expand Down
12 changes: 9 additions & 3 deletions src/Spago/Messages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,18 @@ failedToAddDeps pkgs = makeMessage $
<> map ("- " <>) (NonEmpty.toList pkgs)
<> [""]

upgradingPackageSet :: Text -> Text
upgradingPackageSet newTag = makeMessage
[ "Package-set upgraded to latest tag " <> surroundQuote newTag
updatingPackageSet :: Text -> Text
updatingPackageSet newTag = makeMessage
[ "Updating package-set tag to " <> surroundQuote newTag
, "Fetching the new one and generating hashes.. (this might take some time)"
]

nonExistentPackageSet :: Text -> Text -> Text -> Text -> Text
nonExistentPackageSet org repo oldTag newTag = makeMessage
[ "Package-set tag " <> surroundQuote newTag <> " in the repo " <> surroundQuote (org <> "/" <> repo) <> " does not exist."
, "Will ignore user-specified tag and continue using current tag: " <> surroundQuote oldTag
]

freezePackageSet :: Text
freezePackageSet = makeMessage
[ "Generating new hashes for the package set file so it will be cached.. (this might take some time)"
Expand Down
Loading