Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit 3c917d7

Browse files
committed
chore: update readme, dependencies, and minor file renaming
1 parent 85e98dd commit 3c917d7

File tree

13 files changed

+7259
-3670
lines changed

13 files changed

+7259
-3670
lines changed

README.md

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
## About
3030

31-
`release-workspaces` brings the power of tools like Lerna and Release It! into one package, built to work with [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces). Using this utility, you can do the following:
31+
`release-workspaces` brings the power of Release It! to monorepos. All built with [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) in mind. Using this utility, you can do the following:
3232

3333
- Version packages
3434
- Publish packages
@@ -37,34 +37,42 @@
3737

3838
<p><small>*See <a href="#roadmap">roadmap</a></small></p>
3939

40+
### Scope & Goals
41+
42+
One of the key benefits of npm workspaces is running commands across packages, and managing inter-package dependencies. However, like non-workspace projects, versioning and publishing is more or less a very manual process.
43+
44+
It's therefore _not_ in the perview of this package to interact with behavior beyond versioning and publishing.
45+
4046
## Assumptions
4147

4248
This tool assumes a few things about your workflow:
4349

44-
- You're using npm workspaces (of course) (npm 7.x)
50+
- You're using npm workspaces (npm 7.x)
4551
- All your packages will use the same version for each release
4652

4753
## Usage
4854

4955
`release-workspaces` is used primarily as a command line integration tool combined with an optional configuration file.
5056

51-
The basic requirement is to have a `version` field defined in your root `package.json` (you can alternatively add [`metadata.version`](#metadata) to your config file). This will be the version of your packages, and is automatically updated for you after a release succeeds, but before the git step.
57+
The basic requirement is to have a `version` field defined in your root `package.json` (you can alternatively add [`metadata.version`](#metadata) to your config file). This will be the version of your packages, and is automatically updated for you after a release succeeds.
5258

5359
Using the tool can be as simple as this:
5460

5561
```sh
5662
$ release-workspaces --increment major
63+
# or
64+
$ release-workspaces -i major
5765
```
5866

5967
With only a `version` field in your root `package.json`, mind you!
6068

6169
Here's a more complex example of incrementing packages from prerelease, to release candidate, to minor version.
6270

6371
```sh
64-
$ release-workspaces --increment preminor --preid alpha # 0.1.0 -> 0.2.0-alpha.0
65-
$ release-workspaces --increment prerelease # 0.2.0-alpha.1
66-
$ release-workspaces --increment prerelease --preid rc --npm-tag next # 0.2.0-rc.0 @ next
67-
$ release-workspaces --increment minor # 0.2.0
72+
$ release-workspaces -i preminor --preid alpha # 0.1.0 -> 0.2.0-alpha.0
73+
$ release-workspaces -i prerelease # 0.2.0-alpha.1
74+
$ release-workspaces -i prerelease --preid rc --npm-tag next # 0.2.0-rc.0 @ next
75+
$ release-workspaces -i minor # 0.2.0
6876
```
6977

7078
### Config File
@@ -105,6 +113,8 @@ Defaults:
105113
}
106114
```
107115

116+
_NOTE: Setting both `increment` and `publish` to `false` is a valid configuration if you only wish to tag the latest commit._
117+
108118
#### `git`
109119

110120
Configures how to run git operations (commit, tag, push). Use `${version}` in string values to insert the new version when processed.
@@ -132,7 +142,8 @@ Configures the tool to run scripts during the execution lifecycle. If you need t
132142

133143
Available hooks:
134144

135-
- `prenpm`, `postnpm`: Runs before/after packages are versioned & published
145+
- `preincrement`, `postincrement`: Runs before/after packages are versioned
146+
- `prepublish`, `postpublish`: Runs before/after packages are published
136147
- `precommit`, `postcommit`: Runs before/after publish artifacts are committed
137148
- `pretag`, `posttag`: Runs before/after a release tag is generated
138149
- `prepush`, `postpush`: Runs before/after the commit is pushed to the remote (does not run if both `config.git.commit` and `config.git.tag` are false)
@@ -143,14 +154,14 @@ Arguments passed through the CLI will be passed verbatim to and validated by [se
143154

144155
#### Release Flags
145156

146-
| Name | Type | Description |
147-
| ---------------------- | ------- | ---------------------------------------------------------------------------- |
148-
| `--increment`, `-i` | string | The release increment. E.g. `minor`, `prepatch`, `prerelease`, etc. |
149-
| `--increment-to`, `-s` | string | A specific version to publish. E.g., `3.0.0`, `3.0.0-rc.2`, etc. |
150-
| `--preid`, `-p` | string | Sets the prerelease id. E.g. `alpha`, `rc`, etc. |
151-
| `--npm-tag`, `-n` | string | If given, sets the npm publish tag. Otherwise uses the `preid`. E.g. `next`. |
152-
| `--dry-run`, `-d` | boolean | Prints normal output but doesn't execute. |
153-
| `--verbose`, `-b` | boolean | Prints all commands (can be used with `--dry-run`/`-d`). |
157+
| Name | Type | Description |
158+
| ---------------------- | ------- | ---------------------------------------------------------------------------------- |
159+
| `--increment`, `-i` | string | The release increment. E.g. `minor`, `prepatch`, `prerelease`, etc. |
160+
| `--increment-to`, `-s` | string | A specific version to publish. E.g., `3.0.0`, `3.0.0-rc.2`, etc. |
161+
| `--preid`, `-p` | string | Sets the prerelease id. E.g. `alpha`, `rc`, etc. |
162+
| `--npm-tag`, `-n` | string | If given, sets the npm publish tag. Otherwise uses the `preid`. E.g. `next`. |
163+
| `--dry-run`, `-d` | boolean | Prints normal output but doesn't execute. |
164+
| `--verbose`, `-b` | boolean | Prints all commands and mutating script calls (can be used with `--dry-run`/`-d`). |
154165

155166
Note that if `--npm-tag` isn't given, then the tool will fall back to the value given for `--preid`, else it will use `latest`.
156167

@@ -160,29 +171,29 @@ Similarly, if you run a git-only release (no version, no publish), the tool will
160171

161172
Using config options via CLI will override your config. Useful for one-off releases and otherwise augmenting a base configuration for release types (alpha release, release candidate, no-increment publish, etc).
162173

163-
You can use any of the existing config options as CLI flags by using the formula `--<key>.<property> [value]`. E.g., change the default or user-configured commit message: `--git.commitMessage "chore: release ${version}"` or disable all git checks with `--git.skipChecks`.
174+
You can use any of the existing config options as CLI flags by using the formula `--<key>.<property> [value]`. E.g., change the default or user-configured commit message: `--git.commitMessage "chore: release \${version}"` or disable all git checks with `--git.skipChecks`.
164175

165176
Similarly, you can negate any boolean option by prepending `--no-` to it. E.g., `--no-git.requireCleanDir`.
166177

167178
## Cheatsheet
168179

169180
Here are a few handy examples of how to achieve certain release results with CLI flags. Replace `minor` with your intended release increment.
170181

171-
| Description | Example |
172-
| ------------------------------- | ------------------------------------------------------------------------------------------ |
173-
| Do everything | `$ release-workspaces -i minor` |
174-
| Prerelease | `$ release-workspaces -i preminor -p alpha` |
175-
| Increment prerelease | `$ release-workspaces -i prerelease` |
176-
| Update prerelease id w/ npm tag | `$ release-workspaces -i prerelease -p rc -n next` |
177-
| Increment to a specific version | `$ release-workspaces -s 3.0.0` |
178-
| Skip npm version | `$ release-workspaces --no-npm.increment` |
179-
| Skip npm publish | `$ release-workspaces -i minor --no-npm.publish` |
180-
| Skip all npm operations | `$ release-workspaces --no-npm.increment --no-npm.publish` |
181-
| Skip clean directory check | `$ release-workspaces -i minor --no-git.requireCleanDir` |
182-
| Skip git sync check | `$ release-workspaces -i minor --no-git.requireSync` |
183-
| Skip all git checks | `$ release-workspaces -i minor --git.skipChecks` |
184-
| Skip git operation | `$ release-workspaces -i minor --no-git.[commit/tag/push]` |
185-
| Set custom messaging | `$ release-workspaces -i minor --git.[commitMessage/tagMessage] "Custom msg: \${version}"` |
182+
| Description | Example |
183+
| ------------------------------- | --------------------------------------------------------------------------------------------- |
184+
| Do everything | `$ release-workspaces -i minor` |
185+
| Prerelease | `$ release-workspaces -i preminor -p alpha` |
186+
| Increment prerelease | `$ release-workspaces -i prerelease` |
187+
| Update prerelease id w/ npm tag | `$ release-workspaces -i prerelease -p rc -n next` |
188+
| Increment to a specific version | `$ release-workspaces -s 3.0.0` |
189+
| Skip npm version | `$ release-workspaces --no-npm.increment` |
190+
| Skip npm publish | `$ release-workspaces -i minor --no-npm.publish` |
191+
| Skip all npm operations | `$ release-workspaces --no-npm.increment --no-npm.publish` |
192+
| Skip clean directory check | `$ release-workspaces -i minor --no-git.requireCleanDir` |
193+
| Skip git sync check | `$ release-workspaces -i minor --no-git.requireSync` |
194+
| Skip all git checks | `$ release-workspaces -i minor --git.skipChecks` |
195+
| Skip git operation | `$ release-workspaces -i minor --no-git.[commit/tag/push]` |
196+
| Set custom messaging | `$ release-workspaces -i minor --git.[commitMessage/tagMessage] "Custom msg for \${version}"` |
186197

187198
## Clarifications & Gotchas
188199

@@ -195,6 +206,6 @@ There are some contradictory or otherwise unclear config combinations to note.
195206

196207
## Roadmap
197208

198-
- [ ] Release in CI
199-
- [ ] Rollback changes if failures occur mid-release
209+
- [x] Rollback changes if failures occur mid-release
200210
- [ ] Automate GitHub/GitLab releases
211+
- [ ] Release in CI

bin/__tests__/commit.spec.js renamed to bin/__tests__/git.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getCommitCmd, getTagCmd, getPushCmd } from "../helpers/commands.js"
44
import { setVersionToString } from "../helpers/transformers.js"
55
import { setRollback } from "../helpers/rollback.js"
66
import { reportCmd } from "../helpers/cmd.js"
7-
import { runCommit } from "../modules/commit.js"
7+
import { runGit } from "../modules/git.js"
88

99
jest.mock("../helpers/cmd.js", () => ({
1010
reportCmd: jest.fn(),
@@ -37,10 +37,10 @@ const baseConfig = {
3737
},
3838
}
3939

40-
describe("runCommit()", () => {
40+
describe("runGit()", () => {
4141
describe("tag, commit, and push are false", () => {
4242
it("does not run commands", async () => {
43-
await runCommit(baseConfig)
43+
await runGit(baseConfig)
4444
expect(reportCmd).not.toBeCalled()
4545
})
4646
})
@@ -55,7 +55,7 @@ describe("runCommit()", () => {
5555
git: { ...baseConfig.git, commit: true },
5656
}
5757
// When
58-
await runCommit(config)
58+
await runGit(config)
5959
})
6060

6161
it("runs precommit hook", async () => {
@@ -113,7 +113,7 @@ describe("runCommit()", () => {
113113
git: { ...baseConfig.git, commit: true, push: false, tag: false },
114114
}
115115
// When
116-
await runCommit(config)
116+
await runGit(config)
117117
})
118118

119119
it("doesn't run commit command", async () => {
@@ -131,7 +131,7 @@ describe("runCommit()", () => {
131131
git: { ...baseConfig.git, tag: true },
132132
}
133133
// When
134-
await runCommit(config)
134+
await runGit(config)
135135
})
136136

137137
it("runs pretag hook", async () => {
@@ -188,7 +188,7 @@ describe("runCommit()", () => {
188188
git: { ...baseConfig.git, tag: true, push: true },
189189
}
190190
// When
191-
await runCommit(config)
191+
await runGit(config)
192192
})
193193

194194
it("runs prepush hook", async () => {

bin/__tests__/release.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import "../../.jest/mocks.js"
22
import { getArgs } from "../helpers/get-args.js"
33
import { enableRollback, disableRollback } from "../helpers/rollback.js"
44
import { runNpm } from "../modules/npm.js"
5-
import { runCommit } from "../modules/commit.js"
5+
import { runGit } from "../modules/git.js"
66
import { release } from "../modules/release.js"
77

88
jest.mock("../helpers/get-args.js")
99
jest.mock("../helpers/rollback.js", () => ({
1010
disableRollback: jest.fn(),
1111
enableRollback: jest.fn(),
1212
}))
13-
jest.mock("../modules/commit.js", () => ({
14-
runCommit: jest.fn(),
13+
jest.mock("../modules/git.js", () => ({
14+
runGit: jest.fn(),
1515
}))
1616
jest.mock("../modules/initialize.js")
1717
jest.mock("../modules/npm.js", () => ({
@@ -63,6 +63,6 @@ describe("release()", () => {
6363
// When
6464
await release()
6565
// Then
66-
expect(runCommit).toBeCalled()
66+
expect(runGit).toBeCalled()
6767
})
6868
})

bin/modules/commit.js renamed to bin/modules/git.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { setVersionToString } from "../helpers/transformers.js"
66
import { cmd, reportCmd } from "../helpers/cmd.js"
77
import { setRollback } from "../helpers/rollback.js"
88

9-
export async function runCommit(config) {
9+
export async function runGit(config) {
1010
const {
1111
npm: { increment },
1212
git: {

bin/modules/release.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { getArgs } from "../helpers/get-args.js"
44
import { enableRollback, disableRollback } from "../helpers/rollback.js"
55
import { runNpm } from "./npm.js"
6-
import { runCommit } from "./commit.js"
6+
import { runGit } from "./git.js"
77
import { initialize } from "./initialize.js"
88

99
export async function release() {
@@ -28,7 +28,7 @@ export async function release() {
2828
// Commit changes, create tag, and push to origin
2929

3030
if (commit || tag) {
31-
await runCommit(config)
31+
await runGit(config)
3232
}
3333

3434
disableRollback()

jest.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"restoreMocks": true,
55
"verbose": true,
66
"testMatch": ["<rootDir>/bin/**/__tests__/**/*.spec.js"],
7-
"testURL": "http://localhost/",
7+
"testEnvironmentOptions": {
8+
"url": "http://localhost/"
9+
},
810
"transform": {
911
"\\.js$": "babel-jest"
1012
},

0 commit comments

Comments
 (0)