@oclif/plugin-update 4.4.12 → 4.4.13-dev.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -55,7 +55,7 @@ EXAMPLES
55
55
  $ oclif-example update --available
56
56
  ```
57
57
 
58
- _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v4.4.12/src/commands/update.ts)_
58
+ _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v4.4.13-dev.1/src/commands/update.ts)_
59
59
  <!-- commandsstop -->
60
60
 
61
61
  # Contributing
package/dist/update.js CHANGED
@@ -2,10 +2,11 @@ import { Config, ux } from '@oclif/core';
2
2
  import { green, yellow } from 'ansis';
3
3
  import makeDebug from 'debug';
4
4
  import fileSize from 'filesize';
5
- import { got } from 'got';
5
+ import { HTTPError, got } from 'got';
6
6
  import { existsSync } from 'node:fs';
7
7
  import { mkdir, readFile, readdir, rm, stat, symlink, utimes, writeFile } from 'node:fs/promises';
8
8
  import { basename, dirname, join } from 'node:path';
9
+ import { ProxyAgent } from 'proxy-agent';
9
10
  import { Extractor } from './tar.js';
10
11
  import { ls, wait } from './util.js';
11
12
  const debug = makeDebug('oclif:update');
@@ -13,6 +14,23 @@ const filesize = (n) => {
13
14
  const [num, suffix] = fileSize(n, { output: 'array' });
14
15
  return Number.parseFloat(num).toFixed(1) + ` ${suffix}`;
15
16
  };
17
+ async function httpGet(url) {
18
+ debug(`[${url}] GET`);
19
+ return got
20
+ .get(url, {
21
+ agent: { https: new ProxyAgent() },
22
+ })
23
+ .then((res) => {
24
+ debug(`[${url}] ${res.statusCode}`);
25
+ return res;
26
+ })
27
+ .catch((error) => {
28
+ debug(`[${url}] ${error.response?.statusCode ?? error.code}`);
29
+ // constructing a new HTTPError here will produce a more actionable stack trace
30
+ debug(new HTTPError(error.response));
31
+ throw error;
32
+ });
33
+ }
16
34
  export class Updater {
17
35
  config;
18
36
  clientBin;
@@ -25,7 +43,7 @@ export class Updater {
25
43
  async fetchVersionIndex() {
26
44
  const newIndexUrl = this.config.s3Url(s3VersionIndexKey(this.config));
27
45
  try {
28
- const { body } = await got.get(newIndexUrl);
46
+ const { body } = await httpGet(newIndexUrl);
29
47
  return typeof body === 'string' ? JSON.parse(body) : body;
30
48
  }
31
49
  catch {
@@ -243,7 +261,7 @@ const composeS3SubDir = (config) => {
243
261
  const fetchManifest = async (s3Key, config) => {
244
262
  ux.action.status = 'fetching manifest';
245
263
  const url = config.s3Url(s3Key);
246
- const { body } = await got.get(url);
264
+ const { body } = await httpGet(url);
247
265
  if (typeof body === 'string') {
248
266
  return JSON.parse(body);
249
267
  }
@@ -339,7 +357,7 @@ const determineChannel = async ({ config, version }) => {
339
357
  return channel;
340
358
  }
341
359
  try {
342
- const { body } = await got.get(`${config.npmRegistry ?? 'https://registry.npmjs.org'}/${config.pjson.name}`);
360
+ const { body } = await httpGet(`${config.npmRegistry ?? 'https://registry.npmjs.org'}/${config.pjson.name}`);
343
361
  const tags = body['dist-tags'];
344
362
  const tag = Object.keys(tags).find((v) => tags[v] === version) ?? channel;
345
363
  // convert from npm style tag defaults to OCLIF style
@@ -96,5 +96,5 @@
96
96
  ]
97
97
  }
98
98
  },
99
- "version": "4.4.12"
99
+ "version": "4.4.13-dev.1"
100
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oclif/plugin-update",
3
- "version": "4.4.12",
3
+ "version": "4.4.13-dev.1",
4
4
  "author": "Salesforce",
5
5
  "bugs": "https://github.com/oclif/plugin-update/issues",
6
6
  "dependencies": {
@@ -10,6 +10,7 @@
10
10
  "debug": "^4.3.5",
11
11
  "filesize": "^6.1.0",
12
12
  "got": "^13",
13
+ "proxy-agent": "^6.4.0",
13
14
  "semver": "^7.6.3",
14
15
  "tar-fs": "^2.1.1",
15
16
  "tty-table": "^4.2.3"