Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to pnpm #444

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e7634ab
update gh actions, gitignore, husky, lintstage
technophile-04 Jul 20, 2023
e9cc46f
add pnpm workspace and lock file
technophile-04 Jul 21, 2023
5f6a6d8
generate pnpm-lock.yaml per workspace
technophile-04 Jul 24, 2023
d0a2d15
add use-hooks patch
technophile-04 Jul 24, 2023
da47e55
remove --immutable from gh-workflow
technophile-04 Jul 24, 2023
80e48fd
setup pnpm in gh workflow
technophile-04 Jul 24, 2023
ec68f70
add downloading Git reference back
technophile-04 Jul 26, 2023
d148eb0
updater packageManger version in package.json
technophile-04 Jul 26, 2023
e720b86
add preinstall script
technophile-04 Jul 27, 2023
ba393c0
use glob pattern for workspace
technophile-04 Jul 27, 2023
714a6e8
put back OG deploy command
technophile-04 Aug 1, 2023
073ce50
fix localStorage patch, update pnpm version to 8.6.12
technophile-04 Aug 7, 2023
43665f7
update gh-actions to use pnpm run while running scripts
technophile-04 Aug 7, 2023
f04127e
Merge remote-tracking branch 'origin/main' into feat/pnpm
technophile-04 Sep 3, 2023
ab36f9b
add abitype
technophile-04 Sep 3, 2023
2580043
Merge branch 'main' into feat/pnpm
carletex Sep 7, 2023
1e43995
add check for pnpm version >=8.7.1 & use shorthand -F instead of --fi…
technophile-04 Sep 8, 2023
047fc2c
update readme with lowercase pnpm and mention version
technophile-04 Sep 8, 2023
a792eca
Fix pnpm installation link
carletex Sep 14, 2023
e38ee17
Merge branch 'main' into feat/pnpm
carletex Sep 14, 2023
c3982e2
Merge branch 'main' into feat/pnpm
technophile-04 Sep 21, 2023
e703240
Merge branch 'origin/main' into feat/pnpm
technophile-04 Sep 24, 2023
c09290d
use node v18 in actions
technophile-04 Sep 24, 2023
3b9b57c
update abitype ovveride path
technophile-04 Sep 24, 2023
8fd3023
Merge branch 'main' into feat/pnpm
technophile-04 Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,28 @@ jobs:
- name: Checkout
uses: actions/checkout@master

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup node env
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache : yarn
cache: pnpm

- name: Install dependencies
run: yarn install --immutable
run: pnpm install

- name: Run hardhat node, deploy contracts (& generate contracts typescript output)
run: yarn chain & yarn deploy
run: pnpm chain & pnpm hardhat:deploy

- name: Run nextjs lint
run: yarn next:lint --max-warnings=0
run: pnpm next:lint --max-warnings=0

- name: Check typings on nextjs
run: yarn next:check-types
run: pnpm next:check-types

- name: Run hardhat lint
run: yarn hardhat:lint --max-warnings=0
run: pnpm hardhat:lint --max-warnings=0
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
node_modules

# dependencies, yarn, etc
# yarn / eslint
# pnpm
pnpm-debug.log*
pnpm-error.log*
.pnpm-debug.log*

# yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# eslint
.eslintcache

# Visual Studio Code
.vscode/**

# macOS
.DS_Store
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged --verbose
pnpm lint-staged --verbose
6 changes: 3 additions & 3 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const path = require("path");

const buildNextEslintCommand = (filenames) =>
`yarn next:lint --fix --file ${filenames
`pnpm next:lint --fix --file ${filenames
.map((f) => path.relative(path.join("packages", "nextjs"), f))
.join(" --file ")}`;

const checkTypesNextCommand = () => "yarn next:check-types";
const checkTypesNextCommand = () => "pnpm next:check-types";

const buildHardhatEslintCommand = (filenames) =>
`yarn hardhat:lint-staged --fix ${filenames
`pnpm hardhat:lint-staged --fix ${filenames
.map((f) => path.relative(path.join("packages", "hardhat"), f))
.join(" ")}`;

Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shared-workspace-lockfile = false
9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

783 changes: 0 additions & 783 deletions .yarn/releases/yarn-3.2.3.cjs

This file was deleted.

11 changes: 0 additions & 11 deletions .yarnrc.yml

This file was deleted.

37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
Before you begin, you need to install the following tools:

- [Node (v18 LTS)](https://nodejs.org/en/download/)
- Yarn ([v1](https://classic.yarnpkg.com/en/docs/install/) or [v2+](https://yarnpkg.com/getting-started/install))
- [Git](https://git-scm.com/downloads)
technophile-04 marked this conversation as resolved.
Show resolved Hide resolved
- [PNPM](https://pnpm.io/cli/install)
carletex marked this conversation as resolved.
Show resolved Hide resolved

## Quickstart

Expand All @@ -39,34 +38,34 @@ To get started with Scaffold-ETH 2, follow the steps below:
```
git clone https://github.com/scaffold-eth/scaffold-eth-2.git
cd scaffold-eth-2
yarn install
pnpm install
```

2. Run a local network in the first terminal:

```
yarn chain
pnpm chain
```

This command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in `hardhat.config.ts`.

3. On a second terminal, deploy the test contract:

```
yarn deploy
pnpm hardhat:deploy
```

This command deploys a test smart contract to the local network. The contract is located in `packages/hardhat/contracts` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/hardhat/deploy` to deploy the contract to the network. You can also customize the deploy script.
This command deploys a test smart contract to the local network. The contract is located in `packages/hardhat/contracts` and can be modified to suit your needs. The `pnpm hardhat:deploy` command uses the deploy script located in `packages/hardhat/deploy` to deploy the contract to the network. You can also customize the deploy script.

4. On a third terminal, start your NextJS app:

```
yarn start
pnpm start
```

Visit your app on: `http://localhost:3000`. You can interact with your smart contract using the contract component or the example ui in the frontend. You can tweak the app config in `packages/nextjs/scaffold.config.ts`.

Run smart contract test with `yarn hardhat:test`
Run smart contract test with `pnpm hardhat:test`

- Edit your smart contract `YourContract.sol` in `packages/hardhat/contracts`
- Edit your frontend in `packages/nextjs/pages`
Expand All @@ -78,14 +77,14 @@ Once you are ready to deploy your smart contracts, there are a few things you ne

1. Select the network

By default, `yarn deploy` will deploy the contract to the local network. You can change the defaultNetwork in `packages/hardhat/hardhat.config.ts.` You could also simply run `yarn deploy --network target_network` to deploy to another network.
By default, `pnpm hardhat:deploy` will deploy the contract to the local network. You can change the defaultNetwork in `packages/hardhat/hardhat.config.ts.` You could also simply run `pnpm hardhat:deploy --network target_network` to deploy to another network.

Check the `hardhat.config.ts` for the networks that are pre-configured. You can also add other network settings to the `hardhat.config.ts` file. Here are the [Alchemy docs](https://docs.alchemy.com/docs/how-to-add-alchemy-rpc-endpoints-to-metamask) for information on specific networks.

Example: To deploy the contract to the Sepolia network, run the command below:

```
yarn deploy --network sepolia
pnpm hardhat:deploy --network sepolia
```

2. Generate a new account or add one to deploy the contract(s) from. Additionally you will need to add your Alchemy API key. Rename `.env.example` to `.env` and fill the required keys.
Expand All @@ -97,31 +96,31 @@ DEPLOYER_PRIVATE_KEY=""

The deployer account is the account that will deploy your contracts. Additionally, the deployer account will be used to execute any function calls that are part of your deployment script.

You can generate a random account / private key with `yarn generate` or add the private key of your crypto wallet. `yarn generate` will create a random account and add the DEPLOYER_PRIVATE_KEY to the .env file. You can check the generated account with `yarn account`.
You can generate a random account / private key with `pnpm generate` or add the private key of your crypto wallet. `pnpm generate` will create a random account and add the DEPLOYER_PRIVATE_KEY to the .env file. You can check the generated account with `pnpm account`.

3. Deploy your smart contract(s)

Run the command below to deploy the smart contract to the target network. Make sure to have some funds in your deployer account to pay for the transaction.

```
yarn deploy --network network_name
pnpm hardhat:deploy --network network_name
```

4. Verify your smart contract

You can verify your smart contract on Etherscan by running:

```
yarn verify --network network_name
pnpm verify --network network_name
```

## Deploying your NextJS App

**Hint**: We recommend connecting your GitHub repo to Vercel (through the Vercel UI) so it gets automatically deployed when pushing to `main`.

If you want to deploy directly from the CLI, run `yarn vercel` and follow the steps to deploy to Vercel. Once you log in (email, github, etc), the default options should work. It'll give you a public URL.
If you want to deploy directly from the CLI, run `pnpm vercel` and follow the steps to deploy to Vercel. Once you log in (email, github, etc), the default options should work. It'll give you a public URL.

If you want to redeploy to the same production URL you can run `yarn vercel --prod`. If you omit the `--prod` flag it will deploy it to a preview/test URL.
If you want to redeploy to the same production URL you can run `pnpm vercel --prod`. If you omit the `--prod` flag it will deploy it to a preview/test URL.

**Make sure to check the values of your Scaffold Configuration before deploying your NextJS App.**

Expand Down Expand Up @@ -332,11 +331,11 @@ This example uses the `useScaffoldContract` hook to obtain a contract instance f

We run `pre-commit` [git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) which lints the staged files and don't let you commit if there is an linting error.

To disable this, go to `.husky/pre-commit` file and comment out `yarn lint-staged --verbose`
To disable this, go to `.husky/pre-commit` file and comment out `pnpm lint-staged --verbose`

```diff
- yarn lint-staged --verbose
+ # yarn lint-staged --verbose
- pnpm lint-staged --verbose
+ # pnpm lint-staged --verbose
```

### Deploying to Vercel without any checks
Expand All @@ -346,7 +345,7 @@ By default, Vercel runs types and lint checks before building your app. The depl
To ignore these checks while deploying from the CLI, use:

```shell
yarn vercel:yolo
pnpm vercel:yolo
```

If your repo is connected to Vercel, you can set `NEXT_PUBLIC_IGNORE_BUILD_ERROR` to `true` in a [environment variable](https://vercel.com/docs/concepts/projects/environment-variables).
Expand Down
41 changes: 22 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,34 @@
]
},
"scripts": {
technophile-04 marked this conversation as resolved.
Show resolved Hide resolved
"account": "yarn workspace @se-2/hardhat account",
"chain": "yarn workspace @se-2/hardhat chain",
"fork": "yarn workspace @se-2/hardhat fork",
"deploy": "yarn workspace @se-2/hardhat deploy",
"verify": "yarn workspace @se-2/hardhat verify",
"compile": "yarn workspace @se-2/hardhat compile",
"generate": "yarn workspace @se-2/hardhat generate",
"hardhat:lint": "yarn workspace @se-2/hardhat lint",
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
"hardhat:test": "yarn workspace @se-2/hardhat test",
"start": "yarn workspace @se-2/nextjs dev",
"next:lint": "yarn workspace @se-2/nextjs lint",
"next:format": "yarn workspace @se-2/nextjs format",
"next:check-types": "yarn workspace @se-2/nextjs check-types",
"account": "pnpm --filter @se-2/hardhat account",
"chain": "pnpm --filter @se-2/hardhat chain",
"fork": "pnpm --filter @se-2/hardhat fork",
"hardhat:deploy": "pnpm --filter @se-2/hardhat hardhat:deploy",
carletex marked this conversation as resolved.
Show resolved Hide resolved
"verify": "pnpm --filter @se-2/hardhat verify",
"compile": "pnpm --filter @se-2/hardhat compile",
"generate": "pnpm --filter @se-2/hardhat generate",
"hardhat:lint": "pnpm --filter @se-2/hardhat lint",
"hardhat:lint-staged": "pnpm --filter @se-2/hardhat lint-staged",
"hardhat:test": "pnpm --filter @se-2/hardhat test",
"start": "pnpm --filter @se-2/nextjs dev",
"next:lint": "pnpm --filter @se-2/nextjs lint",
"next:format": "pnpm --filter @se-2/nextjs format",
"next:check-types": "pnpm --filter @se-2/nextjs check-types",
"postinstall": "husky install",
"precommit": "lint-staged",
"vercel": "yarn workspace @se-2/nextjs vercel",
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo"
"vercel": "pnpm --filter @se-2/nextjs vercel",
"vercel:yolo": "pnpm --filter @se-2/nextjs vercel:yolo"
technophile-04 marked this conversation as resolved.
Show resolved Hide resolved
},
"packageManager": "[email protected]",
"packageManager": "[email protected]",
carletex marked this conversation as resolved.
Show resolved Hide resolved
"devDependencies": {
"husky": "^8.0.1",
"lint-staged": "^13.0.3"
},
"resolutions": {
"usehooks-ts@^2.7.2": "patch:usehooks-ts@npm:^2.7.2#./.yarn/patches/usehooks-ts-npm-2.7.2-fceffe0e43.patch"
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
},
"allowNonAppliedPatches": "true"
}
}
2 changes: 1 addition & 1 deletion packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"account": "hardhat run scripts/listAccount.ts",
"chain": "hardhat node --network hardhat --no-deploy",
"compile": "hardhat compile",
"deploy": "hardhat deploy",
"hardhat:deploy": "hardhat deploy",
"fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy",
"generate": "hardhat run scripts/generateAccount.ts",
"lint": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts",
Expand Down
Loading