Skip to content

Commit f4e1cdd

Browse files
authored
ETH-284: update release workflow and README (#203)
* refactor(config): rename config*.ts to index*.ts * build(config): update automatic release workflow * docs(config): update example in README
1 parent 8cb6c71 commit f4e1cdd

12 files changed

+129
-41
lines changed

packages/config/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/build
12
/dist
23
/*.tgz

packages/config/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,22 @@ build: NODE_ENV = "production"
3131
build: ## Run build
3232
$(call npm, run build)
3333

34+
.PHONY: npm-install
35+
npm-install:
36+
$(call npm, install)
37+
38+
.PHONY: npm-publish
39+
npm-publish:
40+
$(call npm, publish . --access public)
41+
42+
.PHONY: npm-pack
43+
npm-pack:
44+
$(call npm, pack)
45+
3446
.PHONY: clean
3547
clean: ## Remove generated files
3648
$(RM) -r \
49+
build \
3750
dist \
3851
node_modules
3952

packages/config/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ npm install --save @streamr/config
1111
```
1212

1313
## Examples
14+
### Typescript
1415
Import DATA token production Ethereum address as a variable in a Typescript project:
1516
```typescript
16-
import * as config from "config"
17+
import * as config from "@streamr/config"
1718

1819
const chains: config.Chains = config.Chains.load("production")
1920
const contractAddress: string = chains.ethereum.contracts["DATA-token"]
2021
const chainId: number = chains.ethereum.id
21-
const httpRpcEndpoints: RPCEndpoint[] = chains.ethereum.getRPCEndpointsByProtocol(RPCProtocol.HTTP)
22-
const wsRpcEndpoints: RPCEndpoint[] = chains.ethereum.getRPCEndpointsByProtocol(RPCProtocol.WEBSOCKET)
22+
const httpRpcEndpoints: RPCEndpoint[] = chains.ethereum.getRPCEndpointsByProtocol(config.RPCProtocol.HTTP)
23+
const wsRpcEndpoints: RPCEndpoint[] = chains.ethereum.getRPCEndpointsByProtocol(config.RPCProtocol.WEBSOCKET)
2324
```
2425

2526
You can also load configuration based on `$NODE_ENV` environment variable:
@@ -29,6 +30,14 @@ import * as config from "config"
2930
const chains: Chains = config.Chains.loadFromNodeEnv()
3031
```
3132

33+
### Javascript
34+
Use in a Javascript project:
35+
```javascript
36+
const config = require("@streamr/config")
37+
const chains: config.Chains = config.Chains.loadFromNodeEnv()
38+
```
39+
40+
### Other Languages
3241
Other languages can read the [JSON file](./src/networks.json) directly.
3342

3443
## Development
@@ -80,12 +89,7 @@ Login to Npmjs.com:
8089
npm login --registry https://registry.npmjs.org --scope @streamr
8190
```
8291

83-
Run build:
84-
```bash
85-
make clean build
86-
```
87-
88-
Create a new release on Npmjs.com, update version in package.json, push a release commit, and tag it on GitHub:
92+
Run clean build, create a new release on Npmjs.com, update version in `package.json`, push a release commit, and tag it on GitHub:
8993
```bash
9094
./release.bash 0.0.1
9195
```

packages/config/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/config/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
"name": "@streamr/config",
33
"version": "0.0.1",
44
"description": "Zero dependency package that contains Streamr Network smart contract addresses",
5-
"main": "dist/index.js",
5+
"main": "dist/src/index.js",
6+
"types": "dist/src/index.d.ts",
67
"directories": {
78
"lib": "./dist",
89
"src": "./src",
910
"test": "./test"
1011
},
1112
"files": [
12-
"dist/src"
13+
"dist"
1314
],
1415
"scripts": {
15-
"build": "npm run prepare",
16-
"prepare": "tsc --project tsconfig.json",
16+
"build": "tsc --project tsconfig.json",
17+
"pretest": "tsc --project tsconfig-test.json",
1718
"test": "mocha --config mocharc.json",
1819
"lint": "eslint --ext .ts src test"
1920
},

packages/config/release-npm-publish.bash

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/config/release-npm-update-version-package-json.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ fi
3030

3131
sed -i '' -e 's/"version": ".*",$/"version": "'"$version"'",/g' package.json
3232
git add package.json
33+
make npm-install
34+
git add package-lock.json

packages/config/release.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ while getopts "h" arg; do
2020
esac
2121
done
2222

23+
make clean
2324
./release-git-validate.bash
2425

2526
version="${1-}"
@@ -29,6 +30,6 @@ if test -z "$version"; then
2930
fi
3031

3132
./release-validate-semver.bash "$version"
32-
3333
./release-git-tag.bash "$version"
34-
./release-npm-publish.bash
34+
make build
35+
make npm-publish
File renamed without changes.

packages/config/test/config.test.ts renamed to packages/config/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it } from "mocha"
22
import { assert } from "chai"
3-
import * as config from "../src/config"
3+
import * as config from "../src"
44

55
describe("Load configuration from JSON file", () => {
66
it("ethereum chain id is 1", () => {

0 commit comments

Comments
 (0)