Skip to content

Commit

Permalink
next-codemod: add empty pnpm-workspace.yaml to test fixtures to byp…
Browse files Browse the repository at this point in the history
…ass PNPM workspace checks (#71726)

### Why?

Since dep installation within next-codemod runs `pnpm install` on the
Next.js repo, it installs in the workspace root scope during testing. We
could add a layer for testing like adding a flag `--no-workspace`, but
it will reduce confidence between the actual running and testing.
Therefore added an empty `pnpm-workspace.yaml` file to each fixture.

### How?

By doing this, both installation and testing will have same environment
of running, `pnpm install` only. To prevent created `pnpm-lockfile` to
be shipped, gitignored it.

This way, we keep things simple and make sure tests match real-world use
better. The empty `pnpm-workspace.yaml` files make `pnpm` treat each
fixture separately, which is closer to how it'll work for users.
  • Loading branch information
devjiwonchoi authored Oct 23, 2024
1 parent aed6c4c commit 741f830
Show file tree
Hide file tree
Showing 14 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/next-codemod/bin/__testfixtures__/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion packages/next-codemod/scripts/test-upgrade-fixture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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
pnpm install
node "$NEXT_CODEMOD_BIN" upgrade "${@:2}"
git --no-pager diff .
git restore .
Expand Down

0 comments on commit 741f830

Please sign in to comment.