profoundjs 6.0.0-beta.6 → 6.0.0-beta.8

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/setup/setup.js CHANGED
@@ -6,16 +6,17 @@
6
6
  This is NPM script: npm run setup
7
7
 
8
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.
9
+ * Kicked off from 'complete_install.js' which is manually run by user.
11
10
  * Can also be run directly for advanced/automated installation.
12
11
 
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.
14
-
15
12
  */
16
13
 
17
14
  const htdocs_download_url = "http://resources.profoundjs.com/profoundui_htdocs.zip";
18
15
 
16
+ // Platform-specific dependency versions.
17
+ const idb_connector_version = "1.2.16";
18
+ const node_pty_version = "^2";
19
+
19
20
  const child_process = require("child_process");
20
21
  const compareVersions = require("compare-versions");
21
22
  const crypto = require("crypto");
@@ -28,7 +29,7 @@ const path = require("path");
28
29
  const util = require("util");
29
30
  const uuidv4 = require("uuid").v4;
30
31
 
31
- const IBMi = os.type() === "OS400";
32
+ const IBMi = iutils.isIBMi();
32
33
 
33
34
  const RED = "\x1b[31m";
34
35
  const CYAN = "\x1b[36m";
@@ -62,7 +63,11 @@ let logFile;
62
63
  "ibmi-instance-ccsid",
63
64
  "ibmi-instance-node-path",
64
65
  "nodegit-version"
65
- ]
66
+ ],
67
+ unknown: function(arg) {
68
+ console.error("Unknown argument:", arg);
69
+ process.exit(1);
70
+ }
66
71
  }
67
72
  );
68
73
 
@@ -93,10 +98,10 @@ let logFile;
93
98
  IBM i instance-related values are ignored unless --ibmi-instance is specified.
94
99
 
95
100
  --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.
101
+ --ibmi-instance creates or replaces STRTCPSVR config.
102
+ --ibmi-instance-autostart sets "autostart=1" in STRTCPSVR config.
103
+ --ibmi-instance-ccsid sets "ccsid" in STRTCPSVR config.
104
+ --ibmi-instance-node-path sets "nodePath" in STRTCPSVR config.
100
105
  `;
101
106
  console.log(HELP);
102
107
  process.exit(0);
@@ -194,6 +199,28 @@ let logFile;
194
199
  }
195
200
  }
196
201
 
202
+ // Install platform-specific dependencies.
203
+ if (IBMi) {
204
+ log(`Installing idb-connector...`);
205
+ child_process.execSync(
206
+ `npm install --no-package-lock idb-connector@"${idb_connector_version}"`,
207
+ {
208
+ cwd: iutils.getPackageDir(),
209
+ stdio: ["ignore", logFile, logFile]
210
+ }
211
+ );
212
+ }
213
+ else {
214
+ log(`Installing profoundjs-node-pty...`);
215
+ child_process.execSync(
216
+ `npm install --save-optional --no-package-lock profoundjs-node-pty@"${node_pty_version}"`,
217
+ {
218
+ cwd: iutils.getPackageDir(),
219
+ stdio: ["ignore", logFile, logFile]
220
+ }
221
+ );
222
+ }
223
+
197
224
  // Install nodegit, if necessary.
198
225
  if (args["nodegit"]) {
199
226
  let version;
@@ -344,28 +371,6 @@ let logFile;
344
371
  let nodePath = process.argv[0];
345
372
  if (args["ibmi-instance"] !== undefined) {
346
373
  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
374
  if (process.argv.find(arg => arg.includes("ibmi-instance-autostart"))) { // minimist sets booleans to false if not passed.
370
375
  autostart = args["ibmi-instance-autostart"];
371
376
  }
@@ -414,6 +419,19 @@ let logFile;
414
419
  die();
415
420
  }
416
421
  }
422
+ if (args["ibmi-instance"] === undefined) {
423
+ // Instance is restarted by PJSINSTALL command only when config is created/replaced.
424
+ const instances = iutils.getIBMiInstances(deployDir);
425
+ if (instances.length > 0) {
426
+ const instance = instances[0];
427
+ log("");
428
+ runCommand(`ENDTCPSVR SERVER(*PJS) INSTANCE(${instance.name})`);
429
+ log("Waiting for instance to end...");
430
+ // This should generally work as shutdown is relatively fast.
431
+ await new Promise(resolve => setTimeout(resolve, 10000));
432
+ runCommand(`STRTCPSVR SERVER(*PJS) INSTANCE(${instance.name})`);
433
+ }
434
+ }
417
435
  }
418
436
  log(`\n${CYAN}Profound.js installation complete.${RESET}\n`);
419
437