Skip to content

Commit f4b97c0

Browse files
committed
docs: added more on contributing (ethers-io#1153).
1 parent 38eccc8 commit f4b97c0

File tree

1 file changed

+103
-25
lines changed

1 file changed

+103
-25
lines changed

docs.wrm/contributing.wrm

Lines changed: 103 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ Many things are the way they are for good (at the time, at least) reasons,
77
but I always welcome criticism, and am completely willing to have my mind
88
changed on things.
99

10-
So, pull requests are always welcome, but please keep a few points in mind:
10+
Pull requests are always welcome, but please keep a few points in mind:
1111

1212
- Backwards-compatibility-breaking changes will not be accepted; they may be
1313
considered for the next major version
1414
- Security is important; adding dependencies require fairly convincing
1515
arguments as to why
1616
- The library aims to be lean, so keep an eye on the dist/ethers.min.js
1717
file size before and after your changes
18+
- Keep the PR simple and readable; only modify files in the ``docs.wrm/``
19+
and ``packages/*/src.ts/`` folders, as this allows the changes to be easily
20+
verified
1821
- Add test cases for both expected and unexpected input
1922
- Any new features need to be supported by me (future issues, documentation,
2023
testing, migration), so anything that is overly complicated or specific
@@ -27,60 +30,135 @@ have a public discussion and figure out the best way to address the problem/feat
2730

2831
_subsection: Building @<contributing--building>
2932

30-
If you wish to modify the source code, there are a few steps involved in
31-
setting up your environment.
33+
The build process for ethers is unfortunatly not super trivial, but
34+
I have attempted to make it as straight-forward as possible.
3235

33-
Since the library uses a monorepo, you must install an initial required
34-
set of libraries, which can then be used to install the remaining libraries
35-
used within each package, as well as link all the packages within the repo
36-
with each other.
36+
It is a mono-repo which attempts to be compatibile with a large
37+
number of environments, build tools and platforms, which is why
38+
there are a some weird things it must do.
3739

38-
_code: Preparing for builds @lang<shell>
40+
There are several custom scripts in the ``misc/admin`` folder
41+
to help manage the monorepo. Developers working on contributing
42+
to ethers should not generally need to worry about those, since
43+
they are wrapped up behind ``npm run SCRIPT`` operations.
44+
45+
_code: Installing @lang<shell>
3946

4047
# Clone the repository
41-
/home/ricmoo> git clone git@github.com:ethers-io/ethers.js.git
48+
/home/ricmoo> git clone https://github.com/ethers-io/ethers.js.git
49+
4250
/home/ricmoo> cd ethers.js
4351

44-
# Install the base dependencies
52+
# Install all dependencies:
53+
# - Hoists all sub-package dependencies in the package.json (preinstall)
54+
# - Installs all the (hoisted) dependencies and devDependencies (install)
55+
# - Build the rat-nests (in .package_node_modules) (postinstall)
56+
# - Create a dependency graph for the TypeScript (postinstall)
57+
# - Link the rat-nets into each project (postinstall)
4558
/home/ricmoo/ethers.js> npm install
4659

47-
# Install each module's dependencies and link the libraries
48-
# internally, so they reference each other
49-
/home/ricmoo/ethers.js> npm run bootstrap
50-
60+
_heading: Making Changes @<contributing--updating>
5161

52-
_subsection: Making your changes @<contributing--updating>
53-
54-
TODO: Add more information here.
62+
Once your environment is set up, you should be able to simply
63+
start the ``auto-build`` feature, and make changes to the
64+
TypeScript source.
5565

5666
_code: Watching and Building @lang<shell>
5767

5868
# Begin watching the files and re-building whenever they change
5969
/home/ricmoo/ethers.js> npm run auto-build
6070

71+
# Or if you do not want to watch and just build
72+
/home/ricmoo/ethers.js> npm run build
73+
74+
_heading: Creating Browser-Ready Files
6175

62-
# Sometimes the issue only affects the ESM modules
63-
/home/ricmoo/ethers.js> npm run auto-build-esm
76+
To create files for use directly in a browser, the distribution
77+
files (located in ``packages/ethers/dist``) need to be built
78+
which requires several intermediate builds, scripts and for
79+
various rollup scripts to execute.
6480

81+
_code: Building Distribution Files @lang<shell>
6582

66-
# Or if you only need to run a single build
67-
/home/ricmoo/ethers.js> npm run _build-cjs
68-
/home/ricmoo/ethers.js> npm run _build-esm
83+
# If you need to rebuild all the libs (esm + cjs) and dist files
84+
# Note: this requires node 10 or newer
85+
/home/ricmoo/ethers.js> npm run build-all
6986

87+
_heading: Testing
7088

7189
_code: Testing @lang<shell>
7290

73-
# Rebuilds all files and bundles testcases up for testing
91+
# Rebuilds all files (npm run build-all) and bundles testcases up for testing
7492
/home/ricmoo/ethers.js> npm test
7593

7694
# Often you don't need the full CI experience
77-
/home/ricmoo/ethers.js> npm run _test-node
95+
/home/ricmoo/ethers.js> npm run test-node
7896

97+
_heading: Distribution
98+
99+
Most developers should not ever require this step, but for people
100+
forking ethers and creating alternates (for example if you have
101+
a non-EVM compatible chain but are trying to reuse this package).
102+
103+
This script will rebuild the entire ethers project, compare it
104+
against npm, re-write package versions, update internal hashes,
105+
re-write various TypeScript files (to get around some ES+TS
106+
limitations for Tree Shaking and linking), re-write map files,
107+
bundle stripped versions of dependencies and basically just a
108+
whole bunch of stuff.
109+
110+
If you use this and get stuck, [message me](link-mail).
79111

80112
_code: Preparing the Distribution @lang<shell>
81113

114+
# Prepare all the distribution files
115+
# - Remove all generated files (i.e. npm run clean)
116+
# - Re-install all dependencies, hoisting, etc. (npm install)
117+
# - Spell check all strings in every TypeScript files
118+
# - Build everything from scratch with this clean install
119+
# - Compare local with npm, bumping the version if changed
120+
# - Build everything again (with the updated versions)
121+
# - Update the CHANGELOG.md with the git history since the last change
82122
/home/ricmoo/ethers.js> npm run update-version
83123

124+
_note: Do NOT check in dist files in a PR
125+
126+
For Pull Requests, please ONLY commit files in the ``docs.wrm/`` and
127+
``packages/*/src.ts/`` folders. I will prepare the distribution builds
128+
myself and keeping the PR relevant makes it easier to verify the changes.
129+
130+
_heading: Publishing
131+
132+
Again, this should not be necessary for most developers. This step
133+
requires using the ``misc/admin/cmds/config-set`` script for a number
134+
of values, including private keys, NPM session keys, AWS access keys,
135+
GitHub API tokens, etc.
136+
137+
The config file is encrypted with about 30 seconds of scrypt password-based
138+
key derivation function, so brute-forcing the file is quite expensive.
139+
140+
The config file also contains a plain-text mnemonic. This is a money-pot.
141+
Place a tempting amount of ether or Bitcoin on this account and set up an
142+
e-mail alert for this account.
143+
144+
If any attacker happens across your encrypted config, they will have instant
145+
access to the plain-text mnemonic, so they have the option to immediately
146+
steal the ether (i.e. the responsible-disclosure bond).
147+
148+
If you ever see this ether taken, your encrypted file is compromised! Rotate
149+
all your AWS keys, NPM session keys, etc. immedately.
150+
151+
@TODO: document all the keys that need to be set for each step
152+
153+
_code: Preparing the Distribution @lang<shell>
154+
155+
# Publish
156+
# - Update any changed packages to NPM
157+
# - Create a release on GitHub with the latest CHANGELOG.md description
158+
# - Upload the bundled files the the CDN
159+
# - Flush the CDN edge caches
160+
/home/ricmoo/ethers.js> npm run publish-all
161+
84162

85163
_subsection: Documentation @<contributing--documentation>
86164

@@ -95,7 +173,7 @@ Style Guide (this section will have much more coming):
95173
- Prefix external links with ``link-``
96174
- Changing an anchor name must be well justified, as it will break all existing links
97175
to that section; flatworm will support symlinks in the future
98-
- In general, I aim for xonsistency; look to similar situations throughout the documentation
176+
- In general, I aim for consistency; look to similar situations throughout the documentation
99177

100178

101179
_heading: Building

0 commit comments

Comments
 (0)