schoolzyinstall 1.0.41 → 1.0.43

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.
@@ -1,8 +1,5 @@
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');
6
3
  var jarName = "schoolzy.jar";
7
4
  var mainClass = "{{MAIN_CLASS}}";
8
5
  var classPath = "{{CLASSPATH}}";
@@ -26,7 +23,9 @@ var jdkProvider = 'zulu';
26
23
  function njreWrap() {
27
24
  'use strict'
28
25
 
26
+ const path = require('path')
29
27
  const fs = require('fs')
28
+ const os = require('os')
30
29
  const crypto = require('crypto')
31
30
  const fetch = require('node-fetch')
32
31
  const yauzl = require('yauzl')
@@ -106,7 +105,7 @@ function njreWrap() {
106
105
 
107
106
  function move (file) {
108
107
  return new Promise((resolve, reject) => {
109
- const jdeployDir = jdeployHomeDir;
108
+ const jdeployDir = path.join(os.homedir(), '.jdeploy');
110
109
  if (!fs.existsSync(jdeployDir)) {
111
110
  fs.mkdirSync(jdeployDir);
112
111
  }
@@ -232,16 +231,8 @@ function njreWrap() {
232
231
  const { openjdk_impl = 'hotspot', release = 'latest', type = 'jre', javafx = false, provider = 'zulu' } = options
233
232
  options = { ...options, openjdk_impl, release, type }
234
233
 
235
- // Determine the architecture based on the platform and environment
236
- let arch = process.arch;
237
- if (arch === 'arm64' || arch === 'aarch64') {
238
- arch = 'aarch64'; // For ARM-based systems, standardize on aarch64
239
- } else {
240
- arch = 'x64'; // Default to x64 for non-ARM systems
241
- }
242
-
243
234
  if (provider === 'zulu') {
244
- return installZulu(version, options, arch);
235
+ return installZulu(version, options);
245
236
  }
246
237
 
247
238
  let url = 'https://api.adoptopenjdk.net/v2/info/releases/openjdk' + version + '?'
@@ -267,9 +258,13 @@ function njreWrap() {
267
258
  return Promise.reject(new Error('Unsupported operating system'))
268
259
  }
269
260
  }
270
-
271
261
  if (!options.arch) {
272
- options.arch = arch; // Use the detected architecture
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'))
273
268
  }
274
269
 
275
270
  Object.keys(options).forEach(key => { url += key + '=' + options[key] + '&' })
@@ -284,85 +279,68 @@ function njreWrap() {
284
279
  .then(extract)
285
280
  }
286
281
 
287
- function installZulu(version = 11, options = {}, arch) {
288
- const { type = 'jre', javafx = false } = options;
282
+ function installZulu(version = 11, options = {}) {
283
+ const { type = 'jre', javafx = false } = options
284
+ var q = {
289
285
 
290
- // Prepare the query parameters for the request
291
- let q = {
292
286
  java_version: version,
293
287
  ext: 'zip',
294
288
  bundle_type: type,
295
- javafx: '' + javafx,
296
- arch: arch, // Use the detected architecture
289
+ javafx: ''+javafx,
290
+ arch: 'x86',
297
291
  hw_bitness: '64',
298
- };
299
292
 
300
- // Base URL for the Azul API
301
- const zuluBaseURL = "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary?";
293
+ };
302
294
 
303
- // Determine the OS
304
- if (!options.os) {
305
- switch (process.platform) {
306
- case 'darwin':
307
- q.os = 'macos';
308
- break;
309
- case 'linux':
310
- q.os = 'linux';
311
- q.ext = 'tar.gz';
312
- break;
313
- case 'win32':
314
- case 'win64':
315
- q.os = 'windows';
316
- break;
317
- default:
318
- return Promise.reject(new Error('Unsupported operating system'));
319
- }
320
- }
321
295
 
322
- // Construct the URL for the download request
323
- let url = zuluBaseURL;
324
- Object.keys(q).forEach(key => { url += key + '=' + q[key] + '&' });
296
+ var zuluBaseURL = "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary?"
297
+ if (!options.os) {
298
+ switch (process.platform) {
325
299
 
326
- const tmpdir = path.join(os.tmpdir(), 'njre');
300
+ case 'darwin':
301
+ q.os = 'macos'
302
+ break
303
+ case 'linux':
304
+ q.os = 'linux'
305
+ q.ext = 'tar.gz'
306
+ break
327
307
 
328
- // Function to handle the download and extraction
329
- const attemptDownload = (url) => {
330
- return download(tmpdir, url)
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
+ }
316
+
317
+
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)
331
323
  .then(move)
332
- .then(extract);
333
- };
334
-
335
- // First, attempt to download the JRE
336
- return download(tmpdir, url)
337
- .then(response => {
338
- // If the JRE is available, proceed with the download and extraction
339
- if (response.status === 200) {
340
- return attemptDownload(url);
341
- } else {
342
- // If JRE is not available, switch to JDK
343
- console.log(`JRE not available for version ${version}, falling back to JDK...`);
344
- // Update the query to request JDK instead of JRE
345
- q.bundle_type = 'jdk'; // Switch to JDK
346
- url = zuluBaseURL;
347
- Object.keys(q).forEach(key => { url += key + '=' + q[key] + '&' });
348
- return attemptDownload(url); // Try downloading the JDK
349
- }
350
- })
351
- .catch(err => {
352
- console.error("Download failed: ", err);
353
- throw err; // Re-throw the error after logging
354
- });
355
- }
324
+ .then(extract)
356
325
 
326
+ }
357
327
 
358
328
  return {install:install};
329
+
330
+
331
+
359
332
  }
360
333
 
361
334
 
362
335
  var fs = require('fs');
336
+ var os = require('os');
337
+ var path = require('path');
363
338
  const njre = njreWrap();
364
339
  const targetJavaVersion = parseInt(javaVersionString);
365
340
  var shell = require("shelljs/global");
341
+ function getJdeploySupportDir() {
342
+ return os.homedir() + path.sep + ".jdeploy";
343
+ }
366
344
 
367
345
  function getJavaVersion(binPath) {
368
346
 
@@ -430,7 +408,7 @@ function getJavaHomeInPath(basepath) {
430
408
  }
431
409
 
432
410
  function findSupportedRuntime(javaVersion, jdk, javafx) {
433
- var jdeployDir = jdeployHomeDir;
411
+ var jdeployDir = path.join(os.homedir(), ".jdeploy");
434
412
  var JAVA_HOME_OVERRIDE = env['JDEPLOY_JAVA_HOME_OVERRIDE'];
435
413
 
436
414
  if (JAVA_HOME_OVERRIDE && fs.existsSync(JAVA_HOME_OVERRIDE)) {
@@ -482,7 +460,7 @@ function getEmbeddedJavaHome() {
482
460
  }
483
461
  var typeDir = jdk ? 'jdk' : 'jre';
484
462
 
485
- var jreDir = path.join(jdeployHomeDir, 'jre', vs, 'jre');
463
+ var jreDir = path.join(os.homedir(), '.jdeploy', 'jre', vs, 'jre');
486
464
  try {
487
465
  var out = jreDir + path.sep + getDirectories(jreDir)[0] + (_driver ? (path.sep + _driver) : '');
488
466
  return out;
Binary file
package/package.json CHANGED
@@ -1 +1 @@
1
- {"bin":{"":"jdeploy-bundle/jdeploy.js"},"author":"Numidia Technology Solutions","description":"SchoolZy System","main":"index.js","preferGlobal":true,"repository":"","version":"1.0.41","jdeploy":{"jdk":false,"checksums":{"icon.png":"60d27fb17e93e2f92c6c3dfa4c11e500","installsplash.png":"f00367ebc9d091c52c47a26241b79fd7"},"publishTargets":[{"name":"npm: schoolzyinstall","type":"NPM","url":"schoolzyinstall"}],"javaVersion":"24","documentTypes":[],"jar":"target/schoolzy.jar","javafx":true,"title":"SchoolZy"},"dependencies":{"njre":"^0.2.0","shelljs":"^0.8.4"},"license":"ISC","name":"schoolzyinstall","files":["jdeploy-bundle"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"}}
1
+ {"bin":{"":"jdeploy-bundle/jdeploy.js"},"author":"Numidia Technology Solutions","description":"SchoolZy system","main":"index.js","preferGlobal":true,"repository":"","version":"1.0.43","jdeploy":{"jdk":false,"checksums":{"icon.png":"60d27fb17e93e2f92c6c3dfa4c11e500","installsplash.png":"60d27fb17e93e2f92c6c3dfa4c11e500"},"publishTargets":[{"name":"npm: schoolzyinstall","type":"NPM","url":"schoolzyinstall"}],"javaVersion":"24","jar":"target/schoolzy.jar","javafx":true,"title":"SchoolZy"},"dependencies":{"njre":"^0.2.0","shelljs":"^0.8.4"},"license":"ISC","name":"schoolzyinstall","files":["jdeploy-bundle"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"}}