Skip to content

Commit

Permalink
support changesets (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn authored Aug 22, 2023
1 parent 0da6d6d commit 2daaee0
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 257 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": ["@svitejs/changesets-changelog-github-compact", {"repo": "feltjs/gro"}],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/twelve-nails-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@feltjs/gro': minor
---

change gro publish to use changesets
84 changes: 84 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@feltjs/eslint-config": "^0.3.0",
"@sveltejs/adapter-static": "^2.0.2",
"@sveltejs/kit": "^1.22.3",
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
"@types/estree": "^1.0.1",
"@types/fs-extra": "^11.0.1",
"@types/node": "^20.3.2",
Expand Down
87 changes: 67 additions & 20 deletions src/docs/publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,74 @@ npm whoami # check if you're logged in
npm login # and follow the instructions
```

> see also [`npm adduser`](https://docs.npmjs.com/cli/v6/commands/npm-adduser)
> more about [`npm login`](https://docs.npmjs.com/cli/v6/commands/npm-adduser)
## using changesets

The [`gro publish` task](https://github.com/feltjs/gro/blob/main/src/publish.task.ts)
integrates with [Changesets](https://github.com/changesets/changesets)
to publish packages to [npm](https://npmjs.com/). Internally the task calls both
[`changeset version`](https://github.com/changesets/changesets/blob/main/packages/cli/README.md#version)
and
[`changeset publish`](https://github.com/changesets/changesets/blob/main/packages/cli/README.md#publish).

Gro does not include Changesets as a dependency.
Install it globally or local to your repo:

```bash
npm i -g @changesets/cli
```

To set up a repo, first run
[init](https://github.com/changesets/changesets/blob/main/packages/cli/README.md#init):

```bash
changeset init
```

If your package is public, configure the `access` property:

```diff
# .changeset/config.json
- "access": "restricted",
+ "access": "public",
```

Optionally install a custom changelog generator like
[`@svitejs/changesets-changelog-github-compact`](https://github.com/svitejs/changesets-changelog-github-compact):

```bash
npm i -D @svitejs/changesets-changelog-github-compact
```

```diff
# .changeset/config.json
- "changelog": "@changesets/cli/changelog",
+ "changelog": ["@svitejs/changesets-changelog-github-compact", {"repo": "org/repo"}],
```

To [add](https://github.com/changesets/changesets/blob/main/packages/cli/README.md#add) a changeset:

```bash
changeset
```

See [the Changesets docs](https://github.com/changesets/changesets) for more.

## `gro publish`

Gro offers [the `gro publish` task](https://github.com/feltjs/gro/blob/main/src/publish.task.ts)
to push a project to a package registry;
currently only npm is supported.
The task passes its args through to
[`npm version`](https://docs.npmjs.com/cli/v6/commands/npm-version),
so to bump the minor version run `gro publish minor`.
It builds, bumps the version, publishes to npm, and syncs commits and tags to GitHub.

Projects are expected to conform to a simple but bespoke changelog format.
See [changelog.md](/changelog.md) for an example.
The `gro publish` task should explain what's wrong and offer an override;
it's designed to prevent mistakes, not tie your hands.
We may switch to [`changesets`](https://github.com/changesets/changesets) at some point.

If `npm publish` fails during `gro publish`, nothing else should be affected;
a common reason is not being logged into npm. (`npm adduser`)
If the builds are correct but `npm publish` failed,
The publish task builds, updates the version, publishes to npm,
and syncs commits and tags to GitHub.

```bash
gro publish
gro publish --help # view the options
```

If `changeset publish` fails during `gro publish`,
the task exits without pushing anything to the remote origin.
It does however create the version commit and tag.
A common failure is not being logged into npm. (see the instructions above)
If the builds are correct but `changeset publish` failed,
and you don't want to undo the version commit and tag,
you can continue manually with `npm publish` inside
the `/dist` subdirectories.
you can continue manually with `changeset publish` or `npm publish` in `/dist/library`.
Loading

0 comments on commit 2daaee0

Please sign in to comment.