Check external module versions

This commit is contained in:
Samuel Elliott 2019-03-23 00:15:31 +00:00
parent d81e92ce55
commit 7d1509f20e
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
5 changed files with 12 additions and 6 deletions

View File

@ -21,6 +21,7 @@ import { SettingsSet, ErrorEvent } from 'structs';
import { Modals } from 'ui';
import Combokeys from 'combokeys';
import Settings from './settings';
import semver from 'semver';
/**
* Base class for managing external content
@ -262,6 +263,8 @@ export default class {
const readConfig = packed ? dirName.config : await FileUtils.readJsonFromFile(configPath);
const mainPath = path.join(contentPath, readConfig.main || 'index.js');
readConfig.info.version = semver.coerce(`${readConfig.info.version || .1}`).version;
const defaultConfig = new SettingsSet({
settings: readConfig.defaultConfig,
schemes: readConfig.configSchemes

View File

@ -19,6 +19,7 @@ import Plugin from './plugin';
import PluginApi from './pluginapi';
import Vendor from './vendor';
import path from 'path';
import semver from 'semver';
export default class PluginManager extends ContentManager {
@ -114,6 +115,8 @@ export default class PluginManager extends ContentManager {
if (!extModule) throw {message: `Dependency ${key} is not loaded.`};
}
if (!semver.satisfies(extModule.version, value)) throw {message: `This plugin requires a different version of ${key}.`};
deps[key] = deps[extModule.id] = extModule.__require;
}
}

View File

@ -38,21 +38,21 @@ class ReleaseInfo {
get core() {
const f = this.files.find(f => f.id === 'core');
f.upToDate = semver.satisfies(this.versions.core, `>=${f.version}`, { includePrerelease: true });
f.upToDate = semver.gte(this.versions.core, f.version, { includePrerelease: true });
f.currentVersion = this.versions.core;
return f;
}
get client() {
const f = this.files.find(f => f.id === 'client');
f.upToDate = semver.satisfies(this.versions.client, `>=${f.version}`, { includePrerelease: true });
f.upToDate = semver.gte(this.versions.client, f.version, { includePrerelease: true });
f.currentVersion = this.versions.client;
return f;
}
get editor() {
const f = this.files.find(f => f.id === 'editor');
f.upToDate = semver.satisfies(this.versions.editor, `>=${f.version}`, { includePrerelease: true });
f.upToDate = semver.gte(this.versions.editor, f.version, { includePrerelease: true });
f.currentVersion = this.versions.editor;
return f;
}

View File

@ -2,9 +2,9 @@
"info": {
"name": "Example Module",
"authors": [ "Jiiks" ],
"version": "1.0",
"version": "1.0.1",
"description": "Module Example"
},
"main": "index.js",
"type": "module"
"type": "module"
}

View File

@ -29,7 +29,7 @@
},
"main": "index.js",
"dependencies": {
"Example Module": "1.0"
"Example Module": "^1.0"
},
"defaultConfig": [
{