make smartupdate resilient
This commit is contained in:
parent
0f15afbb60
commit
1c5c2e9481
15
dist/index.js
vendored
15
dist/index.js
vendored
@ -37,9 +37,13 @@ class SmartUpdate {
|
||||
}
|
||||
}
|
||||
let npmPackage = yield this.getNpmPackageFromRegistry(npmnameArg);
|
||||
if (!npmPackage) {
|
||||
return;
|
||||
}
|
||||
newData.latestVersion = npmPackage.version;
|
||||
let upgradeBool = yield this.checkIfUpgrade(npmPackage, compareVersion, changelogUrlArg);
|
||||
if (upgradeBool) {
|
||||
// TODO:
|
||||
}
|
||||
this.kvStore.writeKey(npmnameArg, newData);
|
||||
});
|
||||
@ -48,7 +52,14 @@ class SmartUpdate {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
plugins.beautylog.log(`smartupdate: checking for newer version of ${plugins.beautycolor.coloredString(npmnameArg, 'pink')}...`);
|
||||
let npmRegistry = new plugins.smartnpm.NpmRegistry();
|
||||
let npmPackage = (yield npmRegistry.search({ name: npmnameArg, boostExact: true }))[0];
|
||||
let npmPackage;
|
||||
try {
|
||||
npmPackage = (yield npmRegistry.search({ name: npmnameArg, boostExact: true }))[0];
|
||||
}
|
||||
catch (err) {
|
||||
plugins.beautylog.warn('failed to retrieve package information...');
|
||||
return null;
|
||||
}
|
||||
return npmPackage;
|
||||
});
|
||||
}
|
||||
@ -75,4 +86,4 @@ class SmartUpdate {
|
||||
}
|
||||
exports.SmartUpdate = SmartUpdate;
|
||||
exports.standardHandler = new SmartUpdate();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsaURBQWdEO0FBRWhELHlDQUFxQztBQVVyQztJQUFBO1FBQ0UsWUFBTyxHQUFHLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxhQUF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QUMsQ0FBQyxDQUFDO29CQUN2QyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyw2QkFBNkIsQ0FBQyxDQUFBO29CQUNwRCxPQUFPLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxlQUFlLENBQUMsQ0FBQTtnQkFDNUMsQ0FBQztnQkFDRCxNQUFNLENBQUMsSUFBSSxDQUFBO1lBQ2IsQ0FBQztRQUNILENBQUM7S0FBQTtDQUNGO0FBN0VELGtDQTZFQztBQUNVLFFBQUEsZUFBZSxHQUFHLElBQUksV0FBVyxFQUFFLENBQUEifQ==
|
16
ts/index.ts
16
ts/index.ts
@ -14,7 +14,6 @@ export class SmartUpdate {
|
||||
kvStore = new plugins.npmextra.KeyValueStore('custom', 'global:smartupdate')
|
||||
|
||||
async check (npmnameArg: string, compareVersion: string, changelogUrlArg?: string) {
|
||||
|
||||
// the newData to write
|
||||
let timeStamp = new TimeStamp()
|
||||
let newData = {
|
||||
@ -43,18 +42,27 @@ export class SmartUpdate {
|
||||
}
|
||||
}
|
||||
let npmPackage = await this.getNpmPackageFromRegistry(npmnameArg)
|
||||
if (!npmPackage) {
|
||||
return
|
||||
}
|
||||
newData.latestVersion = npmPackage.version
|
||||
let upgradeBool = await this.checkIfUpgrade(npmPackage, compareVersion, changelogUrlArg)
|
||||
if (upgradeBool) {
|
||||
|
||||
// TODO:
|
||||
}
|
||||
this.kvStore.writeKey(npmnameArg, newData)
|
||||
}
|
||||
|
||||
private async getNpmPackageFromRegistry (npmnameArg) {
|
||||
private async getNpmPackageFromRegistry (npmnameArg): Promise<plugins.smartnpm.NpmPackage> {
|
||||
plugins.beautylog.log(`smartupdate: checking for newer version of ${plugins.beautycolor.coloredString(npmnameArg, 'pink')}...`)
|
||||
let npmRegistry = new plugins.smartnpm.NpmRegistry()
|
||||
let npmPackage = (await npmRegistry.search({ name: npmnameArg, boostExact: true }))[0]
|
||||
let npmPackage: plugins.smartnpm.NpmPackage
|
||||
try {
|
||||
npmPackage = (await npmRegistry.search({ name: npmnameArg, boostExact: true }))[0]
|
||||
} catch (err) {
|
||||
plugins.beautylog.warn('failed to retrieve package information...')
|
||||
return null
|
||||
}
|
||||
return npmPackage
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user