@oclif/plugin-update 3.1.16 → 3.1.17
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/lib/update.js +18 -7
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/lib/github.d.ts +0 -0
- package/lib/github.js +0 -23
package/lib/update.js
CHANGED
@@ -31,7 +31,7 @@ class Updater {
|
|
31
31
|
core_1.ux.action.stop('not updatable');
|
32
32
|
return;
|
33
33
|
}
|
34
|
-
const channel = options.channel || await this.determineChannel();
|
34
|
+
const channel = options.channel || await this.determineChannel(version);
|
35
35
|
const current = await this.determineCurrentVersion();
|
36
36
|
if (version) {
|
37
37
|
const localVersion = force ? null : await this.findLocalVersion(version);
|
@@ -223,13 +223,24 @@ class Updater {
|
|
223
223
|
alreadyOnVersion(current, updated) {
|
224
224
|
return current === updated;
|
225
225
|
}
|
226
|
-
async determineChannel() {
|
226
|
+
async determineChannel(version) {
|
227
|
+
var _a, _b;
|
227
228
|
const channelPath = path.join(this.config.dataDir, 'channel');
|
228
|
-
|
229
|
-
|
230
|
-
|
229
|
+
const channel = fs.existsSync(channelPath) ? (await fs.readFile(channelPath, 'utf8')).trim() : 'stable';
|
230
|
+
try {
|
231
|
+
const { body } = await http_call_1.default.get(`${(_a = this.config.npmRegistry) !== null && _a !== void 0 ? _a : 'https://registry.npmjs.org'}/${this.config.pjson.name}`);
|
232
|
+
const tags = body['dist-tags'];
|
233
|
+
const tag = (_b = Object.keys(tags).find(v => tags[v] === version)) !== null && _b !== void 0 ? _b : channel;
|
234
|
+
// convert from npm style tag defaults to OCLIF style
|
235
|
+
if (tag === 'latest')
|
236
|
+
return 'stable';
|
237
|
+
if (tag === 'latest-rc')
|
238
|
+
return 'stable-rc';
|
239
|
+
return tag;
|
240
|
+
}
|
241
|
+
catch (_c) {
|
242
|
+
return channel;
|
231
243
|
}
|
232
|
-
return this.config.channel || 'stable';
|
233
244
|
}
|
234
245
|
determinePlatform() {
|
235
246
|
return this.config.platform === 'wsl' ? 'linux' : this.config.platform;
|
@@ -253,7 +264,7 @@ class Updater {
|
|
253
264
|
}
|
254
265
|
async setChannel(channel) {
|
255
266
|
const channelPath = path.join(this.config.dataDir, 'channel');
|
256
|
-
fs.writeFile(channelPath, channel, 'utf8');
|
267
|
+
await fs.writeFile(channelPath, channel, 'utf8');
|
257
268
|
}
|
258
269
|
async logChop() {
|
259
270
|
try {
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oclif/plugin-update",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.17",
|
4
4
|
"author": "Salesforce",
|
5
5
|
"bugs": "https://github.com/oclif/plugin-update/issues",
|
6
6
|
"dependencies": {
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"qqjs": "^0.3.11",
|
44
44
|
"sinon": "^12.0.1",
|
45
45
|
"ts-node": "^9.1.1",
|
46
|
-
"tslib": "^2.5.
|
46
|
+
"tslib": "^2.5.3",
|
47
47
|
"typescript": "4.4.3"
|
48
48
|
},
|
49
49
|
"engines": {
|
package/lib/github.d.ts
DELETED
File without changes
|
package/lib/github.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
// import HTTP from 'http-call'
|
3
|
-
// import {Updater} from '.'
|
4
|
-
// export class GithubUpdater extends Updater {
|
5
|
-
// release?: {tag_name: string}
|
6
|
-
// async update() {
|
7
|
-
// const release = await this.fetchRelease()
|
8
|
-
// const version = release.tag_name.split('v')[1]
|
9
|
-
// const base = this.base(version)
|
10
|
-
// const asset = release.assets.find((a: any) => a.name === `${base}.tar.gz`)
|
11
|
-
// if (!asset) throw new Error('release not found')
|
12
|
-
// return super.update({url: asset.browser_download_url, version})
|
13
|
-
// }
|
14
|
-
// async needsUpdate() {
|
15
|
-
// const version = (await this.fetchRelease()).tag_name.split('v')[1]
|
16
|
-
// return this.config.version !== version
|
17
|
-
// }
|
18
|
-
// private async fetchRelease() {
|
19
|
-
// const [owner, repo] = this.config.pjson.repository.split('/')
|
20
|
-
// const {body} = await HTTP.get(`https://api.github.com/repos/${owner}/${repo}/releases/latest`)
|
21
|
-
// return this.release = body
|
22
|
-
// }
|
23
|
-
// }
|