Skip to content

Commit

Permalink
Use TypeScript project reference (#1002)
Browse files Browse the repository at this point in the history
* Add *.tsbuildinfo to .gitignore

* Bump versions of dependencies, nyc and yargs

* Drop support for node 9 (EOL 2018-06-30)

https://github.com/nodejs/Release

* Add getTransaction snippet
  • Loading branch information
intelliot committed Apr 15, 2019
1 parent 4da8002 commit 0d5103a
Show file tree
Hide file tree
Showing 10 changed files with 1,126 additions and 1,630 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ npm-debug.log
# Ignore dist folder, built from tsc
dist/

# TypeScript incremental compilation cache
*.tsbuildinfo

# Ignore perf test cache
scripts/cache

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ language: node_js
node_js:
- 6
- 8
- 9
- 10
- 11
script:
- yarn compile
- yarn test
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,29 @@
"jayson": "^1.2.2",
"json-loader": "^0.5.2",
"json-schema-to-markdown-table": "^0.4.0",
"mocha": "6.0.2",
"mocha": "6.1.3",
"mocha-junit-reporter": "^1.9.1",
"null-loader": "^0.1.1",
"nyc": "^11.3.0",
"source-map-support": "^0.5.0",
"nyc": "13.3.0",
"source-map-support": "0.5.12",
"ts-loader": "^3.2.0",
"ts-node": "^3.3.0",
"ts-node": "8.0.3",
"tslint": "^5.8.0",
"tslint-eslint-rules": "^4.1.1",
"typescript": "3.4.2",
"uglifyjs-webpack-plugin": "^1.1.4",
"webpack": "3.12.0",
"yargs": "^8.0.2"
"yargs": "13.2.2"
},
"scripts": {
"build": "gulp",
"doctoc": "doctoc docs/index.md --title '# RippleAPI Reference' --github --maxlevel 2",
"docgen": "node --harmony scripts/build_docs.js",
"clean": "rm -rf dist/npm",
"compile": "mkdir -p dist/npm/common && cp -r src/common/schemas dist/npm/common/ && tsc",
"compile": "mkdir -p dist/npm/common && cp -r src/common/schemas dist/npm/common/ && tsc --build",
"watch": "tsc -w",
"prepublish": "npm run clean && npm run compile && npm run build",
"test": "nyc mocha --exit",
"test": "TS_NODE_PROJECT=src/tsconfig.json nyc mocha --exit",
"lint": "tslint -p ./",
"perf": "./scripts/perf_test.sh",
"start": "node scripts/http.js",
Expand Down
17 changes: 17 additions & 0 deletions snippets/src/getTransaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {RippleAPI} from '../../dist/npm'

const api = new RippleAPI({
server: 'wss://s.altnet.rippletest.net:51233'
})

getTransaction()

async function getTransaction() {
await api.connect()
const ledger = await api.getLedger({includeTransactions: true})
console.log(ledger)
const tx = await api.getTransaction(ledger.transactionHashes[0])
console.log(tx)
console.log('deliveredAmount:', tx.outcome.deliveredAmount)
process.exit(0)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const RippleAPI = require('../dist/npm').RippleAPI
import {RippleAPI} from '../../dist/npm'

const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'})

parseAccountFlags()
Expand All @@ -8,4 +9,5 @@ async function parseAccountFlags() {
const account_info = await api.request('account_info', {account: 'rKsdkGhyZH6b2Zzd5hNnEqSv2wpznn4n6N'})
const flags = api.parseAccountFlags(account_info.account_data.Flags)
console.log(JSON.stringify(flags, null, 2))
process.exit(0)
}
13 changes: 13 additions & 0 deletions snippets/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"references": [
{ "path": "../src" }
],
"include": [
"./src/**/*.ts"
]
}
11 changes: 11 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
"outDir": "../dist/npm",
"rootDir": ".",
"composite": true
},
"include": [
"**/*.ts"
]
}
26 changes: 26 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"pretty": true,
"lib": [
"es2017"
],
"target": "es6",

"declaration": true,
"declarationMap": true /* Added 2019-04-13 */,
"sourceMap": true,
"noEmitOnError": true /* Added 2019-04-13 */,

"strictNullChecks": false,
"noImplicitAny": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"strict": true /* Enable all strict type-checking options. */,
"preserveConstEnums": false,

"module": "commonjs",
"moduleResolution": "node",
"suppressImplicitAnyIndexErrors": false
}
}
29 changes: 6 additions & 23 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
{
"compilerOptions": {
"target": "es6",
"lib": [
"es2017"
],
"outDir": "dist/npm",
"rootDir": "src",
"module": "commonjs",
"moduleResolution": "node",
"strictNullChecks": false,
"noImplicitAny": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"strict": true /* Enable all strict type-checking options. */,
"preserveConstEnums": false,
"suppressImplicitAnyIndexErrors": false,
"declaration": true,
"sourceMap": true
},
"include": [
"src/**/*.ts"
"files": [],
"include": [],
"references": [
{ "path": "./src" },
{ "path": "./snippets" }
]
}
}
Loading

0 comments on commit 0d5103a

Please sign in to comment.