@oclif/plugin-update 4.0.1-qa.0 → 4.1.1
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 -32
- package/{lib → dist}/update.d.ts +15 -16
- package/{lib → dist}/update.js +174 -185
- package/{lib → dist}/util.d.ts +3 -3
- package/dist/util.js +22 -0
- package/oclif.lock +7082 -0
- package/oclif.manifest.json +59 -46
- package/package.json +48 -34
- package/lib/commands/update.d.ts +0 -20
- package/lib/commands/update.js +0 -87
- package/lib/hooks/init.js +0 -73
- package/lib/tar.d.ts +0 -2
- package/lib/util.js +0 -29
- /package/{lib → dist}/hooks/init.d.ts +0 -0
package/oclif.manifest.json
CHANGED
@@ -1,78 +1,91 @@
|
|
1
1
|
{
|
2
|
-
"version": "4.0.1-qa.0",
|
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": "4.1.1"
|
78
91
|
}
|
package/package.json
CHANGED
@@ -1,54 +1,64 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oclif/plugin-update",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.1.1",
|
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.9",
|
8
|
+
"chalk": "^5",
|
9
|
+
"cross-spawn": "^7.0.3",
|
9
10
|
"debug": "^4.3.1",
|
10
11
|
"filesize": "^6.1.0",
|
11
|
-
"fs-extra": "^11.1.1",
|
12
12
|
"http-call": "^5.3.0",
|
13
|
-
"inquirer": "^
|
13
|
+
"inquirer": "^9.2.11",
|
14
14
|
"lodash.throttle": "^4.1.1",
|
15
|
-
"log-chopper": "^1.0.2",
|
16
15
|
"semver": "^7.5.4",
|
17
16
|
"tar-fs": "^2.1.1"
|
18
17
|
},
|
19
18
|
"devDependencies": {
|
19
|
+
"@commitlint/config-conventional": "^17.7.0",
|
20
20
|
"@oclif/plugin-help": "^5.2.17",
|
21
|
-
"@oclif/
|
21
|
+
"@oclif/prettier-config": "^0.2.1",
|
22
|
+
"@oclif/test": "^3",
|
22
23
|
"@types/chai": "^4.3.5",
|
24
|
+
"@types/cross-spawn": "^6.0.3",
|
25
|
+
"@types/debug": "^4.1.8",
|
23
26
|
"@types/execa": "^0.9.0",
|
24
|
-
"@types/fs-extra": "^11.0.1",
|
25
27
|
"@types/glob": "^7.1.3",
|
26
|
-
"@types/inquirer": "^
|
28
|
+
"@types/inquirer": "^9.0.3",
|
27
29
|
"@types/lodash.throttle": "^4.1.6",
|
28
|
-
"@types/mocha": "^
|
29
|
-
"@types/node": "^
|
30
|
-
"@types/semver": "^7.5.
|
30
|
+
"@types/mocha": "^10",
|
31
|
+
"@types/node": "^18",
|
32
|
+
"@types/semver": "^7.5.3",
|
31
33
|
"@types/supports-color": "^7.2.0",
|
34
|
+
"@types/tar-fs": "^2.0.2",
|
32
35
|
"chai": "^4.3.7",
|
33
|
-
"
|
34
|
-
"eslint
|
35
|
-
"eslint-config-oclif
|
36
|
-
"
|
37
|
-
"
|
36
|
+
"commitlint": "^17.7.2",
|
37
|
+
"eslint": "^8.49.0",
|
38
|
+
"eslint-config-oclif": "^5.0.0",
|
39
|
+
"eslint-config-oclif-typescript": "^3.0.1",
|
40
|
+
"eslint-config-prettier": "^9.0.0",
|
41
|
+
"got": "^13.0.0",
|
42
|
+
"husky": "^8.0.3",
|
43
|
+
"lint-staged": "^14.0.1",
|
44
|
+
"mocha": "^10.2.0",
|
38
45
|
"nock": "^13.3.2",
|
39
|
-
"oclif": "^
|
46
|
+
"oclif": "^4",
|
47
|
+
"prettier": "^3.0.3",
|
40
48
|
"qqjs": "^0.3.11",
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
49
|
+
"quibble": "^0.8.0",
|
50
|
+
"sinon": "^16.1.0",
|
51
|
+
"strip-ansi": "^7.1.0",
|
52
|
+
"ts-node": "^10.9.1",
|
44
53
|
"typescript": "^5.1.6"
|
45
54
|
},
|
46
55
|
"engines": {
|
47
|
-
"node": ">=
|
56
|
+
"node": ">=18.0.0"
|
48
57
|
},
|
49
58
|
"files": [
|
50
59
|
"oclif.manifest.json",
|
51
|
-
"/
|
60
|
+
"/dist",
|
61
|
+
"/oclif.lock"
|
52
62
|
],
|
53
63
|
"homepage": "https://github.com/oclif/plugin-update",
|
54
64
|
"keywords": [
|
@@ -57,25 +67,29 @@
|
|
57
67
|
"license": "MIT",
|
58
68
|
"oclif": {
|
59
69
|
"autoupdate": "github",
|
60
|
-
"commands": "./
|
70
|
+
"commands": "./dist/commands",
|
61
71
|
"bin": "oclif-example",
|
62
72
|
"hooks": {
|
63
|
-
"init": "./
|
73
|
+
"init": "./dist/hooks/init.js"
|
64
74
|
},
|
65
75
|
"devPlugins": [
|
66
76
|
"@oclif/plugin-help"
|
67
|
-
]
|
77
|
+
],
|
78
|
+
"flexibleTaxonomy": true
|
68
79
|
},
|
69
80
|
"repository": "oclif/plugin-update",
|
70
81
|
"scripts": {
|
71
|
-
"
|
82
|
+
"build": "rm -rf lib && tsc",
|
83
|
+
"lint": "eslint . --ext .ts",
|
84
|
+
"postpack": "rm -f oclif.manifest.json",
|
85
|
+
"posttest": "yarn lint",
|
86
|
+
"prepack": "yarn build && oclif lock && oclif manifest . && oclif lock",
|
87
|
+
"prepare": "husky install",
|
72
88
|
"pretest": "yarn build --noEmit && tsc -p test --noEmit",
|
89
|
+
"test:integration:sf": "mocha --forbid-only \"test/integration/sf.integration.ts\" --timeout 900000",
|
73
90
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
74
|
-
"
|
75
|
-
"prepack": "yarn build && oclif manifest .",
|
76
|
-
"postpack": "rm -f oclif.manifest.json",
|
77
|
-
"version": "oclif readme && git add README.md",
|
78
|
-
"build": "rm -rf lib && tsc"
|
91
|
+
"version": "oclif readme && git add README.md"
|
79
92
|
},
|
80
|
-
"
|
81
|
-
|
93
|
+
"exports": "./dist/index.js",
|
94
|
+
"type": "module"
|
95
|
+
}
|
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 = 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
|
-
UpdateCommand.description = 'update the <%= config.bin %> CLI';
|
46
|
-
UpdateCommand.args = {
|
47
|
-
channel: core_1.Args.string({ optional: true }),
|
48
|
-
};
|
49
|
-
UpdateCommand.examples = [
|
50
|
-
{
|
51
|
-
description: 'Update to the stable channel:',
|
52
|
-
command: '<%= config.bin %> <%= command.id %> stable',
|
53
|
-
},
|
54
|
-
{
|
55
|
-
description: 'Update to a specific version:',
|
56
|
-
command: '<%= config.bin %> <%= command.id %> --version 1.0.0',
|
57
|
-
},
|
58
|
-
{
|
59
|
-
description: 'Interactively select version:',
|
60
|
-
command: '<%= config.bin %> <%= command.id %> --interactive',
|
61
|
-
},
|
62
|
-
{
|
63
|
-
description: 'See available versions:',
|
64
|
-
command: '<%= config.bin %> <%= command.id %> --available',
|
65
|
-
},
|
66
|
-
];
|
67
|
-
UpdateCommand.flags = {
|
68
|
-
autoupdate: core_1.Flags.boolean({ hidden: true }),
|
69
|
-
available: core_1.Flags.boolean({
|
70
|
-
char: 'a',
|
71
|
-
description: 'Install a specific version.',
|
72
|
-
}),
|
73
|
-
version: core_1.Flags.string({
|
74
|
-
char: 'v',
|
75
|
-
description: 'Install a specific version.',
|
76
|
-
exclusive: ['interactive'],
|
77
|
-
}),
|
78
|
-
interactive: core_1.Flags.boolean({
|
79
|
-
char: 'i',
|
80
|
-
description: 'Interactively select version to install. This is ignored if a channel is provided.',
|
81
|
-
exclusive: ['version'],
|
82
|
-
}),
|
83
|
-
force: core_1.Flags.boolean({
|
84
|
-
description: 'Force a re-download of the requested version.',
|
85
|
-
}),
|
86
|
-
};
|
87
|
-
exports.default = UpdateCommand;
|
package/lib/hooks/init.js
DELETED
@@ -1,73 +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 child_process_1 = require("child_process");
|
7
|
-
const node_fs_1 = require("node:fs");
|
8
|
-
const promises_1 = require("node:fs/promises");
|
9
|
-
const path = tslib_1.__importStar(require("path"));
|
10
|
-
const util_1 = require("../util");
|
11
|
-
// eslint-disable-next-line unicorn/prefer-module
|
12
|
-
const debug = require('debug')('cli:updater');
|
13
|
-
function timestamp(msg) {
|
14
|
-
return `[${new Date().toISOString()}] ${msg}`;
|
15
|
-
}
|
16
|
-
async function mtime(f) {
|
17
|
-
const { mtime } = await (0, promises_1.stat)(f);
|
18
|
-
return mtime;
|
19
|
-
}
|
20
|
-
const init = async function (opts) {
|
21
|
-
if (opts.id === 'update')
|
22
|
-
return;
|
23
|
-
if (opts.config.scopedEnvVarTrue('DISABLE_AUTOUPDATE'))
|
24
|
-
return;
|
25
|
-
const binPath = this.config.binPath || this.config.bin;
|
26
|
-
const lastrunfile = path.join(this.config.cacheDir, 'lastrun');
|
27
|
-
const autoupdatefile = path.join(this.config.cacheDir, 'autoupdate');
|
28
|
-
const autoupdatelogfile = path.join(this.config.cacheDir, 'autoupdate.log');
|
29
|
-
const clientRoot = this.config.scopedEnvVar('OCLIF_CLIENT_HOME') || path.join(this.config.dataDir, 'client');
|
30
|
-
const autoupdateEnv = {
|
31
|
-
...process.env,
|
32
|
-
[this.config.scopedEnvVarKey('TIMESTAMPS')]: '1',
|
33
|
-
[this.config.scopedEnvVarKey('SKIP_ANALYTICS')]: '1',
|
34
|
-
};
|
35
|
-
async function autoupdateNeeded() {
|
36
|
-
try {
|
37
|
-
const m = await mtime(autoupdatefile);
|
38
|
-
let days = 1;
|
39
|
-
if (opts.config.channel === 'stable')
|
40
|
-
days = 14;
|
41
|
-
m.setHours(m.getHours() + (days * 24));
|
42
|
-
return m < new Date();
|
43
|
-
}
|
44
|
-
catch (error) {
|
45
|
-
if (error.code !== 'ENOENT')
|
46
|
-
core_1.ux.error(error.stack);
|
47
|
-
if (global.testing)
|
48
|
-
return false;
|
49
|
-
debug('autoupdate ENOENT');
|
50
|
-
return true;
|
51
|
-
}
|
52
|
-
}
|
53
|
-
await (0, util_1.touch)(lastrunfile);
|
54
|
-
const clientDir = path.join(clientRoot, this.config.version);
|
55
|
-
if ((0, node_fs_1.existsSync)(clientDir))
|
56
|
-
await (0, util_1.touch)(clientDir);
|
57
|
-
if (!await autoupdateNeeded())
|
58
|
-
return;
|
59
|
-
debug('autoupdate running');
|
60
|
-
await (0, promises_1.writeFile)(autoupdatefile, '');
|
61
|
-
debug(`spawning autoupdate on ${binPath}`);
|
62
|
-
const fd = await (0, promises_1.open)(autoupdatelogfile, 'a');
|
63
|
-
await (0, promises_1.writeFile)(fd, timestamp(`starting \`${binPath} update --autoupdate\` from ${process.argv.slice(1, 3).join(' ')}\n`));
|
64
|
-
const stream = fd.createWriteStream();
|
65
|
-
(0, child_process_1.spawn)(binPath, ['update', '--autoupdate'], {
|
66
|
-
detached: !this.config.windows,
|
67
|
-
stdio: ['ignore', stream, stream],
|
68
|
-
env: autoupdateEnv,
|
69
|
-
})
|
70
|
-
.on('error', (e) => process.emitWarning(e))
|
71
|
-
.unref();
|
72
|
-
};
|
73
|
-
exports.init = init;
|
package/lib/tar.d.ts
DELETED
package/lib/util.js
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.wait = exports.ls = exports.touch = void 0;
|
4
|
-
const tslib_1 = require("tslib");
|
5
|
-
const fs = tslib_1.__importStar(require("fs-extra"));
|
6
|
-
const path = tslib_1.__importStar(require("path"));
|
7
|
-
async function touch(p) {
|
8
|
-
try {
|
9
|
-
await fs.utimes(p, new Date(), new Date());
|
10
|
-
}
|
11
|
-
catch {
|
12
|
-
await fs.outputFile(p, '');
|
13
|
-
}
|
14
|
-
}
|
15
|
-
exports.touch = touch;
|
16
|
-
async function ls(dir) {
|
17
|
-
const files = await fs.readdir(dir);
|
18
|
-
const paths = files.map(f => path.join(dir, f));
|
19
|
-
return Promise.all(paths.map(path => fs.stat(path).then(stat => ({ path, stat }))));
|
20
|
-
}
|
21
|
-
exports.ls = ls;
|
22
|
-
function wait(ms, unref = false) {
|
23
|
-
return new Promise(resolve => {
|
24
|
-
const t = setTimeout(() => resolve(), ms);
|
25
|
-
if (unref)
|
26
|
-
t.unref();
|
27
|
-
});
|
28
|
-
}
|
29
|
-
exports.wait = wait;
|
File without changes
|