Augment naming

This commit is contained in:
Jaco Greeff
2020-02-23 12:48:01 +01:00
parent 1fd157364b
commit 553b3df0b2
4 changed files with 9 additions and 10 deletions
+5 -7
View File
@@ -2,7 +2,6 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import fs from 'fs';
import path from 'path';
import yargs from 'yargs';
import getWSClass from '@polkadot/rpc-provider/ws/getWSClass';
@@ -21,18 +20,17 @@ function generate (metaHex: string, pkg: string | undefined, output: string, isS
const extraTypes = pkg
? { [pkg]: require(path.join(process.cwd(), output, 'definitions')) }
: {};
const hasRegistry = fs.existsSync(path.join(process.cwd(), output, 'augment-types.ts'));
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);
generateConst(path.join(process.cwd(), output, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict);
generateQuery(path.join(process.cwd(), output, 'augment-api-query.ts'), metaHex, extraTypes, isStrict);
generateTx(path.join(process.cwd(), output, 'augment-api-tx.ts'), metaHex, extraTypes, isStrict);
writeFile(path.join(process.cwd(), output, 'augment.ts'), (): string =>
writeFile(path.join(process.cwd(), output, 'augment-api.ts'), (): string =>
[
HEADER,
...[
'@polkadot/api/augment/rpc',
...['consts', 'query', hasRegistry ? 'types' : '', 'tx'].filter((key) => !!key).map((key) => `./augment-${key}`)
...['consts', 'query', 'tx'].filter((key) => !!key).map((key) => `./augment-api-${key}`)
].map((path) => `import '${path}';\n`)
].join('')
);