mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Merge pull request #264 from oceanprotocol/feature/doc-json
Generate typedoc json during build
This commit is contained in:
commit
c40a9cb261
@ -8,3 +8,4 @@ src/
|
|||||||
tsconfig.json
|
tsconfig.json
|
||||||
tslint.json
|
tslint.json
|
||||||
oceanprotocol-squid-*.tgz
|
oceanprotocol-squid-*.tgz
|
||||||
|
squid-js.json
|
||||||
|
43
package-lock.json
generated
43
package-lock.json
generated
@ -3797,7 +3797,8 @@
|
|||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
@ -3818,12 +3819,14 @@
|
|||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
@ -3838,17 +3841,20 @@
|
|||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@ -3965,7 +3971,8 @@
|
|||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@ -3977,6 +3984,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
@ -3991,6 +3999,7 @@
|
|||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
@ -3998,12 +4007,14 @@
|
|||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
@ -4022,6 +4033,7 @@
|
|||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
@ -4102,7 +4114,8 @@
|
|||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@ -4114,6 +4127,7 @@
|
|||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
@ -4199,7 +4213,8 @@
|
|||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
@ -4235,6 +4250,7 @@
|
|||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
@ -4254,6 +4270,7 @@
|
|||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
@ -4297,12 +4314,14 @@
|
|||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -9705,7 +9724,7 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"underscore": "1.8.3",
|
"underscore": "1.8.3",
|
||||||
"web3-core-helpers": "1.0.0-beta.37",
|
"web3-core-helpers": "1.0.0-beta.37",
|
||||||
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
|
"websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"web3-shh": {
|
"web3-shh": {
|
||||||
|
10
package.json
10
package.json
@ -10,7 +10,7 @@
|
|||||||
"build": "npm run clean && npm run build:tsc && npm run build:dist",
|
"build": "npm run clean && npm run build:tsc && npm run build:dist",
|
||||||
"build:tsc": "tsc --sourceMap",
|
"build:tsc": "tsc --sourceMap",
|
||||||
"build:metadata": "./scripts/get-metadata.js > src/metadata.json",
|
"build:metadata": "./scripts/get-metadata.js > src/metadata.json",
|
||||||
"build:dist": "cross-env NODE_ENV=production webpack",
|
"build:dist": "cross-env NODE_ENV=production webpack && npm run doc:json",
|
||||||
"build:watch": "tsc -w",
|
"build:watch": "tsc -w",
|
||||||
"test": "mocha",
|
"test": "mocha",
|
||||||
"test:watch": "mocha -w --watch-extensions js,ts,json",
|
"test:watch": "mocha -w --watch-extensions js,ts,json",
|
||||||
@ -24,6 +24,7 @@
|
|||||||
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx .",
|
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx .",
|
||||||
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
|
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
|
||||||
"doc": "typedoc --mode modules --out ./doc/ ./src/",
|
"doc": "typedoc --mode modules --out ./doc/ ./src/",
|
||||||
|
"doc:json": "./scripts/typedoc.js",
|
||||||
"merge-coverages": "npx lcov-result-merger \"coverage/*/lcov.info\" coverage/lcov.info",
|
"merge-coverages": "npx lcov-result-merger \"coverage/*/lcov.info\" coverage/lcov.info",
|
||||||
"report-coverage": "npm run report-coverage:unit && npm run report-coverage:integration",
|
"report-coverage": "npm run report-coverage:unit && npm run report-coverage:integration",
|
||||||
"report-coverage:unit": "cat coverage/unit/lcov.info | codacy-coverage --token 71ef0d15f6f04ac29b31d704b28f866a",
|
"report-coverage:unit": "cat coverage/unit/lcov.info | codacy-coverage --token 71ef0d15f6f04ac29b31d704b28f866a",
|
||||||
@ -80,6 +81,7 @@
|
|||||||
"mocha": "^6.1.4",
|
"mocha": "^6.1.4",
|
||||||
"mock-local-storage": "^1.1.8",
|
"mock-local-storage": "^1.1.8",
|
||||||
"nyc": "^14.1.1",
|
"nyc": "^14.1.1",
|
||||||
|
"ora": "^3.4.0",
|
||||||
"prettier": "^1.18.2",
|
"prettier": "^1.18.2",
|
||||||
"source-map-support": "^0.5.12",
|
"source-map-support": "^0.5.12",
|
||||||
"truffle-hdwallet-provider": "^1.0.10",
|
"truffle-hdwallet-provider": "^1.0.10",
|
||||||
@ -111,7 +113,6 @@
|
|||||||
},
|
},
|
||||||
"release-it": {
|
"release-it": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"after:init": "npm test",
|
|
||||||
"after:bump": "npm run changelog"
|
"after:bump": "npm run changelog"
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
@ -126,7 +127,10 @@
|
|||||||
"tagName": "v${version}"
|
"tagName": "v${version}"
|
||||||
},
|
},
|
||||||
"github": {
|
"github": {
|
||||||
"release": true
|
"release": true,
|
||||||
|
"assets": [
|
||||||
|
"dist/squid-js.json"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"publish": false
|
"publish": false
|
||||||
|
55
scripts/typedoc.js
Executable file
55
scripts/typedoc.js
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const typedoc = require('typedoc')
|
||||||
|
const typescript = require('typescript')
|
||||||
|
const ora = require('ora')
|
||||||
|
const squidJsPackage = require('../package.json')
|
||||||
|
|
||||||
|
const { description, version } = squidJsPackage
|
||||||
|
|
||||||
|
// Setup our paths, relative to project root
|
||||||
|
const outPath = './dist/squid-js.json'
|
||||||
|
const files = ['./src/squid.ts']
|
||||||
|
|
||||||
|
// specifically point to tsconfig, otherwise TypeDoc fails
|
||||||
|
const config = typescript.findConfigFile(
|
||||||
|
'./tsconfig.js',
|
||||||
|
typescript.sys.fileExists
|
||||||
|
)
|
||||||
|
|
||||||
|
const generateJson = () => {
|
||||||
|
const spinnerTypedoc = ora('Generating TypeDoc json...').start()
|
||||||
|
|
||||||
|
// Setup our TypeDoc app
|
||||||
|
const app = new typedoc.Application({
|
||||||
|
tsconfig: config
|
||||||
|
})
|
||||||
|
|
||||||
|
const src = app.expandInputFiles(files)
|
||||||
|
const project = app.convert(src)
|
||||||
|
|
||||||
|
// Generate the JSON file
|
||||||
|
app.generateJson(project, outPath)
|
||||||
|
|
||||||
|
// Parse and modify json output
|
||||||
|
const jsonOrig = JSON.parse(fs.readFileSync(outPath, 'utf8'))
|
||||||
|
|
||||||
|
const jsonFinal = {
|
||||||
|
info: {
|
||||||
|
title: 'Squid-js',
|
||||||
|
description,
|
||||||
|
version,
|
||||||
|
sourceUrl: 'https://github.com/oceanprotocol/squid-js/blob/master/'
|
||||||
|
},
|
||||||
|
...jsonOrig
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(outPath, JSON.stringify(jsonFinal, null, 4))
|
||||||
|
|
||||||
|
spinnerTypedoc.succeed('Generated TypeDoc json.')
|
||||||
|
}
|
||||||
|
|
||||||
|
generateJson()
|
Loading…
Reference in New Issue
Block a user