@oclif/plugin-update 4.4.15 → 4.5.0

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/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.15/src/commands/update.ts)_
58
+ _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v4.5.0/src/commands/update.ts)_
59
59
  <!-- commandsstop -->
60
60
 
61
61
  # Contributing
@@ -0,0 +1,7 @@
1
+ import CommandsUpdate from './commands/update.js';
2
+ export declare const commands: {
3
+ update: typeof CommandsUpdate;
4
+ };
5
+ export declare const hooks: {
6
+ init: import("@oclif/core").Hook<"init">;
7
+ };
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import CommandsUpdate from './commands/update.js';
2
+ import { init } from './hooks/init.js';
3
+ export const commands = {
4
+ update: CommandsUpdate,
5
+ };
6
+ export const hooks = {
7
+ init,
8
+ };
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
  }
@@ -309,7 +327,10 @@ const downloadAndExtract = async (output, manifest, channel, config) => {
309
327
  platform: determinePlatform(config),
310
328
  version,
311
329
  }));
312
- const stream = got.stream(gzUrl);
330
+ debug(`Streaming ${gzUrl} to ${output}`);
331
+ const stream = got.stream(gzUrl, {
332
+ agent: { https: new ProxyAgent() },
333
+ });
313
334
  stream.pause();
314
335
  const baseDir = manifest.baseDir ??
315
336
  config.s3Key('baseDir', {
@@ -339,7 +360,7 @@ const determineChannel = async ({ config, version }) => {
339
360
  return channel;
340
361
  }
341
362
  try {
342
- const { body } = await got.get(`${config.npmRegistry ?? 'https://registry.npmjs.org'}/${config.pjson.name}`);
363
+ const { body } = await httpGet(`${config.npmRegistry ?? 'https://registry.npmjs.org'}/${config.pjson.name}`);
343
364
  const tags = body['dist-tags'];
344
365
  const tag = Object.keys(tags).find((v) => tags[v] === version) ?? channel;
345
366
  // convert from npm style tag defaults to OCLIF style
@@ -96,5 +96,5 @@
96
96
  ]
97
97
  }
98
98
  },
99
- "version": "4.4.15"
99
+ "version": "4.5.0"
100
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oclif/plugin-update",
3
- "version": "4.4.15",
3
+ "version": "4.5.0",
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.6",
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"