diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/README.md b/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/README.md new file mode 100644 index 0000000000000..c6f744b30286b --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/README.md @@ -0,0 +1 @@ +Upgrades React without prompt diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/app/layout.ts b/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/app/layout.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/package.json b/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/package.json new file mode 100644 index 0000000000000..f0e0da30ae636 --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/package.json @@ -0,0 +1,11 @@ +{ + "name": "react-18-installed-mixed-router", + "scripts": { + "dev": "next dev" + }, + "dependencies": { + "next": "14.3.0-canary.44", + "react": "18.2.0", + "react-dom": "18.2.0" + } +} diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/pages/index.ts b/packages/next-codemod/bin/__testfixtures__/react-18-installed-mixed-router/pages/index.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/README.md b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/README.md new file mode 100644 index 0000000000000..c6f744b30286b --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/README.md @@ -0,0 +1 @@ +Upgrades React without prompt diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/app/layout.ts b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/app/layout.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/package.json b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/package.json new file mode 100644 index 0000000000000..28587f48b3f75 --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-app-router/package.json @@ -0,0 +1,11 @@ +{ + "name": "react-18-installed-pure-app-router", + "scripts": { + "dev": "next dev" + }, + "dependencies": { + "next": "14.3.0-canary.44", + "react": "18.2.0", + "react-dom": "18.2.0" + } +} diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/README.md b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/README.md new file mode 100644 index 0000000000000..c6f744b30286b --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/README.md @@ -0,0 +1 @@ +Upgrades React without prompt diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/package.json b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/package.json new file mode 100644 index 0000000000000..7ca58bd1489bb --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/package.json @@ -0,0 +1,11 @@ +{ + "name": "react-18-installed-pure-pages-router", + "scripts": { + "dev": "next dev" + }, + "dependencies": { + "next": "14.3.0-canary.44", + "react": "18.2.0", + "react-dom": "18.2.0" + } +} diff --git a/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/pages/index.ts b/packages/next-codemod/bin/__testfixtures__/react-18-installed-pure-pages-router/pages/index.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/README.md b/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/README.md new file mode 100644 index 0000000000000..c6f744b30286b --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/README.md @@ -0,0 +1 @@ +Upgrades React without prompt diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/app/layout.ts b/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/app/layout.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/package.json b/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/package.json new file mode 100644 index 0000000000000..a3ee83b34a39b --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/package.json @@ -0,0 +1,11 @@ +{ + "name": "react-19-installed-mixed-router", + "scripts": { + "dev": "next dev" + }, + "dependencies": { + "next": "14.3.0-canary.45", + "react": "19.0.0-beta-4508873393-20240430", + "react-dom": "19.0.0-beta-4508873393-20240430" + } +} diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/pages/index.ts b/packages/next-codemod/bin/__testfixtures__/react-19-installed-mixed-router/pages/index.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/README.md b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/README.md new file mode 100644 index 0000000000000..c6f744b30286b --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/README.md @@ -0,0 +1 @@ +Upgrades React without prompt diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/app/layout.ts b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/app/layout.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/package.json b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/package.json new file mode 100644 index 0000000000000..9031ec28ac412 --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-app-router/package.json @@ -0,0 +1,11 @@ +{ + "name": "react-19-installed-pure-app-router", + "scripts": { + "dev": "next dev" + }, + "dependencies": { + "next": "14.3.0-canary.45", + "react": "19.0.0-beta-4508873393-20240430", + "react-dom": "19.0.0-beta-4508873393-20240430" + } +} diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/README.md b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/README.md new file mode 100644 index 0000000000000..c6f744b30286b --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/README.md @@ -0,0 +1 @@ +Upgrades React without prompt diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/package.json b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/package.json new file mode 100644 index 0000000000000..881881779fbd0 --- /dev/null +++ b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/package.json @@ -0,0 +1,11 @@ +{ + "name": "react-19-installed-pure-pages-router", + "scripts": { + "dev": "next dev" + }, + "dependencies": { + "next": "14.3.0-canary.45", + "react": "19.0.0-beta-4508873393-20240430", + "react-dom": "19.0.0-beta-4508873393-20240430" + } +} diff --git a/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/pages/index.ts b/packages/next-codemod/bin/__testfixtures__/react-19-installed-pure-pages-router/pages/index.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 4965e5fee684f..77724903e6254 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -30,7 +30,8 @@ "build": "pnpm tsc -d -p tsconfig.json", "prepublishOnly": "cd ../../ && turbo run build", "dev": "pnpm tsc -d -w -p tsconfig.json", - "test": "jest" + "test": "jest", + "test:upgrade-fixture": "./scripts/test-upgrade-fixture.sh" }, "bin": "./bin/next-codemod.js", "devDependencies": { diff --git a/packages/next-codemod/scripts/test-upgrade-fixture.sh b/packages/next-codemod/scripts/test-upgrade-fixture.sh new file mode 100755 index 0000000000000..1a86df2c23823 --- /dev/null +++ b/packages/next-codemod/scripts/test-upgrade-fixture.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Simple test runner for upgrade fixtures. +# For manual verification only (check the README.md) in the fixtures +# for the expected behavior. +# Usage: +# - cwd must be ~/packages/next-codemod +# - `pnpm test:upgrade-fixture <...next-codemod-args>` + +NEXT_CODEMOD_BIN=$(pwd)/bin/next-codemod.js +cd "$1" || exit 1 +# We're only interested in the changes the upgrade command does. +git add -A . +rm -rf node_modules +pnpm install --ignore-workspace --no-lockfile +node "$NEXT_CODEMOD_BIN" upgrade "${@:2}" +git --no-pager diff . +git restore . +git reset HEAD -- .