hardhat-create-app
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -21,10 +21,25 @@ #!/usr/bin/env node | ||
// Set yarn to v2 | ||
console.log('Setting yarn to enable v2...'); | ||
spawnSync('yarn', ['set', 'version', 'berry'], { stdio: 'inherit' }); | ||
// Initialize a new npm project | ||
console.log('Initializing a new npm project...'); | ||
spawnSync('npm', ['init', '-y'], { stdio: 'inherit' }); | ||
spawnSync('yarn', ['init', '--yes'], { stdio: 'inherit' }); | ||
// Remove README.md created by yarn init | ||
console.log('Removing README.md...'); | ||
spawnSync('rm', ['README.md'], { stdio: 'inherit' }); | ||
// Make sure the nodeLinker is set to node-modules to avoid issues with npx | ||
console.log('Add nodeLinker to .yarnrc.yml...'); | ||
const yarnrcPath = path.join(root, '.yarnrc.yml'); | ||
const yarnrcContent = fs.readFileSync(yarnrcPath, 'utf-8'); | ||
fs.writeFileSync(yarnrcPath, yarnrcContent + 'nodeLinker: node-modules\n'); | ||
// Install Hardhat and initialize a new TypeScript project | ||
console.log('Installing Hardhat...'); | ||
spawnSync('npm', ['install', 'hardhat'], { stdio: 'inherit' }); | ||
spawnSync('yarn', ['add', 'hardhat'], { stdio: 'inherit' }); | ||
// Initialize a new Hardhat TypeScript project | ||
console.log('Initializing a new Hardhat TypeScript project...'); | ||
@@ -38,9 +53,9 @@ const result = execSync( | ||
// Install Hardhat Plugins | ||
console.log('Installing Hardhat Plugins...'); | ||
spawnSync( | ||
'npm', | ||
'yarn', | ||
[ | ||
'install', | ||
'--save-dev', | ||
'-f', | ||
'add', | ||
'-D', | ||
'solhint', | ||
@@ -54,3 +69,3 @@ 'prettier', | ||
'dotenv', | ||
'@nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers', | ||
'@nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers@latest', | ||
'@openzeppelin/contracts', | ||
@@ -63,7 +78,11 @@ 'hardhat-contract-sizer', | ||
// Add the "compile" script to package.json | ||
// Add the "compile" and "test" script to package.json | ||
console.log("Adding the 'compile' script to package.json..."); | ||
const packageJsonPath = path.join(root, 'package.json'); | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); | ||
packageJson.scripts.compile = 'hardhat compile'; | ||
packageJson.scripts = { | ||
...(packageJson.script ?? {}), | ||
compile: 'hardhat compile', | ||
test: 'hardhat test', | ||
}; | ||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
@@ -138,2 +157,3 @@ | ||
// Add plugins to the config | ||
modifiedContent = modifiedContent.replace( | ||
@@ -147,3 +167,2 @@ `import "@nomicfoundation/hardhat-toolbox";`, | ||
import * as dotenv from 'dotenv'; | ||
import './tasks/acl'; | ||
@@ -159,2 +178,3 @@ dotenv.config(); | ||
// Success message | ||
console.log(` | ||
@@ -165,17 +185,13 @@ Success! Created ${projectName} at ${root}. | ||
npm run compile | ||
yarn run compile | ||
Compiles the contracts. | ||
npm run test | ||
yarn run test | ||
Runs the tests. | ||
npm run test:watch | ||
Runs the tests in watch mode. | ||
We suggest that you install Hardhat shorthand: | ||
We suggest that you begin by typing: | ||
npm install --global hardhat-shorthand | ||
cd ${projectName} | ||
npm run test | ||
Happy hacking! | ||
`); |
{ | ||
"name": "hardhat-create-app", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10183
346