diff --git a/.changeset/codemods-jscodeshift.md b/.changeset/codemods-jscodeshift.md new file mode 100644 index 00000000..78b30994 --- /dev/null +++ b/.changeset/codemods-jscodeshift.md @@ -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 `. 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`. diff --git a/.changeset/config.json b/.changeset/config.json index ea412825..3bbc0553 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -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", diff --git a/.claude/agents/agent-translation-reviewer.md b/.claude/agents/agent-translation-reviewer.md index d9c29a27..c970be9f 100644 --- a/.claude/agents/agent-translation-reviewer.md +++ b/.claude/agents/agent-translation-reviewer.md @@ -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 @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..d10352dd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Codemod fixtures are compared byte for byte, CRLF and BOM included. +packages/codemods/src/transforms/testfixtures/** -text diff --git a/.gitignore b/.gitignore index 52444ef6..c00d39d1 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.pnp.cjs b/.pnp.cjs index e0ee88a6..61fc8508 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -27,8 +27,8 @@ const RAW_RUNTIME_STATE = "reference": "workspace:examples/with-vite"\ },\ {\ - "name": "react-simplikit-codemod",\ - "reference": "workspace:packages/codemod"\ + "name": "@react-simplikit/codemods",\ + "reference": "workspace:packages/codemods"\ },\ {\ "name": "react-simplikit",\ @@ -40,9 +40,9 @@ const RAW_RUNTIME_STATE = "pnpZipBackend": "libzip",\ "fallbackExclusionList": [\ ["@examples/shared", ["virtual:4859486b80a38e1e55778596b129478b56d21224c49a057e6f204bd0ef112f450c0ab6db41bd028bc885a6d06a104f1faffa30cd30b973c26726b0fe33e03341#workspace:examples/shared", "workspace:examples/shared"]],\ + ["@react-simplikit/codemods", ["workspace:packages/codemods"]],\ ["@react-simplikit/root", ["workspace:."]],\ ["react-simplikit", ["virtual:f9522faed4c7e558462ef89aa232afe8b28f40173b914f756ee38b21c9ce10bf830de8334e264bc007ff37043ac2a4f134dac81249be2bcb7033ff024ce27466#workspace:packages/react-simplikit", "workspace:packages/react-simplikit"]],\ - ["react-simplikit-codemod", ["workspace:packages/codemod"]],\ ["with-nextjs", ["workspace:examples/with-nextjs"]],\ ["with-vite", ["workspace:examples/with-vite"]]\ ],\ @@ -525,6 +525,28 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.13", {\ + "packageLocation": "./.yarn/cache/@babel-core-npm-7.29.13-5b3fcf96b6-7c9d372d63.zip/node_modules/@babel/core/",\ + "packageDependencies": [\ + ["@babel/code-frame", "npm:7.29.7"],\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/generator", "npm:7.29.15"],\ + ["@babel/helper-compilation-targets", "npm:7.29.13"],\ + ["@babel/helper-module-transforms", "virtual:5b3fcf96b634cb59b2dff15aa4eadd0e07ca456bf73139b1a988d8b24b232fd6a2c10517cbc5df07a284836ca24bf698fc477a3aae9be3cdd83b63a7812eabfd#npm:7.29.14"],\ + ["@babel/helpers", "npm:7.29.15"],\ + ["@babel/parser", "npm:7.29.15"],\ + ["@babel/template", "npm:7.29.7"],\ + ["@babel/traverse", "npm:7.29.15"],\ + ["@babel/types", "npm:7.29.15"],\ + ["@jridgewell/remapping", "npm:2.3.5"],\ + ["convert-source-map", "npm:2.0.0"],\ + ["debug", "virtual:78bc20dbf78cba6c65082eb5aff7e39fb1e65131367642c1c1f56d438aa3485100ac20e632291bf65b59c8dc6f30cf02e3c6b442edd0c12f687c22a4080aa3a2#npm:4.4.3"],\ + ["gensync", "npm:1.0.0-beta.2"],\ + ["json5", "npm:2.2.3"],\ + ["semver", "npm:6.3.1"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.7", {\ "packageLocation": "./.yarn/cache/@babel-core-npm-7.29.7-78bc20dbf7-112fb09c24.zip/node_modules/@babel/core/",\ "packageDependencies": [\ @@ -573,6 +595,18 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.15", {\ + "packageLocation": "./.yarn/cache/@babel-generator-npm-7.29.15-58df6df7d2-97f9cad815.zip/node_modules/@babel/generator/",\ + "packageDependencies": [\ + ["@babel/generator", "npm:7.29.15"],\ + ["@babel/parser", "npm:7.29.15"],\ + ["@babel/types", "npm:7.29.15"],\ + ["@jridgewell/gen-mapping", "npm:0.3.13"],\ + ["@jridgewell/trace-mapping", "npm:0.3.31"],\ + ["jsesc", "npm:3.1.0"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.8", {\ "packageLocation": "./.yarn/cache/@babel-generator-npm-7.29.8-00b0e7c8b6-7b89669631.zip/node_modules/@babel/generator/",\ "packageDependencies": [\ @@ -609,6 +643,18 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.13", {\ + "packageLocation": "./.yarn/cache/@babel-helper-compilation-targets-npm-7.29.13-2ec1e913ca-e134fb9379.zip/node_modules/@babel/helper-compilation-targets/",\ + "packageDependencies": [\ + ["@babel/compat-data", "npm:7.29.7"],\ + ["@babel/helper-compilation-targets", "npm:7.29.13"],\ + ["@babel/helper-validator-option", "npm:7.29.7"],\ + ["browserslist", "npm:4.28.1"],\ + ["lru-cache", "npm:5.1.1"],\ + ["semver", "npm:6.3.1"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.7", {\ "packageLocation": "./.yarn/cache/@babel-helper-compilation-targets-npm-7.29.7-7cb31cc38d-4c15fd4c69.zip/node_modules/@babel/helper-compilation-targets/",\ "packageDependencies": [\ @@ -630,6 +676,26 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ + ["virtual:1c87272e092ab93f70a554ed15ab2d4b0a78fab72f05e52d8cf44c9e5f5427951958fd4f0f0175e94b0114aa2b9b23b62fb05cdd4e74e121d0164b6cb446ad26#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-helper-create-class-features-plugin-virtual-259fa9cf78/0/cache/@babel-helper-create-class-features-plugin-npm-7.29.7-d2ad5f51e0-75f34905b5.zip/node_modules/@babel/helper-create-class-features-plugin/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-annotate-as-pure", "npm:7.29.7"],\ + ["@babel/helper-create-class-features-plugin", "virtual:1c87272e092ab93f70a554ed15ab2d4b0a78fab72f05e52d8cf44c9e5f5427951958fd4f0f0175e94b0114aa2b9b23b62fb05cdd4e74e121d0164b6cb446ad26#npm:7.29.7"],\ + ["@babel/helper-member-expression-to-functions", "npm:7.29.7"],\ + ["@babel/helper-optimise-call-expression", "npm:7.29.7"],\ + ["@babel/helper-replace-supers", "virtual:259fa9cf787a59fe47bc5b1b19b58d20739719d9ec2ee4a1764a95bc7305798445105eeeeba4cdee0ec330a4c7c2605ce4c74f90d6f9a2e2356c2d386ae665a1#npm:7.29.7"],\ + ["@babel/helper-skip-transparent-expression-wrappers", "npm:7.29.7"],\ + ["@babel/traverse", "npm:7.29.8"],\ + ["@types/babel__core", null],\ + ["semver", "npm:6.3.1"]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ ["virtual:65b457c958c1b0ab1232285afe5ed4ac405eb84b5ceb678adc05b2cfa735d95361ab1b499b9853a173b8bdecbf9e1526599751c89efb7109417b4964ce0542e6#npm:7.29.7", {\ "packageLocation": "./.yarn/__virtual__/@babel-helper-create-class-features-plugin-virtual-90d75268e5/0/cache/@babel-helper-create-class-features-plugin-npm-7.29.7-d2ad5f51e0-75f34905b5.zip/node_modules/@babel/helper-create-class-features-plugin/",\ "packageDependencies": [\ @@ -726,6 +792,13 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ + ["npm:7.29.14", {\ + "packageLocation": "./.yarn/cache/@babel-helper-module-transforms-npm-7.29.14-5891f46cef-5ca8b9c36d.zip/node_modules/@babel/helper-module-transforms/",\ + "packageDependencies": [\ + ["@babel/helper-module-transforms", "npm:7.29.14"]\ + ],\ + "linkType": "SOFT"\ + }],\ ["npm:7.29.7", {\ "packageLocation": "./.yarn/cache/@babel-helper-module-transforms-npm-7.29.7-50e1c84dbd-ee5a2172c2.zip/node_modules/@babel/helper-module-transforms/",\ "packageDependencies": [\ @@ -733,6 +806,38 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ + ["virtual:3e57fc8ea2706aed083311020f23a9288f3615a793b907a5ac327f19c8df5d5d497355b357ec8ed4bc62861cd094a686a40940ea4536fec548c49dff92212071#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-helper-module-transforms-virtual-1d369a60fa/0/cache/@babel-helper-module-transforms-npm-7.29.7-50e1c84dbd-ee5a2172c2.zip/node_modules/@babel/helper-module-transforms/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-module-imports", "npm:7.29.7"],\ + ["@babel/helper-module-transforms", "virtual:3e57fc8ea2706aed083311020f23a9288f3615a793b907a5ac327f19c8df5d5d497355b357ec8ed4bc62861cd094a686a40940ea4536fec548c49dff92212071#npm:7.29.7"],\ + ["@babel/helper-validator-identifier", "npm:7.29.7"],\ + ["@babel/traverse", "npm:7.29.8"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ + ["virtual:5b3fcf96b634cb59b2dff15aa4eadd0e07ca456bf73139b1a988d8b24b232fd6a2c10517cbc5df07a284836ca24bf698fc477a3aae9be3cdd83b63a7812eabfd#npm:7.29.14", {\ + "packageLocation": "./.yarn/__virtual__/@babel-helper-module-transforms-virtual-41125cb75b/0/cache/@babel-helper-module-transforms-npm-7.29.14-5891f46cef-5ca8b9c36d.zip/node_modules/@babel/helper-module-transforms/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-module-imports", "npm:7.29.7"],\ + ["@babel/helper-module-transforms", "virtual:5b3fcf96b634cb59b2dff15aa4eadd0e07ca456bf73139b1a988d8b24b232fd6a2c10517cbc5df07a284836ca24bf698fc477a3aae9be3cdd83b63a7812eabfd#npm:7.29.14"],\ + ["@babel/helper-validator-identifier", "npm:7.29.7"],\ + ["@babel/traverse", "npm:7.29.15"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ ["virtual:78bc20dbf78cba6c65082eb5aff7e39fb1e65131367642c1c1f56d438aa3485100ac20e632291bf65b59c8dc6f30cf02e3c6b442edd0c12f687c22a4080aa3a2#npm:7.29.7", {\ "packageLocation": "./.yarn/__virtual__/@babel-helper-module-transforms-virtual-bb17ae9247/0/cache/@babel-helper-module-transforms-npm-7.29.7-50e1c84dbd-ee5a2172c2.zip/node_modules/@babel/helper-module-transforms/",\ "packageDependencies": [\ @@ -816,6 +921,22 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ + ["virtual:259fa9cf787a59fe47bc5b1b19b58d20739719d9ec2ee4a1764a95bc7305798445105eeeeba4cdee0ec330a4c7c2605ce4c74f90d6f9a2e2356c2d386ae665a1#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-helper-replace-supers-virtual-b361cc0909/0/cache/@babel-helper-replace-supers-npm-7.29.7-d22238da67-1c7ae37797.zip/node_modules/@babel/helper-replace-supers/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-member-expression-to-functions", "npm:7.29.7"],\ + ["@babel/helper-optimise-call-expression", "npm:7.29.7"],\ + ["@babel/helper-replace-supers", "virtual:259fa9cf787a59fe47bc5b1b19b58d20739719d9ec2ee4a1764a95bc7305798445105eeeeba4cdee0ec330a4c7c2605ce4c74f90d6f9a2e2356c2d386ae665a1#npm:7.29.7"],\ + ["@babel/traverse", "npm:7.29.8"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ ["virtual:90d75268e5ac7ddaa9c237e3e429c2608fd0bca11bfc2901f68ec981aba219fb19eb2c287211868dbfe63b991a41589f4af572c5b5d22b6c03c0228a18d0bfa2#npm:7.29.7", {\ "packageLocation": "./.yarn/__virtual__/@babel-helper-replace-supers-virtual-2f15e3743b/0/cache/@babel-helper-replace-supers-npm-7.29.7-d22238da67-1c7ae37797.zip/node_modules/@babel/helper-replace-supers/",\ "packageDependencies": [\ @@ -875,6 +996,13 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.15", {\ + "packageLocation": "./.yarn/cache/@babel-helper-string-parser-npm-7.29.15-58c9032885-8d130fb596.zip/node_modules/@babel/helper-string-parser/",\ + "packageDependencies": [\ + ["@babel/helper-string-parser", "npm:7.29.15"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.7", {\ "packageLocation": "./.yarn/cache/@babel-helper-string-parser-npm-7.29.7-87998d618e-194bc0f171.zip/node_modules/@babel/helper-string-parser/",\ "packageDependencies": [\ @@ -932,6 +1060,15 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.15", {\ + "packageLocation": "./.yarn/cache/@babel-helpers-npm-7.29.15-3b78a70898-181786000e.zip/node_modules/@babel/helpers/",\ + "packageDependencies": [\ + ["@babel/helpers", "npm:7.29.15"],\ + ["@babel/template", "npm:7.29.7"],\ + ["@babel/types", "npm:7.29.15"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.7", {\ "packageLocation": "./.yarn/cache/@babel-helpers-npm-7.29.7-97e81ccfb9-218e8d1095.zip/node_modules/@babel/helpers/",\ "packageDependencies": [\ @@ -959,6 +1096,14 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.15", {\ + "packageLocation": "./.yarn/cache/@babel-parser-npm-7.29.15-5e1d9e46ec-5fca335e83.zip/node_modules/@babel/parser/",\ + "packageDependencies": [\ + ["@babel/parser", "npm:7.29.15"],\ + ["@babel/types", "npm:7.29.15"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.8", {\ "packageLocation": "./.yarn/cache/@babel-parser-npm-7.29.8-d8ac19f8b3-acc890c5e6.zip/node_modules/@babel/parser/",\ "packageDependencies": [\ @@ -968,6 +1113,29 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@babel/plugin-syntax-flow", [\ + ["npm:7.29.7", {\ + "packageLocation": "./.yarn/cache/@babel-plugin-syntax-flow-npm-7.29.7-d41f3a60ad-b2e330dd0d.zip/node_modules/@babel/plugin-syntax-flow/",\ + "packageDependencies": [\ + ["@babel/plugin-syntax-flow", "npm:7.29.7"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:b1942f79a6351498b1a82b20c64fae905686b687d3822be13f8ebdb64e72960bf16a9c6ff5bd3d6f045d5679569caeb1f4981ab4a7cf033cb515f198a08724a0#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-syntax-flow-virtual-055b1c28aa/0/cache/@babel-plugin-syntax-flow-npm-7.29.7-d41f3a60ad-b2e330dd0d.zip/node_modules/@babel/plugin-syntax-flow/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-syntax-flow", "virtual:b1942f79a6351498b1a82b20c64fae905686b687d3822be13f8ebdb64e72960bf16a9c6ff5bd3d6f045d5679569caeb1f4981ab4a7cf033cb515f198a08724a0#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["@babel/plugin-syntax-jsx", [\ ["npm:7.29.7", {\ "packageLocation": "./.yarn/cache/@babel-plugin-syntax-jsx-npm-7.29.7-887bb0abd4-1736000de1.zip/node_modules/@babel/plugin-syntax-jsx/",\ @@ -990,6 +1158,20 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-syntax-jsx-virtual-4366414622/0/cache/@babel-plugin-syntax-jsx-npm-7.29.7-887bb0abd4-1736000de1.zip/node_modules/@babel/plugin-syntax-jsx/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-syntax-jsx", "virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ ["virtual:f0a69a80aa93c72b8183fa4e2bd271e350dc27cbf0bdf475c51786598dca3506a6a2674eded4d43a31998a9e758ddb54df4f533b47431330a58b63224152f456#npm:7.29.7", {\ "packageLocation": "./.yarn/__virtual__/@babel-plugin-syntax-jsx-virtual-276656c690/0/cache/@babel-plugin-syntax-jsx-npm-7.29.7-887bb0abd4-1736000de1.zip/node_modules/@babel/plugin-syntax-jsx/",\ "packageDependencies": [\ @@ -1027,6 +1209,20 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["virtual:e0c4ad9acb491ff65cfc4287c4187dca9f4a7e631e561dd80305bf6e8d516cf37e3e641d34c5e7fa9a45fae31f18cefbb32aa4bd690f48ce8496f40278974502#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-syntax-typescript-virtual-95c2ea26ea/0/cache/@babel-plugin-syntax-typescript-npm-7.29.7-4784fd3786-c49883b032.zip/node_modules/@babel/plugin-syntax-typescript/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-syntax-typescript", "virtual:e0c4ad9acb491ff65cfc4287c4187dca9f4a7e631e561dd80305bf6e8d516cf37e3e641d34c5e7fa9a45fae31f18cefbb32aa4bd690f48ce8496f40278974502#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ ["virtual:e7c551a16c57969ebf8096aada1d823164eb010d59db092ec51aec254b2c39f856a8faaac18027b9f7ab95c9fbebfda01f9949bde984ae5e8481ce822eddad0b#npm:7.29.7", {\ "packageLocation": "./.yarn/__virtual__/@babel-plugin-syntax-typescript-virtual-2116fc4e41/0/cache/@babel-plugin-syntax-typescript-npm-7.29.7-4784fd3786-c49883b032.zip/node_modules/@babel/plugin-syntax-typescript/",\ "packageDependencies": [\ @@ -1042,7 +1238,62 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@babel/plugin-transform-class-properties", [\ + ["npm:7.29.7", {\ + "packageLocation": "./.yarn/cache/@babel-plugin-transform-class-properties-npm-7.29.7-f4102291f1-c370700423.zip/node_modules/@babel/plugin-transform-class-properties/",\ + "packageDependencies": [\ + ["@babel/plugin-transform-class-properties", "npm:7.29.7"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-class-properties-virtual-1c87272e09/0/cache/@babel-plugin-transform-class-properties-npm-7.29.7-f4102291f1-c370700423.zip/node_modules/@babel/plugin-transform-class-properties/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-create-class-features-plugin", "virtual:1c87272e092ab93f70a554ed15ab2d4b0a78fab72f05e52d8cf44c9e5f5427951958fd4f0f0175e94b0114aa2b9b23b62fb05cdd4e74e121d0164b6cb446ad26#npm:7.29.7"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-transform-class-properties", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["@babel/plugin-transform-flow-strip-types", [\ + ["npm:7.29.7", {\ + "packageLocation": "./.yarn/cache/@babel-plugin-transform-flow-strip-types-npm-7.29.7-7d249e90ed-083e864a60.zip/node_modules/@babel/plugin-transform-flow-strip-types/",\ + "packageDependencies": [\ + ["@babel/plugin-transform-flow-strip-types", "npm:7.29.7"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:dfe8404fe1ef6ad34a90af5f6b90e321a5f74fdc0dd293775aa8073d14d8fc8d0092aa64dcd120b678f5af3ca9d515bab4566bee660eeccc3960c91fd129925d#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-flow-strip-types-virtual-b1942f79a6/0/cache/@babel-plugin-transform-flow-strip-types-npm-7.29.7-7d249e90ed-083e864a60.zip/node_modules/@babel/plugin-transform-flow-strip-types/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-syntax-flow", "virtual:b1942f79a6351498b1a82b20c64fae905686b687d3822be13f8ebdb64e72960bf16a9c6ff5bd3d6f045d5679569caeb1f4981ab4a7cf033cb515f198a08724a0#npm:7.29.7"],\ + ["@babel/plugin-transform-flow-strip-types", "virtual:dfe8404fe1ef6ad34a90af5f6b90e321a5f74fdc0dd293775aa8073d14d8fc8d0092aa64dcd120b678f5af3ca9d515bab4566bee660eeccc3960c91fd129925d#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["@babel/plugin-transform-modules-commonjs", [\ + ["npm:7.29.14", {\ + "packageLocation": "./.yarn/cache/@babel-plugin-transform-modules-commonjs-npm-7.29.14-00070601d8-daa4863b57.zip/node_modules/@babel/plugin-transform-modules-commonjs/",\ + "packageDependencies": [\ + ["@babel/plugin-transform-modules-commonjs", "npm:7.29.14"]\ + ],\ + "linkType": "SOFT"\ + }],\ ["npm:7.29.7", {\ "packageLocation": "./.yarn/cache/@babel-plugin-transform-modules-commonjs-npm-7.29.7-4e669a8fff-9791cb5244.zip/node_modules/@babel/plugin-transform-modules-commonjs/",\ "packageDependencies": [\ @@ -1079,6 +1330,107 @@ const RAW_RUNTIME_STATE = "@types/babel__core"\ ],\ "linkType": "HARD"\ + }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.14", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-modules-commonjs-virtual-23bb9b7c76/0/cache/@babel-plugin-transform-modules-commonjs-npm-7.29.14-00070601d8-daa4863b57.zip/node_modules/@babel/plugin-transform-modules-commonjs/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-module-transforms", "virtual:5b3fcf96b634cb59b2dff15aa4eadd0e07ca456bf73139b1a988d8b24b232fd6a2c10517cbc5df07a284836ca24bf698fc477a3aae9be3cdd83b63a7812eabfd#npm:7.29.14"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-transform-modules-commonjs", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.14"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ + ["virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-modules-commonjs-virtual-3e57fc8ea2/0/cache/@babel-plugin-transform-modules-commonjs-npm-7.29.7-4e669a8fff-9791cb5244.zip/node_modules/@babel/plugin-transform-modules-commonjs/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-module-transforms", "virtual:3e57fc8ea2706aed083311020f23a9288f3615a793b907a5ac327f19c8df5d5d497355b357ec8ed4bc62861cd094a686a40940ea4536fec548c49dff92212071#npm:7.29.7"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-transform-modules-commonjs", "virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["@babel/plugin-transform-nullish-coalescing-operator", [\ + ["npm:7.29.7", {\ + "packageLocation": "./.yarn/cache/@babel-plugin-transform-nullish-coalescing-operator-npm-7.29.7-1ea8485d4f-b0c186fe38.zip/node_modules/@babel/plugin-transform-nullish-coalescing-operator/",\ + "packageDependencies": [\ + ["@babel/plugin-transform-nullish-coalescing-operator", "npm:7.29.7"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-nullish-coalescing-operator-virtual-02690de539/0/cache/@babel-plugin-transform-nullish-coalescing-operator-npm-7.29.7-1ea8485d4f-b0c186fe38.zip/node_modules/@babel/plugin-transform-nullish-coalescing-operator/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-transform-nullish-coalescing-operator", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["@babel/plugin-transform-optional-chaining", [\ + ["npm:7.29.7", {\ + "packageLocation": "./.yarn/cache/@babel-plugin-transform-optional-chaining-npm-7.29.7-968c69098f-71feacf9a7.zip/node_modules/@babel/plugin-transform-optional-chaining/",\ + "packageDependencies": [\ + ["@babel/plugin-transform-optional-chaining", "npm:7.29.7"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-optional-chaining-virtual-871c7019b8/0/cache/@babel-plugin-transform-optional-chaining-npm-7.29.7-968c69098f-71feacf9a7.zip/node_modules/@babel/plugin-transform-optional-chaining/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/helper-skip-transparent-expression-wrappers", "npm:7.29.7"],\ + ["@babel/plugin-transform-optional-chaining", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["@babel/plugin-transform-private-methods", [\ + ["npm:7.29.7", {\ + "packageLocation": "./.yarn/cache/@babel-plugin-transform-private-methods-npm-7.29.7-a97d685cc4-d0dc12fa47.zip/node_modules/@babel/plugin-transform-private-methods/",\ + "packageDependencies": [\ + ["@babel/plugin-transform-private-methods", "npm:7.29.7"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-private-methods-virtual-ceb7212291/0/cache/@babel-plugin-transform-private-methods-npm-7.29.7-a97d685cc4-d0dc12fa47.zip/node_modules/@babel/plugin-transform-private-methods/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-create-class-features-plugin", "virtual:1c87272e092ab93f70a554ed15ab2d4b0a78fab72f05e52d8cf44c9e5f5427951958fd4f0f0175e94b0114aa2b9b23b62fb05cdd4e74e121d0164b6cb446ad26#npm:7.29.7"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/plugin-transform-private-methods", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/plugin-transform-react-display-name", [\ @@ -1328,6 +1680,49 @@ const RAW_RUNTIME_STATE = "@types/babel__core"\ ],\ "linkType": "HARD"\ + }],\ + ["virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-plugin-transform-typescript-virtual-e0c4ad9acb/0/cache/@babel-plugin-transform-typescript-npm-7.29.7-2404b035ea-8bf6a89c68.zip/node_modules/@babel/plugin-transform-typescript/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-annotate-as-pure", "npm:7.29.7"],\ + ["@babel/helper-create-class-features-plugin", "virtual:1c87272e092ab93f70a554ed15ab2d4b0a78fab72f05e52d8cf44c9e5f5427951958fd4f0f0175e94b0114aa2b9b23b62fb05cdd4e74e121d0164b6cb446ad26#npm:7.29.7"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/helper-skip-transparent-expression-wrappers", "npm:7.29.7"],\ + ["@babel/plugin-syntax-typescript", "virtual:e0c4ad9acb491ff65cfc4287c4187dca9f4a7e631e561dd80305bf6e8d516cf37e3e641d34c5e7fa9a45fae31f18cefbb32aa4bd690f48ce8496f40278974502#npm:7.29.7"],\ + ["@babel/plugin-transform-typescript", "virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["@babel/preset-flow", [\ + ["npm:7.29.7", {\ + "packageLocation": "./.yarn/cache/@babel-preset-flow-npm-7.29.7-4e249acd3e-17bb0f3c32.zip/node_modules/@babel/preset-flow/",\ + "packageDependencies": [\ + ["@babel/preset-flow", "npm:7.29.7"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-preset-flow-virtual-dfe8404fe1/0/cache/@babel-preset-flow-npm-7.29.7-4e249acd3e-17bb0f3c32.zip/node_modules/@babel/preset-flow/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/helper-validator-option", "npm:7.29.7"],\ + ["@babel/plugin-transform-flow-strip-types", "virtual:dfe8404fe1ef6ad34a90af5f6b90e321a5f74fdc0dd293775aa8073d14d8fc8d0092aa64dcd120b678f5af3ca9d515bab4566bee660eeccc3960c91fd129925d#npm:7.29.7"],\ + ["@babel/preset-flow", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/preset-react", [\ @@ -1403,6 +1798,24 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7", {\ + "packageLocation": "./.yarn/__virtual__/@babel-preset-typescript-virtual-e01efff20f/0/cache/@babel-preset-typescript-npm-7.29.7-2dbc1e1fa1-40746a23a7.zip/node_modules/@babel/preset-typescript/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/helper-plugin-utils", "npm:7.29.7"],\ + ["@babel/helper-validator-option", "npm:7.29.7"],\ + ["@babel/plugin-syntax-jsx", "virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7"],\ + ["@babel/plugin-transform-modules-commonjs", "virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7"],\ + ["@babel/plugin-transform-typescript", "virtual:e01efff20fd9acc4f19e542caeafcd9ff871bf36ade9f10cbd320570950df014f3bd7ef9109b5bcaefde4f34e3d56102ce82f78bf57002027508d91da792aff2#npm:7.29.7"],\ + ["@babel/preset-typescript", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@types/babel__core", null]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }],\ ["virtual:b56f0089fd6bbc50c1ee8b8d8292f9775083cd3f4a49b1638a575e3e5b72c85e2feb87e77cd91c36e2981f2ec9d091c75dbf7357203484f4404306471644e05b#npm:7.29.7", {\ "packageLocation": "./.yarn/__virtual__/@babel-preset-typescript-virtual-09b2e858e0/0/cache/@babel-preset-typescript-npm-7.29.7-2dbc1e1fa1-40746a23a7.zip/node_modules/@babel/preset-typescript/",\ "packageDependencies": [\ @@ -1422,6 +1835,33 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@babel/register", [\ + ["npm:7.29.13", {\ + "packageLocation": "./.yarn/cache/@babel-register-npm-7.29.13-71dc9ab68f-b0840cd10d.zip/node_modules/@babel/register/",\ + "packageDependencies": [\ + ["@babel/register", "npm:7.29.13"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.13", {\ + "packageLocation": "./.yarn/__virtual__/@babel-register-virtual-f69f76641c/0/cache/@babel-register-npm-7.29.13-71dc9ab68f-b0840cd10d.zip/node_modules/@babel/register/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/register", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.13"],\ + ["@types/babel__core", null],\ + ["clone-deep", "npm:4.0.1"],\ + ["find-cache-dir", "npm:2.1.0"],\ + ["make-dir", "npm:2.1.0"],\ + ["pirates", "npm:4.0.7"],\ + ["source-map-support", "npm:0.5.21"]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["@babel/runtime", [\ ["npm:7.27.0", {\ "packageLocation": "./.yarn/cache/@babel-runtime-npm-7.27.0-67ce9cb54f-35091ea9de.zip/node_modules/@babel/runtime/",\ @@ -1493,6 +1933,20 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.15", {\ + "packageLocation": "./.yarn/cache/@babel-traverse-npm-7.29.15-9d2806c3fb-e598deea5d.zip/node_modules/@babel/traverse/",\ + "packageDependencies": [\ + ["@babel/code-frame", "npm:7.29.7"],\ + ["@babel/generator", "npm:7.29.15"],\ + ["@babel/helper-globals", "npm:7.29.7"],\ + ["@babel/parser", "npm:7.29.15"],\ + ["@babel/template", "npm:7.29.7"],\ + ["@babel/traverse", "npm:7.29.15"],\ + ["@babel/types", "npm:7.29.15"],\ + ["debug", "virtual:58d4eddcdc0ee4d794e83431bdb8379b5cdb1cb447327371fa6788426546f859224b451f3786f45cf7d5e32704eff5b143722c948eb1c4c79c95d68fed8731a4#npm:4.4.0"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.8", {\ "packageLocation": "./.yarn/cache/@babel-traverse-npm-7.29.8-58d4eddcdc-87a28989c4.zip/node_modules/@babel/traverse/",\ "packageDependencies": [\ @@ -1527,6 +1981,15 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:7.29.15", {\ + "packageLocation": "./.yarn/cache/@babel-types-npm-7.29.15-c461d07a10-2a153a44da.zip/node_modules/@babel/types/",\ + "packageDependencies": [\ + ["@babel/helper-string-parser", "npm:7.29.15"],\ + ["@babel/helper-validator-identifier", "npm:7.29.7"],\ + ["@babel/types", "npm:7.29.15"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.29.8", {\ "packageLocation": "./.yarn/cache/@babel-types-npm-7.29.8-3f9597fc63-be7c279f0a.zip/node_modules/@babel/types/",\ "packageDependencies": [\ @@ -5490,6 +5953,32 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@react-simplikit/codemods", [\ + ["workspace:packages/codemods", {\ + "packageLocation": "./packages/codemods/",\ + "packageDependencies": [\ + ["@react-simplikit/codemods", "workspace:packages/codemods"],\ + ["@types/jscodeshift", "npm:17.3.0"],\ + ["@types/node", "npm:24.13.3"],\ + ["@types/prompts", "npm:2.4.9"],\ + ["@types/semver", "npm:7.8.0"],\ + ["@vitest/coverage-v8", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:2.1.9"],\ + ["commander", "npm:13.1.0"],\ + ["detect-indent", "npm:7.0.2"],\ + ["eslint", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:9.39.3"],\ + ["execa", "npm:5.1.1"],\ + ["fast-check", "npm:4.9.0"],\ + ["jscodeshift", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:17.4.0"],\ + ["prompts", "npm:2.4.2"],\ + ["rimraf", "npm:6.0.1"],\ + ["semver", "npm:7.8.5"],\ + ["tsdown", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:0.22.14"],\ + ["typescript", "patch:typescript@npm%3A5.8.3#optional!builtin::version=5.8.3&hash=5786d5"],\ + ["vitest", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:2.1.9"]\ + ],\ + "linkType": "SOFT"\ + }]\ + ]],\ ["@react-simplikit/root", [\ ["workspace:.", {\ "packageLocation": "./",\ @@ -6392,6 +6881,17 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@types/jscodeshift", [\ + ["npm:17.3.0", {\ + "packageLocation": "./.yarn/cache/@types-jscodeshift-npm-17.3.0-9d561ff9c7-56b889b290.zip/node_modules/@types/jscodeshift/",\ + "packageDependencies": [\ + ["@types/jscodeshift", "npm:17.3.0"],\ + ["ast-types", "npm:0.16.3"],\ + ["recast", "npm:0.23.21"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["@types/json-schema", [\ ["npm:7.0.15", {\ "packageLocation": "./.yarn/cache/@types-json-schema-npm-7.0.15-fd16381786-a996a745e6.zip/node_modules/@types/json-schema/",\ @@ -6466,6 +6966,25 @@ const RAW_RUNTIME_STATE = ["undici-types", "npm:7.18.2"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:26.6.6", {\ + "packageLocation": "./.yarn/cache/@types-node-npm-26.6.6-a217a0974b-5cb63f644f.zip/node_modules/@types/node/",\ + "packageDependencies": [\ + ["@types/node", "npm:26.6.6"],\ + ["undici-types", "npm:8.9.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["@types/prompts", [\ + ["npm:2.4.9", {\ + "packageLocation": "./.yarn/cache/@types-prompts-npm-2.4.9-a99ca98ad4-22fe0da680.zip/node_modules/@types/prompts/",\ + "packageDependencies": [\ + ["@types/node", "npm:26.6.6"],\ + ["@types/prompts", "npm:2.4.9"],\ + ["kleur", "npm:3.0.3"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@types/react", [\ @@ -6881,15 +7400,15 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:2.1.9", {\ - "packageLocation": "./.yarn/__virtual__/@vitest-coverage-v8-virtual-d52f271ef0/0/cache/@vitest-coverage-v8-npm-2.1.9-95e7812374-ccf5871954.zip/node_modules/@vitest/coverage-v8/",\ + ["virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9", {\ + "packageLocation": "./.yarn/__virtual__/@vitest-coverage-v8-virtual-bbfa947c4e/0/cache/@vitest-coverage-v8-npm-2.1.9-95e7812374-ccf5871954.zip/node_modules/@vitest/coverage-v8/",\ "packageDependencies": [\ ["@ampproject/remapping", "npm:2.3.0"],\ ["@bcoe/v8-coverage", "npm:0.2.3"],\ ["@types/vitest", null],\ ["@types/vitest__browser", null],\ ["@vitest/browser", null],\ - ["@vitest/coverage-v8", "virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:2.1.9"],\ + ["@vitest/coverage-v8", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9"],\ ["debug", "virtual:58d4eddcdc0ee4d794e83431bdb8379b5cdb1cb447327371fa6788426546f859224b451f3786f45cf7d5e32704eff5b143722c948eb1c4c79c95d68fed8731a4#npm:4.4.0"],\ ["istanbul-lib-coverage", "npm:3.2.2"],\ ["istanbul-lib-report", "npm:3.0.1"],\ @@ -6900,7 +7419,7 @@ const RAW_RUNTIME_STATE = ["std-env", "npm:3.9.0"],\ ["test-exclude", "npm:7.0.1"],\ ["tinyrainbow", "npm:1.2.0"],\ - ["vitest", "virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:2.1.9"]\ + ["vitest", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9"]\ ],\ "packagePeers": [\ "@types/vitest",\ @@ -6910,15 +7429,15 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9", {\ - "packageLocation": "./.yarn/__virtual__/@vitest-coverage-v8-virtual-bbfa947c4e/0/cache/@vitest-coverage-v8-npm-2.1.9-95e7812374-ccf5871954.zip/node_modules/@vitest/coverage-v8/",\ + ["virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:2.1.9", {\ + "packageLocation": "./.yarn/__virtual__/@vitest-coverage-v8-virtual-5f5c83e10c/0/cache/@vitest-coverage-v8-npm-2.1.9-95e7812374-ccf5871954.zip/node_modules/@vitest/coverage-v8/",\ "packageDependencies": [\ ["@ampproject/remapping", "npm:2.3.0"],\ ["@bcoe/v8-coverage", "npm:0.2.3"],\ ["@types/vitest", null],\ ["@types/vitest__browser", null],\ ["@vitest/browser", null],\ - ["@vitest/coverage-v8", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9"],\ + ["@vitest/coverage-v8", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:2.1.9"],\ ["debug", "virtual:58d4eddcdc0ee4d794e83431bdb8379b5cdb1cb447327371fa6788426546f859224b451f3786f45cf7d5e32704eff5b143722c948eb1c4c79c95d68fed8731a4#npm:4.4.0"],\ ["istanbul-lib-coverage", "npm:3.2.2"],\ ["istanbul-lib-report", "npm:3.0.1"],\ @@ -6929,7 +7448,7 @@ const RAW_RUNTIME_STATE = ["std-env", "npm:3.9.0"],\ ["test-exclude", "npm:7.0.1"],\ ["tinyrainbow", "npm:1.2.0"],\ - ["vitest", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9"]\ + ["vitest", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:2.1.9"]\ ],\ "packagePeers": [\ "@types/vitest",\ @@ -7872,6 +8391,16 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["ast-types", [\ + ["npm:0.16.3", {\ + "packageLocation": "./.yarn/cache/ast-types-npm-0.16.3-8ba975e569-a49ff15529.zip/node_modules/ast-types/",\ + "packageDependencies": [\ + ["ast-types", "npm:0.16.3"],\ + ["tslib", "npm:2.9.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["async-function", [\ ["npm:1.0.0", {\ "packageLocation": "./.yarn/cache/async-function-npm-1.0.0-a81667ebcd-669a32c2cb.zip/node_modules/async-function/",\ @@ -8004,6 +8533,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["buffer-from", [\ + ["npm:1.1.2", {\ + "packageLocation": "./.yarn/cache/buffer-from-npm-1.1.2-03d2f20d7e-124fff9d66.zip/node_modules/buffer-from/",\ + "packageDependencies": [\ + ["buffer-from", "npm:1.1.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["cac", [\ ["npm:6.7.14", {\ "packageLocation": "./.yarn/cache/cac-npm-6.7.14-c46284e425-4ee06aaa7b.zip/node_modules/cac/",\ @@ -8310,6 +8848,18 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["clone-deep", [\ + ["npm:4.0.1", {\ + "packageLocation": "./.yarn/cache/clone-deep-npm-4.0.1-70adab92c8-637753615a.zip/node_modules/clone-deep/",\ + "packageDependencies": [\ + ["clone-deep", "npm:4.0.1"],\ + ["is-plain-object", "npm:2.0.4"],\ + ["kind-of", "npm:6.0.3"],\ + ["shallow-clone", "npm:3.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["color-convert", [\ ["npm:2.0.1", {\ "packageLocation": "./.yarn/cache/color-convert-npm-2.0.1-79730e935b-37e1150172.zip/node_modules/color-convert/",\ @@ -8382,6 +8932,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["commondir", [\ + ["npm:1.0.1", {\ + "packageLocation": "./.yarn/cache/commondir-npm-1.0.1-291b790340-33a124960e.zip/node_modules/commondir/",\ + "packageDependencies": [\ + ["commondir", "npm:1.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["concat-map", [\ ["npm:0.0.1", {\ "packageLocation": "./.yarn/cache/concat-map-npm-0.0.1-85a921b7ee-c996b1cfdf.zip/node_modules/concat-map/",\ @@ -9823,6 +10382,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["esprima", [\ + ["npm:4.0.1", {\ + "packageLocation": "./.yarn/cache/esprima-npm-4.0.1-1084e98778-ad4bab9ead.zip/node_modules/esprima/",\ + "packageDependencies": [\ + ["esprima", "npm:4.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["esquery", [\ ["npm:1.6.0", {\ "packageLocation": "./.yarn/cache/esquery-npm-1.6.0-16fee31531-cb9065ec60.zip/node_modules/esquery/",\ @@ -9887,6 +10455,24 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["execa", [\ + ["npm:5.1.1", {\ + "packageLocation": "./.yarn/cache/execa-npm-5.1.1-191347acf5-c8e615235e.zip/node_modules/execa/",\ + "packageDependencies": [\ + ["cross-spawn", "npm:7.0.6"],\ + ["execa", "npm:5.1.1"],\ + ["get-stream", "npm:6.0.1"],\ + ["human-signals", "npm:2.1.0"],\ + ["is-stream", "npm:2.0.1"],\ + ["merge-stream", "npm:2.0.0"],\ + ["npm-run-path", "npm:4.0.1"],\ + ["onetime", "npm:5.1.2"],\ + ["signal-exit", "npm:3.0.7"],\ + ["strip-final-newline", "npm:2.0.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["expect-type", [\ ["npm:1.2.1", {\ "packageLocation": "./.yarn/cache/expect-type-npm-1.2.1-5a68fc99bd-b775c9adab.zip/node_modules/expect-type/",\ @@ -10111,13 +10697,33 @@ const RAW_RUNTIME_STATE = ["npm:7.1.1", {\ "packageLocation": "./.yarn/cache/fill-range-npm-7.1.1-bf491486db-b75b691bbe.zip/node_modules/fill-range/",\ "packageDependencies": [\ - ["fill-range", "npm:7.1.1"],\ - ["to-regex-range", "npm:5.0.1"]\ + ["fill-range", "npm:7.1.1"],\ + ["to-regex-range", "npm:5.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["find-cache-dir", [\ + ["npm:2.1.0", {\ + "packageLocation": "./.yarn/cache/find-cache-dir-npm-2.1.0-772aa82638-556117fd0a.zip/node_modules/find-cache-dir/",\ + "packageDependencies": [\ + ["commondir", "npm:1.0.1"],\ + ["find-cache-dir", "npm:2.1.0"],\ + ["make-dir", "npm:2.1.0"],\ + ["pkg-dir", "npm:3.0.0"]\ ],\ "linkType": "HARD"\ }]\ ]],\ ["find-up", [\ + ["npm:3.0.0", {\ + "packageLocation": "./.yarn/cache/find-up-npm-3.0.0-a2d4b1b317-2c2e7d0a26.zip/node_modules/find-up/",\ + "packageDependencies": [\ + ["find-up", "npm:3.0.0"],\ + ["locate-path", "npm:3.0.0"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:5.0.0", {\ "packageLocation": "./.yarn/cache/find-up-npm-5.0.0-e03e9b796d-062c5a83a9.zip/node_modules/find-up/",\ "packageDependencies": [\ @@ -10148,6 +10754,25 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["flow-estree", [\ + ["npm:0.342.0", {\ + "packageLocation": "./.yarn/cache/flow-estree-npm-0.342.0-938b4a97c9-66d538a0aa.zip/node_modules/flow-estree/",\ + "packageDependencies": [\ + ["flow-estree", "npm:0.342.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["flow-parser", [\ + ["npm:0.342.0", {\ + "packageLocation": "./.yarn/cache/flow-parser-npm-0.342.0-59c20c8e43-c3d78c96c4.zip/node_modules/flow-parser/",\ + "packageDependencies": [\ + ["flow-estree", "npm:0.342.0"],\ + ["flow-parser", "npm:0.342.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["focus-trap", [\ ["npm:7.6.4", {\ "packageLocation": "./.yarn/cache/focus-trap-npm-7.6.4-d90a1ce800-ed810d47fd.zip/node_modules/focus-trap/",\ @@ -10320,6 +10945,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["get-stream", [\ + ["npm:6.0.1", {\ + "packageLocation": "./.yarn/cache/get-stream-npm-6.0.1-83e51a4642-49825d57d3.zip/node_modules/get-stream/",\ + "packageDependencies": [\ + ["get-stream", "npm:6.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["get-symbol-description", [\ ["npm:1.1.0", {\ "packageLocation": "./.yarn/cache/get-symbol-description-npm-1.1.0-7a9e0b1c24-d6a7d6afca.zip/node_modules/get-symbol-description/",\ @@ -10446,6 +11080,13 @@ const RAW_RUNTIME_STATE = ["graceful-fs", "npm:4.2.11"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:4.2.12", {\ + "packageLocation": "./.yarn/cache/graceful-fs-npm-4.2.12-b83a8a0530-a4e2ccd9fe.zip/node_modules/graceful-fs/",\ + "packageDependencies": [\ + ["graceful-fs", "npm:4.2.12"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["graphemer", [\ @@ -10666,6 +11307,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["human-signals", [\ + ["npm:2.1.0", {\ + "packageLocation": "./.yarn/cache/human-signals-npm-2.1.0-f75815481d-695edb3edf.zip/node_modules/human-signals/",\ + "packageDependencies": [\ + ["human-signals", "npm:2.1.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["iconv-lite", [\ ["npm:0.6.3", {\ "packageLocation": "./.yarn/cache/iconv-lite-npm-0.6.3-24b8aae27e-98102bc66b.zip/node_modules/iconv-lite/",\ @@ -10966,6 +11616,16 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["is-plain-object", [\ + ["npm:2.0.4", {\ + "packageLocation": "./.yarn/cache/is-plain-object-npm-2.0.4-da3265d804-f050fdd520.zip/node_modules/is-plain-object/",\ + "packageDependencies": [\ + ["is-plain-object", "npm:2.0.4"],\ + ["isobject", "npm:3.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["is-potential-custom-element-name", [\ ["npm:1.0.1", {\ "packageLocation": "./.yarn/cache/is-potential-custom-element-name-npm-1.0.1-f352f606f8-b73e2f22bc.zip/node_modules/is-potential-custom-element-name/",\ @@ -11007,6 +11667,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["is-stream", [\ + ["npm:2.0.1", {\ + "packageLocation": "./.yarn/cache/is-stream-npm-2.0.1-c802db55e7-7c28424131.zip/node_modules/is-stream/",\ + "packageDependencies": [\ + ["is-stream", "npm:2.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["is-string", [\ ["npm:1.1.1", {\ "packageLocation": "./.yarn/cache/is-string-npm-1.1.1-d2c4f9f448-2f518b4e47.zip/node_modules/is-string/",\ @@ -11120,6 +11789,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["isobject", [\ + ["npm:3.0.1", {\ + "packageLocation": "./.yarn/cache/isobject-npm-3.0.1-8145901fd2-03344f5064.zip/node_modules/isobject/",\ + "packageDependencies": [\ + ["isobject", "npm:3.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["istanbul-lib-coverage", [\ ["npm:3.2.2", {\ "packageLocation": "./.yarn/cache/istanbul-lib-coverage-npm-3.2.2-5c0526e059-6c7ff21067.zip/node_modules/istanbul-lib-coverage/",\ @@ -11252,6 +11930,46 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["jscodeshift", [\ + ["npm:17.4.0", {\ + "packageLocation": "./.yarn/cache/jscodeshift-npm-17.4.0-4a91744f82-ef7b71c22f.zip/node_modules/jscodeshift/",\ + "packageDependencies": [\ + ["jscodeshift", "npm:17.4.0"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:17.4.0", {\ + "packageLocation": "./.yarn/__virtual__/jscodeshift-virtual-578ca3fbde/0/cache/jscodeshift-npm-17.4.0-4a91744f82-ef7b71c22f.zip/node_modules/jscodeshift/",\ + "packageDependencies": [\ + ["@babel/core", "npm:7.29.13"],\ + ["@babel/parser", "npm:7.29.15"],\ + ["@babel/plugin-transform-class-properties", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@babel/plugin-transform-modules-commonjs", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.14"],\ + ["@babel/plugin-transform-nullish-coalescing-operator", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@babel/plugin-transform-optional-chaining", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@babel/plugin-transform-private-methods", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@babel/preset-env", null],\ + ["@babel/preset-flow", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@babel/preset-typescript", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.7"],\ + ["@babel/register", "virtual:578ca3fbdea970e4323f6994f9fc4a3e3f825fd3835e3c20777cd80b24767bd2b2ef1edbfb4c29cb3a18a427933e3f03fe1d134555788d978ae470a5ac794dea#npm:7.29.13"],\ + ["@types/babel__preset-env", null],\ + ["flow-parser", "npm:0.342.0"],\ + ["graceful-fs", "npm:4.2.12"],\ + ["jscodeshift", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:17.4.0"],\ + ["neo-async", "npm:2.6.2"],\ + ["picocolors", "npm:1.1.1"],\ + ["picomatch", "npm:4.0.2"],\ + ["recast", "npm:0.23.21"],\ + ["tmp", "npm:0.2.7"],\ + ["write-file-atomic", "npm:5.0.1"]\ + ],\ + "packagePeers": [\ + "@babel/preset-env",\ + "@types/babel__preset-env"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["jsdom", [\ ["npm:25.0.1", {\ "packageLocation": "./.yarn/cache/jsdom-npm-25.0.1-ccbb1f9cda-6bda32a6df.zip/node_modules/jsdom/",\ @@ -11389,6 +12107,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["kleur", [\ + ["npm:3.0.3", {\ + "packageLocation": "./.yarn/cache/kleur-npm-3.0.3-f6f53649a4-cd3a0b8878.zip/node_modules/kleur/",\ + "packageDependencies": [\ + ["kleur", "npm:3.0.3"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["launch-editor", [\ ["npm:2.14.1", {\ "packageLocation": "./.yarn/cache/launch-editor-npm-2.14.1-72c53f4965-bb0ab18208.zip/node_modules/launch-editor/",\ @@ -11437,6 +12164,15 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["locate-path", [\ + ["npm:3.0.0", {\ + "packageLocation": "./.yarn/cache/locate-path-npm-3.0.0-991671ae9f-3db394b782.zip/node_modules/locate-path/",\ + "packageDependencies": [\ + ["locate-path", "npm:3.0.0"],\ + ["p-locate", "npm:3.0.0"],\ + ["path-exists", "npm:3.0.0"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:6.0.0", {\ "packageLocation": "./.yarn/cache/locate-path-npm-6.0.0-06a1e4c528-d3972ab70d.zip/node_modules/locate-path/",\ "packageDependencies": [\ @@ -11580,6 +12316,15 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["make-dir", [\ + ["npm:2.1.0", {\ + "packageLocation": "./.yarn/cache/make-dir-npm-2.1.0-1ddaf205e7-ada869944d.zip/node_modules/make-dir/",\ + "packageDependencies": [\ + ["make-dir", "npm:2.1.0"],\ + ["pify", "npm:4.0.1"],\ + ["semver", "npm:5.7.3"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:4.0.0", {\ "packageLocation": "./.yarn/cache/make-dir-npm-4.0.0-ec3cd921cc-69b98a6c0b.zip/node_modules/make-dir/",\ "packageDependencies": [\ @@ -11791,6 +12536,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["merge-stream", [\ + ["npm:2.0.0", {\ + "packageLocation": "./.yarn/cache/merge-stream-npm-2.0.0-2ac83efea5-867fdbb30a.zip/node_modules/merge-stream/",\ + "packageDependencies": [\ + ["merge-stream", "npm:2.0.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["merge2", [\ ["npm:1.4.1", {\ "packageLocation": "./.yarn/cache/merge2-npm-1.4.1-a2507bd06c-254a8a4605.zip/node_modules/merge2/",\ @@ -12114,6 +12868,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["mimic-fn", [\ + ["npm:2.1.0", {\ + "packageLocation": "./.yarn/cache/mimic-fn-npm-2.1.0-4fbeb3abb4-b26f5479d7.zip/node_modules/mimic-fn/",\ + "packageDependencies": [\ + ["mimic-fn", "npm:2.1.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["mimic-function", [\ ["npm:5.0.1", {\ "packageLocation": "./.yarn/cache/mimic-function-npm-5.0.1-5078456e31-f3d9464dd1.zip/node_modules/mimic-function/",\ @@ -12346,6 +13109,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["neo-async", [\ + ["npm:2.6.2", {\ + "packageLocation": "./.yarn/cache/neo-async-npm-2.6.2-75d6902586-c2f5a604a5.zip/node_modules/neo-async/",\ + "packageDependencies": [\ + ["neo-async", "npm:2.6.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["next", [\ ["npm:15.5.9", {\ "packageLocation": "./.yarn/cache/next-npm-15.5.9-c16f969d8a-6a120afbc4.zip/node_modules/next/",\ @@ -12453,6 +13225,16 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["npm-run-path", [\ + ["npm:4.0.1", {\ + "packageLocation": "./.yarn/cache/npm-run-path-npm-4.0.1-7aebd8bab3-6f9353a952.zip/node_modules/npm-run-path/",\ + "packageDependencies": [\ + ["npm-run-path", "npm:4.0.1"],\ + ["path-key", "npm:3.1.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["nwsapi", [\ ["npm:2.2.20", {\ "packageLocation": "./.yarn/cache/nwsapi-npm-2.2.20-276b791049-07f4dafa31.zip/node_modules/nwsapi/",\ @@ -12565,6 +13347,14 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["onetime", [\ + ["npm:5.1.2", {\ + "packageLocation": "./.yarn/cache/onetime-npm-5.1.2-3ed148fa42-ffcef6fbb2.zip/node_modules/onetime/",\ + "packageDependencies": [\ + ["mimic-fn", "npm:2.1.0"],\ + ["onetime", "npm:5.1.2"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:7.0.0", {\ "packageLocation": "./.yarn/cache/onetime-npm-7.0.0-cfdd2a579d-5cb9179d74.zip/node_modules/onetime/",\ "packageDependencies": [\ @@ -12632,6 +13422,14 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["p-limit", [\ + ["npm:2.3.0", {\ + "packageLocation": "./.yarn/cache/p-limit-npm-2.3.0-94a0310039-8da01ac53e.zip/node_modules/p-limit/",\ + "packageDependencies": [\ + ["p-limit", "npm:2.3.0"],\ + ["p-try", "npm:2.2.0"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:3.1.0", {\ "packageLocation": "./.yarn/cache/p-limit-npm-3.1.0-05d2ede37f-9db675949d.zip/node_modules/p-limit/",\ "packageDependencies": [\ @@ -12642,6 +13440,14 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["p-locate", [\ + ["npm:3.0.0", {\ + "packageLocation": "./.yarn/cache/p-locate-npm-3.0.0-74de74f952-7b7f06f718.zip/node_modules/p-locate/",\ + "packageDependencies": [\ + ["p-limit", "npm:2.3.0"],\ + ["p-locate", "npm:3.0.0"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:5.0.0", {\ "packageLocation": "./.yarn/cache/p-locate-npm-5.0.0-92cc7c7a3e-2290d627ab.zip/node_modules/p-locate/",\ "packageDependencies": [\ @@ -12660,6 +13466,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["p-try", [\ + ["npm:2.2.0", {\ + "packageLocation": "./.yarn/cache/p-try-npm-2.2.0-e0390dbaf8-c36c199077.zip/node_modules/p-try/",\ + "packageDependencies": [\ + ["p-try", "npm:2.2.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["package-json-from-dist", [\ ["npm:1.0.1", {\ "packageLocation": "./.yarn/cache/package-json-from-dist-npm-1.0.1-4631a88465-62ba2785eb.zip/node_modules/package-json-from-dist/",\ @@ -12723,6 +13538,13 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["path-exists", [\ + ["npm:3.0.0", {\ + "packageLocation": "./.yarn/cache/path-exists-npm-3.0.0-e80371aa68-17d6a5664b.zip/node_modules/path-exists/",\ + "packageDependencies": [\ + ["path-exists", "npm:3.0.0"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:4.0.0", {\ "packageLocation": "./.yarn/cache/path-exists-npm-4.0.0-e9e4f63eb0-8c0bd3f523.zip/node_modules/path-exists/",\ "packageDependencies": [\ @@ -12844,6 +13666,34 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["pify", [\ + ["npm:4.0.1", {\ + "packageLocation": "./.yarn/cache/pify-npm-4.0.1-062756097b-6f9d404b0d.zip/node_modules/pify/",\ + "packageDependencies": [\ + ["pify", "npm:4.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["pirates", [\ + ["npm:4.0.7", {\ + "packageLocation": "./.yarn/cache/pirates-npm-4.0.7-5e4ee2f078-a51f108dd8.zip/node_modules/pirates/",\ + "packageDependencies": [\ + ["pirates", "npm:4.0.7"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["pkg-dir", [\ + ["npm:3.0.0", {\ + "packageLocation": "./.yarn/cache/pkg-dir-npm-3.0.0-16d8d93783-902a3d0c1f.zip/node_modules/pkg-dir/",\ + "packageDependencies": [\ + ["find-up", "npm:3.0.0"],\ + ["pkg-dir", "npm:3.0.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["possible-typed-array-names", [\ ["npm:1.1.0", {\ "packageLocation": "./.yarn/cache/possible-typed-array-names-npm-1.1.0-ce60ca4401-c810983414.zip/node_modules/possible-typed-array-names/",\ @@ -12986,6 +13836,17 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["prompts", [\ + ["npm:2.4.2", {\ + "packageLocation": "./.yarn/cache/prompts-npm-2.4.2-f5d25d5eea-16f1ac2977.zip/node_modules/prompts/",\ + "packageDependencies": [\ + ["kleur", "npm:3.0.3"],\ + ["prompts", "npm:2.4.2"],\ + ["sisteransi", "npm:1.0.5"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["prop-types", [\ ["npm:15.8.1", {\ "packageLocation": "./.yarn/cache/prop-types-npm-15.8.1-17c71ee7ee-59ece7ca2f.zip/node_modules/prop-types/",\ @@ -13416,28 +14277,6 @@ const RAW_RUNTIME_STATE = "linkType": "SOFT"\ }]\ ]],\ - ["react-simplikit-codemod", [\ - ["workspace:packages/codemod", {\ - "packageLocation": "./packages/codemod/",\ - "packageDependencies": [\ - ["@types/node", "npm:24.13.3"],\ - ["@types/semver", "npm:7.8.0"],\ - ["@vitest/coverage-v8", "virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:2.1.9"],\ - ["commander", "npm:13.1.0"],\ - ["detect-indent", "npm:7.0.2"],\ - ["eslint", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:9.39.3"],\ - ["fast-check", "npm:4.9.0"],\ - ["fast-glob", "npm:3.3.3"],\ - ["react-simplikit-codemod", "workspace:packages/codemod"],\ - ["rimraf", "npm:6.0.1"],\ - ["semver", "npm:7.8.5"],\ - ["tsdown", "virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:0.22.14"],\ - ["typescript", "patch:typescript@npm%3A5.8.3#optional!builtin::version=5.8.3&hash=5786d5"],\ - ["vitest", "virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:2.1.9"]\ - ],\ - "linkType": "SOFT"\ - }]\ - ]],\ ["react-style-singleton", [\ ["npm:2.2.3", {\ "packageLocation": "./.yarn/cache/react-style-singleton-npm-2.2.3-18f32c05f7-841938ff16.zip/node_modules/react-style-singleton/",\ @@ -13462,6 +14301,20 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["recast", [\ + ["npm:0.23.21", {\ + "packageLocation": "./.yarn/cache/recast-npm-0.23.21-1e626d51b5-afee4673fd.zip/node_modules/recast/",\ + "packageDependencies": [\ + ["ast-types", "npm:0.16.3"],\ + ["esprima", "npm:4.0.1"],\ + ["recast", "npm:0.23.21"],\ + ["source-map", "npm:0.6.1"],\ + ["tiny-invariant", "npm:1.3.3"],\ + ["tslib", "npm:2.9.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["redent", [\ ["npm:3.0.0", {\ "packageLocation": "./.yarn/cache/redent-npm-3.0.0-31892f4906-d64a6b5c0b.zip/node_modules/redent/",\ @@ -13939,6 +14792,13 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["semver", [\ + ["npm:5.7.3", {\ + "packageLocation": "./.yarn/cache/semver-npm-5.7.3-2620585b81-46308a549d.zip/node_modules/semver/",\ + "packageDependencies": [\ + ["semver", "npm:5.7.3"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:6.3.1", {\ "packageLocation": "./.yarn/cache/semver-npm-6.3.1-bcba31fdbe-e3d79b6090.zip/node_modules/semver/",\ "packageDependencies": [\ @@ -14017,6 +14877,16 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["shallow-clone", [\ + ["npm:3.0.1", {\ + "packageLocation": "./.yarn/cache/shallow-clone-npm-3.0.1-dab5873d0d-7bab09613a.zip/node_modules/shallow-clone/",\ + "packageDependencies": [\ + ["kind-of", "npm:6.0.3"],\ + ["shallow-clone", "npm:3.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["sharp", [\ ["npm:0.34.5", {\ "packageLocation": "./.yarn/unplugged/sharp-npm-0.34.5-dc08218742/node_modules/sharp/",\ @@ -14160,6 +15030,13 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["signal-exit", [\ + ["npm:3.0.7", {\ + "packageLocation": "./.yarn/cache/signal-exit-npm-3.0.7-bd270458a3-25d272fa73.zip/node_modules/signal-exit/",\ + "packageDependencies": [\ + ["signal-exit", "npm:3.0.7"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:4.1.0", {\ "packageLocation": "./.yarn/cache/signal-exit-npm-4.1.0-61fb957687-41602dce54.zip/node_modules/signal-exit/",\ "packageDependencies": [\ @@ -14239,6 +15116,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["source-map", [\ + ["npm:0.6.1", {\ + "packageLocation": "./.yarn/cache/source-map-npm-0.6.1-1a3621db16-ab55398007.zip/node_modules/source-map/",\ + "packageDependencies": [\ + ["source-map", "npm:0.6.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["source-map-js", [\ ["npm:1.2.1", {\ "packageLocation": "./.yarn/cache/source-map-js-npm-1.2.1-b9a47d7e1a-7bda1fc4c1.zip/node_modules/source-map-js/",\ @@ -14248,6 +15134,17 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["source-map-support", [\ + ["npm:0.5.21", {\ + "packageLocation": "./.yarn/cache/source-map-support-npm-0.5.21-09ca99e250-9ee09942f4.zip/node_modules/source-map-support/",\ + "packageDependencies": [\ + ["buffer-from", "npm:1.1.2"],\ + ["source-map", "npm:0.6.1"],\ + ["source-map-support", "npm:0.5.21"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["space-separated-tokens", [\ ["npm:2.0.2", {\ "packageLocation": "./.yarn/cache/space-separated-tokens-npm-2.0.2-b7ff42c9c6-6173e1d903.zip/node_modules/space-separated-tokens/",\ @@ -14456,6 +15353,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["strip-final-newline", [\ + ["npm:2.0.0", {\ + "packageLocation": "./.yarn/cache/strip-final-newline-npm-2.0.0-340c4f7c66-bddf8ccd47.zip/node_modules/strip-final-newline/",\ + "packageDependencies": [\ + ["strip-final-newline", "npm:2.0.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["strip-indent", [\ ["npm:3.0.0", {\ "packageLocation": "./.yarn/cache/strip-indent-npm-3.0.0-519e75a28d-ae0deaf41c.zip/node_modules/strip-indent/",\ @@ -14622,6 +15528,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["tiny-invariant", [\ + ["npm:1.3.3", {\ + "packageLocation": "./.yarn/cache/tiny-invariant-npm-1.3.3-e622f1447c-65af4a0732.zip/node_modules/tiny-invariant/",\ + "packageDependencies": [\ + ["tiny-invariant", "npm:1.3.3"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["tinybench", [\ ["npm:2.9.0", {\ "packageLocation": "./.yarn/cache/tinybench-npm-2.9.0-2861a048db-c3500b0f60.zip/node_modules/tinybench/",\ @@ -14722,6 +15637,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["tmp", [\ + ["npm:0.2.7", {\ + "packageLocation": "./.yarn/cache/tmp-npm-0.2.7-a6fd3441a0-59eb55584f.zip/node_modules/tmp/",\ + "packageDependencies": [\ + ["tmp", "npm:0.2.7"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["to-regex-range", [\ ["npm:5.0.1", {\ "packageLocation": "./.yarn/cache/to-regex-range-npm-5.0.1-f1e8263b00-487988b0a1.zip/node_modules/to-regex-range/",\ @@ -14831,8 +15755,8 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:0.22.14", {\ - "packageLocation": "./.yarn/__virtual__/tsdown-virtual-c5db08016e/0/cache/tsdown-npm-0.22.14-7b27e81b56-d299516472.zip/node_modules/tsdown/",\ + ["virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:0.22.14", {\ + "packageLocation": "./.yarn/__virtual__/tsdown-virtual-9b2026e2a5/0/cache/tsdown-npm-0.22.14-7b27e81b56-d299516472.zip/node_modules/tsdown/",\ "packageDependencies": [\ ["@arethetypeswrong/core", null],\ ["@tsdown/css", null],\ @@ -14855,14 +15779,14 @@ const RAW_RUNTIME_STATE = ["import-without-cache", "npm:0.4.0"],\ ["obug", "npm:2.1.4"],\ ["picomatch", "npm:4.0.5"],\ - ["publint", null],\ + ["publint", "npm:0.3.23"],\ ["rolldown", "npm:1.2.3"],\ ["rolldown-plugin-dts", "virtual:9b2026e2a5c195a2a5556b41c45b99fc716e5f23011bb5566a3500d2b09f1817c312a85dcc93e569164970677831e4e18893629dc7110f3cf1c8cb32ef4a2222#npm:0.27.14"],\ ["tinyexec", "npm:1.3.0"],\ ["tinyglobby", "npm:0.2.17"],\ ["tree-kill", "npm:1.2.2"],\ - ["tsdown", "virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:0.22.14"],\ - ["tsx", null],\ + ["tsdown", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:0.22.14"],\ + ["tsx", "npm:4.19.3"],\ ["typescript", "patch:typescript@npm%3A5.8.3#optional!builtin::version=5.8.3&hash=5786d5"],\ ["unconfig-core", "npm:7.5.0"],\ ["unplugin-unused", null],\ @@ -14891,8 +15815,8 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:0.22.14", {\ - "packageLocation": "./.yarn/__virtual__/tsdown-virtual-9b2026e2a5/0/cache/tsdown-npm-0.22.14-7b27e81b56-d299516472.zip/node_modules/tsdown/",\ + ["virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:0.22.14", {\ + "packageLocation": "./.yarn/__virtual__/tsdown-virtual-568323b643/0/cache/tsdown-npm-0.22.14-7b27e81b56-d299516472.zip/node_modules/tsdown/",\ "packageDependencies": [\ ["@arethetypeswrong/core", null],\ ["@tsdown/css", null],\ @@ -14915,14 +15839,14 @@ const RAW_RUNTIME_STATE = ["import-without-cache", "npm:0.4.0"],\ ["obug", "npm:2.1.4"],\ ["picomatch", "npm:4.0.5"],\ - ["publint", "npm:0.3.23"],\ + ["publint", null],\ ["rolldown", "npm:1.2.3"],\ ["rolldown-plugin-dts", "virtual:9b2026e2a5c195a2a5556b41c45b99fc716e5f23011bb5566a3500d2b09f1817c312a85dcc93e569164970677831e4e18893629dc7110f3cf1c8cb32ef4a2222#npm:0.27.14"],\ ["tinyexec", "npm:1.3.0"],\ ["tinyglobby", "npm:0.2.17"],\ ["tree-kill", "npm:1.2.2"],\ - ["tsdown", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:0.22.14"],\ - ["tsx", "npm:4.19.3"],\ + ["tsdown", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:0.22.14"],\ + ["tsx", null],\ ["typescript", "patch:typescript@npm%3A5.8.3#optional!builtin::version=5.8.3&hash=5786d5"],\ ["unconfig-core", "npm:7.5.0"],\ ["unplugin-unused", null],\ @@ -15019,6 +15943,13 @@ const RAW_RUNTIME_STATE = ["tslib", "npm:2.8.1"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:2.9.1", {\ + "packageLocation": "./.yarn/cache/tslib-npm-2.9.1-1db60cfff0-8ff46e7a4d.zip/node_modules/tslib/",\ + "packageDependencies": [\ + ["tslib", "npm:2.9.1"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["tsx", [\ @@ -15205,6 +16136,13 @@ const RAW_RUNTIME_STATE = ["undici-types", "npm:7.18.2"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:8.9.0", {\ + "packageLocation": "./.yarn/cache/undici-types-npm-8.9.0-c5953f392d-51c712c20c.zip/node_modules/undici-types/",\ + "packageDependencies": [\ + ["undici-types", "npm:8.9.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["unicode-emoji-modifier-base", [\ @@ -15719,8 +16657,8 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:2.1.9", {\ - "packageLocation": "./.yarn/__virtual__/vitest-virtual-d4ecfdcaab/0/cache/vitest-npm-2.1.9-da245b091d-e339e16dcc.zip/node_modules/vitest/",\ + ["virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9", {\ + "packageLocation": "./.yarn/__virtual__/vitest-virtual-ccf0e2d0ea/0/cache/vitest-npm-2.1.9-da245b091d-e339e16dcc.zip/node_modules/vitest/",\ "packageDependencies": [\ ["@edge-runtime/vm", null],\ ["@types/edge-runtime__vm", null],\ @@ -15742,7 +16680,7 @@ const RAW_RUNTIME_STATE = ["debug", "virtual:58d4eddcdc0ee4d794e83431bdb8379b5cdb1cb447327371fa6788426546f859224b451f3786f45cf7d5e32704eff5b143722c948eb1c4c79c95d68fed8731a4#npm:4.4.0"],\ ["expect-type", "npm:1.2.1"],\ ["happy-dom", null],\ - ["jsdom", null],\ + ["jsdom", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:25.0.1"],\ ["magic-string", "npm:0.30.17"],\ ["pathe", "npm:1.1.2"],\ ["std-env", "npm:3.9.0"],\ @@ -15752,7 +16690,7 @@ const RAW_RUNTIME_STATE = ["tinyrainbow", "npm:1.2.0"],\ ["vite", "virtual:ccf0e2d0eac3795ab66e6a4c9ff7b7003116638fc068b9d64678f895760944d6a3593bbc1528b322f00ad7bfcf13dc1be6761cc90f0095ba1e674b7015e97bbb#npm:5.4.18"],\ ["vite-node", "npm:2.1.9"],\ - ["vitest", "virtual:153e8f447525e06c796c624afc450ca80110e691444c20ef3fd083f9f36ec27493159562bfd3886ca8f0cd515e71b00ae6ae6da1d8e5015decd4eb6706180574#npm:2.1.9"],\ + ["vitest", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9"],\ ["why-is-node-running", "npm:2.3.0"]\ ],\ "packagePeers": [\ @@ -15770,8 +16708,8 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9", {\ - "packageLocation": "./.yarn/__virtual__/vitest-virtual-ccf0e2d0ea/0/cache/vitest-npm-2.1.9-da245b091d-e339e16dcc.zip/node_modules/vitest/",\ + ["virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:2.1.9", {\ + "packageLocation": "./.yarn/__virtual__/vitest-virtual-c44292a148/0/cache/vitest-npm-2.1.9-da245b091d-e339e16dcc.zip/node_modules/vitest/",\ "packageDependencies": [\ ["@edge-runtime/vm", null],\ ["@types/edge-runtime__vm", null],\ @@ -15793,7 +16731,7 @@ const RAW_RUNTIME_STATE = ["debug", "virtual:58d4eddcdc0ee4d794e83431bdb8379b5cdb1cb447327371fa6788426546f859224b451f3786f45cf7d5e32704eff5b143722c948eb1c4c79c95d68fed8731a4#npm:4.4.0"],\ ["expect-type", "npm:1.2.1"],\ ["happy-dom", null],\ - ["jsdom", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:25.0.1"],\ + ["jsdom", null],\ ["magic-string", "npm:0.30.17"],\ ["pathe", "npm:1.1.2"],\ ["std-env", "npm:3.9.0"],\ @@ -15803,7 +16741,7 @@ const RAW_RUNTIME_STATE = ["tinyrainbow", "npm:1.2.0"],\ ["vite", "virtual:ccf0e2d0eac3795ab66e6a4c9ff7b7003116638fc068b9d64678f895760944d6a3593bbc1528b322f00ad7bfcf13dc1be6761cc90f0095ba1e674b7015e97bbb#npm:5.4.18"],\ ["vite-node", "npm:2.1.9"],\ - ["vitest", "virtual:539b451571f0988c0af51257f55a5a782178df937d372062375b750931875a6facac716a154eb2b4aa1e0ffc809cf9d1dd6a0b387bd1b99854bdf0c986f9a560#npm:2.1.9"],\ + ["vitest", "virtual:7fda7b2bba982d2f717f4194b882cdedef4d2925b6ba76c3aed5bce1c6abc1fc297a23123ed02fda253e805e88cce2b28622626aade6ee1029299e45e70fbf71#npm:2.1.9"],\ ["why-is-node-running", "npm:2.3.0"]\ ],\ "packagePeers": [\ @@ -16089,6 +17027,17 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["write-file-atomic", [\ + ["npm:5.0.1", {\ + "packageLocation": "./.yarn/cache/write-file-atomic-npm-5.0.1-52283db6ee-e8c850a8e3.zip/node_modules/write-file-atomic/",\ + "packageDependencies": [\ + ["imurmurhash", "npm:0.1.4"],\ + ["signal-exit", "npm:4.1.0"],\ + ["write-file-atomic", "npm:5.0.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["ws", [\ ["npm:8.18.1", {\ "packageLocation": "./.yarn/cache/ws-npm-8.18.1-369b0f5491-e498965d69.zip/node_modules/ws/",\ diff --git a/.prettierignore b/.prettierignore index 51713e3f..bd6f8a0f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -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 diff --git a/.scripts/verify-compiler/index.ts b/.scripts/verify-compiler/index.ts index fdd756eb..7205cbac 100644 --- a/.scripts/verify-compiler/index.ts +++ b/.scripts/verify-compiler/index.ts @@ -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. diff --git a/.scripts/verifySkill.ts b/.scripts/verifySkill.ts index 94c57411..2766eb23 100644 --- a/.scripts/verifySkill.ts +++ b/.scripts/verifySkill.ts @@ -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( diff --git a/.yarn/cache/@babel-core-npm-7.29.13-5b3fcf96b6-7c9d372d63.zip b/.yarn/cache/@babel-core-npm-7.29.13-5b3fcf96b6-7c9d372d63.zip new file mode 100644 index 00000000..9dbc24c3 Binary files /dev/null and b/.yarn/cache/@babel-core-npm-7.29.13-5b3fcf96b6-7c9d372d63.zip differ diff --git a/.yarn/cache/@babel-generator-npm-7.29.15-58df6df7d2-97f9cad815.zip b/.yarn/cache/@babel-generator-npm-7.29.15-58df6df7d2-97f9cad815.zip new file mode 100644 index 00000000..dc877a36 Binary files /dev/null and b/.yarn/cache/@babel-generator-npm-7.29.15-58df6df7d2-97f9cad815.zip differ diff --git a/.yarn/cache/@babel-helper-compilation-targets-npm-7.29.13-2ec1e913ca-e134fb9379.zip b/.yarn/cache/@babel-helper-compilation-targets-npm-7.29.13-2ec1e913ca-e134fb9379.zip new file mode 100644 index 00000000..1b75c595 Binary files /dev/null and b/.yarn/cache/@babel-helper-compilation-targets-npm-7.29.13-2ec1e913ca-e134fb9379.zip differ diff --git a/.yarn/cache/@babel-helper-module-transforms-npm-7.29.14-5891f46cef-5ca8b9c36d.zip b/.yarn/cache/@babel-helper-module-transforms-npm-7.29.14-5891f46cef-5ca8b9c36d.zip new file mode 100644 index 00000000..34d6a6f6 Binary files /dev/null and b/.yarn/cache/@babel-helper-module-transforms-npm-7.29.14-5891f46cef-5ca8b9c36d.zip differ diff --git a/.yarn/cache/@babel-helper-string-parser-npm-7.29.15-58c9032885-8d130fb596.zip b/.yarn/cache/@babel-helper-string-parser-npm-7.29.15-58c9032885-8d130fb596.zip new file mode 100644 index 00000000..d7c1eba2 Binary files /dev/null and b/.yarn/cache/@babel-helper-string-parser-npm-7.29.15-58c9032885-8d130fb596.zip differ diff --git a/.yarn/cache/@babel-helpers-npm-7.29.15-3b78a70898-181786000e.zip b/.yarn/cache/@babel-helpers-npm-7.29.15-3b78a70898-181786000e.zip new file mode 100644 index 00000000..dc637353 Binary files /dev/null and b/.yarn/cache/@babel-helpers-npm-7.29.15-3b78a70898-181786000e.zip differ diff --git a/.yarn/cache/@babel-parser-npm-7.29.15-5e1d9e46ec-5fca335e83.zip b/.yarn/cache/@babel-parser-npm-7.29.15-5e1d9e46ec-5fca335e83.zip new file mode 100644 index 00000000..00316bfe Binary files /dev/null and b/.yarn/cache/@babel-parser-npm-7.29.15-5e1d9e46ec-5fca335e83.zip differ diff --git a/.yarn/cache/@babel-plugin-syntax-flow-npm-7.29.7-d41f3a60ad-b2e330dd0d.zip b/.yarn/cache/@babel-plugin-syntax-flow-npm-7.29.7-d41f3a60ad-b2e330dd0d.zip new file mode 100644 index 00000000..160e8876 Binary files /dev/null and b/.yarn/cache/@babel-plugin-syntax-flow-npm-7.29.7-d41f3a60ad-b2e330dd0d.zip differ diff --git a/.yarn/cache/@babel-plugin-transform-class-properties-npm-7.29.7-f4102291f1-c370700423.zip b/.yarn/cache/@babel-plugin-transform-class-properties-npm-7.29.7-f4102291f1-c370700423.zip new file mode 100644 index 00000000..5807b77e Binary files /dev/null and b/.yarn/cache/@babel-plugin-transform-class-properties-npm-7.29.7-f4102291f1-c370700423.zip differ diff --git a/.yarn/cache/@babel-plugin-transform-flow-strip-types-npm-7.29.7-7d249e90ed-083e864a60.zip b/.yarn/cache/@babel-plugin-transform-flow-strip-types-npm-7.29.7-7d249e90ed-083e864a60.zip new file mode 100644 index 00000000..45c4a030 Binary files /dev/null and b/.yarn/cache/@babel-plugin-transform-flow-strip-types-npm-7.29.7-7d249e90ed-083e864a60.zip differ diff --git a/.yarn/cache/@babel-plugin-transform-modules-commonjs-npm-7.29.14-00070601d8-daa4863b57.zip b/.yarn/cache/@babel-plugin-transform-modules-commonjs-npm-7.29.14-00070601d8-daa4863b57.zip new file mode 100644 index 00000000..4e318161 Binary files /dev/null and b/.yarn/cache/@babel-plugin-transform-modules-commonjs-npm-7.29.14-00070601d8-daa4863b57.zip differ diff --git a/.yarn/cache/@babel-plugin-transform-nullish-coalescing-operator-npm-7.29.7-1ea8485d4f-b0c186fe38.zip b/.yarn/cache/@babel-plugin-transform-nullish-coalescing-operator-npm-7.29.7-1ea8485d4f-b0c186fe38.zip new file mode 100644 index 00000000..8eb92d5b Binary files /dev/null and b/.yarn/cache/@babel-plugin-transform-nullish-coalescing-operator-npm-7.29.7-1ea8485d4f-b0c186fe38.zip differ diff --git a/.yarn/cache/@babel-plugin-transform-optional-chaining-npm-7.29.7-968c69098f-71feacf9a7.zip b/.yarn/cache/@babel-plugin-transform-optional-chaining-npm-7.29.7-968c69098f-71feacf9a7.zip new file mode 100644 index 00000000..dc6f2c57 Binary files /dev/null and b/.yarn/cache/@babel-plugin-transform-optional-chaining-npm-7.29.7-968c69098f-71feacf9a7.zip differ diff --git a/.yarn/cache/@babel-plugin-transform-private-methods-npm-7.29.7-a97d685cc4-d0dc12fa47.zip b/.yarn/cache/@babel-plugin-transform-private-methods-npm-7.29.7-a97d685cc4-d0dc12fa47.zip new file mode 100644 index 00000000..4a159dad Binary files /dev/null and b/.yarn/cache/@babel-plugin-transform-private-methods-npm-7.29.7-a97d685cc4-d0dc12fa47.zip differ diff --git a/.yarn/cache/@babel-preset-flow-npm-7.29.7-4e249acd3e-17bb0f3c32.zip b/.yarn/cache/@babel-preset-flow-npm-7.29.7-4e249acd3e-17bb0f3c32.zip new file mode 100644 index 00000000..d4c2cae6 Binary files /dev/null and b/.yarn/cache/@babel-preset-flow-npm-7.29.7-4e249acd3e-17bb0f3c32.zip differ diff --git a/.yarn/cache/@babel-register-npm-7.29.13-71dc9ab68f-b0840cd10d.zip b/.yarn/cache/@babel-register-npm-7.29.13-71dc9ab68f-b0840cd10d.zip new file mode 100644 index 00000000..ced30d66 Binary files /dev/null and b/.yarn/cache/@babel-register-npm-7.29.13-71dc9ab68f-b0840cd10d.zip differ diff --git a/.yarn/cache/@babel-traverse-npm-7.29.15-9d2806c3fb-e598deea5d.zip b/.yarn/cache/@babel-traverse-npm-7.29.15-9d2806c3fb-e598deea5d.zip new file mode 100644 index 00000000..d7128531 Binary files /dev/null and b/.yarn/cache/@babel-traverse-npm-7.29.15-9d2806c3fb-e598deea5d.zip differ diff --git a/.yarn/cache/@babel-types-npm-7.29.15-c461d07a10-2a153a44da.zip b/.yarn/cache/@babel-types-npm-7.29.15-c461d07a10-2a153a44da.zip new file mode 100644 index 00000000..fe158fec Binary files /dev/null and b/.yarn/cache/@babel-types-npm-7.29.15-c461d07a10-2a153a44da.zip differ diff --git a/.yarn/cache/@types-jscodeshift-npm-17.3.0-9d561ff9c7-56b889b290.zip b/.yarn/cache/@types-jscodeshift-npm-17.3.0-9d561ff9c7-56b889b290.zip new file mode 100644 index 00000000..df549370 Binary files /dev/null and b/.yarn/cache/@types-jscodeshift-npm-17.3.0-9d561ff9c7-56b889b290.zip differ diff --git a/.yarn/cache/@types-node-npm-26.6.6-a217a0974b-5cb63f644f.zip b/.yarn/cache/@types-node-npm-26.6.6-a217a0974b-5cb63f644f.zip new file mode 100644 index 00000000..542c84e7 Binary files /dev/null and b/.yarn/cache/@types-node-npm-26.6.6-a217a0974b-5cb63f644f.zip differ diff --git a/.yarn/cache/@types-prompts-npm-2.4.9-a99ca98ad4-22fe0da680.zip b/.yarn/cache/@types-prompts-npm-2.4.9-a99ca98ad4-22fe0da680.zip new file mode 100644 index 00000000..807a0727 Binary files /dev/null and b/.yarn/cache/@types-prompts-npm-2.4.9-a99ca98ad4-22fe0da680.zip differ diff --git a/.yarn/cache/ast-types-npm-0.16.3-8ba975e569-a49ff15529.zip b/.yarn/cache/ast-types-npm-0.16.3-8ba975e569-a49ff15529.zip new file mode 100644 index 00000000..46de2398 Binary files /dev/null and b/.yarn/cache/ast-types-npm-0.16.3-8ba975e569-a49ff15529.zip differ diff --git a/.yarn/cache/buffer-from-npm-1.1.2-03d2f20d7e-124fff9d66.zip b/.yarn/cache/buffer-from-npm-1.1.2-03d2f20d7e-124fff9d66.zip new file mode 100644 index 00000000..d48c74cb Binary files /dev/null and b/.yarn/cache/buffer-from-npm-1.1.2-03d2f20d7e-124fff9d66.zip differ diff --git a/.yarn/cache/clone-deep-npm-4.0.1-70adab92c8-637753615a.zip b/.yarn/cache/clone-deep-npm-4.0.1-70adab92c8-637753615a.zip new file mode 100644 index 00000000..0c6c9ea9 Binary files /dev/null and b/.yarn/cache/clone-deep-npm-4.0.1-70adab92c8-637753615a.zip differ diff --git a/.yarn/cache/commondir-npm-1.0.1-291b790340-33a124960e.zip b/.yarn/cache/commondir-npm-1.0.1-291b790340-33a124960e.zip new file mode 100644 index 00000000..c3c72899 Binary files /dev/null and b/.yarn/cache/commondir-npm-1.0.1-291b790340-33a124960e.zip differ diff --git a/.yarn/cache/esprima-npm-4.0.1-1084e98778-ad4bab9ead.zip b/.yarn/cache/esprima-npm-4.0.1-1084e98778-ad4bab9ead.zip new file mode 100644 index 00000000..dd9631ae Binary files /dev/null and b/.yarn/cache/esprima-npm-4.0.1-1084e98778-ad4bab9ead.zip differ diff --git a/.yarn/cache/execa-npm-5.1.1-191347acf5-c8e615235e.zip b/.yarn/cache/execa-npm-5.1.1-191347acf5-c8e615235e.zip new file mode 100644 index 00000000..22492211 Binary files /dev/null and b/.yarn/cache/execa-npm-5.1.1-191347acf5-c8e615235e.zip differ diff --git a/.yarn/cache/find-cache-dir-npm-2.1.0-772aa82638-556117fd0a.zip b/.yarn/cache/find-cache-dir-npm-2.1.0-772aa82638-556117fd0a.zip new file mode 100644 index 00000000..4aaff894 Binary files /dev/null and b/.yarn/cache/find-cache-dir-npm-2.1.0-772aa82638-556117fd0a.zip differ diff --git a/.yarn/cache/find-up-npm-3.0.0-a2d4b1b317-2c2e7d0a26.zip b/.yarn/cache/find-up-npm-3.0.0-a2d4b1b317-2c2e7d0a26.zip new file mode 100644 index 00000000..cf5f8bf8 Binary files /dev/null and b/.yarn/cache/find-up-npm-3.0.0-a2d4b1b317-2c2e7d0a26.zip differ diff --git a/.yarn/cache/flow-estree-npm-0.342.0-938b4a97c9-66d538a0aa.zip b/.yarn/cache/flow-estree-npm-0.342.0-938b4a97c9-66d538a0aa.zip new file mode 100644 index 00000000..0bc2e537 Binary files /dev/null and b/.yarn/cache/flow-estree-npm-0.342.0-938b4a97c9-66d538a0aa.zip differ diff --git a/.yarn/cache/flow-parser-npm-0.342.0-59c20c8e43-c3d78c96c4.zip b/.yarn/cache/flow-parser-npm-0.342.0-59c20c8e43-c3d78c96c4.zip new file mode 100644 index 00000000..587c3302 Binary files /dev/null and b/.yarn/cache/flow-parser-npm-0.342.0-59c20c8e43-c3d78c96c4.zip differ diff --git a/.yarn/cache/get-stream-npm-6.0.1-83e51a4642-49825d57d3.zip b/.yarn/cache/get-stream-npm-6.0.1-83e51a4642-49825d57d3.zip new file mode 100644 index 00000000..481f3cc1 Binary files /dev/null and b/.yarn/cache/get-stream-npm-6.0.1-83e51a4642-49825d57d3.zip differ diff --git a/.yarn/cache/graceful-fs-npm-4.2.12-b83a8a0530-a4e2ccd9fe.zip b/.yarn/cache/graceful-fs-npm-4.2.12-b83a8a0530-a4e2ccd9fe.zip new file mode 100644 index 00000000..f7ab5214 Binary files /dev/null and b/.yarn/cache/graceful-fs-npm-4.2.12-b83a8a0530-a4e2ccd9fe.zip differ diff --git a/.yarn/cache/human-signals-npm-2.1.0-f75815481d-695edb3edf.zip b/.yarn/cache/human-signals-npm-2.1.0-f75815481d-695edb3edf.zip new file mode 100644 index 00000000..c6d3ee4c Binary files /dev/null and b/.yarn/cache/human-signals-npm-2.1.0-f75815481d-695edb3edf.zip differ diff --git a/.yarn/cache/is-plain-object-npm-2.0.4-da3265d804-f050fdd520.zip b/.yarn/cache/is-plain-object-npm-2.0.4-da3265d804-f050fdd520.zip new file mode 100644 index 00000000..1b8ec174 Binary files /dev/null and b/.yarn/cache/is-plain-object-npm-2.0.4-da3265d804-f050fdd520.zip differ diff --git a/.yarn/cache/is-stream-npm-2.0.1-c802db55e7-7c28424131.zip b/.yarn/cache/is-stream-npm-2.0.1-c802db55e7-7c28424131.zip new file mode 100644 index 00000000..f577554c Binary files /dev/null and b/.yarn/cache/is-stream-npm-2.0.1-c802db55e7-7c28424131.zip differ diff --git a/.yarn/cache/isobject-npm-3.0.1-8145901fd2-03344f5064.zip b/.yarn/cache/isobject-npm-3.0.1-8145901fd2-03344f5064.zip new file mode 100644 index 00000000..2fdb253e Binary files /dev/null and b/.yarn/cache/isobject-npm-3.0.1-8145901fd2-03344f5064.zip differ diff --git a/.yarn/cache/jscodeshift-npm-17.4.0-4a91744f82-ef7b71c22f.zip b/.yarn/cache/jscodeshift-npm-17.4.0-4a91744f82-ef7b71c22f.zip new file mode 100644 index 00000000..92d7a6fa Binary files /dev/null and b/.yarn/cache/jscodeshift-npm-17.4.0-4a91744f82-ef7b71c22f.zip differ diff --git a/.yarn/cache/kleur-npm-3.0.3-f6f53649a4-cd3a0b8878.zip b/.yarn/cache/kleur-npm-3.0.3-f6f53649a4-cd3a0b8878.zip new file mode 100644 index 00000000..fa5fe2bb Binary files /dev/null and b/.yarn/cache/kleur-npm-3.0.3-f6f53649a4-cd3a0b8878.zip differ diff --git a/.yarn/cache/locate-path-npm-3.0.0-991671ae9f-3db394b782.zip b/.yarn/cache/locate-path-npm-3.0.0-991671ae9f-3db394b782.zip new file mode 100644 index 00000000..bedacb88 Binary files /dev/null and b/.yarn/cache/locate-path-npm-3.0.0-991671ae9f-3db394b782.zip differ diff --git a/.yarn/cache/make-dir-npm-2.1.0-1ddaf205e7-ada869944d.zip b/.yarn/cache/make-dir-npm-2.1.0-1ddaf205e7-ada869944d.zip new file mode 100644 index 00000000..df9594f7 Binary files /dev/null and b/.yarn/cache/make-dir-npm-2.1.0-1ddaf205e7-ada869944d.zip differ diff --git a/.yarn/cache/merge-stream-npm-2.0.0-2ac83efea5-867fdbb30a.zip b/.yarn/cache/merge-stream-npm-2.0.0-2ac83efea5-867fdbb30a.zip new file mode 100644 index 00000000..7274204f Binary files /dev/null and b/.yarn/cache/merge-stream-npm-2.0.0-2ac83efea5-867fdbb30a.zip differ diff --git a/.yarn/cache/mimic-fn-npm-2.1.0-4fbeb3abb4-b26f5479d7.zip b/.yarn/cache/mimic-fn-npm-2.1.0-4fbeb3abb4-b26f5479d7.zip new file mode 100644 index 00000000..374d3a21 Binary files /dev/null and b/.yarn/cache/mimic-fn-npm-2.1.0-4fbeb3abb4-b26f5479d7.zip differ diff --git a/.yarn/cache/neo-async-npm-2.6.2-75d6902586-c2f5a604a5.zip b/.yarn/cache/neo-async-npm-2.6.2-75d6902586-c2f5a604a5.zip new file mode 100644 index 00000000..7dad9430 Binary files /dev/null and b/.yarn/cache/neo-async-npm-2.6.2-75d6902586-c2f5a604a5.zip differ diff --git a/.yarn/cache/npm-run-path-npm-4.0.1-7aebd8bab3-6f9353a952.zip b/.yarn/cache/npm-run-path-npm-4.0.1-7aebd8bab3-6f9353a952.zip new file mode 100644 index 00000000..e0d3adc5 Binary files /dev/null and b/.yarn/cache/npm-run-path-npm-4.0.1-7aebd8bab3-6f9353a952.zip differ diff --git a/.yarn/cache/onetime-npm-5.1.2-3ed148fa42-ffcef6fbb2.zip b/.yarn/cache/onetime-npm-5.1.2-3ed148fa42-ffcef6fbb2.zip new file mode 100644 index 00000000..07670d97 Binary files /dev/null and b/.yarn/cache/onetime-npm-5.1.2-3ed148fa42-ffcef6fbb2.zip differ diff --git a/.yarn/cache/p-limit-npm-2.3.0-94a0310039-8da01ac53e.zip b/.yarn/cache/p-limit-npm-2.3.0-94a0310039-8da01ac53e.zip new file mode 100644 index 00000000..8ead140f Binary files /dev/null and b/.yarn/cache/p-limit-npm-2.3.0-94a0310039-8da01ac53e.zip differ diff --git a/.yarn/cache/p-locate-npm-3.0.0-74de74f952-7b7f06f718.zip b/.yarn/cache/p-locate-npm-3.0.0-74de74f952-7b7f06f718.zip new file mode 100644 index 00000000..6e5bb458 Binary files /dev/null and b/.yarn/cache/p-locate-npm-3.0.0-74de74f952-7b7f06f718.zip differ diff --git a/.yarn/cache/p-try-npm-2.2.0-e0390dbaf8-c36c199077.zip b/.yarn/cache/p-try-npm-2.2.0-e0390dbaf8-c36c199077.zip new file mode 100644 index 00000000..0e49ad75 Binary files /dev/null and b/.yarn/cache/p-try-npm-2.2.0-e0390dbaf8-c36c199077.zip differ diff --git a/.yarn/cache/path-exists-npm-3.0.0-e80371aa68-17d6a5664b.zip b/.yarn/cache/path-exists-npm-3.0.0-e80371aa68-17d6a5664b.zip new file mode 100644 index 00000000..e69aaa78 Binary files /dev/null and b/.yarn/cache/path-exists-npm-3.0.0-e80371aa68-17d6a5664b.zip differ diff --git a/.yarn/cache/pify-npm-4.0.1-062756097b-6f9d404b0d.zip b/.yarn/cache/pify-npm-4.0.1-062756097b-6f9d404b0d.zip new file mode 100644 index 00000000..a18e950b Binary files /dev/null and b/.yarn/cache/pify-npm-4.0.1-062756097b-6f9d404b0d.zip differ diff --git a/.yarn/cache/pirates-npm-4.0.7-5e4ee2f078-a51f108dd8.zip b/.yarn/cache/pirates-npm-4.0.7-5e4ee2f078-a51f108dd8.zip new file mode 100644 index 00000000..ceba9715 Binary files /dev/null and b/.yarn/cache/pirates-npm-4.0.7-5e4ee2f078-a51f108dd8.zip differ diff --git a/.yarn/cache/pkg-dir-npm-3.0.0-16d8d93783-902a3d0c1f.zip b/.yarn/cache/pkg-dir-npm-3.0.0-16d8d93783-902a3d0c1f.zip new file mode 100644 index 00000000..07256759 Binary files /dev/null and b/.yarn/cache/pkg-dir-npm-3.0.0-16d8d93783-902a3d0c1f.zip differ diff --git a/.yarn/cache/prompts-npm-2.4.2-f5d25d5eea-16f1ac2977.zip b/.yarn/cache/prompts-npm-2.4.2-f5d25d5eea-16f1ac2977.zip new file mode 100644 index 00000000..312bbcbe Binary files /dev/null and b/.yarn/cache/prompts-npm-2.4.2-f5d25d5eea-16f1ac2977.zip differ diff --git a/.yarn/cache/recast-npm-0.23.21-1e626d51b5-afee4673fd.zip b/.yarn/cache/recast-npm-0.23.21-1e626d51b5-afee4673fd.zip new file mode 100644 index 00000000..cb40d174 Binary files /dev/null and b/.yarn/cache/recast-npm-0.23.21-1e626d51b5-afee4673fd.zip differ diff --git a/.yarn/cache/semver-npm-5.7.3-2620585b81-46308a549d.zip b/.yarn/cache/semver-npm-5.7.3-2620585b81-46308a549d.zip new file mode 100644 index 00000000..225c8a0c Binary files /dev/null and b/.yarn/cache/semver-npm-5.7.3-2620585b81-46308a549d.zip differ diff --git a/.yarn/cache/shallow-clone-npm-3.0.1-dab5873d0d-7bab09613a.zip b/.yarn/cache/shallow-clone-npm-3.0.1-dab5873d0d-7bab09613a.zip new file mode 100644 index 00000000..2e8077a8 Binary files /dev/null and b/.yarn/cache/shallow-clone-npm-3.0.1-dab5873d0d-7bab09613a.zip differ diff --git a/.yarn/cache/signal-exit-npm-3.0.7-bd270458a3-25d272fa73.zip b/.yarn/cache/signal-exit-npm-3.0.7-bd270458a3-25d272fa73.zip new file mode 100644 index 00000000..fcc0042e Binary files /dev/null and b/.yarn/cache/signal-exit-npm-3.0.7-bd270458a3-25d272fa73.zip differ diff --git a/.yarn/cache/source-map-npm-0.6.1-1a3621db16-ab55398007.zip b/.yarn/cache/source-map-npm-0.6.1-1a3621db16-ab55398007.zip new file mode 100644 index 00000000..5fe413af Binary files /dev/null and b/.yarn/cache/source-map-npm-0.6.1-1a3621db16-ab55398007.zip differ diff --git a/.yarn/cache/source-map-support-npm-0.5.21-09ca99e250-9ee09942f4.zip b/.yarn/cache/source-map-support-npm-0.5.21-09ca99e250-9ee09942f4.zip new file mode 100644 index 00000000..9ac6485d Binary files /dev/null and b/.yarn/cache/source-map-support-npm-0.5.21-09ca99e250-9ee09942f4.zip differ diff --git a/.yarn/cache/strip-final-newline-npm-2.0.0-340c4f7c66-bddf8ccd47.zip b/.yarn/cache/strip-final-newline-npm-2.0.0-340c4f7c66-bddf8ccd47.zip new file mode 100644 index 00000000..e724a6fe Binary files /dev/null and b/.yarn/cache/strip-final-newline-npm-2.0.0-340c4f7c66-bddf8ccd47.zip differ diff --git a/.yarn/cache/tiny-invariant-npm-1.3.3-e622f1447c-65af4a0732.zip b/.yarn/cache/tiny-invariant-npm-1.3.3-e622f1447c-65af4a0732.zip new file mode 100644 index 00000000..7dd09dcd Binary files /dev/null and b/.yarn/cache/tiny-invariant-npm-1.3.3-e622f1447c-65af4a0732.zip differ diff --git a/.yarn/cache/tmp-npm-0.2.7-a6fd3441a0-59eb55584f.zip b/.yarn/cache/tmp-npm-0.2.7-a6fd3441a0-59eb55584f.zip new file mode 100644 index 00000000..61e703ef Binary files /dev/null and b/.yarn/cache/tmp-npm-0.2.7-a6fd3441a0-59eb55584f.zip differ diff --git a/.yarn/cache/tslib-npm-2.9.1-1db60cfff0-8ff46e7a4d.zip b/.yarn/cache/tslib-npm-2.9.1-1db60cfff0-8ff46e7a4d.zip new file mode 100644 index 00000000..01966e7b Binary files /dev/null and b/.yarn/cache/tslib-npm-2.9.1-1db60cfff0-8ff46e7a4d.zip differ diff --git a/.yarn/cache/undici-types-npm-8.9.0-c5953f392d-51c712c20c.zip b/.yarn/cache/undici-types-npm-8.9.0-c5953f392d-51c712c20c.zip new file mode 100644 index 00000000..3fba581c Binary files /dev/null and b/.yarn/cache/undici-types-npm-8.9.0-c5953f392d-51c712c20c.zip differ diff --git a/.yarn/cache/write-file-atomic-npm-5.0.1-52283db6ee-e8c850a8e3.zip b/.yarn/cache/write-file-atomic-npm-5.0.1-52283db6ee-e8c850a8e3.zip new file mode 100644 index 00000000..41bc56ed Binary files /dev/null and b/.yarn/cache/write-file-atomic-npm-5.0.1-52283db6ee-e8c850a8e3.zip differ diff --git a/AGENTS.md b/AGENTS.md index a4323009..2bb38e99 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 diff --git a/CLAUDE.md b/CLAUDE.md index 6d150066..1ab2f33b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 @@ -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 @@ -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**: `.test.ts`; older folders still use `.spec.ts` — keep whichever the folder has - **SSR pattern**: @@ -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 @@ -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 diff --git a/README-es.md b/README-es.md index 453cd87b..8c56227c 100644 --- a/README-es.md +++ b/README-es.md @@ -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 @@ -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 ``` diff --git a/README-ja_jp.md b/README-ja_jp.md index db011d3a..a95b34d5 100644 --- a/README-ja_jp.md +++ b/README-ja_jp.md @@ -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) | ## 特長 @@ -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 コーディングアシスタント向けのエージェントスキル ``` diff --git a/README-ko_kr.md b/README-ko_kr.md index ddf50d89..a36fd1a5 100644 --- a/README-ko_kr.md +++ b/README-ko_kr.md @@ -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) | ## 특징 @@ -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 코딩 어시스턴트용 에이전트 스킬 ``` diff --git a/README-zh_hans.md b/README-zh_hans.md index cd39697c..85df1504 100644 --- a/README-zh_hans.md +++ b/README-zh_hans.md @@ -8,10 +8,10 @@ ## 包 -| 包 | 说明 | 版本 | -| --------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | -| [react-simplikit](./packages/react-simplikit) | React Hook、组件和工具函数:状态与逻辑、浏览器事件,以及移动端 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 Hook、组件和工具函数:状态与逻辑、浏览器事件,以及移动端 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) | ## 特性 @@ -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 编程助手的 agent skill ``` diff --git a/README.md b/README.md index 5f317b5e..99114e4e 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ A collection of lightweight, zero-dependency React utilities for building robust ## Packages -| Package | Description | Version | -| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | -| [react-simplikit](./packages/react-simplikit) | React hooks, components and utils: state and logic, browser events, and mobile web (keyboard, safe area, viewport) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) | -| [react-simplikit-codemod](./packages/codemod) | Codemods that rewrite a codebase for a `react-simplikit` upgrade | [![npm](https://img.shields.io/npm/v/react-simplikit-codemod.svg)](https://www.npmjs.com/package/react-simplikit-codemod) | +| Package | Description | Version | +| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | +| [react-simplikit](./packages/react-simplikit) | React hooks, components and utils: state and logic, browser events, and mobile web (keyboard, safe area, viewport) | [![npm](https://img.shields.io/npm/v/react-simplikit.svg)](https://www.npmjs.com/package/react-simplikit) | +| [@react-simplikit/codemods](./packages/codemods) | Codemods that rewrite a codebase for a `react-simplikit` upgrade | [![npm](https://img.shields.io/npm/v/@react-simplikit/codemods.svg)](https://www.npmjs.com/package/@react-simplikit/codemods) | ## Features @@ -97,7 +97,7 @@ Visit [react-simplikit.slash.page](https://react-simplikit.slash.page) for full ``` packages/ ├── react-simplikit/ # the library -├── codemod/ # react-simplikit-codemod +├── codemods/ # @react-simplikit/codemods └── plugin/ # agent skill for AI coding assistants ``` diff --git a/eslint.config.js b/eslint.config.js index ce3f46f0..888d28ac 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -26,6 +26,8 @@ export default defineConfig( // Consumer fixture is typechecked by its own tsconfig against the installed // tarball, not the workspace graph — the root project can't resolve its imports. '.scripts/verify-pack/fixtures/**', + // Codemod fixtures import packages the workspace does not install, and their layout is the expected output. + 'packages/codemods/src/transforms/testfixtures/**', 'coverage', 'docs', 'node_modules', diff --git a/package.json b/package.json index 1e7fabbf..9278b17c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "test:type": "yarn workspaces foreach -Ap run typecheck", "test:docs": "vitest run --dir .scripts && tsx .scripts/verifyDocsI18n.ts && tsx .scripts/verifyDocs.ts", "test:skill": "tsx .scripts/verifySkill.ts", - "test:codemod": "yarn workspace react-simplikit-codemod run test:e2e", + "test:codemod": "yarn workspace @react-simplikit/codemods run test:e2e", "test:spec": "yarn workspaces foreach -Ap run test", "test:compiled": "yarn workspaces foreach -Ap run test:compiled", "test:coverage": "yarn workspaces foreach -Ap run test:coverage", diff --git a/packages/codemod/README.md b/packages/codemod/README.md deleted file mode 100644 index 25ddc63d..00000000 --- a/packages/codemod/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# react-simplikit-codemod - -[![npm version](https://img.shields.io/npm/v/react-simplikit-codemod.svg)](https://www.npmjs.com/package/react-simplikit-codemod) -[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/react-simplikit/blob/main/LICENSE) - -Codemods for migrating between `react-simplikit` entry points. - -## `mobile-to-root` - -`@react-simplikit/mobile` was absorbed into the `react-simplikit` root entry. This transform rewrites every import of the old package to the root entry, and folds the bindings into an existing `react-simplikit` import when the file already has one and merging cannot change what a name binds. - -```bash -npx react-simplikit-codemod mobile-to-root -``` - -The command rewrites files in place and never prompts. **Commit or stash your work first**, then review the diff. Preview without writing anything: - -```bash -npx react-simplikit-codemod mobile-to-root --dry-run -``` - -### What it changes - -- `import`, `import type`, `import * as ns`, and side-effect imports -- `export ... from` and `export * from` -- `require('@react-simplikit/mobile')`, `require.resolve`, `import m = require(...)`, and `await import('@react-simplikit/mobile')` -- `import('@react-simplikit/mobile').SafeAreaInset` in type position -- `vi.mock` / `vi.importActual` / `jest.mock` / `jest.requireActual` module arguments -- `dependencies`, `devDependencies`, `peerDependencies` and `optionalDependencies` in every `package.json` it finds - -Source files are parsed with the TypeScript compiler and edited by offset, so formatting, comments and quote style survive untouched. `package.json` is the exception: it is reparsed and reserialized, which normalizes line endings and collapses any hand formatting. - -### What it leaves alone - -- Markdown, MDX, comments, and any other prose naming the package -- A source file that names the package where no import could be rewritten — a `moduleNameMapper` entry, say. It is reported so you can check it by hand -- `resolutions` and `overrides` in `package.json` — reported, not edited, because their meaning differs per package manager -- Imports it will not fold into an existing `react-simplikit` import — the specifier is rewritten in place instead: - - a comment sits on the import's own line, where merging would strand it — **reported** - - the local name already refers to a different symbol, where merging would change what the name binds — **reported** - - the import sits inside a `declare module` block, or binds a default or namespace — not reported, because merging it by hand fails to compile rather than passing quietly -- Your lockfile. Reinstall after the run - -`node_modules`, `dist`, `build`, `out`, `coverage`, `.next`, `.yarn`, `.git` and `.pnp.*` are always skipped. Every other dot directory — `.storybook`, `.config` — is scanned. - -### Options - -| Flag | Meaning | -| ------------------- | ------------------------------------------------------------------------------- | -| `--dry-run` | Report what would change without writing anything | -| `--json` | Print a machine-readable report to stdout and nothing else | -| `--no-package-json` | Leave `package.json` dependency fields alone | -| `--ignore ` | Skip an extra glob, relative to the current directory. Repeat for more than one | -| `--debug` | Include stack traces in the report and on stderr | - -### Exit codes - -| Code | Meaning | -| ---- | ------------------------------------------------------------------------- | -| `0` | Success, including "nothing to change" | -| `1` | The invocation was valid but a file could not be read, parsed, or written | -| `2` | Invalid usage: unknown command, bad flag, or a path that does not exist | - -A run is not atomic and does not stop at the first failure. On exit `1` the report lists every file it could not process under **Could not be processed**; everything else was migrated. - -Running it twice is safe: the second run finds nothing to change. - -### After running - -```bash -npm install -``` - -The codemod already wrote the dependency and its version range, so a bare reinstall is enough — `npm install react-simplikit` would overwrite that range with whatever is newest. - -Then run your formatter or linter fix on the changed files. The specifier moved from `@react-simplikit/mobile` to `react-simplikit`, and import-order rules such as `import/order` or `simple-import-sort` place the two differently, so an import that was sorted before the run is usually out of order after it. - -One import needs a version floor: `SafeAreaInset` is only re-exported from the root entry in `react-simplikit@0.2.0` and later. An existing range is kept only when every version it admits sits on or above that floor; `^0.1.0`, `>=0.1.0` and `*` are raised to `^0.2.0`, because a lockfile could keep an older version under them. A `workspace:`, `catalog:` or `file:` protocol is kept as-is and reported instead, since only you know what it should point at. diff --git a/packages/codemod/src/cli.ts b/packages/codemod/src/cli.ts deleted file mode 100644 index 58a58a32..00000000 --- a/packages/codemod/src/cli.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { Command, CommanderError } from 'commander'; -import process from 'node:process'; - -import manifest from '../package.json'; - -import { collectFiles } from './runner/collectFiles.ts'; -import { runTransform } from './runner/runTransform.ts'; -import { MOBILE_PACKAGE_NAME, ROOT_PACKAGE_NAME, TRANSFORM_NAME } from './constants.ts'; -import { describeError, UsageError } from './errors.ts'; -import { formatHuman, formatJson } from './formatHuman.ts'; - -type TransformOptions = { - dryRun: boolean; - json: boolean; - debug: boolean; - packageJson: boolean; - ignore: string[]; -}; - -function collectIgnore(value: string, previous: string[]) { - return [...previous, value]; -} - -async function runCommand(paths: string[], options: TransformOptions) { - const cwd = process.cwd(); - const files = await collectFiles({ paths, ignore: options.ignore, includePackageJson: options.packageJson, cwd }); - const result = await runTransform({ files, cwd, dryRun: options.dryRun, debug: options.debug }); - const report = options.json ? formatJson(result, options.dryRun) : formatHuman(result, options.dryRun); - - process.stdout.write(`${report}\n`); - - if (result.failed.length === 0) { - return; - } - - const count = result.failed.length === 1 ? '1 file' : `${result.failed.length} files`; - const names = result.failed.map(failure => failure.file).join(', '); - - process.stderr.write(`Could not process ${count}: ${names}\n`); - process.exitCode = 1; -} - -function reportFailure(error: unknown, debug: boolean) { - if (error instanceof CommanderError) { - return error.exitCode === 0 ? 0 : 2; - } - - process.stderr.write(`${describeError(error)}\n`); - - if (debug && error instanceof Error && error.stack !== undefined) { - process.stderr.write(`${error.stack}\n`); - } - - return error instanceof UsageError ? 2 : 1; -} - -const program = new Command() - .name('react-simplikit-codemod') - .description('Codemods for migrating react-simplikit entry points') - .version(manifest.version) - .showHelpAfterError(`Run \`react-simplikit-codemod ${TRANSFORM_NAME}\` to migrate a project.`) - .exitOverride(); - -const transform = program - .command(TRANSFORM_NAME) - .description(`Rewrite ${MOBILE_PACKAGE_NAME} imports to ${ROOT_PACKAGE_NAME}`) - .argument('[paths...]', 'files or directories to transform', ['.']) - .option('--dry-run', 'report what would change without writing files', false) - .option('--json', 'print a machine-readable report to stdout', false) - .option('--debug', 'print the stack trace when the run fails', false) - .option('--no-package-json', 'leave package.json dependency fields alone') - .option('--ignore ', 'extra glob to skip; repeat for more than one', collectIgnore, []) - .addHelpText( - 'after', - [ - '', - 'Examples:', - ' $ npx react-simplikit-codemod mobile-to-root', - ' $ npx react-simplikit-codemod mobile-to-root src --dry-run', - ' $ npx react-simplikit-codemod mobile-to-root . --json', - '', - 'Rewrites files in place and never prompts. Commit or stash first.', - '', - 'Docs: https://react-simplikit.slash.page', - 'Issues: https://github.com/toss/react-simplikit/issues', - ].join('\n') - ) - .exitOverride() - .action(runCommand); - -try { - await program.parseAsync(); -} catch (error) { - process.exitCode = reportFailure(error, transform.opts().debug === true); -} diff --git a/packages/codemod/src/errors.test.ts b/packages/codemod/src/errors.test.ts deleted file mode 100644 index 53e8591b..00000000 --- a/packages/codemod/src/errors.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import { describeError, describeFailure } from './errors.ts'; - -describe('describeError', () => { - it('describes both Error instances and anything else that was thrown', () => { - expect(describeError(new Error('boom'))).toBe('boom'); - expect(describeError('boom')).toBe('boom'); - }); -}); - -describe('describeFailure', () => { - it('explains an unparseable manifest instead of quoting the parser', () => { - const reason = describeFailure(new SyntaxError("Expected ':' after property name in JSON at position 46")); - - expect(reason).toContain('valid JSON'); - expect(reason).not.toContain('position 46'); - }); - - it('explains a permission error and what to do', () => { - const denied = Object.assign(new Error("EACCES: permission denied, open '/x/b.ts'"), { code: 'EACCES' }); - - expect(describeFailure(denied)).toContain('write permission'); - }); - - it('falls back to the original message for anything else', () => { - expect(describeFailure(new Error('something odd'))).toBe('something odd'); - }); -}); diff --git a/packages/codemod/src/errors.ts b/packages/codemod/src/errors.ts deleted file mode 100644 index 7ce50fc3..00000000 --- a/packages/codemod/src/errors.ts +++ /dev/null @@ -1,17 +0,0 @@ -export class UsageError extends Error {} - -export function describeError(error: unknown): string { - return error instanceof Error ? error.message : String(error); -} - -export function describeFailure(error: unknown): string { - if (error instanceof SyntaxError) { - return 'The file is not valid JSON. Fix it by hand, then run the codemod again.'; - } - - if (error instanceof Error && 'code' in error && error.code === 'EACCES') { - return 'No write permission for this file. Grant it, or exclude the path with --ignore.'; - } - - return describeError(error); -} diff --git a/packages/codemod/src/formatHuman.test.ts b/packages/codemod/src/formatHuman.test.ts deleted file mode 100644 index 4a25825e..00000000 --- a/packages/codemod/src/formatHuman.test.ts +++ /dev/null @@ -1,231 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import type { RunResult } from './runner/runTransform.ts'; -import { MIN_RUNTIME_VERSION } from './constants.ts'; -import { formatHuman, formatJson } from './formatHuman.ts'; - -const result: RunResult = { - scanned: 3, - changed: [ - { - kind: 'source', - file: 'src/a.ts', - changes: [ - { line: 1, kind: 'import' }, - { line: 4, kind: 'merge' }, - ], - }, - { - kind: 'manifest', - file: 'package.json', - dependencies: [{ field: 'dependencies', removed: '@react-simplikit/mobile', added: '^0.2.0' }], - }, - ], - manual: [{ file: 'package.json', line: undefined, reason: 'overrides still pins it' }], - failed: [], -}; - -describe('formatHuman', () => { - it('names every changed file so the user can review the diff', () => { - const output = formatHuman(result, false); - - expect(output).toContain('Changed 2 of 3 files'); - expect(output).toContain('src/a.ts'); - expect(output).toContain('import:1'); - expect(output).toContain('merge:4'); - expect(output).toContain('dependencies: -@react-simplikit/mobile +react-simplikit@^0.2.0'); - }); - - it('says "would change" in dry-run mode', () => { - expect(formatHuman(result, true)).toContain('Would change 2 of 3 files'); - }); - - it('lists manual follow-ups', () => { - expect(formatHuman(result, false)).toContain('package.json — overrides still pins it'); - }); - - it('closes an applied run by pointing at the install step', () => { - const output = formatHuman(result, false); - - expect(output).toContain('Imports now resolve from react-simplikit'); - expect(output).toContain(MIN_RUNTIME_VERSION); - expect(output).toContain('import-order rules place react-simplikit differently'); - }); - - it('skips the lint hint when only package.json changed', () => { - const output = formatHuman( - { scanned: 1, changed: [{ kind: 'manifest', file: 'package.json', dependencies: [] }], manual: [], failed: [] }, - false - ); - - expect(output).toContain('Imports now resolve'); - expect(output).not.toContain('import-order'); - }); - - it('does not claim a dry run changed anything', () => { - const output = formatHuman(result, true); - - expect(output).toContain('Nothing was written'); - expect(output).toContain('Run without --dry-run to apply'); - expect(output).not.toContain('Imports now resolve'); - expect(output).not.toContain('import-order'); - }); - - it('reports a clean run without a version reminder or a file list', () => { - const output = formatHuman({ scanned: 5, changed: [], manual: [], failed: [] }, false); - - expect(output).toContain('Scanned 5 files'); - expect(output).toContain('No file imports @react-simplikit/mobile'); - expect(output).not.toContain(MIN_RUNTIME_VERSION); - }); - - it('omits the added marker when only the old dependency was removed', () => { - const output = formatHuman( - { - scanned: 1, - changed: [ - { - kind: 'manifest', - file: 'package.json', - dependencies: [{ field: 'dependencies', removed: '@react-simplikit/mobile', added: null }], - }, - ], - manual: [], - failed: [], - }, - false - ); - - expect(output).toContain('dependencies: -@react-simplikit/mobile'); - expect(output).not.toContain('+react-simplikit@'); - }); - - it('omits the follow-up section when there is nothing to follow up on', () => { - const output = formatHuman({ ...result, manual: [] }, false); - - expect(output).not.toContain('manual follow-up'); - }); -}); - -describe('formatHuman — manual notes without file changes', () => { - const manualOnly = { - scanned: 1, - changed: [], - manual: [{ file: 'package.json', line: undefined, reason: '"overrides" still pins it' }], - failed: [], - }; - - it('shows the follow-up instead of claiming nothing was found', () => { - const output = formatHuman(manualOnly, false); - - expect(output).toContain('package.json — "overrides" still pins it'); - expect(output).not.toContain('No file imports'); - }); -}); - -describe('formatHuman — failures', () => { - it('names the files it could not process alongside the ones it changed', () => { - const output = formatHuman( - { - scanned: 2, - changed: [{ kind: 'source', file: 'src/a.ts', changes: [{ line: 1, kind: 'import' }] }], - manual: [], - failed: [{ file: 'package.json', reason: 'Unexpected end of JSON input' }], - }, - false - ); - - expect(output).toContain('src/a.ts'); - expect(output).toContain('Could not be processed:'); - expect(output).toContain('package.json: Unexpected end of JSON input'); - }); -}); - -describe('formatHuman — notes that point at a line', () => { - it('shows the line so the reader can find the import', () => { - const output = formatHuman( - { - scanned: 1, - changed: [{ kind: 'source', file: 'src/a.ts', changes: [{ line: 1, kind: 'import' }] }], - manual: [ - { file: 'src/a.ts', line: 3, reason: 'Left on its own line: `isIOS` already refers to something else.' }, - ], - failed: [], - }, - false - ); - - expect(output).toContain('src/a.ts:3 — Left on its own line'); - }); -}); - -describe('formatHuman — claims it is entitled to make', () => { - it('does not claim a clean scan when a file could not be read', () => { - const output = formatHuman( - { - scanned: 1, - changed: [], - manual: [], - failed: [{ file: 'app/package.json', reason: 'Unexpected end of JSON input' }], - }, - false - ); - - expect(output).not.toContain('No file imports'); - expect(output).toContain('app/package.json: Unexpected end of JSON input'); - }); - - it('only claims a clean scan when nothing at all came back', () => { - expect(formatHuman({ scanned: 5, changed: [], manual: [], failed: [] }, false)).toContain('No file imports'); - }); -}); - -describe('formatHuman — a dependency entry that added nothing', () => { - it('renders a removal without inventing an added range', () => { - const output = formatHuman( - { - scanned: 1, - changed: [ - { - kind: 'manifest', - file: 'package.json', - dependencies: [{ field: 'dependencies', removed: '@react-simplikit/mobile', added: null }], - }, - ], - manual: [], - failed: [], - }, - false - ); - - expect(output).toContain('dependencies: -@react-simplikit/mobile'); - expect(output).not.toContain('+react-simplikit@'); - }); -}); - -describe('formatHuman — a manifest whose text changed with no dependency edit', () => { - it('does not fall through to the source-file rendering', () => { - const output = formatHuman( - { scanned: 1, changed: [{ kind: 'manifest', file: 'package.json', dependencies: [] }], manual: [], failed: [] }, - false - ); - - expect(output).toContain('package.json'); - expect(output).not.toContain('package.json ()'); - }); -}); - -describe('formatJson', () => { - it('names the transform and the dry-run flag alongside the run result', () => { - const parsed = JSON.parse(formatJson({ scanned: 0, changed: [], manual: [], failed: [] }, true)); - - expect(parsed).toEqual({ - transform: 'mobile-to-root', - dryRun: true, - scanned: 0, - changed: [], - manual: [], - failed: [], - }); - }); -}); diff --git a/packages/codemod/src/formatHuman.ts b/packages/codemod/src/formatHuman.ts deleted file mode 100644 index 03b9ee1c..00000000 --- a/packages/codemod/src/formatHuman.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type { PackageJsonChange } from './mobileToRoot/transformPackageJson.ts'; -import type { FileResult, RunResult } from './runner/runTransform.ts'; -import { MIN_RUNTIME_VERSION, MOBILE_PACKAGE_NAME, ROOT_PACKAGE_NAME, TRANSFORM_NAME } from './constants.ts'; - -function describeDependency(change: PackageJsonChange) { - const added = change.added === null ? '' : ` +${ROOT_PACKAGE_NAME}@${change.added}`; - - return `${change.field}: -${change.removed}${added}`; -} - -function describeFile(file: FileResult) { - if (file.kind === 'source') { - return file.changes.map(change => `${change.kind}:${change.line}`).join(', '); - } - - return file.dependencies.length === 0 ? 'rewritten' : file.dependencies.map(describeDependency).join(', '); -} - -function summarize({ changed, failed, manual, scanned }: RunResult, dryRun: boolean) { - if (changed.length > 0) { - return [ - `${dryRun ? 'Would change' : 'Changed'} ${changed.length} of ${scanned} files:`, - ...changed.map(file => ` ${file.file} (${describeFile(file)})`), - ]; - } - - const nothingToReport = manual.length === 0 && failed.length === 0; - - return [ - nothingToReport - ? `Scanned ${scanned} files. No file imports ${MOBILE_PACKAGE_NAME}.` - : `Scanned ${scanned} files. No file was rewritten.`, - ]; -} - -function nextSteps({ changed }: RunResult, dryRun: boolean) { - if (changed.length === 0) { - return []; - } - - const install = dryRun - ? `Nothing was written. Run without --dry-run to apply, then install at least ${ROOT_PACKAGE_NAME}@${MIN_RUNTIME_VERSION}.` - : `Imports now resolve from ${ROOT_PACKAGE_NAME}. Install at least ${ROOT_PACKAGE_NAME}@${MIN_RUNTIME_VERSION} and reinstall so the lockfile catches up.`; - const rewroteSource = !dryRun && changed.some(file => file.kind === 'source'); - const lintHint = rewroteSource - ? [ - `Then run your formatter or linter fix on the changed files: import-order rules place ${ROOT_PACKAGE_NAME} differently from ${MOBILE_PACKAGE_NAME}.`, - ] - : []; - - return ['', install, ...lintHint]; -} - -export function formatHuman(result: RunResult, dryRun: boolean): string { - const { failed, manual } = result; - - const failures = - failed.length === 0 - ? [] - : ['', 'Could not be processed:', ...failed.map(failure => ` ${failure.file}: ${failure.reason}`)]; - const followUps = - manual.length === 0 - ? [] - : [ - '', - 'Needs a manual follow-up:', - ...manual.map(note => ` ${note.file}${note.line === undefined ? '' : `:${note.line}`} — ${note.reason}`), - ]; - - return [...summarize(result, dryRun), ...failures, ...followUps, ...nextSteps(result, dryRun)].join('\n'); -} - -export function formatJson(result: RunResult, dryRun: boolean): string { - return JSON.stringify({ transform: TRANSFORM_NAME, dryRun, ...result }, null, 2); -} diff --git a/packages/codemod/src/mobileToRoot/collectSpecifiers.test.ts b/packages/codemod/src/mobileToRoot/collectSpecifiers.test.ts deleted file mode 100644 index c18876fd..00000000 --- a/packages/codemod/src/mobileToRoot/collectSpecifiers.test.ts +++ /dev/null @@ -1,91 +0,0 @@ -import ts from 'typescript'; -import { describe, expect, it } from 'vitest'; - -import { collectSpecifiers, lineOf, parseSource } from './collectSpecifiers.ts'; - -function kindsOf(code: string, fileName = 'input.tsx'): string[] { - return collectSpecifiers(parseSource(code, fileName)).map(hit => hit.kind); -} - -describe('parseSource', () => { - it('lets TypeScript pick the script kind from the extension', () => { - expect(parseSource('const a = 1;', 'a.ts').languageVariant).toBe(ts.LanguageVariant.Standard); - expect(parseSource('const a = 1;', 'a.cts').languageVariant).toBe(ts.LanguageVariant.Standard); - expect(parseSource('const a = 1;', 'a.tsx').languageVariant).toBe(ts.LanguageVariant.JSX); - expect(parseSource('const a = 1;', 'a.js').languageVariant).toBe(ts.LanguageVariant.JSX); - }); -}); - -describe('lineOf', () => { - it('reports 1-based line numbers', () => { - const sourceFile = parseSource('const a = 1;\nconst b = 2;\n', 'a.ts'); - - expect(lineOf(sourceFile, 0)).toBe(1); - expect(lineOf(sourceFile, sourceFile.text.indexOf('const b'))).toBe(2); - }); -}); - -describe('collectSpecifiers', () => { - it('finds every import form', () => { - expect(kindsOf(`import { useKeyboardHeight } from '@react-simplikit/mobile';`)).toEqual(['import']); - expect(kindsOf(`import type { SafeAreaInset } from '@react-simplikit/mobile';`)).toEqual(['import']); - expect(kindsOf(`import * as mobile from '@react-simplikit/mobile';`)).toEqual(['import']); - expect(kindsOf(`import '@react-simplikit/mobile';`)).toEqual(['import']); - }); - - it('finds re-exports', () => { - expect(kindsOf(`export { isIOS } from '@react-simplikit/mobile';`)).toEqual(['export']); - expect(kindsOf(`export * from '@react-simplikit/mobile';`)).toEqual(['export']); - }); - - it('finds require and dynamic import', () => { - expect(kindsOf(`const m = require('@react-simplikit/mobile');`, 'input.cjs')).toEqual(['require']); - expect(kindsOf(`const m = await import('@react-simplikit/mobile');`)).toEqual(['dynamic-import']); - }); - - it('finds an import type node in type position', () => { - expect(kindsOf(`type I = import('@react-simplikit/mobile').SafeAreaInset;`, 'input.ts')).toEqual(['import-type']); - }); - - it('finds vitest and jest module mocks', () => { - expect(kindsOf(`vi.mock('@react-simplikit/mobile');`)).toEqual(['mock']); - expect(kindsOf(`jest.mock('@react-simplikit/mobile');`)).toEqual(['mock']); - expect(kindsOf(`jest.requireActual('@react-simplikit/mobile');`)).toEqual(['mock']); - }); - - it('attaches the declaration only for import declarations', () => { - const hits = collectSpecifiers( - parseSource( - [ - `import { isIOS } from '@react-simplikit/mobile';`, - `export { isAndroid } from '@react-simplikit/mobile';`, - ].join('\n'), - 'input.ts' - ) - ); - - expect(hits[0]?.declaration).toBeDefined(); - expect(hits[1]?.declaration).toBeUndefined(); - }); - - it('ignores anything that is not a specifier for the old package', () => { - expect(kindsOf(`import { useToggle } from 'react-simplikit';`)).toEqual([]); - expect(kindsOf(`import { x } from '@react-simplikit/mobile/extra';`)).toEqual([]); - expect(kindsOf(`type X = import('react').FC;`, 'input.ts')).toEqual([]); - - expect(kindsOf(`const label = '@react-simplikit/mobile';`)).toEqual([]); - expect(kindsOf(`describe('@react-simplikit/mobile', () => {});`)).toEqual([]); - - expect(kindsOf(`const foo = 1;\nexport { foo };`)).toEqual([]); - - expect(kindsOf(`other.mock('@react-simplikit/mobile');`)).toEqual([]); - expect(kindsOf(`vi.spyOn('@react-simplikit/mobile');`)).toEqual([]); - expect(kindsOf(`a.b.mock('@react-simplikit/mobile');`)).toEqual([]); - expect(kindsOf(`noArgs();`)).toEqual([]); - }); - - it('degrades to no-op on malformed syntax the parser recovers from', () => { - expect(kindsOf(`import broken from someIdentifier;`, 'input.ts')).toEqual([]); - expect(kindsOf(`type Bad = import(Foo).Bar;`, 'input.ts')).toEqual([]); - }); -}); diff --git a/packages/codemod/src/mobileToRoot/collectSpecifiers.ts b/packages/codemod/src/mobileToRoot/collectSpecifiers.ts deleted file mode 100644 index ca6a3512..00000000 --- a/packages/codemod/src/mobileToRoot/collectSpecifiers.ts +++ /dev/null @@ -1,111 +0,0 @@ -import ts from 'typescript'; - -import { MOBILE_PACKAGE_NAME } from '../constants.ts'; - -import type { ChangeKind } from './types.ts'; - -export type SpecifierHit = { - literal: ts.StringLiteralLike; - kind: ChangeKind; - declaration: ts.ImportDeclaration | undefined; -}; - -const MOCK_OBJECTS = new Set(['vi', 'jest']); - -const MOCK_METHODS = new Set([ - 'mock', - 'doMock', - 'unmock', - 'dontMock', - 'requireActual', - 'requireMock', - 'importActual', - 'importMock', -]); - -// TypeScript reads the script kind off the extension itself: `.js` and `.mjs` parse JSX, `.ts` and `.cts` do not. -export function parseSource(code: string, fileName: string): ts.SourceFile { - return ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest, true); -} - -export function lineOf(sourceFile: ts.SourceFile, position: number): number { - return sourceFile.getLineAndCharacterOfPosition(position).line + 1; -} - -function isMobileSpecifier(node: ts.Node): node is ts.StringLiteralLike { - return ts.isStringLiteralLike(node) && node.text === MOBILE_PACKAGE_NAME; -} - -// The return annotation stays: without it the string literals below widen to `string`. -function callKind(expression: ts.LeftHandSideExpression): ChangeKind | undefined { - if (expression.kind === ts.SyntaxKind.ImportKeyword) { - return 'dynamic-import'; - } - - if (ts.isIdentifier(expression)) { - return expression.text === 'require' ? 'require' : undefined; - } - - if (!ts.isPropertyAccessExpression(expression) || !ts.isIdentifier(expression.expression)) { - return undefined; - } - - const object = expression.expression.text; - const method = expression.name.text; - - if (object === 'require' && method === 'resolve') { - return 'require'; - } - - return MOCK_OBJECTS.has(object) && MOCK_METHODS.has(method) ? 'mock' : undefined; -} - -function visitCall(node: ts.CallExpression, hits: SpecifierHit[]) { - const [first] = node.arguments; - - if (first === undefined || !isMobileSpecifier(first)) { - return; - } - - const kind = callKind(node.expression); - - if (kind !== undefined) { - hits.push({ literal: first, kind, declaration: undefined }); - } -} - -export function collectSpecifiers(sourceFile: ts.SourceFile): SpecifierHit[] { - const hits: SpecifierHit[] = []; - - function visit(node: ts.Node) { - if (ts.isImportDeclaration(node) && isMobileSpecifier(node.moduleSpecifier)) { - hits.push({ literal: node.moduleSpecifier, kind: 'import', declaration: node }); - } else if ( - ts.isImportEqualsDeclaration(node) && - ts.isExternalModuleReference(node.moduleReference) && - isMobileSpecifier(node.moduleReference.expression) - ) { - hits.push({ literal: node.moduleReference.expression, kind: 'require', declaration: undefined }); - } else if ( - ts.isExportDeclaration(node) && - node.moduleSpecifier !== undefined && - isMobileSpecifier(node.moduleSpecifier) - ) { - hits.push({ literal: node.moduleSpecifier, kind: 'export', declaration: undefined }); - } else if ( - ts.isImportTypeNode(node) && - ts.isLiteralTypeNode(node.argument) && - isMobileSpecifier(node.argument.literal) - ) { - hits.push({ literal: node.argument.literal, kind: 'import-type', declaration: undefined }); - } else if (ts.isCallExpression(node)) { - visitCall(node, hits); - } - - ts.forEachChild(node, visit); - } - - visit(sourceFile); - - return hits; -} diff --git a/packages/codemod/src/mobileToRoot/mergeImports.test.ts b/packages/codemod/src/mobileToRoot/mergeImports.test.ts deleted file mode 100644 index 71cb8207..00000000 --- a/packages/codemod/src/mobileToRoot/mergeImports.test.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import { collectSpecifiers, parseSource } from './collectSpecifiers.ts'; -import { buildMergeSplices, type MergeResult } from './mergeImports.ts'; - -function merge(lines: readonly string[], fileName = 'a.ts'): MergeResult { - const sourceFile = parseSource(lines.join('\n'), fileName); - - return buildMergeSplices(sourceFile, collectSpecifiers(sourceFile)); -} - -const ROOT_IMPORT = `import { useToggle } from 'react-simplikit';`; - -describe('buildMergeSplices', () => { - it('produces nothing when the file has no react-simplikit import to merge into', () => { - const result = merge([`import { isIOS } from '@react-simplikit/mobile';`]); - - expect(result.splices).toEqual([]); - expect(result.changes).toEqual([]); - expect(result.mergedDeclarations.size).toBe(0); - }); - - it('produces a delete and an insert when a mergeable target exists', () => { - const result = merge([ROOT_IMPORT, `import { isIOS } from '@react-simplikit/mobile';`, ``]); - - expect(result.splices).toHaveLength(2); - expect(result.changes).toEqual([{ line: 2, kind: 'merge' }]); - expect(result.mergedDeclarations.size).toBe(1); - }); - - it('skips mobile imports that are not a plain named list', () => { - const namespaceImport = merge([ROOT_IMPORT, `import * as mobile from '@react-simplikit/mobile';`]); - const sideEffectImport = merge([ROOT_IMPORT, `import '@react-simplikit/mobile';`]); - const defaultImport = merge([ROOT_IMPORT, `import mobile from '@react-simplikit/mobile';`]); - const defaultAndNamed = merge([ROOT_IMPORT, `import mobile, { isIOS } from '@react-simplikit/mobile';`]); - - expect(namespaceImport.splices).toEqual([]); - expect(sideEffectImport.splices).toEqual([]); - expect(defaultImport.splices).toEqual([]); - expect(defaultAndNamed.splices).toEqual([]); - }); - - it('skips hits that are not import declarations', () => { - expect(merge([ROOT_IMPORT, `export { isIOS } from '@react-simplikit/mobile';`]).splices).toEqual([]); - }); - - it('skips targets that cannot receive a named binding', () => { - const namespaceTarget = merge([ - `import * as root from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ]); - const brokenTarget = merge([ - `import { useToggle } from someIdentifier;`, - `import { isIOS } from '@react-simplikit/mobile';`, - ]); - - expect(namespaceTarget.splices).toEqual([]); - expect(brokenTarget.splices).toEqual([]); - }); - - it('refuses to merge across a type-only mismatch in either direction', () => { - const typeIntoValue = merge([ROOT_IMPORT, `import type { SafeAreaInset } from '@react-simplikit/mobile';`]); - const valueIntoType = merge([ - `import type { UseToggleReturn } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ]); - - expect(typeIntoValue.splices).toEqual([]); - expect(valueIntoType.splices).toEqual([]); - }); - - it('merges when both sides are type-only', () => { - const result = merge([ - `import type { UseToggleReturn } from 'react-simplikit';`, - `import type { SafeAreaInset } from '@react-simplikit/mobile';`, - ]); - - expect(result.mergedDeclarations.size).toBe(1); - }); - - it('emits one insert for two mobile imports folded into the same target', () => { - const result = merge([ - ROOT_IMPORT, - `import { isIOS } from '@react-simplikit/mobile';`, - `import { isAndroid } from '@react-simplikit/mobile';`, - ]); - - expect(result.splices).toHaveLength(3); - expect(result.mergedDeclarations.size).toBe(2); - }); - - it('emits no insert when every binding is already on the target', () => { - const result = merge([ - `import { isIOS } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ]); - - expect(result.splices).toHaveLength(1); - expect(result.mergedDeclarations.size).toBe(1); - }); -}); diff --git a/packages/codemod/src/mobileToRoot/mergeImports.ts b/packages/codemod/src/mobileToRoot/mergeImports.ts deleted file mode 100644 index c7cddebc..00000000 --- a/packages/codemod/src/mobileToRoot/mergeImports.ts +++ /dev/null @@ -1,210 +0,0 @@ -import ts from 'typescript'; - -import { ROOT_PACKAGE_NAME } from '../constants.ts'; - -import { lineOf, type SpecifierHit } from './collectSpecifiers.ts'; -import type { SourceChange, SourceNote, Splice } from './types.ts'; - -export type MergeResult = { - splices: Splice[]; - changes: SourceChange[]; - notes: SourceNote[]; - mergedDeclarations: Set; -}; - -type PlainNamedImport = { - named: ts.NamedImports; - isTypeOnly: boolean; -}; - -// Local name → the name it imports, e.g. `isApple` → `isIOS` for `import { isIOS as isApple }`. -type Bindings = ReadonlyMap; - -function importedNameOf(element: ts.ImportSpecifier) { - return (element.propertyName ?? element.name).text; -} - -function bindingsOf(named: ts.NamedImports): Bindings { - return new Map(named.elements.map(element => [element.name.text, importedNameOf(element)])); -} - -function plainNamedImportOf(declaration: ts.ImportDeclaration): PlainNamedImport | undefined { - const clause = declaration.importClause; - - if (clause === undefined) { - return undefined; - } - - const { name, namedBindings, isTypeOnly } = clause; - - if (namedBindings === undefined || name !== undefined || !ts.isNamedImports(namedBindings)) { - return undefined; - } - - return { named: namedBindings, isTypeOnly }; -} - -function isRootImport(statement: ts.Statement): statement is ts.ImportDeclaration { - return ( - ts.isImportDeclaration(statement) && - ts.isStringLiteralLike(statement.moduleSpecifier) && - statement.moduleSpecifier.text === ROOT_PACKAGE_NAME - ); -} - -function collectTargets(sourceFile: ts.SourceFile) { - return sourceFile.statements - .filter(isRootImport) - .map(plainNamedImportOf) - .filter(target => target !== undefined); -} - -function deletionRange(sourceFile: ts.SourceFile, statement: ts.Statement): Splice { - const { text } = sourceFile; - const start = statement.getStart(sourceFile); - const end = statement.getEnd(); - - const lineStart = text.lastIndexOf('\n', start - 1) + 1; - const newlineIndex = text.indexOf('\n', end); - const lineEnd = newlineIndex === -1 ? text.length : newlineIndex + 1; - - const ownsLine = text.slice(lineStart, start).trim() === '' && text.slice(end, lineEnd).trim() === ''; - - return ownsLine ? { start: lineStart, end: lineEnd, text: '' } : { start, end, text: '' }; -} - -function losesComment(sourceFile: ts.SourceFile, statement: ts.Statement) { - const { text } = sourceFile; - const start = statement.getStart(sourceFile); - const newlineIndex = text.indexOf('\n', statement.getEnd()); - const end = newlineIndex === -1 ? text.length : newlineIndex; - const scanner = ts.createScanner( - ts.ScriptTarget.Latest, - false, - sourceFile.languageVariant, - text, - undefined, - start, - end - start - ); - - for (let token = scanner.scan(); token !== ts.SyntaxKind.EndOfFileToken; token = scanner.scan()) { - if (token === ts.SyntaxKind.SingleLineCommentTrivia || token === ts.SyntaxKind.MultiLineCommentTrivia) { - return true; - } - } - - return false; -} - -// The local name that already means something else on the target, if there is one. -function collisionBetween(bound: Bindings, source: ts.NamedImports) { - const clash = source.elements.find(element => { - const existing = bound.get(element.name.text); - - return existing !== undefined && existing !== importedNameOf(element); - }); - - return clash?.name.text; -} - -function refusalFor( - sourceFile: ts.SourceFile, - declaration: ts.ImportDeclaration, - bound: Bindings, - source: ts.NamedImports -) { - if (losesComment(sourceFile, declaration)) { - return 'Left on its own line: a comment sits on it, and merging would strand that comment.'; - } - - const collision = collisionBetween(bound, source); - - if (collision !== undefined) { - return `Left on its own line: \`${collision}\` already refers to a different import here. Merging it by hand would change what the name binds.`; - } - - return undefined; -} - -function elementSeparator(sourceFile: ts.SourceFile, last: ts.ImportSpecifier) { - const { text } = sourceFile; - const lastStart = last.getStart(sourceFile); - const lead = text.slice(text.lastIndexOf('\n', lastStart - 1) + 1, lastStart); - - return lead.trim() === '' ? `,\n${lead}` : ', '; -} - -function insertIntoNamedImports( - sourceFile: ts.SourceFile, - named: ts.NamedImports, - appended: readonly string[] -): Splice { - const last = named.elements.at(-1); - - if (last === undefined) { - const position = named.getStart(sourceFile) + 1; - - return { start: position, end: position, text: appended.join(', ') }; - } - - const separator = elementSeparator(sourceFile, last); - const position = last.getEnd(); - - return { start: position, end: position, text: `${separator}${appended.join(separator)}` }; -} - -export function buildMergeSplices(sourceFile: ts.SourceFile, hits: readonly SpecifierHit[]): MergeResult { - const targets = collectTargets(sourceFile); - const splices: Splice[] = []; - const changes: SourceChange[] = []; - const notes: SourceNote[] = []; - const mergedDeclarations = new Set(); - const boundByTarget = new Map(); - const appendedByTarget = new Map(); - - for (const { declaration } of hits) { - if (declaration === undefined || declaration.parent !== sourceFile) { - continue; - } - - const source = plainNamedImportOf(declaration); - - if (source === undefined) { - continue; - } - - const target = targets.find(candidate => candidate.isTypeOnly === source.isTypeOnly); - - if (target === undefined) { - continue; - } - - const line = lineOf(sourceFile, declaration.getStart(sourceFile)); - const bound = boundByTarget.get(target.named) ?? bindingsOf(target.named); - const refusal = refusalFor(sourceFile, declaration, bound, source.named); - - if (refusal !== undefined) { - notes.push({ line, reason: refusal }); - continue; - } - - const additions = source.named.elements - .filter(element => !bound.has(element.name.text)) - .map(element => sourceFile.text.slice(element.getStart(sourceFile), element.getEnd())); - - boundByTarget.set(target.named, new Map([...bound, ...bindingsOf(source.named)])); - appendedByTarget.set(target.named, [...(appendedByTarget.get(target.named) ?? []), ...additions]); - splices.push(deletionRange(sourceFile, declaration)); - changes.push({ line, kind: 'merge' }); - mergedDeclarations.add(declaration); - } - - for (const [named, appended] of appendedByTarget) { - if (appended.length > 0) { - splices.push(insertIntoNamedImports(sourceFile, named, appended)); - } - } - - return { splices, changes, notes, mergedDeclarations }; -} diff --git a/packages/codemod/src/mobileToRoot/transformPackageJson.test.ts b/packages/codemod/src/mobileToRoot/transformPackageJson.test.ts deleted file mode 100644 index ddb78496..00000000 --- a/packages/codemod/src/mobileToRoot/transformPackageJson.test.ts +++ /dev/null @@ -1,235 +0,0 @@ -import fc from 'fast-check'; -import semver from 'semver'; -import { describe, expect, it } from 'vitest'; - -import { MIN_RUNTIME_VERSION } from '../constants.ts'; - -import { transformPackageJson } from './transformPackageJson.ts'; - -const ROOT_RANGE = `^${MIN_RUNTIME_VERSION}`; -const FLOOR_RANGE = `>=${MIN_RUNTIME_VERSION}`; - -const [FLOOR_MAJOR] = MIN_RUNTIME_VERSION.split('.').map(Number); -const NEXT_MAJOR = `^${FLOOR_MAJOR + 1}.0.0`; - -function isRecord(value: unknown): value is Record { - return typeof value === 'object' && value !== null; -} - -function manifestAfter(input: string): unknown { - return JSON.parse(transformPackageJson(input).text); -} - -function rootRangeAfter(input: string, field = 'dependencies') { - const manifest = manifestAfter(input); - const dependencies = isRecord(manifest) ? manifest[field] : undefined; - - return isRecord(dependencies) ? dependencies['react-simplikit'] : undefined; -} - -describe('transformPackageJson', () => { - it('swaps the mobile dependency for the root package', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1",\n "react": "^19.0.0"\n }\n}\n`; - const result = transformPackageJson(input); - const manifest: unknown = JSON.parse(result.text); - - expect(manifest).not.toHaveProperty(['dependencies', '@react-simplikit/mobile']); - expect(manifest).toMatchObject({ dependencies: { 'react-simplikit': ROOT_RANGE, react: '^19.0.0' } }); - expect(result.changes).toEqual([{ field: 'dependencies', removed: '@react-simplikit/mobile', added: ROOT_RANGE }]); - }); - - it('only removes the old entry when the root package already satisfies the floor', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1",\n "react-simplikit": "^0.2.0"\n }\n}\n`; - const result = transformPackageJson(input); - - expect(rootRangeAfter(input)).toBe('^0.2.0'); - expect(result.changes).toEqual([{ field: 'dependencies', removed: '@react-simplikit/mobile', added: null }]); - }); - - it('handles devDependencies and optionalDependencies with a caret range', () => { - for (const field of ['devDependencies', 'optionalDependencies']) { - const input = `{\n "${field}": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(transformPackageJson(input).changes).toEqual([ - { field, removed: '@react-simplikit/mobile', added: ROOT_RANGE }, - ]); - } - }); - - it('replaces the dependency in every field that declared it', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n },\n "devDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(transformPackageJson(input).changes.map(change => change.added)).toEqual([ROOT_RANGE, ROOT_RANGE]); - expect(rootRangeAfter(input)).toBe(ROOT_RANGE); - expect(rootRangeAfter(input, 'devDependencies')).toBe(ROOT_RANGE); - }); - - it('does not leave a field empty because another field already had the root package', () => { - const input = `{\n "devDependencies": {\n "react-simplikit": "^0.2.0"\n },\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe(ROOT_RANGE); - expect(transformPackageJson(input).changes).toEqual([ - { field: 'dependencies', removed: '@react-simplikit/mobile', added: ROOT_RANGE }, - ]); - }); - - it('keeps a peer contract that declared the old package', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n },\n "peerDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input, 'peerDependencies')).toBe(FLOOR_RANGE); - }); - - it('preserves four-space indentation and the trailing newline', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(transformPackageJson(input).text).toBe( - `{\n "dependencies": {\n "react-simplikit": "${ROOT_RANGE}"\n }\n}\n` - ); - }); - - it('preserves the absence of a trailing newline', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}`; - - expect(transformPackageJson(input).text.endsWith('}')).toBe(true); - }); - - it('falls back to two-space indentation for a single-line manifest', () => { - const input = `{"dependencies":{"@react-simplikit/mobile":"^0.1.1"}}`; - - expect(transformPackageJson(input).text).toBe( - `{\n "dependencies": {\n "react-simplikit": "${ROOT_RANGE}"\n }\n}` - ); - }); - - it('reports resolutions and overrides as manual work instead of editing them', () => { - const input = `{\n "resolutions": {\n "@react-simplikit/mobile": "0.1.1"\n },\n "overrides": {\n "@react-simplikit/mobile": "0.1.1"\n }\n}\n`; - const result = transformPackageJson(input); - - expect(result.changes).toEqual([]); - expect(result.manual).toHaveLength(2); - expect(result.text).toBe(input); - }); - - it('returns the input untouched when the old package is absent', () => { - const input = `{\n "dependencies": {\n "react": "^19.0.0"\n }\n}\n`; - const result = transformPackageJson(input); - - expect(result.text).toBe(input); - expect(result.changes).toEqual([]); - expect(result.manual).toEqual([]); - }); - - it('ignores dependency fields that are not objects', () => { - const asString = transformPackageJson(`{\n "dependencies": "@react-simplikit/mobile"\n}\n`); - const asNull = transformPackageJson( - `{\n "dependencies": null,\n "devDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n` - ); - - expect(asString.changes).toEqual([]); - expect(asNull.changes).toEqual([ - { field: 'devDependencies', removed: '@react-simplikit/mobile', added: ROOT_RANGE }, - ]); - }); - - it('throws when the manifest root is not an object', () => { - expect(() => transformPackageJson(`["@react-simplikit/mobile"]`)).toThrow(/JSON object/); - }); -}); - -describe('transformPackageJson — ranges it must not get wrong', () => { - it('raises an existing range that sits below the floor', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "^0.1.0",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe(ROOT_RANGE); - }); - - it('leaves an existing range that already satisfies the floor', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "^0.9.0",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe('^0.9.0'); - }); - - it('keeps a non-registry protocol instead of inventing a version range', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "workspace:*"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe('workspace:*'); - expect(transformPackageJson(input).manual.join(' ')).toContain('workspace:*'); - }); - - it('leaves an existing non-registry root range alone', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "workspace:*",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe('workspace:*'); - }); - - it('keeps a range whose major is above the floor even when its minor is lower', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "${NEXT_MAJOR}",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe(NEXT_MAJOR); - }); - - it('keeps an existing protocol spec that carries a version instead of flattening it to a range', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "workspace:^0.1.1",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe('workspace:^0.1.1'); - expect(transformPackageJson(input).manual.join(' ')).toContain('workspace:^0.1.1'); - }); - - it('reports an existing protocol spec rather than silently leaving the floor unchecked', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "workspace:*",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(transformPackageJson(input).manual.join(' ')).toContain('workspace:*'); - }); - - it('does not read a version out of a file: path that happens to contain digits', () => { - const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "file:../mobile-0.1.1.tgz"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe('file:../mobile-0.1.1.tgz'); - expect(transformPackageJson(input).manual.join(' ')).toContain('file:../mobile-0.1.1.tgz'); - }); - - it('keeps a range sitting exactly on the floor', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "${ROOT_RANGE}",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe(ROOT_RANGE); - }); - - it('raises a wildcard range: it admits every version, so a lockfile could keep one below the floor', () => { - const input = `{\n "dependencies": {\n "react-simplikit": "*",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - expect(rootRangeAfter(input)).toBe(ROOT_RANGE); - }); - - it('widens rather than narrows a peer range', () => { - const input = `{\n "peerDependencies": {\n "@react-simplikit/mobile": ">=0.1.0"\n }\n}\n`; - - expect(rootRangeAfter(input, 'peerDependencies')).toBe(FLOOR_RANGE); - }); -}); - -describe('transformPackageJson — the floor holds for any registry range', () => { - const version = fc.tuple(fc.nat({ max: 3 }), fc.nat({ max: 12 }), fc.nat({ max: 12 })).map(parts => parts.join('.')); - const range = fc.oneof( - version, - version.map(v => `^${v}`), - version.map(v => `~${v}`), - version.map(v => `>=${v}`), - version.map(v => `<${v}`), - version.map(v => `${v}-beta.1`), - fc.constantFrom('*', '', 'x', '0.x', '1.x') - ); - - it('leaves a range alone exactly when every version it admits is on or above the floor', () => { - fc.assert( - fc.property(range, existing => { - const input = JSON.stringify({ - dependencies: { 'react-simplikit': existing, '@react-simplikit/mobile': '^0.1.1' }, - }); - const output = rootRangeAfter(input); - - expect(typeof output === 'string' && semver.subset(output, FLOOR_RANGE)).toBe(true); - expect(output).toBe(semver.subset(existing, FLOOR_RANGE) ? existing : ROOT_RANGE); - }) - ); - }); -}); diff --git a/packages/codemod/src/mobileToRoot/transformSource.test.ts b/packages/codemod/src/mobileToRoot/transformSource.test.ts deleted file mode 100644 index 9b92c2a9..00000000 --- a/packages/codemod/src/mobileToRoot/transformSource.test.ts +++ /dev/null @@ -1,473 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import { transformSource } from './transformSource.ts'; - -describe('transformSource', () => { - it('rewrites a named import to the root package', () => { - const result = transformSource(`import { useKeyboardHeight } from '@react-simplikit/mobile';\n`, 'a.tsx'); - - expect(result.code).toBe(`import { useKeyboardHeight } from 'react-simplikit';\n`); - expect(result.changes).toEqual([{ line: 1, kind: 'import' }]); - }); - - it('preserves the original quote style', () => { - expect(transformSource(`import { isIOS } from "@react-simplikit/mobile";\n`, 'a.ts').code).toBe( - `import { isIOS } from "react-simplikit";\n` - ); - }); - - it('preserves formatting, comments and blank lines around the edit', () => { - const input = [ - `// keep this comment`, - ``, - `import {`, - ` useSafeAreaInset, // trailing note`, - `} from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.tsx').code).toBe(input.replace('@react-simplikit/mobile', 'react-simplikit')); - }); - - it('rewrites every specifier form in one file, reported in line order', () => { - const input = [ - `import { isIOS } from '@react-simplikit/mobile';`, - `export { isAndroid } from '@react-simplikit/mobile';`, - `const later = await import('@react-simplikit/mobile');`, - `vi.mock('@react-simplikit/mobile');`, - ].join('\n'); - - const result = transformSource(input, 'a.ts'); - - expect(result.code).not.toContain('@react-simplikit/mobile'); - expect(result.changes).toEqual([ - { line: 1, kind: 'import' }, - { line: 2, kind: 'export' }, - { line: 3, kind: 'dynamic-import' }, - { line: 4, kind: 'mock' }, - ]); - }); - - it('rewrites a require call in a cjs file', () => { - expect(transformSource(`const m = require('@react-simplikit/mobile');\n`, 'a.cjs').code).toBe( - `const m = require('react-simplikit');\n` - ); - }); - - it('rewrites an import type node', () => { - expect(transformSource(`type I = import('@react-simplikit/mobile').SafeAreaInset;\n`, 'a.ts').code).toBe( - `type I = import('react-simplikit').SafeAreaInset;\n` - ); - }); - - it('returns the input untouched when the package name never appears', () => { - const input = `import { useToggle } from 'react-simplikit';\n`; - const result = transformSource(input, 'a.ts'); - - expect(result.code).toBe(input); - expect(result.changes).toEqual([]); - }); - - it('returns the input untouched when the package name appears only in a plain string', () => { - const input = `const docs = 'see @react-simplikit/mobile';\n`; - const result = transformSource(input, 'a.ts'); - - expect(result.code).toBe(input); - expect(result.changes).toEqual([]); - }); -}); - -describe('transformSource — merging with an existing react-simplikit import', () => { - it('folds the mobile bindings into the existing import and drops the line', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `import { isIOS, useKeyboardHeight } from '@react-simplikit/mobile';`, - ``, - `export const value = 1;`, - ``, - ].join('\n'); - - const result = transformSource(input, 'a.ts'); - - expect(result.code).toBe( - [ - `import { useToggle, isIOS, useKeyboardHeight } from 'react-simplikit';`, - ``, - `export const value = 1;`, - ``, - ].join('\n') - ); - expect(result.changes).toEqual([{ line: 2, kind: 'merge' }]); - }); - - it('preserves aliases and inline type modifiers when merging', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `import { isIOS as isApple, type SafeAreaInset } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import { useToggle, isIOS as isApple, type SafeAreaInset } from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('drops a binding the target already imports', () => { - const input = [ - `import { isServer, useToggle } from 'react-simplikit';`, - `import { isIOS, isServer } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import { isServer, useToggle, isIOS } from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('merges several mobile imports into one target', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - `import { isAndroid } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import { useToggle, isIOS, isAndroid } from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('keeps a type-only import separate from a value import', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `import type { SafeAreaInset } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [ - `import { useToggle } from 'react-simplikit';`, - `import type { SafeAreaInset } from 'react-simplikit';`, - ``, - ].join('\n') - ); - }); - - it('merges a type-only import into a type-only target', () => { - const input = [ - `import type { UseToggleReturn } from 'react-simplikit';`, - `import type { SafeAreaInset } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import type { UseToggleReturn, SafeAreaInset } from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('keeps a statement that shares its line with another statement', () => { - const input = `import { useToggle } from 'react-simplikit';\nimport { isIOS } from '@react-simplikit/mobile'; const x = 1;\n`; - - expect(transformSource(input, 'a.ts').code).toBe( - `import { useToggle, isIOS } from 'react-simplikit';\n const x = 1;\n` - ); - }); - - it('handles a merged import on the last line without a trailing newline', () => { - const input = `import { useToggle } from 'react-simplikit';\nimport { isIOS } from '@react-simplikit/mobile';`; - - expect(transformSource(input, 'a.ts').code).toBe(`import { useToggle, isIOS } from 'react-simplikit';\n`); - }); - - it('handles a merged import on the very first line', () => { - const input = [ - `import { isIOS } from '@react-simplikit/mobile';`, - `import { useToggle } from 'react-simplikit';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import { useToggle, isIOS } from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('keeps one binding per line when the target list is written that way', () => { - const withTrailingComma = [ - `import {`, - ` useDebounce,`, - ` useLoading,`, - `} from 'react-simplikit';`, - `import { isIOS, useKeyboardHeight } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(withTrailingComma, 'a.ts').code).toBe( - [ - `import {`, - ` useDebounce,`, - ` useLoading,`, - ` isIOS,`, - ` useKeyboardHeight,`, - `} from 'react-simplikit';`, - ``, - ].join('\n') - ); - - const withoutTrailingComma = [ - `import {`, - `\tuseLoading`, - `} from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(withoutTrailingComma, 'a.ts').code).toBe( - [`import {`, `\tuseLoading,`, `\tisIOS`, `} from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('stays inline when the bindings share a line under a broken-out brace', () => { - const input = [ - `import {`, - ` useDebounce, useLoading`, - `} from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import {`, ` useDebounce, useLoading, isIOS`, `} from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('fills an empty named list on the target', () => { - const input = [`import {} from 'react-simplikit';`, `import { isIOS } from '@react-simplikit/mobile';`, ``].join( - '\n' - ); - - expect(transformSource(input, 'a.ts').code).toBe([`import {isIOS} from 'react-simplikit';`, ``].join('\n')); - }); - - it('leaves an import carrying a comment as its own statement rather than losing it', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `import {`, - ` useKeyboardHeight, // needed for the sheet offset`, - `} from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - const result = transformSource(input, 'a.ts'); - - expect(result.code).toBe(input.replace('@react-simplikit/mobile', 'react-simplikit')); - expect(result.changes).toEqual([{ line: 4, kind: 'import' }]); - }); - - it('deletes the mobile import when every binding is already present', () => { - const input = [ - `import { isIOS } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe([`import { isIOS } from 'react-simplikit';`, ``].join('\n')); - }); -}); - -describe('transformSource — shapes that must not be merged or must not be missed', () => { - it('refuses to merge when a local name collides with a different symbol', () => { - const input = [ - `import { useToggle as isIOS } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import { useToggle as isIOS } from 'react-simplikit';`, `import { isIOS } from 'react-simplikit';`, ``].join( - '\n' - ) - ); - }); - - it('refuses to merge when the alias points the other way', () => { - const input = [ - `import { isIOS } from 'react-simplikit';`, - `import { useToggle as isIOS } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import { isIOS } from 'react-simplikit';`, `import { useToggle as isIOS } from 'react-simplikit';`, ``].join( - '\n' - ) - ); - }); - - it('merges a binding the target already imports under the same original name', () => { - const input = [ - `import { isIOS as isApple } from 'react-simplikit';`, - `import { isIOS as isApple } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe( - [`import { isIOS as isApple } from 'react-simplikit';`, ``].join('\n') - ); - }); - - it('never lifts an import out of an ambient module block', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `declare module 'other' {`, - ` import { isIOS } from '@react-simplikit/mobile';`, - ` export const c: typeof isIOS;`, - `}`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').code).toBe(input.replace('@react-simplikit/mobile', 'react-simplikit')); - }); - - it('rewrites an import-equals require', () => { - const result = transformSource(`import m = require('@react-simplikit/mobile');\n`, 'a.ts'); - - expect(result.code).toBe(`import m = require('react-simplikit');\n`); - expect(result.changes).toEqual([{ line: 1, kind: 'require' }]); - }); - - it('rewrites require.resolve and the vitest import helpers', () => { - expect(transformSource(`require.resolve('@react-simplikit/mobile');\n`, 'a.ts').code).toBe( - `require.resolve('react-simplikit');\n` - ); - expect(transformSource(`await vi.importActual('@react-simplikit/mobile');\n`, 'a.ts').code).toBe( - `await vi.importActual('react-simplikit');\n` - ); - expect(transformSource(`await vi.importMock('@react-simplikit/mobile');\n`, 'a.ts').code).toBe( - `await vi.importMock('react-simplikit');\n` - ); - }); -}); - -describe('transformSource — telling the user what it declined to merge', () => { - it('explains a refusal caused by a name that already binds something else', () => { - const result = transformSource( - [ - `import { useToggle as isIOS } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - ``, - ].join('\n'), - 'a.ts' - ); - - expect(result.notes).toEqual([{ line: 2, reason: expect.stringContaining('isIOS') }]); - expect(result.notes[0]?.reason).toContain('by hand'); - }); - - it('explains a refusal caused by a comment on the import s own line', () => { - const result = transformSource( - [ - `import { useToggle } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile'; // keep this`, - ``, - ].join('\n'), - 'a.ts' - ); - - expect(result.notes).toEqual([{ line: 2, reason: expect.stringContaining('comment') }]); - }); - - it('stays quiet when there was nothing to merge into', () => { - expect(transformSource(`import { isIOS } from '@react-simplikit/mobile';\n`, 'a.ts').notes).toEqual([]); - }); - - it('stays quiet about shapes a named list could never hold', () => { - const namespaceImport = transformSource( - [`import { useToggle } from 'react-simplikit';`, `import * as m from '@react-simplikit/mobile';`].join('\n'), - 'a.ts' - ); - const insideAmbientBlock = transformSource( - [ - `import { useToggle } from 'react-simplikit';`, - `declare module 'other' {`, - ` import { isIOS } from '@react-simplikit/mobile';`, - `}`, - ].join('\n'), - 'a.ts' - ); - - expect(namespaceImport.notes).toEqual([]); - expect(insideAmbientBlock.notes).toEqual([]); - }); - - it('leaves nothing to do on a second run', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile';`, - `export { isAndroid } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - const once = transformSource(input, 'a.ts'); - const twice = transformSource(once.code, 'a.ts'); - - expect(twice.code).toBe(once.code); - expect(twice.changes).toEqual([]); - }); -}); - -describe('transformSource — comments that merging would actually lose', () => { - it('merges when the only comment belongs to the line above', () => { - const input = [ - `import { useToggle } from 'react-simplikit'; // the root package`, - `import { isIOS } from '@react-simplikit/mobile';`, - ``, - ].join('\n'); - - const result = transformSource(input, 'a.ts'); - - expect(result.code).toBe( - [`import { useToggle, isIOS } from 'react-simplikit'; // the root package`, ``].join('\n') - ); - expect(result.notes).toEqual([]); - }); - - it('merges under a file banner', () => { - const input = [ - `/** @vitest-environment jsdom */`, - `import { isIOS } from '@react-simplikit/mobile';`, - `import { useToggle } from 'react-simplikit';`, - ``, - ].join('\n'); - - expect(transformSource(input, 'a.ts').notes).toEqual([]); - }); - - it('refuses when the import carries its own trailing comment', () => { - const input = [ - `import { useToggle } from 'react-simplikit';`, - `import { isIOS } from '@react-simplikit/mobile'; // only on mobile`, - ``, - ].join('\n'); - - const result = transformSource(input, 'a.ts'); - - expect(result.code).toBe(input.replace('@react-simplikit/mobile', 'react-simplikit')); - expect(result.notes).toEqual([{ line: 2, reason: expect.stringContaining('comment') }]); - }); -}); - -describe('transformSource — a mention it cannot classify', () => { - it('reports a file that names the package outside any import position', () => { - const result = transformSource( - `module.exports = { moduleNameMapper: { '^@react-simplikit/mobile$': '/stub.js' } };\n`, - 'jest.config.js' - ); - - expect(result.code).toContain('@react-simplikit/mobile'); - expect(result.notes).toEqual([{ line: 1, reason: expect.stringContaining('could not be rewritten') }]); - }); - - it('stays quiet when the mention is inside a rewritten import', () => { - expect(transformSource(`import { isIOS } from '@react-simplikit/mobile';\n`, 'a.ts').notes).toEqual([]); - }); -}); diff --git a/packages/codemod/src/mobileToRoot/transformSource.ts b/packages/codemod/src/mobileToRoot/transformSource.ts deleted file mode 100644 index e7be26ef..00000000 --- a/packages/codemod/src/mobileToRoot/transformSource.ts +++ /dev/null @@ -1,57 +0,0 @@ -import ts from 'typescript'; - -import { MOBILE_PACKAGE_NAME, ROOT_PACKAGE_NAME } from '../constants.ts'; - -import { collectSpecifiers, lineOf, parseSource } from './collectSpecifiers.ts'; -import { buildMergeSplices } from './mergeImports.ts'; -import type { SourceChange, Splice, TransformSourceResult } from './types.ts'; - -function rewriteSpecifier(sourceFile: ts.SourceFile, literal: ts.StringLiteralLike): Splice { - const start = literal.getStart(sourceFile); - const quote = sourceFile.text.slice(start, start + 1); - - return { start, end: literal.getEnd(), text: `${quote}${ROOT_PACKAGE_NAME}${quote}` }; -} - -function applySplices(code: string, splices: readonly Splice[]) { - return splices - .toSorted((a, b) => b.start - a.start) - .reduce((text, splice) => text.slice(0, splice.start) + splice.text + text.slice(splice.end), code); -} - -export function transformSource(code: string, fileName: string): TransformSourceResult { - if (!code.includes(MOBILE_PACKAGE_NAME)) { - return { code, changes: [], notes: [] }; - } - - const sourceFile = parseSource(code, fileName); - const hits = collectSpecifiers(sourceFile); - - if (hits.length === 0) { - return { - code, - changes: [], - notes: [ - { - line: lineOf(sourceFile, code.indexOf(MOBILE_PACKAGE_NAME)), - reason: `This file names ${MOBILE_PACKAGE_NAME} somewhere it could not be rewritten as an import. Check it by hand.`, - }, - ], - }; - } - - const merge = buildMergeSplices(sourceFile, hits); - const rewrites = hits.filter(hit => hit.declaration === undefined || !merge.mergedDeclarations.has(hit.declaration)); - - const splices = [...merge.splices, ...rewrites.map(hit => rewriteSpecifier(sourceFile, hit.literal))]; - const changes: SourceChange[] = [ - ...merge.changes, - ...rewrites.map(hit => ({ line: lineOf(sourceFile, hit.literal.getStart(sourceFile)), kind: hit.kind })), - ]; - - return { - code: applySplices(code, splices), - changes: changes.toSorted((a, b) => a.line - b.line), - notes: merge.notes, - }; -} diff --git a/packages/codemod/src/mobileToRoot/types.ts b/packages/codemod/src/mobileToRoot/types.ts deleted file mode 100644 index 2e023c96..00000000 --- a/packages/codemod/src/mobileToRoot/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -export type ChangeKind = 'import' | 'export' | 'require' | 'dynamic-import' | 'import-type' | 'mock' | 'merge'; - -export type SourceChange = { - line: number; - kind: ChangeKind; -}; - -export type SourceNote = { - line: number; - reason: string; -}; - -export type TransformSourceResult = { - code: string; - changes: SourceChange[]; - notes: SourceNote[]; -}; - -export type Splice = { - start: number; - end: number; - text: string; -}; diff --git a/packages/codemod/src/runner/collectFiles.test.ts b/packages/codemod/src/runner/collectFiles.test.ts deleted file mode 100644 index cb4a1ec3..00000000 --- a/packages/codemod/src/runner/collectFiles.test.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { mkdir, mkdtemp, realpath, symlink, writeFile } from 'node:fs/promises'; -import { tmpdir } from 'node:os'; -import path from 'node:path'; -import { beforeEach, describe, expect, it } from 'vitest'; - -import { collectFiles, type CollectFilesOptions } from './collectFiles.ts'; - -let cwd = ''; - -async function write(relative: string, contents = ''): Promise { - const absolute = path.join(cwd, relative); - - await mkdir(path.dirname(absolute), { recursive: true }); - await writeFile(absolute, contents, 'utf8'); -} - -async function collect(overrides: Partial = {}): Promise { - const files = await collectFiles({ paths: ['.'], ignore: [], includePackageJson: true, cwd, ...overrides }); - - return files.map(file => path.relative(cwd, file).split(path.sep).join('/')).toSorted(); -} - -beforeEach(async () => { - cwd = await realpath(await mkdtemp(path.join(tmpdir(), 'codemod-collect-'))); -}); - -describe('collectFiles', () => { - it('collects every supported source extension and nothing else', async () => { - for (const name of ['a.ts', 'b.tsx', 'c.mts', 'd.cts', 'e.js', 'f.jsx', 'g.mjs', 'h.cjs']) { - await write(name); - } - await write('skip.md'); - await write('skip.css'); - - expect(await collect()).toEqual(['a.ts', 'b.tsx', 'c.mts', 'd.cts', 'e.js', 'f.jsx', 'g.mjs', 'h.cjs'].toSorted()); - }); - - it('includes package.json when asked and skips it otherwise', async () => { - await write('package.json', '{}'); - - expect(await collect()).toEqual(['package.json']); - expect(await collect({ includePackageJson: false })).toEqual([]); - }); - - it('skips vendored and generated directories by default', async () => { - await write('src/a.ts'); - await write('node_modules/pkg/b.ts'); - await write('dist/c.ts'); - await write('coverage/d.ts'); - await write('.next/e.ts'); - - expect(await collect()).toEqual(['src/a.ts']); - }); - - it('honours an extra ignore glob', async () => { - await write('src/a.ts'); - await write('legacy/b.ts'); - - expect(await collect({ ignore: ['**/legacy/**'] })).toEqual(['src/a.ts']); - }); - - it('accepts explicit file paths without globbing', async () => { - await write('src/a.ts'); - await write('src/b.ts'); - - expect(await collect({ paths: ['src/a.ts'] })).toEqual(['src/a.ts']); - }); - - it('deduplicates a file reached through two paths', async () => { - await write('src/a.ts'); - - expect(await collect({ paths: ['src/a.ts', 'src'] })).toEqual(['src/a.ts']); - }); - - it('throws a UsageError naming the path that does not exist', async () => { - await expect(collect({ paths: ['nope'] })).rejects.toThrow(/Path not found: nope/); - }); -}); - -describe('collectFiles — explicit paths obey the same policy as globbed ones', () => { - it('skips an explicitly named package.json when package.json handling is off', async () => { - await write('app/package.json', '{}'); - - expect(await collect({ paths: ['app/package.json'], includePackageJson: false })).toEqual([]); - }); - - it('honours an ignore glob against an explicitly named file', async () => { - await write('vendor/v.ts'); - - expect(await collect({ paths: ['vendor/v.ts'], ignore: ['**/vendor/**'] })).toEqual([]); - }); - - it('skips an explicitly named file inside node_modules', async () => { - await write('node_modules/pkg/i.js'); - - expect(await collect({ paths: ['node_modules/pkg/i.js'] })).toEqual([]); - }); - - it('skips an explicitly named file with an unsupported extension', async () => { - await write('notes.md'); - - expect(await collect({ paths: ['notes.md'] })).toEqual([]); - }); - - it('does not follow a symlinked file or directory given explicitly', async () => { - await write('real/x.ts'); - await symlink(path.join(cwd, 'real'), path.join(cwd, 'linkedDir')); - await symlink(path.join(cwd, 'real', 'x.ts'), path.join(cwd, 'linked.ts')); - - expect(await collect({ paths: ['linkedDir'] })).toEqual([]); - expect(await collect({ paths: ['linked.ts'] })).toEqual([]); - }); -}); - -describe('collectFiles — places it must not silently miss', () => { - it('descends into dot directories', async () => { - await write('src/a.ts'); - await write('.storybook/preview.ts'); - await write('.config/b.ts'); - - expect(await collect()).toEqual(['.config/b.ts', '.storybook/preview.ts', 'src/a.ts']); - }); - - it('still skips the generated dot directories it lists by default', async () => { - await write('src/a.ts'); - await write('.next/x.ts'); - await write('.yarn/y.ts'); - await write('.git/z.ts'); - - expect(await collect()).toEqual(['src/a.ts']); - }); - - it('honours an ignore glob written relative to cwd', async () => { - await write('src/a.ts'); - await write('legacy/b.ts'); - - expect(await collect({ ignore: ['legacy/**'] })).toEqual(['src/a.ts']); - }); - - it('still honours an ignore glob anchored with a double star', async () => { - await write('src/a.ts'); - await write('nested/legacy/b.ts'); - - expect(await collect({ ignore: ['**/legacy/**'] })).toEqual(['src/a.ts']); - }); -}); - -describe('collectFiles — an ignore glob a user is likely to type', () => { - it('honours a glob written with a leading ./', async () => { - await write('legacy/a.ts', ''); - await write('src/a.ts', ''); - - expect(await collect({ ignore: ['./legacy/**'] })).toEqual(['src/a.ts']); - }); -}); diff --git a/packages/codemod/src/runner/collectFiles.ts b/packages/codemod/src/runner/collectFiles.ts deleted file mode 100644 index 39ff9daf..00000000 --- a/packages/codemod/src/runner/collectFiles.ts +++ /dev/null @@ -1,60 +0,0 @@ -import fastGlob from 'fast-glob'; -import { lstat } from 'node:fs/promises'; -import path from 'node:path'; - -import { UsageError } from '../errors.ts'; - -const SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs']); - -const DEFAULT_IGNORE = [ - '**/node_modules/**', - '**/dist/**', - '**/build/**', - '**/out/**', - '**/coverage/**', - '**/.next/**', - '**/.yarn/**', - '**/.git/**', - '**/.pnp.*', -]; - -export type CollectFilesOptions = { - paths: readonly string[]; - ignore: readonly string[]; - includePackageJson: boolean; - cwd: string; -}; - -export async function collectFiles({ paths, ignore, includePackageJson, cwd }: CollectFilesOptions): Promise { - const patterns: string[] = []; - - for (const target of paths) { - const absolute = path.resolve(cwd, target); - const stats = await lstat(absolute).catch(() => undefined); - - if (stats === undefined) { - throw new UsageError(`Path not found: ${target}. Pass a file or directory that exists.`); - } - - const base = fastGlob.convertPathToPattern(absolute); - - patterns.push(stats.isDirectory() ? `${base}/**/*` : base); - } - - const base = fastGlob.convertPathToPattern(cwd); - // Joined, not concatenated: a typed `./legacy/**` must not become `/./legacy/**`, which never matches. - const scoped = ignore.map(pattern => path.posix.join(base, pattern)); - - const files = await fastGlob(patterns, { - ignore: [...DEFAULT_IGNORE, ...scoped], - absolute: true, - dot: true, - followSymbolicLinks: false, - }); - - return files - .filter(file => - path.basename(file) === 'package.json' ? includePackageJson : SOURCE_EXTENSIONS.has(path.extname(file)) - ) - .toSorted(); -} diff --git a/packages/codemod/src/runner/runTransform.test.ts b/packages/codemod/src/runner/runTransform.test.ts deleted file mode 100644 index e3b839c2..00000000 --- a/packages/codemod/src/runner/runTransform.test.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises'; -import { tmpdir } from 'node:os'; -import path from 'node:path'; -import { beforeEach, describe, expect, it } from 'vitest'; - -import { runTransform } from './runTransform.ts'; - -let cwd = ''; - -async function write(relative: string, contents: string): Promise { - const absolute = path.join(cwd, relative); - - await mkdir(path.dirname(absolute), { recursive: true }); - await writeFile(absolute, contents, 'utf8'); - - return absolute; -} - -beforeEach(async () => { - cwd = await realpath(await mkdtemp(path.join(tmpdir(), 'codemod-run-'))); -}); - -describe('runTransform', () => { - it('rewrites a source file and reports it by relative path', async () => { - const file = await write('src/a.ts', `import { isIOS } from '@react-simplikit/mobile';\n`); - const result = await runTransform({ files: [file], cwd, dryRun: false, debug: false }); - - expect(await readFile(file, 'utf8')).toBe(`import { isIOS } from 'react-simplikit';\n`); - expect(result.scanned).toBe(1); - expect(result.changed).toEqual([ - { kind: 'source', file: path.join('src', 'a.ts'), changes: [{ line: 1, kind: 'import' }] }, - ]); - }); - - it('leaves the file on disk untouched when dryRun is set', async () => { - const original = `import { isIOS } from '@react-simplikit/mobile';\n`; - const file = await write('src/a.ts', original); - const result = await runTransform({ files: [file], cwd, dryRun: true, debug: false }); - - expect(await readFile(file, 'utf8')).toBe(original); - expect(result.changed).toHaveLength(1); - }); - - it('counts an unchanged file as scanned but not changed', async () => { - const file = await write('src/a.ts', `import { useToggle } from 'react-simplikit';\n`); - const result = await runTransform({ files: [file], cwd, dryRun: false, debug: false }); - - expect(result.scanned).toBe(1); - expect(result.changed).toEqual([]); - }); - - it('routes package.json through the manifest transform', async () => { - const file = await write( - 'package.json', - `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n` - ); - const result = await runTransform({ files: [file], cwd, dryRun: false, debug: false }); - - const [entry] = result.changed; - - expect(entry?.kind).toBe('manifest'); - expect(entry?.kind === 'manifest' && entry.dependencies).toHaveLength(1); - expect(await readFile(file, 'utf8')).toContain('"react-simplikit"'); - }); - - it('attaches the file path to manual notes', async () => { - const file = await write('package.json', `{\n "overrides": {\n "@react-simplikit/mobile": "0.1.1"\n }\n}\n`); - const result = await runTransform({ files: [file], cwd, dryRun: false, debug: false }); - - expect(result.manual).toEqual([{ file: 'package.json', reason: expect.stringContaining('overrides') }]); - expect(result.changed).toEqual([]); - }); - - it('records a file it cannot parse and keeps going', async () => { - const broken = await write('package.json', `{ "dependencies": { "@react-simplikit/mobile" `); - const good = await write('src/a.ts', `import { isIOS } from '@react-simplikit/mobile';\n`); - const result = await runTransform({ files: [broken, good], cwd, dryRun: false, debug: false }); - - expect(result.failed).toEqual([{ file: 'package.json', reason: expect.any(String) }]); - expect(result.changed.map(entry => entry.file)).toEqual([path.join('src', 'a.ts')]); - expect(await readFile(good, 'utf8')).toBe(`import { isIOS } from 'react-simplikit';\n`); - }); - - it('adds the stack to the reason when debug is on, and keeps it out otherwise', async () => { - const missing = path.join(cwd, 'gone.ts'); - const debugged = await runTransform({ files: [missing], cwd, dryRun: false, debug: true }); - const plain = await runTransform({ files: [missing], cwd, dryRun: false, debug: false }); - - expect(debugged.failed[0]?.reason).toContain(plain.failed[0]?.reason ?? ''); - expect((debugged.failed[0]?.reason.length ?? 0) > (plain.failed[0]?.reason.length ?? 0)).toBe(true); - }); - - it('records a file it cannot read', async () => { - const missing = path.join(cwd, 'gone.ts'); - const result = await runTransform({ files: [missing], cwd, dryRun: false, debug: false }); - - expect(result.failed.map(failure => failure.file)).toEqual(['gone.ts']); - expect(result.changed).toEqual([]); - }); - - it('does not let one bad manifest sink a dry run', async () => { - const broken = await write('package.json', `{ "dependencies": { "@react-simplikit/mobile" `); - const good = await write('src/a.ts', `import { isIOS } from '@react-simplikit/mobile';\n`); - const result = await runTransform({ files: [broken, good], cwd, dryRun: true, debug: false }); - - expect(result.failed).toHaveLength(1); - expect(result.changed).toHaveLength(1); - }); -}); - -describe('runTransform — a target outside the current directory', () => { - it('reports the absolute path instead of a chain of parent segments', async () => { - const outside = await mkdtemp(path.join(tmpdir(), 'codemod-outside-')); - const file = path.join(outside, 'a.ts'); - await writeFile(file, `import { isIOS } from '@react-simplikit/mobile';\nexport const a = isIOS;\n`, 'utf8'); - - const result = await runTransform({ files: [file], cwd, dryRun: true, debug: false }); - - expect(result.changed[0]?.file).toBe(file); - await rm(outside, { recursive: true, force: true }); - }); -}); - -describe('runTransform — --debug on a file the transform rejects', () => { - it('keeps the actionable reason ahead of the stack', async () => { - const file = await write('package.json', '{ "dependencies": { "@react-simplikit/mobile"'); - const result = await runTransform({ files: [file], cwd, dryRun: true, debug: true }); - - expect(result.failed[0]?.reason).toContain('not valid JSON'); - expect(result.failed[0]?.reason).toContain('at '); - }); -}); diff --git a/packages/codemod/src/runner/runTransform.ts b/packages/codemod/src/runner/runTransform.ts deleted file mode 100644 index 02a7327b..00000000 --- a/packages/codemod/src/runner/runTransform.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { readFile, writeFile } from 'node:fs/promises'; -import path from 'node:path'; - -import { describeFailure } from '../errors.ts'; -import type { PackageJsonChange } from '../mobileToRoot/transformPackageJson.ts'; -import { transformPackageJson } from '../mobileToRoot/transformPackageJson.ts'; -import { transformSource } from '../mobileToRoot/transformSource.ts'; -import type { SourceChange } from '../mobileToRoot/types.ts'; - -export type FileResult = - | { kind: 'source'; file: string; changes: SourceChange[] } - | { kind: 'manifest'; file: string; dependencies: PackageJsonChange[] }; - -export type ManualNote = { - file: string; - line: number | undefined; - reason: string; -}; - -export type FileFailure = { - file: string; - reason: string; -}; - -export type RunResult = { - scanned: number; - changed: FileResult[]; - manual: ManualNote[]; - failed: FileFailure[]; -}; - -type RunTransformOptions = { - files: readonly string[]; - cwd: string; - dryRun: boolean; - debug: boolean; -}; - -type FileNote = { line: number | undefined; reason: string }; - -type FileOutcome = { text: string; notes: FileNote[] } & ( - | { kind: 'source'; changes: SourceChange[] } - | { kind: 'manifest'; dependencies: PackageJsonChange[] } -); - -type FileReport = Pick; - -function transformFile(file: string, original: string): FileOutcome { - if (path.basename(file) === 'package.json') { - const result = transformPackageJson(original); - - return { - kind: 'manifest', - text: result.text, - dependencies: result.changes, - notes: result.manual.map(reason => ({ line: undefined, reason })), - }; - } - - const result = transformSource(original, file); - - return { kind: 'source', text: result.code, changes: result.changes, notes: result.notes }; -} - -function displayNameOf(file: string, cwd: string) { - const fromCwd = path.relative(cwd, file); - - return fromCwd.startsWith('..') ? file : fromCwd; -} - -async function processFile(file: string, { cwd, dryRun, debug }: RunTransformOptions): Promise { - const name = displayNameOf(file, cwd); - let manual: ManualNote[] = []; - - try { - const original = await readFile(file, 'utf8'); - const outcome = transformFile(file, original); - - manual = outcome.notes.map(note => ({ file: name, line: note.line, reason: note.reason })); - - if (outcome.text === original) { - return { changed: [], manual, failed: [] }; - } - - if (!dryRun) { - await writeFile(file, outcome.text, 'utf8'); - } - - const changed: FileResult = - outcome.kind === 'manifest' - ? { kind: 'manifest', file: name, dependencies: outcome.dependencies } - : { kind: 'source', file: name, changes: outcome.changes }; - - return { changed: [changed], manual, failed: [] }; - } catch (error) { - const reason = describeFailure(error); - const stack = debug && error instanceof Error ? error.stack : undefined; - - return { - changed: [], - manual, - failed: [{ file: name, reason: stack === undefined ? reason : `${reason}\n${stack}` }], - }; - } -} - -export async function runTransform(options: RunTransformOptions): Promise { - const reports: FileReport[] = []; - - for (const file of options.files) { - reports.push(await processFile(file, options)); - } - - return { - scanned: options.files.length, - changed: reports.flatMap(report => report.changed), - manual: reports.flatMap(report => report.manual), - failed: reports.flatMap(report => report.failed), - }; -} diff --git a/packages/codemod/test/cli.e2e.test.ts b/packages/codemod/test/cli.e2e.test.ts deleted file mode 100644 index 987a19bc..00000000 --- a/packages/codemod/test/cli.e2e.test.ts +++ /dev/null @@ -1,308 +0,0 @@ -import { spawnSync } from 'node:child_process'; -import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; - -import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'; - -import manifest from '../package.json'; - -const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); -// From the manifest, so a `bin` left behind by a build-output rename fails here. -const binPath = path.join(packageRoot, manifest.bin); -const fixturesRoot = path.join(packageRoot, 'test', '__fixtures__'); - -const YARN = process.platform === 'win32' ? 'yarn.cmd' : 'yarn'; - -function runCli(args: readonly string[], cwd: string, env = process.env) { - const { stdout, stderr, status } = spawnSync(YARN, ['node', binPath, ...args], { cwd, env, encoding: 'utf8' }); - - return { stdout, stderr, exitCode: status ?? 1 }; -} - -function reportOf(stdout: string): unknown { - return JSON.parse(stdout); -} - -let cwd = ''; - -async function write(relative: string, contents: string) { - const absolute = path.join(cwd, relative); - - await mkdir(path.dirname(absolute), { recursive: true }); - await writeFile(absolute, contents, 'utf8'); -} - -beforeAll(async () => { - await mkdir(fixturesRoot, { recursive: true }); -}); - -afterAll(async () => { - await rm(fixturesRoot, { force: true, recursive: true }); -}); - -beforeEach(async () => { - cwd = await mkdtemp(path.join(fixturesRoot, 'case-')); -}); - -describe('react-simplikit-codemod', () => { - it('ships a shebang in the built entrypoint', async () => { - expect((await readFile(binPath, 'utf8')).startsWith('#!/usr/bin/env node')).toBe(true); - }); - - it('prints its version to stdout and exits 0', () => { - const result = runCli(['--version'], cwd); - - expect(result.exitCode).toBe(0); - expect(result.stdout.trim()).toMatch(/^\d+\.\d+\.\d+/); - expect(result.stderr).toBe(''); - }); - - it('prints help for the transform and exits 0', () => { - const result = runCli(['mobile-to-root', '--help'], cwd); - - expect(result.exitCode).toBe(0); - expect(result.stdout).toContain('--dry-run'); - expect(result.stdout).toContain('--json'); - expect(result.stdout).toContain('Examples:'); - }); - - it('exits 2 for an unknown command, with the message on stderr', () => { - const result = runCli(['nope'], cwd); - - expect(result.exitCode).toBe(2); - expect(result.stderr).not.toBe(''); - expect(result.stdout).toBe(''); - }); - - it('exits 2 when no command is given', () => { - expect(runCli([], cwd).exitCode).toBe(2); - }); - - it('exits 2 for a path that does not exist and names it', () => { - const result = runCli(['mobile-to-root', 'missing-dir'], cwd); - - expect(result.exitCode).toBe(2); - expect(result.stderr).toContain('Path not found: missing-dir'); - }); - - it('rewrites imports and names the changed file on stdout', async () => { - await write('src/a.tsx', `import { useKeyboardHeight } from '@react-simplikit/mobile';\n`); - - const result = runCli(['mobile-to-root'], cwd); - - expect(result.exitCode).toBe(0); - expect(result.stdout).toContain(path.join('src', 'a.tsx')); - expect(await readFile(path.join(cwd, 'src', 'a.tsx'), 'utf8')).toBe( - `import { useKeyboardHeight } from 'react-simplikit';\n` - ); - }); - - it('leaves files alone with --dry-run', async () => { - const original = `import { isIOS } from '@react-simplikit/mobile';\n`; - await write('src/a.ts', original); - - const result = runCli(['mobile-to-root', '--dry-run'], cwd); - - expect(result.exitCode).toBe(0); - expect(result.stdout).toContain('Would change'); - expect(await readFile(path.join(cwd, 'src', 'a.ts'), 'utf8')).toBe(original); - }); - - it('prints JSON and nothing else on stdout with --json', async () => { - await write('src/a.ts', `import { isIOS } from '@react-simplikit/mobile';\n`); - - const result = runCli(['mobile-to-root', '--json'], cwd); - - expect(result.exitCode).toBe(0); - expect(reportOf(result.stdout)).toEqual({ - transform: 'mobile-to-root', - dryRun: false, - scanned: 1, - changed: [expect.any(Object)], - manual: [], - failed: [], - }); - }); - - it('rewrites the package.json dependency and skips it with --no-package-json', async () => { - const original = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; - - await write('app/package.json', original); - expect(runCli(['mobile-to-root'], cwd).exitCode).toBe(0); - expect(await readFile(path.join(cwd, 'app', 'package.json'), 'utf8')).toContain('"react-simplikit"'); - - await write('app/package.json', original); - expect(runCli(['mobile-to-root', '--no-package-json'], cwd).exitCode).toBe(0); - expect(await readFile(path.join(cwd, 'app', 'package.json'), 'utf8')).toBe(original); - }); - - it('honours a repeatable --ignore glob', async () => { - const original = `import { isIOS } from '@react-simplikit/mobile';\n`; - - await write('src/a.ts', original); - await write('legacy/b.ts', original); - await write('vendor/c.ts', original); - - const result = runCli(['mobile-to-root', '--ignore', '**/legacy/**', '--ignore', '**/vendor/**', '--json'], cwd); - - expect(reportOf(result.stdout)).toMatchObject({ changed: [{ file: path.join('src', 'a.ts') }] }); - }); - - it('accepts an explicit target directory', async () => { - const original = `import { isIOS } from '@react-simplikit/mobile';\n`; - - await write('src/a.ts', original); - await write('other/b.ts', original); - - const result = runCli(['mobile-to-root', 'src', '--json'], cwd); - - expect(reportOf(result.stdout)).toMatchObject({ changed: [{ file: path.join('src', 'a.ts') }] }); - expect(await readFile(path.join(cwd, 'other', 'b.ts'), 'utf8')).toBe(original); - }); - - it('exits 0 and says nothing changed on a clean tree', async () => { - await write('src/a.ts', `import { useToggle } from 'react-simplikit';\n`); - - const result = runCli(['mobile-to-root'], cwd); - - expect(result.exitCode).toBe(0); - expect(result.stdout).toContain('No file imports'); - }); - - it('reports a file it cannot parse, migrates the rest, and exits 1', async () => { - await write('app/package.json', `{ "dependencies": { "@react-simplikit/mobile" `); - await write('src/a.ts', `import { isIOS } from '@react-simplikit/mobile';\n`); - - const result = runCli(['mobile-to-root'], cwd); - - expect(result.exitCode).toBe(1); - expect(result.stdout).toContain('Could not be processed:'); - expect(result.stdout).toContain(path.join('app', 'package.json')); - expect(result.stderr).toContain('Could not process 1 file:'); - expect(await readFile(path.join(cwd, 'src', 'a.ts'), 'utf8')).toBe(`import { isIOS } from 'react-simplikit';\n`); - }); - - it('keeps --json parseable when a file fails', async () => { - await write('app/package.json', `{ "dependencies": { "@react-simplikit/mobile" `); - - const result = runCli(['mobile-to-root', '--json'], cwd); - - expect(result.exitCode).toBe(1); - expect(reportOf(result.stdout)).toMatchObject({ failed: [{ file: path.join('app', 'package.json') }] }); - }); - - it('never hangs or prompts under CI=true', async () => { - await write('src/a.ts', `import { isIOS } from '@react-simplikit/mobile';\n`); - - const result = runCli(['mobile-to-root'], cwd, { ...process.env, CI: 'true' }); - - expect(result.stdout).toContain('Changed 1 of'); - }); -}); - -describe('running it twice', () => { - it('changes nothing on the second run', async () => { - await write( - 'src/a.tsx', - `import { useToggle } from 'react-simplikit';\nimport { isIOS } from '@react-simplikit/mobile';\n` - ); - await write('app/package.json', `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`); - - expect(runCli(['mobile-to-root'], cwd).exitCode).toBe(0); - const afterFirst = await readFile(path.join(cwd, 'src', 'a.tsx'), 'utf8'); - - const second = runCli(['mobile-to-root', '--json'], cwd); - - expect(reportOf(second.stdout)).toMatchObject({ changed: [] }); - expect(await readFile(path.join(cwd, 'src', 'a.tsx'), 'utf8')).toBe(afterFirst); - }); -}); - -describe('declined merges', () => { - it('tells the user why a line was left on its own', async () => { - await write( - 'src/a.ts', - `import { useToggle as isIOS } from 'react-simplikit';\nimport { isIOS } from '@react-simplikit/mobile';\n` - ); - - const result = runCli(['mobile-to-root'], cwd); - - expect(result.exitCode).toBe(0); - expect(result.stdout).toContain('Needs a manual follow-up:'); - expect(result.stdout).toContain('src/a.ts:2'); - expect(result.stdout).toContain('Merging it by hand would change what the name binds'); - }); -}); - -describe('the published tarball', () => { - it('carries the bin entry it declares, executable and runnable', async () => { - const workDir = await mkdtemp(path.join(fixturesRoot, 'pack-')); - const packed = spawnSync('npm', ['pack', '--pack-destination', workDir], { cwd: packageRoot, encoding: 'utf8' }); - - expect(packed.status).toBe(0); - - const tarball = path.join(workDir, packed.stdout.trim().split('\n').at(-1) ?? ''); - - expect(spawnSync('tar', ['-xzf', tarball, '-C', workDir]).status).toBe(0); - - const extracted = path.join(workDir, 'package'); - const packedBin = path.join(extracted, manifest.bin); - - expect(reportOf(await readFile(path.join(extracted, 'package.json'), 'utf8'))).toMatchObject({ - version: manifest.version, - bin: manifest.bin, - }); - expect((await stat(packedBin)).mode & 0o111).toBeGreaterThan(0); - expect((await readFile(packedBin, 'utf8')).startsWith('#!/usr/bin/env node')).toBe(true); - - const run = spawnSync(YARN, ['node', packedBin, '--version'], { cwd: packageRoot, encoding: 'utf8' }); - - expect(run.stdout.trim()).toBe(manifest.version); - }); -}); - -describe('--debug', () => { - it('prints a stack for a usage error only when asked', () => { - const plain = runCli(['mobile-to-root', 'missing-dir'], cwd); - const debugged = runCli(['mobile-to-root', 'missing-dir', '--debug'], cwd); - - expect(plain.stderr).not.toContain('\n at '); - expect(debugged.stderr).toContain('\n at '); - expect(debugged.exitCode).toBe(2); - }); - - it('prints a stack for a file that could not be processed', async () => { - await write('app/package.json', `{ "dependencies": { "@react-simplikit/mobile" `); - - const plain = runCli(['mobile-to-root'], cwd); - const debugged = runCli(['mobile-to-root', '--debug'], cwd); - - expect(plain.stdout).not.toContain('\n at '); - expect(debugged.stdout).toContain('\n at '); - expect(debugged.exitCode).toBe(1); - }); - - it('is not tripped by the string appearing as a flag value', () => { - const result = runCli(['mobile-to-root', 'missing-dir', '--ignore', '--debug'], cwd); - - expect(result.stderr).not.toContain('\n at '); - }); -}); - -describe('what the operator sees on stderr', () => { - it('names the files it could not process, not just a count', async () => { - await write('app/package.json', `{ "dependencies": { "@react-simplikit/mobile" `); - - const result = runCli(['mobile-to-root'], cwd); - - expect(result.stderr).toContain(path.join('app', 'package.json')); - }); - - it('says a command is required when given none', () => { - const result = runCli([], cwd); - - expect(result.exitCode).toBe(2); - expect(result.stderr).toContain('mobile-to-root'); - }); -}); diff --git a/packages/codemod/tsdown.config.ts b/packages/codemod/tsdown.config.ts deleted file mode 100644 index d16e35f2..00000000 --- a/packages/codemod/tsdown.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { defineConfig } from 'tsdown'; - -export default defineConfig({ - entry: ['src/cli.ts'], - clean: true, - publint: 'ci-only', - banner: { js: '#!/usr/bin/env node' }, -}); diff --git a/packages/codemod/CHANGELOG.md b/packages/codemods/CHANGELOG.md similarity index 98% rename from packages/codemod/CHANGELOG.md rename to packages/codemods/CHANGELOG.md index 5a3ec9e4..9a68e01c 100644 --- a/packages/codemod/CHANGELOG.md +++ b/packages/codemods/CHANGELOG.md @@ -1,4 +1,4 @@ -# react-simplikit-codemod +# @react-simplikit/codemods ## 0.1.2 diff --git a/packages/codemods/README.md b/packages/codemods/README.md new file mode 100644 index 00000000..a75b6d97 --- /dev/null +++ b/packages/codemods/README.md @@ -0,0 +1,71 @@ +# @react-simplikit/codemods + +[![npm version](https://img.shields.io/npm/v/@react-simplikit/codemods.svg)](https://www.npmjs.com/package/@react-simplikit/codemods) +[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/react-simplikit/blob/main/LICENSE) + +Codemods for `react-simplikit`, run with [jscodeshift](https://github.com/facebook/jscodeshift). + +## Usage + +Requires Node.js 22 or later. In your terminal, navigate into your project's folder, then run: + +```shell +npx @react-simplikit/codemods +``` + +Leave out `` or `` and the CLI asks for it in a terminal; anywhere else, such as CI, it exits `1`. The command rewrites files in place, so **commit or stash your work first**, then review the diff. Outside a dry run it stops when the git repository holding the path has uncommitted changes anywhere, or when git cannot read its status; `--force` runs anyway. + +| Option | Meaning | +| ----------------------------- | ------------------------------------------------------------------------------------------------------ | +| `-d, --dry` | Dry run: report what would change without writing anything | +| `-p, --print` | Print the transformed files to stdout | +| `-f, --force` | Run even when the git working tree has uncommitted changes | +| `-j, --jscodeshift ` | Pass options straight to jscodeshift, such as `--jscodeshift="--cpus=2 --ignore-pattern=**/legacy/**"` | +| `-v, --version` | Print the version | +| `-h, --help` | Print the help | + +Folders named `node_modules`, `dist`, `build`, `out`, `coverage`, `.next`, `.yarn` or `.git`, and `.pnp.*` files, are skipped wherever they sit inside the path. + +`--help` lists every transform. jscodeshift prints one line per file it could not transform (`ERR`) and one per manual follow-up (`REP`), then a summary. Every run except a dry run ends with the transform's next steps. The command exits `1` when any file failed, on an unknown transform or a path that does not exist, on uncommitted changes or an unreadable git status without `--force`, or when a prompt is cancelled. Every other file is still migrated, and running it twice is safe. + +## `mobile-to-root` + +`@react-simplikit/mobile` was absorbed into the `react-simplikit` root entry. This transform rewrites every import of the old package to the root entry, and folds the bindings into an existing `react-simplikit` import when the file already has one. + +```shell +npx @react-simplikit/codemods mobile-to-root . +``` + +### What it changes + +- `import`, `import type`, `import * as ns`, and side-effect imports +- `export ... from` and `export * from` +- `require('@react-simplikit/mobile')`, `require.resolve`, `import m = require(...)`, and `await import('@react-simplikit/mobile')` +- `import('@react-simplikit/mobile').SafeAreaInset` in type position +- `vi.mock` / `vi.importActual` / `jest.mock` / `jest.requireActual` module arguments +- `dependencies`, `devDependencies`, `peerDependencies` and `optionalDependencies` in every `package.json` it finds + +Source files are parsed with Babel — TypeScript and JSX, with Flow as a fallback for `.js` files — and edited by offset, so formatting, comments and quote style survive untouched. `package.json` is the exception: it is reparsed and reserialized, which normalizes line endings and collapses any hand formatting. + +### What it leaves alone + +- Markdown, MDX, comments, and any other prose naming the package +- A source file that names the package where no import could be rewritten — a `moduleNameMapper` entry, say. It is reported so you can check it by hand +- `resolutions` and `overrides` in `package.json` — reported, not edited, because their meaning differs per package manager +- Imports it will not fold into an existing `react-simplikit` import — the specifier is rewritten in place instead: + - a comment sits on the import's own line, or a line comment such as `// @ts-expect-error` sits right above it, where merging would strand it — **reported** + - the import sits inside a `declare module` block, or binds a default or namespace — not reported, because merging it by hand fails to compile rather than passing quietly +- A file that imports one name twice, from either package. Babel refuses to parse it, so it is reported as an error. Remove the duplicate and run again +- Your lockfile. Reinstall after the run + +### After running + +```shell +npm install +``` + +The codemod already wrote the dependency and its version range, so a bare reinstall is enough — `npm install react-simplikit` would overwrite that range with whatever is newest. + +Then run your formatter or linter fix on the changed files. The specifier moved from `@react-simplikit/mobile` to `react-simplikit`, and import-order rules such as `import/order` or `simple-import-sort` place the two differently, so an import that was sorted before the run is usually out of order after it. + +One import needs a version floor: `SafeAreaInset` is only re-exported from the root entry in `react-simplikit@0.2.0` and later. An existing range is kept only when every version it admits sits on or above that floor; `^0.1.0`, `>=0.1.0` and `*` are raised to `^0.2.0`, because a lockfile could keep an older version under them. A `workspace:`, `catalog:` or `file:` protocol is kept as-is and reported instead, since only you know what it should point at. diff --git a/packages/codemod/package.json b/packages/codemods/package.json similarity index 68% rename from packages/codemod/package.json rename to packages/codemods/package.json index d41ead9f..d5a45092 100644 --- a/packages/codemod/package.json +++ b/packages/codemods/package.json @@ -1,31 +1,31 @@ { - "name": "react-simplikit-codemod", - "version": "0.1.2", - "description": "Codemods for migrating between react-simplikit entry points", + "name": "@react-simplikit/codemods", + "version": "0.4.2", + "description": "Codemods for react-simplikit.", "type": "module", - "bin": "./dist/cli.mjs", + "bin": "./dist/bin/codemods.cjs", "keywords": [ "react-simplikit", - "codemod", - "migration", - "cli" + "codemods" ], "homepage": "https://react-simplikit.slash.page", "bugs": "https://github.com/toss/react-simplikit/issues", "repository": { "type": "git", "url": "git+https://github.com/toss/react-simplikit.git", - "directory": "packages/codemod" + "directory": "packages/codemods" }, "license": "MIT", "files": [ "dist/**/*" ], + "engines": { + "node": ">=22" + }, "scripts": { "build": "tsdown", - "prepublish": "yarn build", "clean": "rimraf ./dist", - "lint": "eslint src", + "lint": "eslint src test", "typecheck": "tsc --noEmit", "test": "vitest run", "test:watch": "vitest", @@ -37,19 +37,23 @@ }, "dependencies": { "commander": "^13.1.0", - "detect-indent": "^7.0.2", - "fast-glob": "^3.3.3", - "semver": "^7.8.5", - "typescript": "^5.7.2" + "execa": "^5.1.1", + "jscodeshift": "^17.3.0", + "prompts": "^2.4.2", + "semver": "^7.8.5" }, "devDependencies": { + "@types/jscodeshift": "^17.3.0", "@types/node": "^24.13.3", + "@types/prompts": "^2.4.9", "@types/semver": "^7.8.0", "@vitest/coverage-v8": "^2.1.8", + "detect-indent": "^7.0.2", "eslint": "^9.39.3", "fast-check": "^4.9.0", "rimraf": "^6.0.1", "tsdown": "^0.22.14", + "typescript": "^5.7.2", "vitest": "^2.1.8" } } diff --git a/packages/codemods/src/bin/codemods.ts b/packages/codemods/src/bin/codemods.ts new file mode 100644 index 00000000..168fa550 --- /dev/null +++ b/packages/codemods/src/bin/codemods.ts @@ -0,0 +1,42 @@ +/** + * Copyright 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ +// Based on https://github.com/reactjs/react-codemod + +import { Command } from 'commander'; + +import packageJson from '../../package.json'; + +import { TRANSFORMER_INQUIRER_CHOICES, transformRunner } from './transformRunner.ts'; + +const program = new Command(packageJson.name); + +program + .description(packageJson.description) + .version(packageJson.version, '-v, --version', 'Output the current version of @react-simplikit/codemods.') + .argument( + '[codemod]', + 'Codemod slug to run. See "https://github.com/toss/react-simplikit/tree/main/packages/codemods"' + ) + .argument('[path]', 'Path to source directory.') + .usage('[codemod] [path]') + .helpOption('-h, --help', 'Display this help message.') + .option('-d, --dry', 'Dry run (no changes are made to files)') + .option('-p, --print', 'Print transformed files to stdout, useful for development') + .option('-f, --force', 'Bypass Git safety checks and forcibly run codemods') + .option('-j, --jscodeshift ', '(Advanced) Pass options directly to jscodeshift') + .addHelpText( + 'after', + [ + '', + 'Transforms:', + ...TRANSFORMER_INQUIRER_CHOICES.map(({ title, description }) => ` ${title} ${description}`), + ].join('\n') + ) + .action(transformRunner); + +program.parse(process.argv); diff --git a/packages/codemods/src/bin/transformRunner.test.ts b/packages/codemods/src/bin/transformRunner.test.ts new file mode 100644 index 00000000..dcf9f516 --- /dev/null +++ b/packages/codemods/src/bin/transformRunner.test.ts @@ -0,0 +1,46 @@ +import { join, resolve } from 'node:path'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import { transformerDirectory, transformRunner } from './transformRunner.ts'; + +// Everything a pipe can drive runs against the built bin in test/cli.e2e.test.ts; only the prompts need a terminal. +const { execa, prompts } = vi.hoisted(() => ({ execa: vi.fn(), prompts: vi.fn() })); + +vi.mock('execa', () => ({ default: execa })); +vi.mock('prompts', () => ({ default: prompts })); + +const { isTTY } = process.stdin; + +afterEach(() => { + process.stdin.isTTY = isTTY; + vi.restoreAllMocks(); + vi.clearAllMocks(); +}); + +describe('transformRunner in a terminal', () => { + it('asks for the transform, then the path, and runs with the answers', async () => { + process.stdin.isTTY = true; + vi.spyOn(console, 'log').mockImplementation(() => {}); + execa.mockResolvedValue({ failed: false, exitCode: 0, stdout: '', stderr: '' }); + prompts.mockResolvedValueOnce({ transformer: 'mobile-to-root' }).mockResolvedValueOnce({ path: 'test' }); + + await transformRunner(); + + expect(prompts).toHaveBeenCalledTimes(2); + expect(execa).toHaveBeenLastCalledWith( + process.execPath, + expect.arrayContaining(['--transform', join(transformerDirectory, 'mobile-to-root.cjs'), '.']), + { cwd: resolve('test'), stdio: 'inherit', reject: false } + ); + }); + + it('exits 1 when a prompt is cancelled', async () => { + process.stdin.isTTY = true; + prompts.mockImplementationOnce((_question, { onCancel }) => onCancel()); + + const run = transformRunner(undefined, 'src'); + + await expect(run).rejects.toThrow('process.exit unexpectedly called with "1"'); + expect(execa).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/codemods/src/bin/transformRunner.ts b/packages/codemods/src/bin/transformRunner.ts new file mode 100644 index 00000000..1aabdf95 --- /dev/null +++ b/packages/codemods/src/bin/transformRunner.ts @@ -0,0 +1,169 @@ +import execa from 'execa'; +import { statSync } from 'node:fs'; +import { basename, dirname, join, resolve } from 'node:path'; +import prompts from 'prompts'; + +export const TRANSFORMER_INQUIRER_CHOICES = [ + { + title: 'mobile-to-root', + description: 'Migrate @react-simplikit/mobile imports and dependencies to react-simplikit', + rewritesPackageJson: true, + nextSteps: [ + 'Act on every REP line above by hand.', + 'Reinstall (npm install, yarn or pnpm install) so the lockfile drops @react-simplikit/mobile.', + 'Run your formatter or linter fix on the changed files: import order rules sort react-simplikit elsewhere.', + ], + }, +]; + +const IGNORE_PATTERNS = [ + '**/node_modules/**', + '**/dist/**', + '**/build/**', + '**/out/**', + '**/coverage/**', + '**/.next/**', + '**/.yarn/**', + '**/.git/**', + '**/.pnp.*', +]; + +function onCancel() { + process.exit(1); +} + +// Through the package's own bin file, not `.bin/jscodeshift`: Yarn PnP installs have no `.bin` folder. +export const jscodeshiftExecutable = require.resolve('jscodeshift/bin/jscodeshift.js'); +export const transformerDirectory = join(__dirname, '../', '../', 'dist', 'transforms'); + +type TransformRunnerOptions = { + dry?: boolean; + print?: boolean; + force?: boolean; + jscodeshift?: string; +}; + +export async function transformRunner(transform?: string, path?: string, options?: TransformRunnerOptions) { + let transformer = transform ?? ''; + let directory = path ?? ''; + + // Without a terminal the prompt never gets an answer, and Node would exit 0 having done nothing. + if ((transform === undefined || path === undefined) && process.stdin.isTTY !== true) { + console.error('Pass both the transform and the path when not running in a terminal, for example:'); + console.error(' npx @react-simplikit/codemods mobile-to-root .'); + process.exit(1); + } + + if (transform === undefined) { + const res = await prompts( + { + type: 'select', + name: 'transformer', + message: 'Which transform would you like to apply?', + choices: TRANSFORMER_INQUIRER_CHOICES.map(({ title, description }) => ({ title, description, value: title })), + }, + { onCancel } + ); + + transformer = res.transformer; + } + + const choice = TRANSFORMER_INQUIRER_CHOICES.find(x => x.title === transformer); + + if (choice === undefined) { + console.error('Invalid transform choice, pick one of:'); + console.error(TRANSFORMER_INQUIRER_CHOICES.map(x => `- ${x.title}`).join('\n')); + process.exit(1); + } + + if (path === undefined) { + const res = await prompts( + { + type: 'text', + name: 'path', + message: 'On which files or directory should the codemods be applied?', + initial: '.', + }, + { onCancel } + ); + + directory = res.path; + } + + const args: string[] = []; + + if (options?.dry === true) { + args.push('--dry'); + } + if (options?.print === true) { + args.push('--print'); + } + args.push('--no-babel'); + args.push('--fail-on-error'); + + args.push(...IGNORE_PATTERNS.map(pattern => `--ignore-pattern=${pattern}`)); + + const extensions = ['tsx', 'ts', 'mts', 'cts', 'jsx', 'js', 'mjs', 'cjs']; + + if (choice.rewritesPackageJson) { + extensions.push('json'); + } + + args.push(`--extensions=${extensions.join(',')}`); + + if (options?.jscodeshift !== undefined) { + args.push(...options.jscodeshift.split(/\s+/).filter(flag => flag !== '')); + } + + const target = resolve(directory); + const stats = statSync(target, { throwIfNoEntry: false }); + + if (stats === undefined) { + console.error(`Path not found: ${directory}`); + process.exit(1); + } + + // jscodeshift matches the ignore patterns against the whole path, so it runs from inside the target: + // otherwise a project under a `build` or `dist` folder would have every file ignored. + const cwd = stats.isDirectory() ? target : dirname(target); + + if (options?.dry !== true) { + const git = await execa('git', ['status', '--porcelain'], { cwd, reject: false }); + // Without git, or in a folder outside any repository, there is nothing to check. + const outsideRepository = git.exitCode === undefined || git.stderr.includes('not a git repository'); + + if (!outsideRepository && (git.failed || git.stdout !== '')) { + if (options?.force !== true) { + console.error( + git.failed + ? `Could not read the git status: ${git.stderr.trim()}` + : 'Before we continue, please stash or commit your git changes.' + ); + console.error('You may use the --force flag to override this safety check.'); + process.exit(1); + } + + console.warn('WARNING: Git directory is not clean. Forcibly continuing.'); + } + } + + args.push('--transform', join(transformerDirectory, `${transformer}.cjs`)); + args.push(stats.isDirectory() ? '.' : basename(target)); + + console.log(`Executing command: jscodeshift ${args.join(' ')}`); + + // jscodeshift already prints each failed file and the summary. + const result = await execa(process.execPath, [jscodeshiftExecutable, ...args], { + cwd, + stdio: 'inherit', + reject: false, + }); + + if (result.failed) { + process.exit(1); + } + + if (options?.dry !== true) { + console.log(['', 'Next steps:', ...choice.nextSteps.map((step, index) => ` ${index + 1}. ${step}`)].join('\n')); + } +} diff --git a/packages/codemods/src/transforms/mobile-to-root.ts b/packages/codemods/src/transforms/mobile-to-root.ts new file mode 100644 index 00000000..5fe38119 --- /dev/null +++ b/packages/codemods/src/transforms/mobile-to-root.ts @@ -0,0 +1,25 @@ +import type { API, FileInfo } from 'jscodeshift'; +import { basename, extname } from 'node:path'; + +import { transformPackageJson } from './utils/mobileToRoot/transformPackageJson.ts'; +import { transformSource } from './utils/mobileToRoot/transformSource.ts'; + +export default function transform(file: FileInfo, api: API) { + if (basename(file.path) === 'package.json') { + const result = transformPackageJson(file.source); + + result.manual.forEach(reason => api.report(reason)); + + return result.text; + } + + if (extname(file.path) === '.json') { + return undefined; + } + + const result = transformSource(file.source, file.path); + + result.notes.forEach(note => api.report(`line ${note.line}: ${note.reason}`)); + + return result.code; +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/bom.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/bom.input.ts new file mode 100644 index 00000000..f0fe0f83 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/bom.input.ts @@ -0,0 +1,2 @@ +import { isIOS } from "@react-simplikit/mobile"; +export const b = isIOS; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/bom.output.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/bom.output.ts new file mode 100644 index 00000000..8ac8d223 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/bom.output.ts @@ -0,0 +1,2 @@ +import { isIOS } from "react-simplikit"; +export const b = isIOS; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/commonjs.input.cjs b/packages/codemods/src/transforms/testfixtures/mobile-to-root/commonjs.input.cjs new file mode 100644 index 00000000..083c5a05 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/commonjs.input.cjs @@ -0,0 +1,3 @@ +const { isIOS } = require('@react-simplikit/mobile'); +jest.mock('@react-simplikit/mobile'); +module.exports = { isIOS, actual: jest.requireActual('@react-simplikit/mobile') }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/commonjs.output.cjs b/packages/codemods/src/transforms/testfixtures/mobile-to-root/commonjs.output.cjs new file mode 100644 index 00000000..839c56db --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/commonjs.output.cjs @@ -0,0 +1,3 @@ +const { isIOS } = require('react-simplikit'); +jest.mock('react-simplikit'); +module.exports = { isIOS, actual: jest.requireActual('react-simplikit') }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/crlf.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/crlf.input.ts new file mode 100644 index 00000000..93ed4963 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/crlf.input.ts @@ -0,0 +1,4 @@ +import { isAndroid } from '@react-simplikit/mobile'; +import { useToggle } from 'react-simplikit'; + +export const a = isAndroid() && useToggle; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/crlf.output.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/crlf.output.ts new file mode 100644 index 00000000..9646116a --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/crlf.output.ts @@ -0,0 +1,3 @@ +import { useToggle, isAndroid } from 'react-simplikit'; + +export const a = isAndroid() && useToggle; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/declaration-file.input.d.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/declaration-file.input.d.ts new file mode 100644 index 00000000..3a90f4a6 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/declaration-file.input.d.ts @@ -0,0 +1,9 @@ +import type { SafeAreaInset } from '@react-simplikit/mobile'; +declare module 'app' { + import { isIOS } from '@react-simplikit/mobile'; + export const inset: SafeAreaInset; + export const check: typeof isIOS; +} +declare global { + interface Window { inset?: import('@react-simplikit/mobile').SafeAreaInset } +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/declaration-file.output.d.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/declaration-file.output.d.ts new file mode 100644 index 00000000..bf4c1929 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/declaration-file.output.d.ts @@ -0,0 +1,9 @@ +import type { SafeAreaInset } from 'react-simplikit'; +declare module 'app' { + import { isIOS } from 'react-simplikit'; + export const inset: SafeAreaInset; + export const check: typeof isIOS; +} +declare global { + interface Window { inset?: import('react-simplikit').SafeAreaInset } +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/default-import.input.mjs b/packages/codemods/src/transforms/testfixtures/mobile-to-root/default-import.input.mjs new file mode 100644 index 00000000..e9ce8398 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/default-import.input.mjs @@ -0,0 +1,3 @@ +import mobile, { isIOS } from '@react-simplikit/mobile'; +import { useToggle } from 'react-simplikit'; +export default { mobile, isIOS, useToggle }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/default-import.output.mjs b/packages/codemods/src/transforms/testfixtures/mobile-to-root/default-import.output.mjs new file mode 100644 index 00000000..f5da3c9b --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/default-import.output.mjs @@ -0,0 +1,3 @@ +import mobile, { isIOS } from 'react-simplikit'; +import { useToggle } from 'react-simplikit'; +export default { mobile, isIOS, useToggle }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/dependencies.input.json b/packages/codemods/src/transforms/testfixtures/mobile-to-root/dependencies.input.json new file mode 100644 index 00000000..8a46dc9c --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/dependencies.input.json @@ -0,0 +1,8 @@ +{ + "name": "web", + "dependencies": { + "@react-simplikit/mobile": "^0.1.3", + "react": "^18.3.1", + "react-simplikit": "^0.1.0" + } +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/dependencies.output.json b/packages/codemods/src/transforms/testfixtures/mobile-to-root/dependencies.output.json new file mode 100644 index 00000000..e4c2f450 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/dependencies.output.json @@ -0,0 +1,7 @@ +{ + "name": "web", + "dependencies": { + "react": "^18.3.1", + "react-simplikit": "^0.2.0" + } +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/duplicate-binding.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/duplicate-binding.input.ts new file mode 100644 index 00000000..a5f0b55f --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/duplicate-binding.input.ts @@ -0,0 +1,2 @@ +import { isIOS } from '@react-simplikit/mobile'; +import { isIOS } from 'react-simplikit'; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/empty-and-side-effect-imports.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/empty-and-side-effect-imports.input.ts new file mode 100644 index 00000000..8717f153 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/empty-and-side-effect-imports.input.ts @@ -0,0 +1,5 @@ +import {} from 'react-simplikit'; +import { useSafeAreaInset } from '@react-simplikit/mobile'; +import {} from '@react-simplikit/mobile'; +import '@react-simplikit/mobile'; +export { useSafeAreaInset }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/empty-and-side-effect-imports.output.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/empty-and-side-effect-imports.output.ts new file mode 100644 index 00000000..200d4b22 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/empty-and-side-effect-imports.output.ts @@ -0,0 +1,3 @@ +import {useSafeAreaInset} from 'react-simplikit'; +import 'react-simplikit'; +export { useSafeAreaInset }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/flow.input.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/flow.input.js new file mode 100644 index 00000000..2cbd4719 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/flow.input.js @@ -0,0 +1,4 @@ +// @flow +import { isIOS } from '@react-simplikit/mobile'; +type Props = {| name: string |}; +export function f(p: Props): boolean { return isIOS(); } diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/flow.output.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/flow.output.js new file mode 100644 index 00000000..00eb3caa --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/flow.output.js @@ -0,0 +1,4 @@ +// @flow +import { isIOS } from 'react-simplikit'; +type Props = {| name: string |}; +export function f(p: Props): boolean { return isIOS(); } diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/import-equals.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/import-equals.input.ts new file mode 100644 index 00000000..7eb3528d --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/import-equals.input.ts @@ -0,0 +1,2 @@ +import mobile = require('@react-simplikit/mobile'); +export = mobile; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/import-equals.output.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/import-equals.output.ts new file mode 100644 index 00000000..8a041f57 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/import-equals.output.ts @@ -0,0 +1,2 @@ +import mobile = require('react-simplikit'); +export = mobile; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/jsx-in-js.input.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/jsx-in-js.input.js new file mode 100644 index 00000000..c423575c --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/jsx-in-js.input.js @@ -0,0 +1,2 @@ +import { isIOS } from '@react-simplikit/mobile'; +export const El = () =>
{isIOS() ? 'ios' : 'other'}
; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/jsx-in-js.output.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/jsx-in-js.output.js new file mode 100644 index 00000000..48748cde --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/jsx-in-js.output.js @@ -0,0 +1,2 @@ +import { isIOS } from 'react-simplikit'; +export const El = () =>
{isIOS() ? 'ios' : 'other'}
; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/merge.input.tsx b/packages/codemods/src/transforms/testfixtures/mobile-to-root/merge.input.tsx new file mode 100644 index 00000000..1e98fb5c --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/merge.input.tsx @@ -0,0 +1,20 @@ +'use client'; +/** + * Bottom sheet. + */ +import { useState } from 'react'; +import { useToggle } from 'react-simplikit'; +import { + useKeyboardHeight, + useSafeAreaInset, // insets for the notch +} from '@react-simplikit/mobile'; +import { isIOS as isApple } from '@react-simplikit/mobile'; +import type { SafeAreaInset } from "@react-simplikit/mobile"; + +export function Sheet({ items }: { items: T[] }) { + const [open, toggle] = useToggle(); + const [n] = useState(0); + const { keyboardHeight } = useKeyboardHeight(); + const inset: SafeAreaInset = useSafeAreaInset(); + return
{isApple() && open ? keyboardHeight + inset.bottom + n : items.length}
; +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/merge.output.tsx b/packages/codemods/src/transforms/testfixtures/mobile-to-root/merge.output.tsx new file mode 100644 index 00000000..c218a9af --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/merge.output.tsx @@ -0,0 +1,19 @@ +'use client'; +/** + * Bottom sheet. + */ +import { useState } from 'react'; +import { useToggle, isIOS as isApple } from 'react-simplikit'; +import { + useKeyboardHeight, + useSafeAreaInset, // insets for the notch +} from 'react-simplikit'; +import type { SafeAreaInset } from "react-simplikit"; + +export function Sheet({ items }: { items: T[] }) { + const [open, toggle] = useToggle(); + const [n] = useState(0); + const { keyboardHeight } = useKeyboardHeight(); + const inset: SafeAreaInset = useSafeAreaInset(); + return
{isApple() && open ? keyboardHeight + inset.bottom + n : items.length}
; +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/modern-syntax.input.tsx b/packages/codemods/src/transforms/testfixtures/mobile-to-root/modern-syntax.input.tsx new file mode 100644 index 00000000..249a0380 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/modern-syntax.input.tsx @@ -0,0 +1,9 @@ +import { useToggle, type UseToggleReturn } from 'react-simplikit'; +import { useKeyboardHeight, type SafeAreaInset } from '@react-simplikit/mobile'; + +const conf = { open: false } satisfies { open: boolean }; +class Store { @observable count = 0; } +declare function observable(...args: unknown[]): void; +export function C(): JSX.Element { const k = useKeyboardHeight(); return <>{String(conf.open)}{k.keyboardHeight}; } +export type T = [UseToggleReturn, SafeAreaInset, Store]; +export { useToggle }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/modern-syntax.output.tsx b/packages/codemods/src/transforms/testfixtures/mobile-to-root/modern-syntax.output.tsx new file mode 100644 index 00000000..3419f05d --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/modern-syntax.output.tsx @@ -0,0 +1,8 @@ +import { useToggle, type UseToggleReturn, useKeyboardHeight, type SafeAreaInset } from 'react-simplikit'; + +const conf = { open: false } satisfies { open: boolean }; +class Store { @observable count = 0; } +declare function observable(...args: unknown[]): void; +export function C(): JSX.Element { const k = useKeyboardHeight(); return <>{String(conf.open)}{k.keyboardHeight}; } +export type T = [UseToggleReturn, SafeAreaInset, Store]; +export { useToggle }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/module-name-mapper.input.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/module-name-mapper.input.js new file mode 100644 index 00000000..85fd742a --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/module-name-mapper.input.js @@ -0,0 +1,3 @@ +module.exports = { + moduleNameMapper: { '^@react-simplikit/mobile$': '/stub.js' }, +}; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/module-name-mapper.output.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/module-name-mapper.output.js new file mode 100644 index 00000000..85fd742a --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/module-name-mapper.output.js @@ -0,0 +1,3 @@ +module.exports = { + moduleNameMapper: { '^@react-simplikit/mobile$': '/stub.js' }, +}; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/no-mobile-import.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/no-mobile-import.input.ts new file mode 100644 index 00000000..887709ff --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/no-mobile-import.input.ts @@ -0,0 +1,3 @@ +import { useToggle } from 'react-simplikit'; + +export const toggle = useToggle; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/resolutions.input.json b/packages/codemods/src/transforms/testfixtures/mobile-to-root/resolutions.input.json new file mode 100644 index 00000000..0ef4d110 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/resolutions.input.json @@ -0,0 +1,5 @@ +{ + "name": "monorepo", + "workspaces": ["apps/*", "packages/*"], + "resolutions": { "@react-simplikit/mobile": "0.1.0" } +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/resolutions.output.json b/packages/codemods/src/transforms/testfixtures/mobile-to-root/resolutions.output.json new file mode 100644 index 00000000..0ef4d110 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/resolutions.output.json @@ -0,0 +1,5 @@ +{ + "name": "monorepo", + "workspaces": ["apps/*", "packages/*"], + "resolutions": { "@react-simplikit/mobile": "0.1.0" } +} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/same-line.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/same-line.input.ts new file mode 100644 index 00000000..524baefb --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/same-line.input.ts @@ -0,0 +1 @@ +import { useToggle } from 'react-simplikit'; import { isIOS } from '@react-simplikit/mobile'; export const x = [useToggle, isIOS]; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/same-line.output.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/same-line.output.ts new file mode 100644 index 00000000..4f9cd585 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/same-line.output.ts @@ -0,0 +1 @@ +import { useToggle, isIOS } from 'react-simplikit'; export const x = [useToggle, isIOS]; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/sloppy-script.input.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/sloppy-script.input.js new file mode 100644 index 00000000..45d9f5f9 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/sloppy-script.input.js @@ -0,0 +1,3 @@ +var m = require('@react-simplikit/mobile'); +var octal = 010; +module.exports = m; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/sloppy-script.output.js b/packages/codemods/src/transforms/testfixtures/mobile-to-root/sloppy-script.output.js new file mode 100644 index 00000000..45c3751f --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/sloppy-script.output.js @@ -0,0 +1,3 @@ +var m = require('react-simplikit'); +var octal = 010; +module.exports = m; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/specifier-forms.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/specifier-forms.input.ts new file mode 100644 index 00000000..a106e6b0 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/specifier-forms.input.ts @@ -0,0 +1,9 @@ +export async function load() { + const mobile = await import('@react-simplikit/mobile'); + const path = require.resolve('@react-simplikit/mobile'); + type Inset = import('@react-simplikit/mobile').SafeAreaInset; + const x: Inset | undefined = undefined; + return { mobile, path, x, tpl: require(`@react-simplikit/mobile`) }; +} +export * from '@react-simplikit/mobile'; +export { isIOS as default } from '@react-simplikit/mobile'; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/specifier-forms.output.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/specifier-forms.output.ts new file mode 100644 index 00000000..4eaf69d7 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/specifier-forms.output.ts @@ -0,0 +1,9 @@ +export async function load() { + const mobile = await import('react-simplikit'); + const path = require.resolve('react-simplikit'); + type Inset = import('react-simplikit').SafeAreaInset; + const x: Inset | undefined = undefined; + return { mobile, path, x, tpl: require(`react-simplikit`) }; +} +export * from 'react-simplikit'; +export { isIOS as default } from 'react-simplikit'; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/string-mention.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/string-mention.input.ts new file mode 100644 index 00000000..f3f1176f --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/string-mention.input.ts @@ -0,0 +1,2 @@ +// Migrated from @react-simplikit/mobile. +export const docs = 'see @react-simplikit/mobile'; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/subpath.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/subpath.input.ts new file mode 100644 index 00000000..c9cb5354 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/subpath.input.ts @@ -0,0 +1,3 @@ +import { internal } from '@react-simplikit/mobile/extra'; + +export { internal }; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/tabs.input.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/tabs.input.ts new file mode 100644 index 00000000..9dd351fd --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/tabs.input.ts @@ -0,0 +1,4 @@ +import { + useLoading +} from 'react-simplikit'; +import { isIOS } from '@react-simplikit/mobile'; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/tabs.output.ts b/packages/codemods/src/transforms/testfixtures/mobile-to-root/tabs.output.ts new file mode 100644 index 00000000..7624d45e --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/tabs.output.ts @@ -0,0 +1,4 @@ +import { + useLoading, + isIOS +} from 'react-simplikit'; diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/test-mocks.input.tsx b/packages/codemods/src/transforms/testfixtures/mobile-to-root/test-mocks.input.tsx new file mode 100644 index 00000000..c74cc521 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/test-mocks.input.tsx @@ -0,0 +1,11 @@ +import { vi, describe, it, expect } from 'vitest'; +import * as mobile from '@react-simplikit/mobile'; + +vi.mock('@react-simplikit/mobile', async () => ({ + ...(await vi.importActual('@react-simplikit/mobile')), + isIOS: () => true, +})); + +describe('@react-simplikit/mobile', () => { + it('works', () => expect(mobile.isIOS()).toBe(true)); +}); diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/test-mocks.output.tsx b/packages/codemods/src/transforms/testfixtures/mobile-to-root/test-mocks.output.tsx new file mode 100644 index 00000000..854b8deb --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/test-mocks.output.tsx @@ -0,0 +1,11 @@ +import { vi, describe, it, expect } from 'vitest'; +import * as mobile from 'react-simplikit'; + +vi.mock('react-simplikit', async () => ({ + ...(await vi.importActual('react-simplikit')), + isIOS: () => true, +})); + +describe('@react-simplikit/mobile', () => { + it('works', () => expect(mobile.isIOS()).toBe(true)); +}); diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/workspace-and-peer.input.json b/packages/codemods/src/transforms/testfixtures/mobile-to-root/workspace-and-peer.input.json new file mode 100644 index 00000000..594008fd --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/workspace-and-peer.input.json @@ -0,0 +1 @@ +{"name":"ui","peerDependencies":{"@react-simplikit/mobile":"*"},"devDependencies":{"@react-simplikit/mobile":"workspace:*"}} diff --git a/packages/codemods/src/transforms/testfixtures/mobile-to-root/workspace-and-peer.output.json b/packages/codemods/src/transforms/testfixtures/mobile-to-root/workspace-and-peer.output.json new file mode 100644 index 00000000..2bdb50a6 --- /dev/null +++ b/packages/codemods/src/transforms/testfixtures/mobile-to-root/workspace-and-peer.output.json @@ -0,0 +1,9 @@ +{ + "name": "ui", + "peerDependencies": { + "react-simplikit": ">=0.2.0" + }, + "devDependencies": { + "react-simplikit": "workspace:*" + } +} diff --git a/packages/codemods/src/transforms/tests/mobile-to-root.test.ts b/packages/codemods/src/transforms/tests/mobile-to-root.test.ts new file mode 100644 index 00000000..44c638fa --- /dev/null +++ b/packages/codemods/src/transforms/tests/mobile-to-root.test.ts @@ -0,0 +1,310 @@ +import type { API } from 'jscodeshift'; +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { describe, expect, it, vi } from 'vitest'; + +import transform from '../mobile-to-root.ts'; + +// Read as bytes on purpose: line endings, a BOM and the final newline are part of what the transform must keep. +function readFixture(fileName: string) { + return readFileSync(join(__dirname, '../testfixtures/mobile-to-root', fileName), 'utf8'); +} + +function migrate(path: string, source: string, report = vi.fn()) { + return transform({ path, source }, { report } as unknown as API); +} + +describe('mobile-to-root — rewrites', () => { + it('folds a mobile import into the root import and leaves a commented one on its own line', () => { + const report = vi.fn(); + const expected = readFixture('merge.output.tsx'); + + const output = migrate('merge.tsx', readFixture('merge.input.tsx'), report); + const secondRun = migrate('merge.tsx', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).toHaveBeenCalledTimes(1); + }); + + it('appends to a tab-indented import one binding per line', () => { + const report = vi.fn(); + const expected = readFixture('tabs.output.ts'); + + const output = migrate('tabs.ts', readFixture('tabs.input.ts'), report); + const secondRun = migrate('tabs.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('keeps CRLF line endings', () => { + const report = vi.fn(); + const expected = readFixture('crlf.output.ts'); + + const output = migrate('crlf.ts', readFixture('crlf.input.ts'), report); + const secondRun = migrate('crlf.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('keeps a byte order mark', () => { + const report = vi.fn(); + const expected = readFixture('bom.output.ts'); + + const output = migrate('bom.ts', readFixture('bom.input.ts'), report); + const secondRun = migrate('bom.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('rewrites dynamic imports, require.resolve, import types, template literals and re-exports', () => { + const report = vi.fn(); + const expected = readFixture('specifier-forms.output.ts'); + + const output = migrate('specifier-forms.ts', readFixture('specifier-forms.input.ts'), report); + const secondRun = migrate('specifier-forms.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('rewrites vitest mocks and reports the package name left in a test title', () => { + const report = vi.fn(); + const expected = readFixture('test-mocks.output.tsx'); + + const output = migrate('test-mocks.tsx', readFixture('test-mocks.input.tsx'), report); + const secondRun = migrate('test-mocks.tsx', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).toHaveBeenCalledTimes(1); + }); + + it('rewrites require and jest mocks in a .cjs file', () => { + const report = vi.fn(); + const expected = readFixture('commonjs.output.cjs'); + + const output = migrate('commonjs.cjs', readFixture('commonjs.input.cjs'), report); + const secondRun = migrate('commonjs.cjs', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('rewrites an import with a default binding in place in a .mjs file', () => { + const report = vi.fn(); + const expected = readFixture('default-import.output.mjs'); + + const output = migrate('default-import.mjs', readFixture('default-import.input.mjs'), report); + const secondRun = migrate('default-import.mjs', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('rewrites a declaration file without lifting imports out of declare module', () => { + const report = vi.fn(); + const expected = readFixture('declaration-file.output.d.ts'); + + const output = migrate('declaration-file.d.ts', readFixture('declaration-file.input.d.ts'), report); + const secondRun = migrate('declaration-file.d.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('rewrites import-equals', () => { + const report = vi.fn(); + const expected = readFixture('import-equals.output.ts'); + + const output = migrate('import-equals.ts', readFixture('import-equals.input.ts'), report); + const secondRun = migrate('import-equals.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('parses satisfies, decorators and inline type modifiers', () => { + const report = vi.fn(); + const expected = readFixture('modern-syntax.output.tsx'); + + const output = migrate('modern-syntax.tsx', readFixture('modern-syntax.input.tsx'), report); + const secondRun = migrate('modern-syntax.tsx', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('merges an empty named import and rewrites a side-effect import', () => { + const report = vi.fn(); + const expected = readFixture('empty-and-side-effect-imports.output.ts'); + + const output = migrate( + 'empty-and-side-effect-imports.ts', + readFixture('empty-and-side-effect-imports.input.ts'), + report + ); + const secondRun = migrate('empty-and-side-effect-imports.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('merges an import that shares its line with other statements', () => { + const report = vi.fn(); + const expected = readFixture('same-line.output.ts'); + + const output = migrate('same-line.ts', readFixture('same-line.input.ts'), report); + const secondRun = migrate('same-line.ts', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('reads a Flow-annotated .js file', () => { + const report = vi.fn(); + const expected = readFixture('flow.output.js'); + + const output = migrate('flow.js', readFixture('flow.input.js'), report); + const secondRun = migrate('flow.js', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('reads a sloppy-mode script', () => { + const report = vi.fn(); + const expected = readFixture('sloppy-script.output.js'); + + const output = migrate('sloppy-script.js', readFixture('sloppy-script.input.js'), report); + const secondRun = migrate('sloppy-script.js', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('reads JSX in a .js file', () => { + const report = vi.fn(); + const expected = readFixture('jsx-in-js.output.js'); + + const output = migrate('jsx-in-js.js', readFixture('jsx-in-js.input.js'), report); + const secondRun = migrate('jsx-in-js.js', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); +}); + +describe('mobile-to-root — package.json', () => { + it('replaces the dependency and raises the react-simplikit floor', () => { + const report = vi.fn(); + const expected = readFixture('dependencies.output.json'); + + const output = migrate('package.json', readFixture('dependencies.input.json'), report); + const secondRun = migrate('package.json', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).not.toHaveBeenCalled(); + }); + + it('writes a >= floor for peerDependencies and reports a workspace: protocol', () => { + const report = vi.fn(); + const expected = readFixture('workspace-and-peer.output.json'); + + const output = migrate('package.json', readFixture('workspace-and-peer.input.json'), report); + const secondRun = migrate('package.json', expected); + + expect(output).toBe(expected); + expect(secondRun).toBe(expected); + expect(report).toHaveBeenCalledTimes(1); + }); + + it('reports resolutions without editing them', () => { + const report = vi.fn(); + const input = readFixture('resolutions.input.json'); + + const output = migrate('package.json', input, report); + + expect(output).toBe(input); + expect(report).toHaveBeenCalledTimes(1); + }); + + it('skips every other JSON file', () => { + const source = JSON.stringify({ paths: { '@react-simplikit/mobile': ['./stub'] } }); + + const output = migrate('tsconfig.json', source); + + expect(output).toBeUndefined(); + }); +}); + +describe('mobile-to-root — files it must not change', () => { + it('returns a file without the package byte for byte', () => { + const report = vi.fn(); + const input = readFixture('no-mobile-import.input.ts'); + + const output = migrate('no-mobile-import.ts', input, report); + + expect(output).toBe(input); + expect(report).not.toHaveBeenCalled(); + }); + + it('leaves a moduleNameMapper entry and reports it', () => { + const report = vi.fn(); + const input = readFixture('module-name-mapper.input.js'); + + const output = migrate('jest.config.js', input, report); + + expect(output).toBe(input); + expect(report).toHaveBeenCalledTimes(1); + }); + + it('leaves the package name in comments and strings and reports it', () => { + const report = vi.fn(); + const input = readFixture('string-mention.input.ts'); + + const output = migrate('string-mention.ts', input, report); + + expect(output).toBe(input); + expect(report).toHaveBeenCalledTimes(1); + }); + + it('leaves a subpath import and reports it', () => { + const report = vi.fn(); + const input = readFixture('subpath.input.ts'); + + const output = migrate('subpath.ts', input, report); + + expect(output).toBe(input); + expect(report).toHaveBeenCalledTimes(1); + }); +}); + +describe('mobile-to-root — files it cannot read', () => { + it('throws on a name imported twice, so jscodeshift reports the file', () => { + const report = vi.fn(); + + expect(() => migrate('duplicate-binding.ts', readFixture('duplicate-binding.input.ts'), report)).toThrow( + 'already been declared' + ); + expect(report).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/codemods/src/transforms/utils/mobileToRoot/collectSpecifiers.test.ts b/packages/codemods/src/transforms/utils/mobileToRoot/collectSpecifiers.test.ts new file mode 100644 index 00000000..c030ef86 --- /dev/null +++ b/packages/codemods/src/transforms/utils/mobileToRoot/collectSpecifiers.test.ts @@ -0,0 +1,274 @@ +import { describe, expect, it } from 'vitest'; + +import { collectSpecifiers, lineOf, parseSource } from './collectSpecifiers.ts'; + +// The source text of every specifier found, quotes included, so a test shows exactly what would be rewritten. +function specifiersIn(code: string, fileName = 'input.tsx') { + return collectSpecifiers(parseSource(code, fileName)).map(hit => code.slice(hit.literal.start, hit.literal.end)); +} + +describe('parseSource', () => { + it('parses an angle-bracket cast in a .ts file', () => { + const code = 'const a = b;'; + + expect(() => parseSource(code, 'a.ts')).not.toThrow(); + }); + + it('parses JSX in a .js file', () => { + const code = 'const a =
;'; + + expect(() => parseSource(code, 'a.js')).not.toThrow(); + }); + + it('reads a file without import or export as a sloppy-mode script', () => { + const code = `var m = require('@react-simplikit/mobile');\nvar octal = 010;\n`; + + expect(specifiersIn(code, 'legacy.js')).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('reads the deprecated import assertion syntax', () => { + const code = `import data from './a.json' assert { type: 'json' };\nimport { isIOS } from '@react-simplikit/mobile';\n`; + + expect(specifiersIn(code, 'input.ts')).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('falls back to Flow for a .js file the TSX parser rejects', () => { + const code = `// @flow\nimport { isIOS } from '@react-simplikit/mobile';\ntype Props = {| name: string |};\n`; + + expect(specifiersIn(code, 'flow.js')).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('does not fall back to Flow outside JavaScript files', () => { + const code = `type Props = {| name: string |};`; + + expect(() => parseSource(code, 'flow.tsx')).toThrow(SyntaxError); + }); + + it('throws on syntax no parser can read in a .ts file', () => { + const code = `import broken from someIdentifier;`; + + expect(() => parseSource(code, 'input.ts')).toThrow(SyntaxError); + }); + + it('throws the TSX error when the Flow fallback fails too', () => { + const code = `import broken from someIdentifier;`; + + expect(() => parseSource(code, 'input.js')).toThrow(SyntaxError); + }); +}); + +describe('lineOf', () => { + it('reports line 1 for the first character', () => { + const code = 'const a = 1;\nconst b = 2;\n'; + + expect(lineOf(code, 0)).toBe(1); + }); + + it('counts the lines before the position', () => { + const code = 'const a = 1;\nconst b = 2;\n'; + + expect(lineOf(code, 13)).toBe(2); + }); +}); + +describe('collectSpecifiers — what it finds', () => { + it('finds a named import', () => { + const code = `import { useKeyboardHeight } from '@react-simplikit/mobile';`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds a type-only import', () => { + const code = `import type { SafeAreaInset } from '@react-simplikit/mobile';`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds a namespace import', () => { + const code = `import * as mobile from '@react-simplikit/mobile';`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds a side-effect import', () => { + const code = `import '@react-simplikit/mobile';`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds a named re-export', () => { + const code = `export { isIOS } from '@react-simplikit/mobile';`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds a star re-export', () => { + const code = `export * from '@react-simplikit/mobile';`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds require', () => { + const code = `const m = require('@react-simplikit/mobile');`; + + expect(specifiersIn(code, 'input.cjs')).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds require with a template literal that has no substitutions', () => { + const code = 'const m = require(`@react-simplikit/mobile`);'; + + expect(specifiersIn(code, 'input.cjs')).toEqual(['`@react-simplikit/mobile`']); + }); + + it('finds a dynamic import', () => { + const code = `const m = await import('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds an import type node', () => { + const code = `type I = import('@react-simplikit/mobile').SafeAreaInset;`; + + expect(specifiersIn(code, 'input.ts')).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds vi.mock', () => { + const code = `vi.mock('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds jest.mock', () => { + const code = `jest.mock('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds jest.requireActual', () => { + const code = `jest.requireActual('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds vi.doUnmock', () => { + const code = `vi.doUnmock('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds jest.setMock', () => { + const code = `jest.setMock('@react-simplikit/mobile', {});`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds jest.createMockFromModule', () => { + const code = `jest.createMockFromModule('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds jest.genMockFromModule', () => { + const code = `jest.genMockFromModule('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('finds jest.deepUnmock', () => { + const code = `jest.deepUnmock('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([`'@react-simplikit/mobile'`]); + }); + + it('attaches the declaration to an import and not to a re-export', () => { + const code = [ + `import { isIOS } from '@react-simplikit/mobile';`, + `export { isAndroid } from '@react-simplikit/mobile';`, + ].join('\n'); + + const [importHit, exportHit] = collectSpecifiers(parseSource(code, 'input.ts')); + + expect(importHit?.declaration).toBeDefined(); + expect(exportHit?.declaration).toBeUndefined(); + }); +}); + +describe('collectSpecifiers — what it leaves alone', () => { + it('ignores the root package', () => { + const code = `import { useToggle } from 'react-simplikit';`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores a subpath of the old package', () => { + const code = `import { x } from '@react-simplikit/mobile/extra';`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores an import type node for another package', () => { + const code = `type X = import('react').FC;`; + + expect(specifiersIn(code, 'input.ts')).toEqual([]); + }); + + it('ignores the name in a plain string', () => { + const code = `const label = '@react-simplikit/mobile';`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores the name as an argument to an unrelated function', () => { + const code = `describe('@react-simplikit/mobile', () => {});`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores a local re-export without a source', () => { + const code = `const foo = 1;\nexport { foo };`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores mock on another object', () => { + const code = `other.mock('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores a vi method that does not take a module', () => { + const code = `vi.spyOn('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores a nested member call', () => { + const code = `a.b.mock('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores a computed member call', () => { + const code = `vi['mock']('@react-simplikit/mobile');`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores a call without arguments', () => { + const code = `noArgs();`; + + expect(specifiersIn(code)).toEqual([]); + }); + + it('ignores a template literal with substitutions', () => { + const code = 'require(`${prefix}/mobile`);'; + + expect(specifiersIn(code, 'input.cjs')).toEqual([]); + }); + + it('ignores a template literal naming another package', () => { + const code = 'const m = require(`react-simplikit`);'; + + expect(specifiersIn(code, 'input.cjs')).toEqual([]); + }); +}); diff --git a/packages/codemods/src/transforms/utils/mobileToRoot/collectSpecifiers.ts b/packages/codemods/src/transforms/utils/mobileToRoot/collectSpecifiers.ts new file mode 100644 index 00000000..d71bf4bc --- /dev/null +++ b/packages/codemods/src/transforms/utils/mobileToRoot/collectSpecifiers.ts @@ -0,0 +1,146 @@ +import j, { type CallExpression, type Collection, type File, type ImportDeclaration } from 'jscodeshift'; +// @ts-expect-error: Declaration files are not included +import babylon from 'jscodeshift/parser/babylon'; +// @ts-expect-error: Declaration files are not included +import tsOptions from 'jscodeshift/parser/tsOptions'; + +import { MOBILE_PACKAGE_NAME } from './constants.ts'; +import type { Comment, Span } from './types.ts'; + +export type ParsedSource = { + code: string; + root: Collection; + comments: Comment[]; +}; + +export type SpecifierHit = { + literal: Span; + declaration: ImportDeclaration | undefined; +}; + +const MOCK_OBJECTS = new Set(['vi', 'jest']); + +const MOCK_METHODS = new Set([ + 'mock', + 'doMock', + 'unmock', + 'dontMock', + 'requireActual', + 'requireMock', + 'importActual', + 'importMock', + 'doUnmock', + 'deepUnmock', + 'setMock', + 'createMockFromModule', + 'genMockFromModule', +]); + +type Parser = { parse: (code: string) => File & { comments: Comment[] } }; + +// `unambiguous` reads a file without import or export as a script, so sloppy-mode CommonJS still parses. +// `deprecatedAssertSyntax` keeps `import data from './a.json' assert { type: 'json' }` readable. +const tsPlugins: unknown[] = tsOptions.plugins.map((plugin: unknown) => + plugin === 'importAttributes' ? ['importAttributes', { deprecatedAssertSyntax: true }] : plugin +); +const tsParser: Parser = babylon({ ...tsOptions, sourceType: 'unambiguous', plugins: tsPlugins }); +const tsxParser: Parser = babylon({ ...tsOptions, sourceType: 'unambiguous', plugins: ['jsx', ...tsPlugins] }); +// jscodeshift's default Babel options read Flow and JSX. +const flowParser: Parser = babylon(); + +function parseFile(code: string, fileName: string) { + if (/\.[mc]?ts$/.test(fileName)) { + return tsParser.parse(code); + } + + try { + return tsxParser.parse(code); + } catch (error) { + if (!/\.[mc]?jsx?$/.test(fileName)) { + throw error; + } + + try { + return flowParser.parse(code); + } catch { + throw error; + } + } +} + +// Straight to Babel, not through recast: recast widens tabs before it records offsets, and the edits splice by offset. +export function parseSource(code: string, fileName: string): ParsedSource { + const file = parseFile(code, fileName); + + return { code, root: j(file), comments: file.comments }; +} + +// Babel records the offsets on every node; ast-types leaves them out of its types. +export function spanOf(node: object): Span { + return node as Span; +} + +export function lineOf(code: string, position: number): number { + return code.slice(0, position).split('\n').length; +} + +function mobileSpecifierOf(node: object | null | undefined): Span | undefined { + if (j.StringLiteral.check(node)) { + return node.value === MOBILE_PACKAGE_NAME ? spanOf(node) : undefined; + } + + if (j.TemplateLiteral.check(node) && node.expressions.length === 0) { + return node.quasis[0]?.value.cooked === MOBILE_PACKAGE_NAME ? spanOf(node) : undefined; + } + + return undefined; +} + +function takesModuleSpecifier(callee: CallExpression['callee']) { + if (callee.type === 'Import') { + return true; + } + + if (j.Identifier.check(callee)) { + return callee.name === 'require'; + } + + if ( + !j.MemberExpression.check(callee) || + callee.computed === true || + !j.Identifier.check(callee.object) || + !j.Identifier.check(callee.property) + ) { + return false; + } + + const object = callee.object.name; + const method = callee.property.name; + + return (object === 'require' && method === 'resolve') || (MOCK_OBJECTS.has(object) && MOCK_METHODS.has(method)); +} + +export function collectSpecifiers({ root }: ParsedSource): SpecifierHit[] { + const hits: SpecifierHit[] = []; + + function add(node: object | null | undefined, declaration?: ImportDeclaration) { + const literal = mobileSpecifierOf(node); + + if (literal !== undefined) { + hits.push({ literal, declaration }); + } + } + + root.find(j.ImportDeclaration).forEach(path => add(path.node.source, path.node)); + root.find(j.ExportNamedDeclaration).forEach(path => add(path.node.source)); + root.find(j.ExportAllDeclaration).forEach(path => add(path.node.source)); + root.find(j.TSImportType).forEach(path => add(path.node.argument)); + root.find(j.TSExternalModuleReference).forEach(path => add(path.node.expression)); + root.find(j.CallExpression).forEach(path => { + if (takesModuleSpecifier(path.node.callee)) { + add(path.node.arguments[0]); + } + }); + + return hits; +} diff --git a/packages/codemod/src/constants.ts b/packages/codemods/src/transforms/utils/mobileToRoot/constants.ts similarity index 87% rename from packages/codemod/src/constants.ts rename to packages/codemods/src/transforms/utils/mobileToRoot/constants.ts index c631d3e4..fd4e8864 100644 --- a/packages/codemod/src/constants.ts +++ b/packages/codemods/src/transforms/utils/mobileToRoot/constants.ts @@ -2,8 +2,6 @@ export const MOBILE_PACKAGE_NAME = '@react-simplikit/mobile'; export const ROOT_PACKAGE_NAME = 'react-simplikit'; -export const TRANSFORM_NAME = 'mobile-to-root'; - // Must name a version that is actually published: a range nothing satisfies breaks every // migrated install with ETARGET. Check `npm view react-simplikit version` before releasing. export const MIN_RUNTIME_VERSION = '0.2.0'; diff --git a/packages/codemods/src/transforms/utils/mobileToRoot/mergeImports.ts b/packages/codemods/src/transforms/utils/mobileToRoot/mergeImports.ts new file mode 100644 index 00000000..6718cb02 --- /dev/null +++ b/packages/codemods/src/transforms/utils/mobileToRoot/mergeImports.ts @@ -0,0 +1,148 @@ +import j, { type ImportDeclaration, type ImportSpecifier } from 'jscodeshift'; + +import { lineOf, type ParsedSource, spanOf, type SpecifierHit } from './collectSpecifiers.ts'; +import { ROOT_PACKAGE_NAME } from './constants.ts'; +import type { SourceNote, Splice } from './types.ts'; + +export type MergeResult = { + splices: Splice[]; + notes: SourceNote[]; + mergedDeclarations: Set; +}; + +type PlainNamedImport = { + declaration: ImportDeclaration; + elements: ImportSpecifier[]; + isTypeOnly: boolean; +}; + +function plainNamedImportOf(code: string, declaration: ImportDeclaration): PlainNamedImport | undefined { + // Babel always fills the list; ast-types marks it optional. + const specifiers = declaration.specifiers!; + const elements = specifiers.filter(specifier => j.ImportSpecifier.check(specifier)); + + if (elements.length !== specifiers.length) { + return undefined; + } + + // Babel gives `import {} from 'x'` and `import 'x'` the same empty list; only the braces tell them apart. + if (elements.length === 0 && !code.slice(spanOf(declaration).start, spanOf(declaration.source).start).includes('{')) { + return undefined; + } + + return { declaration, elements, isTypeOnly: declaration.importKind === 'type' }; +} + +function deletionRange(code: string, statement: ImportDeclaration): Splice { + const { start, end } = spanOf(statement); + + const lineStart = code.lastIndexOf('\n', start - 1) + 1; + const newlineIndex = code.indexOf('\n', end); + const lineEnd = newlineIndex === -1 ? code.length : newlineIndex + 1; + + const ownsLine = code.slice(lineStart, start).trim() === '' && code.slice(end, lineEnd).trim() === ''; + + return ownsLine ? { start: lineStart, end: lineEnd, text: '' } : { start, end, text: '' }; +} + +function lineStartOf(code: string, position: number) { + return code.lastIndexOf('\n', position - 1) + 1; +} + +// A comment on the import's own line, or a line comment right above it such as `// @ts-expect-error`, +// would end up on another statement once the import is removed. +function losesComment({ code, comments }: ParsedSource, statement: ImportDeclaration) { + const { start, end } = spanOf(statement); + const newlineIndex = code.indexOf('\n', end); + const lineEnd = newlineIndex === -1 ? code.length : newlineIndex; + const previousLineStart = lineStartOf(code, lineStartOf(code, start) - 1); + + return comments.some( + comment => + (comment.start >= start && comment.start < lineEnd) || + (comment.type === 'CommentLine' && + comment.start >= previousLineStart && + comment.end < start && + code.slice(lineStartOf(code, comment.start), comment.start).trim() === '') + ); +} + +function elementSeparator(code: string, last: ImportSpecifier) { + const lastStart = spanOf(last).start; + const lead = code.slice(lineStartOf(code, lastStart), lastStart); + const newline = code.includes('\r\n') ? '\r\n' : '\n'; + + return lead.trim() === '' ? `,${newline}${lead}` : ', '; +} + +function insertIntoNamedImports(code: string, target: PlainNamedImport, appended: readonly string[]): Splice { + const last = target.elements.at(-1); + + if (last === undefined) { + const position = code.indexOf('{', spanOf(target.declaration).start) + 1; + + return { start: position, end: position, text: appended.join(', ') }; + } + + const separator = elementSeparator(code, last); + const position = spanOf(last).end; + + return { start: position, end: position, text: `${separator}${appended.join(separator)}` }; +} + +// Babel rejects a name imported twice in one scope, so two imports that reach this point never bind the same name. +export function buildMergeSplices(parsed: ParsedSource, hits: readonly SpecifierHit[]): MergeResult { + const { code } = parsed; + const statements = parsed.root.find(j.Program).nodes()[0].body; + const targets = statements + .filter(statement => j.ImportDeclaration.check(statement)) + .filter(statement => statement.source.value === ROOT_PACKAGE_NAME) + .map(statement => plainNamedImportOf(code, statement)) + .filter(target => target !== undefined); + const splices: Splice[] = []; + const notes: SourceNote[] = []; + const mergedDeclarations = new Set(); + const appendedByTarget = new Map(); + + for (const { declaration } of hits) { + if (declaration === undefined || !statements.includes(declaration)) { + continue; + } + + const source = plainNamedImportOf(code, declaration); + + if (source === undefined) { + continue; + } + + const target = targets.find(candidate => candidate.isTypeOnly === source.isTypeOnly); + + if (target === undefined) { + continue; + } + + const line = lineOf(code, spanOf(declaration).start); + + if (losesComment(parsed, declaration)) { + notes.push({ + line, + reason: 'Left on its own line: a comment sits on it or right above it, and merging would strand that comment.', + }); + continue; + } + + const additions = source.elements.map(element => code.slice(spanOf(element).start, spanOf(element).end)); + + appendedByTarget.set(target, [...(appendedByTarget.get(target) ?? []), ...additions]); + splices.push(deletionRange(code, declaration)); + mergedDeclarations.add(declaration); + } + + for (const [target, appended] of appendedByTarget) { + if (appended.length > 0) { + splices.push(insertIntoNamedImports(code, target, appended)); + } + } + + return { splices, notes, mergedDeclarations }; +} diff --git a/packages/codemods/src/transforms/utils/mobileToRoot/transformPackageJson.test.ts b/packages/codemods/src/transforms/utils/mobileToRoot/transformPackageJson.test.ts new file mode 100644 index 00000000..233537c1 --- /dev/null +++ b/packages/codemods/src/transforms/utils/mobileToRoot/transformPackageJson.test.ts @@ -0,0 +1,284 @@ +import fc from 'fast-check'; +import semver from 'semver'; +import { describe, expect, it } from 'vitest'; + +import { transformPackageJson } from './transformPackageJson.ts'; + +// The react-simplikit spec the transform leaves in `field`, so a range test reads as one value. +function rootSpecAfter(input: string, field = 'dependencies'): unknown { + const manifest: Record | undefined> = JSON.parse(transformPackageJson(input).text); + + return manifest[field]?.['react-simplikit']; +} + +describe('transformPackageJson — dependency fields', () => { + it('swaps the mobile dependency for the root package', () => { + const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1",\n "react": "^19.0.0"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe( + `{\n "dependencies": {\n "react": "^19.0.0",\n "react-simplikit": "^0.2.0"\n }\n}\n` + ); + expect(result.manual).toEqual([]); + }); + + it('only removes the old entry when the root package already satisfies the floor', () => { + const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1",\n "react-simplikit": "^0.2.0"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "dependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n`); + }); + + it('swaps the dependency in devDependencies', () => { + const input = `{\n "devDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "devDependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n`); + }); + + it('swaps the dependency in optionalDependencies', () => { + const input = `{\n "optionalDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "optionalDependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n`); + }); + + it('swaps the dependency in every field that declared it', () => { + const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n },\n "devDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe( + `{\n "dependencies": {\n "react-simplikit": "^0.2.0"\n },\n "devDependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n` + ); + }); + + it('adds the root package to the field that had the old one even when another field already has it', () => { + const input = `{\n "devDependencies": {\n "react-simplikit": "^0.2.0"\n },\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe( + `{\n "devDependencies": {\n "react-simplikit": "^0.2.0"\n },\n "dependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n` + ); + }); + + it('writes a >= floor for peerDependencies', () => { + const input = `{\n "peerDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "peerDependencies": {\n "react-simplikit": ">=0.2.0"\n }\n}\n`); + }); + + it('skips a dependency field that is a string', () => { + const input = `{\n "dependencies": "@react-simplikit/mobile"\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "dependencies": "@react-simplikit/mobile"\n}\n`); + }); + + it('skips a dependency field that is null and still rewrites the others', () => { + const input = `{\n "dependencies": null,\n "devDependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe( + `{\n "dependencies": null,\n "devDependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n` + ); + }); +}); + +describe('transformPackageJson — formatting', () => { + it('keeps four-space indentation and the trailing newline', () => { + const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "dependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n`); + }); + + it('keeps the absence of a trailing newline', () => { + const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "dependencies": {\n "react-simplikit": "^0.2.0"\n }\n}`); + }); + + it('falls back to two-space indentation for a single-line manifest', () => { + const input = `{"dependencies":{"@react-simplikit/mobile":"^0.1.1"}}`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "dependencies": {\n "react-simplikit": "^0.2.0"\n }\n}`); + }); +}); + +describe('transformPackageJson — a byte order mark', () => { + it('reads a manifest that starts with a byte order mark and keeps the mark', () => { + const input = `\uFEFF{\n "dependencies": {\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`\uFEFF{\n "dependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n`); + }); +}); + +describe('transformPackageJson — what it leaves alone', () => { + it('returns a manifest without the old package untouched', () => { + const input = `{\n "dependencies": {\n "react": "^19.0.0"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(`{\n "dependencies": {\n "react": "^19.0.0"\n }\n}\n`); + expect(result.manual).toEqual([]); + }); + + it('reports resolutions and overrides instead of editing them', () => { + const input = `{\n "resolutions": {\n "@react-simplikit/mobile": "0.1.1"\n },\n "overrides": {\n "@react-simplikit/mobile": "0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(input); + expect(result.manual).toEqual([expect.stringContaining('"resolutions"'), expect.stringContaining('"overrides"')]); + }); + + it('reports a mention outside the dependency fields', () => { + const input = `{\n "peerDependenciesMeta": {\n "@react-simplikit/mobile": { "optional": true }\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(result.text).toBe(input); + expect(result.manual).toEqual([expect.stringContaining('outside the dependency fields')]); + }); + + it('throws when the manifest root is not an object', () => { + const input = `["@react-simplikit/mobile"]`; + + expect(() => transformPackageJson(input)).toThrow('package.json must contain a JSON object at its root'); + }); +}); + +describe('transformPackageJson — the react-simplikit range it writes', () => { + it('raises an existing range that sits below the floor', () => { + const input = `{\n "dependencies": {\n "react-simplikit": "^0.1.0",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + expect(rootSpecAfter(input)).toBe('^0.2.0'); + }); + + it('keeps an existing range that already satisfies the floor', () => { + const input = `{\n "dependencies": {\n "react-simplikit": "^0.9.0",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + expect(rootSpecAfter(input)).toBe('^0.9.0'); + }); + + it('keeps a range sitting exactly on the floor', () => { + const input = `{\n "dependencies": {\n "react-simplikit": "^0.2.0",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + expect(rootSpecAfter(input)).toBe('^0.2.0'); + }); + + it('keeps a range whose major is above the floor even when its minor is lower', () => { + const input = `{\n "dependencies": {\n "react-simplikit": "^1.0.0",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + expect(rootSpecAfter(input)).toBe('^1.0.0'); + }); + + it('raises a wildcard, because a lockfile could keep a version below the floor under it', () => { + const input = `{\n "dependencies": {\n "react-simplikit": "*",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + expect(rootSpecAfter(input)).toBe('^0.2.0'); + }); + + it('widens a peer range instead of narrowing it', () => { + const input = `{\n "peerDependencies": {\n "@react-simplikit/mobile": ">=0.1.0"\n }\n}\n`; + + expect(rootSpecAfter(input, 'peerDependencies')).toBe('>=0.2.0'); + }); +}); + +describe('transformPackageJson — specs that are not version ranges', () => { + it('keeps a workspace: spec from the old package and reports it', () => { + const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "workspace:*"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(rootSpecAfter(input)).toBe('workspace:*'); + expect(result.manual).toEqual([expect.stringContaining('workspace:*')]); + }); + + it('keeps a file: path from the old package without reading a version out of it', () => { + const input = `{\n "dependencies": {\n "@react-simplikit/mobile": "file:../mobile-0.1.1.tgz"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(rootSpecAfter(input)).toBe('file:../mobile-0.1.1.tgz'); + expect(result.manual).toEqual([expect.stringContaining('file:../mobile-0.1.1.tgz')]); + }); + + it('keeps an existing workspace: root spec and reports that the floor is unchecked', () => { + const input = `{\n "dependencies": {\n "react-simplikit": "workspace:*",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(rootSpecAfter(input)).toBe('workspace:*'); + expect(result.manual).toEqual([expect.stringContaining('workspace:*')]); + }); + + it('keeps an existing protocol spec that carries a version instead of flattening it', () => { + const input = `{\n "dependencies": {\n "react-simplikit": "workspace:^0.1.1",\n "@react-simplikit/mobile": "^0.1.1"\n }\n}\n`; + + const result = transformPackageJson(input); + + expect(rootSpecAfter(input)).toBe('workspace:^0.1.1'); + expect(result.manual).toEqual([expect.stringContaining('workspace:^0.1.1')]); + }); +}); + +describe('transformPackageJson — the floor holds for any registry range', () => { + const version = fc.tuple(fc.nat({ max: 3 }), fc.nat({ max: 12 }), fc.nat({ max: 12 })).map(parts => parts.join('.')); + const range = fc.oneof( + version, + version.map(v => `^${v}`), + version.map(v => `~${v}`), + version.map(v => `>=${v}`), + version.map(v => `<${v}`), + version.map(v => `${v}-beta.1`), + fc.constantFrom('*', '', 'x', '0.x', '1.x') + ); + + // A property test needs an oracle: semver, not the transform, decides what the right answer is. + it('leaves a range alone exactly when every version it admits is on or above the floor', () => { + fc.assert( + fc.property(range, existing => { + const input = JSON.stringify({ + dependencies: { 'react-simplikit': existing, '@react-simplikit/mobile': '^0.1.1' }, + }); + + const output = rootSpecAfter(input); + + expect(output).toBe(semver.subset(existing, '>=0.2.0') ? existing : '^0.2.0'); + }) + ); + }); + + it('always writes a range that clears the floor', () => { + fc.assert( + fc.property(range, existing => { + const input = JSON.stringify({ + dependencies: { 'react-simplikit': existing, '@react-simplikit/mobile': '^0.1.1' }, + }); + + const output = rootSpecAfter(input); + + expect(semver.subset(String(output), '>=0.2.0')).toBe(true); + }) + ); + }); +}); diff --git a/packages/codemod/src/mobileToRoot/transformPackageJson.ts b/packages/codemods/src/transforms/utils/mobileToRoot/transformPackageJson.ts similarity index 78% rename from packages/codemod/src/mobileToRoot/transformPackageJson.ts rename to packages/codemods/src/transforms/utils/mobileToRoot/transformPackageJson.ts index 01d8eb5b..f524d956 100644 --- a/packages/codemod/src/mobileToRoot/transformPackageJson.ts +++ b/packages/codemods/src/transforms/utils/mobileToRoot/transformPackageJson.ts @@ -1,23 +1,15 @@ import detectIndent from 'detect-indent'; import semver from 'semver'; -import { MIN_RUNTIME_VERSION, MOBILE_PACKAGE_NAME, ROOT_PACKAGE_NAME } from '../constants.ts'; - -export type PackageJsonChange = { - field: string; - removed: string; - added: string | null; -}; +import { MIN_RUNTIME_VERSION, MOBILE_PACKAGE_NAME, ROOT_PACKAGE_NAME } from './constants.ts'; type TransformPackageJsonResult = { text: string; - changes: PackageJsonChange[]; manual: string[]; }; type RootDependency = { spec: unknown; - added: string | null; manual: string[]; }; @@ -37,7 +29,6 @@ function rootDependencyFor(field: string, existing: unknown, previous: unknown): if (typeof existing === 'string' && semver.validRange(existing) === null) { return { spec: existing, - added: null, manual: [ `"${field}" points ${ROOT_PACKAGE_NAME} at \`${existing}\`, so its version cannot be checked against the ${MIN_RUNTIME_VERSION} floor. Confirm that source ships ${MIN_RUNTIME_VERSION} or newer.`, ], @@ -46,39 +37,38 @@ function rootDependencyFor(field: string, existing: unknown, previous: unknown): // `*` and `>=0.1.0` still admit a version below the floor, and a lockfile would keep one there. if (typeof existing === 'string' && semver.subset(existing, FLOOR_RANGE)) { - return { spec: existing, added: null, manual: [] }; + return { spec: existing, manual: [] }; } if (typeof previous === 'string' && semver.validRange(previous) === null) { return { spec: previous, - added: null, manual: [ `"${field}" pinned ${MOBILE_PACKAGE_NAME} as \`${previous}\`, which is not a version range. Point ${ROOT_PACKAGE_NAME} at the same source by hand.`, ], }; } - const added = field === 'peerDependencies' ? FLOOR_RANGE : `^${MIN_RUNTIME_VERSION}`; - - return { spec: added, added, manual: [] }; + return { spec: field === 'peerDependencies' ? FLOOR_RANGE : `^${MIN_RUNTIME_VERSION}`, manual: [] }; } export function transformPackageJson(text: string): TransformPackageJsonResult { if (!text.includes(MOBILE_PACKAGE_NAME)) { - return { text, changes: [], manual: [] }; + return { text, manual: [] }; } - const parsed: unknown = JSON.parse(text); + // JSON.parse rejects a byte order mark, so it is set aside and written back. + const bom = text.startsWith('\uFEFF') ? '\uFEFF' : ''; + const parsed: unknown = JSON.parse(text.slice(bom.length)); if (!isRecord(parsed)) { throw new Error('package.json must contain a JSON object at its root'); } - const changes: PackageJsonChange[] = []; const manual: string[] = []; let next = parsed; + let changed = false; for (const field of DEPENDENCY_FIELDS) { const value = next[field]; @@ -91,7 +81,7 @@ export function transformPackageJson(text: string): TransformPackageJsonResult { const root = rootDependencyFor(field, value[ROOT_PACKAGE_NAME], previous); next = { ...next, [field]: { ...rest, [ROOT_PACKAGE_NAME]: root.spec } }; - changes.push({ field, removed: MOBILE_PACKAGE_NAME, added: root.added }); + changed = true; manual.push(...root.manual); } @@ -105,12 +95,13 @@ export function transformPackageJson(text: string): TransformPackageJsonResult { } } - if (changes.length === 0) { - return { text, changes, manual }; - } - const { indent } = detectIndent(text); const serialized = JSON.stringify(next, null, indent === '' ? ' ' : indent); + const output = changed ? `${bom}${serialized}${text.endsWith('\n') ? '\n' : ''}` : text; + + if (output.includes(MOBILE_PACKAGE_NAME) && manual.length === 0) { + manual.push(`package.json still names ${MOBILE_PACKAGE_NAME} outside the dependency fields. Check it by hand.`); + } - return { text: text.endsWith('\n') ? `${serialized}\n` : serialized, changes, manual }; + return { text: output, manual }; } diff --git a/packages/codemods/src/transforms/utils/mobileToRoot/transformSource.test.ts b/packages/codemods/src/transforms/utils/mobileToRoot/transformSource.test.ts new file mode 100644 index 00000000..88b6c62e --- /dev/null +++ b/packages/codemods/src/transforms/utils/mobileToRoot/transformSource.test.ts @@ -0,0 +1,598 @@ +import { describe, expect, it } from 'vitest'; + +import { transformSource } from './transformSource.ts'; + +describe('transformSource — rewriting in place', () => { + it('rewrites a named import to the root package', () => { + const input = `import { useKeyboardHeight } from '@react-simplikit/mobile';\n`; + + const result = transformSource(input, 'a.tsx'); + + expect(result.code).toBe(`import { useKeyboardHeight } from 'react-simplikit';\n`); + }); + + it('keeps double quotes', () => { + const input = `import { isIOS } from "@react-simplikit/mobile";\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { isIOS } from "react-simplikit";\n`); + }); + + it('keeps comments and blank lines around the edit', () => { + const input = [ + `// keep this comment`, + ``, + `import {`, + ` useSafeAreaInset, // trailing note`, + `} from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.tsx'); + + expect(result.code).toBe( + [ + `// keep this comment`, + ``, + `import {`, + ` useSafeAreaInset, // trailing note`, + `} from 'react-simplikit';`, + ``, + ].join('\n') + ); + }); + + it('keeps tab indentation', () => { + const input = `import {\n\tisIOS,\n} from '@react-simplikit/mobile';\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import {\n\tisIOS,\n} from 'react-simplikit';\n`); + }); + + it('rewrites a re-export', () => { + const input = `export { isAndroid } from '@react-simplikit/mobile';\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`export { isAndroid } from 'react-simplikit';\n`); + }); + + it('rewrites a dynamic import', () => { + const input = `const later = await import('@react-simplikit/mobile');\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`const later = await import('react-simplikit');\n`); + }); + + it('rewrites a require call in a .cjs file', () => { + const input = `const m = require('@react-simplikit/mobile');\n`; + + const result = transformSource(input, 'a.cjs'); + + expect(result.code).toBe(`const m = require('react-simplikit');\n`); + }); + + it('rewrites require.resolve', () => { + const input = `require.resolve('@react-simplikit/mobile');\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`require.resolve('react-simplikit');\n`); + }); + + it('rewrites an import-equals require', () => { + const input = `import m = require('@react-simplikit/mobile');\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import m = require('react-simplikit');\n`); + }); + + it('rewrites an import type node', () => { + const input = `type I = import('@react-simplikit/mobile').SafeAreaInset;\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`type I = import('react-simplikit').SafeAreaInset;\n`); + }); + + it('rewrites vi.mock', () => { + const input = `vi.mock('@react-simplikit/mobile');\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`vi.mock('react-simplikit');\n`); + }); + + it('rewrites vi.importActual', () => { + const input = `await vi.importActual('@react-simplikit/mobile');\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`await vi.importActual('react-simplikit');\n`); + }); + + it('rewrites vi.importMock', () => { + const input = `await vi.importMock('@react-simplikit/mobile');\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`await vi.importMock('react-simplikit');\n`); + }); + + it('returns a file without the package untouched', () => { + const input = `import { useToggle } from 'react-simplikit';\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle } from 'react-simplikit';\n`); + expect(result.notes).toEqual([]); + }); + + it('changes nothing on a second run', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile';`, + `export { isAndroid } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + const once = transformSource(input, 'a.ts').code; + + const twice = transformSource(once, 'a.ts'); + + expect(twice.code).toBe( + [`import { useToggle, isIOS } from 'react-simplikit';`, `export { isAndroid } from 'react-simplikit';`, ``].join( + '\n' + ) + ); + expect(twice.notes).toEqual([]); + }); + + it('throws on a name imported twice, so the file is reported instead of merged', () => { + const input = [ + `import { useToggle as isIOS } from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile';`, + ].join('\n'); + + expect(() => transformSource(input, 'a.ts')).toThrow('already been declared'); + }); +}); + +describe('transformSource — merging into an existing react-simplikit import', () => { + it('folds the mobile bindings into the existing import and drops the line', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import { isIOS, useKeyboardHeight } from '@react-simplikit/mobile';`, + ``, + `export const value = 1;`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [ + `import { useToggle, isIOS, useKeyboardHeight } from 'react-simplikit';`, + ``, + `export const value = 1;`, + ``, + ].join('\n') + ); + }); + + it('keeps aliases and inline type modifiers', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import { isIOS as isApple, type SafeAreaInset } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle, isIOS as isApple, type SafeAreaInset } from 'react-simplikit';\n`); + }); + + it('merges several mobile imports into one target', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile';`, + `import { isAndroid } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle, isIOS, isAndroid } from 'react-simplikit';\n`); + }); + + it('merges a type-only import into a type-only target', () => { + const input = [ + `import type { UseToggleReturn } from 'react-simplikit';`, + `import type { SafeAreaInset } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import type { UseToggleReturn, SafeAreaInset } from 'react-simplikit';\n`); + }); + + it('merges an import that shares its line with another statement', () => { + const input = `import { useToggle } from 'react-simplikit';\nimport { isIOS } from '@react-simplikit/mobile'; const x = 1;\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle, isIOS } from 'react-simplikit';\n const x = 1;\n`); + }); + + it('merges an import on the last line without a trailing newline', () => { + const input = `import { useToggle } from 'react-simplikit';\nimport { isIOS } from '@react-simplikit/mobile';`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle, isIOS } from 'react-simplikit';\n`); + }); + + it('merges an import on the first line into a target below it', () => { + const input = [ + `import { isIOS } from '@react-simplikit/mobile';`, + `import { useToggle } from 'react-simplikit';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle, isIOS } from 'react-simplikit';\n`); + }); + + it('adds one binding per line to a target written one per line with a trailing comma', () => { + const input = [ + `import {`, + ` useDebounce,`, + ` useLoading,`, + `} from 'react-simplikit';`, + `import { isIOS, useKeyboardHeight } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [ + `import {`, + ` useDebounce,`, + ` useLoading,`, + ` isIOS,`, + ` useKeyboardHeight,`, + `} from 'react-simplikit';`, + ``, + ].join('\n') + ); + }); + + it('adds one binding per line to a tab-indented target without a trailing comma', () => { + const input = [ + `import {`, + `\tuseLoading`, + `} from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe([`import {`, `\tuseLoading,`, `\tisIOS`, `} from 'react-simplikit';`, ``].join('\n')); + }); + + it('stays inline when the target bindings share a line under a broken-out brace', () => { + const input = [ + `import {`, + ` useDebounce, useLoading`, + `} from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`import {`, ` useDebounce, useLoading, isIOS`, `} from 'react-simplikit';`, ``].join('\n') + ); + }); + + it('fills an empty named list on the target', () => { + const input = [`import {} from 'react-simplikit';`, `import { isIOS } from '@react-simplikit/mobile';`, ``].join( + '\n' + ); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import {isIOS} from 'react-simplikit';\n`); + }); + + it('drops an empty mobile import without touching the target', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import {} from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle } from 'react-simplikit';\n`); + }); + + it('merges when the only comment belongs to the target line', () => { + const input = [ + `import { useToggle } from 'react-simplikit'; // the root package`, + `import { isIOS } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import { useToggle, isIOS } from 'react-simplikit'; // the root package\n`); + expect(result.notes).toEqual([]); + }); + + it('merges under a file banner comment', () => { + const input = [ + `/** @vitest-environment jsdom */`, + `import { isIOS } from '@react-simplikit/mobile';`, + `import { useToggle } from 'react-simplikit';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`/** @vitest-environment jsdom */`, `import { useToggle, isIOS } from 'react-simplikit';`, ``].join('\n') + ); + expect(result.notes).toEqual([]); + }); +}); + +describe('transformSource — imports it rewrites in place instead of merging', () => { + it('keeps a type-only import apart from a value target', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import type { SafeAreaInset } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [ + `import { useToggle } from 'react-simplikit';`, + `import type { SafeAreaInset } from 'react-simplikit';`, + ``, + ].join('\n') + ); + }); + + it('keeps a value import apart from a type-only target', () => { + const input = [ + `import type { UseToggleReturn } from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`import type { UseToggleReturn } from 'react-simplikit';`, `import { isIOS } from 'react-simplikit';`, ``].join( + '\n' + ) + ); + }); + + it('keeps a namespace import on its own line, without a note', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import * as m from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`import { useToggle } from 'react-simplikit';`, `import * as m from 'react-simplikit';`, ``].join('\n') + ); + expect(result.notes).toEqual([]); + }); + + it('keeps an import with a default binding on its own line', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import mobile, { isIOS } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`import { useToggle } from 'react-simplikit';`, `import mobile, { isIOS } from 'react-simplikit';`, ``].join( + '\n' + ) + ); + }); + + it('keeps a side-effect import on its own line', () => { + const input = [`import { useToggle } from 'react-simplikit';`, `import '@react-simplikit/mobile';`, ``].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`import { useToggle } from 'react-simplikit';`, `import 'react-simplikit';`, ``].join('\n') + ); + }); + + it('does not merge into a namespace target', () => { + const input = [ + `import * as root from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`import * as root from 'react-simplikit';`, `import { isIOS } from 'react-simplikit';`, ``].join('\n') + ); + }); + + it('does not merge into a side-effect target', () => { + const input = [`import 'react-simplikit';`, `import { isIOS } from '@react-simplikit/mobile';`, ``].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe([`import 'react-simplikit';`, `import { isIOS } from 'react-simplikit';`, ``].join('\n')); + }); + + it('never lifts an import out of an ambient module block, without a note', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `declare module 'other' {`, + ` import { isIOS } from '@react-simplikit/mobile';`, + ` export const c: typeof isIOS;`, + `}`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [ + `import { useToggle } from 'react-simplikit';`, + `declare module 'other' {`, + ` import { isIOS } from 'react-simplikit';`, + ` export const c: typeof isIOS;`, + `}`, + ``, + ].join('\n') + ); + expect(result.notes).toEqual([]); + }); + + it('leaves an import with a comment inside its braces and explains why', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import {`, + ` useKeyboardHeight, // needed for the sheet offset`, + `} from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [ + `import { useToggle } from 'react-simplikit';`, + `import {`, + ` useKeyboardHeight, // needed for the sheet offset`, + `} from 'react-simplikit';`, + ``, + ].join('\n') + ); + expect(result.notes).toEqual([{ line: 2, reason: expect.stringContaining('comment') }]); + }); + + it('leaves an import with a trailing comment and explains why', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `import { isIOS } from '@react-simplikit/mobile'; // only on mobile`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [ + `import { useToggle } from 'react-simplikit';`, + `import { isIOS } from 'react-simplikit'; // only on mobile`, + ``, + ].join('\n') + ); + expect(result.notes).toEqual([{ line: 2, reason: expect.stringContaining('comment') }]); + }); +}); + +describe('transformSource — comments and line endings around a merge', () => { + it('leaves an import under a line comment such as @ts-expect-error and explains why', () => { + const input = [ + `import { useToggle } from 'react-simplikit';`, + `// @ts-expect-error the stub has no types`, + `import { isIOS } from '@react-simplikit/mobile';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [ + `import { useToggle } from 'react-simplikit';`, + `// @ts-expect-error the stub has no types`, + `import { isIOS } from 'react-simplikit';`, + ``, + ].join('\n') + ); + expect(result.notes).toEqual([{ line: 3, reason: expect.stringContaining('comment') }]); + }); + + it('adds a binding with the CRLF line ending the file uses', () => { + const input = `import {\r\n useToggle,\r\n} from 'react-simplikit';\r\nimport { isIOS } from '@react-simplikit/mobile';\r\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`import {\r\n useToggle,\r\n isIOS,\r\n} from 'react-simplikit';\r\n`); + }); +}); + +describe('transformSource — mentions it cannot rewrite', () => { + it('reports a moduleNameMapper entry and leaves it', () => { + const input = `module.exports = { moduleNameMapper: { '^@react-simplikit/mobile$': '/stub.js' } };\n`; + + const result = transformSource(input, 'jest.config.js'); + + expect(result.code).toBe( + `module.exports = { moduleNameMapper: { '^@react-simplikit/mobile$': '/stub.js' } };\n` + ); + expect(result.notes).toEqual([{ line: 1, reason: expect.stringContaining('could not be rewritten') }]); + }); + + it('reports a plain string naming the package and leaves it', () => { + const input = `const docs = 'see @react-simplikit/mobile';\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe(`const docs = 'see @react-simplikit/mobile';\n`); + expect(result.notes).toEqual([{ line: 1, reason: expect.stringContaining('could not be rewritten') }]); + }); + + it('reports a mention left next to an import it did rewrite', () => { + const input = [ + `import { isIOS } from '@react-simplikit/mobile';`, + `import extra from '@react-simplikit/mobile/extra';`, + ``, + ].join('\n'); + + const result = transformSource(input, 'a.ts'); + + expect(result.code).toBe( + [`import { isIOS } from 'react-simplikit';`, `import extra from '@react-simplikit/mobile/extra';`, ``].join('\n') + ); + expect(result.notes).toEqual([{ line: 2, reason: expect.stringContaining('could not be rewritten') }]); + }); + + it('stays quiet when every mention was rewritten', () => { + const input = `import { isIOS } from '@react-simplikit/mobile';\n`; + + const result = transformSource(input, 'a.ts'); + + expect(result.notes).toEqual([]); + }); +}); diff --git a/packages/codemods/src/transforms/utils/mobileToRoot/transformSource.ts b/packages/codemods/src/transforms/utils/mobileToRoot/transformSource.ts new file mode 100644 index 00000000..3038efac --- /dev/null +++ b/packages/codemods/src/transforms/utils/mobileToRoot/transformSource.ts @@ -0,0 +1,44 @@ +import { collectSpecifiers, lineOf, parseSource } from './collectSpecifiers.ts'; +import { MOBILE_PACKAGE_NAME, ROOT_PACKAGE_NAME } from './constants.ts'; +import { buildMergeSplices } from './mergeImports.ts'; +import type { Span, Splice, TransformSourceResult } from './types.ts'; + +function rewriteSpecifier(code: string, literal: Span): Splice { + const quote = code.slice(literal.start, literal.start + 1); + + return { start: literal.start, end: literal.end, text: `${quote}${ROOT_PACKAGE_NAME}${quote}` }; +} + +function applySplices(code: string, splices: readonly Splice[]) { + return splices + .toSorted((a, b) => b.start - a.start) + .reduce((text, splice) => text.slice(0, splice.start) + splice.text + text.slice(splice.end), code); +} + +export function transformSource(code: string, fileName: string): TransformSourceResult { + if (!code.includes(MOBILE_PACKAGE_NAME)) { + return { code, notes: [] }; + } + + const parsed = parseSource(code, fileName); + const hits = collectSpecifiers(parsed); + const merge = buildMergeSplices(parsed, hits); + const rewrites = hits.filter(hit => hit.declaration === undefined || !merge.mergedDeclarations.has(hit.declaration)); + const output = applySplices(code, [...merge.splices, ...rewrites.map(hit => rewriteSpecifier(code, hit.literal))]); + const leftover = output.indexOf(MOBILE_PACKAGE_NAME); + + if (leftover === -1) { + return { code: output, notes: merge.notes }; + } + + return { + code: output, + notes: [ + ...merge.notes, + { + line: lineOf(output, leftover), + reason: `This file names ${MOBILE_PACKAGE_NAME} somewhere it could not be rewritten as an import. Check it by hand.`, + }, + ], + }; +} diff --git a/packages/codemods/src/transforms/utils/mobileToRoot/types.ts b/packages/codemods/src/transforms/utils/mobileToRoot/types.ts new file mode 100644 index 00000000..97cdfec2 --- /dev/null +++ b/packages/codemods/src/transforms/utils/mobileToRoot/types.ts @@ -0,0 +1,22 @@ +export type SourceNote = { + line: number; + reason: string; +}; + +export type TransformSourceResult = { + code: string; + notes: SourceNote[]; +}; + +export type Span = { + start: number; + end: number; +}; + +export type Comment = Span & { + type: string; +}; + +export type Splice = Span & { + text: string; +}; diff --git a/packages/codemods/test/cli.e2e.test.ts b/packages/codemods/test/cli.e2e.test.ts new file mode 100644 index 00000000..7f8d86dc --- /dev/null +++ b/packages/codemods/test/cli.e2e.test.ts @@ -0,0 +1,324 @@ +import { spawnSync } from 'node:child_process'; +import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; + +import manifest from '../package.json'; + +const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +// From the manifest, so a `bin` left behind by a build-output rename fails here. +const binPath = path.join(packageRoot, manifest.bin); +const fixturesRoot = path.join(packageRoot, 'test', '__fixtures__'); +// Projects live outside this repository, so its own uncommitted changes never trip the git check. +const projectsRoot = path.join(tmpdir(), 'react-simplikit-codemods-e2e'); + +const MOBILE_IMPORT = `import { isIOS } from '@react-simplikit/mobile';\n`; +const ROOT_IMPORT = `import { isIOS } from 'react-simplikit';\n`; + +beforeAll(async () => { + await mkdir(fixturesRoot, { recursive: true }); + await mkdir(projectsRoot, { recursive: true }); +}); + +afterAll(async () => { + await rm(fixturesRoot, { force: true, recursive: true }); + await rm(projectsRoot, { force: true, recursive: true }); +}); + +// The PnP loader comes in through NODE_OPTIONS, which the child inherits from the test run. +function runCli(args: readonly string[], bin = binPath) { + const { stdout, stderr, status } = spawnSync(process.execPath, [bin, ...args], { + cwd: packageRoot, + encoding: 'utf8', + }); + + return { stdout, stderr, exitCode: status ?? 1 }; +} + +async function createProject(files: Record) { + const project = await mkdtemp(path.join(projectsRoot, 'case-')); + + for (const [relative, contents] of Object.entries(files)) { + await mkdir(path.dirname(path.join(project, relative)), { recursive: true }); + await writeFile(path.join(project, relative), contents, 'utf8'); + } + + return project; +} + +function readProjectFile(project: string, relative: string) { + return readFile(path.join(project, relative), 'utf8'); +} + +function git(project: string, ...args: string[]) { + spawnSync('git', ['-c', 'user.name=codemods', '-c', 'user.email=codemods@example.com', ...args], { cwd: project }); +} + +describe('the bin', () => { + it('starts with a shebang', async () => { + const bin = await readFile(binPath, 'utf8'); + + expect(bin.startsWith('#!/usr/bin/env node')).toBe(true); + }); + + it('prints its version with -v', () => { + const result = runCli(['-v']); + + expect(result.stdout).toBe(`${manifest.version}\n`); + }); + + it('prints its usage with -h', () => { + const result = runCli(['-h']); + + expect(result.stdout).toContain('Usage: @react-simplikit/codemods [codemod] [path]'); + }); + + it('lists the transforms in the help', () => { + const result = runCli(['-h']); + + expect(result.stdout).toContain('Transforms:\n mobile-to-root '); + }); +}); + +describe('arguments it rejects', () => { + it('exits 1 instead of prompting when it is not run in a terminal', () => { + const result = runCli(['mobile-to-root']); + + expect(result.exitCode).toBe(1); + expect(result.stderr).toContain('Pass both the transform and the path'); + }); + + it('exits 1 on an unknown transform and lists the valid ones', async () => { + const project = await createProject({}); + + const result = runCli(['nope', project]); + + expect(result.exitCode).toBe(1); + expect(result.stderr).toContain('- mobile-to-root'); + }); + + it('exits 1 on a path that does not exist', async () => { + const project = await createProject({}); + + const result = runCli(['mobile-to-root', path.join(project, 'missing')]); + + expect(result.exitCode).toBe(1); + expect(result.stderr).toContain('Path not found'); + }); +}); + +describe('a run', () => { + it('rewrites source files and package.json, then prints the next steps', async () => { + const project = await createProject({ + 'src/a.tsx': `import { useToggle } from 'react-simplikit';\n${MOBILE_IMPORT}`, + 'package.json': `{\n "dependencies": { "@react-simplikit/mobile": "^0.1.0" }\n}\n`, + }); + + const result = runCli(['mobile-to-root', project]); + + expect(result.exitCode).toBe(0); + expect(await readProjectFile(project, 'src/a.tsx')).toBe(`import { useToggle, isIOS } from 'react-simplikit';\n`); + expect(await readProjectFile(project, 'package.json')).toBe( + `{\n "dependencies": {\n "react-simplikit": "^0.2.0"\n }\n}\n` + ); + expect(result.stdout).toContain('Next steps:'); + }); + + it('prints the jscodeshift command it runs', async () => { + const project = await createProject({}); + + const result = runCli(['mobile-to-root', project]); + + expect(result.stdout).toContain( + 'Executing command: jscodeshift --no-babel --fail-on-error ' + + '--ignore-pattern=**/node_modules/** --ignore-pattern=**/dist/** --ignore-pattern=**/build/** ' + + '--ignore-pattern=**/out/** --ignore-pattern=**/coverage/** --ignore-pattern=**/.next/** ' + + '--ignore-pattern=**/.yarn/** --ignore-pattern=**/.git/** --ignore-pattern=**/.pnp.* ' + + '--extensions=tsx,ts,mts,cts,jsx,js,mjs,cjs,json --transform ' + ); + }); + + it('migrates a single file given as the path', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT, 'src/b.ts': MOBILE_IMPORT }); + + const result = runCli(['mobile-to-root', path.join(project, 'src', 'a.ts')]); + + expect(result.exitCode).toBe(0); + expect(await readProjectFile(project, 'src/a.ts')).toBe(ROOT_IMPORT); + expect(await readProjectFile(project, 'src/b.ts')).toBe(MOBILE_IMPORT); + }); + + it('skips node_modules', async () => { + const project = await createProject({ 'node_modules/dep/index.js': MOBILE_IMPORT }); + + runCli(['mobile-to-root', project]); + + expect(await readProjectFile(project, 'node_modules/dep/index.js')).toBe(MOBILE_IMPORT); + }); + + it('still migrates a project that sits under a build folder', async () => { + const project = await createProject({ 'build/app/src/a.ts': MOBILE_IMPORT }); + + const result = runCli(['mobile-to-root', path.join(project, 'build', 'app')]); + + expect(result.exitCode).toBe(0); + expect(await readProjectFile(project, 'build/app/src/a.ts')).toBe(ROOT_IMPORT); + }); + + it('migrates the rest and exits 1 when a file cannot be parsed', async () => { + const project = await createProject({ + 'src/broken.ts': `${MOBILE_IMPORT}import { isIOS } from 'x';\n`, + 'src/ok.ts': MOBILE_IMPORT, + }); + + const result = runCli(['mobile-to-root', project]); + + expect(result.exitCode).toBe(1); + expect(result.stdout).toContain('broken.ts'); + expect(await readProjectFile(project, 'src/ok.ts')).toBe(ROOT_IMPORT); + }); + + it('changes nothing on a second run', async () => { + const project = await createProject({ + 'src/a.ts': `import { useToggle } from 'react-simplikit';\n${MOBILE_IMPORT}`, + }); + runCli(['mobile-to-root', project]); + + runCli(['mobile-to-root', project]); + + expect(await readProjectFile(project, 'src/a.ts')).toBe(`import { useToggle, isIOS } from 'react-simplikit';\n`); + }); +}); + +describe('--dry and --print', () => { + it('writes nothing and prints no next steps with --dry', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + + const result = runCli(['mobile-to-root', project, '--dry']); + + expect(result.exitCode).toBe(0); + expect(await readProjectFile(project, 'src/a.ts')).toBe(MOBILE_IMPORT); + expect(result.stdout).not.toContain('Next steps:'); + }); + + it('prints the transformed source with --print', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + + const result = runCli(['mobile-to-root', project, '--dry', '--print']); + + expect(result.stdout).toContain(ROOT_IMPORT); + }); +}); + +describe('the git safety check', () => { + it('stops on uncommitted changes and writes nothing', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + git(project, 'init', '-q'); + + const result = runCli(['mobile-to-root', project]); + + expect(result.exitCode).toBe(1); + expect(result.stderr).toContain('please stash or commit your git changes'); + expect(await readProjectFile(project, 'src/a.ts')).toBe(MOBILE_IMPORT); + }); + + it('runs on a committed working tree', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + git(project, 'init', '-q'); + git(project, 'add', '-A'); + git(project, 'commit', '-q', '-m', 'init'); + + const result = runCli(['mobile-to-root', project]); + + expect(result.exitCode).toBe(0); + expect(await readProjectFile(project, 'src/a.ts')).toBe(ROOT_IMPORT); + }); + + it('runs on uncommitted changes with --force and warns', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + git(project, 'init', '-q'); + + const result = runCli(['mobile-to-root', project, '--force']); + + expect(result.exitCode).toBe(0); + expect(result.stderr).toContain('WARNING: Git directory is not clean. Forcibly continuing.'); + expect(await readProjectFile(project, 'src/a.ts')).toBe(ROOT_IMPORT); + }); + + it('skips the check on a dry run', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + git(project, 'init', '-q'); + + const result = runCli(['mobile-to-root', project, '--dry']); + + expect(result.exitCode).toBe(0); + expect(result.stderr).not.toContain('please stash or commit'); + }); + + it('stops when git cannot read the working tree', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + git(project, 'init', '-q'); + await writeFile(path.join(project, '.git', 'index'), 'not an index'); + + const result = runCli(['mobile-to-root', project]); + + expect(result.exitCode).toBe(1); + expect(result.stderr).toContain('Could not read the git status'); + expect(await readProjectFile(project, 'src/a.ts')).toBe(MOBILE_IMPORT); + }); + + it('runs in a folder outside any git repository', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT }); + + const result = runCli(['mobile-to-root', project]); + + expect(result.exitCode).toBe(0); + expect(await readProjectFile(project, 'src/a.ts')).toBe(ROOT_IMPORT); + }); +}); + +describe('--jscodeshift', () => { + it('passes the options through to jscodeshift', async () => { + const project = await createProject({ 'src/a.ts': MOBILE_IMPORT, 'legacy/b.ts': MOBILE_IMPORT }); + + const result = runCli(['mobile-to-root', project, '--jscodeshift=--ignore-pattern=**/legacy/**']); + + expect(result.exitCode).toBe(0); + expect(await readProjectFile(project, 'src/a.ts')).toBe(ROOT_IMPORT); + expect(await readProjectFile(project, 'legacy/b.ts')).toBe(MOBILE_IMPORT); + }); +}); + +describe('the published tarball', () => { + async function extractTarball() { + const workDir = await mkdtemp(path.join(fixturesRoot, 'pack-')); + const packed = spawnSync('npm', ['pack', '--ignore-scripts', '--pack-destination', workDir], { + cwd: packageRoot, + encoding: 'utf8', + }); + const tarball = path.join(workDir, packed.stdout.trim().split('\n').at(-1) ?? ''); + spawnSync('tar', ['-xzf', tarball, '-C', workDir]); + + return path.join(workDir, 'package'); + } + + it('carries an executable bin that runs', async () => { + const extracted = await extractTarball(); + const packedBin = path.join(extracted, manifest.bin); + + const result = runCli(['-v'], packedBin); + + expect((await stat(packedBin)).mode & 0o111).toBeGreaterThan(0); + expect(result.stdout).toBe(`${manifest.version}\n`); + }); + + it('carries the transforms the bin runs', async () => { + const extracted = await extractTarball(); + + const transform = await stat(path.join(extracted, 'dist', 'transforms', 'mobile-to-root.cjs')); + + expect(transform.isFile()).toBe(true); + }); +}); diff --git a/packages/codemod/tsconfig.json b/packages/codemods/tsconfig.json similarity index 83% rename from packages/codemod/tsconfig.json rename to packages/codemods/tsconfig.json index 6a11186d..b47312ba 100644 --- a/packages/codemod/tsconfig.json +++ b/packages/codemods/tsconfig.json @@ -14,5 +14,5 @@ "types": ["node"] }, "include": ["src/**/*", "test/**/*"], - "exclude": ["node_modules", "dist", "test/__fixtures__"] + "exclude": ["node_modules", "dist", "test/__fixtures__", "src/**/testfixtures"] } diff --git a/packages/codemods/tsdown.config.ts b/packages/codemods/tsdown.config.ts new file mode 100644 index 00000000..8a960dd8 --- /dev/null +++ b/packages/codemods/tsdown.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from 'tsdown'; + +export default defineConfig([ + { + entry: ['src/bin/codemods.ts'], + outDir: 'dist/bin', + format: 'cjs', + clean: true, + publint: 'ci-only', + banner: { js: '#!/usr/bin/env node' }, + }, + { + entry: ['src/transforms/*.ts'], + outDir: 'dist/transforms', + format: 'cjs', + clean: true, + // detect-indent is ESM-only, and the transforms are loaded with require(). + deps: { alwaysBundle: ['detect-indent'] }, + }, +]); diff --git a/packages/codemod/vitest.config.ts b/packages/codemods/vitest.config.ts similarity index 76% rename from packages/codemod/vitest.config.ts rename to packages/codemods/vitest.config.ts index a4013745..880d4616 100644 --- a/packages/codemod/vitest.config.ts +++ b/packages/codemods/vitest.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ provider: 'v8', reporter: ['text', 'json'], include: ['src/**/*.ts'], - exclude: ['src/cli.ts', 'src/constants.ts', 'src/**/*.test.ts'], + exclude: ['src/bin/*.ts', 'src/**/constants.ts', 'src/**/*.test.ts', 'src/**/testfixtures/**'], thresholds: { statements: 100, branches: 100, functions: 100, lines: 100 }, }, }, diff --git a/packages/codemod/vitest.e2e.config.ts b/packages/codemods/vitest.e2e.config.ts similarity index 60% rename from packages/codemod/vitest.e2e.config.ts rename to packages/codemods/vitest.e2e.config.ts index 95bfff87..d876fd19 100644 --- a/packages/codemod/vitest.e2e.config.ts +++ b/packages/codemods/vitest.e2e.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { include: ['test/**/*.e2e.test.ts'], - // Each test spawns the built bin through yarn; the 5s default leaves no margin on CI. + // Each test spawns the built bin and jscodeshift's workers; the 5s default leaves no margin on CI. testTimeout: 60_000, }, }); diff --git a/packages/plugin/README.md b/packages/plugin/README.md index df54e94f..241923fa 100644 --- a/packages/plugin/README.md +++ b/packages/plugin/README.md @@ -3,7 +3,7 @@ Agent skills for [react-simplikit](https://react-simplikit.slash.page). Two ship in this plugin: - **`react-simplikit`** — a catalog of every hook, component and util with a one-line description, import and SSR rules, and a reference page per entry. With it installed, an agent checks the library before hand-writing debounce, throttle, click-outside, keyboard-avoidance and similar logic. -- **`react-simplikit-codemod`** — how to run the upgrade codemods (`npx react-simplikit-codemod `) on a codebase, including the JSON report the CLI emits and what to do with each exit code. +- **`react-simplikit-codemod`** — how to run the upgrade codemods (`npx @react-simplikit/codemods `) on a codebase, how to read the jscodeshift output, and what to do with each exit code. ## Install @@ -65,7 +65,7 @@ claude plugin marketplace remove react-design-philosophy `skills/react-simplikit-codemod/` -- `SKILL.md` — preconditions, the commands and their flags, the shape of the `--json` report, the manual follow-ups to act on afterwards, and what each exit code means. It has no `references/`. +- `SKILL.md` — preconditions, the commands and their flags, how to read the jscodeshift output, the manual follow-ups to act on afterwards, and what each exit code means. It has no `references/`. ## Contributing @@ -77,7 +77,7 @@ The two skills are maintained differently. - Catalog descriptions come from each entry's documentation page (`.md` next to its source), which `yarn docs:gen ` writes from the JSDoc. - Run `yarn skill:gen` to regenerate (it also runs at the end of `yarn docs:gen`), then `yarn test:skill` to check the result. CI fails if the committed skill differs from a fresh generation. -**`skills/react-simplikit-codemod/` is hand-written.** It documents the CLI in `packages/codemod`, so a change to the CLI's flags, JSON report or exit codes has to be carried into it by hand. `yarn test:skill` checks its frontmatter and length but cannot tell whether it still matches the CLI. +**`skills/react-simplikit-codemod/` is hand-written.** It documents the CLI in `packages/codemods`, so a change to the CLI's flags, output or exit codes has to be carried into it by hand. `yarn test:skill` checks its frontmatter and length but cannot tell whether it still matches the CLI. ## License diff --git a/packages/plugin/skills/react-simplikit-codemod/SKILL.md b/packages/plugin/skills/react-simplikit-codemod/SKILL.md index db5030b0..816c45bb 100644 --- a/packages/plugin/skills/react-simplikit-codemod/SKILL.md +++ b/packages/plugin/skills/react-simplikit-codemod/SKILL.md @@ -16,102 +16,54 @@ Do **not** run this when the project has no `@react-simplikit/mobile` dependency ## Preconditions -- The working tree is committed or stashed. This command rewrites files in place and has no undo of its own. +- Node.js 22 or later. +- The working tree is committed or stashed. This command rewrites files in place and has no undo of its own, so outside `--dry` it refuses to run on uncommitted changes and exits `1`. Pass `--force` only when the user has said to run on a dirty tree. ## Commands +Always pass both the transform and the path. Without a terminal to ask in, the CLI exits `1` when either is missing. + Preview first — this writes nothing: ```bash -npx react-simplikit-codemod mobile-to-root --dry-run --json +npx @react-simplikit/codemods mobile-to-root . --dry ``` Apply: ```bash -npx react-simplikit-codemod mobile-to-root +npx @react-simplikit/codemods mobile-to-root . ``` Limit it to one directory: ```bash -npx react-simplikit-codemod mobile-to-root src -``` - -Skip paths, or leave manifests alone: - -```bash -npx react-simplikit-codemod mobile-to-root --ignore 'legacy/**' --ignore '**/e2e/**' -npx react-simplikit-codemod mobile-to-root --no-package-json +npx @react-simplikit/codemods mobile-to-root src ``` -`--debug` puts stack traces in the report and on stderr, including for files that could not be processed. The command never prompts and is safe to run twice, so it fits non-interactive and CI use. - -## JSON output - -`--json` writes only this object to stdout. Everything else goes to stderr. - -```json -{ - "transform": "mobile-to-root", - "dryRun": false, - "scanned": 128, - "changed": [ - { - "kind": "source", - "file": "src/a.tsx", - "changes": [{ "line": 3, "kind": "import" }] - }, - { - "kind": "manifest", - "file": "package.json", - "dependencies": [ - { - "field": "dependencies", - "removed": "@react-simplikit/mobile", - "added": "^0.2.0" - } - ] - } - ], - "manual": [ - { - "file": "src/a.tsx", - "line": 4, - "reason": "Left on its own line: `isIOS` already refers to a different import here..." - }, - { - "file": "package.json", - "reason": "\"overrides\" still pins @react-simplikit/mobile..." - } - ], - "failed": [] -} -``` - -The object always carries these six keys. - -`changed[].kind` is `source` or `manifest`, and it decides the rest of the entry: a `source` entry carries `changes`, a `manifest` entry carries `dependencies`. Neither key appears on the other kind, so branch on `kind` rather than testing an array for emptiness. +`--print` also writes each transformed file to stdout. To skip extra paths, hand jscodeshift its own option: `--jscodeshift="--ignore-pattern=**/legacy/**"`. There is no flag to leave `package.json` alone; narrow the path argument instead. `node_modules`, `dist`, `build`, `out`, `coverage`, `.next`, `.yarn`, `.git` and `.pnp.*` are always skipped. The command is safe to run twice. -`changes[].kind` is one of `import`, `export`, `require`, `dynamic-import`, `import-type`, `mock`, `merge`. +## Reading the output -`dependencies[].added` is `null` in two cases: the existing `react-simplikit` range already satisfies the floor and was left as it was, or no registry range could be written at all because the old dependency was pinned by a `workspace:`/`catalog:`/`file:` protocol. The second case always carries a `manual` note naming the field. +The run is jscodeshift's, so its lines follow jscodeshift's format: -`manual[].line` is present only for a note about a specific import; manifest notes have no line. - -`failed[]` holds the files that could not be read, parsed, or written. It is always present and usually empty. +- ` ERR Transformation error (...)`, followed by the error's stack — the file could not be parsed or transformed. It was left untouched +- ` REP ` — a manual follow-up. In a source file the message starts with `line :` and names either an import the codemod deliberately left on its own (a comment sits on it or right above it) or a mention of the package it could not rewrite, such as a `moduleNameMapper` entry or a subpath import. In a `package.json` it names a field to check by hand: an `overrides` or `resolutions` entry it did not edit, a dependency whose `workspace:`/`catalog:`/`file:` spec it could not check, or a mention outside the dependency fields +- `Results:` with counts of `errors`, `unmodified`, `skipped` and `ok` — `ok` is the number of files rewritten +- `Next steps:` — printed after every run except a dry run. It repeats the steps under **After the run** below ## After the run -1. Act on every entry in `manual` by hand. Entries with a `line` mark an import the codemod deliberately left on its own — read the reason before merging it yourself, because merging it by hand can change what a name binds. +1. Act on every `REP` line by hand. Read the reason first: merging an import the codemod left on its own can strand the comment that sits on it. 2. Run a bare `npm install` (or the equivalent) so the lockfile drops the old package. Do not run `npm install react-simplikit` — it would overwrite the range the codemod just wrote. 3. Run the project's formatter or linter fix (`eslint --fix`, say) on the changed files. Import-order rules place `react-simplikit` differently from `@react-simplikit/mobile`, so a sorted import block is usually out of order after the run. 4. Require `react-simplikit@0.2.0` or newer — the first release re-exporting the `SafeAreaInset` type from the root entry. An existing range below that floor is raised automatically; a `workspace:`/`catalog:`/`file:` protocol is kept and reported instead. ## Failure handling -| Exit code | What to do | -| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `2` | The invocation was wrong. stderr names the bad path or flag. Fix it and rerun | -| `1` | Some files could not be processed. They are listed in `failed` (or under **Could not be processed**); every other file was migrated. Fix those and rerun | -| `0` | Done. Review the diff | +| Exit code | What to do | +| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `1` | The transform name or the path was wrong, or the git repository has uncommitted changes or an unreadable status — stderr says which. Otherwise some files could not be processed — they are the `ERR` lines, and every other file was migrated. Fix those and rerun | +| `0` | Done. Review the diff | + +A file that imports the same name twice — once from each package, say — fails to parse. Remove the duplicate import and rerun. diff --git a/tsconfig.json b/tsconfig.json index dd40577e..a6a72e44 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "types": ["@testing-library/jest-dom"] }, "include": ["packages/**/src", ".scripts/**/*"], - "exclude": [".scripts/verify-pack/fixtures/**"], + "exclude": [".scripts/verify-pack/fixtures/**", "packages/codemods/src/transforms/testfixtures/**"], "vueCompilerOptions": { "vitePressExtensions": [".md"] } diff --git a/yarn.lock b/yarn.lock index bc77bf9f..57e9792c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -340,6 +340,29 @@ __metadata: languageName: node linkType: hard +"@babel/core@npm:^7.24.7": + version: 7.29.13 + resolution: "@babel/core@npm:7.29.13" + dependencies: + "@babel/code-frame": "npm:^7.29.7" + "@babel/generator": "npm:^7.29.13" + "@babel/helper-compilation-targets": "npm:^7.29.13" + "@babel/helper-module-transforms": "npm:^7.29.13" + "@babel/helpers": "npm:^7.29.13" + "@babel/parser": "npm:^7.29.13" + "@babel/template": "npm:^7.29.7" + "@babel/traverse": "npm:^7.29.13" + "@babel/types": "npm:^7.29.11" + "@jridgewell/remapping": "npm:^2.3.5" + convert-source-map: "npm:^2.0.0" + debug: "npm:^4.1.0" + gensync: "npm:^1.0.0-beta.2" + json5: "npm:^2.2.3" + semver: "npm:^6.3.1" + checksum: 10c0/7c9d372d63c0d30c35b78c70e373eeed9eee2c4b7cfe40f43daf5298f85e1cde8760c410a9a330148162911ae292acb17b5edddc33dd7b681e798949cec23ae1 + languageName: node + linkType: hard + "@babel/core@npm:^7.28.0": version: 7.28.5 resolution: "@babel/core@npm:7.28.5" @@ -389,6 +412,19 @@ __metadata: languageName: node linkType: hard +"@babel/generator@npm:^7.29.13, @babel/generator@npm:^7.29.15": + version: 7.29.15 + resolution: "@babel/generator@npm:7.29.15" + dependencies: + "@babel/parser": "npm:^7.29.15" + "@babel/types": "npm:^7.29.15" + "@jridgewell/gen-mapping": "npm:^0.3.12" + "@jridgewell/trace-mapping": "npm:^0.3.28" + jsesc: "npm:^3.0.2" + checksum: 10c0/97f9cad815732c86d285e266dba400c302af1a8951e0a8ffff48aff8d22e15d3422bd81d3280d4efb81660330acd0e6b9e6195d64902fd94a33723a99ec8929e + languageName: node + linkType: hard + "@babel/generator@npm:^7.29.7, @babel/generator@npm:^7.29.8": version: 7.29.8 resolution: "@babel/generator@npm:7.29.8" @@ -424,6 +460,19 @@ __metadata: languageName: node linkType: hard +"@babel/helper-compilation-targets@npm:^7.29.13": + version: 7.29.13 + resolution: "@babel/helper-compilation-targets@npm:7.29.13" + dependencies: + "@babel/compat-data": "npm:^7.29.7" + "@babel/helper-validator-option": "npm:^7.29.7" + browserslist: "npm:^4.24.0" + lru-cache: "npm:^5.1.1" + semver: "npm:^6.3.1" + checksum: 10c0/e134fb9379f3375bd57c042bf26d9eb1cfae0bb89df498e8cd7e62ca7212a924e09c01be2b25040e7a2fbc9725cf81d692415c50afb568816e8ea4db554c94f7 + languageName: node + linkType: hard + "@babel/helper-compilation-targets@npm:^7.29.7": version: 7.29.7 resolution: "@babel/helper-compilation-targets@npm:7.29.7" @@ -511,6 +560,19 @@ __metadata: languageName: node linkType: hard +"@babel/helper-module-transforms@npm:^7.29.13, @babel/helper-module-transforms@npm:^7.29.14": + version: 7.29.14 + resolution: "@babel/helper-module-transforms@npm:7.29.14" + dependencies: + "@babel/helper-module-imports": "npm:^7.29.7" + "@babel/helper-validator-identifier": "npm:^7.29.7" + "@babel/traverse": "npm:^7.29.14" + peerDependencies: + "@babel/core": ^7.0.0 + checksum: 10c0/5ca8b9c36d5b9656196c758df1dc10148086b232f3df43d932a66d84f46faf93da7096667903c1f652539759789dc1ef5fbff0569baeabb110dce27faa988250 + languageName: node + linkType: hard + "@babel/helper-module-transforms@npm:^7.29.7": version: 7.29.7 resolution: "@babel/helper-module-transforms@npm:7.29.7" @@ -584,6 +646,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-string-parser@npm:^7.29.15": + version: 7.29.15 + resolution: "@babel/helper-string-parser@npm:7.29.15" + checksum: 10c0/8d130fb596ef470c646f2f98fb50ada5a653ea9fd583dba0884f15327b8022c749e839e0c4e4ee9c670d258e10b997e23b7224ca57cc08dca5e808d4fe5d7048 + languageName: node + linkType: hard + "@babel/helper-string-parser@npm:^7.29.7": version: 7.29.7 resolution: "@babel/helper-string-parser@npm:7.29.7" @@ -636,6 +705,16 @@ __metadata: languageName: node linkType: hard +"@babel/helpers@npm:^7.29.13": + version: 7.29.15 + resolution: "@babel/helpers@npm:7.29.15" + dependencies: + "@babel/template": "npm:^7.29.7" + "@babel/types": "npm:^7.29.15" + checksum: 10c0/181786000e988b6834572c84ed794127e104da9728ba37c70fbc9063b2b184f297a314dc734e35cb9efa7bcba6e3848e09d8bfa9b44503ea6a031e14a85e3c8c + languageName: node + linkType: hard + "@babel/helpers@npm:^7.29.7": version: 7.29.7 resolution: "@babel/helpers@npm:7.29.7" @@ -668,6 +747,17 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.24.7, @babel/parser@npm:^7.29.13, @babel/parser@npm:^7.29.15": + version: 7.29.15 + resolution: "@babel/parser@npm:7.29.15" + dependencies: + "@babel/types": "npm:^7.29.15" + bin: + parser: ./bin/babel-parser.js + checksum: 10c0/5fca335e83d30af8e2dd632c3630526cf410ea6b6567c2f7a5e44e13deba39caf7146ba35f9d6abea34d6d4e869eb32e00dc37fa5213d288ff987cff360db6a6 + languageName: node + linkType: hard + "@babel/parser@npm:^7.25.3, @babel/parser@npm:^7.25.4, @babel/parser@npm:^7.25.7, @babel/parser@npm:^7.26.7, @babel/parser@npm:^7.27.0": version: 7.27.0 resolution: "@babel/parser@npm:7.27.0" @@ -679,6 +769,17 @@ __metadata: languageName: node linkType: hard +"@babel/plugin-syntax-flow@npm:^7.29.7": + version: 7.29.7 + resolution: "@babel/plugin-syntax-flow@npm:7.29.7" + dependencies: + "@babel/helper-plugin-utils": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/b2e330dd0dc535c7364937ce2b29a06065e60b1d523db75f36ab4fb89e4ba664e2230cbb1937b35712c9a0ebafc3358f323d6e6b22247d5ebad12fdd3e1f6e98 + languageName: node + linkType: hard + "@babel/plugin-syntax-jsx@npm:^7.29.7": version: 7.29.7 resolution: "@babel/plugin-syntax-jsx@npm:7.29.7" @@ -701,6 +802,42 @@ __metadata: languageName: node linkType: hard +"@babel/plugin-transform-class-properties@npm:^7.24.7": + version: 7.29.7 + resolution: "@babel/plugin-transform-class-properties@npm:7.29.7" + dependencies: + "@babel/helper-create-class-features-plugin": "npm:^7.29.7" + "@babel/helper-plugin-utils": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/c370700423439aa9f0c1f8c4b97f2ef7c2dc46a1b04ec3b10e83e6bae5e4e2159f56d8e4376c9d669b3cf827650cc3740170a36e3924e3e9970d27fd85f4e48a + languageName: node + linkType: hard + +"@babel/plugin-transform-flow-strip-types@npm:^7.29.7": + version: 7.29.7 + resolution: "@babel/plugin-transform-flow-strip-types@npm:7.29.7" + dependencies: + "@babel/helper-plugin-utils": "npm:^7.29.7" + "@babel/plugin-syntax-flow": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/083e864a60927cde7bd75822bdf5c6c72de200ee955e48f6ff5923f0d2b0744ab8f1b64c45e74b88ae3796f03721489afffdb0536f25c54d0dd58508a8904f40 + languageName: node + linkType: hard + +"@babel/plugin-transform-modules-commonjs@npm:^7.24.7": + version: 7.29.14 + resolution: "@babel/plugin-transform-modules-commonjs@npm:7.29.14" + dependencies: + "@babel/helper-module-transforms": "npm:^7.29.14" + "@babel/helper-plugin-utils": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/daa4863b5798fd1efab9531f64b706d189d42d590b23f0c1e398f18231116b13a601501d305a80d950c1183154014cd7afd139c76de8e5cd85f926fa47065ac2 + languageName: node + linkType: hard + "@babel/plugin-transform-modules-commonjs@npm:^7.29.7": version: 7.29.7 resolution: "@babel/plugin-transform-modules-commonjs@npm:7.29.7" @@ -713,6 +850,41 @@ __metadata: languageName: node linkType: hard +"@babel/plugin-transform-nullish-coalescing-operator@npm:^7.24.7": + version: 7.29.7 + resolution: "@babel/plugin-transform-nullish-coalescing-operator@npm:7.29.7" + dependencies: + "@babel/helper-plugin-utils": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/b0c186fe38bc66830e1be76f06fabbae8a655d3896a841ba5ffa12d6c40bb9c8a6ecd38a7e2196034b1d7470653109b1ceac1ef5e46a5fdc9291d14afa56e0d0 + languageName: node + linkType: hard + +"@babel/plugin-transform-optional-chaining@npm:^7.24.7": + version: 7.29.7 + resolution: "@babel/plugin-transform-optional-chaining@npm:7.29.7" + dependencies: + "@babel/helper-plugin-utils": "npm:^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/71feacf9a7083030f4c69bf4e91db75f2fceae28e58c58b63db040006d908e15bc1e85a464f24ad659f17702e91a64eabbff9f1dd555ba33d78bb1af8a1d697a + languageName: node + linkType: hard + +"@babel/plugin-transform-private-methods@npm:^7.24.7": + version: 7.29.7 + resolution: "@babel/plugin-transform-private-methods@npm:7.29.7" + dependencies: + "@babel/helper-create-class-features-plugin": "npm:^7.29.7" + "@babel/helper-plugin-utils": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/d0dc12fa478d05e346dfb02fad2ed99b308d9a7324bada71530a62dc1ccbf07b4c2581ac677b7196b3994f191ef1922199e2c8f33957b726e2019ce07b4ced0f + languageName: node + linkType: hard + "@babel/plugin-transform-react-display-name@npm:^7.29.7": version: 7.29.7 resolution: "@babel/plugin-transform-react-display-name@npm:7.29.7" @@ -799,6 +971,19 @@ __metadata: languageName: node linkType: hard +"@babel/preset-flow@npm:^7.24.7": + version: 7.29.7 + resolution: "@babel/preset-flow@npm:7.29.7" + dependencies: + "@babel/helper-plugin-utils": "npm:^7.29.7" + "@babel/helper-validator-option": "npm:^7.29.7" + "@babel/plugin-transform-flow-strip-types": "npm:^7.29.7" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/17bb0f3c320fadb631ab64951ec0f6e05a62b15418c7864c181645b3205cabd3a8541dd3f497bf06cb1d0e04a3806f6cffee7675c97a87d4aaa04961f334cdcb + languageName: node + linkType: hard + "@babel/preset-react@npm:^7.27.0": version: 7.29.7 resolution: "@babel/preset-react@npm:7.29.7" @@ -815,7 +1000,7 @@ __metadata: languageName: node linkType: hard -"@babel/preset-typescript@npm:^7.28.0": +"@babel/preset-typescript@npm:^7.24.7, @babel/preset-typescript@npm:^7.28.0": version: 7.29.7 resolution: "@babel/preset-typescript@npm:7.29.7" dependencies: @@ -830,6 +1015,21 @@ __metadata: languageName: node linkType: hard +"@babel/register@npm:^7.24.6": + version: 7.29.13 + resolution: "@babel/register@npm:7.29.13" + dependencies: + clone-deep: "npm:^4.0.1" + find-cache-dir: "npm:^2.0.0" + make-dir: "npm:^2.1.0" + pirates: "npm:^4.0.6" + source-map-support: "npm:^0.5.16" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 10c0/b0840cd10df6586addc794a5e25ecc5a65f1f9ccfe86d8efd15db5e71ead95ed47bdf2913011c56c755bcff118e831e8b8ed8232f75d7da210f39f9c637df9a9 + languageName: node + linkType: hard + "@babel/runtime@npm:^7.12.5": version: 7.27.0 resolution: "@babel/runtime@npm:7.27.0" @@ -902,6 +1102,21 @@ __metadata: languageName: node linkType: hard +"@babel/traverse@npm:^7.29.13, @babel/traverse@npm:^7.29.14": + version: 7.29.15 + resolution: "@babel/traverse@npm:7.29.15" + dependencies: + "@babel/code-frame": "npm:^7.29.7" + "@babel/generator": "npm:^7.29.15" + "@babel/helper-globals": "npm:^7.29.7" + "@babel/parser": "npm:^7.29.15" + "@babel/template": "npm:^7.29.7" + "@babel/types": "npm:^7.29.15" + debug: "npm:^4.3.1" + checksum: 10c0/e598deea5d59ee93ffea8ce3de13e2288d07b3d6f059caba63abc6c4e09ebb52c0ad862b68370733a70d810c4c8e93deb81ecd5a5246fe5ccea249d5545156ec + languageName: node + linkType: hard + "@babel/traverse@npm:^7.29.7": version: 7.29.8 resolution: "@babel/traverse@npm:7.29.8" @@ -947,6 +1162,16 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.29.11, @babel/types@npm:^7.29.15": + version: 7.29.15 + resolution: "@babel/types@npm:7.29.15" + dependencies: + "@babel/helper-string-parser": "npm:^7.29.15" + "@babel/helper-validator-identifier": "npm:^7.29.7" + checksum: 10c0/2a153a44daccd3f93f33b64f57f9614a160ba1e53ef3c35c305ad687678a537e59b17f0a501901df8618304b905f3268ba39d96ffb78b0b5790e96dc2a9b5833 + languageName: node + linkType: hard + "@bcoe/v8-coverage@npm:^0.2.3": version: 0.2.3 resolution: "@bcoe/v8-coverage@npm:0.2.3" @@ -4115,6 +4340,32 @@ __metadata: languageName: node linkType: hard +"@react-simplikit/codemods@workspace:packages/codemods": + version: 0.0.0-use.local + resolution: "@react-simplikit/codemods@workspace:packages/codemods" + dependencies: + "@types/jscodeshift": "npm:^17.3.0" + "@types/node": "npm:^24.13.3" + "@types/prompts": "npm:^2.4.9" + "@types/semver": "npm:^7.8.0" + "@vitest/coverage-v8": "npm:^2.1.8" + commander: "npm:^13.1.0" + detect-indent: "npm:^7.0.2" + eslint: "npm:^9.39.3" + execa: "npm:^5.1.1" + fast-check: "npm:^4.9.0" + jscodeshift: "npm:^17.3.0" + prompts: "npm:^2.4.2" + rimraf: "npm:^6.0.1" + semver: "npm:^7.8.5" + tsdown: "npm:^0.22.14" + typescript: "npm:^5.7.2" + vitest: "npm:^2.1.8" + bin: + codemods: ./dist/bin/codemods.cjs + languageName: unknown + linkType: soft + "@react-simplikit/root@workspace:.": version: 0.0.0-use.local resolution: "@react-simplikit/root@workspace:." @@ -4867,6 +5118,16 @@ __metadata: languageName: node linkType: hard +"@types/jscodeshift@npm:^17.3.0": + version: 17.3.0 + resolution: "@types/jscodeshift@npm:17.3.0" + dependencies: + ast-types: "npm:^0.16.1" + recast: "npm:^0.23.11" + checksum: 10c0/56b889b290f12322b43d74c7434b69cef3e1ca8444e37891e08585f716b1c23f44596f650fb92220a8c6e5776d3dbc7d8ece67e950b6f9e733eee8e712128c73 + languageName: node + linkType: hard + "@types/json-schema@npm:^7.0.15": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" @@ -4921,6 +5182,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:*": + version: 26.6.6 + resolution: "@types/node@npm:26.6.6" + dependencies: + undici-types: "npm:~8.9.0" + checksum: 10c0/5cb63f644f6e85a257a9cd2403cbcbe196760e2a35fd3ec9fb8b5cff663e14cc832b198cc17b53f870a2e30900ed45a1fb3f53e6589aba26b8e8c484aa672053 + languageName: node + linkType: hard + "@types/node@npm:^24.13.3": version: 24.13.3 resolution: "@types/node@npm:24.13.3" @@ -4930,6 +5200,16 @@ __metadata: languageName: node linkType: hard +"@types/prompts@npm:^2.4.9": + version: 2.4.9 + resolution: "@types/prompts@npm:2.4.9" + dependencies: + "@types/node": "npm:*" + kleur: "npm:^3.0.3" + checksum: 10c0/22fe0da6807681c85e88ba283184f4be4c8a95c744ea12a638865c98c4e0c22e7f733542f6b0f1fbca02245cdc3fe84feacf9c9adf4ddd8bc98a337fd679d8d2 + languageName: node + linkType: hard + "@types/react-dom@npm:^19.0.0": version: 19.1.2 resolution: "@types/react-dom@npm:19.1.2" @@ -5891,6 +6171,15 @@ __metadata: languageName: node linkType: hard +"ast-types@npm:^0.16.1": + version: 0.16.3 + resolution: "ast-types@npm:0.16.3" + dependencies: + tslib: "npm:^2.0.1" + checksum: 10c0/a49ff15529aa4545d44b28064d50769c3b48f608f30a388e1da3ac659e11c95502a1dd4345fb2209093007a214ab912110ef13e14a353781fccd74f4222980c6 + languageName: node + linkType: hard + "async-function@npm:^1.0.0": version: 1.0.0 resolution: "async-function@npm:1.0.0" @@ -6012,6 +6301,13 @@ __metadata: languageName: node linkType: hard +"buffer-from@npm:^1.0.0": + version: 1.1.2 + resolution: "buffer-from@npm:1.1.2" + checksum: 10c0/124fff9d66d691a86d3b062eff4663fe437a9d9ee4b47b1b9e97f5a5d14f6d5399345db80f796827be7c95e70a8e765dd404b7c3ff3b3324f98e9b0c8826cc34 + languageName: node + linkType: hard + "cac@npm:^6.7.14": version: 6.7.14 resolution: "cac@npm:6.7.14" @@ -6286,6 +6582,17 @@ __metadata: languageName: node linkType: hard +"clone-deep@npm:^4.0.1": + version: 4.0.1 + resolution: "clone-deep@npm:4.0.1" + dependencies: + is-plain-object: "npm:^2.0.4" + kind-of: "npm:^6.0.2" + shallow-clone: "npm:^3.0.0" + checksum: 10c0/637753615aa24adf0f2d505947a1bb75e63964309034a1cf56ba4b1f30af155201edd38d26ffe26911adaae267a3c138b344a4947d39f5fc1b6d6108125aa758 + languageName: node + linkType: hard + "color-convert@npm:^2.0.1": version: 2.0.1 resolution: "color-convert@npm:2.0.1" @@ -6346,6 +6653,13 @@ __metadata: languageName: node linkType: hard +"commondir@npm:^1.0.1": + version: 1.0.1 + resolution: "commondir@npm:1.0.1" + checksum: 10c0/33a124960e471c25ee19280c9ce31ccc19574b566dc514fe4f4ca4c34fa8b0b57cf437671f5de380e11353ea9426213fca17687dd2ef03134fea2dbc53809fd6 + languageName: node + linkType: hard + "concat-map@npm:0.0.1": version: 0.0.1 resolution: "concat-map@npm:0.0.1" @@ -6389,7 +6703,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.6": +"cross-spawn@npm:^7.0.3, cross-spawn@npm:^7.0.6": version: 7.0.6 resolution: "cross-spawn@npm:7.0.6" dependencies: @@ -7569,6 +7883,16 @@ __metadata: languageName: node linkType: hard +"esprima@npm:~4.0.0": + version: 4.0.1 + resolution: "esprima@npm:4.0.1" + bin: + esparse: ./bin/esparse.js + esvalidate: ./bin/esvalidate.js + checksum: 10c0/ad4bab9ead0808cf56501750fd9d3fb276f6b105f987707d059005d57e182d18a7c9ec7f3a01794ebddcca676773e42ca48a32d67a250c9d35e009ca613caba3 + languageName: node + linkType: hard + "esquery@npm:^1.5.0": version: 1.6.0 resolution: "esquery@npm:1.6.0" @@ -7624,6 +7948,23 @@ __metadata: languageName: node linkType: hard +"execa@npm:^5.1.1": + version: 5.1.1 + resolution: "execa@npm:5.1.1" + dependencies: + cross-spawn: "npm:^7.0.3" + get-stream: "npm:^6.0.0" + human-signals: "npm:^2.1.0" + is-stream: "npm:^2.0.0" + merge-stream: "npm:^2.0.0" + npm-run-path: "npm:^4.0.1" + onetime: "npm:^5.1.2" + signal-exit: "npm:^3.0.3" + strip-final-newline: "npm:^2.0.0" + checksum: 10c0/c8e615235e8de4c5addf2fa4c3da3e3aa59ce975a3e83533b4f6a71750fb816a2e79610dc5f1799b6e28976c9ae86747a36a606655bf8cb414a74d8d507b304f + languageName: node + linkType: hard + "expect-type@npm:^1.1.0": version: 1.2.1 resolution: "expect-type@npm:1.2.1" @@ -7796,6 +8137,26 @@ __metadata: languageName: node linkType: hard +"find-cache-dir@npm:^2.0.0": + version: 2.1.0 + resolution: "find-cache-dir@npm:2.1.0" + dependencies: + commondir: "npm:^1.0.1" + make-dir: "npm:^2.0.0" + pkg-dir: "npm:^3.0.0" + checksum: 10c0/556117fd0af14eb88fb69250f4bba9e905e7c355c6136dff0e161b9cbd1f5285f761b778565a278da73a130f42eccc723d7ad4c002ae547ed1d698d39779dabb + languageName: node + linkType: hard + +"find-up@npm:^3.0.0": + version: 3.0.0 + resolution: "find-up@npm:3.0.0" + dependencies: + locate-path: "npm:^3.0.0" + checksum: 10c0/2c2e7d0a26db858e2f624f39038c74739e38306dee42b45f404f770db357947be9d0d587f1cac72d20c114deb38aa57316e879eb0a78b17b46da7dab0a3bd6e3 + languageName: node + linkType: hard + "find-up@npm:^5.0.0": version: 5.0.0 resolution: "find-up@npm:5.0.0" @@ -7823,6 +8184,22 @@ __metadata: languageName: node linkType: hard +"flow-estree@npm:0.342.0": + version: 0.342.0 + resolution: "flow-estree@npm:0.342.0" + checksum: 10c0/66d538a0aaa80a4dc3b7e10940b15498b40c011565490a80c0994c81b206b89245b76ebc7b2170a8038b991e328f2e2fd77871a81d3ba24fef9eafd90b434ee9 + languageName: node + linkType: hard + +"flow-parser@npm:0.*": + version: 0.342.0 + resolution: "flow-parser@npm:0.342.0" + dependencies: + flow-estree: "npm:0.342.0" + checksum: 10c0/c3d78c96c41838b22b13d59d1ec47990335af1e6a6b8c334128792713ef67d996bcdfff6dac244f109650b556636c2a40b29a08278d6d2eb6ce6f6fbb9e94ef0 + languageName: node + linkType: hard + "focus-trap@npm:^7.6.4": version: 7.6.4 resolution: "focus-trap@npm:7.6.4" @@ -7982,6 +8359,13 @@ __metadata: languageName: node linkType: hard +"get-stream@npm:^6.0.0": + version: 6.0.1 + resolution: "get-stream@npm:6.0.1" + checksum: 10c0/49825d57d3fd6964228e6200a58169464b8e8970489b3acdc24906c782fb7f01f9f56f8e6653c4a50713771d6658f7cfe051e5eb8c12e334138c9c918b296341 + languageName: node + linkType: hard + "get-symbol-description@npm:^1.1.0": version: 1.1.0 resolution: "get-symbol-description@npm:1.1.0" @@ -8099,6 +8483,13 @@ __metadata: languageName: node linkType: hard +"graceful-fs@npm:^4.2.4": + version: 4.2.12 + resolution: "graceful-fs@npm:4.2.12" + checksum: 10c0/a4e2ccd9fe7ed384ed0d466363028978c1b1537f0719db826dfa6a850abd8fc418596f14d9a9609f830ba8137df3da1acc1132a6afd635d8633fbe53530c3e6d + languageName: node + linkType: hard + "graceful-fs@npm:^4.2.6": version: 4.2.11 resolution: "graceful-fs@npm:4.2.11" @@ -8294,6 +8685,13 @@ __metadata: languageName: node linkType: hard +"human-signals@npm:^2.1.0": + version: 2.1.0 + resolution: "human-signals@npm:2.1.0" + checksum: 10c0/695edb3edfcfe9c8b52a76926cd31b36978782062c0ed9b1192b36bebc75c4c87c82e178dfcb0ed0fc27ca59d434198aac0bd0be18f5781ded775604db22304a + languageName: node + linkType: hard + "iconv-lite@npm:0.6.3, iconv-lite@npm:^0.6.2": version: 0.6.3 resolution: "iconv-lite@npm:0.6.3" @@ -8554,6 +8952,15 @@ __metadata: languageName: node linkType: hard +"is-plain-object@npm:^2.0.4": + version: 2.0.4 + resolution: "is-plain-object@npm:2.0.4" + dependencies: + isobject: "npm:^3.0.1" + checksum: 10c0/f050fdd5203d9c81e8c4df1b3ff461c4bc64e8b5ca383bcdde46131361d0a678e80bcf00b5257646f6c636197629644d53bd8e2375aea633de09a82d57e942f4 + languageName: node + linkType: hard + "is-potential-custom-element-name@npm:^1.0.1": version: 1.0.1 resolution: "is-potential-custom-element-name@npm:1.0.1" @@ -8589,6 +8996,13 @@ __metadata: languageName: node linkType: hard +"is-stream@npm:^2.0.0": + version: 2.0.1 + resolution: "is-stream@npm:2.0.1" + checksum: 10c0/7c284241313fc6efc329b8d7f08e16c0efeb6baab1b4cd0ba579eb78e5af1aa5da11e68559896a2067cd6c526bd29241dda4eb1225e627d5aa1a89a76d4635a5 + languageName: node + linkType: hard + "is-string@npm:^1.0.7, is-string@npm:^1.1.1": version: 1.1.1 resolution: "is-string@npm:1.1.1" @@ -8687,6 +9101,13 @@ __metadata: languageName: node linkType: hard +"isobject@npm:^3.0.1": + version: 3.0.1 + resolution: "isobject@npm:3.0.1" + checksum: 10c0/03344f5064a82f099a0cd1a8a407f4c0d20b7b8485e8e816c39f249e9416b06c322e8dec5b842b6bb8a06de0af9cb48e7bc1b5352f0fadc2f0abac033db3d4db + languageName: node + linkType: hard + "istanbul-lib-coverage@npm:^3.0.0, istanbul-lib-coverage@npm:^3.2.2": version: 3.2.2 resolution: "istanbul-lib-coverage@npm:3.2.2" @@ -8812,6 +9233,39 @@ __metadata: languageName: node linkType: hard +"jscodeshift@npm:^17.3.0": + version: 17.4.0 + resolution: "jscodeshift@npm:17.4.0" + dependencies: + "@babel/core": "npm:^7.24.7" + "@babel/parser": "npm:^7.24.7" + "@babel/plugin-transform-class-properties": "npm:^7.24.7" + "@babel/plugin-transform-modules-commonjs": "npm:^7.24.7" + "@babel/plugin-transform-nullish-coalescing-operator": "npm:^7.24.7" + "@babel/plugin-transform-optional-chaining": "npm:^7.24.7" + "@babel/plugin-transform-private-methods": "npm:^7.24.7" + "@babel/preset-flow": "npm:^7.24.7" + "@babel/preset-typescript": "npm:^7.24.7" + "@babel/register": "npm:^7.24.6" + flow-parser: "npm:0.*" + graceful-fs: "npm:^4.2.4" + neo-async: "npm:^2.5.0" + picocolors: "npm:^1.0.1" + picomatch: "npm:^4.0.2" + recast: "npm:^0.23.11" + tmp: "npm:^0.2.3" + write-file-atomic: "npm:^5.0.1" + peerDependencies: + "@babel/preset-env": ^7.1.6 + peerDependenciesMeta: + "@babel/preset-env": + optional: true + bin: + jscodeshift: bin/jscodeshift.js + checksum: 10c0/ef7b71c22f211cbba8ae96ffd2d3e8af28450d8f703d32050ff9f6cb29042bc163ce7d8239798b672b543bb12203adea20fb4d2c0034acc5440d26cb17c7a42f + languageName: node + linkType: hard + "jsdom@npm:^25.0.1": version: 25.0.1 resolution: "jsdom@npm:25.0.1" @@ -8924,13 +9378,20 @@ __metadata: languageName: node linkType: hard -"kind-of@npm:^6.0.0": +"kind-of@npm:^6.0.0, kind-of@npm:^6.0.2": version: 6.0.3 resolution: "kind-of@npm:6.0.3" checksum: 10c0/61cdff9623dabf3568b6445e93e31376bee1cdb93f8ba7033d86022c2a9b1791a1d9510e026e6465ebd701a6dd2f7b0808483ad8838341ac52f003f512e0b4c4 languageName: node linkType: hard +"kleur@npm:^3.0.3": + version: 3.0.3 + resolution: "kleur@npm:3.0.3" + checksum: 10c0/cd3a0b8878e7d6d3799e54340efe3591ca787d9f95f109f28129bdd2915e37807bf8918bb295ab86afb8c82196beec5a1adcaf29042ce3f2bd932b038fe3aa4b + languageName: node + linkType: hard + "launch-editor@npm:^2.14.1": version: 2.14.1 resolution: "launch-editor@npm:2.14.1" @@ -8974,6 +9435,16 @@ __metadata: languageName: node linkType: hard +"locate-path@npm:^3.0.0": + version: 3.0.0 + resolution: "locate-path@npm:3.0.0" + dependencies: + p-locate: "npm:^3.0.0" + path-exists: "npm:^3.0.0" + checksum: 10c0/3db394b7829a7fe2f4fbdd25d3c4689b85f003c318c5da4052c7e56eed697da8f1bce5294f685c69ff76e32cba7a33629d94396976f6d05fb7f4c755c5e2ae8b + languageName: node + linkType: hard + "locate-path@npm:^6.0.0": version: 6.0.0 resolution: "locate-path@npm:6.0.0" @@ -9104,6 +9575,16 @@ __metadata: languageName: node linkType: hard +"make-dir@npm:^2.0.0, make-dir@npm:^2.1.0": + version: 2.1.0 + resolution: "make-dir@npm:2.1.0" + dependencies: + pify: "npm:^4.0.1" + semver: "npm:^5.6.0" + checksum: 10c0/ada869944d866229819735bee5548944caef560d7a8536ecbc6536edca28c72add47cc4f6fc39c54fb25d06b58da1f8994cf7d9df7dadea047064749efc085d8 + languageName: node + linkType: hard + "make-dir@npm:^4.0.0": version: 4.0.0 resolution: "make-dir@npm:4.0.0" @@ -9289,6 +9770,13 @@ __metadata: languageName: node linkType: hard +"merge-stream@npm:^2.0.0": + version: 2.0.0 + resolution: "merge-stream@npm:2.0.0" + checksum: 10c0/867fdbb30a6d58b011449b8885601ec1690c3e41c759ecd5a9d609094f7aed0096c37823ff4a7190ef0b8f22cc86beb7049196ff68c016e3b3c671d0dac91ce5 + languageName: node + linkType: hard + "merge2@npm:^1.3.0": version: 1.4.1 resolution: "merge2@npm:1.4.1" @@ -9581,6 +10069,13 @@ __metadata: languageName: node linkType: hard +"mimic-fn@npm:^2.1.0": + version: 2.1.0 + resolution: "mimic-fn@npm:2.1.0" + checksum: 10c0/b26f5479d7ec6cc2bce275a08f146cf78f5e7b661b18114e2506dd91ec7ec47e7a25bf4360e5438094db0560bcc868079fb3b1fb3892b833c1ecbf63f80c95a4 + languageName: node + linkType: hard + "mimic-function@npm:^5.0.0": version: 5.0.1 resolution: "mimic-function@npm:5.0.1" @@ -9794,6 +10289,13 @@ __metadata: languageName: node linkType: hard +"neo-async@npm:^2.5.0": + version: 2.6.2 + resolution: "neo-async@npm:2.6.2" + checksum: 10c0/c2f5a604a54a8ec5438a342e1f356dff4bc33ccccdb6dc668d94fe8e5eccfc9d2c2eea6064b0967a767ba63b33763f51ccf2cd2441b461a7322656c1f06b3f5d + languageName: node + linkType: hard + "next@npm:^15.0.0": version: 15.5.9 resolution: "next@npm:15.5.9" @@ -9903,6 +10405,15 @@ __metadata: languageName: node linkType: hard +"npm-run-path@npm:^4.0.1": + version: 4.0.1 + resolution: "npm-run-path@npm:4.0.1" + dependencies: + path-key: "npm:^3.0.0" + checksum: 10c0/6f9353a95288f8455cf64cbeb707b28826a7f29690244c1e4bb61ec573256e021b6ad6651b394eb1ccfd00d6ec50147253aba2c5fe58a57ceb111fad62c519ac + languageName: node + linkType: hard + "nwsapi@npm:^2.2.12": version: 2.2.20 resolution: "nwsapi@npm:2.2.20" @@ -9999,6 +10510,15 @@ __metadata: languageName: node linkType: hard +"onetime@npm:^5.1.2": + version: 5.1.2 + resolution: "onetime@npm:5.1.2" + dependencies: + mimic-fn: "npm:^2.1.0" + checksum: 10c0/ffcef6fbb2692c3c40749f31ea2e22677a876daea92959b8a80b521d95cca7a668c884d8b2045d1d8ee7d56796aa405c405462af112a1477594cc63531baeb8f + languageName: node + linkType: hard + "onetime@npm:^7.0.0": version: 7.0.0 resolution: "onetime@npm:7.0.0" @@ -10061,6 +10581,15 @@ __metadata: languageName: node linkType: hard +"p-limit@npm:^2.0.0": + version: 2.3.0 + resolution: "p-limit@npm:2.3.0" + dependencies: + p-try: "npm:^2.0.0" + checksum: 10c0/8da01ac53efe6a627080fafc127c873da40c18d87b3f5d5492d465bb85ec7207e153948df6b9cbaeb130be70152f874229b8242ee2be84c0794082510af97f12 + languageName: node + linkType: hard + "p-limit@npm:^3.0.2": version: 3.1.0 resolution: "p-limit@npm:3.1.0" @@ -10070,6 +10599,15 @@ __metadata: languageName: node linkType: hard +"p-locate@npm:^3.0.0": + version: 3.0.0 + resolution: "p-locate@npm:3.0.0" + dependencies: + p-limit: "npm:^2.0.0" + checksum: 10c0/7b7f06f718f19e989ce6280ed4396fb3c34dabdee0df948376483032f9d5ec22fdf7077ec942143a75827bb85b11da72016497fc10dac1106c837ed593969ee8 + languageName: node + linkType: hard + "p-locate@npm:^5.0.0": version: 5.0.0 resolution: "p-locate@npm:5.0.0" @@ -10086,6 +10624,13 @@ __metadata: languageName: node linkType: hard +"p-try@npm:^2.0.0": + version: 2.2.0 + resolution: "p-try@npm:2.2.0" + checksum: 10c0/c36c19907734c904b16994e6535b02c36c2224d433e01a2f1ab777237f4d86e6289fd5fd464850491e940379d4606ed850c03e0f9ab600b0ebddb511312e177f + languageName: node + linkType: hard + "package-json-from-dist@npm:^1.0.0": version: 1.0.1 resolution: "package-json-from-dist@npm:1.0.1" @@ -10141,6 +10686,13 @@ __metadata: languageName: node linkType: hard +"path-exists@npm:^3.0.0": + version: 3.0.0 + resolution: "path-exists@npm:3.0.0" + checksum: 10c0/17d6a5664bc0a11d48e2b2127d28a0e58822c6740bde30403f08013da599182289c56518bec89407e3f31d3c2b6b296a4220bc3f867f0911fee6952208b04167 + languageName: node + linkType: hard + "path-exists@npm:^4.0.0": version: 4.0.0 resolution: "path-exists@npm:4.0.0" @@ -10148,7 +10700,7 @@ __metadata: languageName: node linkType: hard -"path-key@npm:^3.1.0": +"path-key@npm:^3.0.0, path-key@npm:^3.1.0": version: 3.1.1 resolution: "path-key@npm:3.1.1" checksum: 10c0/748c43efd5a569c039d7a00a03b58eecd1d75f3999f5a28303d75f521288df4823bc057d8784eb72358b2895a05f29a070bc9f1f17d28226cc4e62494cc58c4c @@ -10210,7 +10762,7 @@ __metadata: languageName: node linkType: hard -"picocolors@npm:^1.0.0, picocolors@npm:^1.1.1": +"picocolors@npm:^1.0.0, picocolors@npm:^1.0.1, picocolors@npm:^1.1.1": version: 1.1.1 resolution: "picocolors@npm:1.1.1" checksum: 10c0/e2e3e8170ab9d7c7421969adaa7e1b31434f789afb9b3f115f6b96d91945041ac3ceb02e9ec6fe6510ff036bcc0bf91e69a1772edc0b707e12b19c0f2d6bcf58 @@ -10245,6 +10797,29 @@ __metadata: languageName: node linkType: hard +"pify@npm:^4.0.1": + version: 4.0.1 + resolution: "pify@npm:4.0.1" + checksum: 10c0/6f9d404b0d47a965437403c9b90eca8bb2536407f03de165940e62e72c8c8b75adda5516c6b9b23675a5877cc0bcac6bdfb0ef0e39414cd2476d5495da40e7cf + languageName: node + linkType: hard + +"pirates@npm:^4.0.6": + version: 4.0.7 + resolution: "pirates@npm:4.0.7" + checksum: 10c0/a51f108dd811beb779d58a76864bbd49e239fa40c7984cd11596c75a121a8cc789f1c8971d8bb15f0dbf9d48b76c05bb62fcbce840f89b688c0fa64b37e8478a + languageName: node + linkType: hard + +"pkg-dir@npm:^3.0.0": + version: 3.0.0 + resolution: "pkg-dir@npm:3.0.0" + dependencies: + find-up: "npm:^3.0.0" + checksum: 10c0/902a3d0c1f8ac43b1795fa1ba6ffeb37dfd53c91469e969790f6ed5e29ff2bdc50b63ba6115dc056d2efb4a040aa2446d512b3804bdafdf302f734fb3ec21847 + languageName: node + linkType: hard + "possible-typed-array-names@npm:^1.0.0": version: 1.1.0 resolution: "possible-typed-array-names@npm:1.1.0" @@ -10363,6 +10938,16 @@ __metadata: languageName: node linkType: hard +"prompts@npm:^2.4.2": + version: 2.4.2 + resolution: "prompts@npm:2.4.2" + dependencies: + kleur: "npm:^3.0.3" + sisteransi: "npm:^1.0.5" + checksum: 10c0/16f1ac2977b19fe2cf53f8411cc98db7a3c8b115c479b2ca5c82b5527cd937aa405fa04f9a5960abeb9daef53191b53b4d13e35c1f5d50e8718c76917c5f1ea4 + languageName: node + linkType: hard + "prop-types@npm:^15.8.1": version: 15.8.1 resolution: "prop-types@npm:15.8.1" @@ -10598,28 +11183,6 @@ __metadata: languageName: node linkType: hard -"react-simplikit-codemod@workspace:packages/codemod": - version: 0.0.0-use.local - resolution: "react-simplikit-codemod@workspace:packages/codemod" - dependencies: - "@types/node": "npm:^24.13.3" - "@types/semver": "npm:^7.8.0" - "@vitest/coverage-v8": "npm:^2.1.8" - commander: "npm:^13.1.0" - detect-indent: "npm:^7.0.2" - eslint: "npm:^9.39.3" - fast-check: "npm:^4.9.0" - fast-glob: "npm:^3.3.3" - rimraf: "npm:^6.0.1" - semver: "npm:^7.8.5" - tsdown: "npm:^0.22.14" - typescript: "npm:^5.7.2" - vitest: "npm:^2.1.8" - bin: - react-simplikit-codemod: ./dist/cli.mjs - languageName: unknown - linkType: soft - "react-simplikit@workspace:*, react-simplikit@workspace:^, react-simplikit@workspace:packages/react-simplikit": version: 0.0.0-use.local resolution: "react-simplikit@workspace:packages/react-simplikit" @@ -10696,6 +11259,19 @@ __metadata: languageName: node linkType: hard +"recast@npm:^0.23.11": + version: 0.23.21 + resolution: "recast@npm:0.23.21" + dependencies: + ast-types: "npm:^0.16.1" + esprima: "npm:~4.0.0" + source-map: "npm:~0.6.1" + tiny-invariant: "npm:^1.3.3" + tslib: "npm:^2.0.1" + checksum: 10c0/afee4673fda5a95b0db8199a3f75c6f675269f00328a3673f241a6088c99b5a58f7082b6cff683456a182e3302bfb57313ebb1c2073228b260724b0993ff1f9a + languageName: node + linkType: hard + "redent@npm:^3.0.0": version: 3.0.0 resolution: "redent@npm:3.0.0" @@ -11279,6 +11855,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^5.6.0": + version: 5.7.3 + resolution: "semver@npm:5.7.3" + bin: + semver: bin/semver + checksum: 10c0/46308a549dd9d9b9dd2b89c47acce5905e81d456d1e105880c07f31a93469fcd4416c9b6cf437cbcad22093ba8371bca2ad6c4a874c6f073af3500645f236979 + languageName: node + linkType: hard + "semver@npm:^6.3.1": version: 6.3.1 resolution: "semver@npm:6.3.1" @@ -11359,6 +11944,15 @@ __metadata: languageName: node linkType: hard +"shallow-clone@npm:^3.0.0": + version: 3.0.1 + resolution: "shallow-clone@npm:3.0.1" + dependencies: + kind-of: "npm:^6.0.2" + checksum: 10c0/7bab09613a1b9f480c85a9823aebec533015579fa055ba6634aa56ba1f984380670eaf33b8217502931872aa1401c9fcadaa15f9f604d631536df475b05bcf1e + languageName: node + linkType: hard + "sharp@npm:^0.34.3": version: 0.34.5 resolution: "sharp@npm:0.34.5" @@ -11537,6 +12131,13 @@ __metadata: languageName: node linkType: hard +"signal-exit@npm:^3.0.3": + version: 3.0.7 + resolution: "signal-exit@npm:3.0.7" + checksum: 10c0/25d272fa73e146048565e08f3309d5b942c1979a6f4a58a8c59d5fa299728e9c2fcd1a759ec870863b1fd38653670240cd420dad2ad9330c71f36608a6a1c912 + languageName: node + linkType: hard + "signal-exit@npm:^4.0.1, signal-exit@npm:^4.1.0": version: 4.1.0 resolution: "signal-exit@npm:4.1.0" @@ -11615,6 +12216,23 @@ __metadata: languageName: node linkType: hard +"source-map-support@npm:^0.5.16": + version: 0.5.21 + resolution: "source-map-support@npm:0.5.21" + dependencies: + buffer-from: "npm:^1.0.0" + source-map: "npm:^0.6.0" + checksum: 10c0/9ee09942f415e0f721d6daad3917ec1516af746a8120bba7bb56278707a37f1eb8642bde456e98454b8a885023af81a16e646869975f06afc1a711fb90484e7d + languageName: node + linkType: hard + +"source-map@npm:^0.6.0, source-map@npm:~0.6.1": + version: 0.6.1 + resolution: "source-map@npm:0.6.1" + checksum: 10c0/ab55398007c5e5532957cb0beee2368529618ac0ab372d789806f5718123cc4367d57de3904b4e6a4170eb5a0b0f41373066d02ca0735a0c4d75c7d328d3e011 + languageName: node + linkType: hard + "space-separated-tokens@npm:^2.0.0": version: 2.0.2 resolution: "space-separated-tokens@npm:2.0.2" @@ -11803,6 +12421,13 @@ __metadata: languageName: node linkType: hard +"strip-final-newline@npm:^2.0.0": + version: 2.0.0 + resolution: "strip-final-newline@npm:2.0.0" + checksum: 10c0/bddf8ccd47acd85c0e09ad7375409d81653f645fda13227a9d459642277c253d877b68f2e5e4d819fe75733b0e626bac7e954c04f3236f6d196f79c94fa4a96f + languageName: node + linkType: hard + "strip-indent@npm:^3.0.0": version: 3.0.0 resolution: "strip-indent@npm:3.0.0" @@ -11937,6 +12562,13 @@ __metadata: languageName: node linkType: hard +"tiny-invariant@npm:^1.3.3": + version: 1.3.3 + resolution: "tiny-invariant@npm:1.3.3" + checksum: 10c0/65af4a07324b591a059b35269cd696aba21bef2107f29b9f5894d83cc143159a204b299553435b03874ebb5b94d019afa8b8eff241c8a4cfee95872c2e1c1c4a + languageName: node + linkType: hard + "tinybench@npm:^2.9.0": version: 2.9.0 resolution: "tinybench@npm:2.9.0" @@ -12027,6 +12659,13 @@ __metadata: languageName: node linkType: hard +"tmp@npm:^0.2.3": + version: 0.2.7 + resolution: "tmp@npm:0.2.7" + checksum: 10c0/59eb55584f2f07210d3231b6a1f6b5c2b9794d8a7b509c8ee867ed2acad6d2245ee2448b7937b676ffbff3155a70077edde8a69f9d7cf0f90c86a62e8910c357 + languageName: node + linkType: hard + "to-regex-range@npm:^5.0.1": version: 5.0.1 resolution: "to-regex-range@npm:5.0.1" @@ -12166,6 +12805,13 @@ __metadata: languageName: node linkType: hard +"tslib@npm:^2.0.1": + version: 2.9.1 + resolution: "tslib@npm:2.9.1" + checksum: 10c0/8ff46e7a4d19fa62c23483c89cf5ccc3906e742ef6e6d60bd3826b686143b300b4f6f04161cc1cf31a6b11fe70e1058ae4d4e4a108b5c68326d469684736a83c + languageName: node + linkType: hard + "tsx@npm:^4.19.2": version: 4.19.3 resolution: "tsx@npm:4.19.3" @@ -12334,6 +12980,13 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~8.9.0": + version: 8.9.0 + resolution: "undici-types@npm:8.9.0" + checksum: 10c0/51c712c20c087368f62c6fc0f2bc49fa76bfe5dec28ff01584bb677ff29b0622569783c02d43e151143808c48c0503f804093bd2c491b10f2a830138034cb451 + languageName: node + linkType: hard + "unicode-emoji-modifier-base@npm:^1.0.0": version: 1.0.0 resolution: "unicode-emoji-modifier-base@npm:1.0.0" @@ -12991,6 +13644,16 @@ __metadata: languageName: node linkType: hard +"write-file-atomic@npm:^5.0.1": + version: 5.0.1 + resolution: "write-file-atomic@npm:5.0.1" + dependencies: + imurmurhash: "npm:^0.1.4" + signal-exit: "npm:^4.0.1" + checksum: 10c0/e8c850a8e3e74eeadadb8ad23c9d9d63e4e792bd10f4836ed74189ef6e996763959f1249c5650e232f3c77c11169d239cbfc8342fc70f3fe401407d23810505d + languageName: node + linkType: hard + "ws@npm:^8.18.0": version: 8.18.1 resolution: "ws@npm:8.18.1"