Skip to content

Commit ca4c98e

Browse files
committed
setup changesets
1 parent 9f24bca commit ca4c98e

8 files changed

Lines changed: 1000 additions & 0 deletions

File tree

.changeset/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in the readme](https://github.com/changesets/changesets/blob/main/packages/changesets-cli/README.md)
6+
7+
It is used by the repository to track versioning and release codemods.
8+
9+
## Adding a changeset
10+
11+
Run `pnpm changeset` to create a new changeset for your changes.

.changeset/config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": [],
11+
"privatePackages": {
12+
"version": false,
13+
"tag": false
14+
}
15+
}

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
permissions:
11+
id-token: write
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
release:
17+
name: Release
18+
runs-on: ubuntu-latest
19+
outputs:
20+
published: ${{ steps.changesets.outputs.published }}
21+
changed_dirs: ${{ steps.tag.outputs.changed_dirs }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: pnpm/action-setup@v4
26+
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
cache: pnpm
31+
32+
- run: pnpm install --frozen-lockfile
33+
34+
- name: Create Release PR or Publish
35+
id: changesets
36+
uses: changesets/action@v1
37+
with:
38+
version: pnpm version-packages
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Tag released versions
43+
if: steps.changesets.outputs.hasChangesets == 'false'
44+
id: tag
45+
run: bash scripts/tag-and-publish.sh
46+
47+
publish:
48+
name: Publish ${{ matrix.dir }}
49+
needs: release
50+
if: needs.release.outputs.changed_dirs != '[]' && needs.release.outputs.changed_dirs != ''
51+
runs-on: ubuntu-latest
52+
strategy:
53+
matrix:
54+
dir: ${{ fromJson(needs.release.outputs.changed_dirs) }}
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- uses: pnpm/action-setup@v4
59+
60+
- uses: actions/setup-node@v4
61+
with:
62+
node-version: 20
63+
cache: pnpm
64+
65+
- run: pnpm install --frozen-lockfile
66+
67+
- name: Publish codemod
68+
uses: codemod/publish-action@v1
69+
with:
70+
path: ${{ matrix.dir }}

CONTRIBUTING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Contributing
2+
3+
Thanks for your interest in contributing to react-codemod!
4+
5+
## Development setup
6+
7+
```bash
8+
# Install dependencies
9+
pnpm install
10+
11+
# Run all tests
12+
pnpm test
13+
14+
# Type-check all codemods
15+
pnpm check-types
16+
```
17+
18+
## Making changes
19+
20+
1. Create a branch from `main`.
21+
2. Make your changes and add or update tests.
22+
3. Run `pnpm test` and `pnpm check-types` to verify everything passes.
23+
4. Add a changeset (see below).
24+
5. Open a pull request.
25+
26+
## Adding a changeset
27+
28+
This repo uses [Changesets](https://github.com/changesets/changesets) for versioning and releases. Every PR that changes a codemod must include a changeset.
29+
30+
```bash
31+
pnpm changeset
32+
```
33+
34+
Follow the prompts to:
35+
1. Select the affected codemod(s).
36+
2. Choose the semver bump type — **patch** for bug fixes, **minor** for new features, **major** for breaking changes.
37+
3. Write a short summary of the change.
38+
39+
This creates a markdown file in `.changeset/` that should be committed with your PR.
40+
41+
## Release workflow
42+
43+
1. Merge a PR with one or more changesets into `main`.
44+
2. CI automatically opens a **Version Packages** PR that bumps versions in `package.json` and `codemod.yaml`.
45+
3. Merge the version PR — git tags are created and the updated codemods are published to the Codemod registry.
46+
47+
## Adding a new codemod
48+
49+
Each codemod lives in its own directory under `codemods/jssg/`:
50+
51+
```
52+
codemods/jssg/<name>/
53+
scripts/codemod.ts # Codemod logic (jssg / ast-grep)
54+
tests/ # Input/expected test fixtures
55+
codemod.yaml # Codemod manifest
56+
workflow.yaml # Execution workflow
57+
package.json
58+
```
59+
60+
Use an existing codemod as a reference when creating a new one.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"check-types": "pnpm run check-types:active",
1212
"check-types:active": "pnpm -r --filter \"@react-new/*\" check-types",
1313
"test:legacy": "bash -lc 'cd codemods/legacy && pnpm install --ignore-workspace --frozen-lockfile --force && pnpm run test:ci'",
14+
"changeset": "changeset",
15+
"version-packages": "changeset version && bash scripts/sync-codemod-versions.sh",
1416
"ci": "pnpm run lint && pnpm run test:active && pnpm run check-types:active && pnpm run test:legacy"
1517
},
1618
"keywords": [
@@ -26,6 +28,7 @@
2628
},
2729
"packageManager": "pnpm@9.14.2",
2830
"devDependencies": {
31+
"@changesets/cli": "^2.30.0",
2932
"@types/node": "latest"
3033
},
3134
"dependencies": {

0 commit comments

Comments
 (0)