Skip to content

Commit

Permalink
feat: fetch graphql types script
Browse files Browse the repository at this point in the history
  • Loading branch information
shuffledex committed May 14, 2020
1 parent 0ab49ac commit 7c03ea5
Show file tree
Hide file tree
Showing 4 changed files with 1,126 additions and 21 deletions.
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"start": "node scripts/generateTsconfigDev.js && cross-env webpack-dev-server --config=webpack.config.dev.js",
"generate:polkadot-types": "yarn fetch-definitions && yarn generate:defs && yarn generate:meta && yarn generate:tags",
"fetch:harvester-types": "node scripts/fetchHarvesterTypes.js",
"fetch-definitions": "node scripts/fetchDefinitions.js",
"generate:defs": "ts-node --skip-project node_modules/.bin/polkadot-types-from-defs --package polymesh-types --input ./src/polkadot",
"generate:meta": "ts-node --skip-project node_modules/.bin/polkadot-types-from-chain --package polymesh-types --endpoint wss://pmf.polymath.network --output ./src/polkadot --strict",
Expand Down Expand Up @@ -52,6 +53,7 @@
"husky": "^4.1.0",
"jest": "25.1.0",
"lint-staged": "^8.1.5",
"nodegit": "^0.26.5",
"prettier": "^1.19.1",
"prettier-eslint": "^9.0.1",
"prettier-eslint-cli": "^5.0.0",
Expand Down Expand Up @@ -81,7 +83,9 @@
"@polkadot/util": "2.8.1",
"@polkadot/util-crypto": "2.8.1",
"@types/bignumber.js": "^5.0.0",
"apollo-boost": "^0.4.9",
"bignumber.js": "^9.0.0",
"graphql": "^15.0.0",
"json-stable-stringify": "^1.0.1",
"lodash": "^4.17.15"
}
Expand Down
32 changes: 32 additions & 0 deletions scripts/fetchHarvesterTypes.js
@@ -0,0 +1,32 @@
/* eslint-disable */
const git = require('nodegit');
const path = require('path');
const rimraf = require('rimraf');
const { exec } = require('child_process');

const BRANCH = process.env.BRANCH;
const GITHUB_PROYECT = 'git@github.com:PolymathNetwork/tooling-gql.git';
const TOOLING_FOLDER = 'tooling-gql';
const OUTPUT_TYPES = path.resolve(__dirname, '../src/polkadot/harvester-types.ts');

const tooling = path.resolve(__dirname, TOOLING_FOLDER);
rimraf.sync(tooling);

git
.Clone(GITHUB_PROYECT, tooling, {
fetchOpts: {
callbacks: {
certificateCheck: () => 1,
credentials: function(_, username) {
return git.Cred.sshKeyFromAgent(username);
},
},
},
})
.then(function() {
if (BRANCH) {
exec(`cd scripts/${TOOLING_FOLDER} && git checkout ${BRANCH}`);
}
exec(`cp scripts/${TOOLING_FOLDER}/src/generated/graphqlTypes.ts ${OUTPUT_TYPES}`);
rimraf.sync(tooling);
});

0 comments on commit 7c03ea5

Please sign in to comment.