liverpool-telescope-phase2ui 2.1.1 → 2.1.2

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.
Binary file
@@ -1,5 +1,8 @@
1
1
  #! /usr/bin/env node
2
2
 
3
+ var path = require('path');
4
+ var os = require('os');
5
+ var jdeployHomeDir = process.env.JDEPLOY_HOME || path.join(os.homedir(), '.jdeploy');
3
6
  var jarName = "Phase2UI.jar";
4
7
  var mainClass = "{{MAIN_CLASS}}";
5
8
  var classPath = "{{CLASSPATH}}";
@@ -23,9 +26,7 @@ var jdkProvider = 'zulu';
23
26
  function njreWrap() {
24
27
  'use strict'
25
28
 
26
- const path = require('path')
27
29
  const fs = require('fs')
28
- const os = require('os')
29
30
  const crypto = require('crypto')
30
31
  const fetch = require('node-fetch')
31
32
  const yauzl = require('yauzl')
@@ -62,6 +63,10 @@ function njreWrap() {
62
63
  createDir(dir)
63
64
  .then(() => fetch(url))
64
65
  .then(response => {
66
+ // Validate HTTP status code before writing the file
67
+ if (!response.ok) {
68
+ return reject(new Error(`HTTP ${response.status}: ${response.statusText} for ${url}`))
69
+ }
65
70
  const destFile = path.join(dir, destName)
66
71
  const destStream = fs.createWriteStream(destFile)
67
72
  response.body.pipe(destStream).on('finish', () => resolve(destFile))
@@ -105,7 +110,7 @@ function njreWrap() {
105
110
 
106
111
  function move (file) {
107
112
  return new Promise((resolve, reject) => {
108
- const jdeployDir = path.join(os.homedir(), '.jdeploy');
113
+ const jdeployDir = jdeployHomeDir;
109
114
  if (!fs.existsSync(jdeployDir)) {
110
115
  fs.mkdirSync(jdeployDir);
111
116
  }
@@ -231,8 +236,16 @@ function njreWrap() {
231
236
  const { openjdk_impl = 'hotspot', release = 'latest', type = 'jre', javafx = false, provider = 'zulu' } = options
232
237
  options = { ...options, openjdk_impl, release, type }
233
238
 
239
+ // Determine the architecture based on the platform and environment
240
+ let arch = process.arch;
241
+ if (arch === 'arm64' || arch === 'aarch64') {
242
+ arch = 'aarch64'; // For ARM-based systems, standardize on aarch64
243
+ } else {
244
+ arch = 'x64'; // Default to x64 for non-ARM systems
245
+ }
246
+
234
247
  if (provider === 'zulu') {
235
- return installZulu(version, options);
248
+ return installZulu(version, options, arch);
236
249
  }
237
250
 
238
251
  let url = 'https://api.adoptopenjdk.net/v2/info/releases/openjdk' + version + '?'
@@ -258,13 +271,9 @@ function njreWrap() {
258
271
  return Promise.reject(new Error('Unsupported operating system'))
259
272
  }
260
273
  }
274
+
261
275
  if (!options.arch) {
262
- if (options.os == 'mac') {
263
- // For now, for compatibility reasons use x64 always
264
- options.arch = 'x64';
265
- } else if (/^ppc64|s390x|x32|x64$/g.test(process.arch)) options.arch = process.arch
266
- else if (process.arch === 'ia32') options.arch = 'x32'
267
- else return Promise.reject(new Error('Unsupported architecture'))
276
+ options.arch = arch; // Use the detected architecture
268
277
  }
269
278
 
270
279
  Object.keys(options).forEach(key => { url += key + '=' + options[key] + '&' })
@@ -279,68 +288,72 @@ function njreWrap() {
279
288
  .then(extract)
280
289
  }
281
290
 
282
- function installZulu(version = 11, options = {}) {
283
- const { type = 'jre', javafx = false } = options
284
- var q = {
291
+ function installZulu(version = 11, options = {}, arch) {
292
+ const { type = 'jre', javafx = false } = options;
285
293
 
294
+ // Prepare the query parameters for the request
295
+ let q = {
286
296
  java_version: version,
287
297
  ext: 'zip',
288
298
  bundle_type: type,
289
- javafx: ''+javafx,
290
- arch: 'x86',
299
+ javafx: '' + javafx,
300
+ arch: arch, // Use the detected architecture
291
301
  hw_bitness: '64',
302
+ };
292
303
 
293
- };
304
+ // Base URL for the Azul API
305
+ const zuluBaseURL = "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary?";
294
306
 
307
+ // Determine the OS
308
+ if (!options.os) {
309
+ switch (process.platform) {
310
+ case 'darwin':
311
+ q.os = 'macos';
312
+ break;
313
+ case 'linux':
314
+ q.os = 'linux';
315
+ q.ext = 'tar.gz';
316
+ break;
317
+ case 'win32':
318
+ case 'win64':
319
+ q.os = 'windows';
320
+ break;
321
+ default:
322
+ return Promise.reject(new Error('Unsupported operating system'));
323
+ }
324
+ }
295
325
 
296
- var zuluBaseURL = "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary?"
297
- if (!options.os) {
298
- switch (process.platform) {
299
-
300
- case 'darwin':
301
- q.os = 'macos'
302
- break
303
- case 'linux':
304
- q.os = 'linux'
305
- q.ext = 'tar.gz'
306
- break
307
-
308
- case 'win32':
309
- case 'win64':
310
- q.os = 'windows'
311
- break
312
- default:
313
- return Promise.reject(new Error('Unsupported operating system'))
314
- }
315
- }
326
+ // Construct the URL for the download request
327
+ let url = zuluBaseURL;
328
+ Object.keys(q).forEach(key => { url += key + '=' + q[key] + '&' });
316
329
 
330
+ const tmpdir = path.join(os.tmpdir(), 'njre');
317
331
 
318
- var url = zuluBaseURL;
319
- Object.keys(q).forEach(key => { url += key + '=' + q[key] + '&' })
320
- const tmpdir = path.join(os.tmpdir(), 'njre')
321
- //console.log("Downloading "+url);
322
- return download(tmpdir, url)
332
+ // Function to handle the download and extraction
333
+ const attemptDownload = (url) => {
334
+ return download(tmpdir, url)
323
335
  .then(move)
324
- .then(extract)
325
-
336
+ .then(extract);
337
+ };
338
+
339
+ // Attempt to download and extract the JRE/JDK
340
+ return attemptDownload(url)
341
+ .catch(err => {
342
+ console.error("Download failed: ", err);
343
+ // Exit with non-zero status code to signal failure to CI/CD systems
344
+ process.exit(1);
345
+ });
326
346
  }
327
347
 
328
- return {install:install};
329
-
330
-
331
348
 
349
+ return {install:install};
332
350
  }
333
351
 
334
352
 
335
353
  var fs = require('fs');
336
- var os = require('os');
337
- var path = require('path');
338
354
  const njre = njreWrap();
339
355
  const targetJavaVersion = parseInt(javaVersionString);
340
356
  var shell = require("shelljs/global");
341
- function getJdeploySupportDir() {
342
- return os.homedir() + path.sep + ".jdeploy";
343
- }
344
357
 
345
358
  function getJavaVersion(binPath) {
346
359
 
@@ -408,7 +421,7 @@ function getJavaHomeInPath(basepath) {
408
421
  }
409
422
 
410
423
  function findSupportedRuntime(javaVersion, jdk, javafx) {
411
- var jdeployDir = path.join(os.homedir(), ".jdeploy");
424
+ var jdeployDir = jdeployHomeDir;
412
425
  var JAVA_HOME_OVERRIDE = env['JDEPLOY_JAVA_HOME_OVERRIDE'];
413
426
 
414
427
  if (JAVA_HOME_OVERRIDE && fs.existsSync(JAVA_HOME_OVERRIDE)) {
@@ -460,7 +473,7 @@ function getEmbeddedJavaHome() {
460
473
  }
461
474
  var typeDir = jdk ? 'jdk' : 'jre';
462
475
 
463
- var jreDir = path.join(os.homedir(), '.jdeploy', 'jre', vs, 'jre');
476
+ var jreDir = path.join(jdeployHomeDir, 'jre', vs, 'jre');
464
477
  try {
465
478
  var out = jreDir + path.sep + getDirectories(jreDir)[0] + (_driver ? (path.sep + _driver) : '');
466
479
  return out;
@@ -526,7 +539,7 @@ if (!done) {
526
539
  }
527
540
 
528
541
  if (!done) {
529
- console.log("Downloading java runtime environment for version "+targetJavaVersion);
542
+ console.error("Downloading java runtime environment for version "+targetJavaVersion);
530
543
  njre.install(targetJavaVersion, {type: bundleType, javafx: javafx}).then(function(dir) {
531
544
  var _javaHome = getJavaHomeInPath(dir);
532
545
  if (_javaHome == null)
@@ -541,13 +554,15 @@ if (!done) {
541
554
  javaBinary += '.exe';
542
555
 
543
556
  }
544
- fs.chmodSync(javaBinary, 0755);
557
+ fs.chmodSync(javaBinary, 0o755);
545
558
 
546
559
  env['PATH'] = path.join(env['JAVA_HOME'], 'bin') + path.delimiter + env['PATH'];
547
560
 
548
561
  run(env['JAVA_HOME']);
549
562
  }).catch(function(err) {
550
- console.log("Failed to install JRE", err);
563
+ console.error("Failed to install JRE", err);
564
+ // Exit with non-zero status code to signal failure to CI/CD systems
565
+ process.exit(1);
551
566
  });
552
567
  }
553
568
 
@@ -573,6 +588,7 @@ function run(_javaHome) {
573
588
 
574
589
  var userArgs = process.argv.slice(2);
575
590
  var javaArgs = [];
591
+ javaArgs.push('-Djdeploy.mode=npx');
576
592
  javaArgs.push('-Djdeploy.base='+__dirname);
577
593
  javaArgs.push('-Djdeploy.port='+port);
578
594
  javaArgs.push('-Djdeploy.war.path='+warPath);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1 +1 @@
1
- {"bin":{"Phase2UI":"jdeploy-bundle/jdeploy.js"},"author":"ARI LJMU","description":"Liverpool Telescope Phase2UI","main":"index.js","preferGlobal":true,"repository":"","version":"2.1.1","jdeploy":{"jdk":false,"checksums":{"icon.png":"c61683452fcbd89eec1cfee19fbbb755"},"javaVersion":"8","jar":"Phase2UI.jar","javafx":false,"title":"Liverpool-Telescope-Phase2UI"},"dependencies":{"command-exists-promise":"^2.0.2","node-fetch":"2.6.7","tar":"^4.4.8","yauzl":"^2.10.0","shelljs":"^0.8.4"},"license":"ISC","name":"liverpool-telescope-phase2ui","files":["jdeploy-bundle"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"}}
1
+ {"bin":{"Phase2UI":"jdeploy-bundle/jdeploy.js"},"author":"ARI LJMU","description":"Liverpool Telescope Phase2UI.","main":"index.js","preferGlobal":true,"version":"2.1.2","jdeploy":{"checksums":{"icon.png":"c61683452fcbd89eec1cfee19fbbb755"},"fallbackToUniversal":false,"generateLegacyBundles":false,"mainClass":"ngat.oss.client.gui.frame.LoginFrame","publishTargets":[{"name":"npm: npm","type":"NPM","url":""}],"javaVersion":"8","jar":"Phase2UI.jar","title":"Liverpool-Telescope-Phase2UI","platformBundlesEnabled":false,"downloadPage":{"platforms":["default"]}},"dependencies":{"command-exists-promise":"^2.0.2","node-fetch":"2.6.7","tar":"^4.4.8","yauzl":"^2.10.0","shelljs":"^0.8.4"},"license":"ISC","name":"liverpool-telescope-phase2ui","files":["jdeploy-bundle"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"homepage":"telescope.livjm.ac.uk"}