@oclif/plugin-update 3.2.3 → 3.2.4-qa.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +14 -10
- package/dist/commands/update.d.ts +20 -0
- package/dist/commands/update.js +83 -0
- package/dist/hooks/init.js +67 -0
- package/dist/tar.d.ts +6 -0
- package/{lib → dist}/tar.js +34 -30
- package/dist/update.d.ts +26 -0
- package/dist/update.js +362 -0
- package/{lib → dist}/util.d.ts +3 -4
- package/dist/util.js +22 -0
- package/oclif.lock +7063 -0
- package/oclif.manifest.json +59 -46
- package/package.json +47 -35
- package/lib/commands/update.d.ts +0 -20
- package/lib/commands/update.js +0 -87
- package/lib/hooks/init.js +0 -67
- package/lib/tar.d.ts +0 -2
- package/lib/update.d.ts +0 -44
- package/lib/update.js +0 -388
- package/lib/util.js +0 -37
- /package/{lib → dist}/hooks/init.d.ts +0 -0
package/oclif.manifest.json
CHANGED
@@ -1,78 +1,91 @@
|
|
1
1
|
{
|
2
|
-
"version": "3.2.3",
|
3
2
|
"commands": {
|
4
3
|
"update": {
|
5
|
-
"id": "update",
|
6
|
-
"description": "update the <%= config.bin %> CLI",
|
7
|
-
"strict": true,
|
8
|
-
"pluginName": "@oclif/plugin-update",
|
9
|
-
"pluginAlias": "@oclif/plugin-update",
|
10
|
-
"pluginType": "core",
|
11
4
|
"aliases": [],
|
5
|
+
"args": {
|
6
|
+
"channel": {
|
7
|
+
"name": "channel"
|
8
|
+
}
|
9
|
+
},
|
10
|
+
"description": "update the <%= config.bin %> CLI",
|
12
11
|
"examples": [
|
13
12
|
{
|
14
|
-
"
|
15
|
-
"
|
13
|
+
"command": "<%= config.bin %> <%= command.id %> stable",
|
14
|
+
"description": "Update to the stable channel:"
|
16
15
|
},
|
17
16
|
{
|
18
|
-
"
|
19
|
-
"
|
17
|
+
"command": "<%= config.bin %> <%= command.id %> --version 1.0.0",
|
18
|
+
"description": "Update to a specific version:"
|
20
19
|
},
|
21
20
|
{
|
22
|
-
"
|
23
|
-
"
|
21
|
+
"command": "<%= config.bin %> <%= command.id %> --interactive",
|
22
|
+
"description": "Interactively select version:"
|
24
23
|
},
|
25
24
|
{
|
26
|
-
"
|
27
|
-
"
|
25
|
+
"command": "<%= config.bin %> <%= command.id %> --available",
|
26
|
+
"description": "See available versions:"
|
28
27
|
}
|
29
28
|
],
|
30
29
|
"flags": {
|
31
30
|
"autoupdate": {
|
32
|
-
"name": "autoupdate",
|
33
|
-
"type": "boolean",
|
34
31
|
"hidden": true,
|
35
|
-
"
|
32
|
+
"name": "autoupdate",
|
33
|
+
"allowNo": false,
|
34
|
+
"type": "boolean"
|
36
35
|
},
|
37
36
|
"available": {
|
38
|
-
"name": "available",
|
39
|
-
"type": "boolean",
|
40
37
|
"char": "a",
|
41
|
-
"description": "
|
42
|
-
"
|
38
|
+
"description": "See available versions.",
|
39
|
+
"name": "available",
|
40
|
+
"allowNo": false,
|
41
|
+
"type": "boolean"
|
43
42
|
},
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"multiple": false,
|
50
|
-
"exclusive": [
|
51
|
-
"interactive"
|
52
|
-
]
|
43
|
+
"force": {
|
44
|
+
"description": "Force a re-download of the requested version.",
|
45
|
+
"name": "force",
|
46
|
+
"allowNo": false,
|
47
|
+
"type": "boolean"
|
53
48
|
},
|
54
49
|
"interactive": {
|
55
|
-
"name": "interactive",
|
56
|
-
"type": "boolean",
|
57
50
|
"char": "i",
|
58
51
|
"description": "Interactively select version to install. This is ignored if a channel is provided.",
|
59
|
-
"allowNo": false,
|
60
52
|
"exclusive": [
|
61
53
|
"version"
|
62
|
-
]
|
54
|
+
],
|
55
|
+
"name": "interactive",
|
56
|
+
"allowNo": false,
|
57
|
+
"type": "boolean"
|
63
58
|
},
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"
|
68
|
-
|
59
|
+
"version": {
|
60
|
+
"char": "v",
|
61
|
+
"description": "Install a specific version.",
|
62
|
+
"exclusive": [
|
63
|
+
"interactive"
|
64
|
+
],
|
65
|
+
"name": "version",
|
66
|
+
"hasDynamicHelp": false,
|
67
|
+
"multiple": false,
|
68
|
+
"type": "option"
|
69
69
|
}
|
70
70
|
},
|
71
|
-
"
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
"hasDynamicHelp": false,
|
72
|
+
"id": "update",
|
73
|
+
"pluginAlias": "@oclif/plugin-update",
|
74
|
+
"pluginName": "@oclif/plugin-update",
|
75
|
+
"pluginType": "core",
|
76
|
+
"strict": true,
|
77
|
+
"enableJsonFlag": false,
|
78
|
+
"isESM": true,
|
79
|
+
"relativePath": [
|
80
|
+
"dist",
|
81
|
+
"commands",
|
82
|
+
"update.js"
|
83
|
+
],
|
84
|
+
"aliasPermutations": [],
|
85
|
+
"permutations": [
|
86
|
+
"update"
|
87
|
+
]
|
76
88
|
}
|
77
|
-
}
|
89
|
+
},
|
90
|
+
"version": "3.2.4-qa.0"
|
78
91
|
}
|
package/package.json
CHANGED
@@ -1,57 +1,65 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oclif/plugin-update",
|
3
|
-
"version": "3.2.
|
3
|
+
"version": "3.2.4-qa.0",
|
4
4
|
"author": "Salesforce",
|
5
5
|
"bugs": "https://github.com/oclif/plugin-update/issues",
|
6
6
|
"dependencies": {
|
7
|
-
"@oclif/core": "^
|
8
|
-
"chalk": "^
|
7
|
+
"@oclif/core": "^3.0.4",
|
8
|
+
"chalk": "^5",
|
9
9
|
"cross-spawn": "^7.0.3",
|
10
10
|
"debug": "^4.3.1",
|
11
11
|
"filesize": "^6.1.0",
|
12
|
-
"fs-extra": "^9.0.1",
|
13
12
|
"http-call": "^5.3.0",
|
14
|
-
"inquirer": "^
|
13
|
+
"inquirer": "^9.2.11",
|
15
14
|
"lodash.throttle": "^4.1.1",
|
16
15
|
"log-chopper": "^1.0.2",
|
17
16
|
"semver": "^7.5.4",
|
18
17
|
"tar-fs": "^2.1.1"
|
19
18
|
},
|
20
19
|
"devDependencies": {
|
20
|
+
"@commitlint/config-conventional": "^17.7.0",
|
21
21
|
"@oclif/plugin-help": "^5.2.17",
|
22
|
-
"@oclif/
|
22
|
+
"@oclif/prettier-config": "^0.2.1",
|
23
|
+
"@oclif/test": "^3",
|
23
24
|
"@types/chai": "^4.3.5",
|
24
|
-
"@types/cross-spawn": "^6.0.
|
25
|
+
"@types/cross-spawn": "^6.0.3",
|
26
|
+
"@types/debug": "^4.1.8",
|
25
27
|
"@types/execa": "^0.9.0",
|
26
|
-
"@types/fs-extra": "^8.0.1",
|
27
28
|
"@types/glob": "^7.1.3",
|
28
|
-
"@types/inquirer": "^
|
29
|
+
"@types/inquirer": "^9.0.3",
|
29
30
|
"@types/lodash.throttle": "^4.1.6",
|
30
|
-
"@types/mocha": "^
|
31
|
-
"@types/node": "^
|
32
|
-
"@types/semver": "^7.5.
|
31
|
+
"@types/mocha": "^10",
|
32
|
+
"@types/node": "^18",
|
33
|
+
"@types/semver": "^7.5.3",
|
33
34
|
"@types/supports-color": "^7.2.0",
|
34
|
-
"@types/
|
35
|
+
"@types/tar-fs": "^2.0.2",
|
35
36
|
"chai": "^4.3.7",
|
36
|
-
"
|
37
|
-
"eslint
|
38
|
-
"eslint-config-oclif
|
39
|
-
"
|
40
|
-
"
|
37
|
+
"commitlint": "^17.7.2",
|
38
|
+
"eslint": "^8.49.0",
|
39
|
+
"eslint-config-oclif": "^5.0.0",
|
40
|
+
"eslint-config-oclif-typescript": "^3.0.1",
|
41
|
+
"eslint-config-prettier": "^9.0.0",
|
42
|
+
"got": "^13.0.0",
|
43
|
+
"husky": "^8.0.3",
|
44
|
+
"lint-staged": "^14.0.1",
|
45
|
+
"mocha": "^10.2.0",
|
41
46
|
"nock": "^13.3.2",
|
42
|
-
"oclif": "^
|
47
|
+
"oclif": "^4",
|
48
|
+
"prettier": "^3.0.3",
|
43
49
|
"qqjs": "^0.3.11",
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
50
|
+
"quibble": "^0.8.0",
|
51
|
+
"sinon": "^16.1.0",
|
52
|
+
"strip-ansi": "^7.1.0",
|
53
|
+
"ts-node": "^10.9.1",
|
54
|
+
"typescript": "^5.1.6"
|
48
55
|
},
|
49
56
|
"engines": {
|
50
|
-
"node": ">=
|
57
|
+
"node": ">=18.0.0"
|
51
58
|
},
|
52
59
|
"files": [
|
53
60
|
"oclif.manifest.json",
|
54
|
-
"/
|
61
|
+
"/dist",
|
62
|
+
"/oclif.lock"
|
55
63
|
],
|
56
64
|
"homepage": "https://github.com/oclif/plugin-update",
|
57
65
|
"keywords": [
|
@@ -60,25 +68,29 @@
|
|
60
68
|
"license": "MIT",
|
61
69
|
"oclif": {
|
62
70
|
"autoupdate": "github",
|
63
|
-
"commands": "./
|
71
|
+
"commands": "./dist/commands",
|
64
72
|
"bin": "oclif-example",
|
65
73
|
"hooks": {
|
66
|
-
"init": "./
|
74
|
+
"init": "./dist/hooks/init.js"
|
67
75
|
},
|
68
76
|
"devPlugins": [
|
69
77
|
"@oclif/plugin-help"
|
70
|
-
]
|
78
|
+
],
|
79
|
+
"flexibleTaxonomy": true
|
71
80
|
},
|
72
81
|
"repository": "oclif/plugin-update",
|
73
82
|
"scripts": {
|
74
|
-
"
|
83
|
+
"build": "rm -rf lib && tsc",
|
84
|
+
"lint": "eslint . --ext .ts",
|
85
|
+
"postpack": "rm -f oclif.manifest.json",
|
86
|
+
"posttest": "yarn lint",
|
87
|
+
"prepack": "yarn build && oclif lock && oclif manifest . && oclif lock",
|
88
|
+
"prepare": "husky install",
|
75
89
|
"pretest": "yarn build --noEmit && tsc -p test --noEmit",
|
90
|
+
"test:integration:sf": "mocha --forbid-only \"test/integration/sf.integration.ts\" --timeout 900000",
|
76
91
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
77
|
-
"
|
78
|
-
"prepack": "yarn build && oclif manifest .",
|
79
|
-
"postpack": "rm -f oclif.manifest.json",
|
80
|
-
"version": "oclif readme && git add README.md",
|
81
|
-
"build": "rm -rf lib && tsc"
|
92
|
+
"version": "oclif readme && git add README.md"
|
82
93
|
},
|
83
|
-
"
|
94
|
+
"exports": "./dist/index.js",
|
95
|
+
"type": "module"
|
84
96
|
}
|
package/lib/commands/update.d.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import { Command } from '@oclif/core';
|
2
|
-
export default class UpdateCommand extends Command {
|
3
|
-
static description: string;
|
4
|
-
static args: {
|
5
|
-
channel: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
6
|
-
};
|
7
|
-
static examples: {
|
8
|
-
description: string;
|
9
|
-
command: string;
|
10
|
-
}[];
|
11
|
-
static flags: {
|
12
|
-
autoupdate: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
13
|
-
available: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
14
|
-
version: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
15
|
-
interactive: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
16
|
-
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
17
|
-
};
|
18
|
-
run(): Promise<void>;
|
19
|
-
private promptForVersion;
|
20
|
-
}
|
package/lib/commands/update.js
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const core_1 = require("@oclif/core");
|
5
|
-
const inquirer_1 = require("inquirer");
|
6
|
-
const path = (0, tslib_1.__importStar)(require("path"));
|
7
|
-
const semver_1 = require("semver");
|
8
|
-
const update_1 = require("../update");
|
9
|
-
class UpdateCommand extends core_1.Command {
|
10
|
-
async run() {
|
11
|
-
const { args, flags } = await this.parse(UpdateCommand);
|
12
|
-
const updater = new update_1.Updater(this.config);
|
13
|
-
if (flags.available) {
|
14
|
-
const index = await updater.fetchVersionIndex();
|
15
|
-
const allVersions = (0, semver_1.sort)(Object.keys(index)).reverse();
|
16
|
-
const localVersions = await updater.findLocalVersions();
|
17
|
-
const table = allVersions.map(version => {
|
18
|
-
const location = localVersions.find(l => path.basename(l).startsWith(version)) || index[version];
|
19
|
-
return { version, location };
|
20
|
-
});
|
21
|
-
core_1.ux.table(table, { version: {}, location: {} });
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
if (args.channel && flags.version) {
|
25
|
-
this.error('You cannot specify both a version and a channel.');
|
26
|
-
}
|
27
|
-
return updater.runUpdate({
|
28
|
-
channel: args.channel,
|
29
|
-
autoUpdate: flags.autoupdate,
|
30
|
-
force: flags.force,
|
31
|
-
version: flags.interactive ? await this.promptForVersion(updater) : flags.version,
|
32
|
-
});
|
33
|
-
}
|
34
|
-
async promptForVersion(updater) {
|
35
|
-
const choices = (0, semver_1.sort)(Object.keys(await updater.fetchVersionIndex())).reverse();
|
36
|
-
const { version } = await (0, inquirer_1.prompt)({
|
37
|
-
name: 'version',
|
38
|
-
message: 'Select a version to update to',
|
39
|
-
type: 'list',
|
40
|
-
choices: [...choices, new inquirer_1.Separator()],
|
41
|
-
});
|
42
|
-
return version;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
exports.default = UpdateCommand;
|
46
|
-
UpdateCommand.description = 'update the <%= config.bin %> CLI';
|
47
|
-
UpdateCommand.args = {
|
48
|
-
channel: core_1.Args.string({ optional: true }),
|
49
|
-
};
|
50
|
-
UpdateCommand.examples = [
|
51
|
-
{
|
52
|
-
description: 'Update to the stable channel:',
|
53
|
-
command: '<%= config.bin %> <%= command.id %> stable',
|
54
|
-
},
|
55
|
-
{
|
56
|
-
description: 'Update to a specific version:',
|
57
|
-
command: '<%= config.bin %> <%= command.id %> --version 1.0.0',
|
58
|
-
},
|
59
|
-
{
|
60
|
-
description: 'Interactively select version:',
|
61
|
-
command: '<%= config.bin %> <%= command.id %> --interactive',
|
62
|
-
},
|
63
|
-
{
|
64
|
-
description: 'See available versions:',
|
65
|
-
command: '<%= config.bin %> <%= command.id %> --available',
|
66
|
-
},
|
67
|
-
];
|
68
|
-
UpdateCommand.flags = {
|
69
|
-
autoupdate: core_1.Flags.boolean({ hidden: true }),
|
70
|
-
available: core_1.Flags.boolean({
|
71
|
-
char: 'a',
|
72
|
-
description: 'Install a specific version.',
|
73
|
-
}),
|
74
|
-
version: core_1.Flags.string({
|
75
|
-
char: 'v',
|
76
|
-
description: 'Install a specific version.',
|
77
|
-
exclusive: ['interactive'],
|
78
|
-
}),
|
79
|
-
interactive: core_1.Flags.boolean({
|
80
|
-
char: 'i',
|
81
|
-
description: 'Interactively select version to install. This is ignored if a channel is provided.',
|
82
|
-
exclusive: ['version'],
|
83
|
-
}),
|
84
|
-
force: core_1.Flags.boolean({
|
85
|
-
description: 'Force a re-download of the requested version.',
|
86
|
-
}),
|
87
|
-
};
|
package/lib/hooks/init.js
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.init = void 0;
|
4
|
-
const tslib_1 = require("tslib");
|
5
|
-
const core_1 = require("@oclif/core");
|
6
|
-
const cross_spawn_1 = (0, tslib_1.__importDefault)(require("cross-spawn"));
|
7
|
-
const fs = (0, tslib_1.__importStar)(require("fs-extra"));
|
8
|
-
const path = (0, tslib_1.__importStar)(require("path"));
|
9
|
-
const util_1 = require("../util");
|
10
|
-
// eslint-disable-next-line unicorn/prefer-module
|
11
|
-
const debug = require('debug')('cli:updater');
|
12
|
-
function timestamp(msg) {
|
13
|
-
return `[${new Date().toISOString()}] ${msg}`;
|
14
|
-
}
|
15
|
-
async function mtime(f) {
|
16
|
-
const { mtime } = await fs.stat(f);
|
17
|
-
return mtime;
|
18
|
-
}
|
19
|
-
const init = async function (opts) {
|
20
|
-
if (opts.id === 'update')
|
21
|
-
return;
|
22
|
-
if (opts.config.scopedEnvVarTrue('DISABLE_AUTOUPDATE'))
|
23
|
-
return;
|
24
|
-
const binPath = this.config.binPath || this.config.bin;
|
25
|
-
const lastrunfile = path.join(this.config.cacheDir, 'lastrun');
|
26
|
-
const autoupdatefile = path.join(this.config.cacheDir, 'autoupdate');
|
27
|
-
const autoupdatelogfile = path.join(this.config.cacheDir, 'autoupdate.log');
|
28
|
-
const clientRoot = this.config.scopedEnvVar('OCLIF_CLIENT_HOME') || path.join(this.config.dataDir, 'client');
|
29
|
-
const autoupdateEnv = Object.assign(Object.assign({}, process.env), { [this.config.scopedEnvVarKey('TIMESTAMPS')]: '1', [this.config.scopedEnvVarKey('SKIP_ANALYTICS')]: '1' });
|
30
|
-
async function autoupdateNeeded() {
|
31
|
-
try {
|
32
|
-
const m = await mtime(autoupdatefile);
|
33
|
-
let days = 1;
|
34
|
-
if (opts.config.channel === 'stable')
|
35
|
-
days = 14;
|
36
|
-
m.setHours(m.getHours() + (days * 24));
|
37
|
-
return m < new Date();
|
38
|
-
}
|
39
|
-
catch (error) {
|
40
|
-
if (error.code !== 'ENOENT')
|
41
|
-
core_1.ux.error(error.stack);
|
42
|
-
if (global.testing)
|
43
|
-
return false;
|
44
|
-
debug('autoupdate ENOENT');
|
45
|
-
return true;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
await (0, util_1.touch)(lastrunfile);
|
49
|
-
const clientDir = path.join(clientRoot, this.config.version);
|
50
|
-
if (await fs.pathExists(clientDir))
|
51
|
-
await (0, util_1.touch)(clientDir);
|
52
|
-
if (!await autoupdateNeeded())
|
53
|
-
return;
|
54
|
-
debug('autoupdate running');
|
55
|
-
await fs.outputFile(autoupdatefile, '');
|
56
|
-
debug(`spawning autoupdate on ${binPath}`);
|
57
|
-
const fd = await fs.open(autoupdatelogfile, 'a');
|
58
|
-
fs.write(fd, timestamp(`starting \`${binPath} update --autoupdate\` from ${process.argv.slice(1, 3).join(' ')}\n`));
|
59
|
-
(0, cross_spawn_1.default)(binPath, ['update', '--autoupdate'], {
|
60
|
-
detached: !this.config.windows,
|
61
|
-
stdio: ['ignore', fd, fd],
|
62
|
-
env: autoupdateEnv,
|
63
|
-
})
|
64
|
-
.on('error', (e) => process.emitWarning(e))
|
65
|
-
.unref();
|
66
|
-
};
|
67
|
-
exports.init = init;
|
package/lib/tar.d.ts
DELETED
package/lib/update.d.ts
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
import { Config } from '@oclif/core';
|
2
|
-
export declare namespace Updater {
|
3
|
-
type Options = {
|
4
|
-
autoUpdate: boolean;
|
5
|
-
channel?: string | undefined;
|
6
|
-
version?: string | undefined;
|
7
|
-
force?: boolean;
|
8
|
-
};
|
9
|
-
type VersionIndex = Record<string, string>;
|
10
|
-
}
|
11
|
-
export declare class Updater {
|
12
|
-
private config;
|
13
|
-
private readonly clientRoot;
|
14
|
-
private readonly clientBin;
|
15
|
-
constructor(config: Config);
|
16
|
-
runUpdate(options: Updater.Options): Promise<void>;
|
17
|
-
findLocalVersions(): Promise<string[]>;
|
18
|
-
fetchVersionIndex(): Promise<Updater.VersionIndex>;
|
19
|
-
private ensureClientDir;
|
20
|
-
private composeS3SubDir;
|
21
|
-
private s3ChannelManifestKey;
|
22
|
-
private s3VersionManifestKey;
|
23
|
-
private s3VersionIndexKey;
|
24
|
-
private fetchChannelManifest;
|
25
|
-
private fetchVersionManifest;
|
26
|
-
private fetchManifest;
|
27
|
-
private downloadAndExtract;
|
28
|
-
private update;
|
29
|
-
private updateToExistingVersion;
|
30
|
-
private notUpdatable;
|
31
|
-
private alreadyOnVersion;
|
32
|
-
private determineChannel;
|
33
|
-
private determinePlatform;
|
34
|
-
private determineCurrentVersion;
|
35
|
-
private findLocalVersion;
|
36
|
-
private setChannel;
|
37
|
-
private logChop;
|
38
|
-
private mtime;
|
39
|
-
private debounce;
|
40
|
-
private tidy;
|
41
|
-
private touch;
|
42
|
-
private refreshConfig;
|
43
|
-
private createBin;
|
44
|
-
}
|