@oclif/plugin-update 2.1.2 → 2.2.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/CHANGELOG.md +23 -0
- package/README.md +4 -4
- package/lib/commands/update.js +1 -2
- package/lib/hooks/init.js +3 -2
- package/lib/update.js +29 -28
- package/oclif.manifest.json +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,29 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
4
|
|
5
|
+
## [2.2.0](https://github.com/oclif/plugin-update/compare/v2.1.5...v2.2.0) (2022-01-28)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* remove cli-ux ([#364](https://github.com/oclif/plugin-update/issues/364)) ([980c612](https://github.com/oclif/plugin-update/commit/980c6121846a9201da4071f6edc2afc0219751f6))
|
11
|
+
|
12
|
+
### [2.1.5](https://github.com/oclif/plugin-update/compare/v2.1.4...v2.1.5) (2022-01-06)
|
13
|
+
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
* add main to package.json ([#361](https://github.com/oclif/plugin-update/issues/361)) ([9daade3](https://github.com/oclif/plugin-update/commit/9daade340a102a8e0a57ae8a278b3803daf32117))
|
18
|
+
|
19
|
+
### [2.1.4](https://github.com/oclif/plugin-update/compare/v2.1.3...v2.1.4) (2022-01-06)
|
20
|
+
|
21
|
+
|
22
|
+
### Bug Fixes
|
23
|
+
|
24
|
+
* bump @oclif/core ([#360](https://github.com/oclif/plugin-update/issues/360)) ([749b949](https://github.com/oclif/plugin-update/commit/749b949e8127a5b594f28fe7468c1e13440f9817))
|
25
|
+
|
26
|
+
### [2.1.3](https://github.com/oclif/plugin-update/compare/v2.1.2...v2.1.3) (2021-12-09)
|
27
|
+
|
5
28
|
### [2.1.2](https://github.com/oclif/plugin-update/compare/v2.1.1...v2.1.2) (2021-12-08)
|
6
29
|
|
7
30
|
|
package/README.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
====================
|
3
3
|
|
4
4
|
[](https://npmjs.org/package/@oclif/plugin-update)
|
5
|
-
[](https://circleci.com/gh/oclif/plugin-update/tree/main)
|
6
|
+
[](https://ci.appveyor.com/project/oclif/plugin-update/branch/main)
|
7
7
|
[](https://npmjs.org/package/@oclif/plugin-update)
|
8
|
-
[](https://github.com/oclif/plugin-update/blob/
|
8
|
+
[](https://github.com/oclif/plugin-update/blob/main/package.json)
|
9
9
|
|
10
10
|
<!-- toc -->
|
11
11
|
* [Usage](#usage)
|
@@ -33,5 +33,5 @@ DESCRIPTION
|
|
33
33
|
update the oclif-example CLI
|
34
34
|
```
|
35
35
|
|
36
|
-
_See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v2.1.
|
36
|
+
_See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/v2.1.5/src/commands/update.ts)_
|
37
37
|
<!-- commandsstop -->
|
package/lib/commands/update.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const core_1 = require("@oclif/core");
|
4
|
-
const cli_ux_1 = require("cli-ux");
|
5
4
|
const path = require("path");
|
6
5
|
const update_1 = require("../update");
|
7
6
|
async function getPinToVersion() {
|
8
|
-
return
|
7
|
+
return core_1.CliUx.ux.prompt('Enter a version to update to');
|
9
8
|
}
|
10
9
|
class UpdateCommand extends core_1.Command {
|
11
10
|
constructor() {
|
package/lib/hooks/init.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.init = void 0;
|
4
|
-
const
|
4
|
+
const core_1 = require("@oclif/core");
|
5
5
|
const spawn = require("cross-spawn");
|
6
6
|
const fs = require("fs-extra");
|
7
7
|
const path = require("path");
|
8
8
|
const util_1 = require("../util");
|
9
|
+
// eslint-disable-next-line unicorn/prefer-module
|
9
10
|
const debug = require('debug')('cli:updater');
|
10
11
|
function timestamp(msg) {
|
11
12
|
return `[${new Date().toISOString()}] ${msg}`;
|
@@ -36,7 +37,7 @@ const init = async function (opts) {
|
|
36
37
|
}
|
37
38
|
catch (error) {
|
38
39
|
if (error.code !== 'ENOENT')
|
39
|
-
|
40
|
+
core_1.CliUx.ux.error(error.stack);
|
40
41
|
if (global.testing)
|
41
42
|
return false;
|
42
43
|
debug('autoupdate ENOENT');
|
package/lib/update.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/* eslint-disable unicorn/prefer-module */
|
3
4
|
const color_1 = require("@oclif/color");
|
4
|
-
const
|
5
|
+
const core_1 = require("@oclif/core");
|
5
6
|
const spawn = require("cross-spawn");
|
6
7
|
const fs = require("fs-extra");
|
7
8
|
const _ = require("lodash");
|
@@ -20,45 +21,45 @@ class UpdateCli {
|
|
20
21
|
this.channel = this.options.channel || await this.determineChannel();
|
21
22
|
if (this.options.fromLocal) {
|
22
23
|
await this.ensureClientDir();
|
23
|
-
|
24
|
+
core_1.CliUx.ux.debug(`Looking for locally installed versions at ${this.clientRoot}`);
|
24
25
|
// Do not show known non-local version folder names, bin and current.
|
25
26
|
const versions = fs.readdirSync(this.clientRoot).filter(dirOrFile => dirOrFile !== 'bin' && dirOrFile !== 'current');
|
26
27
|
if (versions.length === 0)
|
27
28
|
throw new Error('No locally installed versions found.');
|
28
|
-
|
29
|
+
core_1.CliUx.ux.log(`Found versions: \n${versions.map(version => ` ${version}`).join('\n')}\n`);
|
29
30
|
const pinToVersion = await this.options.getPinToVersion();
|
30
31
|
if (!versions.includes(pinToVersion))
|
31
32
|
throw new Error(`Version ${pinToVersion} not found in the locally installed versions.`);
|
32
33
|
if (!await fs.pathExists(path.join(this.clientRoot, pinToVersion))) {
|
33
34
|
throw new Error(`Version ${pinToVersion} is not already installed at ${this.clientRoot}.`);
|
34
35
|
}
|
35
|
-
|
36
|
-
|
36
|
+
core_1.CliUx.ux.action.start(`${this.options.config.name}: Updating CLI`);
|
37
|
+
core_1.CliUx.ux.debug(`switching to existing version ${pinToVersion}`);
|
37
38
|
this.updateToExistingVersion(pinToVersion);
|
38
|
-
|
39
|
-
|
39
|
+
core_1.CliUx.ux.log();
|
40
|
+
core_1.CliUx.ux.log(`Updating to an already installed version will not update the channel. If autoupdate is enabled, the CLI will eventually be updated back to ${this.channel}.`);
|
40
41
|
}
|
41
42
|
else {
|
42
|
-
|
43
|
+
core_1.CliUx.ux.action.start(`${this.options.config.name}: Updating CLI`);
|
43
44
|
await this.options.config.runHook('preupdate', { channel: this.channel });
|
44
45
|
const manifest = await this.fetchManifest();
|
45
46
|
this.currentVersion = await this.determineCurrentVersion();
|
46
47
|
this.updatedVersion = manifest.sha ? `${manifest.version}-${manifest.sha}` : manifest.version;
|
47
48
|
const reason = await this.skipUpdate();
|
48
49
|
if (reason)
|
49
|
-
|
50
|
+
core_1.CliUx.ux.action.stop(reason || 'done');
|
50
51
|
else
|
51
52
|
await this.update(manifest);
|
52
|
-
|
53
|
+
core_1.CliUx.ux.debug('tidy');
|
53
54
|
await this.tidy();
|
54
55
|
await this.options.config.runHook('update', { channel: this.channel });
|
55
56
|
}
|
56
|
-
|
57
|
-
|
57
|
+
core_1.CliUx.ux.debug('done');
|
58
|
+
core_1.CliUx.ux.action.stop();
|
58
59
|
}
|
59
60
|
async fetchManifest() {
|
60
61
|
const http = require('http-call').HTTP;
|
61
|
-
|
62
|
+
core_1.CliUx.ux.action.status = 'fetching manifest';
|
62
63
|
try {
|
63
64
|
const url = this.options.config.s3Url(this.options.config.s3Key('manifest', {
|
64
65
|
channel: this.channel,
|
@@ -105,12 +106,12 @@ class UpdateCli {
|
|
105
106
|
});
|
106
107
|
const extraction = (0, tar_1.extract)(stream, baseDir, output, sha256gz);
|
107
108
|
// to-do: use cli.action.type
|
108
|
-
if (
|
109
|
+
if (core_1.CliUx.ux.action.frames) {
|
109
110
|
// if spinner action
|
110
111
|
const total = Number.parseInt(stream.headers['content-length'], 10);
|
111
112
|
let current = 0;
|
112
113
|
const updateStatus = _.throttle((newStatus) => {
|
113
|
-
|
114
|
+
core_1.CliUx.ux.action.status = newStatus;
|
114
115
|
}, 250, { leading: true, trailing: false });
|
115
116
|
stream.on('data', data => {
|
116
117
|
current += data.length;
|
@@ -121,7 +122,7 @@ class UpdateCli {
|
|
121
122
|
await extraction;
|
122
123
|
}
|
123
124
|
async update(manifest, channel = 'stable') {
|
124
|
-
|
125
|
+
core_1.CliUx.ux.action.start(`${this.options.config.name}: Updating CLI from ${color_1.default.green(this.currentVersion)} to ${color_1.default.green(this.updatedVersion)}${channel === 'stable' ? '' : ' (' + color_1.default.yellow(channel) + ')'}`);
|
125
126
|
await this.ensureClientDir();
|
126
127
|
const output = path.join(this.clientRoot, this.updatedVersion);
|
127
128
|
if (!await fs.pathExists(output)) {
|
@@ -140,7 +141,7 @@ class UpdateCli {
|
|
140
141
|
if (!this.options.config.binPath) {
|
141
142
|
const instructions = this.options.config.scopedEnvVar('UPDATE_INSTRUCTIONS');
|
142
143
|
if (instructions)
|
143
|
-
|
144
|
+
core_1.CliUx.ux.warn(instructions);
|
144
145
|
return 'not updatable';
|
145
146
|
}
|
146
147
|
if (this.currentVersion === this.updatedVersion) {
|
@@ -165,7 +166,7 @@ class UpdateCli {
|
|
165
166
|
return matches ? matches[1] : this.options.config.version;
|
166
167
|
}
|
167
168
|
catch (error) {
|
168
|
-
|
169
|
+
core_1.CliUx.ux.debug(error);
|
169
170
|
}
|
170
171
|
return this.options.config.version;
|
171
172
|
}
|
@@ -181,12 +182,12 @@ class UpdateCli {
|
|
181
182
|
}
|
182
183
|
async logChop() {
|
183
184
|
try {
|
184
|
-
|
185
|
+
core_1.CliUx.ux.debug('log chop');
|
185
186
|
const logChopper = require('log-chopper').default;
|
186
187
|
await logChopper.chop(this.options.config.errlog);
|
187
188
|
}
|
188
189
|
catch (error) {
|
189
|
-
|
190
|
+
core_1.CliUx.ux.debug(error.message);
|
190
191
|
}
|
191
192
|
}
|
192
193
|
async mtime(f) {
|
@@ -202,16 +203,16 @@ class UpdateCli {
|
|
202
203
|
if (m > new Date()) {
|
203
204
|
const msg = `waiting until ${m.toISOString()} to update`;
|
204
205
|
if (output) {
|
205
|
-
|
206
|
+
core_1.CliUx.ux.debug(msg);
|
206
207
|
}
|
207
208
|
else {
|
208
|
-
await
|
209
|
+
await core_1.CliUx.ux.log(msg);
|
209
210
|
output = true;
|
210
211
|
}
|
211
212
|
await (0, util_1.wait)(60 * 1000); // wait 1 minute
|
212
213
|
return this.debounce();
|
213
214
|
}
|
214
|
-
|
215
|
+
core_1.CliUx.ux.log('time to update');
|
215
216
|
}
|
216
217
|
// removes any unused CLIs
|
217
218
|
async tidy() {
|
@@ -234,26 +235,26 @@ class UpdateCli {
|
|
234
235
|
await this.logChop();
|
235
236
|
}
|
236
237
|
catch (error) {
|
237
|
-
|
238
|
+
core_1.CliUx.ux.warn(error);
|
238
239
|
}
|
239
240
|
}
|
240
241
|
async touch() {
|
241
242
|
// touch the client so it won't be tidied up right away
|
242
243
|
try {
|
243
244
|
const p = path.join(this.clientRoot, this.options.config.version);
|
244
|
-
|
245
|
+
core_1.CliUx.ux.debug('touching client at', p);
|
245
246
|
if (!await fs.pathExists(p))
|
246
247
|
return;
|
247
248
|
await fs.utimes(p, new Date(), new Date());
|
248
249
|
}
|
249
250
|
catch (error) {
|
250
|
-
|
251
|
+
core_1.CliUx.ux.warn(error);
|
251
252
|
}
|
252
253
|
}
|
253
254
|
async reexec() {
|
254
|
-
|
255
|
+
core_1.CliUx.ux.action.stop();
|
255
256
|
return new Promise((_, reject) => {
|
256
|
-
|
257
|
+
core_1.CliUx.ux.debug('restarting CLI after update', this.clientBin);
|
257
258
|
spawn(this.clientBin, ['update'], {
|
258
259
|
stdio: 'inherit',
|
259
260
|
env: Object.assign(Object.assign({}, process.env), { [this.options.config.scopedEnvVarKey('HIDE_UPDATED_MESSAGE')]: '1' }),
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"2.
|
1
|
+
{"version":"2.2.0","commands":{"update":{"id":"update","description":"update the <%= config.bin %> CLI","strict":true,"pluginName":"@oclif/plugin-update","pluginAlias":"@oclif/plugin-update","pluginType":"core","aliases":[],"flags":{"autoupdate":{"name":"autoupdate","type":"boolean","hidden":true,"allowNo":false},"from-local":{"name":"from-local","type":"boolean","description":"interactively choose an already installed version","allowNo":false}},"args":[{"name":"channel"}]}}}
|
package/package.json
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oclif/plugin-update",
|
3
|
-
"version": "2.
|
4
|
-
"author": "
|
3
|
+
"version": "2.2.0",
|
4
|
+
"author": "Salesforce",
|
5
5
|
"bugs": "https://github.com/oclif/plugin-update/issues",
|
6
6
|
"dependencies": {
|
7
7
|
"@oclif/color": "^1.0.0",
|
8
|
-
"@oclif/core": "1.0
|
8
|
+
"@oclif/core": "^1.2.0",
|
9
9
|
"@types/semver": "^7.3.4",
|
10
|
-
"cli-ux": "6.0.6",
|
11
10
|
"cross-spawn": "^7.0.3",
|
12
11
|
"debug": "^4.3.1",
|
13
12
|
"filesize": "^6.1.0",
|
@@ -19,7 +18,7 @@
|
|
19
18
|
"tar-fs": "^2.1.1"
|
20
19
|
},
|
21
20
|
"devDependencies": {
|
22
|
-
"@oclif/plugin-help": "5.1.9",
|
21
|
+
"@oclif/plugin-help": "^5.1.9",
|
23
22
|
"@oclif/test": "^2.0.2",
|
24
23
|
"@types/chai": "^4.2.15",
|
25
24
|
"@types/cross-spawn": "^6.0.2",
|
@@ -38,7 +37,7 @@
|
|
38
37
|
"globby": "^11.0.2",
|
39
38
|
"mocha": "^9",
|
40
39
|
"nock": "^13.2.1",
|
41
|
-
"oclif": "2.
|
40
|
+
"oclif": "^2.3.0",
|
42
41
|
"qqjs": "^0.3.11",
|
43
42
|
"sinon": "^12.0.1",
|
44
43
|
"ts-node": "^9.1.1",
|
@@ -78,5 +77,6 @@
|
|
78
77
|
"postpack": "rm -f oclif.manifest.json",
|
79
78
|
"version": "oclif readme && git add README.md",
|
80
79
|
"build": "rm -rf lib && tsc"
|
81
|
-
}
|
80
|
+
},
|
81
|
+
"main": "lib/index.js"
|
82
82
|
}
|