How to use the @snyk/cli-interface.legacyPlugin.isMultiResult function in @snyk/cli-interface

To help you get started, we’ve selected a few @snyk/cli-interface examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snyk / snyk / src / cli / commands / monitor / index.ts View on Github external
spinner.clear(postingMonitorSpinnerLabel),
        );

        await spinner.clear(postingMonitorSpinnerLabel)(res);

        res.path = path;
        const endpoint = url.parse(config.API);
        let leader = '';
        if (res.org) {
          leader = '/org/' + res.org;
        }
        endpoint.pathname = leader + '/manage';
        const manageUrl = url.format(endpoint);

        endpoint.pathname = leader + '/monitor/' + res.id;
        const projectName = pluginApi.isMultiResult(inspectResult)
          ? projectDeps.package.name
          : undefined;
        const monOutput = formatMonitorOutput(
          packageManager,
          res,
          manageUrl,
          options,
          projectName,
          foundProjectCount,
        );
        results.push({ ok: true, data: monOutput, path, projectName });
      }
      // push a good result
    } catch (err) {
      // push this error, the loop continues
      results.push({ ok: false, data: err, path });
github snyk / snyk / src / cli / commands / monitor.ts View on Github external
spinner.clear(postingMonitorSpinnerLabel),
        );

        await spinner.clear(postingMonitorSpinnerLabel)(res);

        res.path = path;
        const endpoint = url.parse(config.API);
        let leader = '';
        if (res.org) {
          leader = '/org/' + res.org;
        }
        endpoint.pathname = leader + '/manage';
        const manageUrl = url.format(endpoint);

        endpoint.pathname = leader + '/monitor/' + res.id;
        const projectName = pluginApi.isMultiResult(inspectResult)
          ? projectDeps.package.name
          : undefined;
        const monOutput = formatMonitorOutput(
          packageManager,
          res,
          manageUrl,
          options,
          projectName,
          advertiseSubprojectsCount,
        );
        results.push({ ok: true, data: monOutput, path, projectName });
      }
      // push a good result
    } catch (err) {
      // push this error, the loop continues
      results.push({ ok: false, data: err, path });
github snyk / snyk / src / cli / commands / monitor / index.ts View on Github external
'policy-path': options['policy-path'],
      'project-name': options['project-name'] || config.PROJECT_NAME,
      isDocker: !!options.docker,
      prune: !!options['prune-repeated-subdependencies'],
      'experimental-dep-graph': !!options['experimental-dep-graph'],
      'remote-repo-url': options['remote-repo-url'],
    };

    // We send results from "all-sub-projects" scanning as different Monitor objects

    // SinglePackageResult is a legacy format understood by Registry, so we have to convert
    // a MultiProjectResult to an array of these.

    let perProjectResult: pluginApi.SinglePackageResult[] = [];
    let foundProjectCount;
    if (pluginApi.isMultiResult(inspectResult)) {
      perProjectResult = convertMultiPluginResultToSingle(inspectResult);
    } else {
      foundProjectCount = getSubProjectCount(inspectResult);
      perProjectResult = [inspectResult];
    }

    // Post the project dependencies to the Registry
    for (const projectDeps of perProjectResult) {
      maybePrintDeps(options, projectDeps.package);

      const res = await promiseOrCleanup(
        snykMonitor(path, meta, projectDeps, targetFile),
        spinner.clear(postingMonitorSpinnerLabel),
      );

      await spinner.clear(postingMonitorSpinnerLabel)(res);
github snyk / snyk / src / lib / plugins / get-deps-from-plugin.ts View on Github external
}
    inspectRes = await getMultiPluginResult(root, options, targetFiles);
    return inspectRes;
  } else {
    // TODO: is this needed for the auto detect handling above?
    // don't override options.file if scanning multiple files at once
    if (!options.scanAllUnmanaged) {
      options.file = options.file || detectPackageFile(root);
    }
    if (!options.docker && !(options.file || options.packageManager)) {
      throw NoSupportedManifestsFoundError([...root]);
    }
    inspectRes = await getSinglePluginResult(root, options);
  }

  if (!pluginApi.isMultiResult(inspectRes)) {
    if (!inspectRes.package) {
      // something went wrong if both are not present...
      throw Error(
        `error getting dependencies from ${options.packageManager} ` +
          "plugin: neither 'package' nor 'scannedProjects' were found",
      );
    }
    if (!inspectRes.package.targetFile && inspectRes.plugin) {
      inspectRes.package.targetFile = inspectRes.plugin.targetFile;
    }
    // We are using "options" to store some information returned from plugin that we need to use later,
    // but don't want to send to Registry in the Payload.
    // TODO(kyegupov): decouple inspect and payload so that we don't need this hack
    if (
      inspectRes.plugin.meta &&
      inspectRes.plugin.meta.allSubProjectNames &&
github snyk / snyk / src / cli / commands / monitor / index.ts View on Github external
spinner.clear(postingMonitorSpinnerLabel),
      );

      await spinner.clear(postingMonitorSpinnerLabel)(res);

      res.path = path;
      const endpoint = url.parse(config.API);
      let leader = '';
      if (res.org) {
        leader = '/org/' + res.org;
      }
      endpoint.pathname = leader + '/manage';
      const manageUrl = url.format(endpoint);

      endpoint.pathname = leader + '/monitor/' + res.id;
      const projectName = pluginApi.isMultiResult(inspectResult)
        ? projectDeps.package.name
        : undefined;
      const monOutput = formatMonitorOutput(
        packageManager,
        res,
        manageUrl,
        options,
        projectName,
        foundProjectCount,
      );
      return { ok: true, data: monOutput, path, projectName };
    }
  } catch (err) {
    return { ok: false, data: err, path };
  }
  return {

@snyk/cli-interface

Snyk CLI interface definitions

Apache-2.0
Latest version published 10 months ago

Package Health Score

64 / 100
Full package analysis

Similar packages