-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpanax-cli-file
68 lines (58 loc) · 1.61 KB
/
panax-cli-file
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
#!/usr/bin/env node
var chalk = require('chalk');
var program = require('commander');
var path = require('path');
var fs = require('fs');
var exec = require('child_process').exec;
program
.usage('<file.js>')
.parse(process.argv);
if (!process.argv.slice(2).length) {
program.help();
}
// Require JSON Config
var jsonPath = path.join(__dirname, program.args[0]);
var json = require(jsonPath);
// if (!json.config) {
// console.error(chalk.red('Error: No config found!'));
// process.exit(1);
// }
/**
* PanaxJS call
*/
// var Panax = require('panaxjs');
// var panax_config = require('./config/panax');
// var oPanax = new Panax(panax_config);
console.log('Applying Panax configuration from ' + chalk.bold.blue(jsonPath) + ':');
// Apply config if present
if (json.config) {
for(var ent in json.config) {
for(var col in json.config[ent]) {
for(var prop in json.config[ent][col]) {
// Dup from panax-cli-config-add
// oPanax.tableConfig(args, function (err, response) {
// if(err) {
// console.error(chalk.red('Error: ') + err);
// process.exit(1);
// }
console.log(chalk.bold.green('ADD') + ':\t' +
chalk.bold.white('\'' + ent + '\'') + ', ' +
chalk.blue('\'' + col + '\'') + ', ' +
chalk.cyan('\'' + prop + '\'') + ', ' +
'\'' + json.config[ent][col][prop] + '\''
);
// });
}
}
}
}
// Clear cache if present
if (json.clearCache) {
if(json.clearCache==='all') {
for(var ent in json.config) {
// ToDo: clearCache json.config[ent]
}
} else if (typeof(json.clearCache)==='array') {
// ToDo: Clear configuration for array of individual entities
}
}