snyk-nodejs-lockfile-parser

  • Version 2.2.1
  • Published
  • 308 kB
  • 18 dependencies
  • Apache-2.0 license

Install

npm i snyk-nodejs-lockfile-parser
yarn add snyk-nodejs-lockfile-parser
pnpm add snyk-nodejs-lockfile-parser

Overview

Generate a dep tree given a lockfile

Index

Functions

function buildDepGraphFromCliOutput

buildDepGraphFromCliOutput: (
rawCliOutput: string,
lockfileContent: string,
manifestFileContent: string
) => DepGraph;

    function buildDepGraphYarnLockV1Simple

    buildDepGraphYarnLockV1Simple: (
    extractedYarnLockV1Pkgs: NormalisedPkgs,
    pkgJson: PackageJsonBase,
    options: Yarn1DepGraphBuildOptions
    ) => Promise<import('@snyk/dep-graph').DepGraph>;

      function buildDepGraphYarnLockV1SimpleCyclesPruned

      buildDepGraphYarnLockV1SimpleCyclesPruned: (
      extractedYarnLockV1Pkgs: NormalisedPkgs,
      pkgJson: PackageJsonBase,
      options: DepGraphBuildOptions
      ) => Promise<import('@snyk/dep-graph').DepGraph>;

        function buildDepGraphYarnLockV1Workspace

        buildDepGraphYarnLockV1Workspace: (
        extractedYarnLockV1Pkgs: NormalisedPkgs,
        pkgJson: PackageJsonBase,
        workspacePkgNameToVersion: Record<string, string>,
        options: DepGraphBuildOptions
        ) => Promise<import('@snyk/dep-graph').DepGraph>;

          function buildDepGraphYarnLockV1WorkspaceCyclesPruned

          buildDepGraphYarnLockV1WorkspaceCyclesPruned: (
          extractedYarnLockV1Pkgs: NormalisedPkgs,
          pkgJson: PackageJsonBase,
          workspacePkgNameToVersion: Record<string, string>,
          options: DepGraphBuildOptions
          ) => Promise<import('@snyk/dep-graph').DepGraph>;

            function buildDepGraphYarnLockV2Simple

            buildDepGraphYarnLockV2Simple: (
            extractedYarnLockV2Pkgs: NormalisedPkgs,
            pkgJson: PackageJsonBase,
            options: YarnLockV2ProjectParseOptions,
            workspaceArgs?: YarnLockV2WorkspaceArgs
            ) => Promise<import('@snyk/dep-graph').DepGraph>;

              function buildDepTree

              buildDepTree: (
              manifestFileContents: string,
              lockFileContents: string,
              includeDev?: boolean,
              lockfileType?: LockfileType,
              strictOutOfSync?: boolean,
              defaultManifestFileName?: string
              ) => Promise<PkgTree>;

                function buildDepTreeFromFiles

                buildDepTreeFromFiles: (
                root: string,
                manifestFilePath: string,
                lockFilePath: string,
                includeDev?: boolean,
                strictOutOfSync?: boolean,
                honorAliases?: boolean
                ) => Promise<PkgTree>;

                  function extractPkgsFromYarnLockV1

                  extractPkgsFromYarnLockV1: (yarnLockContent: string) => NormalisedPkgs;

                    function extractPkgsFromYarnLockV2

                    extractPkgsFromYarnLockV2: (yarnLockContent: string) => NormalisedPkgs;

                      function getLockfileVersionFromFile

                      getLockfileVersionFromFile: (targetFile: string) => NodeLockfileVersion;

                        function getNpmLockfileVersion

                        getNpmLockfileVersion: (
                        lockFileContents: string
                        ) =>
                        | NodeLockfileVersion.NpmLockV1
                        | NodeLockfileVersion.NpmLockV2
                        | NodeLockfileVersion.NpmLockV3;

                          function getPnpmLockfileParser

                          getPnpmLockfileParser: (
                          pnpmLockContent: string | undefined,
                          lockfileVersion?: NodeLockfileVersion,
                          workspaceArgs?: PnpmWorkspaceArgs
                          ) => PnpmLockfileParser;

                            function getPnpmLockfileVersion

                            getPnpmLockfileVersion: (
                            lockFileContents: string
                            ) =>
                            | NodeLockfileVersion.PnpmLockV5
                            | NodeLockfileVersion.PnpmLockV6
                            | NodeLockfileVersion.PnpmLockV9;

                              function getPnpmWorkspaces

                              getPnpmWorkspaces: (workspacesYamlFile: string) => string[];

                                function getYarnLockfileType

                                getYarnLockfileType: (
                                lockFileContents: string,
                                root?: string,
                                lockFilePath?: string
                                ) => LockfileType;

                                  function getYarnLockfileVersion

                                  getYarnLockfileVersion: (
                                  lockFileContents: string
                                  ) => NodeLockfileVersion.YarnLockV1 | NodeLockfileVersion.YarnLockV2;

                                    function getYarnWorkspaces

                                    getYarnWorkspaces: (targetFile: string) => string[] | false;

                                      function getYarnWorkspacesFromFiles

                                      getYarnWorkspacesFromFiles: (
                                      root: any,
                                      manifestFilePath: string
                                      ) => string[] | false;

                                        function parseNpmLockV2Project

                                        parseNpmLockV2Project: (
                                        pkgJsonContent: string,
                                        pkgLockContent: string,
                                        options: ProjectParseOptions
                                        ) => Promise<DepGraph>;

                                          function parsePkgJson

                                          parsePkgJson: (pkgJsonContent: string) => PackageJsonBase;

                                            function parsePnpmProject

                                            parsePnpmProject: (
                                            pkgJsonContent: string,
                                            pnpmLockContent: string | undefined,
                                            options: PnpmProjectParseOptions,
                                            lockfileVersion?: NodeLockfileVersion
                                            ) => Promise<DepGraph>;

                                              function parsePnpmWorkspace

                                              parsePnpmWorkspace: (
                                              root: string,
                                              workspaceDir: string,
                                              options: PnpmProjectParseOptions
                                              ) => Promise<ScannedNodeProject[]>;

                                                function parsePnpmWorkspaceProject

                                                parsePnpmWorkspaceProject: (
                                                pkgJsonContent: string,
                                                pnpmLockfileContents: string,
                                                options: PnpmProjectParseOptions,
                                                importer: string,
                                                lockfileVersion?: NodeLockfileVersion
                                                ) => Promise<DepGraph>;

                                                  function parseYarnLockV1Project

                                                  parseYarnLockV1Project: (
                                                  pkgJsonContent: string,
                                                  yarnLockContent: string,
                                                  options: YarnLockV1ProjectParseOptions
                                                  ) => Promise<import('@snyk/dep-graph').DepGraph>;

                                                    function parseYarnLockV1WorkspaceProject

                                                    parseYarnLockV1WorkspaceProject: (
                                                    yarnLockContent: string,
                                                    workspacePackagesPkgJsons: string[],
                                                    options: ProjectParseOptions
                                                    ) => Promise<DepGraph[]>;

                                                      function parseYarnLockV2Project

                                                      parseYarnLockV2Project: (
                                                      pkgJsonContent: string,
                                                      yarnLockContent: string,
                                                      options: YarnLockV2ProjectParseOptions,
                                                      workspaceArgs?: YarnLockV2WorkspaceArgs
                                                      ) => Promise<DepGraph>;

                                                        Classes

                                                        class InvalidUserInputError

                                                        class InvalidUserInputError extends Error {}

                                                          constructor

                                                          constructor(...args: any[]);

                                                            property code

                                                            code: number;

                                                              property name

                                                              name: string;

                                                                class OutOfSyncError

                                                                class OutOfSyncError extends Error {}

                                                                  constructor

                                                                  constructor(dependencyName: string, lockFileType: LockfileType);

                                                                    property code

                                                                    code: number;

                                                                      property dependencyName

                                                                      dependencyName: string;

                                                                        property lockFileType

                                                                        lockFileType: string;

                                                                          property name

                                                                          name: string;

                                                                            class UnsupportedRuntimeError

                                                                            class UnsupportedRuntimeError extends Error {}

                                                                              constructor

                                                                              constructor(...args: any[]);

                                                                                property code

                                                                                code: number;

                                                                                  property name

                                                                                  name: string;

                                                                                    Interfaces

                                                                                    interface ManifestFile

                                                                                    interface ManifestFile {}

                                                                                      property dependencies

                                                                                      dependencies?: ManifestDependencies;

                                                                                        property devDependencies

                                                                                        devDependencies?: ManifestDependencies;

                                                                                          property engines

                                                                                          engines?: {
                                                                                          node?: string;
                                                                                          };

                                                                                            property name

                                                                                            name: string;

                                                                                              property optionalDependencies

                                                                                              optionalDependencies?: ManifestDependencies;

                                                                                                property peerDependencies

                                                                                                peerDependencies?: ManifestDependencies;

                                                                                                  property peerDependenciesMeta

                                                                                                  peerDependenciesMeta?: PeerDependenciesMeta;

                                                                                                    property private

                                                                                                    private?: string;

                                                                                                      property resolutions

                                                                                                      resolutions?: ManifestDependencies;

                                                                                                        property version

                                                                                                        version?: string;

                                                                                                          property workspaces

                                                                                                          workspaces?: string[] | WorkspacesAlternateConfig;

                                                                                                            interface PkgTree

                                                                                                            interface PkgTree extends DepTreeDep {}

                                                                                                              property cyclic

                                                                                                              cyclic?: boolean;

                                                                                                                property dependencies

                                                                                                                dependencies: {
                                                                                                                [depName: string]: DepTreeDep;
                                                                                                                };

                                                                                                                  property hasDevDependencies

                                                                                                                  hasDevDependencies?: boolean;

                                                                                                                    property meta

                                                                                                                    meta?: {
                                                                                                                    nodeVersion?: string;
                                                                                                                    lockfileVersion?: number;
                                                                                                                    packageManager?: string;
                                                                                                                    };

                                                                                                                      property packageFormatVersion

                                                                                                                      packageFormatVersion?: string;

                                                                                                                        property size

                                                                                                                        size?: number;

                                                                                                                          property type

                                                                                                                          type?: string;

                                                                                                                            Enums

                                                                                                                            enum LockfileType

                                                                                                                            enum LockfileType {
                                                                                                                            npm = 'npm',
                                                                                                                            npm7 = 'npm7',
                                                                                                                            yarn = 'yarn',
                                                                                                                            yarn2 = 'yarn2',
                                                                                                                            pnpm = 'pnpm',
                                                                                                                            }

                                                                                                                              member npm

                                                                                                                              npm = 'npm'

                                                                                                                                member npm7

                                                                                                                                npm7 = 'npm7'

                                                                                                                                  member pnpm

                                                                                                                                  pnpm = 'pnpm'

                                                                                                                                    member yarn

                                                                                                                                    yarn = 'yarn'

                                                                                                                                      member yarn2

                                                                                                                                      yarn2 = 'yarn2'

                                                                                                                                        enum NodeLockfileVersion

                                                                                                                                        enum NodeLockfileVersion {
                                                                                                                                        NpmLockV1 = 'NPM_LOCK_V1',
                                                                                                                                        NpmLockV2 = 'NPM_LOCK_V2',
                                                                                                                                        NpmLockV3 = 'NPM_LOCK_V3',
                                                                                                                                        YarnLockV1 = 'YARN_LOCK_V1',
                                                                                                                                        YarnLockV2 = 'YARN_LOCK_V2',
                                                                                                                                        PnpmLockV5 = 'PNPM_LOCK_V5',
                                                                                                                                        PnpmLockV6 = 'PNPM_LOCK_V6',
                                                                                                                                        PnpmLockV9 = 'PNPM_LOCK_V9',
                                                                                                                                        }

                                                                                                                                          member NpmLockV1

                                                                                                                                          NpmLockV1 = 'NPM_LOCK_V1'

                                                                                                                                            member NpmLockV2

                                                                                                                                            NpmLockV2 = 'NPM_LOCK_V2'

                                                                                                                                              member NpmLockV3

                                                                                                                                              NpmLockV3 = 'NPM_LOCK_V3'

                                                                                                                                                member PnpmLockV5

                                                                                                                                                PnpmLockV5 = 'PNPM_LOCK_V5'

                                                                                                                                                  member PnpmLockV6

                                                                                                                                                  PnpmLockV6 = 'PNPM_LOCK_V6'

                                                                                                                                                    member PnpmLockV9

                                                                                                                                                    PnpmLockV9 = 'PNPM_LOCK_V9'

                                                                                                                                                      member YarnLockV1

                                                                                                                                                      YarnLockV1 = 'YARN_LOCK_V1'

                                                                                                                                                        member YarnLockV2

                                                                                                                                                        YarnLockV2 = 'YARN_LOCK_V2'

                                                                                                                                                          enum Scope

                                                                                                                                                          enum Scope {
                                                                                                                                                          prod = 'prod',
                                                                                                                                                          dev = 'dev',
                                                                                                                                                          }

                                                                                                                                                            member dev

                                                                                                                                                            dev = 'dev'

                                                                                                                                                              member prod

                                                                                                                                                              prod = 'prod'

                                                                                                                                                                Type Aliases

                                                                                                                                                                type NormalisedPkgs

                                                                                                                                                                type NormalisedPkgs = Record<
                                                                                                                                                                PkgIdentifier,
                                                                                                                                                                {
                                                                                                                                                                version: string;
                                                                                                                                                                resolution?: string;
                                                                                                                                                                dependencies: Record<string, string>;
                                                                                                                                                                optionalDependencies: Record<string, string>;
                                                                                                                                                                }
                                                                                                                                                                >;

                                                                                                                                                                  type PackageJsonBase

                                                                                                                                                                  type PackageJsonBase = {
                                                                                                                                                                  name: string;
                                                                                                                                                                  version: string;
                                                                                                                                                                  dependencies?: Record<string, string>;
                                                                                                                                                                  devDependencies?: Record<string, string>;
                                                                                                                                                                  optionalDependencies?: Record<string, string>;
                                                                                                                                                                  peerDependencies?: Record<string, string>;
                                                                                                                                                                  resolutions?: Record<string, string>;
                                                                                                                                                                  overrides?: Overrides;
                                                                                                                                                                  pnpm?: {
                                                                                                                                                                  overrides?: Overrides;
                                                                                                                                                                  };
                                                                                                                                                                  };

                                                                                                                                                                    type ProjectParseOptions

                                                                                                                                                                    type ProjectParseOptions = DepGraphBuildOptions &
                                                                                                                                                                    LockFileParseOptions & {
                                                                                                                                                                    pruneCycles: boolean;
                                                                                                                                                                    };

                                                                                                                                                                      type YarnLockPackages

                                                                                                                                                                      type NormalisedPkgs = Record<
                                                                                                                                                                      PkgIdentifier,
                                                                                                                                                                      {
                                                                                                                                                                      version: string;
                                                                                                                                                                      resolution?: string;
                                                                                                                                                                      dependencies: Record<string, string>;
                                                                                                                                                                      optionalDependencies: Record<string, string>;
                                                                                                                                                                      }
                                                                                                                                                                      >;

                                                                                                                                                                        type YarnLockV2ProjectParseOptions

                                                                                                                                                                        type YarnLockV2ProjectParseOptions = {
                                                                                                                                                                        includeDevDeps: boolean;
                                                                                                                                                                        includeOptionalDeps: boolean;
                                                                                                                                                                        strictOutOfSync: boolean;
                                                                                                                                                                        pruneWithinTopLevelDeps: boolean;
                                                                                                                                                                        honorAliases?: boolean;
                                                                                                                                                                        };

                                                                                                                                                                          Package Files (24)

                                                                                                                                                                          Dependencies (18)

                                                                                                                                                                          Dev Dependencies (14)

                                                                                                                                                                          Peer Dependencies (0)

                                                                                                                                                                          No peer dependencies.

                                                                                                                                                                          Badge

                                                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/snyk-nodejs-lockfile-parser.

                                                                                                                                                                          • Markdown
                                                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/snyk-nodejs-lockfile-parser)
                                                                                                                                                                          • HTML
                                                                                                                                                                            <a href="https://www.jsdocs.io/package/snyk-nodejs-lockfile-parser"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>