-
Notifications
You must be signed in to change notification settings - Fork 73
/
app.js
114 lines (83 loc) · 3.54 KB
/
app.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var
path = require('path'),
fs = require('fs'),
config = require('./config.js'),
fn = require('./fn.js'),
exec = require('child_process').exec;
;
// Validations
fn.validatePackages(config.objects.packages);
// Parameters
var params = fn.getParameters();
// Generate Data
fn.generateDataOosUtilValues();
// Create Synonyms Script
fn.createSynonymScript(config);
fn.createGrantScript(config);
// Clear files
for (file in config.files){
if (file !== 'createSynonyms' && file !== 'createGrants'){
fn.writeFile(config.files[file], '');
}
}
console.log('*** Generating Install File ***');
fn.appendFile(config.files.install,`
-- DO NOT MODIFY THIS FILE. IT IS AUTO GENERATED
set define off
prompt *** OOS_UTILS ***
`
);
fn.appendFile(config.files.install,'prompt *** Prereqs OOS_UTILS ***\n');
for (script in config.preInstall){
fn.appendFile(files.install, fn.readFile(config.preInstall[script]));
}//config.objects.preInstall
fn.appendFile(config.files.install,'\n');
fn.appendFile(config.files.install,'prompt *** Installing OOS_UTILS ***\n\n\n');
fn.appendFile(config.files.install,'prompt *** TABLES ***\n');
for (table in config.objects.tables){
fn.appendFile(files.install, `prompt ${table}\n`);
fn.appendFile(files.install, fn.readFile(config.objects.tables[table].src));
}//tables
fn.appendFile(config.files.install,'prompt *** PACKAGES ***\n');
var packageSpecContent;
for (package in config.objects.packages){
fn.appendFile(config.files.install, `prompt ${package}`);
packageSpecContent = fn.readFile(config.objects.packages[package].pks);
// #58 update version numbers
packageSpecContent = packageSpecContent.replace(/(gc_version_major constant pls_integer :=\s*)(.*)/, `$1${params.version.major};`);
packageSpecContent = packageSpecContent.replace(/(gc_version_minor constant pls_integer :=\s*)(.*)/, `$1${params.version.minor};`);
packageSpecContent = packageSpecContent.replace(/(gc_version_patch constant pls_integer :=\s*)(.*)/, `$1${params.version.patch};`);
fn.appendFile(files.install, packageSpecContent);
fn.appendFile(files.install, fn.readFile(config.objects.packages[package].pkb));
}//packages
fn.appendFile(config.files.install,'\n\nprompt *** Post Install ***\n');
for (script in config.postInstall){
fn.appendFile(files.install, fn.readFile(config.postInstall[script]));
}//config.objects.postInstall
fn.appendFile(config.files.install,'\n\nprompt *** Data ***\n');
for (myData in config.objects.data){
fn.appendFile(config.files.install,'prompt ' + myData);
fn.appendFile(files.install, fn.readFile(config.objects.data[myData].src));
}
console.log('*** Generating Uninstall File ***');
fn.appendFile(config.files.uninstall,'prompt *** Uninstalling OOS_UTILS ***\n\n\n');
fn.appendFile(config.files.uninstall,'prompt *** TABLES ***\n');
for (table in config.objects.tables){
fn.appendFile(files.uninstall, 'prompt ' + table);
fn.appendFile(files.uninstall, config.objects.tables[table].uninstall);
}//tables
fn.appendFile(config.files.uninstall,'\n\nprompt *** PACKAGES ***\n');
for (package in config.objects.packages){
fn.appendFile(files.uninstall, `prompt ${package}`);
fn.appendFile(files.uninstall, `drop package ${package};\n`);
}//packages
// Generate Documentation
// Future make htis generic for others to use (not just martin) - #59
var cmd = 'node ~/Documents/GitHub/oraopensource/plsql-md-doc/app oos-utils';
console.log(`*** Generating Documentation ***`);
exec(cmd, function(error, stdout, stderr) {
// command output is in stdout
if (error !== null) {
console.log(`Error: ${error}`);
}
});