Skip to content

Commit c12b0e4

Browse files
Merge pull request #11 from synaphea/master
Propose mirgration of codebase from JS to TS
2 parents b8a8044 + ac8a5b1 commit c12b0e4

22 files changed

+5809
-330
lines changed

.all-contributorsrc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"projectName": "iroha-javascript",
3+
"projectOwner": "GUCCI-swallow",
4+
"files": [
5+
"README.md"
6+
],
7+
"imageSize": 100,
8+
"commit": true,
9+
"contributors": [
10+
{
11+
"login": "takemiyamakoto",
12+
"name": "",
13+
"avatar_url": "https://avatars3.githubusercontent.com/u/20982317?v=3&s=460",
14+
"profile": "https://github.com/takemiyamakoto",
15+
"contributions": [
16+
"code"
17+
]
18+
},
19+
{
20+
"login": "luca3104",
21+
"name": "Satoshi Kaji",
22+
"avatar_url": "https://avatars0.githubusercontent.com/u/12592891?v=3&s=460",
23+
"profile": "https://github.com/luca3104",
24+
"contributions": [
25+
"doc"
26+
]
27+
},
28+
{
29+
"login": "6londe",
30+
"name": "6londe",
31+
"avatar_url": "https://avatars0.githubusercontent.com/u/11345397?v=3&s=460",
32+
"profile": "https://github.com/6londe",
33+
"contributions": [
34+
"doc"
35+
]
36+
},
37+
{
38+
"login": "theofilis",
39+
"name": "George Theofilis",
40+
"avatar_url": "https://avatars3.githubusercontent.com/u/475517?v=3&s=460",
41+
"profile": "https://github.com/theofilis",
42+
"contributions": [
43+
"code", "test", "tool"
44+
]
45+
}
46+
]
47+
}

.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"targets": {
5+
"browsers": ["last 2 versions", "safari >= 7"],
6+
"node": true
7+
},
8+
"modules": false
9+
}]
10+
]
11+
}

.circleci/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
working_directory: ~/iroha-javascript
6+
docker:
7+
- image: node:7.7
8+
steps:
9+
- checkout
10+
- restore_cache:
11+
key: irohajs-{{ .Branch }}-{{ checksum "package.json" }}
12+
- run:
13+
name: Pre-Dependencies
14+
command: mkdir ~/iroha-javascript/artifacts
15+
- run:
16+
name: Install Dependencies
17+
command: npm prune && npm cache clean && npm install
18+
- run:
19+
name: Test & Build
20+
command: npm run test:prod && npm run build
21+
- store_artifacts:
22+
path: ~/iroha-javascript/dist
23+
destination: iroha
24+
- save_cache:
25+
key: irohajs-{{ .Branch }}-{{ checksum "package.json" }}
26+
paths:
27+
- "~/iroha-javascript/node_modules"

.gitignore

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,9 @@
1-
# Created by https://www.gitignore.io/api/node
2-
3-
### Node ###
4-
# Logs
5-
logs
6-
*.log
7-
npm-debug.log*
8-
9-
# Runtime data
10-
pids
11-
*.pid
12-
*.seed
13-
*.pid.lock
14-
15-
# Directory for instrumented libs generated by jscoverage/JSCover
16-
lib-cov
17-
18-
# Coverage directory used by tools like istanbul
1+
node_modules
192
coverage
20-
21-
# nyc test coverage
223
.nyc_output
23-
24-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
25-
.grunt
26-
27-
# node-waf configuration
28-
.lock-wscript
29-
30-
# Compiled binary addons (http://nodejs.org/api/addons.html)
31-
build/Release
32-
33-
# Dependency directories
34-
node_modules
35-
jspm_packages
36-
37-
# Optional npm cache directory
38-
.npm
39-
40-
# Optional eslint cache
41-
.eslintcache
42-
43-
# Optional REPL history
44-
.node_repl_history
45-
46-
dist
4+
.DS_Store
5+
*.log
6+
.vscode
7+
.idea
8+
/dist/
9+
.awcache

README.md

Lines changed: 117 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
```html
2323
<script src="/path/to/iroha.js"></script>
2424
```
25-
or
26-
```js
27-
import Iroha from 'iroha.js'
28-
var Iroha = require('iroha.js')
29-
```
3025

3126
### API
3227
#### iroha.createKeyPair
@@ -35,6 +30,8 @@ var Iroha = require('iroha.js')
3530
var keys = iroha.createKeyPair();
3631
```
3732

33+
34+
3835
Return key object.
3936
**Response**:
4037

@@ -44,23 +41,19 @@ Return key object.
4441
privateKey: A 64 byte private key encoded base64
4542
}
4643
```
47-
#### iroha.sign
44+
#### iroha.createSignature
4845

4946
```js
50-
var signature = iroha.sign({
51-
publicKey: A 32 byte public key encoded base64,
52-
privateKey: A 64 byte private key encoded base64,
53-
message: A message
54-
});
47+
var keys = iroha.createSignature();
5548
```
5649

5750

5851

59-
Return signature object.
60-
**signature**:
52+
Return key object.
53+
**keys**:
6154

6255
```js
63-
//signature
56+
//keys
6457
{
6558
publicKey: A 32 byte public key encoded base64,
6659
privateKey: A 64 byte private key encoded base64,
@@ -74,19 +67,121 @@ signature(A signature string encoded base64)
7467
#### iroha.verify
7568

7669
```js
77-
var keys = iroha.verify({
78-
publicKey: A 32 byte public key encoded base64,
79-
signature: A signature,
80-
message: A message
81-
});
70+
var keys = iroha.verify();
8271
```
8372

73+
74+
Return key object.
75+
**keys**:
76+
77+
```js
78+
//keys
79+
{
80+
publicKey: A 32 byte public key encoded base64,
81+
signature: A signature,
82+
message: A message
83+
}
84+
```
8485
**Response**:
8586

8687
Return True or False;
8788

88-
## Author
89-
[GUCCI-swallow](https://github.com/GUCCI-swallow)
89+
### Development Guide
90+
91+
#### Features
92+
93+
- Zero-setup. After running `npm install` things will be setup for you :wink:
94+
- **[Webpack 2](https://webpack.js.org/)** for UMD bundle, with [Tree-shaking](https://webpack.js.org/guides/tree-shaking/) dead code elimination
95+
- Tests, coverage and interactive watch mode using **[Jest](http://facebook.github.io/jest/)**
96+
- **[TSLint](https://palantir.github.io/tslint/)** ([standard-config](https://github.com/blakeembrey/tslint-config-standard)) for your code styling
97+
- **Docs automatic generation and deployment** to `gh-pages`, using **[TypeDoc](http://typedoc.org/)**
98+
- Automatic types `(*.d.ts)` file generation
99+
- **[Travis](https://travis-ci.org)** integration and **[Coveralls](https://coveralls.io/)** report
100+
- (Optional) **Automatic releases and changelog**, using [Semantic release](https://github.com/semantic-release/semantic-release), [Commitizen](https://github.com/commitizen/cz-cli), [Conventional changelog](https://github.com/conventional-changelog/conventional-changelog) and [Husky](https://github.com/typicode/husky) (for the git hooks)
101+
102+
#### NPM scripts
103+
104+
- `npm t`: Run test suite
105+
- `npm run test:watch`: Run test suite in [interactive watch mode](http://facebook.github.io/jest/docs/cli.html#watch)
106+
- `npm run test:prod`: Run linting + generate coverage
107+
- `npm run build`: Bundles code, create docs and generate typings
108+
- `npm run build:dev`: Same than `build`, but code is not minified
109+
- `npm run commit`: Commit using conventional commit style ([husky](https://github.com/typicode/husky) will tell you to use it if you haven't :wink:)
110+
111+
#### Automatic releases
112+
113+
If you'd like to have automatic releases with Semantic Versioning, follow these simple steps.
114+
115+
_**Prerequisites**: you need to create/login accounts and add your project to:_
116+
- npm
117+
- Travis
118+
- Coveralls
119+
120+
Set up the git hooks (see [Git hooks section](#git-hooks) for more info):
121+
122+
```bash
123+
node tools/init-hooks
124+
```
125+
126+
Install semantic release and run it (answer NO to "Generate travis.yml").
127+
128+
```bash
129+
npm install -g semantic-release-cli
130+
semantic-release setup
131+
# IMPORTANT!! Answer NO to "Generate travis.yml" question. Is already prepared for you :P
132+
```
133+
134+
From now on, you'll need to use `npm run commit`, which is a convenient way to create conventional commits.
135+
136+
Automatic releases are possible thanks to [semantic release](https://github.com/semantic-release/semantic-release), which publishes your code automatically on github and npm, plus generates automatically a changelog. This setup is highly influenced by [Kent C. Dodds course on egghead.io](https://egghead.io/courses/how-to-write-an-open-source-javascript-library)
137+
138+
#### Git Hooks
139+
140+
By default, there are 2 disabled git hooks. You can enable them by running `node tools/init-hooks` (which uses [husky](https://github.com/typicode/husky)). They make sure:
141+
- You follow a [conventional commit message](https://github.com/conventional-changelog/conventional-changelog)
142+
- Your build is not gonna fail in [Travis](https://travis-ci.org) (or your CI server), since it's runned locally before `git push`
143+
144+
This makes more sense in combination of [automatic releases](#automatic-releases)
145+
146+
#### FAQ
147+
148+
##### Why using TypeScript and Babel?
149+
150+
In most cases, you can compile TypeScript code to ES5, or even ES3. But in some cases, where you use "functional es2015+ features", such as `Array.prototype.find`, `Map`, `Set`... then you need to set `target` to "es6". This is by design, since TypeScript only provides down-emits on syntactical language features (such as `const`, `class`...), but Babel does. So it's set up in a 2 steps build so you can use es2015+ features.
151+
152+
This should be transparent for you and you shouldn't even notice. But if don't need this, you can remove Babel from the build:
153+
- Set target to "es5" or "es3" in `tsconfig.json`
154+
- Remove `"useBabel": true` from `tsconfig.json`
155+
156+
More info in [https://github.com/Microsoft/TypeScript/issues/6945](https://github.com/Microsoft/TypeScript/issues/6945)
157+
158+
##### What if I don't want git-hooks, automatic releases or semantic-release?
159+
160+
Then you may want to:
161+
- Remove `commitmsg`, `postinstall` scripts from `package.json`. That will not use those git hooks to make sure you make a conventional commit
162+
- Remove `npm run semantic-release` from `.travis.yml`
163+
164+
##### What if I don't want to use coveralls or report my coverage?
165+
166+
Remove `npm run report-coverage` from `.travis.yml`
167+
168+
##### What is `npm install` doing the first time runned?
169+
170+
It runs the script `tools/init` which sets up everything for you. In short, it:
171+
- Configures webpack for the build, which creates the umd library, generate docs, etc.
172+
- Configures `package.json` (typings file, main file, etc)
173+
- Renames main src and test files
174+
175+
## Credits
176+
177+
Made with :heart: by [GUCCI-swallow](https://github.com/GUCCI-swallow) and all these wonderful contributors ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
178+
179+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
180+
| [<img src="https://avatars3.githubusercontent.com/u/20982317?v=3&s=460" width="100px;"/><br /><sub>誠</sub>](https://github.com/takemiyamakoto)<br />[💻](https://github.com/GUCCI-swallow/iroha-javascript/commits?author=takemiyamakoto) | [<img src="https://avatars0.githubusercontent.com/u/12592891?v=3&s=460" width="100px;"/><br /><sub>Satoshi Kaji</sub>](https://github.com/luca3104)<br />[📖](https://github.com/GUCCI-swallow/iroha-javascript/commits?author=luca3104) | [<img src="https://avatars0.githubusercontent.com/u/11345397?v=3&s=460" width="100px;"/><br /><sub>6londe</sub>](https://github.com/6londe)<br />[📖](https://github.com/GUCCI-swallow/iroha-javascript/commits?author=6londe) | [<img src="https://avatars3.githubusercontent.com/u/475517?v=3&s=460" width="100px;"/><br /><sub>George Theofilis</sub>](https://github.com/theofilis)<br />[💻](https://github.com/GUCCI-swallow/iroha-javascript/commits?author=theofilis) [⚠️](https://github.com/GUCCI-swallow/iroha-javascript/commits?author=theofilis) 🔧 |
181+
| :---: | :---: | :---: | :---: |
182+
<!-- ALL-CONTRIBUTORS-LIST:END -->
183+
184+
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
90185

91186
## License
92187

@@ -102,4 +197,4 @@ Unless required by applicable law or agreed to in writing, software
102197
distributed under the License is distributed on an "AS IS" BASIS,
103198
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104199
See the License for the specific language governing permissions and
105-
limitations under the License.
200+
limitations under the License.

gulpfile.js

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

0 commit comments

Comments
 (0)