@oclif/plugin-update 5.0.0 → 5.0.1

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
@@ -81,7 +81,7 @@ EXAMPLES
81
81
  $ oclif-example update --available
82
82
  ```
83
83
 
84
- _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/5.0.0/src/commands/update.ts)_
84
+ _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/5.0.1/src/commands/update.ts)_
85
85
  <!-- commandsstop -->
86
86
 
87
87
  # Contributing
@@ -1,4 +1,4 @@
1
- import { Command, Interfaces } from '@oclif/core';
1
+ import { Command, type Interfaces } from '@oclif/core';
2
2
  export default class UpdateCommand extends Command {
3
3
  static args: {
4
4
  channel: Interfaces.Arg<string | undefined, Record<string, unknown>>;
@@ -1,2 +1,2 @@
1
- import { Interfaces } from '@oclif/core';
1
+ import { type Interfaces } from '@oclif/core';
2
2
  export declare const init: Interfaces.Hook<'init'>;
@@ -81,10 +81,12 @@ export const init = async function (opts) {
81
81
  detached: !config.windows,
82
82
  env: autoupdateEnv,
83
83
  stdio: ['ignore', stream, stream],
84
- ...(config.windows ? { shell: true } : {}),
84
+ ...(config.windows && { shell: true }),
85
85
  })
86
- .on('error', (e) => process.emitWarning(e))
87
- .on('close', () => fd.close())
86
+ .on('error', (e) => {
87
+ process.emitWarning(e);
88
+ })
89
+ .on('close', async () => fd.close())
88
90
  .unref();
89
91
  async function claimAutoupdate(markerPath) {
90
92
  // Fast path: try to atomically create the marker. Wins the race when no
package/dist/tar.js CHANGED
@@ -24,16 +24,16 @@ const ignore = (_name, header) => {
24
24
  }
25
25
  };
26
26
  async function extract(stream, basename, output, sha) {
27
- const getTmp = () => `${output}.partial.${Math.random().toString().split('.')[1].slice(0, 5)}`;
27
+ const getTmp = () => `${output}.partial.${Math.random().toString().split('.', 2)[1].slice(0, 5)}`;
28
28
  let tmp = getTmp();
29
29
  if (existsSync(tmp))
30
30
  tmp = getTmp();
31
31
  debug(`extracting to ${tmp}`);
32
32
  try {
33
33
  await new Promise((resolve, reject) => {
34
- let shaValidated = false;
35
- let extracted = false;
36
- const check = () => shaValidated && extracted && resolve(null);
34
+ let isShaValidated = false;
35
+ let isExtracted = false;
36
+ const check = () => isShaValidated && isExtracted && resolve(null);
37
37
  if (sha) {
38
38
  const hasher = crypto.createHash('sha256');
39
39
  stream.on('error', reject);
@@ -41,7 +41,7 @@ async function extract(stream, basename, output, sha) {
41
41
  stream.on('end', () => {
42
42
  const shasum = hasher.digest('hex');
43
43
  if (sha === shasum) {
44
- shaValidated = true;
44
+ isShaValidated = true;
45
45
  check();
46
46
  }
47
47
  else {
@@ -50,11 +50,11 @@ async function extract(stream, basename, output, sha) {
50
50
  });
51
51
  }
52
52
  else
53
- shaValidated = true;
53
+ isShaValidated = true;
54
54
  const extract = tarExtract(tmp, { ignore });
55
55
  extract.on('error', reject);
56
56
  extract.on('finish', () => {
57
- extracted = true;
57
+ isExtracted = true;
58
58
  check();
59
59
  });
60
60
  const gunzip = zlib.createGunzip();
package/dist/update.js CHANGED
@@ -71,8 +71,8 @@ export class Updater {
71
71
  determineCurrentVersion(this.clientBin, this.config.version),
72
72
  ]);
73
73
  if (version) {
74
- const localVersion = force ? null : await this.findLocalVersion(version);
75
- if (alreadyOnVersion(current, localVersion || null)) {
74
+ const localVersion = force ? undefined : await this.findLocalVersion(version);
75
+ if (alreadyOnVersion(current, localVersion ?? undefined)) {
76
76
  ux.action.stop(this.config.scopedEnvVar('HIDE_UPDATED_MESSAGE') ? 'done' : `already on version ${current}`);
77
77
  return;
78
78
  }
@@ -213,7 +213,7 @@ get_script_dir () {
213
213
  };
214
214
  await Promise.all(files
215
215
  .filter((f) => isNotSpecial(f.path, this.config.version) && isOld(f.stat))
216
- .map((f) => rm(f.path, { force: true, recursive: true })));
216
+ .map(async (f) => rm(f.path, { force: true, recursive: true })));
217
217
  }
218
218
  catch (error) {
219
219
  ux.warn(error);
@@ -289,7 +289,7 @@ const notUpdatable = (config) => {
289
289
  };
290
290
  const composeS3SubDir = (config) => {
291
291
  let s3SubDir = config.pjson.oclif.update?.s3?.folder || '';
292
- if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/')
292
+ if (s3SubDir !== '' && !s3SubDir.endsWith('/'))
293
293
  s3SubDir = `${s3SubDir}/`;
294
294
  return s3SubDir;
295
295
  };
@@ -334,10 +334,10 @@ const s3VersionManifestKey = ({ config, hash, version }) => {
334
334
  // a new one when it's again "needed".
335
335
  const MAX_DEBOUNCE_WAIT_MS = 6 * 60 * 60 * 1000; // 6 hours
336
336
  const DEBOUNCE_POLL_INTERVAL_MS = 60 * 1000; // 1 minute
337
- const debounce = (cacheDir) => {
337
+ const debounce = async (cacheDir) => {
338
338
  const lastrunfile = join(cacheDir, 'lastrun');
339
339
  const startedAt = Date.now();
340
- let announced = false;
340
+ let isAnnounced = false;
341
341
  return new Promise((resolve) => {
342
342
  const check = async () => {
343
343
  const m = await mtime(lastrunfile);
@@ -353,12 +353,12 @@ const debounce = (cacheDir) => {
353
353
  return;
354
354
  }
355
355
  const msg = `waiting until ${m.toISOString()} to update`;
356
- if (announced) {
356
+ if (isAnnounced) {
357
357
  debug(msg);
358
358
  }
359
359
  else {
360
360
  ux.stdout(msg);
361
- announced = true;
361
+ isAnnounced = true;
362
362
  }
363
363
  setTimeout(check, DEBOUNCE_POLL_INTERVAL_MS);
364
364
  };
@@ -439,7 +439,7 @@ const determineChannel = async ({ config, version }) => {
439
439
  const determineCurrentVersion = async (clientBin, version) => {
440
440
  try {
441
441
  const currentVersion = await readFile(clientBin, 'utf8');
442
- const matches = currentVersion.match(/\.\.[/\\|](.+)[/\\|]bin/);
442
+ const matches = /\.\.[/\\|](.+)[/\\|]bin/.exec(currentVersion);
443
443
  return matches ? matches[1] : version;
444
444
  }
445
445
  catch (error) {
package/dist/util.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Stats } from 'node:fs';
1
+ import { type Stats } from 'node:fs';
2
2
  export declare function touch(p: string): Promise<void>;
3
3
  export declare function ls(dir: string): Promise<Array<{
4
4
  path: string;
package/dist/util.js CHANGED
@@ -11,11 +11,13 @@ export async function touch(p) {
11
11
  export async function ls(dir) {
12
12
  const files = await readdir(dir);
13
13
  const paths = files.map((f) => join(dir, f));
14
- return Promise.all(paths.map((path) => stat(path).then((s) => ({ path, stat: s }))));
14
+ return Promise.all(paths.map(async (path) => stat(path).then((s) => ({ path, stat: s }))));
15
15
  }
16
- export function wait(ms, unref = false) {
16
+ export async function wait(ms, unref = false) {
17
17
  return new Promise((resolve) => {
18
- const t = setTimeout(() => resolve(), ms);
18
+ const t = setTimeout(() => {
19
+ resolve();
20
+ }, ms);
19
21
  if (unref)
20
22
  t.unref();
21
23
  });
@@ -106,5 +106,5 @@
106
106
  ]
107
107
  }
108
108
  },
109
- "version": "5.0.0"
109
+ "version": "5.0.1"
110
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oclif/plugin-update",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "author": "Salesforce",
5
5
  "bugs": "https://github.com/oclif/plugin-update/issues",
6
6
  "dependencies": {