oclif 4.17.20 → 4.17.22
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/lib/commands/manifest.d.ts +1 -2
- package/lib/commands/manifest.js +13 -29
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/lib/commands/manifest.js
CHANGED
|
@@ -41,10 +41,6 @@ const fs_extra_1 = require("fs-extra");
|
|
|
41
41
|
const node_child_process_1 = require("node:child_process");
|
|
42
42
|
const os = __importStar(require("node:os"));
|
|
43
43
|
const node_path_1 = __importDefault(require("node:path"));
|
|
44
|
-
const node_stream_1 = require("node:stream");
|
|
45
|
-
const node_util_1 = require("node:util");
|
|
46
|
-
const semver_1 = require("semver");
|
|
47
|
-
const pipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
|
|
48
44
|
async function fileExists(filePath) {
|
|
49
45
|
try {
|
|
50
46
|
await (0, fs_extra_1.access)(filePath);
|
|
@@ -74,22 +70,18 @@ class Manifest extends core_1.Command {
|
|
|
74
70
|
catch { }
|
|
75
71
|
const { args } = await this.parse(Manifest);
|
|
76
72
|
const root = node_path_1.default.resolve(args.path);
|
|
77
|
-
const packageJson = (0, fs_extra_1.readJSONSync)('package.json');
|
|
73
|
+
const packageJson = (0, fs_extra_1.readJSONSync)(node_path_1.default.join(root, 'package.json'));
|
|
78
74
|
let jitPluginManifests = [];
|
|
79
75
|
if (flags.jit && packageJson.oclif?.jitPlugins) {
|
|
80
76
|
this.debug('jitPlugins: %s', packageJson.oclif.jitPlugins);
|
|
81
77
|
const tmpDir = os.tmpdir();
|
|
82
|
-
const { default: got } = await import('got');
|
|
83
78
|
const promises = Object.entries(packageJson.oclif.jitPlugins).map(async ([jitPlugin, version]) => {
|
|
84
79
|
const pluginDir = jitPlugin.replace('/', '-').replace('@', '');
|
|
85
80
|
const fullPath = node_path_1.default.join(tmpDir, pluginDir);
|
|
86
81
|
if (await fileExists(fullPath))
|
|
87
82
|
await (0, fs_extra_1.remove)(fullPath);
|
|
88
83
|
await (0, fs_extra_1.mkdir)(fullPath, { recursive: true });
|
|
89
|
-
const
|
|
90
|
-
const tarballUrl = await this.getTarballUrl(jitPlugin, resolvedVersion);
|
|
91
|
-
const tarball = node_path_1.default.join(fullPath, node_path_1.default.basename(tarballUrl));
|
|
92
|
-
await pipeline(got.stream(tarballUrl), (0, fs_extra_1.createWriteStream)(tarball));
|
|
84
|
+
const tarball = await this.downloadTarball(jitPlugin, version, fullPath);
|
|
93
85
|
await this.executeCommand(`tar -xzf "${tarball}"`, { cwd: fullPath });
|
|
94
86
|
const manifest = (await (0, fs_extra_1.readJSON)(node_path_1.default.join(fullPath, 'package', 'oclif.manifest.json')));
|
|
95
87
|
for (const command of Object.values(manifest.commands)) {
|
|
@@ -134,6 +126,17 @@ class Manifest extends core_1.Command {
|
|
|
134
126
|
this.log(`wrote manifest to ${file}`);
|
|
135
127
|
return plugin.manifest;
|
|
136
128
|
}
|
|
129
|
+
async downloadTarball(plugin, version, tarballStoragePath) {
|
|
130
|
+
const { stderr } = await this.executeCommand(`npm pack ${plugin}@${version} --pack-destination "${tarballStoragePath}" --json`);
|
|
131
|
+
// You can `npm pack` with multiple modules to download multiple at a time. There will be at least 1 if the command
|
|
132
|
+
// succeeded.
|
|
133
|
+
const tarballs = JSON.parse(stderr);
|
|
134
|
+
if (!Array.isArray(tarballs) || tarballs.length !== 1) {
|
|
135
|
+
throw new Error(`Could not download tarballs for ${plugin}. Tarball download was not in the correct format.`);
|
|
136
|
+
}
|
|
137
|
+
const { filename } = tarballs[0];
|
|
138
|
+
return node_path_1.default.join(tarballStoragePath, filename);
|
|
139
|
+
}
|
|
137
140
|
async executeCommand(command, options) {
|
|
138
141
|
return new Promise((resolve) => {
|
|
139
142
|
(0, node_child_process_1.exec)(command, options, (error, stderr, stdout) => {
|
|
@@ -149,24 +152,5 @@ class Manifest extends core_1.Command {
|
|
|
149
152
|
});
|
|
150
153
|
});
|
|
151
154
|
}
|
|
152
|
-
async getTarballUrl(plugin, version) {
|
|
153
|
-
const { stderr } = await this.executeCommand(`npm view ${plugin}@${version} --json`);
|
|
154
|
-
const { dist } = JSON.parse(stderr);
|
|
155
|
-
return dist.tarball;
|
|
156
|
-
}
|
|
157
|
-
async getVersion(plugin, version) {
|
|
158
|
-
if (version.startsWith('^') || version.startsWith('~')) {
|
|
159
|
-
// Grab latest from npm to get all the versions so we can find the max satisfying version.
|
|
160
|
-
// We explicitly ask for latest since this command is typically run inside of `npm prepack`,
|
|
161
|
-
// which sets the npm_config_tag env var, which is used as the default anytime a tag isn't
|
|
162
|
-
// provided to `npm view`. This can be problematic if you're building the `nightly` version
|
|
163
|
-
// of a CLI and all the JIT plugins don't have a `nightly` tag themselves.
|
|
164
|
-
// TL;DR - always ask for latest to avoid potentially requesting a non-existent tag.
|
|
165
|
-
const { stderr } = await this.executeCommand(`npm view ${plugin}@latest --json`);
|
|
166
|
-
const { versions } = JSON.parse(stderr);
|
|
167
|
-
return (0, semver_1.maxSatisfying)(versions, version) ?? version.replace('^', '').replace('~', '');
|
|
168
|
-
}
|
|
169
|
-
return version;
|
|
170
|
-
}
|
|
171
155
|
}
|
|
172
156
|
exports.default = Manifest;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oclif",
|
|
3
3
|
"description": "oclif: create your own CLI",
|
|
4
|
-
"version": "4.17.
|
|
4
|
+
"version": "4.17.22",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bin": {
|
|
7
7
|
"oclif": "bin/run.js"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@inquirer/input": "^2.2.4",
|
|
15
15
|
"@inquirer/select": "^2.5.0",
|
|
16
16
|
"@oclif/core": "^4.2.3",
|
|
17
|
-
"@oclif/plugin-help": "^6.2.
|
|
17
|
+
"@oclif/plugin-help": "^6.2.23",
|
|
18
18
|
"@oclif/plugin-not-found": "^3.2.32",
|
|
19
19
|
"@oclif/plugin-warn-if-update-available": "^3.1.31",
|
|
20
20
|
"async-retry": "^1.3.3",
|