Skip to content

Commit 9fa96f6

Browse files
authored
docs: add v3→v4 migration guide (sentry-cli → sentry) (#1201)
Adds a migration guide for the upcoming **major release** (v3 → v4), where the legacy Rust `sentry-cli` is replaced by the new TypeScript `sentry` CLI. New page: `docs/src/content/docs/migrating-from-v3.md` (wired into the **Getting Started** sidebar, between Installation and Self-Hosted). ## Covers - **The rename** — `sentry-cli` → `sentry` binary, `@sentry/cli` → `sentry` npm package, with install/uninstall steps for npm/brew/curl/npx. - **Command changes**, grouped for quick scanning: - *Still work unchanged* (`info`, `send-event`, `send-envelope`, `bash-hook`, `sourcemaps`, `debug-files`, `react-native …`). - *Renamed groups* (plural → singular: `releases`→`release`, `projects`→`project`, …) with a note that bare plurals still work as list shortcuts. - *Moved* (`login`→`auth login`, `update`→`cli upgrade`, `uninstall`→`cli uninstall`, `deploys`→`release deploys`, `upload-dif`/`upload-dsym`→`debug-files upload`, `difutil`→`debug-files`, `upload-proguard`→`proguard upload`). - *Removed* (`send-metric`). - **A copy-paste `sentry-cli()` shim** that transparently translates every moved/renamed command to its v4 form, so existing scripts and muscle memory keep working during migration (the user-requested "practical alternatives"). - **Output & scripting** (`--json` instead of screen-scraping, `NO_COLOR`/`SENTRY_PLAIN_OUTPUT`), **OAuth device-flow auth** (tokens still honored), **semantic exit codes**, **debug-ID-first sourcemaps**, and **config/`.sentryclirc` backward-compat**. All command mappings were verified against the actual v4 route map (`src/app.ts`), `src/commands/`, and the existing exit-codes/configuration docs. `cd docs && pnpm run build` passes (page renders, no broken links). > Note: I inferred the release will be branded **v4**; if it lands under a different version the title/headings are a trivial find-replace.
1 parent 8d76bda commit 9fa96f6

55 files changed

Lines changed: 1185 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
outputs:
5252
skill: ${{ steps.filter.outputs.skill == 'true' || startsWith(github.ref, 'refs/heads/release/') }}
5353
code: ${{ steps.filter.outputs.code == 'true' || startsWith(github.ref, 'refs/heads/release/') }}
54+
codemod: ${{ steps.filter.outputs.codemod == 'true' || startsWith(github.ref, 'refs/heads/release/') }}
5455
build-targets: ${{ steps.targets.outputs.matrix }}
5556
nightly-version: ${{ steps.nightly.outputs.version }}
5657
steps:
@@ -80,6 +81,9 @@ jobs:
8081
- 'package.json'
8182
- 'pnpm-lock.yaml'
8283
- '.github/workflows/ci.yml'
84+
codemod:
85+
- 'codemods/**'
86+
- '.github/workflows/ci.yml'
8387
- name: Compute build matrix
8488
id: targets
8589
run: |
@@ -114,6 +118,22 @@ jobs:
114118
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
115119
echo "Nightly version: ${VERSION}"
116120
121+
codemod-test:
122+
name: Codemod tests
123+
needs: [changes]
124+
if: needs.changes.outputs.codemod == 'true'
125+
runs-on: ubuntu-latest
126+
steps:
127+
- uses: actions/checkout@v6
128+
- uses: actions/setup-node@v6
129+
with:
130+
node-version: ${{ env.NODE_VERSION_22 }}
131+
# jssg fixtures live under codemods/sentry-v3-to-v4/tests/<case>/. The
132+
# codemod CLI is pinned for reproducible runs (bump deliberately).
133+
- name: Run jssg codemod tests
134+
working-directory: codemods/sentry-v3-to-v4
135+
run: npx codemod@1.12.7 jssg test -l typescript ./scripts/codemod.ts
136+
117137
check-generated:
118138
name: Validate generated files
119139
needs: [changes]
@@ -888,7 +908,7 @@ jobs:
888908
ci-status:
889909
name: CI Status
890910
if: always()
891-
needs: [changes, check-generated, build-binary, build-npm, build-docs, test-e2e, generate-patches]
911+
needs: [changes, check-generated, build-binary, build-npm, build-docs, test-e2e, generate-patches, codemod-test]
892912
runs-on: ubuntu-latest
893913
permissions: {}
894914
steps:
@@ -897,7 +917,7 @@ jobs:
897917
# Check for explicit failures or cancellations in all jobs
898918
# generate-patches is skipped on PRs — that's expected
899919
# publish-nightly is excluded: it's infrastructure (GHCR push), not code quality
900-
results="${{ needs.check-generated.result }} ${{ needs.build-binary.result }} ${{ needs.build-npm.result }} ${{ needs.build-docs.result }} ${{ needs.test-e2e.result }} ${{ needs.generate-patches.result }}"
920+
results="${{ needs.check-generated.result }} ${{ needs.build-binary.result }} ${{ needs.build-npm.result }} ${{ needs.build-docs.result }} ${{ needs.test-e2e.result }} ${{ needs.generate-patches.result }} ${{ needs.codemod-test.result }}"
901921
for result in $results; do
902922
if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then
903923
echo "::error::CI failed"
@@ -915,4 +935,8 @@ jobs:
915935
echo "::error::CI failed - upstream job failed causing check-generated to be skipped"
916936
exit 1
917937
fi
938+
if [[ "${{ needs.changes.outputs.codemod }}" == "true" && "${{ needs.codemod-test.result }}" == "skipped" ]]; then
939+
echo "::error::CI failed - upstream job failed causing codemod-test to be skipped"
940+
exit 1
941+
fi
918942
echo "CI passed"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish codemod
2+
3+
# Publishes codemods/sentry-v3-to-v4 to the Codemod Registry
4+
# (https://codemod.com/registry) as `@sentry/cli-v3-to-v4`.
5+
#
6+
# Prerequisites (one-time, done on codemod.com):
7+
# 1. Own/create the `@sentry` scope in the Codemod Registry.
8+
# 2. Register this repository as a trusted publisher (OIDC) for that scope,
9+
# so no long-lived API key is needed here.
10+
#
11+
# Trigger by pushing a tag like `codemod-v0.1.0`, or run manually.
12+
13+
on:
14+
push:
15+
tags:
16+
- "codemod-v*"
17+
workflow_dispatch:
18+
19+
permissions:
20+
contents: read
21+
id-token: write # OIDC token for the Codemod Registry trusted publisher
22+
23+
jobs:
24+
publish:
25+
name: Publish to Codemod Registry
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v6
29+
- uses: actions/setup-node@v6
30+
with:
31+
node-version: "22"
32+
- name: Publish
33+
working-directory: codemods/sentry-v3-to-v4
34+
# Pin the CLI in this OIDC-privileged job (avoid running unreviewed
35+
# `@latest` with a publish token). Bump deliberately alongside the CI
36+
# `codemod-test` job.
37+
run: npx codemod@1.12.7 publish

biome.jsonc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
"!docs",
1919
"!test/init-eval/templates",
2020
"!dist-build",
21+
// The codemod package is a self-contained Codemod (jssg) project with
22+
// its own tooling/tests (`codemods/sentry-v3-to-v4`); it uses the
23+
// `codemod:ast-grep` runtime import and intentionally "bad" v3 fixtures,
24+
// so it must not be linted/formatted by the repo's Biome config.
25+
"!codemods",
26+
// custom-ca.ts blows past Biome's type-analysis limit when pulled into
27+
// the module graph (internal Biome bug); force-ignore even via a test.
2128
"!!src/lib/custom-ca.ts"
2229
]
2330
},

codemods/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Codemods
2+
3+
Automated migration transforms for the Sentry CLI.
4+
5+
## `sentry-v3-to-v4.cjs`
6+
7+
Migrates the legacy `@sentry/cli` v3 Node wrapper (`new SentryCli().releases.*`)
8+
to the v4 `sentry` package library API (`createSentrySDK()`).
9+
10+
```bash
11+
# Run against your source (any path/glob jscodeshift accepts)
12+
npx jscodeshift -t codemods/sentry-v3-to-v4.cjs src/
13+
14+
# Or straight from GitHub, without cloning:
15+
npx jscodeshift \
16+
-t https://raw.githubusercontent.com/getsentry/cli/main/codemods/sentry-v3-to-v4.cjs \
17+
src/
18+
19+
# For TypeScript sources, pick the matching parser:
20+
npx jscodeshift --parser=tsx -t codemods/sentry-v3-to-v4.cjs src/
21+
```
22+
23+
It rewrites:
24+
25+
- the `@sentry/cli` import / `require``sentry`,
26+
- `new SentryCli(configFile, options)``createSentrySDK(options)`
27+
(drops the removed `configFile` arg, renames `authToken``token`),
28+
- the `releases.*` method chain → the v4 `release.*` / `sourcemap.*` methods,
29+
- `execute(args)``run(...args)`.
30+
31+
Because several option **shapes** changed between v3 and v4 (most notably
32+
`uploadSourceMaps({ include })``sourcemap.upload({ directory })`), the codemod
33+
does the mechanical rewrites and inserts `// TODO(sentry-v4): …` comments where a
34+
call needs a manual review rather than guessing. **Review the diff** after
35+
running it.
36+
37+
See [Migrating from v3](https://cli.sentry.dev/migrating-from-v3/) for the full
38+
guide.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
target/
3+
*.tgz

codemods/sentry-v3-to-v4/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# `@sentry/cli-v3-to-v4`
2+
3+
A [Codemod](https://codemod.com) that migrates programmatic **`@sentry/cli` v3**
4+
usage (the `SentryCli` class) to the **v4 `sentry` package** (`createSentrySDK`
5+
factory + typed command methods).
6+
7+
It is referenced from the CLI's
8+
[migration guide](https://cli.sentry.dev/migrating-from-v3/).
9+
10+
## Usage
11+
12+
```bash
13+
npx codemod @sentry/cli-v3-to-v4
14+
```
15+
16+
Run it from your project root; it rewrites `.js`/`.ts` files in place. Review the
17+
diff afterward — the codemod inserts `// TODO(sentry-v4): …` comments wherever an
18+
option shape changed and needs a manual decision (it flags rather than guesses).
19+
20+
## What it does
21+
22+
- Rewrites the module specifier `@sentry/cli``sentry`, **keeping your local
23+
binding name** (so re-exports and pass-throughs stay valid).
24+
- `new SentryCli(configFile?, options?)``SentryCli(options?)` — drops `new`
25+
(v4's default export is the `createSentrySDK` factory) and the removed
26+
`configFile` positional, and renames the `authToken` option to `token`.
27+
- Maps the release/sourcemap methods:
28+
`releases.new``release.create`, `releases.finalize``release.finalize`,
29+
`releases.setCommits``release["set-commits"]`,
30+
`releases.uploadSourceMaps``sourcemap.upload`,
31+
`releases.newDeploy``release.deploy`,
32+
`releases.proposeVersion``release["propose-version"]`, and
33+
`execute([...])``run(...)`.
34+
- Only touches files that actually import `@sentry/cli`, and only rewrites
35+
method calls on instances it can see created via `new SentryCli(...)`.
36+
37+
## Development
38+
39+
```bash
40+
# Run the test fixtures (tests/<case>/input.ts + expected.ts)
41+
pnpm test
42+
43+
# Type-check the transform
44+
pnpm run check-types
45+
46+
# Update expected fixtures after an intentional change
47+
pnpm dlx codemod@latest jssg test -l typescript ./scripts/codemod.ts -u
48+
```
49+
50+
## Publishing
51+
52+
Published to the [Codemod Registry](https://codemod.com/registry) under the
53+
`@sentry` scope. See [`.github/workflows/publish-codemod.yml`](../../.github/workflows/publish-codemod.yml)
54+
for the tag-triggered, trusted-publisher (OIDC) release.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
schema_version: "1.0"
2+
3+
name: "@sentry/cli-v3-to-v4"
4+
version: "0.1.0"
5+
description: "Migrate @sentry/cli v3 SDK usage to the v4 sentry package"
6+
author: "Sentry"
7+
license: "MIT"
8+
9+
10+
targets:
11+
# Keep this aligned with the files matched in workflow.yaml.
12+
languages: ["typescript"]
13+
14+
keywords: ["sentry", "sentry-cli", "migration", "v3", "v4"]
15+
16+
registry:
17+
access: "public"
18+
visibility: "public"
19+
20+
capabilities: []
21+
22+
workflows:
23+
- name: main
24+
default: true
25+
path: workflow.yaml
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "sentry-v3-to-v4",
3+
"version": "0.1.0",
4+
"description": "Migrate @sentry/cli v3 SDK usage to the v4 sentry package",
5+
"packageManager": "pnpm@10.x",
6+
"type": "module",
7+
"scripts": {
8+
"test": "pnpm dlx codemod@1.12.7 jssg test -l typescript ./scripts/codemod.ts",
9+
"check-types": "tsc --noEmit"
10+
},
11+
"devDependencies": {
12+
"@codemod.com/jssg-types": "latest",
13+
"typescript": "latest"
14+
}
15+
}

0 commit comments

Comments
 (0)