@ijuantm/simpl-addon 2.2.0 → 2.3.0
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/install.js +55 -5
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -114,14 +114,21 @@ const checkServerAvailability = () => new Promise(resolve => {
|
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
const
|
|
118
|
-
|
|
117
|
+
const getVersionsData = async () => {
|
|
118
|
+
if (!await checkServerAvailability()) throw new Error('CDN server is currently unreachable');
|
|
119
|
+
return JSON.parse(await fetchUrl(`${CDN_BASE}/versions.json`));
|
|
120
|
+
};
|
|
119
121
|
|
|
120
|
-
|
|
122
|
+
const getAvailableAddons = async (version) => {
|
|
123
|
+
const localAddonsDir = path.join(LOCAL_RELEASES_DIR, version, 'add-ons');
|
|
121
124
|
|
|
122
|
-
if (
|
|
125
|
+
if (fs.existsSync(localAddonsDir)) return fs.readdirSync(localAddonsDir, {withFileTypes: true})
|
|
126
|
+
.filter(entry => entry.isFile() && entry.name.endsWith('.zip'))
|
|
127
|
+
.map(entry => entry.name.replace('.zip', ''));
|
|
123
128
|
|
|
124
|
-
|
|
129
|
+
const versionsData = await getVersionsData();
|
|
130
|
+
const versionMeta = versionsData.versions[version];
|
|
131
|
+
return versionMeta?.['add-ons'] || [];
|
|
125
132
|
};
|
|
126
133
|
|
|
127
134
|
const extractMarkers = (content) => {
|
|
@@ -376,6 +383,49 @@ const main = async () => {
|
|
|
376
383
|
log(` │ ${COLORS.bold}Simpl Add-on Installer${COLORS.reset} ${COLORS.dim}(${version})${COLORS.reset}${' '.repeat(37 - version.length)}│`);
|
|
377
384
|
log(` ╰${'─'.repeat(62)}╯`);
|
|
378
385
|
console.log();
|
|
386
|
+
|
|
387
|
+
let versionsData;
|
|
388
|
+
|
|
389
|
+
try {
|
|
390
|
+
versionsData = await getVersionsData();
|
|
391
|
+
} catch (error) {
|
|
392
|
+
console.log();
|
|
393
|
+
log(` ${COLORS.red}✗${COLORS.reset} Failed to fetch version data`, 'red');
|
|
394
|
+
if (error.message === 'CDN server is currently unreachable') log(` ${COLORS.dim}The CDN server is currently unavailable. Please try again later.${COLORS.reset}`);
|
|
395
|
+
console.log();
|
|
396
|
+
process.exit(1);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const versionMeta = versionsData.versions[version];
|
|
400
|
+
if (!versionMeta) {
|
|
401
|
+
console.log();
|
|
402
|
+
log(` ${COLORS.red}✗${COLORS.reset} Version ${COLORS.bold}${version}${COLORS.reset} not found`, 'red');
|
|
403
|
+
console.log();
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (versionMeta['script-compatible'] === false) {
|
|
408
|
+
console.log();
|
|
409
|
+
log(` ${COLORS.red}✗${COLORS.reset} Version ${COLORS.bold}${version}${COLORS.reset} is not compatible with this installer`, 'red');
|
|
410
|
+
console.log();
|
|
411
|
+
log(` ${COLORS.bold}Manual download:${COLORS.reset}`, 'blue');
|
|
412
|
+
log(` ${COLORS.cyan}${CDN_BASE}/${version}/add-ons/`, 'cyan');
|
|
413
|
+
console.log();
|
|
414
|
+
log(` ${COLORS.bold}Available add-ons for this version:${COLORS.reset}`, 'blue');
|
|
415
|
+
|
|
416
|
+
const addons = versionMeta['add-ons'] || [];
|
|
417
|
+
if (addons.length === 0) {
|
|
418
|
+
log(` ${COLORS.dim}No add-ons available${COLORS.reset}`);
|
|
419
|
+
} else {
|
|
420
|
+
addons.forEach(name => {
|
|
421
|
+
log(` ${COLORS.cyan}•${COLORS.reset} ${name}: ${COLORS.dim}${CDN_BASE}/${version}/add-ons/${name}.zip${COLORS.reset}`);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
console.log();
|
|
426
|
+
process.exit(1);
|
|
427
|
+
}
|
|
428
|
+
|
|
379
429
|
log(' 📦 Fetching available add-ons...', 'bold');
|
|
380
430
|
|
|
381
431
|
let addons;
|