Merge pull request #1862 from gilmoskowitz/i24559_xtlocks
[xtuple] / scripts / build_app.js
1 #!/usr/bin/env node
2
3 /*jshint node:true, indent:2, curly:false, eqeqeq:true, immed:true, latedef:true, newcap:true, noarg:true,
4 regexp:true, undef:true, strict:true, trailing:true, white:true */
5 /*global _:true */
6
7 //
8 // This file really just parses the arguments, and sends the real work
9 // off to scripts/lib/build_all.js.
10 //
11
12 (function () {
13   "use strict";
14
15   var program = require('commander'),
16     build = require("./lib/build_all").build;
17
18   program
19     .option('-b, --backup [/path/to/the.backup]', 'Location of database backup file. Must be used with the -i flag.')
20     .option('-c, --config [/path/to/alternate_config.js]', 'Location of datasource config file. [config.js]')
21     .option('-d, --database [database name]', 'Use specific database. [All databases in config file.]')
22     .option('-e, --extension [/path/to/extension]', 'Extension to build. [Core plus all extensions registered for the database.]')
23     .option('-f, --frozen', 'Apply frozen scripts for first-time foundation extension installs.')
24     .option('-i, --initialize', 'Initialize database. Must be used with the -b or -s flag.')
25     .option('-k, --keepsql', 'Do not delete the temporary sql files that represent the payload of the build.')
26     .option('-p, --populate', 'Populate data.')
27     .option('-q, --quick', 'Quicken install by not dropping the views pre-emptively.')
28     .option('-s, --source [/path/to/source_data.sql]', 'Location of source data. Must be used with the -i flag.')
29     .option('-u, --unregister', 'Unregister an extension.')
30     .option('-y, --clientonly', 'Only rebuild the client.')
31     .option('-z, --databaseonly', 'Only rebuild the database.')
32     .parse(process.argv);
33
34   build({
35     backup: program.backup,
36     config: program.config,
37     database: program.database,
38     extension: program.extension,
39     frozen: program.frozen,
40     initialize: program.initialize,
41     keepSql: program.keepsql,
42     populateData: program.populate,
43     source: program.source,
44     unregister: program.unregister,
45     wipeViews: !program.quick && !program.extension,
46     clientOnly: program.clientonly,
47     databaseOnly: program.databaseonly
48   }, function (err, res) {
49     console.log(err || res || "Success!");
50     process.exit(err ? 1 : 0);
51   });
52
53 }());