-
Notifications
You must be signed in to change notification settings - Fork 0
/
abiniser.js
70 lines (57 loc) · 2.56 KB
/
abiniser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
'use strict';
const pjson = require('./package.json');
const program = require('commander');
const generate = require('./lib/generate.js');
const removeSourceEntries = require('./lib/removeSourceEntries.js');
const checkIntegrity = require('./lib/checkIntegrity.js');
function help() {
console.log(
`
More info: https://github.com/Augmint/abiniser
Examples:
abiniser generate
Creates abi and deployments jsons from all truffle contract json files listed in abiniser.json config file
`
);
}
program.version(pjson.version).description(pjson.description);
program
.command('generate')
.description('Generate deployment and abi files from Truffle generated JSON files')
.alias('gen')
.option('-c, --config-file [value]', 'Sets abiniser config file.', './abiniser.json')
.option('-a, --abi-output-dir [value]', 'Sets abi output directory.', './abiniser/abis')
.option('-d, --deployments-output-dir [value]', 'Sets deployments output directory.', './abiniser/deployments')
.option('-n, --network-id [value]', 'Generate deployments file only for the given network id number')
.option('-i, --input-dir [value]', 'Sets input directory with truffle contract json files.', './build/contracts')
.option('-r, --regenerate', 'Regenerate abi and deploy files even if they exists with same abi hash', false)
.option('-s, --source-include', 'Include contract source in generated deploy file', false)
.action(options => generate(options));
program
.command('removeSourceEntries')
.alias('removeSrc')
.description('remove source entries from all deployment files')
.option(
'-d, --deployments-output-dir [value]',
'Sets deployments output directory to work on.',
'./abiniser/deployments'
)
.action(options => removeSourceEntries(options));
program
.command('check')
.description('Basic integrity check of files generated. Checks references between Abi files and deployment files')
.option('-a, --abi-output-dir [value]', 'Sets abi output directory to work on.', './abiniser/abis')
.option(
'-d, --deployments-output-dir [value]',
'Sets deployments output directory to work on.',
'./abiniser/deployments'
)
.action(options => checkIntegrity(options));
program.on('--help', () => help());
program.on('command:*', () => {
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
});
program.parse(process.argv);
console.log(`
${pjson.name} v${pjson.version} - ${pjson.description}`);