Skip to content

Commit c324a45

Browse files
author
SilentCicero
committed
version 0.1.0 -- docs, config, util
1 parent 3921082 commit c324a45

File tree

8 files changed

+216
-12
lines changed

8 files changed

+216
-12
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ intToHex <Function (Number) : (String)>
7676

7777
Please help better the ecosystem by submitting issues and pull requests to default. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBNB linting standard and the unix philosophy.
7878

79-
<!--
8079
## Guides
8180

82-
You'll find more detailed information on using default and tailoring it to your needs in our guides:
81+
You'll find more detailed information on using `ethjs-util` and tailoring it to your needs in our guides:
8382

8483
- [User guide](docs/user-guide.md) - Usage, configuration, FAQ and complementary tools.
85-
- [Developer guide](docs/developer-guide.md) - Contributing to wafr and writing your own plugins & formatters.
86-
-->
84+
- [Developer guide](docs/developer-guide.md) - Contributing to `ethjs-util` and writing your own code and coverage.
8785

8886
## Help out
8987

dist/ethjs-util.js

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ethjs-util.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Documentation
2+
3+
## Table of Contents
4+
5+
- [General](general)
6+
- [**Developer Guide**](developer-guide.md)
7+
- [**User Guide**](user-guide.md)
8+
9+
## Overview
10+
11+
### Structure
12+
13+
The [`src/`](../../../tree/master/src) directory contains your entire application code, including JavaScript, and tests.
14+
15+
The rest of the folders and files only exist to make your life easier, and
16+
should not need to be touched.
17+
18+
For more in-depth structure, see the developer-guide.md.
19+
20+
*(If they do have to be changed, please [submit an issue](https://github.com/ethjs/ethjs-util/issues)!)*
21+
22+
### Testing
23+
24+
For a thorough explanation of the testing procedure, see the
25+
[testing documentation](./developer-guide/README.md)!
26+
27+
#### Unit testing
28+
29+
Unit tests live in `src/tests/` directories right next to the components being tested
30+
and are run with `npm test`.

docs/developer-guide.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Developer Guide
2+
3+
All information regarding contributing to and progressing `ethjs-util` module can be found in this document.
4+
5+
## Install
6+
7+
```
8+
npm install --save ethjs-util
9+
```
10+
11+
## Install from Source
12+
13+
```
14+
git clone http://github.com/ethjs/ethjs-util
15+
npm install
16+
```
17+
18+
## Test
19+
20+
```
21+
npm test
22+
```
23+
24+
## Build
25+
26+
```
27+
npm run build
28+
```
29+
30+
## Linting
31+
32+
```
33+
npm run lint
34+
```
35+
36+
## Travis-ci and Coveralls Testing
37+
38+
Note, this will generate a `coveralls` report locally.
39+
40+
```
41+
npm run test-travis
42+
```
43+
44+
You can find the coveralls report and view the percentages and stats, by going to the [index.html](coverage/lcov-report/index.html) file generated after running the `test-travis` script. Open this in Chrome to see the generated report. Travis will run mocha as usual, but collect information about the testing coverage. This report will be sent by TravisCI during the automated build process.
45+
46+
## Build Staging
47+
48+
The build staging for this module is as follows:
49+
50+
1. Cleanup
51+
2. Linting
52+
3. Testing
53+
4. Babel processing (output to lib)
54+
5. Webpack (output to dist)
55+
6. Webpack production (output to dist)
56+
7. Retest lib folder for babel processing solidity
57+
8. Report build stats
58+
59+
## Folder Structure
60+
61+
All module source code is found in the `src` directory. All module helper scripts can be found in the `scripts` folder. These will not need to be touched, and are purely configuration for this repository.
62+
63+
```
64+
./ethjs-util
65+
./.github
66+
./dist
67+
./lib
68+
./tests
69+
./internals
70+
./webpack
71+
./coverage
72+
./docs
73+
./src
74+
./tests
75+
```
76+
77+
Note, the `./lib` dir is generated from the babel build staging. `./coverage` is generated from the `npm run test-travis` script. All internals and helper scripts (i.e. `webpack`) are in `./internals`. All distribution builds are in `./dist` (usually a minified and unminified production build of the package).
78+
79+
## NPM Practice
80+
81+
Across all `ethjs-` repos, we enforce version hardening (i.e. "0.0.3" not "^0.0.3"). We want to reduce potential hazardous install changes from dependancies as much as possible to ensure package preformace, testing, security and design. Please make sure all your commits and PR's are version hardend if you are installing or removing new packages.
82+
83+
After build staging it is the `lib` folder which actually gets published to NPM. This allows for easy inclusion into other modules which may not use babel transpiling or which may not support es2015+.
84+
85+
## NPM/Node Version Requirements
86+
87+
`ethjs` requires you have:
88+
- `nodejs` -v 6.5.0+
89+
- `npm` -v 3.0+
90+
91+
This is a requirement to run, test, lint and build this module.
92+
93+
## Changelog
94+
95+
All relevant changes are notated in the `CHANGELOG.md` file, moniter this file for changes to this repository.
96+
97+
## Travis-ci and Coveralls Practice
98+
99+
Across all `ethjs-` repos, we enforce mandatory travis-ci and coveralls testing. We never `commit to master`. As a general policy, Coveralls.io results must always be above 95% for any `ethjs-` PR or commit. We want to ensure complete coverage across the board.
100+
101+
## Contributing
102+
103+
Please help better the ecosystem by submitting issues and pull requests. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBNB linting standard. Please read more about contributing to `ethjs-util` in the `.github/CONTRIBUTING.md`.
104+
105+
## Licence
106+
107+
This project is licensed under the MIT license, Copyright (c) 2016 Nick Dodson. For more information see LICENSE.

docs/user-guide.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# User Guide
2+
3+
All information for developers using `ethjs-util` should consult this document.
4+
5+
## Install
6+
7+
```
8+
npm install --save ethjs-util
9+
```
10+
11+
## Usage
12+
13+
```js
14+
const util = require('ethjs-util');
15+
16+
const value = util.intToBuffer(38272);
17+
18+
// returns <Buffer ...>
19+
```
20+
21+
## Available Methods
22+
23+
```
24+
arrayContainsArray <Function (Array, Array) : (Boolean)>
25+
getBinarySize <Function (String) : (Number)>
26+
toBuffer <Function (String) : (Buffer)>
27+
intToBuffer <Function (Number) : (Buffer)>
28+
isHexPrefixed <Function (String) : (Boolean)>
29+
stripHexPrefix <Function (String) : (String)>
30+
padToEven <Function (String) : (String)>
31+
intToHex <Function (Number) : (String)>
32+
```
33+
34+
## Browser Builds
35+
36+
`ethjs` provides production distributions for all of its modules that are ready for use in the browser right away. Simply include either `dist/ethjs-util.js` or `dist/ethjs-util.min.js` directly into an HTML file to start using this module. Note, an `ethUtil` object is made available globally.
37+
38+
```html
39+
<script type="text/javascript" src="ethjs-util.min.js"></script>
40+
<script type="text/javascript">
41+
ethUtil(...);
42+
</script>
43+
```
44+
45+
Note, even though `ethjs` should have transformed and polyfilled most of the requirements to run this module across most modern browsers. You may want to look at an additional polyfill for extra support.
46+
47+
Use a polyfill service such as `Polyfill.io` to ensure complete cross-browser support:
48+
https://polyfill.io/
49+
50+
## Other Awesome Modules, Tools and Frameworks
51+
52+
- [web3.js](https://github.com/ethereum/web3.js) -- the original Ethereum swiss army knife **Ethereum Foundation**
53+
- [ethereumjs](https://github.com/ethereumjs) -- critical ethereumjs infrastructure **Ethereum Foundation**
54+
- [browser-solidity](https://ethereum.github.io/browser-solidity) -- an in browser Solidity IDE **Ethereum Foundation**
55+
- [wafr](https://github.com/silentcicero/wafr) -- a super simple Solidity testing framework
56+
- [truffle](https://github.com/ConsenSys/truffle) -- a solidity/js dApp framework
57+
- [embark](https://github.com/iurimatias/embark-framework) -- a solidity/js dApp framework
58+
- [dapple](https://github.com/nexusdev/dapple) -- a solidity dApp framework
59+
- [chaitherium](https://github.com/SafeMarket/chaithereum) -- a JS web3 unit testing framework
60+
- [contest](https://github.com/DigixGlobal/contest) -- a JS testing framework for contracts
61+
62+
## Our Relationship with Ethereum & EthereumJS
63+
64+
We would like to mention that we are not in any way affiliated with the Ethereum Foundation or `ethereumjs`. However, we love the work they do and work with them often to make Ethereum great! Our aim is to support the Ethereum ecosystem with a policy of diversity, modularity, simplicity, transparency, clarity, optimization and extensibility.
65+
66+
Many of our modules use code from `web3.js` and the `ethereumjs-` repositories. We thank the authors where we can in the relevant repositories. We use their code carefully, and make sure all test coverage is ported over and where possible, expanded on.

internals/webpack/webpack.config.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var webpack = require('webpack'); // eslint-disable-line
22

33
var env = process.env.NODE_ENV; // eslint-disable-line
4+
var filename = 'ethjs-util'; // eslint-disable-line
5+
var library = 'ethUtil'; // eslint-disable-line
46
var config = { // eslint-disable-line
57
module: {
68
loaders: [
@@ -17,13 +19,14 @@ var config = { // eslint-disable-line
1719
},
1820
devtool: 'cheap-module-source-map',
1921
output: {
20-
library: 'ethUtil',
22+
path: 'dist',
23+
filename: filename + '.js', // eslint-disable-line
24+
library: library, // eslint-disable-line
2125
libraryTarget: 'umd',
2226
umdNamedDefine: true,
2327
},
2428
plugins: [
2529
new webpack.BannerPlugin({ banner: ' /* eslint-disable */ ', raw: true, entryOnly: true }),
26-
new webpack.BannerPlugin({ banner: ' /* eslint-disable */ ', raw: true }),
2730
new webpack.optimize.OccurrenceOrderPlugin(),
2831
new webpack.DefinePlugin({
2932
'process.env.NODE_ENV': JSON.stringify(env),
@@ -32,6 +35,7 @@ var config = { // eslint-disable-line
3235
};
3336

3437
if (env === 'production') {
38+
config.output.filename = filename + '.min.js'; // eslint-disable-line
3539
config.plugins
3640
.push(new webpack.optimize.UglifyJsPlugin({
3741
compressor: {

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ethjs-util",
3-
"version": "0.0.5",
3+
"version": "0.1.0",
44
"description": "A simple set of Ethereum JS utilties.",
55
"main": "./lib/index.js",
66
"scripts": {
@@ -11,8 +11,8 @@
1111
"prebuild": "npm run build:clean && npm run test",
1212
"build:clean": "npm run test:clean && rimraf ./dist",
1313
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib --copy-files",
14-
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack --config ./internals/webpack/webpack.config.js ./lib/index.js ./dist/ethjs-util.js",
15-
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack --config ./internals/webpack/webpack.config.js ./lib/index.js ./dist/ethjs-util.min.js",
14+
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack --config ./internals/webpack/webpack.config.js ./lib/index.js --progress",
15+
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack --config ./internals/webpack/webpack.config.js ./lib/index.js --progress",
1616
"build": "npm run build:commonjs && npm run test:lib && npm run build:umd && npm run build:umd:min",
1717
"lint": "npm run lint:js",
1818
"lint:eslint": "eslint --ignore-path .gitignore --ignore-pattern **/**.min.js",
@@ -116,8 +116,8 @@
116116
"bignumber.js": "3.0.1",
117117
"bn.js": "4.11.6",
118118
"chai": "3.5.0",
119-
"coveralls": "2.11.9",
120119
"eslint": "2.10.1",
120+
"coveralls": "2.11.9",
121121
"eslint-config-airbnb": "9.0.1",
122122
"eslint-import-resolver-webpack": "0.2.4",
123123
"eslint-plugin-import": "1.8.0",

0 commit comments

Comments
 (0)