@oclif/plugin-update 3.1.15 → 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 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
- if (fs.existsSync(channelPath)) {
229
- const channel = await fs.readFile(channelPath, 'utf8');
230
- return String(channel).trim();
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 {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.1.15",
2
+ "version": "3.1.17",
3
3
  "commands": {
4
4
  "update": {
5
5
  "id": "update",
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@oclif/plugin-update",
3
- "version": "3.1.15",
3
+ "version": "3.1.17",
4
4
  "author": "Salesforce",
5
5
  "bugs": "https://github.com/oclif/plugin-update/issues",
6
6
  "dependencies": {
7
- "@oclif/color": "^1.0.4",
7
+ "@oclif/color": "^1.0.5",
8
8
  "@oclif/core": "^2.8.5",
9
9
  "cross-spawn": "^7.0.3",
10
10
  "debug": "^4.3.1",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@oclif/plugin-help": "^5.2.9",
22
- "@oclif/test": "^2.3.19",
22
+ "@oclif/test": "^2.3.21",
23
23
  "@types/chai": "^4.3.5",
24
24
  "@types/cross-spawn": "^6.0.2",
25
25
  "@types/execa": "^0.9.0",
@@ -28,7 +28,7 @@
28
28
  "@types/inquirer": "^8.2.0",
29
29
  "@types/lodash.throttle": "^4.1.6",
30
30
  "@types/mocha": "^9",
31
- "@types/node": "^14.18.47",
31
+ "@types/node": "^14.18.48",
32
32
  "@types/semver": "^7.5.0",
33
33
  "@types/supports-color": "^7.2.0",
34
34
  "@types/write-json-file": "^3.2.1",
@@ -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.0",
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
- // }