sigdiff 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -15
- package/dist/cli.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# sigdiff
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Detects breaking changes in TypeScript projects by diffing the actual API surface between git refs. No config, no setup, no commit conventions.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx sigdiff v1.0.0..v2.0.0
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
## Why
|
|
9
|
+
## Why this exists
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Tools like `changesets` require developers to manually describe what changed. `semantic-release` relies on commit message conventions. `api-extractor` extracts the API surface but leaves semver classification to humans.
|
|
12
|
+
|
|
13
|
+
`sigdiff` skips all of that. Point it at two git refs and it tells you what changed in your exports, classified by semver level. Think [`cargo-semver-checks`](https://github.com/obi1kenobi/cargo-semver-checks) for TypeScript.
|
|
14
|
+
|
|
15
|
+
The goal here is to keep it simple and minimize overhead. No config files. No plugins. No workflow changes.
|
|
12
16
|
|
|
13
17
|
## Usage
|
|
14
18
|
|
|
@@ -16,21 +20,23 @@ Commit messages are a human interpretation of a change — imprecise, incomplete
|
|
|
16
20
|
# Compare last tag to HEAD
|
|
17
21
|
npx sigdiff
|
|
18
22
|
|
|
19
|
-
# Compare two
|
|
23
|
+
# Compare two tags
|
|
20
24
|
npx sigdiff v1.0.0..v2.0.0
|
|
21
25
|
|
|
26
|
+
# Any git ref works: branches, commits, relative refs
|
|
27
|
+
npx sigdiff main..feature-branch
|
|
28
|
+
npx sigdiff abc1234..def5678
|
|
29
|
+
npx sigdiff HEAD~5..HEAD
|
|
30
|
+
|
|
22
31
|
# Scope to a specific entrypoint
|
|
23
32
|
npx sigdiff --entrypoint src/index.ts
|
|
24
33
|
|
|
25
34
|
# JSON output
|
|
26
35
|
npx sigdiff --json
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## What it detects
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
# Exit with code 1 if breaking changes are detected (useful for CI)
|
|
38
|
+
npx sigdiff --check
|
|
39
|
+
```
|
|
34
40
|
|
|
35
41
|
## Example output
|
|
36
42
|
|
|
@@ -38,7 +44,7 @@ Changes are classified as `major`, `minor`, or `patch` per semver rules.
|
|
|
38
44
|
### Breaking Changes
|
|
39
45
|
|
|
40
46
|
- Removed function `fetchLegacyData`
|
|
41
|
-
- `createUser` signature changed: `(name: string, email: string)`
|
|
47
|
+
- `createUser` signature changed: `(name: string, email: string)` -> `(opts: CreateUserOpts)`
|
|
42
48
|
|
|
43
49
|
### New
|
|
44
50
|
|
|
@@ -48,6 +54,34 @@ Changes are classified as `major`, `minor`, or `patch` per semver rules.
|
|
|
48
54
|
Suggested version bump: major
|
|
49
55
|
```
|
|
50
56
|
|
|
57
|
+
## What it detects
|
|
58
|
+
|
|
59
|
+
Functions, arrow functions, interfaces, type aliases, enums, classes, and constants. Parameters, return types, property shapes, and member names.
|
|
60
|
+
|
|
61
|
+
Changes are classified as `major`, `minor`, or `patch` per semver rules.
|
|
62
|
+
|
|
63
|
+
## How it compares
|
|
64
|
+
|
|
65
|
+
| | sigdiff | changesets | semantic-release | api-extractor |
|
|
66
|
+
| --------------------- | --------------- | ----------------------- | -------------------- | --------------- |
|
|
67
|
+
| Detects API changes | Automatic (AST) | Manual (you write them) | No (commit messages) | Automatic (AST) |
|
|
68
|
+
| Semver classification | Automatic | Manual | Commit-based | Manual |
|
|
69
|
+
| Changelog output | Yes | Yes | Yes | No |
|
|
70
|
+
| Config required | None | Yes | Yes | Yes |
|
|
71
|
+
| Git ref comparison | Any ref | N/A | N/A | Baseline file |
|
|
72
|
+
|
|
73
|
+
## CI integration
|
|
74
|
+
|
|
75
|
+
Use `--check` to fail your pipeline when breaking changes are introduced:
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
# .github/workflows/ci.yml
|
|
79
|
+
- name: API surface check
|
|
80
|
+
run: npx sigdiff origin/main..HEAD --entrypoint src/index.ts --check
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Without `--check`, sigdiff always exits 0 and just prints the diff. With `--check`, it exits 1 if any breaking changes are detected, making it easy to gate PRs.
|
|
84
|
+
|
|
51
85
|
## Programmatic API
|
|
52
86
|
|
|
53
87
|
```typescript
|
|
@@ -61,10 +95,10 @@ console.log(format(buildResult(classify(diff(before, after)))));
|
|
|
61
95
|
|
|
62
96
|
## Notes
|
|
63
97
|
|
|
64
|
-
- TypeScript only
|
|
65
|
-
- Single-package projects
|
|
66
|
-
- Read-only
|
|
67
|
-
- 1 runtime dependency ([`cac`](https://github.com/cacjs/cac))
|
|
98
|
+
- TypeScript only. No JS support (no type info to diff).
|
|
99
|
+
- Single-package projects. No monorepo support yet.
|
|
100
|
+
- Read-only. Never touches your working tree.
|
|
101
|
+
- 1 runtime dependency ([`cac`](https://github.com/cacjs/cac)). ~8 KB published.
|
|
68
102
|
|
|
69
103
|
## License
|
|
70
104
|
|
package/dist/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ cli
|
|
|
16
16
|
.command('[range]', 'Diff the public API surface between two git refs')
|
|
17
17
|
.option('--entrypoint <path>', 'Scope to a specific file')
|
|
18
18
|
.option('--json', 'Output as JSON instead of markdown')
|
|
19
|
+
.option('--check', 'Exit with code 1 if breaking changes are detected')
|
|
19
20
|
.action((range, options) => {
|
|
20
21
|
try {
|
|
21
22
|
(0, git_1.assertGitRepo)();
|
|
@@ -27,6 +28,9 @@ cli
|
|
|
27
28
|
const result = (0, format_1.buildResult)(classified);
|
|
28
29
|
const output = (0, format_1.format)(result, { json: options.json });
|
|
29
30
|
process.stdout.write(output);
|
|
31
|
+
if (options.check && result.breaking.length > 0) {
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
catch (err) {
|
|
32
36
|
if (err instanceof errors_1.SigdiffException) {
|