purescript / spago

🍝 PureScript package manager and build tool
BSD 3-Clause "New" or "Revised" License
791 stars 132 forks source link

New command: `spago publish` #766

Closed thomashoneyman closed 1 year ago

thomashoneyman commented 3 years ago

Related to #204 and https://github.com/purescript/registry/pull/140 and depends on the new registry.

The PureScript registry supports a minimal API consisting of package additions, updates, and unpublishing. This issue tracks adding a command to Spago that at least would support adding and updating packages. To do this, we'll need to support a few things from the registry:

  1. The registry uses a new manifest format as described in the Manifest.dhall definition. Spago will need to be able to generate this format from spago.dhall files, and therefore spago.dhall files themselves probably have to be changed. (This could be tracked in a separate issue if necessary.)
  2. The registry adds packages based on the Operation.dhall definition. The spago publish command would need to produce the correct JSON corresponding with the update or addition operations.
  3. The registry relies on issue creation and comments on the registry repository to kick off operations. Spago will need to open an issue on GitHub on the user's behalf, either automatically (with a confirmation) or by providing the user with a link to create the issue with the correct JSON contents themselves.

All of this is a bit in flux: this is at least blocked until https://github.com/purescript/registry/pull/140 merges.

f-f commented 3 years ago

Some more notes on your points:

  1. The main thing we need to support for this is the notion of "targets", and indeed there's #681 open to track this change to the config format. I am not sure if we should pivot that issue to track the whole config thing - in any case, I think the new config format is going to look something between the new Manifest type and our current config. In the early days of the Registry RFC the Package type (which later became Manifest) is basically how I imagine this config will look like. E.g. take a look at the Package, Target, and Index types.
  2. The dhall package has some Template Haskell facilities to embed Dhall types into the compilation step so that:

    1. we wouldn't have to type down the Haskell types, and
    2. we'd automatically keep them in sync with upstream.

    I.e. we'd basically call makeHaskellTypes on the Operation type

  3. I would like to avoid directly calling the GitHub API from Spago, because we'd otherwise have to ask the user to configure a GitHub Token. We can avoid that by just printing out a link to create the issue.

To expand a bit more on how the publish UX could look like, here's an example:

$ spago publish
Generating package manifest from your config...
Running Registry checks..
Checks passed.
Publish your package by opening this ticket: https://github.com/purescript/spago/issues/new?body=etcetc

Note: to run the package checks we'd just import the same code that we use for running checks in the Registry CI

f-f commented 2 years ago

An update on this now that we have the new codebase in place (see the spaghetto folder). This command would:

thomashoneyman commented 2 years ago

With regards to the first point, once the new configuration format is stable the registry can support it directly, meaning there is no need to generate a manifest. Or, in other words, the manifest generation code can be moved to the registry codebase.

f-f commented 1 year ago

This is implemented in spaghetto since https://github.com/purescript/spago/commit/b95c82e90cf8a990c622ca09fed09e1b43a6da59.

It will run all the checks and make sure the package is in order for publishing, and the only thing missing is calling out to the registry API, which is blocked on https://github.com/purescript/registry-dev/issues/578

f-f commented 1 year ago

This is now released