aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/contract_templates/contract.handlebars (renamed from packages/0x.js/contract_templates/contract.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/call.handlebars (renamed from packages/0x.js/contract_templates/partials/call.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/params.handlebars (renamed from packages/0x.js/contract_templates/partials/params.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/return_type.handlebars (renamed from packages/0x.js/contract_templates/partials/return_type.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/tx.handlebars (renamed from packages/0x.js/contract_templates/partials/tx.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/typed_params.handlebars (renamed from packages/0x.js/contract_templates/partials/typed_params.mustache)0
-rw-r--r--packages/0x.js/package.json2
-rw-r--r--packages/abi-gen/CHANGELOG.md3
-rw-r--r--packages/abi-gen/src/index.ts52
9 files changed, 39 insertions, 18 deletions
diff --git a/packages/0x.js/contract_templates/contract.mustache b/packages/0x.js/contract_templates/contract.handlebars
index d3fe1b8cc..d3fe1b8cc 100644
--- a/packages/0x.js/contract_templates/contract.mustache
+++ b/packages/0x.js/contract_templates/contract.handlebars
diff --git a/packages/0x.js/contract_templates/partials/call.mustache b/packages/0x.js/contract_templates/partials/call.handlebars
index 0475136f0..0475136f0 100644
--- a/packages/0x.js/contract_templates/partials/call.mustache
+++ b/packages/0x.js/contract_templates/partials/call.handlebars
diff --git a/packages/0x.js/contract_templates/partials/params.mustache b/packages/0x.js/contract_templates/partials/params.handlebars
index ac5d4ae85..ac5d4ae85 100644
--- a/packages/0x.js/contract_templates/partials/params.mustache
+++ b/packages/0x.js/contract_templates/partials/params.handlebars
diff --git a/packages/0x.js/contract_templates/partials/return_type.mustache b/packages/0x.js/contract_templates/partials/return_type.handlebars
index 383961a40..383961a40 100644
--- a/packages/0x.js/contract_templates/partials/return_type.mustache
+++ b/packages/0x.js/contract_templates/partials/return_type.handlebars
diff --git a/packages/0x.js/contract_templates/partials/tx.mustache b/packages/0x.js/contract_templates/partials/tx.handlebars
index 9df83266a..9df83266a 100644
--- a/packages/0x.js/contract_templates/partials/tx.mustache
+++ b/packages/0x.js/contract_templates/partials/tx.handlebars
diff --git a/packages/0x.js/contract_templates/partials/typed_params.mustache b/packages/0x.js/contract_templates/partials/typed_params.handlebars
index 3ea4b2e95..3ea4b2e95 100644
--- a/packages/0x.js/contract_templates/partials/typed_params.mustache
+++ b/packages/0x.js/contract_templates/partials/typed_params.handlebars
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 9cce372a5..32063aab2 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -12,7 +12,7 @@
"upload_docs_json":
"aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
"generate_contract_wrappers":
- "node ../abi-gen/lib/index.js --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --templates contract_templates --output src/contract_wrappers/generated",
+ "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template contract_templates/contract.handlebars --partials 'contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "run-s test:coverage report_test_coverage",
"test": "run-s clean test:commonjs",
diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md
index fb2c6eb24..9247b315a 100644
--- a/packages/abi-gen/CHANGELOG.md
+++ b/packages/abi-gen/CHANGELOG.md
@@ -1,5 +1,8 @@
# CHANGELOG
+## v0.2.0 - _???_
+* Added CLI options for explicit specifying location of partials and main template (#346)
+
## v0.1.0 - _January 11, 2018_
* Fixed array typings with union types (#295)
diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts
index 527af32b1..5412d11ce 100644
--- a/packages/abi-gen/src/index.ts
+++ b/packages/abi-gen/src/index.ts
@@ -17,24 +17,43 @@ import { utils } from './utils';
const ABI_TYPE_CONSTRUCTOR = 'constructor';
const ABI_TYPE_METHOD = 'function';
const ABI_TYPE_EVENT = 'event';
-const MAIN_TEMPLATE_NAME = 'contract.mustache';
const args = yargs
- .option('abiGlob', {
+ .option('abis', {
describe: 'Glob pattern to search for ABI JSON files',
type: 'string',
- demand: true,
- })
- .option('templates', {
- describe: 'Folder where to search for templates',
- type: 'string',
- demand: true,
+ demandOption: true,
})
.option('output', {
+ alias: ['o', 'out'],
describe: 'Folder where to put the output files',
type: 'string',
- demand: true,
- }).argv;
+ normalize: true,
+ demandOption: true,
+ })
+ .option('partials', {
+ describe: 'Glob pattern for the partial template files',
+ type: 'string',
+ implies: 'template',
+ })
+ .option('template', {
+ describe: 'Path for the main template file that will be used to generate each contract',
+ type: 'string',
+ demandOption: true,
+ normalize: true,
+ })
+ .example("$0 --abis 'src/artifacts/**/*.json' --out 'src/contracts/generated/' --partials 'src/templates/partials/**/*.handlebars' --template 'src/templates/contract.handlebars'", 'Full usage example')
+ .argv;
+
+function registerPartials(partialsGlob: string) {
+ const partialTemplateFileNames = globSync(partialsGlob);
+ utils.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);
+ }
+ return partialsGlob;
+}
function writeOutputFile(name: string, renderedTsCode: string): void {
const fileName = toSnakeCase(name);
@@ -45,15 +64,14 @@ function writeOutputFile(name: string, renderedTsCode: string): void {
Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input));
Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output));
-const partialTemplateFileNames = globSync(`${args.templates}/partials/**/*.mustache`);
-for (const partialTemplateFileName of partialTemplateFileNames) {
- const namedContent = utils.getNamedContent(partialTemplateFileName);
- Handlebars.registerPartial(namedContent.name, namedContent.content);
-}
-const mainTemplate = utils.getNamedContent(`${args.templates}/${MAIN_TEMPLATE_NAME}`);
+if (args.partials) {
+ registerPartials(args.partials);
+}
+const mainTemplate = utils.getNamedContent(args.template);
const template = Handlebars.compile<ContextData>(mainTemplate.content);
-const abiFileNames = globSync(args.abiGlob);
+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