@@ -7,14 +7,17 @@ Many things are the way they are for good (at the time, at least) reasons,
7
7
but I always welcome criticism, and am completely willing to have my mind
8
8
changed on things.
9
9
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:
11
11
12
12
- Backwards-compatibility-breaking changes will not be accepted; they may be
13
13
considered for the next major version
14
14
- Security is important; adding dependencies require fairly convincing
15
15
arguments as to why
16
16
- The library aims to be lean, so keep an eye on the dist/ethers.min.js
17
17
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
18
21
- Add test cases for both expected and unexpected input
19
22
- Any new features need to be supported by me (future issues, documentation,
20
23
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
27
30
28
31
_subsection: Building @<contributing--building>
29
32
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 .
32
35
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.
37
39
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>
39
46
40
47
# 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
+
42
50
/home/ricmoo> cd ethers.js
43
51
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)
45
58
/home/ricmoo/ethers.js> npm install
46
59
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>
51
61
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 .
55
65
56
66
_code: Watching and Building @lang<shell>
57
67
58
68
# Begin watching the files and re-building whenever they change
59
69
/home/ricmoo/ethers.js> npm run auto-build
60
70
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
61
75
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.
64
80
81
+ _code: Building Distribution Files @lang<shell>
65
82
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
69
86
87
+ _heading: Testing
70
88
71
89
_code: Testing @lang<shell>
72
90
73
- # Rebuilds all files and bundles testcases up for testing
91
+ # Rebuilds all files (npm run build-all) and bundles testcases up for testing
74
92
/home/ricmoo/ethers.js> npm test
75
93
76
94
# 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
78
96
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).
79
111
80
112
_code: Preparing the Distribution @lang<shell>
81
113
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
82
122
/home/ricmoo/ethers.js> npm run update-version
83
123
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
+
84
162
85
163
_subsection: Documentation @<contributing--documentation>
86
164
@@ -95,7 +173,7 @@ Style Guide (this section will have much more coming):
95
173
- Prefix external links with ``link-``
96
174
- Changing an anchor name must be well justified, as it will break all existing links
97
175
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
99
177
100
178
101
179
_heading: Building
0 commit comments