diff options
Diffstat (limited to 'packages/abi-gen/src')
-rw-r--r-- | packages/abi-gen/src/globals.d.ts | 7 | ||||
-rw-r--r-- | packages/abi-gen/src/index.ts | 17 | ||||
-rw-r--r-- | packages/abi-gen/src/monorepo_scripts/postpublish.ts | 8 | ||||
-rw-r--r-- | packages/abi-gen/src/utils.ts | 3 |
4 files changed, 24 insertions, 11 deletions
diff --git a/packages/abi-gen/src/globals.d.ts b/packages/abi-gen/src/globals.d.ts index 39df3f852..d267a4106 100644 --- a/packages/abi-gen/src/globals.d.ts +++ b/packages/abi-gen/src/globals.d.ts @@ -2,3 +2,10 @@ declare function toSnakeCase(str: string): string; declare module 'to-snake-case' { export = toSnakeCase; } + +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 7c29f7d1d..8932e4045 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node +import { logUtils } from '@0xproject/utils'; import chalk from 'chalk'; import * as fs from 'fs'; import { sync as globSync } from 'glob'; @@ -62,7 +63,7 @@ const args = yargs function registerPartials(partialsGlob: string) { const partialTemplateFileNames = globSync(partialsGlob); - utils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`); + logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`); for (const partialTemplateFileName of partialTemplateFileNames) { const namedContent = utils.getNamedContent(partialTemplateFileName); Handlebars.registerPartial(namedContent.name, namedContent.content); @@ -77,7 +78,7 @@ function writeOutputFile(name: string, renderedTsCode: string): void { } const filePath = `${args.output}/${fileName}.ts`; fs.writeFileSync(filePath, renderedTsCode); - utils.log(`Created: ${chalk.bold(filePath)}`); + logUtils.log(`Created: ${chalk.bold(filePath)}`); } Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend)); @@ -91,17 +92,17 @@ const template = Handlebars.compile<ContextData>(mainTemplate.content); const abiFileNames = globSync(args.abis); if (_.isEmpty(abiFileNames)) { - utils.log(`${chalk.red(`No ABI files found.`)}`); - utils.log(`Please make sure you've passed the correct folder name and that the files have + logUtils.log(`${chalk.red(`No ABI files found.`)}`); + logUtils.log(`Please make sure you've passed the correct folder name and that the files have ${chalk.bold('*.json')} extensions`); process.exit(1); } else { - utils.log(`Found ${chalk.green(`${abiFileNames.length}`)} ${chalk.bold('ABI')} files`); + logUtils.log(`Found ${chalk.green(`${abiFileNames.length}`)} ${chalk.bold('ABI')} files`); mkdirp.sync(args.output); } for (const abiFileName of abiFileNames) { const namedContent = utils.getNamedContent(abiFileName); - utils.log(`Processing: ${chalk.bold(namedContent.name)}...`); + logUtils.log(`Processing: ${chalk.bold(namedContent.name)}...`); const parsedContent = JSON.parse(namedContent.content); let ABI; if (_.isArray(parsedContent)) { @@ -112,8 +113,8 @@ for (const abiFileName of abiFileNames) { ABI = parsedContent.networks[args.networkId].abi; // 0x contracts package artifact } if (_.isUndefined(ABI)) { - utils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`); - utils.log( + logUtils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`); + logUtils.log( `Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x deployer artifact`, ); process.exit(1); diff --git a/packages/abi-gen/src/monorepo_scripts/postpublish.ts b/packages/abi-gen/src/monorepo_scripts/postpublish.ts new file mode 100644 index 000000000..dcb99d0f7 --- /dev/null +++ b/packages/abi-gen/src/monorepo_scripts/postpublish.ts @@ -0,0 +1,8 @@ +import { postpublishUtils } from '@0xproject/monorepo-scripts'; + +import * as packageJSON from '../package.json'; +import * as tsConfigJSON from '../tsconfig.json'; + +const cwd = `${__dirname}/..`; +// tslint:disable-next-line:no-floating-promises +postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/abi-gen/src/utils.ts b/packages/abi-gen/src/utils.ts index 3e4ff619a..c4520ade0 100644 --- a/packages/abi-gen/src/utils.ts +++ b/packages/abi-gen/src/utils.ts @@ -73,9 +73,6 @@ export const utils = { isObjectType(tsType: string): boolean { return /^{.*}$/.test(tsType); }, - log(...args: any[]): void { - console.log(...args); // tslint:disable-line:no-console - }, getPartialNameFromFileName(filename: string): string { const name = path.parse(filename).name; return name; |