Skip to content

Instantly share code, notes, and snippets.

@kowito
Created January 9, 2024 07:19
Show Gist options
  • Save kowito/b0392c97a3071613ba90c0b32d9af6c2 to your computer and use it in GitHub Desktop.
Save kowito/b0392c97a3071613ba90c0b32d9af6c2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the project name from the first command line argument
PROJECT_NAME=$1
# Check if the project name was provided
if [ -z "$PROJECT_NAME" ]; then
echo "Error: No project name provided."
echo "Usage: $0 <project_name>"
exit 1
fi
# Create a new directory for your project and navigate into it
mkdir "$PROJECT_NAME"
cd "$PROJECT_NAME"
# Initialize a new pnpm project (Press Enter to skip all prompts)
pnpm init
# Install Hardhat and additional specified packages as development dependencies
pnpm add --save-dev hardhat @openzeppelin/contracts-upgradeable @nomiclabs/hardhat-ethers ethers
# Initialize Git repository
git init
# Create directories for contracts, scripts, and tests
mkdir contracts scripts test
# Create a basic Hardhat project
echo "module.exports = {};" > hardhat.config.js
# Add Hardhat commands to package.json
jq '.scripts = {
"compile": "hardhat compile",
"test": "hardhat test",
"deploy": "hardhat run scripts/deploy.js",
"node": "hardhat node"
}' package.json > temp.json && mv temp.json package.json
# Create a basic .gitignore file (optional)
echo "node_modules
dist
.cache
artifacts
build
coverage" > .gitignore
# First Git commit with the project initialization message
git add .
git commit -m "Initial commit - Set up $PROJECT_NAME project"
echo "Hardhat project initialized successfully in '$PROJECT_NAME' directory with basic structure and Git repository."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment