MCPcopy
hub / github.com/Kong/insomnia / getPluginInfo

Function getPluginInfo

packages/insomnia/src/main/install-plugin.ts:206–243  ·  view source on GitHub ↗
(lookupName: string, allowScopedPackageNames = false)

Source from the content-addressed store, hash-verified

204 * Verifies that the package contains an "insomnia" attribute.
205 */
206export async function getPluginInfo(lookupName: string, allowScopedPackageNames = false) {
207 const validationError = validatePluginName(lookupName, allowScopedPackageNames);
208
209 if (validationError) {
210 throw new Error(validationError);
211 }
212
213 console.log('[plugins] Fetching module info from npm');
214
215 const registryUrl = await getRegistryUrl();
216 const stdout = await runYarnCommand(['info', lookupName, '--json', '--registry', registryUrl]);
217
218 let yarnOutput;
219 try {
220 yarnOutput = JSON.parse(stdout);
221 } catch (err) {
222 throw new Error(`Invalid JSON received from yarn: ${(err as Error).message}`);
223 }
224
225 const data = yarnOutput.data;
226 if (!data || typeof data !== 'object') {
227 throw new Error(`Unexpected yarn output structure`);
228 }
229
230 if (!data.insomnia) {
231 throw new Error(`Package "${lookupName}" is not an Insomnia plugin (missing "insomnia" attribute)`);
232 }
233
234 return {
235 insomnia: data.insomnia,
236 name: data.name,
237 version: data.version,
238 dist: {
239 shasum: data.dist.shasum,
240 tarball: data.dist.tarball,
241 },
242 };
243}
244
245/**
246 * Installs a plugin into a temporary directory using Yarn.

Callers 2

installPluginFunction · 0.85

Calls 5

validatePluginNameFunction · 0.90
getRegistryUrlFunction · 0.85
runYarnCommandFunction · 0.85
logMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected