Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/codemods-jscodeshift.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-simplikit/codemods': patch
---

`react-simplikit-codemod` is now `@react-simplikit/codemods` and runs its transforms through jscodeshift: `npx @react-simplikit/codemods mobile-to-root <path>`. The CLI asks for the transform and the path when they are left out, and takes `--dry`, `--print`, `--force` and `--jscodeshift`. Outside a dry run it stops on uncommitted git changes unless `--force` is passed. `--json`, `--ignore`, `--no-package-json` and `--debug` are gone; manual follow-ups are printed as jscodeshift `REP` lines, and a file that cannot be processed exits `1` as before. `--help` lists the transforms, every run except a dry run prints the next steps, and the package requires Node.js 22 or later. The package version now moves with `react-simplikit`.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://unpkg.com/@changesets/config@4.0.0/schema.json",
"changelog": ["./changelog.mjs", { "repo": "toss/react-simplikit" }],
"commit": false,
"fixed": [],
"fixed": [["react-simplikit", "@react-simplikit/codemods"]],
"linked": [],
"access": "public",
"baseBranch": "main",
Expand Down
4 changes: 2 additions & 2 deletions .claude/agents/agent-translation-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ is kept in English as well, matching React 官方中文文档 — never 钩子.
when the result is hard to parse in one pass. Judge by readability, not by clause count; a
multi-clause sentence can be perfectly natural in Chinese
- Translating a UI label, proper noun, or identifier the source deliberately left in English:
package names (`react-simplikit-codemod`), prop and option names, npm script names, and UI
package names (`@react-simplikit/codemods`), prop and option names, npm script names, and UI
labels such as badge alt text (`MIT License`, `Discord Badge`). The converse also fails
review — `deprecated` used as an ordinary adjective in prose is translated (已弃用); only the
identifier beside it stays in English
Expand Down Expand Up @@ -256,7 +256,7 @@ the first failure mode below.
- Missing `¿` / `¡` opening marks, and missing accents where the accent carries meaning
(`más`/`mas`, `sí`/`si`, `qué`/`que`, `tú`/`tu`, `él`/`el`, `está`/`esta`, `aún`/`aun`)
- Translating a UI label, proper noun, or identifier the source deliberately left in English:
package names (`react-simplikit-codemod`), prop and option names, npm script names, and UI
package names (`@react-simplikit/codemods`), prop and option names, npm script names, and UI
labels such as badge alt text (`MIT License`, `Discord Badge`). The converse also fails
review — `deprecated` used as an ordinary adjective in prose is translated (`obsoleto`,
agreeing with its noun); only the identifier beside it stays in English
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Codemod fixtures are compared byte for byte, CRLF and BOM included.
packages/codemods/src/transforms/testfixtures/** -text
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ node_modules
coverage

# fake consumer projects the codemod e2e suite writes and rewrites in place
packages/codemod/test/__fixtures__/
packages/codemods/test/__fixtures__/

# vitepress
.vitepress/cache
Expand Down
1,055 changes: 1,002 additions & 53 deletions .pnp.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ src/hooks/**/*.md
src/utils/**/*.md
packages/plugin/skills/react-simplikit/SKILL.md
packages/plugin/skills/react-simplikit/references
packages/codemod/test/__fixtures__
packages/codemods/test/__fixtures__
packages/codemods/src/transforms/testfixtures
2 changes: 1 addition & 1 deletion .scripts/verify-compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getRootPath } from '../utils/getRootPath.ts';
const REACT_COMPILER = createRequire(import.meta.url).resolve('babel-plugin-react-compiler');

const SOURCE_GLOBS = ['packages/*/src/**/*.ts', 'packages/*/src/**/*.tsx'];
const IGNORED_GLOBS = ['**/*.spec.*', '**/*.test.*', '**/test/**', '**/test-utils/**'];
const IGNORED_GLOBS = ['**/*.spec.*', '**/*.test.*', '**/test/**', '**/test-utils/**', '**/testfixtures/**'];

// Both `'18'` and `'19'` produce identical diagnostics for this codebase, so the newer
// target is used. Revisit if the compatibility surface ever diverges between majors.
Expand Down
11 changes: 8 additions & 3 deletions .scripts/verifySkill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,21 @@ try {
const skill = await readVerifiedSkill(skillDirectory, 'react-simplikit');
const codemodSkill = await readVerifiedSkill(codemodSkillDirectory, 'react-simplikit-codemod');

const constants = await fs.readFile(path.join(root, 'packages/codemod/src/constants.ts'), 'utf8');
const constants = await fs.readFile(
path.join(root, 'packages/codemods/src/transforms/utils/mobileToRoot/constants.ts'),
'utf8'
);
const floor = /MIN_RUNTIME_VERSION = '(.*)'/.exec(constants)?.[1];

if (floor === undefined) {
throw new Error('MIN_RUNTIME_VERSION is missing from packages/codemod/src/constants.ts');
throw new Error(
'MIN_RUNTIME_VERSION is missing from packages/codemods/src/transforms/utils/mobileToRoot/constants.ts'
);
}

for (const [label, contents] of [
['the react-simplikit-codemod skill', codemodSkill],
['packages/codemod/README.md', await fs.readFile(path.join(root, 'packages/codemod/README.md'), 'utf8')],
['packages/codemods/README.md', await fs.readFile(path.join(root, 'packages/codemods/README.md'), 'utf8')],
] as const) {
// The prose form, not a bare version: the JSON sample carries that and would stay green.
assert.equal(
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
React utility hooks/components library. Two published packages and an agent plugin:

- `react-simplikit` (`packages/react-simplikit`) — React hooks, components and utils
- `react-simplikit-codemod` (`packages/codemod`) — bin-only CLI that runs upgrade codemods on consumer codebases (`mobile-to-root` today)
- `@react-simplikit/codemods` (`packages/codemods`) — bin-only CLI that runs upgrade codemods on consumer codebases (`mobile-to-root` today)
- `packages/plugin` — agent skills for Claude Code, Codex and skills.sh. No `package.json`, so it is neither a workspace nor on npm. `yarn skill:gen` regenerates `skills/react-simplikit` from the public exports and `yarn test:skill` fails CI when the committed copy drifts; `skills/react-simplikit-codemod` is hand-written

## Architecture
Expand Down
14 changes: 7 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
React utility hooks/components library. Two published packages and an agent plugin:

- `react-simplikit` (`packages/react-simplikit`) — React hooks, components and utils
- `react-simplikit-codemod` (`packages/codemod`) — bin-only CLI that runs upgrade codemods on consumer codebases (`mobile-to-root` today). The rules below describe the library; the exceptions that apply to the CLI are called out where they differ
- `@react-simplikit/codemods` (`packages/codemods`) — bin-only CLI that runs upgrade codemods on consumer codebases (`mobile-to-root` today). The rules below describe the library; the exceptions that apply to the CLI are called out where they differ
- `packages/plugin` — agent skills for Claude Code (the root `.claude-plugin/marketplace.json` points here), Codex and skills.sh. No `package.json`, so it is neither a workspace nor on npm. `yarn skill:gen` regenerates `skills/react-simplikit` from the public exports and `yarn test:skill` fails CI when the committed copy drifts; `skills/react-simplikit-codemod` is hand-written

## Development Quick Start
Expand Down Expand Up @@ -67,9 +67,9 @@ src/
- **Import extensions** — Use `.ts`/`.tsx` extensions in source imports (tsdown rewrites them to `.mjs`/`.cjs` in the output)
- **useEffect cleanup** — Always return cleanup to remove listeners/subscriptions
- **`"use client"` banner** — tsdown adds this to every emitted file for RSC compatibility
- **Named exports only** — No default exports
- **Named exports only** — No default exports. The one exception is a codemod transform in `packages/codemods/src/transforms/`, which jscodeshift loads through its default export
- **No `any` in implementation** — Full TypeScript strict mode, and lint rejects `any`. The only exception is `CallerTypedArgs` in `src/_internal/types.ts`, the parameter list of a function the caller passes in
- **Zero dependencies** — No runtime dependencies in `react-simplikit`. `react-simplikit-codemod` is a dev-time CLI and declares `commander`, `detect-indent`, `fast-glob`, `semver` and `typescript` in `dependencies`
- **Zero dependencies** — No runtime dependencies in `react-simplikit`. `@react-simplikit/codemods` is a dev-time CLI and declares `commander`, `execa`, `jscodeshift`, `prompts` and `semver` in `dependencies`

### SSR-Safe Coding Pattern

Expand Down Expand Up @@ -101,7 +101,7 @@ Never initialize state with browser API calls (causes hydration mismatch).

## Testing

- **100% coverage mandatory** — Enforced by Vitest coverage threshold. The codemod excludes two files: `src/cli.ts`, because its e2e suite runs the built bin in a child process where v8 cannot attribute the lines back, and `src/constants.ts`, which holds no executable statements. An excluded file still needs its behaviour covered somewhere — `cli.ts`'s exit codes and `--debug` output are asserted by the e2e suite
- **100% coverage mandatory** — Enforced by Vitest coverage threshold. The codemods package excludes `src/bin/*.ts`, because its e2e suite runs the built bin in a child process where v8 cannot attribute the lines back, and `constants.ts`, which holds no executable statements. An excluded file still needs its behaviour covered somewhere — the bin's `-v`, `-h` and exit codes are asserted by the e2e suite
- **SSR tests required** — All hooks accessing browser APIs must have `.ssr.test.ts`
- **Test file name**: `<name>.test.ts`; older folders still use `<name>.spec.ts` — keep whichever the folder has
- **SSR pattern**:
Expand Down Expand Up @@ -163,7 +163,7 @@ PR with changeset merged → release.yml triggers
- `changeset publish` v3 calls `yarn npm publish` for Yarn Berry, but manifests must stay valid for plain `npm pack` (`verify-pack`)
- Therefore: **always declare `main`/`types`/`module`/`exports` at the top level** of package.json
- `publishConfig` should only contain `access: "public"`
- A bin-only package declares `bin` instead and has no `main`/`types`/`module`/`exports`. `packages/codemod` is one; `bin` must point at the built `dist/cli.mjs`, and changing it requires re-running `yarn install` because `yarn.lock` records the value
- A bin-only package declares `bin` instead and has no `main`/`types`/`module`/`exports`. `packages/codemods` is one; `bin` must point at the built `dist/bin/codemods.cjs`, and changing it requires re-running `yarn install` because `yarn.lock` records the value

### OIDC Trusted Publishing

Expand All @@ -189,8 +189,8 @@ packages/
│ ├── src/ # Source (hooks, components, utils)
│ ├── dist/ # Build output (per-module, mirrors src/)
│ └── package.json
├── codemod/ # react-simplikit-codemod — bin-only CLI
│ ├── src/ # cli.ts plus runner/ and mobileToRoot/
├── codemods/ # @react-simplikit/codemods — bin-only CLI
│ ├── src/ # bin/ (CLI, jscodeshift runner) and transforms/ (one file per transform)
│ ├── test/ # e2e suite that spawns the built bin
│ └── package.json # declares `bin`, no main/types/module/exports
└── plugin/ # agent plugin — no package.json, not a workspace, not on npm
Expand Down
10 changes: 5 additions & 5 deletions README-es.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Una colección de utilidades de React ligeras y sin dependencias para crear apli

## Paquetes

| Paquete | Descripción | Versión |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | Hooks, componentes y utilidades de React: estado y lógica, eventos del navegador y web móvil (teclado, área segura, viewport) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [react-simplikit-codemod](./packages/codemod) | Codemods que reescriben una base de código para actualizar `react-simplikit` | [![npm](https://img.shields.io/npm/v/react-simplikit-codemod.svg)](https://www.npmjs.com/package/react-simplikit-codemod) |
| Paquete | Descripción | Versión |
| ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | Hooks, componentes y utilidades de React: estado y lógica, eventos del navegador y web móvil (teclado, área segura, viewport) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [@react-simplikit/codemods](./packages/codemods) | Codemods que reescriben una base de código para actualizar `react-simplikit` | [![npm](https://img.shields.io/npm/v/@react-simplikit/codemods.svg)](https://www.npmjs.com/package/@react-simplikit/codemods) |

## Características

Expand Down Expand Up @@ -97,7 +97,7 @@ Consulta la documentación completa en [react-simplikit.slash.page](https://reac
```
packages/
├── react-simplikit/ # la biblioteca
├── codemod/ # react-simplikit-codemod
├── codemods/ # @react-simplikit/codemods
└── plugin/ # skill de agente para asistentes de programación con IA
```

Expand Down
10 changes: 5 additions & 5 deletions README-ja_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

## パッケージ

| パッケージ | 説明 | バージョン |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | React のフック、コンポーネント、ユーティリティ: 状態とロジック、ブラウザイベント、モバイル Web(キーボード、セーフエリア、ビューポート) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [react-simplikit-codemod](./packages/codemod) | `react-simplikit` のアップグレードに合わせてコードベースを書き換える codemod | [![npm](https://img.shields.io/npm/v/react-simplikit-codemod.svg)](https://www.npmjs.com/package/react-simplikit-codemod) |
| パッケージ | 説明 | バージョン |
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | React のフック、コンポーネント、ユーティリティ: 状態とロジック、ブラウザイベント、モバイル Web(キーボード、セーフエリア、ビューポート) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [@react-simplikit/codemods](./packages/codemods) | `react-simplikit` のアップグレードに合わせてコードベースを書き換える codemod | [![npm](https://img.shields.io/npm/v/@react-simplikit/codemods.svg)](https://www.npmjs.com/package/@react-simplikit/codemods) |

## 特長

Expand Down Expand Up @@ -97,7 +97,7 @@ npx skills add toss/react-simplikit --skill react-simplikit
```
packages/
├── react-simplikit/ # ライブラリ本体
├── codemod/ # react-simplikit-codemod
├── codemods/ # @react-simplikit/codemods
└── plugin/ # AI コーディングアシスタント向けのエージェントスキル
```

Expand Down
10 changes: 5 additions & 5 deletions README-ko_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

## 패키지

| 패키지 | 설명 | 버전 |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | React 훅, 컴포넌트, 유틸리티: 상태와 로직, 브라우저 이벤트, 모바일 웹(키보드, 안전 영역, 뷰포트) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [react-simplikit-codemod](./packages/codemod) | `react-simplikit` 업그레이드에 맞춰 코드베이스를 고쳐 쓰는 codemod | [![npm](https://img.shields.io/npm/v/react-simplikit-codemod.svg)](https://www.npmjs.com/package/react-simplikit-codemod) |
| 패키지 | 설명 | 버전 |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| [react-simplikit](./packages/react-simplikit) | React 훅, 컴포넌트, 유틸리티: 상태와 로직, 브라우저 이벤트, 모바일 웹(키보드, 안전 영역, 뷰포트) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) |
| [@react-simplikit/codemods](./packages/codemods) | `react-simplikit` 업그레이드에 맞춰 코드베이스를 고쳐 쓰는 codemod | [![npm](https://img.shields.io/npm/v/@react-simplikit/codemods.svg)](https://www.npmjs.com/package/@react-simplikit/codemods) |

## 특징

Expand Down Expand Up @@ -97,7 +97,7 @@ npx skills add toss/react-simplikit --skill react-simplikit
```
packages/
├── react-simplikit/ # 라이브러리
├── codemod/ # react-simplikit-codemod
├── codemods/ # @react-simplikit/codemods
└── plugin/ # AI 코딩 어시스턴트용 에이전트 스킬
```

Expand Down
Loading
Loading