oclif 3.16.0 → 3.17.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/.oclif.manifest.json +1 -1
- package/lib/commands/manifest.d.ts +2 -1
- package/lib/commands/manifest.js +38 -22
- package/lib/tarballs/node.js +7 -18
- package/lib/util.d.ts +1 -0
- package/lib/util.js +18 -2
- package/package.json +2 -2
package/.oclif.manifest.json
CHANGED
package/lib/commands/manifest.js
CHANGED
|
@@ -6,6 +6,11 @@ const path = require("path");
|
|
|
6
6
|
const os = require("os");
|
|
7
7
|
const semver = require("semver");
|
|
8
8
|
const shelljs_1 = require("shelljs");
|
|
9
|
+
const got_1 = require("got");
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
const stream_1 = require("stream");
|
|
12
|
+
const util_2 = require("../util");
|
|
13
|
+
const pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
9
14
|
async function fileExists(filePath) {
|
|
10
15
|
try {
|
|
11
16
|
await fs.access(filePath);
|
|
@@ -32,20 +37,26 @@ class Manifest extends core_1.Command {
|
|
|
32
37
|
const tmpDir = os.tmpdir();
|
|
33
38
|
const promises = Object.entries(packageJson.oclif.jitPlugins).map(async ([jitPlugin, version]) => {
|
|
34
39
|
const pluginDir = jitPlugin.replace('/', '-').replace('@', '');
|
|
35
|
-
const repo = this.executeCommand(`npm view ${jitPlugin}@latest repository --json`);
|
|
36
|
-
const stdout = JSON.parse(repo.stdout);
|
|
37
|
-
const repoUrl = stdout.url.replace(`${stdout.type}+`, '');
|
|
38
40
|
const fullPath = path.join(tmpDir, pluginDir);
|
|
39
41
|
if (await fileExists(fullPath))
|
|
40
42
|
await fs.remove(fullPath);
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
await fs.mkdir(fullPath, { recursive: true });
|
|
44
|
+
const resolvedVersion = this.getVersion(jitPlugin, version);
|
|
45
|
+
const tarballUrl = this.getTarballUrl(jitPlugin, resolvedVersion);
|
|
46
|
+
const tarball = path.join(fullPath, path.basename(tarballUrl));
|
|
47
|
+
await pipeline(got_1.default.stream(tarballUrl), fs.createWriteStream(tarball));
|
|
48
|
+
if (process.platform === 'win32') {
|
|
49
|
+
await (0, util_2.checkFor7Zip)();
|
|
50
|
+
(0, shelljs_1.exec)(`7z x -bd -y "${tarball}"`, { cwd: fullPath });
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
(0, shelljs_1.exec)(`tar -xzf "${tarball}"`, { cwd: fullPath });
|
|
54
|
+
}
|
|
55
|
+
const manifest = await fs.readJSON(path.join(fullPath, 'package', 'oclif.manifest.json'));
|
|
56
|
+
for (const command of Object.values(manifest.commands)) {
|
|
57
|
+
command.pluginType = 'jit';
|
|
58
|
+
}
|
|
59
|
+
return manifest;
|
|
49
60
|
});
|
|
50
61
|
core_1.ux.action.start('Generating JIT plugin manifests');
|
|
51
62
|
jitPluginManifests = await Promise.all(promises);
|
|
@@ -72,18 +83,23 @@ class Manifest extends core_1.Command {
|
|
|
72
83
|
fs.writeFileSync(file, JSON.stringify(plugin.manifest, null, 2));
|
|
73
84
|
this.log(`wrote manifest to ${file}`);
|
|
74
85
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
getVersion(plugin, version) {
|
|
87
|
+
var _a;
|
|
88
|
+
if (version.startsWith('^') || version.startsWith('~')) {
|
|
89
|
+
// Grab latest from npm to get all the versions so we can find the max satisfying version.
|
|
90
|
+
// We explicitly ask for latest since this command is typically run inside of `npm prepack`,
|
|
91
|
+
// which sets the npm_config_tag env var, which is used as the default anytime a tag isn't
|
|
92
|
+
// provided to `npm view`. This can be problematic if you're building the `nightly` version
|
|
93
|
+
// of a CLI and all the JIT plugins don't have a `nightly` tag themselves.
|
|
94
|
+
// TL;DR - always ask for latest to avoid potentially requesting a non-existent tag.
|
|
95
|
+
const { versions } = JSON.parse(this.executeCommand(`npm view ${plugin}@latest --json`).stdout);
|
|
96
|
+
return (_a = semver.maxSatisfying(versions, version)) !== null && _a !== void 0 ? _a : version.replace('^', '').replace('~', '');
|
|
86
97
|
}
|
|
98
|
+
return version;
|
|
99
|
+
}
|
|
100
|
+
getTarballUrl(plugin, version) {
|
|
101
|
+
const { dist } = JSON.parse(this.executeCommand(`npm view ${plugin}@${version} --json`).stdout);
|
|
102
|
+
return dist.tarball;
|
|
87
103
|
}
|
|
88
104
|
executeCommand(command, options) {
|
|
89
105
|
const debugString = (options === null || options === void 0 ? void 0 : options.cwd) ? `executing command: ${command} in ${options.cwd}` : `executing command: ${command}`;
|
package/lib/tarballs/node.js
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchNodeBinary = void 0;
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
4
|
const path = require("path");
|
|
6
5
|
const fs = require("fs-extra");
|
|
7
|
-
const
|
|
6
|
+
const stream_1 = require("stream");
|
|
8
7
|
const log_1 = require("../log");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const util_1 = require("util");
|
|
11
10
|
const got_1 = require("got");
|
|
12
11
|
const retry = require("async-retry");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const util_2 = require("../util");
|
|
13
|
+
const pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
14
|
+
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
15
15
|
const RETRY_TIMEOUT_MS = 1000;
|
|
16
|
-
async function checkFor7Zip() {
|
|
17
|
-
try {
|
|
18
|
-
await exec('7z');
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
if (error.code === 127)
|
|
22
|
-
core_1.Errors.error('install 7-zip to package windows tarball');
|
|
23
|
-
else
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
16
|
async function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }) {
|
|
28
17
|
if (arch === 'arm')
|
|
29
18
|
arch = 'armv7l';
|
|
@@ -31,7 +20,7 @@ async function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }) {
|
|
|
31
20
|
let tarball = path.join(tmp, 'node', `${nodeBase}.tar.xz`);
|
|
32
21
|
let url = `https://nodejs.org/dist/v${nodeVersion}/${nodeBase}.tar.xz`;
|
|
33
22
|
if (platform === 'win32') {
|
|
34
|
-
await checkFor7Zip();
|
|
23
|
+
await (0, util_2.checkFor7Zip)();
|
|
35
24
|
nodeBase = `node-v${nodeVersion}-win-${arch}`;
|
|
36
25
|
tarball = path.join(tmp, 'node', `${nodeBase}.7z`);
|
|
37
26
|
url = `https://nodejs.org/dist/v${nodeVersion}/${nodeBase}.7z`;
|
package/lib/util.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ interface VersionsObject {
|
|
|
12
12
|
export declare const sortVersionsObjectByKeysDesc: (input: VersionsObject) => VersionsObject;
|
|
13
13
|
export declare const prettifyPaths: (input: string) => string;
|
|
14
14
|
export declare const hash: (algo: string, fp: string | string[]) => Promise<string>;
|
|
15
|
+
export declare function checkFor7Zip(): Promise<void>;
|
|
15
16
|
export {};
|
package/lib/util.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hash = exports.prettifyPaths = exports.sortVersionsObjectByKeysDesc = exports.template = exports.sortBy = exports.compact = exports.uniqBy = exports.castArray = void 0;
|
|
3
|
+
exports.checkFor7Zip = exports.hash = exports.prettifyPaths = exports.sortVersionsObjectByKeysDesc = exports.template = exports.sortBy = exports.compact = exports.uniqBy = exports.castArray = void 0;
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
4
5
|
const _ = require("lodash");
|
|
5
6
|
const os = require("os");
|
|
6
|
-
const crypto = require("
|
|
7
|
+
const crypto = require("crypto");
|
|
7
8
|
const log_1 = require("./log");
|
|
8
9
|
const fs = require("fs-extra");
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
9
13
|
function castArray(input) {
|
|
10
14
|
if (input === undefined)
|
|
11
15
|
return [];
|
|
@@ -91,3 +95,15 @@ const hash = async (algo, fp) => {
|
|
|
91
95
|
});
|
|
92
96
|
};
|
|
93
97
|
exports.hash = hash;
|
|
98
|
+
async function checkFor7Zip() {
|
|
99
|
+
try {
|
|
100
|
+
await exec('7z');
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error.code === 127)
|
|
104
|
+
core_1.Errors.error('install 7-zip to package windows tarball');
|
|
105
|
+
else
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.checkFor7Zip = checkFor7Zip;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oclif",
|
|
3
3
|
"description": "oclif: create your own CLI",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.17.1",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bin": {
|
|
7
7
|
"oclif": "bin/run"
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"posttest": "yarn run lint",
|
|
129
129
|
"prepack": "shx rm -rf lib && tsc && bin/dev manifest .",
|
|
130
130
|
"test": "nps test && yarn test:unit && yarn test:integration",
|
|
131
|
-
"test:integration": "mocha --forbid-only \"test/integration/*.test.ts\"",
|
|
131
|
+
"test:integration": "mocha --forbid-only \"test/integration/*.test.ts\" --timeout 600000",
|
|
132
132
|
"test:unit": "mocha --forbid-only \"test/unit/*.test.ts\"",
|
|
133
133
|
"version": "bin/dev readme && git add README.md"
|
|
134
134
|
},
|