[Updater > Module] Rewrite bootstrap, remove installPendingUpdates for simplicity
This commit is contained in:
parent
785bd0a672
commit
5070e01d4e
|
@ -20,11 +20,7 @@ exports.initSplash = (startMin = false) => {
|
||||||
|
|
||||||
launchSplash(startMin);
|
launchSplash(startMin);
|
||||||
|
|
||||||
if (newUpdater != null) {
|
if (newUpdater != null) updateUntilCurrent();
|
||||||
updateUntilCurrent();
|
|
||||||
} else {
|
|
||||||
moduleUpdater.installPendingUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
|
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
|
||||||
destroySplash();
|
destroySplash();
|
||||||
|
@ -253,7 +249,6 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
|
||||||
add('installed-module', segmentCallback(installs));
|
add('installed-module', segmentCallback(installs));
|
||||||
|
|
||||||
add('installing-modules-finished', callbackCheck);
|
add('installing-modules-finished', callbackCheck);
|
||||||
add('no-pending-updates', callbackCheck);
|
|
||||||
|
|
||||||
const progressCallback = (tracker) => ({ name, cur, total }) => tracker.record(name, '', cur, total);
|
const progressCallback = (tracker) => ({ name, cur, total }) => tracker.record(name, '', cur, total);
|
||||||
|
|
||||||
|
@ -267,6 +262,8 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
|
||||||
});
|
});
|
||||||
|
|
||||||
sendState(CHECKING_FOR_UPDATES);
|
sendState(CHECKING_FOR_UPDATES);
|
||||||
|
|
||||||
|
callbackCheck();
|
||||||
};
|
};
|
||||||
|
|
||||||
const scheduleNextUpdate = (callback = moduleUpdater.checkForUpdates) => { // Used by v1 and v2, default to v1 as used more widely in it
|
const scheduleNextUpdate = (callback = moduleUpdater.checkForUpdates) => { // Used by v1 and v2, default to v1 as used more widely in it
|
||||||
|
|
|
@ -10,8 +10,7 @@ const request = require('./request');
|
||||||
const events = exports.events = new (require('events').EventEmitter)();
|
const events = exports.events = new (require('events').EventEmitter)();
|
||||||
exports.INSTALLED_MODULE = 'installed-module'; // Fixes DiscordNative ensureModule as it uses export
|
exports.INSTALLED_MODULE = 'installed-module'; // Fixes DiscordNative ensureModule as it uses export
|
||||||
|
|
||||||
let bootstrapping,
|
let skipHost, skipModule,
|
||||||
skipHost, skipModule,
|
|
||||||
remote = {},
|
remote = {},
|
||||||
installed = {},
|
installed = {},
|
||||||
downloading, installing,
|
downloading, installing,
|
||||||
|
@ -49,8 +48,10 @@ exports.init = (endpoint, { releaseChannel, version }) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
installed = JSON.parse(fs.readFileSync(manifestPath));
|
installed = JSON.parse(fs.readFileSync(manifestPath));
|
||||||
} catch (e) {
|
} catch {
|
||||||
bootstrapping = true;
|
for (const m in JSON.parse(fs.readFileSync(join(paths.getResources(), 'bootstrap', 'manifest.json')))) { // Read [resources]/bootstrap/manifest.json, with "moduleName": version (always 0)
|
||||||
|
installed[m] = { installedVersion: 0 }; // Set initial version as 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,8 +340,6 @@ const finishInstall = (name, ver, success) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
resetTracking();
|
resetTracking();
|
||||||
|
|
||||||
bootstrapping = false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -392,18 +391,4 @@ exports.install = (name, def, { version } = {}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadModule(name, version ?? remote[name] ?? 0);
|
downloadModule(name, version ?? remote[name] ?? 0);
|
||||||
};
|
|
||||||
|
|
||||||
exports.installPendingUpdates = () => {
|
|
||||||
if (bootstrapping) {
|
|
||||||
log('Modules', 'Bootstrapping...');
|
|
||||||
|
|
||||||
for (const m in JSON.parse(fs.readFileSync(join(paths.getResources(), 'bootstrap', 'manifest.json')))) { // Read [resources]/bootstrap/manifest.json, with "moduleName": version (always 0)
|
|
||||||
installed[m] = { installedVersion: 0 }; // Set initial version as 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return exports.checkForUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
events.emit('no-pending-updates');
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue