profoundjs 6.0.0-beta.2 → 6.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -0
- package/package.json +8 -9
- package/profound.jse +1 -1
- package/setup/complete_install.js +405 -0
- package/setup/config.js +1 -1
- package/setup/install.js +148 -0
- package/setup/install_utils.js +123 -0
- package/setup/modules/puiscreens.json +23 -25
- package/setup/package.json +2 -2
- package/setup/pjsdist.savf +0 -0
- package/setup/setup.js +498 -866
- package/setup/start.js +12 -1
package/setup/setup.js
CHANGED
|
@@ -1,257 +1,481 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
const pjsBaseInstance = '/profoundjs-base/instances/';
|
|
4
|
-
|
|
5
|
-
const child_process = require('child_process');
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const fse = require('fs-extra');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const extract = require('extract-zip');
|
|
10
|
-
const crypto = require('crypto');
|
|
11
|
-
const os = require('os');
|
|
12
|
-
|
|
13
|
-
var IBMi = (os.type() === 'OS400');
|
|
14
|
-
var setupDir = __dirname;
|
|
15
|
-
var dirSep = path.sep;
|
|
16
|
-
var dirParts = __dirname.split(dirSep);
|
|
17
|
-
while (dirParts.length > 0 && dirParts.pop() !== "node_modules") {};
|
|
18
|
-
if (dirParts.length === 0) {
|
|
19
|
-
console.log("Can't find deployment directory.");
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
var deployDir = dirParts.join(dirSep);
|
|
23
|
-
var silent = process.argv.includes("--silent");
|
|
24
|
-
if (process.env.SILENT_INSTALL) silent = true;
|
|
2
|
+
"use strict";
|
|
25
3
|
|
|
26
|
-
|
|
27
|
-
if (process.env.PORT) portNumber = process.env.PORT;
|
|
4
|
+
/*
|
|
28
5
|
|
|
29
|
-
|
|
30
|
-
var zipFile = setupDir + dirSep + 'htdocs.zip';
|
|
31
|
-
console.log("");
|
|
32
|
-
console.log("Starting Download...")
|
|
33
|
-
console.log("");
|
|
6
|
+
This is NPM script: npm run setup
|
|
34
7
|
|
|
35
|
-
|
|
8
|
+
* Performs additional installation.
|
|
9
|
+
* Kicked off automatically after NPM install if 'config.js' is present in deployment directory.
|
|
10
|
+
* Otherwise kicked off from 'complete_install.js' which is manually run by user.
|
|
11
|
+
* Can also be run directly for advanced/automated installation.
|
|
36
12
|
|
|
37
|
-
|
|
13
|
+
NOTE: Output from this script will be suppressed by NPM 7+ when invoked via 'npm install', unless process ends with non-zero exit code.
|
|
38
14
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const htdocs_download_url = "http://resources.profoundjs.com/profoundui_htdocs.zip";
|
|
18
|
+
|
|
19
|
+
const child_process = require("child_process");
|
|
20
|
+
const compareVersions = require("compare-versions");
|
|
21
|
+
const crypto = require("crypto");
|
|
22
|
+
const extract = require("extract-zip");
|
|
23
|
+
const fs = require("fs-extra");
|
|
24
|
+
const iutils = require("./install_utils.js");
|
|
25
|
+
const os = require("os");
|
|
26
|
+
const minimist = require("minimist");
|
|
27
|
+
const path = require("path");
|
|
28
|
+
const util = require("util");
|
|
29
|
+
const uuidv4 = require("uuid").v4;
|
|
30
|
+
|
|
31
|
+
const IBMi = os.type() === "OS400";
|
|
32
|
+
|
|
33
|
+
const RED = "\x1b[31m";
|
|
34
|
+
const CYAN = "\x1b[36m";
|
|
35
|
+
const RESET = "\x1b[0m";
|
|
36
|
+
|
|
37
|
+
const logDir = path.join(os.tmpdir(), "profoundjs-" + uuidv4());
|
|
38
|
+
const logPath = path.join(logDir, "setup.log");
|
|
39
|
+
let logFile;
|
|
40
|
+
|
|
41
|
+
(async () => {
|
|
42
|
+
try {
|
|
43
|
+
|
|
44
|
+
// Parse arguments.
|
|
45
|
+
const args = minimist(
|
|
46
|
+
process.argv.slice(2),
|
|
47
|
+
{
|
|
48
|
+
alias: {
|
|
49
|
+
"c": "config-file",
|
|
50
|
+
"h": "help"
|
|
55
51
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
boolean: [
|
|
53
|
+
"h",
|
|
54
|
+
"ibmi-connector-library",
|
|
55
|
+
"ibmi-instance-autostart",
|
|
56
|
+
"nodegit",
|
|
57
|
+
"static-files"
|
|
58
|
+
],
|
|
59
|
+
string: [
|
|
60
|
+
"c",
|
|
61
|
+
"ibmi-instance",
|
|
62
|
+
"ibmi-instance-ccsid",
|
|
63
|
+
"ibmi-instance-node-path",
|
|
64
|
+
"nodegit-version"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// Show help and quit, if requested.
|
|
70
|
+
if (args["help"]) {
|
|
71
|
+
const HELP = `Usage: npm run setup -- [OPTION]
|
|
72
|
+
-c, --config-file=<file> Alternate config file.
|
|
73
|
+
-h, --help Print this help and exit.
|
|
74
|
+
--nodegit Install nodegit.
|
|
75
|
+
--nodegit-version=version Override nodegit version.
|
|
76
|
+
--static-files Install static files.
|
|
77
|
+
--ibmi-connector-library Install IBM i Connector library.
|
|
78
|
+
--ibmi-instance=<name> Create/update STRTCPSVR instance config.
|
|
79
|
+
--ibmi-instance-autostart Autostart flag for STRTCPSVR instance.
|
|
80
|
+
--ibmi-instance-ccsid=<ccsid> CCSID for STRTCPSVR instance.
|
|
81
|
+
--ibmi-instance-node-path=<path> Node.js binary path for STRTCPSVR instance.
|
|
82
|
+
|
|
83
|
+
Performs additional installation using config values and CLI options.
|
|
84
|
+
Default config file is <INSTALL_DIRECTORY>/config.js.
|
|
85
|
+
|
|
86
|
+
--config-file can be an absolute path or path relative to working directory.
|
|
87
|
+
--static-files are installed to directory specified in config file.
|
|
88
|
+
--static-files is invalid if directory exists or if a URL is specified.
|
|
89
|
+
--nodegit-version is ignored if --nodegit is not used.
|
|
90
|
+
--nodegit-version can accept an NPM package version, tag, or version range.
|
|
91
|
+
|
|
92
|
+
IBM i-related values are invalid when not installing on IBM i.
|
|
93
|
+
IBM i instance-related values are ignored unless --ibmi-instance is specified.
|
|
94
|
+
|
|
95
|
+
--ibmi-connector-library installs to library specified in config file.
|
|
96
|
+
--ibmi-instance creates STRTCPSVR config, if not already present.
|
|
97
|
+
--ibmi-instance-autostart sets/updates "autostart" in STRTCPSVR config.
|
|
98
|
+
--ibmi-instance-ccsid sets/updates "ccsid" in STRTCPSVR config.
|
|
99
|
+
--ibmi-instance-node-path sets/updates "nodePath" in STRTCPSVR config.
|
|
100
|
+
`;
|
|
101
|
+
console.log(HELP);
|
|
102
|
+
process.exit(0);
|
|
64
103
|
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
104
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (defaultAnswer !== "") {
|
|
79
|
-
var lastChar = question.substr(question.length - 1, 1);
|
|
80
|
-
if (lastChar === ":" || lastChar === "?") {
|
|
81
|
-
question = question.substr(0, question.length - 1) + " (" + defaultAnswer + ")" + lastChar;
|
|
105
|
+
// Initialize log file.
|
|
106
|
+
fs.mkdirSync(logDir);
|
|
107
|
+
logFile = fs.openSync(logPath, "w");
|
|
108
|
+
|
|
109
|
+
// Validate arguments.
|
|
110
|
+
if (args._.length > 0) {
|
|
111
|
+
logError("Unknown argument:", args._[0]);
|
|
112
|
+
die();
|
|
82
113
|
}
|
|
83
|
-
|
|
84
|
-
|
|
114
|
+
|
|
115
|
+
const deployDir = iutils.getDeployDir();
|
|
116
|
+
if (!deployDir) {
|
|
117
|
+
logError("Can't find deployment directory.");
|
|
118
|
+
die();
|
|
85
119
|
}
|
|
86
|
-
}
|
|
87
|
-
question += " ";
|
|
88
120
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
const configPath = args["config-file"] !== undefined ? path.resolve(args["config-file"]) : iutils.getConfigPath();
|
|
122
|
+
if (!fileExists(configPath)) {
|
|
123
|
+
logError(`Configuration file ${configPath} not found.`);
|
|
124
|
+
die();
|
|
125
|
+
}
|
|
126
|
+
const config = require(configPath);
|
|
127
|
+
|
|
128
|
+
if (args["static-files"]) {
|
|
129
|
+
if (typeof config.staticFilesDirectory !== "string") {
|
|
130
|
+
logError("staticFilesDirectory is missing from config or is invalid.");
|
|
131
|
+
die();
|
|
132
|
+
}
|
|
133
|
+
if (/^https?:\/\//i.test(config.staticFilesDirectory)) {
|
|
134
|
+
logError("--static-files is not valid when staticFilesDirectory is a URL.");
|
|
135
|
+
die();
|
|
136
|
+
}
|
|
137
|
+
const staticDir = path.resolve(deployDir, config.staticFilesDirectory);
|
|
138
|
+
let exists = false;
|
|
139
|
+
try {
|
|
140
|
+
fs.statSync(staticDir);
|
|
141
|
+
exists = true;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {}
|
|
144
|
+
if (exists) {
|
|
145
|
+
logError(`staticFilesDirectory ${staticDir} already exists.`);
|
|
146
|
+
die();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (args["ibmi-connector-library"]) {
|
|
150
|
+
if (!IBMi) {
|
|
151
|
+
logError(`--ibmi-connector-library is not valid on ${os.platform()}`);
|
|
152
|
+
die();
|
|
153
|
+
}
|
|
154
|
+
if (typeof config.connectorLibrary !== "string") {
|
|
155
|
+
logError("connectorLibrary is missing from config or is invalid.");
|
|
156
|
+
die();
|
|
157
|
+
}
|
|
158
|
+
let error = iutils.validateIBMiName(config.connectorLibrary);
|
|
159
|
+
if (error) {
|
|
160
|
+
logError("connectorLibrary is invalid: " + error);
|
|
161
|
+
die();
|
|
162
|
+
}
|
|
163
|
+
if (config.connectorIASP !== undefined) {
|
|
164
|
+
error = iutils.validateIBMiIASP(config.connectorIASP);
|
|
165
|
+
if (error) {
|
|
166
|
+
logError("connectorIASP is invalid: " + error);
|
|
167
|
+
die();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (args["ibmi-instance"] !== undefined) {
|
|
172
|
+
if (!IBMi) {
|
|
173
|
+
logError(`--ibmi-instance is not valid on ${os.platform()}`);
|
|
174
|
+
die();
|
|
175
|
+
}
|
|
176
|
+
let error = iutils.validateIBMiName(args["ibmi-instance"]);
|
|
177
|
+
if (error) {
|
|
178
|
+
logError("--ibmi-instance is invalid: " + error);
|
|
179
|
+
die();
|
|
180
|
+
}
|
|
181
|
+
if (args["ibmi-instance-ccsid"] !== undefined) {
|
|
182
|
+
error = iutils.validateIBMiCCSID(parseInt(args["ibmi-instance-ccsid"], 10));
|
|
183
|
+
if (error) {
|
|
184
|
+
logError("--ibmi-instance-ccsid is invalid: " + error);
|
|
185
|
+
die();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (args["ibmi-instance-node-path"] !== undefined) {
|
|
189
|
+
const nodePath = args["ibmi-instance-node-path"].trim();
|
|
190
|
+
if (!fileExists(nodePath)) {
|
|
191
|
+
logError("--ibmi-instance-node-path is invalid: " + nodePath + " does not exist.");
|
|
192
|
+
die();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Install nodegit, if necessary.
|
|
198
|
+
if (args["nodegit"]) {
|
|
199
|
+
let version;
|
|
200
|
+
if (args["nodegit-version"]) {
|
|
201
|
+
version = args["nodegit-version"];
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
// Current stable version of nodegit doesn't have pre-built binaries for Node > 14.
|
|
205
|
+
// If installing on Node > 14, use alpha version with pre-built binaries.
|
|
206
|
+
version = "0.27.0"; // Current stable version.
|
|
207
|
+
if (compareVersions("14.*.*", process.versions.node) === -1) {
|
|
208
|
+
version = "0.28.0-alpha.18";
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
log(`Installing nodegit...`);
|
|
212
|
+
try {
|
|
213
|
+
child_process.execSync(
|
|
214
|
+
`npm install --no-package-lock nodegit@"${version}"`,
|
|
215
|
+
{
|
|
216
|
+
cwd: iutils.getPackageDir(),
|
|
217
|
+
stdio: ["ignore", logFile, logFile]
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
logError("nodegit installation failed.");
|
|
223
|
+
die();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
95
226
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
answer = answer.trim();
|
|
100
|
-
if (typeof validationFunction === "function" && validationFunction(answer) === false) {
|
|
101
|
-
ask(questionParm, defaultAnswer, validationFunction, callback);
|
|
227
|
+
// Create modules directory.
|
|
228
|
+
if (directoryExists(path.join(deployDir, "modules"))) {
|
|
229
|
+
log("modules directory exists.");
|
|
102
230
|
}
|
|
103
231
|
else {
|
|
104
|
-
|
|
232
|
+
log("Creating modules directory.");
|
|
233
|
+
fs.mkdirSync(path.join(deployDir, "modules"));
|
|
105
234
|
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
235
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
exists = false;
|
|
117
|
-
}
|
|
118
|
-
return exists;
|
|
119
|
-
}
|
|
236
|
+
// Grant PROFOUNDJS user all permissions to modules directory tree.
|
|
237
|
+
if (IBMi) {
|
|
238
|
+
runCommand("CHGAUT OBJ('" + deployDir + "') USER(PROFOUNDJS) DTAAUT(*RWX) OBJAUT(*ALL)");
|
|
239
|
+
runCommand("CHGAUT OBJ('" + path.join(deployDir, "modules") + "') USER(PROFOUNDJS) DTAAUT(*RWX) OBJAUT(*ALL) SUBTREE(*ALL)");
|
|
240
|
+
}
|
|
120
241
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
var stat = fs.statSync(dir);
|
|
125
|
-
if (stat && stat.isDirectory()) exists = true;
|
|
126
|
-
}
|
|
127
|
-
catch (err) {
|
|
128
|
-
exists = false;
|
|
129
|
-
}
|
|
130
|
-
return exists;
|
|
131
|
-
}
|
|
242
|
+
// Create puiscreens.json.
|
|
243
|
+
createPuiscreens(deployDir);
|
|
132
244
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
var content = fs.readFileSync(file, type);
|
|
142
|
-
if (typeof process === "function") content = process(content);
|
|
143
|
-
fs.writeFileSync(toFile, content, type);
|
|
144
|
-
}
|
|
245
|
+
// Create puiuplexit.js.
|
|
246
|
+
if (fileExists(path.join(deployDir, "modules", "puiuplexit.js"))) {
|
|
247
|
+
log("puiuplexit.js file exists.");
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
log("Creating puiuplexit.js.");
|
|
251
|
+
copyFile(path.join(__dirname, "modules", "puiuplexit.js"), path.join(deployDir, "modules"), "utf8");
|
|
252
|
+
}
|
|
145
253
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
files = fs.readdirSync(dir);
|
|
151
|
-
files.forEach(function(file, index) {
|
|
152
|
-
if(fs.lstatSync(dir + dirSep + file).isDirectory()) { // recurse
|
|
153
|
-
copyDir(dir + dirSep + file, destinationDir + dirSep + dirName);
|
|
154
|
-
}
|
|
254
|
+
// Create puidnlexit.js.
|
|
255
|
+
if (fileExists(path.join(deployDir, "modules", "puidnlexit.js"))) {
|
|
256
|
+
log("puidnlexit.js file exists.");
|
|
257
|
+
}
|
|
155
258
|
else {
|
|
156
|
-
|
|
259
|
+
log("Creating puidnlexit.js.");
|
|
260
|
+
copyFile(path.join(__dirname, "modules", "puidnlexit.js"), path.join(deployDir, "modules"), "utf8");
|
|
157
261
|
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
262
|
|
|
263
|
+
// Create samples directory.
|
|
264
|
+
if (directoryExists(path.join(deployDir, "modules", "pjssamples"))) {
|
|
265
|
+
fs.removeSync(path.join(deployDir, "modules", "pjssamples"));
|
|
266
|
+
}
|
|
267
|
+
log("Copying pjssamples.");
|
|
268
|
+
copyDir(path.join(__dirname, "modules", "pjssamples"), path.join(deployDir, "modules"));
|
|
161
269
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
270
|
+
// Create store_credentials.js.
|
|
271
|
+
if (fileExists(path.join(deployDir, "store_credentials.js"))) {
|
|
272
|
+
log("store_credentials.js file exists.");
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
copyFile(path.join(__dirname, "store_credentials.js"), deployDir, "utf8");
|
|
276
|
+
log("store_credentials.js created.");
|
|
277
|
+
}
|
|
165
278
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
279
|
+
// Create updatepui.js.
|
|
280
|
+
if (!IBMi) {
|
|
281
|
+
// This file is not needed on IBM i because the proper way to install Profound UI on IBM i is to download the full version from the web site
|
|
282
|
+
if (fileExists(path.join(deployDir, "updatepui.js"))) {
|
|
283
|
+
log("updatepui.js file exists.");
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
copyFile(path.join(__dirname, "updatepui.js"), deployDir, "utf8");
|
|
287
|
+
log("updatepui.js created.");
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Create call.js.
|
|
292
|
+
if (fileExists(path.join(deployDir, "call.js"))) {
|
|
293
|
+
log("call.js file exists.");
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
copyFile(path.join(__dirname, "call.js"), deployDir, "utf8");
|
|
297
|
+
log("call.js created.");
|
|
298
|
+
}
|
|
174
299
|
|
|
175
|
-
|
|
176
|
-
if (fileExists(deployDir + dirSep + "start.js")) {
|
|
177
|
-
console.log("start.js file exists.");
|
|
300
|
+
// Convert start.js to Promises, if necessary.
|
|
178
301
|
const convertStartJS = require("./convertStartJS.js");
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
console.log("start.js file converted to Promises.");
|
|
302
|
+
if (convertStartJS(path.join(deployDir, "start.js"))) {
|
|
303
|
+
log("start.js file converted to Promises.");
|
|
182
304
|
}
|
|
183
|
-
callback();
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
copyFile(setupDir + dirSep + "start.js", deployDir, "utf8");
|
|
187
|
-
console.log("start.js created.");
|
|
188
|
-
callback();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
305
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
306
|
+
// Install Profound UI static files, if necessary.
|
|
307
|
+
if (args["static-files"]) {
|
|
308
|
+
log("");
|
|
309
|
+
log("Downloading Profound UI static files...")
|
|
310
|
+
const profound = require("profoundjs");
|
|
311
|
+
const zipFile = path.join(__dirname, "htdocs.zip");
|
|
312
|
+
const opts = {
|
|
313
|
+
follow_max: 15 // Follow redirects.
|
|
314
|
+
};
|
|
315
|
+
try {
|
|
316
|
+
await profound.utils.download(htdocs_download_url, zipFile, opts, process.stdout.isTTY ? process.stdout : null);
|
|
317
|
+
log("Download completed. Extracting...");
|
|
318
|
+
await extract(zipFile, { dir: path.resolve(deployDir, config.staticFilesDirectory) });
|
|
319
|
+
log("Directory " + config.staticFilesDirectory + " extracted.");
|
|
320
|
+
}
|
|
321
|
+
finally {
|
|
322
|
+
try {
|
|
323
|
+
fs.unlinkSync(zipFile);
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Install native IBM i components, if necessary.
|
|
331
|
+
if (IBMi) {
|
|
332
|
+
log("");
|
|
333
|
+
if (args["ibmi-connector-library"] || args["ibmi-instance"] !== undefined) {
|
|
334
|
+
let portNumber = config.port || 8081;
|
|
335
|
+
let connectorLibrary = "*NONE";
|
|
336
|
+
let connectorIASP;
|
|
337
|
+
if (args["ibmi-connector-library"]) {
|
|
338
|
+
connectorLibrary = config.connectorLibrary;
|
|
339
|
+
connectorIASP = config.connectorIASP || "*SYSBAS";
|
|
340
|
+
}
|
|
341
|
+
let svrname = "*NONE";
|
|
342
|
+
let autostart = true;
|
|
343
|
+
let ccsid = 37;
|
|
344
|
+
let nodePath = process.argv[0];
|
|
345
|
+
if (args["ibmi-instance"] !== undefined) {
|
|
346
|
+
svrname = args["ibmi-instance"].toUpperCase();
|
|
347
|
+
const instances = iutils.getIBMiInstances().filter(instance => instance.name === svrname);
|
|
348
|
+
if (instances.length > 0) {
|
|
349
|
+
const instance = instances[0];
|
|
350
|
+
let opt = getOpt("autostart");
|
|
351
|
+
if (opt) {
|
|
352
|
+
autostart = (opt.value === "1");
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
autostart = false;
|
|
356
|
+
}
|
|
357
|
+
opt = getOpt("ccsid");
|
|
358
|
+
if (opt) {
|
|
359
|
+
ccsid = opt.value;
|
|
360
|
+
}
|
|
361
|
+
opt = getOpt("nodePath");
|
|
362
|
+
if (opt) {
|
|
363
|
+
nodePath = opt.value;
|
|
364
|
+
}
|
|
365
|
+
function getOpt(name) {
|
|
366
|
+
return instance.options.find(opt => opt.name === name);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (process.argv.find(arg => arg.includes("ibmi-instance-autostart"))) { // minimist sets booleans to false if not passed.
|
|
370
|
+
autostart = args["ibmi-instance-autostart"];
|
|
371
|
+
}
|
|
372
|
+
if (args["ibmi-instance-ccsid"] !== undefined) {
|
|
373
|
+
ccsid = args["ibmi-instance-ccsid"];
|
|
374
|
+
}
|
|
375
|
+
if (args["ibmi-instance-node-path"] !== undefined) {
|
|
376
|
+
nodePath = args["ibmi-instance-node-path"];
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// First, try copying the save file
|
|
380
|
+
var success = runCommand("CPYFRMSTMF FROMSTMF('" + __dirname + "/pjsdist.savf') TOMBR('/QSYS.LIB/QGPL.LIB/PJSDIST.FILE') MBROPT(*REPLACE)");
|
|
381
|
+
if (!success) {
|
|
382
|
+
logError("Unable to create installer save file.");
|
|
383
|
+
die();
|
|
384
|
+
}
|
|
385
|
+
// Now, try restoring the PJSINSTALL program
|
|
386
|
+
success = runCommand("RSTOBJ OBJ(PJSINSTALL) SAVLIB(QTEMP) DEV(*SAVF) OBJTYPE(*ALL) SAVF(QGPL/PJSDIST) RSTLIB(QGPL)");
|
|
387
|
+
if (!success) {
|
|
388
|
+
// Clean up save file
|
|
389
|
+
log("");
|
|
390
|
+
log("Cleaning up...");
|
|
391
|
+
runCommand("DLTF FILE(QGPL/PJSDIST)");
|
|
392
|
+
logError("Unable to restore installer save file.");
|
|
393
|
+
die();
|
|
394
|
+
}
|
|
395
|
+
// Now, try running PJSINSTALL
|
|
396
|
+
var command = "QGPL/PJSINSTALL CONNLIB(" + connectorLibrary + ")";
|
|
397
|
+
if (connectorLibrary != "*NONE")
|
|
398
|
+
command += " CONNIASP(" + connectorIASP + ") CONNHOST('localhost') CONNPORT(" + portNumber + ")";
|
|
399
|
+
command += " SVRNAME(" + svrname + ")";
|
|
400
|
+
if (svrname != "*NONE")
|
|
401
|
+
command += " SVRDIR('" + deployDir + "') " +
|
|
402
|
+
"SVRAUTO(" + ((autostart) ? "*YES" : "*NO") + ") CCSID(" + ccsid + ") NODEPATH('" + nodePath + "')";
|
|
403
|
+
success = runCommand(command, "-Ke");
|
|
404
|
+
// Clean up program and save file
|
|
405
|
+
log("");
|
|
406
|
+
log("Cleaning up...");
|
|
407
|
+
runCommand("DLTPGM PGM(QGPL/PJSINSTALL)");
|
|
408
|
+
runCommand("DLTCMD CMD(QGPL/PJSINSTALL)");
|
|
409
|
+
runCommand("DLTPNLGRP PNLGRP(QGPL/PJSINSTALL)");
|
|
410
|
+
runCommand("DLTMSGF MSGF(QGPL/PJSINSTALL)");
|
|
411
|
+
runCommand("DLTF FILE(QGPL/PJSDIST)");
|
|
412
|
+
if (!success) {
|
|
413
|
+
logError("PJSINSTALL command failed.");
|
|
414
|
+
die();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
log(`\n${CYAN}Profound.js installation complete.${RESET}\n`);
|
|
203
419
|
|
|
204
|
-
function createUpdatepui(callback) {
|
|
205
|
-
if (IBMi) {
|
|
206
|
-
// This file is not needed on IBM i because the proper way to install Profound UI on IBM i is to download the full version from the web site
|
|
207
|
-
callback();
|
|
208
|
-
return;
|
|
209
420
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
copyFile(setupDir + dirSep + "updatepui.js", deployDir, "utf8");
|
|
216
|
-
console.log("updatepui.js created.");
|
|
217
|
-
callback();
|
|
421
|
+
catch (error) {
|
|
422
|
+
logError(error);
|
|
423
|
+
die();
|
|
218
424
|
}
|
|
425
|
+
})();
|
|
426
|
+
|
|
427
|
+
function log(...args) {
|
|
428
|
+
console.log(...args);
|
|
429
|
+
logToFile(...args);
|
|
219
430
|
}
|
|
220
431
|
|
|
221
|
-
function
|
|
432
|
+
function logError(...args) {
|
|
433
|
+
console.error(...args);
|
|
434
|
+
logToFile(...args);
|
|
435
|
+
}
|
|
222
436
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
copyFile(setupDir + dirSep + "store_credentials.js", deployDir, "utf8");
|
|
229
|
-
console.log("store_credentials.js created.");
|
|
230
|
-
callback();
|
|
231
|
-
}
|
|
232
|
-
|
|
437
|
+
function logToFile(...args) {
|
|
438
|
+
let output = `${util.format(...args)}\n`; // Mimic console.log().
|
|
439
|
+
output = output.replace(/\x1b\[[0-9]+m/g, ""); // Strip terminal escape codes for colors.
|
|
440
|
+
fs.writeFileSync(logFile, output, { flag: "a" });
|
|
233
441
|
}
|
|
234
442
|
|
|
235
|
-
function
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
443
|
+
function die() {
|
|
444
|
+
logError(`\n${RED}Profound.js installation failed.${RESET}`);
|
|
445
|
+
console.error(`${RED}See installation log:${RESET} ${logPath}\n`);
|
|
446
|
+
process.exit(1);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function copyDir(dir, destinationDir) {
|
|
450
|
+
const dirName = path.basename(dir);
|
|
451
|
+
fs.mkdirSync(path.join(destinationDir, dirName));
|
|
452
|
+
const files = fs.readdirSync(dir);
|
|
453
|
+
files.forEach(function(file, index) {
|
|
454
|
+
if(fs.lstatSync(path.join(dir, file)).isDirectory()) { // recurse
|
|
455
|
+
copyDir(path.join(dir, file), path.join(destinationDir, dirName));
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
copyFile(path.join(dir, file), path.join(destinationDir, dirName), null, null);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
243
462
|
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
|
|
463
|
+
function copyFile(file, destination, type) {
|
|
464
|
+
if (type == null) type = "binary";
|
|
465
|
+
if (directoryExists(destination))
|
|
466
|
+
var toFile = path.join(destination, path.basename(file));
|
|
467
|
+
else
|
|
468
|
+
var toFile = destination;
|
|
469
|
+
var content = fs.readFileSync(file, type);
|
|
470
|
+
fs.writeFileSync(toFile, content, type);
|
|
247
471
|
}
|
|
248
472
|
|
|
249
|
-
function createPuiscreens() {
|
|
473
|
+
function createPuiscreens(deployDir) {
|
|
250
474
|
function copyFileOldVersionIs(version, compareStr){
|
|
251
475
|
compareStr = compareStr || "=";
|
|
252
|
-
|
|
253
|
-
copyFile(
|
|
254
|
-
|
|
476
|
+
log("Found Standard puiscreens.json file version "+compareStr+" "+version+", replacing with current version...");
|
|
477
|
+
copyFile(path.join(__dirname, "modules", "puiscreens.json"), targetPuiScreensFile, "utf8");
|
|
478
|
+
log("puiscreens.json file was replaced.");
|
|
255
479
|
}
|
|
256
480
|
|
|
257
481
|
// Check which version of puiscreens.json is installed.
|
|
@@ -260,14 +484,14 @@ function createPuiscreens() {
|
|
|
260
484
|
// 1. Check the SHA key of existing puiscreens.json.
|
|
261
485
|
// 2. If it's an official PJS screen, no customizations have been made, so it's safe to replace with this version.
|
|
262
486
|
// 3. If it's not an official version, check if we have lower case User & Password. If not, then backup existing version to puiscreens_bak.json and install this official version.
|
|
263
|
-
// 4. Otherwise it's not an official version but should work OK. So leave existing puiscreens.json, and check if we already have a puiscreens_orig.json, and
|
|
487
|
+
// 4. Otherwise it's not an official version but should work OK. So leave existing puiscreens.json, and check if we already have a puiscreens_orig.json, and
|
|
264
488
|
// create it if not.
|
|
265
|
-
var targetPuiScreensFile = deployDir
|
|
489
|
+
var targetPuiScreensFile = path.join(deployDir, "modules", "puiscreens.json");
|
|
266
490
|
if (fileExists(targetPuiScreensFile)) {
|
|
267
491
|
|
|
268
492
|
var data = fs.readFileSync(targetPuiScreensFile);
|
|
269
|
-
var checksum = crypto.createHash(
|
|
270
|
-
|
|
493
|
+
var checksum = crypto.createHash("sha512").update(data).digest("hex"); // sha512 best for 64-bit
|
|
494
|
+
|
|
271
495
|
switch (checksum) {
|
|
272
496
|
case "4fb38daa851aacd21cf3aeaa92304df4e0353cae2b6dab3a5fd53c0cf4d42875b5efadbb4bb29642cbff07bfdd8e1c7a9c107f582905f7fc798c3841e888ee61":
|
|
273
497
|
copyFileOldVersionIs("4.6.1", "<=");
|
|
@@ -275,7 +499,7 @@ function createPuiscreens() {
|
|
|
275
499
|
case "2e63c0e9816f52b515c45479ada102af806bc73b79d14109567500c529bfaa166fb981ddb6062a1ba0a7f8e36a11d674a955d2f003806f21165cb26ad0fbdf33":
|
|
276
500
|
copyFileOldVersionIs("4.7.0");
|
|
277
501
|
break;
|
|
278
|
-
|
|
502
|
+
|
|
279
503
|
case "b5eadc2df96e97de184cc331f133933c5f2945ab6c84997cfb30f2e6b478dfa6c8753bdb328b8257382f16a6d8e85b469af09f6d0eb872642300225590031c83":
|
|
280
504
|
copyFileOldVersionIs("4.8.0");
|
|
281
505
|
break;
|
|
@@ -284,7 +508,7 @@ function createPuiscreens() {
|
|
|
284
508
|
case "b5e4d420d49d48c1dd08d0f50b88018fb64ee77248edcd9a656aee9f8ba723d0a91b18751f34cfc2efcd905f71834d5c2ac5cbff552fd85d164b710c3c2e079d":
|
|
285
509
|
copyFileOldVersionIs("4.9.1");
|
|
286
510
|
break;
|
|
287
|
-
|
|
511
|
+
|
|
288
512
|
case "1d469f6d2e4549dc259155a4b00d8f278ea89dc3566e18860ed9f6ccd406db8a47b0b3cbc359b397c59feac6faeb6a7fdc6ce2edbd3f120e295464dd41dd28f8":
|
|
289
513
|
copyFileOldVersionIs("4.11.1");
|
|
290
514
|
break;
|
|
@@ -307,22 +531,26 @@ function createPuiscreens() {
|
|
|
307
531
|
break;
|
|
308
532
|
|
|
309
533
|
case "af04803ac52709fd25f6fc87ff3ea309ad03ee6a9631f32511a5aa32c5ae50f34fd0e38e0d47dea223ac0c5dfb595199c623a83772af830edd21378055403e5c":
|
|
310
|
-
|
|
534
|
+
copyFileOldVersionIs("6.0.0");
|
|
535
|
+
break;
|
|
536
|
+
|
|
537
|
+
case "cd3e32138fbf1dac7755c233e1b5fc0d14f800694184c92989ddc5e62bacf86306013bcf423bf837183c979f61d6b323e0581363297ca6cf7f1b15435e0fbff5":
|
|
538
|
+
log("Found Standard puiscreens.json file version >= 6.0.0-beta.5, no need for update.");
|
|
311
539
|
break;
|
|
312
|
-
|
|
540
|
+
|
|
313
541
|
default:
|
|
314
542
|
var puiScreens = JSON.parse(data);
|
|
315
|
-
|
|
543
|
+
log("Found Customized puiscreens.json file, analyzing contents...");
|
|
316
544
|
|
|
317
545
|
// We need to check the signon screen and make sure we have lower case bound fields
|
|
318
546
|
var goodUser = false, goodPassword = false, goodSubmit = false, goodError = false;
|
|
319
547
|
|
|
320
548
|
formats:
|
|
321
|
-
for (i in puiScreens.formats) {
|
|
549
|
+
for (var i in puiScreens.formats) {
|
|
322
550
|
var format = puiScreens.formats[i];
|
|
323
551
|
|
|
324
552
|
if (format.screen["record format name"].toLowerCase() === "signonscrn") {
|
|
325
|
-
for (j in format.items) {
|
|
553
|
+
for (var j in format.items) {
|
|
326
554
|
var itemValue = format.items[j].value;
|
|
327
555
|
if (itemValue && typeof itemValue === "object") {
|
|
328
556
|
if (itemValue.fieldName === "ssuser") goodUser = true;
|
|
@@ -344,680 +572,84 @@ function createPuiscreens() {
|
|
|
344
572
|
}
|
|
345
573
|
|
|
346
574
|
if (goodUser && goodPassword && goodSubmit && goodError) {
|
|
347
|
-
|
|
348
|
-
copyFile(
|
|
349
|
-
|
|
575
|
+
log("The Customized puiscreens.json file is compatible, so leaving it in place. Creating puiscreens_orig.json");
|
|
576
|
+
copyFile(path.join(__dirname, "modules", "puiscreens.json"), path.join(deployDir, "modules", "puiscreens_orig.json"), "utf8");
|
|
577
|
+
log("puiscreens_orig.json created. For latest functionality, please migrate standard fields into your customized version.");
|
|
350
578
|
}
|
|
351
579
|
else {
|
|
352
|
-
|
|
353
|
-
copyFile(deployDir
|
|
354
|
-
|
|
355
|
-
copyFile(
|
|
356
|
-
|
|
580
|
+
log("The Customized puiscreens.json file is NOT compatible, backing it up to puiscreens_bak.json...");
|
|
581
|
+
copyFile(path.join(deployDir, "modules", "puiscreens.json"), path.join(deployDir, "modules", "puiscreens_bak.json"), "utf8");
|
|
582
|
+
log("puiscreens_bak.json created. Creating puiscreens.json ...");
|
|
583
|
+
copyFile(path.join(__dirname, "modules", "puiscreens.json"), targetPuiScreensFile, "utf8");
|
|
584
|
+
log("puiscreens.json created. Please migrate standard fields into your customized version.");
|
|
357
585
|
}
|
|
358
586
|
}
|
|
359
587
|
}
|
|
360
588
|
else {
|
|
361
|
-
|
|
362
|
-
copyFile(
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
function createPUIUPLEXIT() {
|
|
367
|
-
if (fileExists(deployDir + dirSep + "modules" + dirSep + "puiuplexit.js")) {
|
|
368
|
-
console.log("puiuplexit.js file exists.");
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
console.log("Creating puiuplexit.js.");
|
|
372
|
-
copyFile(setupDir + dirSep + "modules" + dirSep + "puiuplexit.js", deployDir + dirSep + "modules", "utf8");
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function createPUIDNLEXIT() {
|
|
377
|
-
if (fileExists(deployDir + dirSep + "modules" + dirSep + "puidnlexit.js")) {
|
|
378
|
-
console.log("puidnlexit.js file exists.");
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
console.log("Creating puidnlexit.js.");
|
|
382
|
-
copyFile(setupDir + dirSep + "modules" + dirSep + "puidnlexit.js", deployDir + dirSep + "modules", "utf8");
|
|
589
|
+
log("Creating puiscreens.json.");
|
|
590
|
+
copyFile(path.join(__dirname, "modules", "puiscreens.json"), targetPuiScreensFile, "utf8");
|
|
383
591
|
}
|
|
384
592
|
}
|
|
385
593
|
|
|
386
|
-
function
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
function validateName(name) {
|
|
394
|
-
|
|
395
|
-
name = name.trim().toUpperCase();
|
|
396
|
-
var firstChar = name.substr(0, 1);
|
|
397
|
-
|
|
398
|
-
if ((firstChar < "A" || firstChar > "Z") && firstChar != "#" && firstChar != "@" && firstChar != "$") {
|
|
399
|
-
console.log("Name must start with an alpha character.");
|
|
400
|
-
return false;
|
|
401
|
-
}
|
|
402
|
-
for (var i = 1; i < name.length; i++) {
|
|
403
|
-
var chr = name.substr(i, 1);
|
|
404
|
-
if ((chr < "A" || chr > "Z") && (chr < "0" || chr > "9") && chr != "#" && chr != "@" && chr != "$" && chr != "_" && chr != ".") {
|
|
405
|
-
console.log("Name contains invalid characters.");
|
|
406
|
-
return false;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if (name.length > 10) {
|
|
411
|
-
console.log("Name must be 10 characters or less.");
|
|
412
|
-
return false;
|
|
594
|
+
function directoryExists(dir) {
|
|
595
|
+
var exists = false;
|
|
596
|
+
try {
|
|
597
|
+
var stat = fs.statSync(dir);
|
|
598
|
+
if (stat && stat.isDirectory()) exists = true;
|
|
413
599
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function validateIASP(name) {
|
|
419
|
-
|
|
420
|
-
if (name.trim().toUpperCase() == "*SYSBAS")
|
|
421
|
-
return true;
|
|
422
|
-
else return validateName(name);
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function isURL(path) {
|
|
427
|
-
if (typeof path !== "string") return false;
|
|
428
|
-
path = path.toLowerCase();
|
|
429
|
-
if (path.substr(0, 7) === "http://") return true;
|
|
430
|
-
if (path.substr(0, 8) === "https://") return true;
|
|
431
|
-
return false;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
function validateDirectory(directory) {
|
|
435
|
-
if (IBMi) {
|
|
436
|
-
var ch = directory.substr(0, 1);
|
|
437
|
-
if (ch !== "/" && ch !== "\\" && !isURL(directory)) {
|
|
438
|
-
directory = deployDir + dirSep + directory;
|
|
439
|
-
}
|
|
440
|
-
if (!directoryExists(directory) && !isURL(directory)) {
|
|
441
|
-
console.log("WARNING: The specified directory was not found. You can create it later or modify the staticFilesDirectory property in config.js.");
|
|
442
|
-
console.log("");
|
|
443
|
-
}
|
|
600
|
+
catch (err) {
|
|
601
|
+
exists = false;
|
|
444
602
|
}
|
|
445
|
-
return
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
function validatePort(port) {
|
|
449
|
-
if (port === "0") return true;
|
|
450
|
-
port = Number(port);
|
|
451
|
-
if (!isNaN(port) && port >= 1 && port <= 65535) return true;
|
|
452
|
-
console.log("Invalid port number. Valid range is 0-65535.");
|
|
453
|
-
return false;
|
|
603
|
+
return exists;
|
|
454
604
|
}
|
|
455
605
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
return false;
|
|
606
|
+
function fileExists(file) {
|
|
607
|
+
var exists = false;
|
|
608
|
+
try {
|
|
609
|
+
var stat = fs.statSync(file);
|
|
610
|
+
if (stat && stat.isFile()) exists = true;
|
|
462
611
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
function isValidCcsid(ccsid) {
|
|
468
|
-
|
|
469
|
-
ccsid = Number(ccsid);
|
|
470
|
-
if (isNaN(ccsid)) {
|
|
471
|
-
console.log("Invalid CCSID. A numeric value is required.");
|
|
472
|
-
return false;
|
|
612
|
+
catch (err) {
|
|
613
|
+
exists = false;
|
|
473
614
|
}
|
|
474
|
-
|
|
475
|
-
// Here's the list of valid CCSID's that can be used for jobs on IBM i
|
|
476
|
-
if ([37, 256, 273, 277, 278, 280, 284, 285, 290, 297, 420, 423, 424, 425, 500, 833, 836, 838, 870, 871, 875, 880,
|
|
477
|
-
905, 918, 924, 930, 933, 935, 937, 939, 1025, 1026, 1027, 1047, 1097, 1112, 1122, 1123, 1130, 1132, 1137,
|
|
478
|
-
1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1153, 1154, 1155, 1156, 1157, 1158, 1160, 1164,
|
|
479
|
-
1166, 1175, 1364, 1371, 1377, 1388, 1399, 4971, 5026, 5035, 5123, 5233, 8612, 9030, 12708, 13121, 13124,
|
|
480
|
-
28709, 57777, 61175, 62211, 62224, 62235, 62245, 62251].indexOf(ccsid) > -1)
|
|
481
|
-
return true;
|
|
482
|
-
|
|
483
|
-
console.log("Value " + ccsid + " is not a valid CCSID for the SBMJOB command.");
|
|
484
|
-
|
|
485
|
-
return false;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
function validateYesNo(answer) {
|
|
489
|
-
answer = answer.toUpperCase();
|
|
490
|
-
if (answer === "Y" || answer === "YES" || answer === "N" || answer === "NO") return true;
|
|
491
|
-
console.log("Invalid answer. Use y or n.");
|
|
492
|
-
return false;
|
|
615
|
+
return exists;
|
|
493
616
|
}
|
|
494
617
|
|
|
495
|
-
function
|
|
496
|
-
|
|
497
|
-
var ret = {};
|
|
498
|
-
if (fileExists(deployDir + dirSep + "config.js")) {
|
|
499
|
-
|
|
500
|
-
const config = require(deployDir + dirSep + "config.js");
|
|
618
|
+
function runCommand(command, switches) {
|
|
501
619
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
620
|
+
log("Executing IBM i command: " + command);
|
|
621
|
+
var args = [command];
|
|
622
|
+
if (typeof switches == "string") {
|
|
623
|
+
args.unshift(switches);
|
|
507
624
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
function createConfig(profounduiLibrary, connectorLibrary, connectorIASP, callback) {
|
|
513
|
-
|
|
514
|
-
if (fileExists(deployDir + dirSep + "config.js")) {
|
|
515
|
-
|
|
516
|
-
// If the config already exists, check if any settings need to be updated
|
|
517
|
-
|
|
518
|
-
if (!IBMi) {
|
|
519
|
-
console.log("config.js file exists.");
|
|
520
|
-
callback();
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
const config = require(deployDir + dirSep + "config.js");
|
|
525
|
-
var isConfigChanged = false;
|
|
526
|
-
|
|
527
|
-
// Check if it contains a profounduiLibrary setting
|
|
528
|
-
if (profounduiLibrary) {
|
|
529
|
-
|
|
530
|
-
var configProfounduiLibrary = getProfounduiLibrary();
|
|
531
|
-
|
|
532
|
-
if (configProfounduiLibrary) {
|
|
533
|
-
|
|
534
|
-
if (configProfounduiLibrary !== profounduiLibrary) {
|
|
535
|
-
isConfigChanged = true;
|
|
536
|
-
console.log("Updating profounduiLibrary setting in config.js from " + configProfounduiLibrary + " to " + profounduiLibrary + "...");
|
|
537
|
-
config.profounduiLibrary = profounduiLibrary;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
isConfigChanged = true;
|
|
543
|
-
console.log("config.js file exists, but does not have a profounduiLibrary setting, creating one now...");
|
|
544
|
-
config.profounduiLibrary = profounduiLibrary;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
// Check if it contains a connectorLibrary setting
|
|
550
|
-
if (connectorLibrary && connectorLibrary !== "*NONE") {
|
|
551
|
-
|
|
552
|
-
var configConnectorLibrary = getConnectorLibrary();
|
|
553
|
-
|
|
554
|
-
if (configConnectorLibrary.name) {
|
|
555
|
-
|
|
556
|
-
if (configConnectorLibrary.name !== connectorLibrary) {
|
|
557
|
-
isConfigChanged = true;
|
|
558
|
-
console.log("Updating connectorLibrary setting in config.js from " + configConnectorLibrary.name + " to " + connectorLibrary + "...");
|
|
559
|
-
config.connectorLibrary = connectorLibrary;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
}
|
|
563
|
-
else {
|
|
564
|
-
isConfigChanged = true;
|
|
565
|
-
console.log("config.js file exists, but does not have a connectorLibrary setting, creating one now...");
|
|
566
|
-
config.connectorLibrary = connectorLibrary;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// Check if it contains a connectorIASP setting
|
|
570
|
-
if (connectorIASP) {
|
|
571
|
-
|
|
572
|
-
if (configConnectorLibrary.IASP) {
|
|
573
|
-
|
|
574
|
-
if (configConnectorLibrary.IASP !== connectorIASP) {
|
|
575
|
-
isConfigChanged = true;
|
|
576
|
-
console.log("Updating connectorIASP setting in config.js from " + configConnectorLibrary.IASP + " to " + connectorIASP + "...");
|
|
577
|
-
if (connectorIASP == "*SYSBAS")
|
|
578
|
-
delete config.connectorIASP;
|
|
579
|
-
else
|
|
580
|
-
config.connectorIASP = connectorIASP;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
else if (connectorIASP != "*SYSBAS") {
|
|
585
|
-
isConfigChanged = true;
|
|
586
|
-
console.log("config.js file exists, but does not have a connectorIASP setting, creating one now...");
|
|
587
|
-
config.connectorIASP = connectorIASP;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
// Update config.js if we made any chanegs
|
|
596
|
-
if (isConfigChanged) {
|
|
597
|
-
|
|
598
|
-
fs.writeFile(deployDir + dirSep + "config.js", stringifyConfig(config), (err) => {
|
|
599
|
-
if (err)
|
|
600
|
-
console.log('An error occurred updating config.js file : ' + err);
|
|
601
|
-
else
|
|
602
|
-
console.log('config.js file has been updated.');
|
|
603
|
-
callback();
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
else
|
|
607
|
-
callback();
|
|
625
|
+
else {
|
|
626
|
+
args.unshift("-e");
|
|
608
627
|
}
|
|
609
|
-
else {
|
|
610
|
-
|
|
611
|
-
var defaultStaticDir = "htdocs";
|
|
612
|
-
if (IBMi) {
|
|
613
|
-
defaultStaticDir = "/www/profoundui/htdocs";
|
|
614
|
-
if (!directoryExists(defaultStaticDir)) {
|
|
615
|
-
console.log("WARNING: Profound UI Installation not found in default location.");
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
console.log("");
|
|
620
|
-
console.log("You can provide the Profound UI directory as a remote URL (e.g. http://myibmi:8080) or as a local directory name. If the directory does not exist, the installer can create it for you.");
|
|
621
|
-
console.log("");
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
ask("Specify Profound UI static files directory", defaultStaticDir, validateDirectory, function(staticDir) {
|
|
625
|
-
ask("Specify port number for Profound.js server", portNumber, validatePort, function(newPortNumber) {
|
|
626
|
-
copyFile(setupDir + dirSep + "config.js", deployDir, "utf8", function(content) {
|
|
627
|
-
var config = content.substr(content.indexOf("{"));
|
|
628
|
-
eval("config = " + config);
|
|
629
|
-
config.staticFilesDirectory = staticDir;
|
|
630
|
-
config.port = Number(newPortNumber);
|
|
631
|
-
if (connectorLibrary && connectorLibrary !== "*NONE") {
|
|
632
|
-
config.connectorLibrary = connectorLibrary;
|
|
633
|
-
if (connectorIASP != "*SYSBAS")
|
|
634
|
-
config.connectorIASP = connectorIASP;
|
|
635
|
-
}
|
|
636
|
-
if (profounduiLibrary)
|
|
637
|
-
config.profounduiLibrary = profounduiLibrary;
|
|
638
|
-
|
|
639
|
-
if (IBMi)
|
|
640
|
-
config.showIBMiParmDefn = true;
|
|
641
|
-
|
|
642
|
-
// Check if this is a workspace (if so, default to mysql)
|
|
643
|
-
if (!IBMi && fileExists(deployDir + dirSep + "modules" + dirSep + "app" + dirSep + ".noderun" + dirSep + "settings.json")) {
|
|
644
|
-
if (config.databaseConnections) delete config.databaseConnections; // remove property so that it's appended at the end when we set it
|
|
645
|
-
config.databaseConnections = [{
|
|
646
|
-
name: "default",
|
|
647
|
-
default: true,
|
|
648
|
-
driver: "mysql",
|
|
649
|
-
driverOptions: {
|
|
650
|
-
user: "user-name",
|
|
651
|
-
password: "your-password",
|
|
652
|
-
host: "localhost",
|
|
653
|
-
database: "database-name"
|
|
654
|
-
}
|
|
655
|
-
}];
|
|
656
|
-
}
|
|
657
628
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
console.log("config.js created.");
|
|
666
|
-
console.log("");
|
|
667
|
-
|
|
668
|
-
if (!IBMi && !isURL(staticDir)) {
|
|
669
|
-
var absoluteStaticDir = path.resolve(deployDir, staticDir);
|
|
670
|
-
if (!directoryExists(absoluteStaticDir)) {
|
|
671
|
-
console.log("");
|
|
672
|
-
console.log("The specified directory for Profound UI was not found.");
|
|
673
|
-
ask("Should the installer create the directory and download a copy of Profound UI static files?", "y", validateYesNo, function(answer) {
|
|
674
|
-
if (answer.toUpperCase() == "Y") {
|
|
675
|
-
downloadHtdocs(absoluteStaticDir, callback);
|
|
676
|
-
}
|
|
677
|
-
else {
|
|
678
|
-
callback();
|
|
679
|
-
}
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
else {
|
|
683
|
-
callback();
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
else {
|
|
687
|
-
callback();
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
}
|
|
629
|
+
const options = {
|
|
630
|
+
stdio: ["ignore", logFile, logFile],
|
|
631
|
+
cwd: __dirname,
|
|
632
|
+
env: {
|
|
633
|
+
QIBM_USE_DESCRIPTOR_STDIO: "Y",
|
|
634
|
+
QIBM_MULTI_THREADED: "N" // Many IBM commands cannot run in multi-threaded mode...
|
|
635
|
+
}};
|
|
693
636
|
|
|
694
|
-
|
|
695
|
-
process.stdin.destroy();
|
|
696
|
-
console.log("");
|
|
697
|
-
process.exit(0);
|
|
698
|
-
}
|
|
637
|
+
const results = child_process.spawnSync("system", args, options);
|
|
699
638
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
const child_process = require("child_process");
|
|
704
|
-
var args = [command];
|
|
705
|
-
if (typeof switches == "string")
|
|
706
|
-
args.unshift(switches);
|
|
707
|
-
else
|
|
708
|
-
args.unshift("-e");
|
|
709
|
-
|
|
710
|
-
// Many IBM commands cannot run in multi-threaded mode...
|
|
711
|
-
var options = {stdio: "inherit", cwd: setupDir, env: {QIBM_USE_DESCRIPTOR_STDIO:"Y", QIBM_MULTI_THREADED:"N"}};
|
|
712
|
-
|
|
713
|
-
var results = child_process.spawnSync(
|
|
714
|
-
"system",
|
|
715
|
-
args,
|
|
716
|
-
options);
|
|
717
|
-
|
|
718
|
-
var code = results.status;
|
|
719
|
-
var signal = results.signal;
|
|
720
|
-
|
|
721
|
-
if (code != null) {
|
|
639
|
+
const code = results.status;
|
|
640
|
+
const signal = results.signal;
|
|
641
|
+
if (code != null) {
|
|
722
642
|
if (code === 0) {
|
|
723
|
-
console.log("Command finished successfully.");
|
|
724
643
|
return true;
|
|
725
644
|
}
|
|
726
645
|
else {
|
|
727
|
-
|
|
646
|
+
logError("Process exited, code %d", code);
|
|
728
647
|
}
|
|
729
648
|
}
|
|
730
649
|
else {
|
|
731
|
-
|
|
732
|
-
|
|
650
|
+
logError("Process ended due to signal %s", signal);
|
|
651
|
+
logError(results); // show full results including detailed error
|
|
733
652
|
}
|
|
734
653
|
return false;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
function getProfounduiLibrary() {
|
|
739
|
-
|
|
740
|
-
if (fileExists(deployDir + dirSep + "config.js")) {
|
|
741
|
-
|
|
742
|
-
const config = require(deployDir + dirSep + "config.js");
|
|
743
|
-
|
|
744
|
-
if (config.profounduiLibrary) {
|
|
745
|
-
return config.profounduiLibrary;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
return null;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
function askPuiLibrary(callback) {
|
|
754
|
-
|
|
755
|
-
var defaultProfounduiLibrary = getProfounduiLibrary();
|
|
756
|
-
|
|
757
|
-
ask("Specify Profound UI installation library", (defaultProfounduiLibrary) ? defaultProfounduiLibrary : "PROFOUNDUI", validateName, function(puiLibrary) {
|
|
758
|
-
callback(puiLibrary.trim().toUpperCase());
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
function askConnector(callback) {
|
|
765
|
-
|
|
766
|
-
ask("Install Profound.js Connector IBM i ILE components?", "y", validateYesNo, function(answer) {
|
|
767
|
-
|
|
768
|
-
if (answer.toUpperCase() == "Y") {
|
|
769
|
-
|
|
770
|
-
var connectorLibrary = getConnectorLibrary();
|
|
771
|
-
ask("Enter Profound.js Connector library name:", (connectorLibrary.name) ? connectorLibrary.name : "PROFOUNDJS", validateName, function(answer) {
|
|
772
|
-
|
|
773
|
-
var name = answer.trim().toUpperCase();
|
|
774
|
-
ask("Enter Profound.js Connector library IASP:", (connectorLibrary.IASP) ? connectorLibrary.IASP : "*SYSBAS", validateIASP, function(answer) {
|
|
775
|
-
|
|
776
|
-
callback(name, answer.trim().toUpperCase());
|
|
777
|
-
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
|
|
785
|
-
callback("*NONE");
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
function getServerInstances(instanceRootDir) {
|
|
794
|
-
|
|
795
|
-
const serverInstances = [];
|
|
796
|
-
if (directoryExists(pjsBaseInstance)) {
|
|
797
|
-
|
|
798
|
-
const instanceDirs = fs.readdirSync(pjsBaseInstance);
|
|
799
|
-
instanceDirs.forEach((instanceDir) => {
|
|
800
|
-
|
|
801
|
-
let data
|
|
802
|
-
try {
|
|
803
|
-
|
|
804
|
-
data = fs.readFileSync(path.join(pjsBaseInstance, instanceDir, "/conf"), "utf8");
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
catch (error) {
|
|
808
|
-
|
|
809
|
-
return;
|
|
810
|
-
|
|
811
|
-
}
|
|
812
|
-
let options = data.split('\n');
|
|
813
|
-
let config = { name: instanceDir, autostart: "n", ccsid: 37, nodePath: "/QOpenSys/pkgs/bin/node" };
|
|
814
|
-
|
|
815
|
-
options.forEach(option => {
|
|
816
|
-
|
|
817
|
-
let parts = option.split('=');
|
|
818
|
-
let configOption = parts[0].trim();
|
|
819
|
-
|
|
820
|
-
switch (configOption) {
|
|
821
|
-
case 'path':
|
|
822
|
-
config.path = parts[1].trim();
|
|
823
|
-
break;
|
|
824
|
-
case 'nodePath':
|
|
825
|
-
config.nodePath = parts[1].trim();
|
|
826
|
-
break;
|
|
827
|
-
case 'nodeArgs':
|
|
828
|
-
config.nodeArgs = parts[1].trim();
|
|
829
|
-
break;
|
|
830
|
-
case 'autostart':
|
|
831
|
-
config.autostart = (parts[1].trim() === '1') ? 'y' : 'n';
|
|
832
|
-
break;
|
|
833
|
-
case 'ccsid':
|
|
834
|
-
config.ccsid = parts[1].trim();
|
|
835
|
-
break;
|
|
836
|
-
case '':
|
|
837
|
-
break;
|
|
838
|
-
default:
|
|
839
|
-
break;
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
if (config.path === instanceRootDir + dirSep + 'start.js')
|
|
843
|
-
serverInstances.push(config);
|
|
844
|
-
|
|
845
|
-
});
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
if (serverInstances.length === 0)
|
|
849
|
-
serverInstances.push({ name: "PROFOUNDJS", autostart: "y", ccsid: 37, nodePath: "/QOpenSys/pkgs/bin/node" });
|
|
850
|
-
return serverInstances;
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
function askServerInstance(callback) {
|
|
856
|
-
|
|
857
|
-
serverInstances = getServerInstances(deployDir);
|
|
858
|
-
|
|
859
|
-
if (serverInstances.length > 1) {
|
|
860
|
-
console.log('\nWARNING - Multiple STRTCPSVR/ENDTCPSVR instances found for this server in ' + pjsBaseInstance + ' : -\n');
|
|
861
|
-
serverInstances.forEach(serverInstance => {
|
|
862
|
-
console.log(JSON.stringify(serverInstance));
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
ask("\nCreate/replace server instance configuration for STRTCPSVR/ENDTCPSVR commands?", "y", validateYesNo, function(answer) {
|
|
867
|
-
|
|
868
|
-
if (answer.toUpperCase() == "Y") {
|
|
869
|
-
|
|
870
|
-
ask("Server instance name:", serverInstances[0].name.toUpperCase(), validateName, function(answer) {
|
|
871
|
-
|
|
872
|
-
var svrname = answer.trim().toUpperCase();
|
|
873
|
-
|
|
874
|
-
ask("Specify CCSID for instance " + svrname, serverInstances[0].ccsid, isValidCcsid, function(ccsid) {
|
|
875
|
-
|
|
876
|
-
ask("Specify Node.js path for instance " + svrname, serverInstances[0].nodePath, isValidNodePath, function(nodePath) {
|
|
877
|
-
|
|
878
|
-
ask("Autostart server instance " + svrname + " when TCP/IP starts?", serverInstances[0].autostart, validateYesNo, function(answer) {
|
|
879
|
-
|
|
880
|
-
var autostart = (answer.toUpperCase() == "Y");
|
|
881
|
-
callback(svrname, autostart, ccsid, nodePath);
|
|
882
|
-
|
|
883
|
-
});
|
|
884
|
-
});
|
|
885
|
-
});
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
}
|
|
889
|
-
else {
|
|
890
|
-
|
|
891
|
-
callback("*NONE");
|
|
892
|
-
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
function stringifyConfig(config) {
|
|
900
|
-
|
|
901
|
-
// JavaScript functions (like connectorIPFilter) will be lost when doing JSON.stringify,
|
|
902
|
-
// so we need to do some magic to preserve them.
|
|
903
|
-
|
|
904
|
-
let funkz = [];
|
|
905
|
-
let configString = "\nmodule.exports = ";
|
|
906
|
-
|
|
907
|
-
configString += JSON.stringify(config, (key, val) => {
|
|
908
|
-
if (typeof val === 'function') {
|
|
909
|
-
let n = funkz.length;
|
|
910
|
-
funkz.push(val.toString());
|
|
911
|
-
return `___function${n}___`;
|
|
912
|
-
}
|
|
913
|
-
return val;
|
|
914
|
-
}, " ");
|
|
915
|
-
|
|
916
|
-
configString += "\n";
|
|
917
|
-
|
|
918
|
-
for (var i=0; i<funkz.length; i++) {
|
|
919
|
-
configString = configString.replace(`"___function${i}___"`, funkz[i]);
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
return configString;
|
|
923
|
-
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
if (["win32", "darwin", "linux"].includes(os.platform()))
|
|
928
|
-
installNodeGit();
|
|
929
|
-
createPackageFile();
|
|
930
|
-
createModulesDirectory();
|
|
931
|
-
createPuiscreens();
|
|
932
|
-
createPUIUPLEXIT();
|
|
933
|
-
createPUIDNLEXIT();
|
|
934
|
-
copyPjssamples();
|
|
935
|
-
|
|
936
|
-
createStoreCredentials(function() {
|
|
937
|
-
createUpdatepui(function() {
|
|
938
|
-
createCall(function() {
|
|
939
|
-
createStart(function() {
|
|
940
|
-
if (IBMi && !silent) {
|
|
941
|
-
console.log("");
|
|
942
|
-
askPuiLibrary(function(profounduiLibrary) {
|
|
943
|
-
askConnector(function(connectorLibrary, connectorIASP) {
|
|
944
|
-
createConfig(profounduiLibrary, connectorLibrary, connectorIASP, function() {
|
|
945
|
-
askServerInstance(function(svrname, autostart, ccsid, nodePath) {
|
|
946
|
-
if (connectorLibrary != "*NONE" || svrname != "*NONE") {
|
|
947
|
-
// First, try copying the save file
|
|
948
|
-
var success = runCommand("CPYFRMSTMF FROMSTMF('" + setupDir + dirSep + "pjsdist.savf') TOMBR('/QSYS.LIB/QGPL.LIB/PJSDIST.FILE') MBROPT(*REPLACE)");
|
|
949
|
-
if (success) {
|
|
950
|
-
// Now, try restoring the PJSINSTALL program
|
|
951
|
-
success = runCommand("RSTOBJ OBJ(PJSINSTALL) SAVLIB(QTEMP) DEV(*SAVF) OBJTYPE(*ALL) SAVF(QGPL/PJSDIST) RSTLIB(QGPL)");
|
|
952
|
-
if (success) {
|
|
953
|
-
// Now, try running PJSINSTALL
|
|
954
|
-
var command = "QGPL/PJSINSTALL CONNLIB(" + connectorLibrary + ")";
|
|
955
|
-
if (connectorLibrary != "*NONE")
|
|
956
|
-
command += " CONNIASP(" + connectorIASP + ") CONNHOST('localhost') CONNPORT(" + portNumber + ")";
|
|
957
|
-
command += " SVRNAME(" + svrname + ")";
|
|
958
|
-
if (svrname != "*NONE")
|
|
959
|
-
command += " SVRDIR('" + deployDir + "') " +
|
|
960
|
-
"SVRAUTO(" + ((autostart) ? "*YES" : "*NO") + ") CCSID(" + ccsid + ") NODEPATH('" + nodePath + "')";
|
|
961
|
-
success = runCommand(command, "-Ke");
|
|
962
|
-
// Clean up program and save file
|
|
963
|
-
console.log("");
|
|
964
|
-
console.log("Cleaning up...");
|
|
965
|
-
runCommand("DLTPGM PGM(QGPL/PJSINSTALL)");
|
|
966
|
-
runCommand("DLTCMD CMD(QGPL/PJSINSTALL)");
|
|
967
|
-
runCommand("DLTPNLGRP PNLGRP(QGPL/PJSINSTALL)");
|
|
968
|
-
runCommand("DLTMSGF MSGF(QGPL/PJSINSTALL)");
|
|
969
|
-
runCommand("DLTF FILE(QGPL/PJSDIST)");
|
|
970
|
-
console.log("");
|
|
971
|
-
if (success) {
|
|
972
|
-
console.log("Profound.js successfully installed.");
|
|
973
|
-
}
|
|
974
|
-
else {
|
|
975
|
-
console.log("Profound.js did NOT install successfully! Check messages above.");
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
else {
|
|
979
|
-
// Clean up save file
|
|
980
|
-
console.log("");
|
|
981
|
-
console.log("Cleaning up...");
|
|
982
|
-
runCommand("DLTF FILE(QGPL/PJSDIST)");
|
|
983
|
-
console.log("");
|
|
984
|
-
console.log("Profound.js did NOT install successfully! Check messages above.");
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
else {
|
|
988
|
-
console.log("");
|
|
989
|
-
console.log("Profound.js did NOT install successfully! Check messages above.");
|
|
990
|
-
}
|
|
991
|
-
finish();
|
|
992
|
-
}
|
|
993
|
-
else {
|
|
994
|
-
finish();
|
|
995
|
-
}
|
|
996
|
-
});
|
|
997
|
-
});
|
|
998
|
-
});
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
else {
|
|
1002
|
-
createConfig(null, null, null, function() {
|
|
1003
|
-
console.log("");
|
|
1004
|
-
console.log("Installation completed.");
|
|
1005
|
-
finish();
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
1009
|
-
});
|
|
1010
|
-
});
|
|
1011
|
-
});
|
|
1012
|
-
|
|
1013
|
-
function installNodeGit() {
|
|
1014
|
-
|
|
1015
|
-
child_process.execSync(
|
|
1016
|
-
"npm install nodegit",
|
|
1017
|
-
{
|
|
1018
|
-
cwd: path.resolve(__dirname, ".."),
|
|
1019
|
-
stdio: ["ignore", "inherit", "inherit"]
|
|
1020
|
-
}
|
|
1021
|
-
);
|
|
1022
654
|
|
|
1023
655
|
}
|