Skip to content

Commit 6a24d2d

Browse files
committed
Prepare for release
1 parent 58fd5e1 commit 6a24d2d

1 file changed

Lines changed: 73 additions & 5 deletions

File tree

README.md

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,87 @@
11
# risk
22

3-
An experiment in a smaller Danger JS runtime with a more narrow scope: GitHub, ESM, TS+JS only, Node 22+
3+
A smaller [Danger JS](https://danger.systems/js) runtime with a narrower scope: GitHub only, ESM only, Node 22+. Three runtime dependencies.
44

5-
Aims to have as few dependencies as possible. Currently that is 3.
5+
Full documentation lives at [danger.systems/js](https://danger.systems/js) — the Dangerfile API is the same.
66

77
## Installation
88

99
```sh
10-
yarn add risk
10+
yarn add risk --dev
1111
```
1212

1313
## Usage
1414

15+
Create a `dangerfile.ts` in your project root:
16+
17+
```ts
18+
import { danger, warn, fail, message, markdown } from "risk"
19+
20+
if (!danger.github.pr.body.length) {
21+
fail("Please add a description to your PR.")
22+
}
23+
24+
const bigPR = danger.github.pr.additions + danger.github.pr.deletions > 500
25+
if (bigPR) {
26+
warn("This PR is quite large. Consider splitting it up.")
27+
}
28+
29+
message(`This PR modifies ${danger.git.modified_files.length} file(s).`)
30+
```
31+
32+
Existing Dangerfiles that `import { danger } from "danger"` will also work — a built-in ESM loader handles the redirect.
33+
34+
### Commands
35+
36+
**`danger ci`** — Run on CI against the current pull request.
37+
38+
```sh
39+
danger ci [options]
40+
```
41+
42+
| Option | Description |
43+
|---|---|
44+
| `-d, --dangerfile <path>` | Path to Dangerfile (default: `dangerfile.ts`) |
45+
| `--id <id>` | Unique identifier for this run (default: `"Danger"`) |
46+
| `-t, --text-only` | Print to stdout instead of posting comments |
47+
| `--fail-on-errors` | Exit with code 1 if there are failures |
48+
| `--new-comment` | Always create a new comment |
49+
| `--remove-previous-comments` | Remove previous Danger comments |
50+
| `--base-url <url>` | GitHub API base URL (for GitHub Enterprise) |
51+
52+
**`danger pr <url>`** — Test your Dangerfile against an existing PR without posting comments.
53+
54+
```sh
55+
danger pr https://github.com/owner/repo/pull/123
56+
```
57+
58+
### GitHub Actions
59+
60+
```yaml
61+
- run: yarn danger ci
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
```
65+
66+
For other CI providers, set `DANGER_GITHUB_API_TOKEN` and either `DANGER_PR_URL` or `DANGER_REPO_SLUG` + `DANGER_PR_ID`.
67+
68+
### GitHub Enterprise
69+
70+
Set `--base-url` or the `DANGER_GITHUB_API_BASE_URL` environment variable to your GHE API endpoint.
71+
72+
## What's different from Danger JS
73+
74+
- **GitHub only** — no GitLab or BitBucket support
75+
- **ESM only** — no CommonJS, no Babel transpilation
76+
- **Node 22+** — uses native type stripping, `fetch`, `parseArgs`, `styleText`
77+
- **Single process** — no subprocess/runner model
78+
- **3 runtime deps** — `@octokit/rest`, `parse-diff`, `picomatch`
79+
80+
## Releasing
81+
1582
```sh
16-
yarn danger ci
83+
# Update CHANGELOG.md with the new version, then:
84+
yarn release <patch|minor|major>
1785
```
1886

19-
Will evaluate an existing `dangerfile.ts`, `dangerfile.js` etc
87+
This bumps `package.json`, commits, tags, and pushes. The [publish workflow](.github/workflows/publish.yml) handles creating the GitHub release and publishing to npm.

0 commit comments

Comments
 (0)