Use @polkadot/dev for common tasks (#6)
* Use @polkadot/dev for common tasks * Use scripts from @polkadot/dev * js code hints * Cleanup scripts
This commit is contained in:
@@ -1,12 +1,3 @@
|
||||
{
|
||||
"presets": [
|
||||
"env",
|
||||
"stage-0"
|
||||
],
|
||||
"plugins": [
|
||||
"transform-flow-strip-types",
|
||||
"transform-class-properties",
|
||||
"transform-object-rest-spread",
|
||||
"transform-runtime"
|
||||
]
|
||||
"extends": "@polkadot/dev/.babelrc"
|
||||
}
|
||||
|
||||
+2
-32
@@ -1,35 +1,5 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"mocha": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"semistandard",
|
||||
"plugin:flowtype/recommended"
|
||||
],
|
||||
"globals": {
|
||||
"expect": true
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"plugins": [
|
||||
"flowtype"
|
||||
],
|
||||
"rules": {
|
||||
"curly": ["error", "all"],
|
||||
"newline-after-var": ["error", "always"],
|
||||
"no-alert": "error",
|
||||
"no-debugger": "error",
|
||||
"no-duplicate-imports": ["error", {
|
||||
"includeExports": true
|
||||
}],
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"object-property-newline": 0,
|
||||
"one-var-declaration-per-line": ["error", "always"],
|
||||
"padded-blocks": ["error", {
|
||||
"blocks": "never",
|
||||
"classes": "never",
|
||||
"switches": "never"
|
||||
}]
|
||||
}
|
||||
"./node_modules/@polkadot/dev/.eslintrc.json"
|
||||
]
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
build/
|
||||
coverage/
|
||||
lib/
|
||||
node_modules/
|
||||
tmp/
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "8"
|
||||
script: ./scripts/travis.sh
|
||||
script: ./node_modules/.bin/polkadot-dev-build-travis build check coveralls npm test
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
ISC License (ISC)
|
||||
Copyright 2017 Jaco Greeff
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
Copyright 2017 Jaco Greeff <jacogr@gmail.com>
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
@@ -19,7 +19,7 @@ npm install --save @polkadot/api
|
||||
|
||||
Initialisation -
|
||||
|
||||
```
|
||||
```js
|
||||
import Api from '@polkadot/api';
|
||||
import HttpProvider from '@polkadot/api-provider/http';
|
||||
|
||||
@@ -29,7 +29,7 @@ const api = new Api(provider);
|
||||
|
||||
Making calls -
|
||||
|
||||
```
|
||||
```js
|
||||
api.chain
|
||||
.getHeader('0x1234567890')
|
||||
.then((header) => console.log(header))
|
||||
@@ -38,4 +38,4 @@ api.chain
|
||||
|
||||
## Available methods
|
||||
|
||||
For a list of currently exposed methods, see the [@polkadot/jsonrpc](https://github.com/polkadot-js/jsonrpc) repository.
|
||||
For a list of currently exposed methods, see the [@polkadot/jsonrpc](https://github.com/polkadot-js/jsonrpc#readme) repository.
|
||||
|
||||
Generated
+2253
-105
File diff suppressed because it is too large
Load Diff
+7
-39
@@ -25,50 +25,18 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api#readme",
|
||||
"scripts": {
|
||||
"build": "npm run build:js",
|
||||
"build:js": "rimraf lib && babel src --out-dir lib --ignore *.spec.js,types.js",
|
||||
"check": "npm run check:flow && npm run check:lint",
|
||||
"check:flow": "flow check",
|
||||
"check:lint": "eslint src",
|
||||
"ci:makeshift": "makeshift",
|
||||
"ci:coveralls": "coveralls < coverage/lcov.info",
|
||||
"build": "rimraf build && babel src --out-dir build --ignore *.spec.js",
|
||||
"check": "eslint src && flow check",
|
||||
"test": "cross-env NODE_ENV=test babel-istanbul cover _mocha 'src/*.spec.js' 'src/**/*.spec.js'"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-provider": "~0.1.0",
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-eslint": "^8.0.2",
|
||||
"babel-istanbul": "^0.12.2",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-flow": "^6.23.0",
|
||||
"babel-preset-stage-0": "^6.24.1",
|
||||
"chai": "^4.1.2",
|
||||
"coveralls": "^3.0.0",
|
||||
"cross-env": "^5.1.1",
|
||||
"eslint": "^4.11.0",
|
||||
"eslint-config-semistandard": "^11.0.0",
|
||||
"eslint-config-standard": "^10.2.1",
|
||||
"eslint-plugin-flowtype": "^2.39.1",
|
||||
"eslint-plugin-import": "^2.8.0",
|
||||
"eslint-plugin-node": "^5.2.1",
|
||||
"eslint-plugin-promise": "^3.6.0",
|
||||
"eslint-plugin-standard": "^3.0.1",
|
||||
"flow-bin": "^0.59.0",
|
||||
"makeshift": "^1.1.0",
|
||||
"mocha": "^4.0.1",
|
||||
"rimraf": "^2.6.2",
|
||||
"sinon": "^4.1.2",
|
||||
"sinon-chai": "^2.14.0"
|
||||
"@polkadot/dev": "^0.1.7",
|
||||
"@polkadot/api-provider": "^0.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api-format": "~0.3.0",
|
||||
"@polkadot/jsonrpc": "~0.3.0",
|
||||
"@polkadot/util": "~0.3.0",
|
||||
"@polkadot/api-format": "~0.3.4",
|
||||
"@polkadot/jsonrpc": "~0.3.5",
|
||||
"@polkadot/util": "~0.5.2",
|
||||
"babel-runtime": "^6.26.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
# ISC, Copyright 2017 Jaco Greeff
|
||||
|
||||
set -e
|
||||
|
||||
function setupGit () {
|
||||
REPO=$1
|
||||
|
||||
echo "Setting up GitHub config for $REPO"
|
||||
|
||||
git config push.default simple
|
||||
git config merge.ours.driver true
|
||||
git config user.name "Travis CI"
|
||||
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
||||
git remote set-url origin https://${GH_TOKEN}@github.com/${REPO}.git > /dev/null 2>&1
|
||||
}
|
||||
|
||||
echo "Running code checks & build"
|
||||
|
||||
npm run check
|
||||
npm run build
|
||||
npm run test
|
||||
npm run ci:coveralls
|
||||
|
||||
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "master" ]; then
|
||||
echo "Branch check completed"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
setupGit ${TRAVIS_REPO_SLUG}
|
||||
|
||||
if [ -n "$(git status --untracked-files=no --porcelain)" ]; then
|
||||
echo "Adding build artifacts"
|
||||
|
||||
git add .
|
||||
git commit -m "[CI Skip] Build artifacts"
|
||||
fi
|
||||
|
||||
echo "Incrementing package version"
|
||||
|
||||
npm --no-git-tag-version version
|
||||
npm version patch -m "[CI Skip] Version bump"
|
||||
git push --quiet origin HEAD:refs/heads/$TRAVIS_BRANCH > /dev/null 2>&1
|
||||
|
||||
echo "Publishing to npm"
|
||||
|
||||
npm run ci:makeshift
|
||||
cp LICENSE package.json package-lock.json src/types.js lib/
|
||||
cd lib
|
||||
npm publish
|
||||
cd ..
|
||||
|
||||
echo "Release completed"
|
||||
|
||||
exit 0
|
||||
+3
-3
@@ -7,8 +7,8 @@ import type { ApiInterface } from './types';
|
||||
|
||||
const { formatInputs, formatOutput } = require('@polkadot/api-format');
|
||||
const interfaces = require('@polkadot/jsonrpc');
|
||||
const { callSignature } = require('@polkadot/jsonrpc/util');
|
||||
const { isFunction } = require('@polkadot/util/is');
|
||||
const isFunction = require('@polkadot/util/is/function');
|
||||
const jsonrpcSignature = require('@polkadot/util/jsonrpc/signature');
|
||||
|
||||
module.exports = class Api implements ApiInterface {
|
||||
_provider: ProviderInterface;
|
||||
@@ -58,7 +58,7 @@ module.exports = class Api implements ApiInterface {
|
||||
|
||||
return formatOutput(output, result);
|
||||
} catch (error) {
|
||||
throw new Error(`${callSignature(rpcName, inputs, output)}:: ${error.message}`);
|
||||
throw new Error(`${jsonrpcSignature(rpcName, inputs, output)}:: ${error.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
|
||||
const sinon = require('sinon');
|
||||
|
||||
const { isFunction } = require('@polkadot/util/is');
|
||||
const isFunction = require('@polkadot/util/is/function');
|
||||
|
||||
const Api = require('./api');
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('Api', () => {
|
||||
return container
|
||||
.blah()
|
||||
.catch((error) => {
|
||||
expect(error).to.match(/test_blah\(foo: Address\) => Address/);
|
||||
expect(error).to.match(/test_blah \(foo: Address\): Address/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// ISC, Copyright 2017 Jaco Greeff
|
||||
// @flow
|
||||
|
||||
/*::
|
||||
export interface ApiInterface {
|
||||
+chain: any;
|
||||
+state: any;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user