Global dependencies: node
and nvm
echo "v16.14.0" > .nvmrc
nvm use
echo "node_modules\n.DS_Store\ntypechain\n.env\n" > .gitignore
npm install -g yarn
yarn init --yes
Add export PATH="$(yarn global bin):$PATH"
to .bashrc
or .zshrc
yarn global add lerna
lerna init
Add to lerna.json
{
"packages": [
"packages/*"
],
"version": "0.0.1",
"npmClient": "yarn",
"useWorkspaces": true
}
Add to package.json
{
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"test": "lerna run test",
"new-version": "lerna version --conventional-commits --yes",
"diff": "lerna diff"
}
}
Step 4: Conventional Commits
yarn add -D -W git-cz
yarn global add typescript
cd packages
yarn add -D -W create-react-app create-react-library
yarn create react-app glider --template typescript
yarn create react-app rooms --template typescript
lerna bootstrap
mkdir smart-contracts && cd $_
yarn init
Edit package.json
{
"name": "stays-smart-contracts",
"version": "0.0.1",
"license": "GPL3"
}
Hardhat
yarn add -D hardhat
yarn run hardhat # > Create an empty hardhat.config.js
Typescript
yarn add -D ts-node chai @types/node @types/mocha @types/chai @nomiclabs/hardhat-ethers ethers @nomiclabs/hardhat-waffle ethereum-waffle chai [email protected] @typechain/hardhat @typechain/ethers-v5
tsc --init
mv hardhat.config.js hardhat.config.ts
Change tsconfig.json
to:
{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"outDir": "dist"
},
"include": ["./scripts", "./test", "./typechain"],
"files": ["./hardhat.config.ts"]
}
Change hardhat.config.ts
to
import '@typechain/hardhat'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
module.exports = {
solidity: {
version: '0.8.8'
}
}
Structure
mkdir contracts test
cd packages
mkdir docs && cd $_
yarn init --yes
echo "# Stays: on-chain bookings" > README.md
Edit package.json
{
"name": "stays-docs",
"version": "0.0.1",
"license": "MIT"
}
Add the following configuration
"devDependencies": {
"@windingtree/eslint-config": "^0.0.1",
"@windingtree/prettier-config": "^0.0.1"
}
to:
packages/rooms/package.json
packages/glider/package.json
packages/smart-contracts/package.json
and then:
lerna bootstrap