@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 +1 -1
- package/dist/commands/update.d.ts +1 -1
- package/dist/hooks/init.d.ts +1 -1
- package/dist/hooks/init.js +5 -3
- package/dist/tar.js +7 -7
- package/dist/update.js +9 -9
- package/dist/util.d.ts +1 -1
- package/dist/util.js +5 -3
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
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.
|
|
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
|
package/dist/hooks/init.d.ts
CHANGED
|
@@ -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'>;
|
package/dist/hooks/init.js
CHANGED
|
@@ -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
|
|
84
|
+
...(config.windows && { shell: true }),
|
|
85
85
|
})
|
|
86
|
-
.on('error', (e) =>
|
|
87
|
-
.
|
|
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
|
|
35
|
-
let
|
|
36
|
-
const check = () =>
|
|
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
|
-
|
|
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
|
-
|
|
53
|
+
isShaValidated = true;
|
|
54
54
|
const extract = tarExtract(tmp, { ignore });
|
|
55
55
|
extract.on('error', reject);
|
|
56
56
|
extract.on('finish', () => {
|
|
57
|
-
|
|
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 ?
|
|
75
|
-
if (alreadyOnVersion(current, localVersion
|
|
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.
|
|
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
|
|
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 (
|
|
356
|
+
if (isAnnounced) {
|
|
357
357
|
debug(msg);
|
|
358
358
|
}
|
|
359
359
|
else {
|
|
360
360
|
ux.stdout(msg);
|
|
361
|
-
|
|
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 =
|
|
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
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(() =>
|
|
18
|
+
const t = setTimeout(() => {
|
|
19
|
+
resolve();
|
|
20
|
+
}, ms);
|
|
19
21
|
if (unref)
|
|
20
22
|
t.unref();
|
|
21
23
|
});
|
package/oclif.manifest.json
CHANGED