packageanalyzer Documentation

website·Indexed 29 days ago

https://packageanalyzer-docs.vercel.app/

A framework for analyzing packages and dependency trees. It includes a CLI with commands for linting, analyzing, generating custom reports, checking licenses, and visualizing dependency trees, as well as a programmatic API via the @tmkn/packageanalyzer library.

Tokens
10.2K
Snippets
65
Records
81
Agent score
75%

What's inside packageanalyzer

  1. Overview of packageanalyzer CLI commands

    The packageanalyzer CLI provides a set of built-in commands for package auditing and analysis, including linting, general analysis, custom reporting, license checking, and dependency tree visualization.
  2. Overview of packageanalyzer framework

    packageanalyzer is an open-source framework used to introspect Node.js packages. It works by collecting metadata (such as package.json) for an entire dependency tree and providing utility functions to query that data. It can also be extended to collect additional custom data during the introspection process.
  3. Use Attachments to enrich package data in packageanalyzer

    In packageanalyzer, while the core process only collects package.json during dependency tree traversal, an Attachment allows you to add custom data to each package. An Attachment is a function executed for every package in the tree, enabling the retrieval of external data (e.g., npm weekly download counts, bundlephobia bundle sizes, or GitHub repository info) or the performance of custom calculations. The resulting data is associated with the package and becomes accessible via the Package class.
  4. Understand the Package class in packageanalyzer

    The Package class is the central component of packageanalyzer. After an analysis, it provides a single instance representing the root of the dependency tree. This nested structure allows developers to query the dependency tree, access data from the corresponding package.json, and retrieve associated Attachment data.
  5. Understand the Provider system in packageanalyzer

    The Provider is the component used by packageanalyzer to retrieve package.json files and package metadata, which are essential for building a dependency tree. Different providers exist for different data sources, such as the npm registry or the local file system.
  6. Validate package.json keys using ValidateKey

    The ValidateKey rule from @tmkn/packageanalyzer allows you to validate entries (keys) in a package.json file. It can be used to simply check if a key exists or to apply a custom validation function to the value of a specific key. The rule configuration is passed as the third element in the rule tuple within the lint configuration file.
    import { ValidateKey } from "@tmkn/packageanalyzer";
  7. Understand the role of the Package in packageanalyzer

    The Package entity processes data retrieved by the Provider and any associated Attachment data. It provides utility functions to interact with this data and is organized as a nested data structure that mirrors the dependency tree.
  8. Implement IPackageMetaDataProvider for package metadata retrieval

    The IPackageMetaDataProvider interface is used to fetch metadata containing information about all available versions of a specific package.
    export interface IPackageMetaDataProvider {
        getPackageMetadata(name: string): Promise<PackageMetaData | undefined>;
    }
  9. Run dependency tree checks using pkga lint

    The pkga lint command allows you to define and run checks on a dependency tree. If a rule is configured as an error and is triggered, the process will exit with a non-zero status code. Checks are defined in a JavaScript or TypeScript configuration file passed as the first argument to the command.