npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

danger-plugin-typescript-graph

v1.18.0

Published

Visualize the dependencies between files in the TypeScript code base.

Downloads

1,914

Readme

danger-plugin-typescript-graph

npm version semantic-release

This plugin is a Danger plugin designed to automatically run the CLI tool typescript-graph, which visualizes the dependencies between files in a TypeScript codebase, in a CI environment. Understanding dependencies is crucial for maintaining code integrity. By using this plugin, you can easily check dependencies before creating or merging a pull request.

Usage

Preparing to Run DangerJS on CI Environment

Before installing this library, make sure you have DangerJS set up to run on your CI environment. The setup involves the following 5 steps:

  1. Include the Danger module.
  2. Create a Dangerfile and add some basic rules.
  3. Create an account for Danger to use.
  4. Set up an access token for that account.
  5. Configure your CI environment to run Danger.

For more details, please refer to the DangerJS Official Getting Started Guide.

Install

yarn add danger-plugin-typescript-graph --dev

At a glance

// dangerfile.js
import typescriptGraph from 'danger-plugin-typescript-graph';

typescriptGraph();

Sample Usage

Basic File Modifications

In this example, we show the dependency graph when you've modified outputGraph.ts and its related test files. The modified files are highlighted in yellow, and the files they depend on are also explicitly displayed on the graph.

flowchart
    classDef modified fill:yellow,stroke:#999,color:black
    subgraph src["src"]
        src/utils["/utils"]:::dir
        src/index.ts["index.ts"]
        subgraph src/outputGraph["/outputGraph"]
            src/outputGraph/outputGraph.ts["outputGraph.ts"]:::modified
            src/outputGraph/output2Graphs.test.ts["output2Graphs.test.ts"]:::modified
            src/outputGraph/mergeGraphsWithDifferences.ts["mergeGraphsWithDifferences.ts"]
            src/outputGraph/applyMutualDifferences.ts["applyMutualDifferences.ts"]
        end
    end
    src/outputGraph/outputGraph.ts-->src/utils
    src/outputGraph/outputGraph.ts-->src/outputGraph/mergeGraphsWithDifferences.ts
    src/outputGraph/outputGraph.ts-->src/outputGraph/applyMutualDifferences.ts
    src/index.ts-->src/outputGraph/outputGraph.ts
    src/outputGraph/output2Graphs.test.ts-->src/outputGraph/outputGraph.ts
    src/outputGraph/mergeGraphsWithDifferences.ts-->src/utils
    src/outputGraph/applyMutualDifferences.ts-->src/utils
    src/index.ts-->src/utils

Changes Involving File Deletion or Movement

This case demonstrates the impact when a file is deleted or moved. Dependency graphs are generated for both the base branch and the head branch. Deleted files are displayed in a grayed-out manner.

Base Branch
flowchart
    classDef modified fill:yellow,stroke:#999,color:black
    classDef deleted fill:dimgray,stroke:#999,color:black,stroke-dasharray: 4 4,stroke-width:2px;
    subgraph src["src"]
        src/index.ts["index.ts"]:::modified
        src/index.test.ts["index.test.ts"]
        src/getRenameFiles.ts["getRenameFiles.ts"]
        src/getFullGraph.ts["getFullGraph.ts"]
        subgraph src/graph_["/graph"]
            src/_graph__/index.ts["index.ts"]:::deleted
            src/_graph__/outputGraph.ts["outputGraph.ts"]
            src/_graph__/output2Graphs.ts["output2Graphs.ts"]
        end
    end
    src/_graph__/index.ts-->src/_graph__/outputGraph.ts
    src/_graph__/index.ts-->src/_graph__/output2Graphs.ts
    src/index.ts-->src/getRenameFiles.ts
    src/index.ts-->src/getFullGraph.ts
    src/index.ts-->src/_graph__/index.ts
    src/index.test.ts-->src/index.ts
Head Branch
flowchart
    classDef modified fill:yellow,stroke:#999,color:black
    subgraph src["src"]
        src/index.ts["index.ts"]:::modified
        src/index.test.ts["index.test.ts"]
        src/getRenameFiles.ts["getRenameFiles.ts"]
        src/getFullGraph.ts["getFullGraph.ts"]
        subgraph src/graph_["/graph"]
            src/_graph__/output2Graphs.ts["output2Graphs.ts"]
            src/_graph__/outputGraph.ts["outputGraph.ts"]
        end
    end
    src/index.ts-->src/getRenameFiles.ts
    src/index.ts-->src/getFullGraph.ts
    src/index.ts-->src/_graph__/output2Graphs.ts
    src/index.ts-->src/_graph__/outputGraph.ts
    src/index.test.ts-->src/index.ts

Configuration

The .danger-tsgrc.json is a configuration file that stores settings in JSON format. If the relevant configuration file does not exist, or if it is in an invalid format, the default settings will be applied. Each configuration item has a corresponding environment variable, which takes precedence over the settings in the configuration file.

| Configuration Item | Details | Type | Default Value | Description | | --------------------------------- | --------------------------------------------------------------------------------- | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------- | | Root directory for tsconfig | Env: TSG_TSCONFIG_ROOTKey: tsconfigRoot | string | "./" | Specifies the directory where tsconfig will be searched. | | Maximum Node Count | Env: TSG_MAX_SIZEKey: maxSize | number | 30 | Specifies the value to limit graph display when the number of changed files is large. | | Graph Orientation | Env: TSG_ORIENTATIONKey: orientation | TB or LR | Not specified | Specifies the orientation (TB or LR) of the graph. However, Mermaid may produce graphs in the opposite direction. | | Debug Mode | Env: TSG_DEBUGKey: debug | boolean | false | Specifies whether to enable debug mode. Logs will be output in debug mode. | | Enclose in <details> tag | Env: TSG_IN_DETAILSKey: inDetails | boolean | true | Specifies whether to enclose Mermaid in a <details> tag and collapse it. | | Exclude Files | Env: NoneKey: exclude | string[] | [] | Specifies the files to be excluded from the graph. | | Display index.ts Dependency Files | Env: TSG_INCLUDE_INDEX_FILE_DEPENDENCIESKey: includeIndexFileDependencies | boolean | false | Specifies whether to display dependency files when the changed file is referenced from an index.ts in the same directory. |

Changelog

See the GitHub release history.

Contributing

See CONTRIBUTING.md.