Useful scripts for Truffle testers and maintainers on *nix OS.
Table of contents generated with markdown-toc
It's recommended that you use Node Version Manager
(nvm) to manage node versions for Truffle
development.
A list of frequently used packages can be stored in a file named default-packages
at the NVM directory , this list will be automatically installed globally every time a new node version is added.
First, create the $NVM_DIR/default-packages file.
touch $NVM_DIR/default-packages
We recommend adding faker-cli
, typescript
and yarn
.
# $NVM_DIR/default-packages
faker-cli
typescript
yarn
✨ We currently recommend using Node v14(LTS) or v16(LTS) with NPM 6 for yarn bootstrap
truffle. ✨
-
Clone this repo
git clone git@github.com:trufflesuite/dotfiles ~/.truffle-dotfiles
-
edit your shell startup script to set a couple of env variables, and source the dotfiles.
# in your .(zsh/bash)rc file ## TRUFFLE_ROOT is the path to your cloned truffle project export TRUFFLE_ROOT=~/work/truffle # YOU SHOULD ADJUST THIS FOR YOURSELF ## REPROD_ROOT is where you would like reproductions to be created. export REPROD_ROOT=~/work/reprod source ~/.truffle-dotfiles/scripts/truffle-scripts.sh
Create and navigate to a new folder organized by year/month/date
.
You will create many truffle projects in the course of your work and reprod
makes it easier with the benefit of organizing the folders by date. This is a
lifesaver when jumping between projects.
usage: reprod [ name ]
Options:
name specify the name of the project. A random name will
be used if not spcified.
Here's directory that's created after running reprod safe-eval
.
work/reproduce <-- This is REPROD_ROOT
├── 2021
│ └── 05
│ └── 25
│ └── safe-eval
Before using list-reprod please install the brew
utility for your Operating System
brew install tree # for OS X
For displaying directories as trees.
List all reprod folders for a year.
usage: list-reprod-year [ year ]
Options:
year specify the year. [default: current year]
List all reprod folders for a month.
usage: list-reprod-month [ month ]
Options:
month specify the month. [default: current month]
List all reprod folders for a day in current month.
usage: list-reprod-day [ day ]
Options:
day specify the day. [default: today]
You busy 🐝! List all reprod folders for today
usage: list-reprod-today
Display your current truffle resolutions. Useful for sanity checking.
$ show-truffle-env
truffle: /Users/cds/.nvm/versions/node/v12.22.1/bin/truffle
db-kit: db-kit: aliased to node /Users/cds/work/truffle/packages/db-kit/dist/bin/cli.js
Truffle v5.3.6 (core: 5.3.6)
Solidity v0.5.16 (solc-js)
Node v12.22.1
Web3.js v1.3.5
$
As you add features, debug issues you'll need to run specific versions truffle. There's the released version, the current bundled version, and the unbundled source. These two variants allow you to perform a regular execution and one with the node debug inspector enabled for acts of debuggerie.
Both variants use the truffle source currently in your TRUFFLE_ROOT
folder.
Invoke the truffle version you're currently developing.
usage: use-truffle-core
$ use-truffle-core
$ show-truffle-env
truffle: aliased to node /Users/liangliang/code/truffle/packages/core/cli.js
db-kit: db-kit not found
Truffle v5.5.32 (core: 5.5.32)
Ganache v7.4.3
Solidity - 0.8.13 (solc-js)
Node v16.16.0
Web3.js v1.7.4
Invoke the truffle code in your current git branch with the debug inspector
enabled. This allows you to debug the truffle process by using a debug client.
For example, to use chrome dev tools, navigate to chrome://inspect
in a
chrome browser.
usage: use-truffle-core-debug
$ use-truffle-core-debug
$ show-truffle-env
truffle: truffle: aliased to node --inspect-brk /Users/liangliang/code/truffle/packages/core/cli.js
db-kit: db-kit not found
Truffle v5.5.32 (core: 5.5.32)
Ganache v7.4.3
Solidity - 0.8.13 (solc-js)
Node v16.16.0
Web3.js v1.7.4
Invoke the bundled truffle version in your current git branch. This bundle will eventually be published to the npm registry. N.B. You should have already built truffle
usage: use-truffle-bundle
$ use-truffle-bundle
$ show-truffle-env
truffle: truffle: aliased to node /Users/liangliang/code/truffle/packages/truffle/build/cli.bundled.js
db-kit: db-kit not found
Truffle v5.5.32 (core: 5.5.32)
Ganache v7.4.3
Solidity - 0.8.13 (solc-js)
Node v16.16.0
Web3.js v1.7.4
Use the version of truffle installed by npm. Note, all this does is unalias truffle to allow normal PATH environment resolution.
usage: use-truffle-stable
$ use-truffle-stable
$ show-truffle-env
truffle: /Users/liangliang/.nvm/versions/node/v16.16.0/bin/truffle
db-kit: db-kit not found
Truffle v5.5.32 (core: 5.5.32)
Ganache v7.4.3
Solidity - 0.8.13 (solc-js)
Node v16.16.0
Web3.js v1.7.4
Similarly, aliases are created for @truffle/db-kit 3 commands are available
command | description |
---|---|
use-dbkit-core |
use local developed version of db-kit |
use-dbkit-core-debug |
use local version of db-kit with debug inspector enabled |
use-dbkit-stable |
use npm installed version of db-kit |