diff --git a/.codeclimate.yml b/.codeclimate.yml index 4684bf4682..caf10f79bb 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -5,5 +5,6 @@ exclude_patterns: - "**/*.test.ts" - "docs/**/*.js" - "packages/api/src/types/augment/" +- "packages/typegen/scripts" +- "packages/typegen/src" - "packages/types/src/interfaces/" -- "packages/types/src/scripts/" diff --git a/package.json b/package.json index 97faecc9ab..458056d32d 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,10 @@ "typescript": "^3.7.5" }, "scripts": { - "build": "yarn build:interfaces && polkadot-dev-build-ts", - "build:interfaces": "node packages/types/src/scripts/interfacesTsWrapper.js", - "docs": "node packages/types/src/scripts/MetadataMdWrapper.js && polkadot-dev-build-docs", - "chain:info": "node packages/types/src/scripts/extractChainWrapper.js", + "build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)", + "build:interfaces": "polkadot-types-internal-interfaces", + "docs": "polkadot-types-internal-metadata && polkadot-dev-build-docs", + "chain:info": "polkadot-types-chain-info", "lint": "polkadot-dev-run-lint", "clean": "polkadot-dev-clean-build", "postinstall": "polkadot-dev-yarn-only", @@ -27,6 +27,7 @@ "@babel/register": "^7.8.3", "@babel/runtime": "^7.8.4", "@polkadot/dev": "^0.40.17", - "@polkadot/ts": "^0.2.3" + "@polkadot/ts": "^0.2.3", + "copyfiles": "^2.2.0" } } diff --git a/packages/typegen/LICENSE b/packages/typegen/LICENSE new file mode 100644 index 0000000000..0d381b2e97 --- /dev/null +++ b/packages/typegen/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/packages/typegen/README.md b/packages/typegen/README.md new file mode 100644 index 0000000000..054d559b56 --- /dev/null +++ b/packages/typegen/README.md @@ -0,0 +1,3 @@ +# @polkadot/typegen + +A collection of type generation scripts, allowing the input of metadata and definitions for the creation of TS outputs. diff --git a/packages/typegen/package.json b/packages/typegen/package.json new file mode 100644 index 0000000000..c50c9c8295 --- /dev/null +++ b/packages/typegen/package.json @@ -0,0 +1,50 @@ +{ + "name": "@polkadot/typegen", + "version": "1.3.0-beta.5", + "description": "Type generation scripts", + "main": "index.js", + "bin": { + "polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js", + "polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js", + "polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.js", + "polkadot-types-internal-interfaces": "./scripts/polkadot-types-internal-interfaces.js", + "polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.js" + }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/polkadot-js/api.git" + }, + "keywords": [ + "Polkadot", + "JsonRPC" + ], + "author": "Jaco Greeff ", + "maintainers": [ + "Jaco Greeff " + ], + "contributors": [], + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/polkadot-js/api/issues" + }, + "homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme", + "dependencies": { + "@babel/core": "^7.8.3", + "@babel/register": "^7.8.3", + "@babel/runtime": "^7.8.4", + "@polkadot/api": "^1.3.0-beta.5", + "@polkadot/jsonrpc": "^1.3.0-beta.5", + "@polkadot/metadata": "^1.3.0-beta.5", + "@polkadot/types": "^1.3.0-beta.5", + "@polkadot/util": "^2.3.1", + "websocket": "^1.0.31", + "yargs": "^15.1.0" + }, + "devDependencies": { + "@types/yargs": "^15.0.3" + } +} diff --git a/packages/typegen/scripts/polkadot-types-chain-info.js b/packages/typegen/scripts/polkadot-types-chain-info.js new file mode 100755 index 0000000000..50100ecc00 --- /dev/null +++ b/packages/typegen/scripts/polkadot-types-chain-info.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. +/* eslint-disable @typescript-eslint/no-var-requires */ + +let main; + +try { + main = require('../extractChain').default; +} catch (error) { + require('@babel/register')({ + extensions: ['.js', '.ts'], + plugins: [ + ['module-resolver', { + alias: { + '^@polkadot/api-derive(.*)': './packages/api-derive/src\\1', + '^@polkadot/metadata(.*)': './packages/metadata/src\\1', + '^@polkadot/api(.*)': './packages/api/src/\\1', + '^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1', + '^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1', + '^@polkadot/rpc-provider(.*)': './packages/rpc-provider/src\\1', + '^@polkadot/types(.*)': './packages/types/src\\1' + } + }] + ] + }); + + main = require('../src/extractChain.ts').default; +} + +main(); diff --git a/packages/typegen/scripts/polkadot-types-from-chain.js b/packages/typegen/scripts/polkadot-types-from-chain.js new file mode 100755 index 0000000000..87f0b233cf --- /dev/null +++ b/packages/typegen/scripts/polkadot-types-from-chain.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. +/* eslint-disable @typescript-eslint/no-var-requires */ + +let main; + +try { + main = require('../fromChain').default; +} catch (error) { + require('@babel/register')({ + extensions: ['.js', '.ts'], + plugins: [ + ['module-resolver', { + alias: { + '^@polkadot/metadata(.*)': './packages/metadata/src\\1', + '^@polkadot/types(.*)': './packages/types/src\\1' + } + }] + ] + }); + + main = require('../src/fromChain').default; +} + +main(); diff --git a/packages/typegen/scripts/polkadot-types-from-defs.js b/packages/typegen/scripts/polkadot-types-from-defs.js new file mode 100755 index 0000000000..c81ef2340c --- /dev/null +++ b/packages/typegen/scripts/polkadot-types-from-defs.js @@ -0,0 +1,28 @@ +#!/usr/bin/env node +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. +/* eslint-disable @typescript-eslint/no-var-requires */ + +let main; + +try { + main = require('../fromDefs').default; +} catch (error) { + require('@babel/register')({ + extensions: ['.js', '.ts'], + plugins: [ + ['module-resolver', { + alias: { + '^@polkadot/metadata(.*)': './packages/metadata/src\\1', + '^@polkadot/typegen(.*)': './packages/typegen/src\\1', + '^@polkadot/types(.*)': './packages/types/src\\1' + } + }] + ] + }); + + main = require('../sr/fromDefs.ts').default; +} + +main(); diff --git a/packages/typegen/scripts/polkadot-types-internal-interfaces.js b/packages/typegen/scripts/polkadot-types-internal-interfaces.js new file mode 100755 index 0000000000..801975f1c7 --- /dev/null +++ b/packages/typegen/scripts/polkadot-types-internal-interfaces.js @@ -0,0 +1,28 @@ +#!/usr/bin/env node +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. +/* eslint-disable @typescript-eslint/no-var-requires */ + +let main; + +try { + main = require('../interfacesTs').default; +} catch (error) { + require('@babel/register')({ + extensions: ['.js', '.ts'], + plugins: [ + ['module-resolver', { + alias: { + '^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1', + '^@polkadot/metadata(.*)': './packages/metadata/src\\1', + '^@polkadot/types(.*)': './packages/types/src\\1' + } + }] + ] + }); + + main = require('../src/interfacesTs.ts').default; +} + +main(); diff --git a/packages/typegen/scripts/polkadot-types-internal-metadata.js b/packages/typegen/scripts/polkadot-types-internal-metadata.js new file mode 100755 index 0000000000..04d12e41ca --- /dev/null +++ b/packages/typegen/scripts/polkadot-types-internal-metadata.js @@ -0,0 +1,28 @@ +#!/usr/bin/env node +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. +/* eslint-disable @typescript-eslint/no-var-requires */ + +let main; + +try { + main = require('../metadataMd').default; +} catch (error) { + require('@babel/register')({ + extensions: ['.js', '.ts'], + plugins: [ + ['module-resolver', { + alias: { + '^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1', + '^@polkadot/metadata(.*)': './packages/metadata/src\\1', + '^@polkadot/types(.*)': './packages/types/src\\1' + } + }] + ] + }); + + main = require('../src/metadataMd.ts').default; +} + +main(); diff --git a/packages/types/src/scripts/extractChain.ts b/packages/typegen/src/extractChain.ts similarity index 66% rename from packages/types/src/scripts/extractChain.ts rename to packages/typegen/src/extractChain.ts index 771752f341..b864433003 100644 --- a/packages/types/src/scripts/extractChain.ts +++ b/packages/typegen/src/extractChain.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. @@ -9,21 +9,8 @@ import process from 'process'; import yargs from 'yargs'; import { ApiPromise, WsProvider } from '@polkadot/api/index'; -// retrieve and parse arguments - we do this globally, since this is a single command -const { argv: { ws } } = yargs - .usage('Usage: [options]') - .wrap(120) - .options({ - ws: { - default: 'ws://127.0.0.1:9944', - description: 'The API endpoint to connect to, e.g. wss://poc3-rpc.polkadot.io', - type: 'string', - required: true - } - }); - /** @internal */ -async function main (): Promise { +async function run (ws: string): Promise { const provider = new WsProvider(ws); const api = await ApiPromise.create({ provider }); const [chain, props] = await Promise.all([ @@ -38,11 +25,26 @@ async function main (): Promise { api.runtimeMetadata.getUniqTypes(false); } -main() - .then((): void => { - process.exit(0); - }) - .catch((error: Error) => { - console.error('FATAL:', error.message); - process.exit(-1); - }); +export default function main (): void { + // retrieve and parse arguments - we do this globally, since this is a single command + const { ws } = yargs + .usage('Usage: [options]') + .wrap(120) + .options({ + ws: { + default: 'ws://127.0.0.1:9944', + description: 'The API endpoint to connect to, e.g. wss://poc3-rpc.polkadot.io', + type: 'string', + required: true + } + }).argv; + + run(ws) + .then((): void => { + process.exit(0); + }) + .catch((error: Error) => { + console.error('FATAL:', error.message); + process.exit(-1); + }); +} diff --git a/packages/typegen/src/fromChain.ts b/packages/typegen/src/fromChain.ts new file mode 100644 index 0000000000..d7b6517691 --- /dev/null +++ b/packages/typegen/src/fromChain.ts @@ -0,0 +1,86 @@ +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import path from 'path'; +import yargs from 'yargs'; +import { formatNumber } from '@polkadot/util'; + +import generateConst from './generate/consts'; +import generateQuery from './generate/query'; +import generateTx from './generate/tx'; + +if (typeof WebSocket === 'undefined') { + (global as any).WebSocket = require('websocket').w3cwebsocket; +} + +let websocket: any = null; + +function generate (metaHex: string, pkg: string | undefined, output: string, isStrict?: boolean): void { + console.log(`Generating from metadata, ${formatNumber((metaHex.length - 2) / 2)} bytes`); + + const extraTypes = pkg + ? { [pkg]: require(path.join(process.cwd(), output, 'definitions')) } + : {}; + + generateConst(path.join(process.cwd(), output, 'augment.consts.ts'), metaHex, extraTypes, isStrict); + generateQuery(path.join(process.cwd(), output, 'augment.query.ts'), metaHex, extraTypes, isStrict); + generateTx(path.join(process.cwd(), output, 'augment.tx.ts'), metaHex, extraTypes, isStrict); + + process.exit(0); +} + +function onSocketClose (event: any): void { + console.error(`disconnected, code: '${event.code}' reason: '${event.reason}'`); + + process.exit(1); +} + +function onSocketError (event: any): void { + console.error(event); + + process.exit(1); +} + +function onSocketOpen (): boolean { + console.log('connected'); + + websocket.send('{"id":"1","jsonrpc":"2.0","method":"state_getMetadata","params":[]}'); + + return true; +} + +export default function main (): void { + const { endpoint, output, package: pkg, strict: isStrict } = yargs.strict().options({ + endpoint: { + description: 'The endpoint to connect to, e.g. wss://kusama-rpc.polkadot.io or relative file to JSON output', + type: 'string', + required: true + }, + output: { + description: 'The target directory to write the data to', + type: 'string', + required: true + }, + package: { + description: 'Optional package in output location (for extra definitions)', + type: 'string' + }, + strict: { + description: 'Turns on stirct mode, not outputting genric versions', + type: 'boolean' + } + }).argv; + + if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) { + websocket = new WebSocket(endpoint); + websocket.onclose = onSocketClose; + websocket.onerror = onSocketError; + websocket.onopen = onSocketOpen; + websocket.onmessage = (message: any): void => { + generate(JSON.parse(message.data).result, pkg, output, isStrict); + }; + } else { + generate(require(path.join(process.cwd(), endpoint)).result, pkg, output, isStrict); + } +} diff --git a/packages/typegen/src/fromDefs.ts b/packages/typegen/src/fromDefs.ts new file mode 100644 index 0000000000..d514a2e5b5 --- /dev/null +++ b/packages/typegen/src/fromDefs.ts @@ -0,0 +1,53 @@ +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import path from 'path'; +import yargs from 'yargs'; +import * as substrateDefs from '@polkadot/types/interfaces/definitions'; + +import { generateInterfaceRegistry } from './generate/interfaceRegistry'; +import { generateTsDef } from './generate/tsDef'; + +export default function main (): void { + const { input, package: pkg } = yargs.strict().options({ + input: { + description: 'The directory to use for the user definitions', + type: 'string', + required: true + }, + package: { + description: 'The package name & path to use for the user types', + type: 'string', + required: true + } + }).argv; + + // eslint-disable-next-line @typescript-eslint/no-var-requires + const userDefs = require(path.join(process.cwd(), input, 'definitions.ts')); + const userKeys = Object.keys(userDefs); + const filteredBase = Object + .entries(substrateDefs) + .filter(([key]) => { + if (userKeys.includes(key)) { + console.warn(`Override found for ${key} in user types, ignoring in @polkadot/types`); + + return false; + } + + return true; + }) + .reduce((defs: any, [key, value]) => { + defs[key] = value; + + return defs; + }, {}); + + const allDefs = { + '@polkadot/types/interfaces': filteredBase, + [pkg]: userDefs + }; + + generateTsDef(allDefs, path.join(process.cwd(), input), pkg); + generateInterfaceRegistry(allDefs, path.join(process.cwd(), input, 'interfaceRegistry.ts')); +} diff --git a/packages/types/src/scripts/generate/consts.ts b/packages/typegen/src/generate/consts.ts similarity index 91% rename from packages/types/src/scripts/generate/consts.ts rename to packages/typegen/src/generate/consts.ts index 81ce6a963a..36c4eaebaf 100644 --- a/packages/types/src/scripts/generate/consts.ts +++ b/packages/typegen/src/generate/consts.ts @@ -1,15 +1,15 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { ModuleMetadataLatest } from '../../interfaces/metadata'; -import * as defaultDefs from '../../interfaces/definitions'; +import { ModuleMetadataLatest } from '@polkadot/types/interfaces/metadata'; +import * as defaultDefs from '@polkadot/types/interfaces/definitions'; import staticData from '@polkadot/metadata/Metadata/static'; import Metadata from '@polkadot/metadata/Metadata'; +import { TypeRegistry } from '@polkadot/types/create'; import { stringCamelCase } from '@polkadot/util'; -import { TypeRegistry } from '../../create'; import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, indent, setImports, writeFile } from '../util'; // Generate types for one module diff --git a/packages/types/src/scripts/generate/interfaceRegistry.ts b/packages/typegen/src/generate/interfaceRegistry.ts similarity index 90% rename from packages/types/src/scripts/generate/interfaceRegistry.ts rename to packages/typegen/src/generate/interfaceRegistry.ts index f1f88d6d09..a7d6e4840d 100644 --- a/packages/types/src/scripts/generate/interfaceRegistry.ts +++ b/packages/typegen/src/generate/interfaceRegistry.ts @@ -1,10 +1,11 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import Raw from '../../codec/Raw'; -import * as defaultDefinitions from '../../interfaces/definitions'; -import * as defaultPrimitives from '../../primitive'; +import Raw from '@polkadot/types/codec/Raw'; +import * as defaultDefinitions from '@polkadot/types/interfaces/definitions'; +import * as defaultPrimitives from '@polkadot/types/primitive'; + import { FOOTER, HEADER, createImportCode, createImports, getDerivedTypes, indent, setImports, writeFile } from '../util'; const primitiveClasses = { diff --git a/packages/types/src/scripts/generate/query.ts b/packages/typegen/src/generate/query.ts similarity index 95% rename from packages/types/src/scripts/generate/query.ts rename to packages/typegen/src/generate/query.ts index f3bf6ae8fa..1f7f260304 100644 --- a/packages/types/src/scripts/generate/query.ts +++ b/packages/typegen/src/generate/query.ts @@ -1,16 +1,16 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { ModuleMetadataLatest, StorageEntryMetadataLatest } from '../../interfaces/metadata'; -import { Registry } from '../../types'; -import * as defaultDefs from '../../interfaces/definitions'; +import { ModuleMetadataLatest, StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata'; +import { Registry } from '@polkadot/types/types'; +import * as defaultDefs from '@polkadot/types/interfaces/definitions'; import staticData from '@polkadot/metadata/Metadata/static'; import Metadata from '@polkadot/metadata/Metadata'; +import { TypeRegistry } from '@polkadot/types/create'; import { stringLowerFirst } from '@polkadot/util'; -import { TypeRegistry } from '../../create'; import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports, writeFile } from '../util'; // If the StorageEntry returns T, output `Option` if the modifier is optional diff --git a/packages/types/src/scripts/generate/rpc.ts b/packages/typegen/src/generate/rpc.ts similarity index 93% rename from packages/types/src/scripts/generate/rpc.ts rename to packages/typegen/src/generate/rpc.ts index 0cd127465b..d5d47a5f58 100644 --- a/packages/types/src/scripts/generate/rpc.ts +++ b/packages/typegen/src/generate/rpc.ts @@ -1,10 +1,11 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import interfaces from '@polkadot/jsonrpc'; -import * as definitions from '../../interfaces/definitions'; -import { TypeRegistry } from '../../create'; +import * as definitions from '@polkadot/types/interfaces/definitions'; +import { TypeRegistry } from '@polkadot/types/create'; + import { FOOTER, HEADER, createDocComments, createImportCode, createImports, getSimilarTypes, setImports, writeFile, indent } from '../util'; /** @internal */ diff --git a/packages/types/src/scripts/generate/tsDef.ts b/packages/typegen/src/generate/tsDef.ts similarity index 96% rename from packages/types/src/scripts/generate/tsDef.ts rename to packages/typegen/src/generate/tsDef.ts index 778900cb35..c801625d11 100644 --- a/packages/types/src/scripts/generate/tsDef.ts +++ b/packages/typegen/src/generate/tsDef.ts @@ -1,15 +1,15 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../../create/types'; +import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '@polkadot/types/create/types'; import fs from 'fs'; import path from 'path'; +import { getTypeDef } from '@polkadot/types/create'; +import * as defaultDefinitions from '@polkadot/types/interfaces/definitions'; import { isString, stringCamelCase, stringUpperFirst } from '@polkadot/util'; -import { getTypeDef } from '../../create'; -import * as defaultDefinitions from '../../interfaces/definitions'; import { FOOTER, HEADER, TypeImports, createImportCode, createImports, exportInterface, exportType, formatType, setImports, writeFile } from '../util'; interface Imports extends TypeImports { diff --git a/packages/types/src/scripts/generate/tx.ts b/packages/typegen/src/generate/tx.ts similarity index 92% rename from packages/types/src/scripts/generate/tx.ts rename to packages/typegen/src/generate/tx.ts index c5b8325167..47cb316c31 100644 --- a/packages/types/src/scripts/generate/tx.ts +++ b/packages/typegen/src/generate/tx.ts @@ -1,17 +1,17 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { ModuleMetadataLatest } from '../../interfaces/metadata'; -import * as defaultDefs from '../../interfaces/definitions'; -import { Registry } from '../../types'; +import { ModuleMetadataLatest } from '@polkadot/types/interfaces/metadata'; +import * as defaultDefs from '@polkadot/types/interfaces/definitions'; +import { Registry } from '@polkadot/types/types'; import staticData from '@polkadot/metadata/Metadata/static'; import Metadata from '@polkadot/metadata/Metadata'; -import { Text } from '@polkadot/types'; +import { Text } from '@polkadot/types/primitive'; +import { TypeRegistry } from '@polkadot/types/create'; import { stringCamelCase } from '@polkadot/util'; -import { TypeRegistry } from '../../create'; import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports, writeFile } from '../util'; const MAPPED_NAMES: Record = { diff --git a/packages/typegen/src/index.ts b/packages/typegen/src/index.ts new file mode 100644 index 0000000000..feae4ae3d2 --- /dev/null +++ b/packages/typegen/src/index.ts @@ -0,0 +1,5 @@ +// Copyright 2017-2020 @polkadot/typegen authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +export { formatType } from './util/formatting'; diff --git a/packages/types/src/scripts/interfacesTs.ts b/packages/typegen/src/interfacesTs.ts similarity index 64% rename from packages/types/src/scripts/interfacesTs.ts rename to packages/typegen/src/interfacesTs.ts index dd3f615aa1..00dda8292e 100644 --- a/packages/types/src/scripts/interfacesTs.ts +++ b/packages/typegen/src/interfacesTs.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. @@ -9,11 +9,13 @@ import generateRpcTypes from './generate/rpc'; import generateTsDef from './generate/tsDef'; import generateTxTypes from './generate/tx'; -generateInterfaceRegistry(); +export default function main (): void { + generateInterfaceRegistry(); -generateConstsTypes(); -generateQueryTypes(); -generateTxTypes(); -generateRpcTypes(); + generateConstsTypes(); + generateQueryTypes(); + generateTxTypes(); + generateRpcTypes(); -generateTsDef(); + generateTsDef(); +} diff --git a/packages/types/src/scripts/MetadataMd.ts b/packages/typegen/src/metadataMd.ts similarity index 51% rename from packages/types/src/scripts/MetadataMd.ts rename to packages/typegen/src/metadataMd.ts index 92ae6baa18..b0b349d45d 100644 --- a/packages/types/src/scripts/MetadataMd.ts +++ b/packages/typegen/src/metadataMd.ts @@ -1,20 +1,32 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { MetadataLatest, ModuleMetadataLatest } from '../interfaces/metadata'; +import { MetadataLatest } from '@polkadot/types/interfaces/metadata'; import fs from 'fs'; import interfaces from '@polkadot/jsonrpc'; import Decorated from '@polkadot/metadata/Decorated'; import rpcdata from '@polkadot/metadata/Metadata/static'; +import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey'; +import Call from '@polkadot/types/primitive/Generic/Call'; +import { TypeRegistry } from '@polkadot/types/create'; +import { Vec } from '@polkadot/types/codec'; +import { Text } from '@polkadot/types/primitive'; import { stringCamelCase, stringLowerFirst } from '@polkadot/util'; -import { unwrapStorageType } from '../primitive/StorageKey'; -import Call from '../primitive/Generic/Call'; -import { TypeRegistry } from '../create'; -import { Vec } from '../codec'; -import { Text } from '../primitive'; +interface Page { + title: string; + description: string; + sections: { + name: string; + description?: string; + items: { + name: string; + [bullet: string]: string | Vec; + }[]; + }[]; +} const STATIC_TEXT = '\n\n(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)'; @@ -28,10 +40,12 @@ const DESC_STORAGE = `The following sections contain Storage methods are part of /** @internal */ function documentationVecToMarkdown (docLines: Vec, indent = 0): string { const md = docLines - .map(docLine => docLine && docLine.substring(1)) // trim the leading space + .map((docLine) => docLine && docLine.substring(1)) // trim the leading space .reduce((md, docLine): string => // generate paragraphs - !docLine.trim().length ? `${md}\n\n` // empty line - : /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n') ? `${md}\n\n${docLine}` // line calling for a preceding linebreak + !docLine.trim().length + ? `${md}\n\n` // empty line + : /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n') + ? `${md}\n\n${docLine}` // line calling for a preceding linebreak : `${md}${docLine // line continuing the preceding line .replace(/^# $/g, '\\# \\\n\n') .replace(/^# <\/weight>$/g, '\n\n\\# \\') @@ -41,19 +55,6 @@ function documentationVecToMarkdown (docLines: Vec, indent = 0): string { return md && md.split('\n\n').map(line => `${' '.repeat(indent)}${line}`).join('\n\n'); } -interface Page { - title: string; - description: string; - sections: { - name: string; - description?: string; - items: { - name: string; - [bullet: string]: string | Vec; - }[]; - }[]; -} - function renderPage (page: Page): string { let md = `## ${page.title}\n\n`; @@ -85,16 +86,9 @@ function renderPage (page: Page): string { return md; } -/** - * Sort object by their `.name` - */ -/** @internal */ function sortByName (a: T, b: T): number { - // ignore upper and lowercase - const nameA = a.name.toString().toUpperCase(); - const nameB = b.name.toString().toUpperCase(); - - return nameA.localeCompare(nameB); + // case insensitive (all-uppercase) sorting + return a.name.toString().toUpperCase().localeCompare(b.name.toString().toUpperCase()); } /** @internal */ @@ -102,28 +96,32 @@ function addRpc (): string { return renderPage({ title: 'JSON-RPC', description: DESC_RPC, - sections: Object.keys(interfaces).sort().map(sectionName => { - const section = interfaces[sectionName]; + sections: Object.keys(interfaces) + .sort() + .map((sectionName) => { + const section = interfaces[sectionName]; - return { - name: sectionName, - description: section.description, - items: Object.keys(section.methods).sort().map(methodName => { - const method = section.methods[methodName]; - const args = method.params.map(({ name, isOptional, type }): string => { - return name + (isOptional ? '?' : '') + ': `' + type + '`'; - }).join(', '); - const type = '`' + method.type + '`'; + return { + name: sectionName, + description: section.description, + items: Object.keys(section.methods) + .sort() + .map((methodName) => { + const method = section.methods[methodName]; + const args = method.params.map(({ name, isOptional, type }): string => { + return name + (isOptional ? '?' : '') + ': `' + type + '`'; + }).join(', '); + const type = '`' + method.type + '`'; - return { - name: `${methodName}(${args}): ${type}`, - jsonrpc: `${sectionName}_${methodName}`, - interface: `api.rpc.${sectionName}.${methodName}`, - ...(method.description && { summary: method.description }) - }; - }) - }; - }) + return { + name: `${methodName}(${args}): ${type}`, + jsonrpc: `${sectionName}_${methodName}`, + interface: `api.rpc.${sectionName}.${methodName}`, + ...(method.description && { summary: method.description }) + }; + }) + }; + }) }); } @@ -132,56 +130,61 @@ function addConstants (metadata: MetadataLatest): string { return renderPage({ title: 'Constants', description: DESC_CONSTANTS, - sections: metadata.modules.sort(sortByName).filter(moduleMetadata => !moduleMetadata.constants.isEmpty).map(moduleMetadata => { - const sectionName = stringLowerFirst(moduleMetadata.name.toString()); + sections: metadata.modules + .sort(sortByName) + .filter((moduleMetadata) => !moduleMetadata.constants.isEmpty) + .map((moduleMetadata) => { + const sectionName = stringLowerFirst(moduleMetadata.name.toString()); - return { - name: sectionName, - items: moduleMetadata.constants.sort(sortByName).map(func => { - const methodName = stringCamelCase(func.name.toString()); + return { + name: sectionName, + items: moduleMetadata.constants + .sort(sortByName) + .map((func) => { + const methodName = stringCamelCase(func.name.toString()); - return { - name: `${methodName}: ` + '`' + func.type + '`', - interface: `api.consts.${sectionName}.${methodName}`, - ...(func.documentation.length && { summary: func.documentation }) - }; - }) - }; - }) + return { + name: `${methodName}: ` + '`' + func.type + '`', + interface: `api.consts.${sectionName}.${methodName}`, + ...(func.documentation.length && { summary: func.documentation }) + }; + }) + }; + }) }); } /** @internal */ function addStorage (metadata: MetadataLatest): string { - const moduleSections = metadata.modules.sort(sortByName) - .filter(moduleMetadata => !moduleMetadata.storage.isNone) - .map(moduleMetadata => { + const moduleSections = metadata.modules + .sort(sortByName) + .filter((moduleMetadata) => !moduleMetadata.storage.isNone) + .map((moduleMetadata) => { const sectionName = stringLowerFirst(moduleMetadata.name.toString()); return { name: sectionName, - items: moduleMetadata.storage.unwrap().items.sort(sortByName).map(func => { - const arg = - func.type.isMap + items: moduleMetadata.storage.unwrap().items + .sort(sortByName) + .map((func) => { + const arg = func.type.isMap ? ('`' + func.type.asMap.key.toString() + '`') : func.type.isDoubleMap ? ('`' + func.type.asDoubleMap.key1.toString() + ', ' + func.type.asDoubleMap.key2.toString() + '`') : ''; + const methodName = stringLowerFirst(func.name.toString()); + let result = unwrapStorageType(func.type); - const methodName = stringLowerFirst(func.name.toString()); + if (func.modifier.isOptional) { + result = `Option<${result}>`; + } - let result = unwrapStorageType(func.type); - - if (func.modifier.isOptional) { - result = `Option<${result}>`; - } - - return { - name: `${methodName}(${arg}): ` + '`' + result + '`', - interface: `api.query.${sectionName}.${methodName}`, - ...(func.documentation.length && { summary: func.documentation }) - }; - }) + return { + name: `${methodName}(${arg}): ` + '`' + result + '`', + interface: `api.query.${sectionName}.${methodName}`, + ...(func.documentation.length && { summary: func.documentation }) + }; + }) }; }); @@ -200,23 +203,28 @@ function addExtrinsics (metadata: MetadataLatest): string { return renderPage({ title: 'Extrinsics', description: DESC_EXTRINSICS, - sections: metadata.modules.map((i): ModuleMetadataLatest => i).sort(sortByName).filter(meta => !meta.calls.isNone && meta.calls.unwrap().length).map(meta => { - const sectionName = stringCamelCase(meta.name.toString()); + sections: metadata.modules + .sort(sortByName) + .filter((meta) => !meta.calls.isNone && meta.calls.unwrap().length) + .map((meta) => { + const sectionName = stringCamelCase(meta.name.toString()); - return { - name: sectionName, - items: meta.calls.unwrap().sort(sortByName).map(func => { - const methodName = stringCamelCase(func.name.toString()); - const args = Call.filterOrigin(func).map(({ name, type }): string => `${name}: ` + '`' + type + '`').join(', '); + return { + name: sectionName, + items: meta.calls.unwrap() + .sort(sortByName) + .map((func) => { + const methodName = stringCamelCase(func.name.toString()); + const args = Call.filterOrigin(func).map(({ name, type }): string => `${name}: ` + '`' + type + '`').join(', '); - return { - name: `${methodName}(${args})`, - interface: `api.tx.${sectionName}.${methodName}`, - ...(func.documentation.length && { summary: func.documentation }) - }; - }) - }; - }) + return { + name: `${methodName}(${args})`, + interface: `api.tx.${sectionName}.${methodName}`, + ...(func.documentation.length && { summary: func.documentation }) + }; + }) + }; + }) }); } @@ -225,22 +233,23 @@ function addEvents (metadata: MetadataLatest): string { return renderPage({ title: 'Events', description: DESC_EVENTS, - sections: metadata.modules.sort(sortByName).filter(meta => !meta.events.isNone && meta.events.unwrap().length).map(meta => { - const sectionName = stringCamelCase(meta.name.toString()); + sections: metadata.modules + .sort(sortByName) + .filter((meta) => !meta.events.isNone && meta.events.unwrap().length) + .map((meta) => ({ + name: stringCamelCase(meta.name.toString()), + items: meta.events.unwrap() + .sort(sortByName) + .map((func) => { + const methodName = func.name.toString(); + const args = func.args.map((type): string => '`' + type + '`').join(', '); - return { - name: sectionName, - items: meta.events.unwrap().sort(sortByName).map(func => { - const methodName = func.name.toString(); - const args = func.args.map((type): string => '`' + type + '`').join(', '); - - return { - name: `${methodName}(${args})`, - ...(func.documentation.length && { summary: func.documentation }) - }; - }) - }; - }) + return { + name: `${methodName}(${args})`, + ...(func.documentation.length && { summary: func.documentation }) + }; + }) + })) }); } @@ -249,19 +258,18 @@ function addErrors (metadata: MetadataLatest): string { return renderPage({ title: 'Errors', description: DESC_ERRORS, - sections: metadata.modules.sort(sortByName).filter(moduleMetadata => !moduleMetadata.errors.isEmpty).map(moduleMetadata => { - const sectionName = stringLowerFirst(moduleMetadata.name.toString()); - - return { - name: sectionName, - items: moduleMetadata.errors.sort(sortByName).map(error => { - return { + sections: metadata.modules + .sort(sortByName) + .filter((moduleMetadata) => !moduleMetadata.errors.isEmpty) + .map((moduleMetadata) => ({ + name: stringLowerFirst(moduleMetadata.name.toString()), + items: moduleMetadata.errors + .sort(sortByName) + .map((error) => ({ name: error.name.toString(), ...(error.documentation.length && { summary: error.documentation }) - }; - }) - }; - }) + })) + })) }); } @@ -281,43 +289,14 @@ function writeFile (name: string, ...chunks: any[]): void { writeStream.end(); } -/** @internal */ -function writeToRpcMd (): void { +export default function main (): void { + const registry = new TypeRegistry(); + const metadata = new Decorated(registry, rpcdata).metadata.asLatest; + writeFile('docs/substrate/rpc.md', addRpc()); -} - -/** @internal */ -function writeToConstantsMd (metadata: MetadataLatest): void { writeFile('docs/substrate/constants.md', addConstants(metadata)); -} - -/** @internal */ -function writeToStorageMd (metadata: MetadataLatest): void { writeFile('docs/substrate/storage.md', addStorage(metadata)); -} - -/** @internal */ -function writeToExtrinsicsMd (metadata: MetadataLatest): void { writeFile('docs/substrate/extrinsics.md', addExtrinsics(metadata)); -} - -/** @internal */ -function writeToEventsMd (metadata: MetadataLatest): void { writeFile('docs/substrate/events.md', addEvents(metadata)); -} - -/** @internal */ -function writeToErrorsMd (metadata: MetadataLatest): void { writeFile('docs/substrate/errors.md', addErrors(metadata)); } - -const registry = new TypeRegistry(); -const decorated = new Decorated(registry, rpcdata); -const latest = decorated.metadata.asLatest; - -writeToRpcMd(); -writeToConstantsMd(latest); -writeToStorageMd(latest); -writeToExtrinsicsMd(latest); -writeToEventsMd(latest); -writeToErrorsMd(latest); diff --git a/packages/types/src/scripts/util/class.ts b/packages/typegen/src/util/class.ts similarity index 80% rename from packages/types/src/scripts/util/class.ts rename to packages/typegen/src/util/class.ts index b9f38ce819..c2b561222f 100644 --- a/packages/types/src/scripts/util/class.ts +++ b/packages/typegen/src/util/class.ts @@ -1,10 +1,10 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { Constructor } from '../../types'; +import { Constructor } from '@polkadot/types/types'; -import UInt from '../../codec/UInt'; +import UInt from '@polkadot/types/codec/UInt'; // See if a class is child of another class // FIMXE This could go in util some day diff --git a/packages/types/src/scripts/util/derived.ts b/packages/typegen/src/util/derived.ts similarity index 83% rename from packages/types/src/scripts/util/derived.ts rename to packages/typegen/src/util/derived.ts index 4e056591eb..1cb076511a 100644 --- a/packages/types/src/scripts/util/derived.ts +++ b/packages/typegen/src/util/derived.ts @@ -2,23 +2,24 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { TypeDef, TypeDefInfo } from '../../create/types'; -import { Constructor, Registry } from '../../types'; +import { TypeDef, TypeDefInfo } from '@polkadot/types/create/types'; +import { Constructor, Registry } from '@polkadot/types/types'; import { stringLowerFirst } from '@polkadot/util'; import { isChildClass, isCompactEncodable } from './class'; -import { ClassOf, ClassOfUnsafe, getTypeDef } from '../../create'; -import AbstractInt from '../../codec/AbstractInt'; -import Compact from '../../codec/Compact'; -import Enum from '../../codec/Enum'; -import Option from '../../codec/Option'; -import Struct from '../../codec/Struct'; -import Vec from '../../codec/Vec'; -import GenericAccountId from '../../primitive/Generic/AccountId'; -import GenericAddress from '../../primitive/Generic/Address'; -import Vote, { convictionNames as _voteConvictions } from '../../primitive/Generic/Vote'; -import Null from '../../primitive/Null'; -import * as primitiveClasses from '../../primitive'; +import { ClassOf, ClassOfUnsafe, getTypeDef } from '@polkadot/types/create'; +import AbstractInt from '@polkadot/types/codec/AbstractInt'; +import Compact from '@polkadot/types/codec/Compact'; +import Enum from '@polkadot/types/codec/Enum'; +import Option from '@polkadot/types/codec/Option'; +import Struct from '@polkadot/types/codec/Struct'; +import Vec from '@polkadot/types/codec/Vec'; +import GenericAccountId from '@polkadot/types/primitive/Generic/AccountId'; +import GenericAddress from '@polkadot/types/primitive/Generic/Address'; +import Vote, { convictionNames as _voteConvictions } from '@polkadot/types/primitive/Generic/Vote'; +import Null from '@polkadot/types/primitive/Null'; +import * as primitiveClasses from '@polkadot/types/primitive'; + import { formatType } from './formatting'; import { setImports, TypeImports } from './imports'; diff --git a/packages/types/src/scripts/util/docs.ts b/packages/typegen/src/util/docs.ts similarity index 91% rename from packages/types/src/scripts/util/docs.ts rename to packages/typegen/src/util/docs.ts index 5cf70afc58..b97c855c4f 100644 --- a/packages/types/src/scripts/util/docs.ts +++ b/packages/typegen/src/util/docs.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/types/src/scripts/util/file.ts b/packages/typegen/src/util/file.ts similarity index 86% rename from packages/types/src/scripts/util/file.ts rename to packages/typegen/src/util/file.ts index ce0fca3acf..93c4e8a1c1 100644 --- a/packages/types/src/scripts/util/file.ts +++ b/packages/typegen/src/util/file.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/types/src/scripts/util/formatting.spec.ts b/packages/typegen/src/util/formatting.spec.ts similarity index 82% rename from packages/types/src/scripts/util/formatting.spec.ts rename to packages/typegen/src/util/formatting.spec.ts index a7d7c2026e..71eeb5ad88 100644 --- a/packages/types/src/scripts/util/formatting.spec.ts +++ b/packages/typegen/src/util/formatting.spec.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/types/src/scripts/util/formatting.ts b/packages/typegen/src/util/formatting.ts similarity index 95% rename from packages/types/src/scripts/util/formatting.ts rename to packages/typegen/src/util/formatting.ts index b20f06f034..278c43ca8f 100644 --- a/packages/types/src/scripts/util/formatting.ts +++ b/packages/typegen/src/util/formatting.ts @@ -1,11 +1,12 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../../create/types'; +import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '@polkadot/types/create/types'; + +import { getTypeDef } from '@polkadot/types/create'; +import { paramsNotation } from '@polkadot/types/codec/utils'; -import { getTypeDef } from '../../create'; -import { paramsNotation } from '../../codec/utils'; import { setImports, TypeImports } from './imports'; export const HEADER = '// Auto-generated via `yarn polkadot-types-from-defs`, do not edit\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n'; diff --git a/packages/types/src/scripts/util/imports.ts b/packages/typegen/src/util/imports.ts similarity index 93% rename from packages/types/src/scripts/util/imports.ts rename to packages/typegen/src/util/imports.ts index d4c57e247f..5c4c1b2216 100644 --- a/packages/types/src/scripts/util/imports.ts +++ b/packages/typegen/src/util/imports.ts @@ -1,12 +1,12 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { TypeDefInfo } from '../../create/types'; +import { TypeDefInfo } from '@polkadot/types/create/types'; -import * as codecClasses from '../../codec'; -import { getTypeDef } from '../../create'; -import * as primitiveClasses from '../../primitive'; +import * as codecClasses from '@polkadot/types/codec'; +import { getTypeDef } from '@polkadot/types/create'; +import * as primitiveClasses from '@polkadot/types/primitive'; // these map all the codec and primitive types for import, see the TypeImports below. If // we have an unseen type, it is `undefined`/`false`, if we need to import it, it is `true` diff --git a/packages/types/src/scripts/util/index.ts b/packages/typegen/src/util/index.ts similarity index 80% rename from packages/types/src/scripts/util/index.ts rename to packages/typegen/src/util/index.ts index 9a3dd86a54..846e1d5b63 100644 --- a/packages/types/src/scripts/util/index.ts +++ b/packages/typegen/src/util/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/types authors & contributors +// Copyright 2017-2020 @polkadot/typegen authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/types/package.json b/packages/types/package.json index 9c4d7235df..0ab306a927 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -3,10 +3,6 @@ "version": "1.3.0-beta.5", "description": "Implementation of the Parity codec", "main": "index.js", - "bin": { - "polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js", - "polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.js" - }, "keywords": [ "Polkadot", "JsonRPC" @@ -30,23 +26,17 @@ }, "homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme", "dependencies": { - "@babel/core": "^7.8.4", - "@babel/register": "^7.8.3", "@babel/runtime": "^7.8.4", - "@polkadot/api": "^1.3.0-beta.5", "@polkadot/metadata": "^1.3.0-beta.5", "@polkadot/util": "^2.3.1", "@polkadot/util-crypto": "^2.3.1", "@types/bn.js": "^4.11.6", "bn.js": "^5.1.1", "memoizee": "^0.4.14", - "rxjs": "^6.5.4", - "websocket": "^1.0.31", - "yargs": "^15.1.0" + "rxjs": "^6.5.4" }, "devDependencies": { "@polkadot/keyring": "^2.3.1", - "@types/memoizee": "^0.4.3", - "@types/yargs": "^15.0.3" + "@types/memoizee": "^0.4.3" } } diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 32d6c2f832..1cff35ff85 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -15,6 +15,3 @@ try { export * from './codec'; export * from './create'; export * from './index.types'; - -// FIXME We actually don't want to do this (if needed, it certainly is not in the right place) -export { formatType } from './scripts/util/formatting'; diff --git a/packages/types/src/scripts/MetadataMdWrapper.js b/packages/types/src/scripts/MetadataMdWrapper.js deleted file mode 100644 index 19a9fab799..0000000000 --- a/packages/types/src/scripts/MetadataMdWrapper.js +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env node -// Copyright 2017-2020 @polkadot/types authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -// eslint-disable-next-line @typescript-eslint/no-var-requires -require('@babel/register')({ - extensions: ['.js', '.ts'], - plugins: [ - ['module-resolver', { - alias: { - '^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1', - '^@polkadot/metadata(.*)': './packages/metadata/src\\1', - '^@polkadot/types(.*)': './packages/types/src\\1' - } - }] - ] -}); - -require('./MetadataMd.ts'); diff --git a/packages/types/src/scripts/extractChainWrapper.js b/packages/types/src/scripts/extractChainWrapper.js deleted file mode 100644 index c895976fc8..0000000000 --- a/packages/types/src/scripts/extractChainWrapper.js +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env node -// Copyright 2017-2020 @polkadot/types authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -// eslint-disable-next-line @typescript-eslint/no-var-requires -require('@babel/register')({ - extensions: ['.js', '.ts'], - plugins: [ - ['module-resolver', { - alias: { - '^@polkadot/api-derive(.*)': './packages/api-derive/src\\1', - '^@polkadot/metadata(.*)': './packages/metadata/src\\1', - '^@polkadot/api(.*)': './packages/api/src/\\1', - '^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1', - '^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1', - '^@polkadot/rpc-provider(.*)': './packages/rpc-provider/src\\1', - '^@polkadot/types(.*)': './packages/types/src\\1' - } - }] - ] -}); - -require('./extractChain.ts'); diff --git a/packages/types/src/scripts/interfacesTsWrapper.js b/packages/types/src/scripts/interfacesTsWrapper.js deleted file mode 100644 index 7f13cf927d..0000000000 --- a/packages/types/src/scripts/interfacesTsWrapper.js +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env node -// Copyright 2017-2020 @polkadot/types authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -// eslint-disable-next-line @typescript-eslint/no-var-requires -require('@babel/register')({ - extensions: ['.js', '.ts'], - plugins: [ - ['module-resolver', { - alias: { - '^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1', - '^@polkadot/metadata(.*)': './packages/metadata/src\\1', - '^@polkadot/types(.*)': './packages/types/src\\1' - } - }] - ] -}); - -require('./interfacesTs.ts'); diff --git a/packages/types/src/scripts/polkadot-types-from-chain.js b/packages/types/src/scripts/polkadot-types-from-chain.js deleted file mode 100755 index 51952dfe0d..0000000000 --- a/packages/types/src/scripts/polkadot-types-from-chain.js +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env node -// Copyright 2017-2020 @polkadot/types authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. -/* eslint-disable @typescript-eslint/no-var-requires */ - -require('@babel/register')({ - extensions: ['.js', '.ts'], - plugins: [ - ['module-resolver', { - alias: { - '^@polkadot/metadata(.*)': './packages/metadata/src\\1', - '^@polkadot/types(.*)': './packages/types/src\\1' - } - }] - ] -}); - -if (typeof WebSocket === 'undefined') { - global.WebSocket = require('websocket').w3cwebsocket; -} - -const path = require('path'); -const yargs = require('yargs'); -const { formatNumber } = require('@polkadot/util'); -const generateConst = require('./generate/consts').default; -const generateQuery = require('./generate/query').default; -const generateTx = require('./generate/tx').default; - -const { endpoint, output, package, strict: isStrict } = yargs.strict().options({ - endpoint: { - description: 'The endpoint to connect to, e.g. wss://kusama-rpc.polkadot.io or relative file to JSON output', - type: 'string', - required: true - }, - output: { - description: 'The target directory to write the data to', - type: 'string', - required: true - }, - package: { - description: 'Optional package in output location (for extra definitions)' - }, - strinct: { - description: 'Turns on stirct mode, not outputting genric versions', - type: 'boolean' - } -}).argv; -let websocket = null; - -function generate (metaHex) { - console.log(`Generating from metadata, ${formatNumber((metaHex.length - 2) / 2)} bytes`); - - const extraTypes = package - ? { [package]: require(path.join(process.cwd(), output, 'definitions')) } - : {}; - - generateConst(path.join(process.cwd(), output, 'augment.consts.ts'), metaHex, extraTypes, isStrict); - generateQuery(path.join(process.cwd(), output, 'augment.query.ts'), metaHex, extraTypes, isStrict); - generateTx(path.join(process.cwd(), output, 'augment.tx.ts'), metaHex, extraTypes, isStrict); - - process.exit(0); -} - -function onSocketClose (event) { - console.error(`${endpoint} disconnected, code: '${event.code}' reason: '${event.reason}'`); - - process.exit(1); -} - -function onSocketError (event) { - console.error(event); - - process.exit(1); -} - -function onSocketOpen () { - console.log(`${endpoint} connected`); - - websocket.send('{"id":"1","jsonrpc":"2.0","method":"state_getMetadata","params":[]}'); - - return true; -} - -function onSocketMessage (message) { - generate(JSON.parse(message.data).result); -} - -if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) { - websocket = new WebSocket(endpoint); - websocket.onclose = onSocketClose; - websocket.onerror = onSocketError; - websocket.onmessage = onSocketMessage; - websocket.onopen = onSocketOpen; -} else { - generate(require(path.join(process.cwd(), endpoint)).result); -} diff --git a/packages/types/src/scripts/polkadot-types-from-defs.js b/packages/types/src/scripts/polkadot-types-from-defs.js deleted file mode 100755 index efe65a7300..0000000000 --- a/packages/types/src/scripts/polkadot-types-from-defs.js +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env node -// Copyright 2017-2020 @polkadot/types authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. -/* eslint-disable @typescript-eslint/no-var-requires */ - -require('@babel/register')({ - extensions: ['.js', '.ts'], - plugins: [ - ['module-resolver', { - alias: { - '^@polkadot/metadata(.*)': './packages/metadata/src\\1', - '^@polkadot/types(.*)': './packages/types/src\\1' - } - }] - ] -}); - -const path = require('path'); -const yargs = require('yargs'); -const substrateDefs = require('../interfaces/definitions'); -const { generateInterfaceRegistry } = require('./generateTypes/interfaceRegistry'); -const { generateTsDef } = require('./generateTypes/tsDef'); - -const { input, package } = yargs.strict().options({ - input: { - description: 'The directory to use for the user definitions', - type: 'string', - required: true - }, - package: { - description: 'The package name & path to use for the user types', - type: 'string', - required: true - } -}).argv; - -const userDefs = require(path.join(process.cwd(), input, 'definitions.ts')); -const userKeys = Object.keys(userDefs); -const filteredBase = Object - .entries(substrateDefs) - .filter(([key]) => { - if (userKeys.includes(key)) { - console.warn(`Override found for ${key} in user types, ignoring in @polkadot/types`); - - return false; - } - - return true; - }) - .reduce((defs, [key, value]) => { - defs[key] = value; - - return defs; - }, {}); - -const allDefs = { - '@polkadot/types/interfaces': filteredBase, - [package]: userDefs -}; - -generateTsDef(allDefs, path.join(process.cwd(), input), package); -generateInterfaceRegistry(allDefs, path.join(process.cwd(), input, 'interfaceRegistry.ts')); diff --git a/yarn.lock b/yarn.lock index ae590c90ee..478b4cd514 100644 --- a/yarn.lock +++ b/yarn.lock @@ -34,7 +34,7 @@ invariant "^2.2.4" semver "^5.5.0" -"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.7.5", "@babel/core@^7.8.4": +"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.7.5", "@babel/core@^7.8.3", "@babel/core@^7.8.4": version "7.8.4" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.8.4.tgz#d496799e5c12195b3602d0fddd77294e3e38e80e" integrity sha512-0LiLrB2PwrVI+a2/IEskBopDYSd8BCb3rOvH7D5tzoWd696TBEduBvuLVm4Nx6rltrLZqvI3MCalB2K2aVzQjA== @@ -2148,9 +2148,9 @@ defer-to-connect "^1.0.1" "@types/babel__core@^7.1.0": - version "7.1.3" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30" - integrity sha512-8fBo0UR2CcwWxeX7WIIgJ7lXjasFxoYgRnFHUj+hRvKkpiBJbxhdAPTCY6/ZKM0uxANFVzt4yObSLuTiTnazDA== + version "7.1.4" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.4.tgz#5c5569cc40e5f2737dfc00692f5444e871e4a234" + integrity sha512-c/5MuRz5HM4aizqL5ViYfW4iEnmfPcfbH4Xa6GgLT21dMc1NGeNnuS6egHheOmP+kCJ9CAzC4pv4SDCWTnRkbg== dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" @@ -3577,13 +3577,13 @@ browserify-zlib@^0.2.0: pako "~1.0.5" browserslist@^4.0.0, browserslist@^4.3.4, browserslist@^4.8.3, browserslist@^4.8.5, browserslist@^4.8.6: - version "4.8.6" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.8.6.tgz#96406f3f5f0755d272e27a66f4163ca821590a7e" - integrity sha512-ZHao85gf0eZ0ESxLfCp73GG9O/VTytYDIkIiZDlURppLTI9wErSM/5yAKEq6rcUdxBLjMELmrYUJGg5sxGKMHg== + version "4.8.7" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.8.7.tgz#ec8301ff415e6a42c949d0e66b405eb539c532d0" + integrity sha512-gFOnZNYBHrEyUML0xr5NJ6edFaaKbTFX9S9kQHlYfCP0Rit/boRIz4G+Avq6/4haEKJXdGGUnoolx+5MWW2BoA== dependencies: - caniuse-lite "^1.0.30001023" - electron-to-chromium "^1.3.341" - node-releases "^1.1.47" + caniuse-lite "^1.0.30001027" + electron-to-chromium "^1.3.349" + node-releases "^1.1.49" bs58@^4.0.1: version "4.0.1" @@ -3808,7 +3808,7 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001023: +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001027: version "1.0.30001027" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001027.tgz#283e2ef17d94889cc216a22c6f85303d78ca852d" integrity sha512-7xvKeErvXZFtUItTHgNtLgS9RJpVnwBlWX8jSo/BO8VsF6deszemZSkJJJA1KOKrXuzZH4WALpAJdq5EyfgMLg== @@ -4204,12 +4204,12 @@ config-chain@^1.1.11: ini "^1.3.4" proto-list "~1.2.1" -configstore@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/configstore/-/configstore-5.0.0.tgz#37de662c7a49b5fe8dbcf8f6f5818d2d81ed852b" - integrity sha512-eE/hvMs7qw7DlcB5JPRnthmrITuHMmACUJAp89v6PT6iOqzoLS7HRWhBtuHMlhNHo2AhUSA/3Dh1bKNJHcublQ== +configstore@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/configstore/-/configstore-5.0.1.tgz#d365021b5df4b98cdd187d6a3b0e3f6a7cc5ed96" + integrity sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA== dependencies: - dot-prop "^5.1.0" + dot-prop "^5.2.0" graceful-fs "^4.1.2" make-dir "^3.0.0" unique-string "^2.0.0" @@ -4400,6 +4400,18 @@ copy-webpack-plugin@^5.0.2: serialize-javascript "^2.1.2" webpack-log "^2.0.0" +copyfiles@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/copyfiles/-/copyfiles-2.2.0.tgz#d9fc6c06f299337fb7eeb7ea5887e9d7188d9d47" + integrity sha512-iJbHJI+8OKqsq+4JF0rqgRkZzo++jqO6Wf4FUU1JM41cJF6JcY5968XyF4tm3Kkm7ZOMrqlljdm8N9oyY5raGw== + dependencies: + glob "^7.0.5" + minimatch "^3.0.3" + mkdirp "^0.5.1" + noms "0.0.0" + through2 "^2.0.1" + yargs "^13.2.4" + core-js-compat@^3.6.2: version "3.6.4" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.6.4.tgz#938476569ebb6cda80d339bcf199fae4f16fff17" @@ -5249,14 +5261,14 @@ dot-prop@^3.0.0: dependencies: is-obj "^1.0.0" -dot-prop@^4.1.1, dot-prop@^4.2.0: +dot-prop@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ== dependencies: is-obj "^1.0.0" -dot-prop@^5.1.0: +dot-prop@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.2.0.tgz#c34ecc29556dc45f1f4c22697b6f4904e0cc4fcb" integrity sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A== @@ -5296,10 +5308,10 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= -electron-to-chromium@^1.3.341: - version "1.3.349" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.349.tgz#663f26a69d348a462df47b4d7ab162a2f29bbcb7" - integrity sha512-uEb2zs6EJ6OZIqaMsCSliYVgzE/f7/s1fLWqtvRtHg/v5KBF2xds974fUnyatfxIDgkqzQVwFtam5KExqywx0Q== +electron-to-chromium@^1.3.349: + version "1.3.352" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.352.tgz#f0fc1e561104dbfba55cb3d45cad3626dc75d7e9" + integrity sha512-dL/RyoueFG3UMhG0q3weAQvr+Tbqx/axAnOXYIIOsoYnV+2i+nRvX2S6msEo2+JARbBP8MFkkSYQ8AoY9Bh4Og== elliptic@^6.0.0, elliptic@^6.5.2: version "6.5.2" @@ -5492,6 +5504,11 @@ es6-weak-map@^2.0.2: es6-iterator "^2.0.3" es6-symbol "^3.1.1" +escape-goat@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675" + integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q== + escape-html@^1.0.3, escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -5702,9 +5719,9 @@ esprima@4.0.1, esprima@^4.0.0, esprima@^4.0.1: integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== esquery@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" - integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== + version "1.1.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.1.0.tgz#c5c0b66f383e7656404f86b31334d72524eddb48" + integrity sha512-MxYW9xKmROWF672KqjO75sszsA8Mxhw06YFeS5VHlB98KDHbOSurm3ArsjO60Eaf3QmGMCP1yn+0JQkNLo/97Q== dependencies: estraverse "^4.0.0" @@ -6022,9 +6039,9 @@ figures@^2.0.0: escape-string-regexp "^1.0.5" figures@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.1.0.tgz#4b198dd07d8d71530642864af2d45dd9e459c4ec" - integrity sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg== + version "3.2.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" + integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== dependencies: escape-string-regexp "^1.0.5" @@ -7773,6 +7790,11 @@ is-yarn-global@^0.3.0: resolved "https://registry.yarnpkg.com/is-yarn-global/-/is-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232" integrity sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw== +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= + isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -8791,9 +8813,9 @@ make-dir@^2.0.0, make-dir@^2.1.0: semver "^5.6.0" make-dir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.0.0.tgz#1b5f39f6b9270ed33f9f054c5c0f84304989f801" - integrity sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw== + version "3.0.2" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.0.2.tgz#04a1acbf22221e1d6ef43559f43e05a90dbb4392" + integrity sha512-rYKABKutXa6vXTXhoV18cBE7PaewPXHe/Bdq4v+ZLMhxbWApkFFplT0LcbMW+6BbjnQXzZ/sAvSE/JdguApG5w== dependencies: semver "^6.0.0" @@ -9157,7 +9179,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: +minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== @@ -9520,7 +9542,7 @@ node-notifier@^6.0.0: shellwords "^0.1.1" which "^1.3.1" -node-releases@^1.1.47: +node-releases@^1.1.49: version "1.1.49" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.49.tgz#67ba5a3fac2319262675ef864ed56798bb33b93e" integrity sha512-xH8t0LS0disN0mtRCh+eByxFPie+msJUBL/lJDBuap53QGiYPa9joh83K4pCZgWJ+2L4b9h88vCVdXQ60NO2bg== @@ -9534,6 +9556,14 @@ node-source-walk@^4.0.0, node-source-walk@^4.2.0: dependencies: "@babel/parser" "^7.0.0" +noms@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859" + integrity sha1-2o69nzr51nYJGbJ9nNyAkqczKFk= + dependencies: + inherits "^2.0.1" + readable-stream "~1.0.31" + nopt@1.0.10: version "1.0.10" resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee" @@ -10680,11 +10710,11 @@ postcss-safe-parser@^4.0.1: postcss "^7.0.26" postcss-selector-parser@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-3.1.1.tgz#4f875f4afb0c96573d5cf4d74011aee250a7e865" - integrity sha1-T4dfSvsMllc9XPTXQBGu4lCn6GU= + version "3.1.2" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-3.1.2.tgz#b310f5c4c0fdaf76f94902bbaa30db6aa84f5270" + integrity sha512-h7fJ/5uWuRVyOtkO45pnt1Ih40CEleeyCHzipqAZO2e5H20g25Y48uYnFUiShvY4rZWNJ/Bib/KVPmanaCtOhA== dependencies: - dot-prop "^4.1.1" + dot-prop "^5.2.0" indexes-of "^1.0.1" uniq "^1.0.1" @@ -10868,12 +10898,12 @@ promise-retry@^1.1.1: retry "^0.10.0" prompts@^2.0.1: - version "2.3.0" - resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.3.0.tgz#a444e968fa4cc7e86689a74050685ac8006c4cc4" - integrity sha512-NfbbPPg/74fT7wk2XYQ7hAIp9zJyZp5Fu19iRbORqqy1BhtrkZ0fPafBU+7bmn8ie69DpT0R6QpJIN2oisYjJg== + version "2.3.1" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.3.1.tgz#b63a9ce2809f106fa9ae1277c275b167af46ea05" + integrity sha512-qIP2lQyCwYbdzcqHIUi2HAxiWixhoM9OdLCWf8txXsapC/X9YdsCoeyRIXE/GP+Q0J37Q7+XN/MFqbUa7IzXNA== dependencies: kleur "^3.0.3" - sisteransi "^1.0.3" + sisteransi "^1.0.4" promzard@^0.3.0: version "0.3.0" @@ -10988,6 +11018,13 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +pupa@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.0.1.tgz#dbdc9ff48ffbea4a26a069b6f9f7abb051008726" + integrity sha512-hEJH0s8PXLY/cdXh66tNEQGndDrIKNqNC5xmrysZy3i5C3oEoLna7YAOad+7u125+zH1HNXUmGEkrhb3c2VriA== + dependencies: + escape-goat "^2.0.0" + q@^1.1.2, q@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" @@ -11194,14 +11231,24 @@ read@1, read@~1.0.1: util-deprecate "~1.0.1" "readable-stream@2 || 3", readable-stream@^3.0.2, readable-stream@^3.0.6, readable-stream@^3.1.1: - version "3.5.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.5.0.tgz#465d70e6d1087f6162d079cd0b5db7fbebfd1606" - integrity sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA== + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== dependencies: inherits "^2.0.3" string_decoder "^1.1.1" util-deprecate "^1.0.1" +readable-stream@~1.0.31: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + readdir-scoped-modules@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.1.0.tgz#8d45407b4f870a0dcaebc0e28670d18e74514309" @@ -11352,9 +11399,9 @@ regjsgen@^0.5.0: integrity sha512-5qxzGZjDs9w4tzT3TPhCJqWdCc3RLYwy9J2NB0nm5Lz+S273lvWcpjaTGHsT1dc6Hhfq41uSEOw8wBmxrKOuyg== regjsparser@^0.6.0: - version "0.6.2" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.2.tgz#fd62c753991467d9d1ffe0a9f67f27a529024b96" - integrity sha512-E9ghzUtoLwDekPT0DYCp+c4h+bvuUpe6rRHCTYn6eGoqj1LgKXxT6I0Il4WbjhQkOghzi/V+y03bPKvbllL93Q== + version "0.6.3" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.3.tgz#74192c5805d35e9f5ebe3c1fb5b40d40a8a38460" + integrity sha512-8uZvYbnfAtEm9Ab8NTb3hdLwL4g/LQzEYP7Xs27T96abJCCE2d6r3cPZPQEsLKy0vRSGVNG+/zVGtLr86HQduA== dependencies: jsesc "~0.5.0" @@ -11916,7 +11963,7 @@ simple-swizzle@^0.2.2: dependencies: is-arrayish "^0.3.1" -sisteransi@^1.0.3: +sisteransi@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.4.tgz#386713f1ef688c7c0304dc4c0632898941cad2e3" integrity sha512-/ekMoM4NJ59ivGSfKapeG+FWtrmWvA1p6FBZwXrqojw90vJu8lBmrTxCMuBCydKtkaUe2zt4PlxeTKpjwMbyig== @@ -12336,6 +12383,11 @@ string_decoder@^1.0.0, string_decoder@^1.1.1: dependencies: safe-buffer "~5.2.0" +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= + string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -12690,7 +12742,7 @@ throat@^5.0.0: resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b" integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA== -through2@^2.0.0, through2@^2.0.2: +through2@^2.0.0, through2@^2.0.1, through2@^2.0.2: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== @@ -12980,9 +13032,9 @@ typedoc-plugin-no-inherit@^1.1.10: integrity sha512-BhSFAWlBTh9Bf6PSfruIqdQBM8gd/Gj8hVuRk5pVWkHu4I/SB24LzFr5gAo52ZlaQSeN72+VOkkRD6tNYl8Enw== typedoc@^0.16.9: - version "0.16.9" - resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.16.9.tgz#d6f46f4dea7d3362029927a92981efdf896f435b" - integrity sha512-UvOGoy76yqwCXwxPgatwgXWfsQ3FczyZ6ZNLjhCPK+TsDir6LiU3YB6N9XZmPv36E+7LA860mnc8a0v6YADKFw== + version "0.16.10" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.16.10.tgz#217cd4243c9b4d85f49b94323c178f6d279bfb9c" + integrity sha512-Eo1+K+XTiqSi4lz5cPrV4RncLv6abjCd/jfL5tTueNZGO2p8x2yDIrXkxL9C+SoLjJm2xpMs3CXYmTnilxk1cA== dependencies: "@types/minimatch" "3.0.3" fs-extra "^8.1.0" @@ -13137,13 +13189,13 @@ upath@^1.1.0, upath@^1.1.1, upath@^1.2.0: integrity sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg== update-notifier@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.0.0.tgz#f344a6f8b03e00e31b323d632a0e632e9f0e0654" - integrity sha512-p9zf71hWt5GVXM4iEBujpUgx8mK9AWiCCapEJm/O1z5ntCim83Z1ATqzZFBHFYqx03laMqv8LiDgs/7ikXjf/g== + version "4.1.0" + resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.0.tgz#4866b98c3bc5b5473c020b1250583628f9a328f3" + integrity sha512-w3doE1qtI0/ZmgeoDoARmI5fjDoT93IfKgEGqm26dGUOh8oNpaSTsGNdYRN/SjOuo10jcJGwkEL3mroKzktkew== dependencies: boxen "^4.2.0" chalk "^3.0.0" - configstore "^5.0.0" + configstore "^5.0.1" has-yarn "^2.1.0" import-lazy "^2.1.0" is-ci "^2.0.0" @@ -13151,6 +13203,7 @@ update-notifier@^4.0.0: is-npm "^4.0.0" is-yarn-global "^0.3.0" latest-version "^5.0.0" + pupa "^2.0.1" semver-diff "^3.1.1" xdg-basedir "^4.0.0" @@ -13906,7 +13959,7 @@ yargs-parser@^11.1.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^13.1.0: +yargs-parser@^13.1.0, yargs-parser@^13.1.1: version "13.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0" integrity sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ== @@ -13965,6 +14018,22 @@ yargs@13.2.4: y18n "^4.0.0" yargs-parser "^13.1.0" +yargs@^13.2.4: + version "13.3.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.0.tgz#4c657a55e07e5f2cf947f8a366567c04a0dedc83" + integrity sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.1" + yargs@^14.2.2: version "14.2.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.2.tgz#2769564379009ff8597cdd38fba09da9b493c4b5"