Skip to content

Pulling feat/dep-tree-gen into develop#1082

Open
github-actions[bot] wants to merge 33 commits into
developfrom
feat/dep-tree-gen
Open

Pulling feat/dep-tree-gen into develop#1082
github-actions[bot] wants to merge 33 commits into
developfrom
feat/dep-tree-gen

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

No description provided.

ktun95 added 12 commits June 12, 2025 12:09
This commit introduces a new package, `@dictybase/scripts`, which
contains scripts for the frontend. It includes:

- README.md: A basic README file for the package.
- package.json: Defines the package's metadata, dependencies, and
  scripts for building, testing, and linting.
- tsconfig.json: Configuration file for the TypeScript compiler.
- vitest.config.ts: Configuration file for Vitest, a testing framework.

The package provides a foundation for reusable scripts within the
frontend codebase.
The setupFiles option is removed from the vitest config.
This simplifies the configuration and removes unnecessary setup.
This commit introduces two new types: ProjectManifest and
DependencyNode. These types are used to represent the structure of
a project's manifest file (e.g., package.json) and the dependency
tree, respectively. These types will be used by the
generateDepTree script.
…tree generation script

This commit adds a README.md file to the generateDepTree script. The file describes the purpose of the script, the algorithm it uses, and some questions that need to be answered.
Adds unit tests for the `getManifest` function to ensure that it
correctly reads and parses the `package.json` file. This increases
confidence in the function's reliability and prevents regressions.
… tree

This commit introduces the `getDependencyTree` function, which constructs a dependency tree based on a project manifest and a collection of local packages. It recursively resolves dependencies, creating a nested structure that represents the project's dependency graph. The function utilizes `fp-ts` for functional data manipulation, enhancing code clarity and maintainability.
…manifests

This commit introduces a new module, `getLocalPackages`, which is responsible for retrieving the manifests of local packages within a specified directory. It exports two functions: `getManifest`, which retrieves the manifest for a single package, and `getManifests`, which retrieves the manifests for all packages in a directory. The module uses `node:fs` to read the `package.json` files and `fp-ts` for functional programming constructs. This module will be used to generate a dependency tree of local packages.
This adds a new script that generates a dependency tree for a
specified package. It uses the `getLocalPackages` and
`getDependencyTree` functions to get the manifests and generate the
tree, respectively. The script then prints the JSON string
representation of the dependency tree to the console.
…tManifests

The function `getLocalPackages` was renamed to `getManifests` to better
reflect its purpose, which is to retrieve multiple manifests. The import
statements and tests were updated to reflect this change.
The if/else statement was simplified to improve readability.
The `let dependencies` declaration was changed to `const dependencies`
because it is not reassigned.
The `localPackages[name]` expression can be undefined, but the
`getDependencyTree` function expects a non-nullable value. Adding a
non-null assertion ensures that the function receives the expected type
and prevents potential runtime errors.
The tsconfig.json file has been updated to be compatible with Node 22.
This includes:
- Setting the target to es2022
- Setting the module to nodenext
- Setting the moduleResolution to node
- Adding allowSyntheticDefaultImports and esModuleInterop
- Enabling strict mode and related options
- Adding resolveJsonModule
- Setting declaration to true
- Setting outDir and rootDir
- Adding types: ["node"]
- Adding include and exclude patterns
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 13, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

ktun95 added 16 commits June 13, 2025 11:24
This change introduces the functionality to output the dependency graph to a JSON file. The dependency graph is generated using the `getDependencyTree` function, and then written to a file named `dependency-graph.json` in the root directory. This allows for easier analysis and visualization of the project's dependencies.
…ode review

The README is updated to include a more detailed algorithm for
generating the dependency tree, a list of open questions, and a code
review section with strengths and issues to address. This provides
better documentation and guidance for future development.
This commit introduces a new package called
`generate-dependency-graph`. This package contains scripts
for generating a dependency graph of the frontendx
packages. The package includes the following files:

- `README.md`: A readme file for the package.
- `package.json`: The package.json file for the package.
- `src/generateDepTree/README.md`: A readme file for the
  `generateDepTree` module.
- `src/generateDepTree/__tests__/getLocalPackages.test.ts`:
  A test file for the `getLocalPackages` module.
- `src/generateDepTree/getDependencyTree.ts`: A module for
  generating the dependency tree.
- `src/generateDepTree/getLocalPackages.ts`: A module for
  getting the local packages.
- `src/generateDepTree/index.ts`: The main entry point for
  the `generateDepTree` module.
- `src/generateDepTree/types.ts`: A module for defining the
  types used in the `generateDepTree` module.
- `tsconfig.json`: The tsconfig.json file for the package.
- `vitest.config.ts`: The vitest.config.ts file for the
  package.

The purpose of this package is to provide a way to generate
a dependency graph of the frontendx packages. This can be
used to visualize the dependencies between the packages and
to identify potential problems.
…raph

This commit introduces a new package, `generate-dependency-graph`,
which is responsible for generating a dependency graph of the
project. The package includes the following files:

- `README.md`: Provides an overview of the package and its
  functionality.
- `src/README.md`: Contains detailed information about the
  package's implementation, including the algorithm used to
  generate the dependency graph.
- `src/__tests__/getLocalPackages.test.ts`: Contains unit tests
  for the `getLocalPackages` module.
- `src/getDependencyTree.ts`: Implements the logic for
  generating the dependency tree.
- `src/getLocalPackages.ts`: Provides functions for retrieving
  local package manifests.
- `src/index.ts`: The main entry point of the package, which
  orchestrates the dependency graph generation process.
- `src/types.ts`: Defines the types used throughout the package.

The package uses `fp-ts` for functional programming patterns and
generates a JSON representation of the dependency tree. The
generated graph includes all immediate external NPM dependencies
and local frontendx packages (`@dictybase/*`) and their
subtrees.

This new package will help in visualizing and understanding the
dependencies between different parts of the project, which can
aid in tasks such as refactoring, dependency management, and
identifying potential circular dependencies.
The README.md file was removed because it was outdated and no
longer relevant to the current state of the package. The information
contained within the file was either obsolete or already documented
elsewhere. Removing the file cleans up the project directory and
avoids potential confusion.
This commit introduces the TreeNode and PackageNode classes, which
are fundamental building blocks for representing the dependency graph.
TreeNode provides the basic tree structure, while PackageNode extends
it to hold package-specific information like name and version.
These classes will be used to construct and traverse the dependency
graph.
This change adds the commander package as a dependency.
The commander package is used to parse command line arguments.
This updates the yarn.lock file to reflect changes in dependencies.
This commit introduces the `ProjectNode` class, which extends the
`TreeNode` class. It represents a project node in a dependency graph.
It contains the project's name, version, and parent node. It also
includes methods to get the parent and add children.
…lass to implement ITreeNode interface

The PackageNode class was removed as it was not necessary and the TreeNode class was updated to implement the ITreeNode interface. This simplifies the code and makes it more maintainable. The parent type was changed to TreeNode and children type to ITreeNode to improve type safety and allow for more flexibility in the future.
…n to generate dependency tree

This commit introduces a new function, `getDependencyTree2`, which generates a dependency tree based on a project manifest and a record of local packages. It recursively builds the tree, creating `ProjectNode` instances for each dependency. If a dependency is found in the local packages, it recursively calls `getDependencyTree2` to build the subtree for that dependency. Otherwise, it creates a leaf node for the external dependency. The function utilizes `fp-ts` for functional programming constructs like `pipe`, `RmapWithIndex`, and `Rhas`.
…ph as JSON

This commit introduces the `renderJSON` function, which will be responsible for rendering the dependency graph in JSON format. This is a new feature that will allow users to export the dependency graph in a standard format for further analysis or visualization. The function is currently empty and will be implemented in a subsequent commit.
…e readability

The imports `Ord as SOrd` from `fp-ts/string`, `collect as Rcollect` and `DependencyNode` from `./types` were not being used in the file. Removing them improves code readability by removing unnecessary code.
…d CLI entrypoint

This commit introduces a new module, `analyzeDependencies`, which encapsulates the logic for analyzing dependencies within a project. It also creates a CLI entrypoint using Commander.js to allow users to specify the app directory to analyze. The `analyzeDependencies` module is responsible for:

- Locating the app's manifest file.
- Identifying the packages directory.
- Retrieving manifest files for all packages within the packages directory.
- Constructing a dependency tree based on the app and package manifests.

The CLI entrypoint simplifies the process of running the dependency analysis by providing a command-line interface.
Adds a "generate" script to the package.json file for the
generate-dependency-graph package. This script allows users to
easily generate the dependency graph by running the command
"npm run generate".

The new script simplifies the process of generating the dependency
graph, making it more convenient for developers.
…ncy graph to JSON format

The toJSON plugin converts the dependency graph to a JSON format.
The renderJSON file was removed because it was not used.
ktun95 added 2 commits June 19, 2025 19:52
This commit introduces a new tool for generating dependency graphs
for monorepo applications. The tool uses the commander library to
define a command-line interface, the inquirer library to prompt the
user for a plugin, and the fp-ts library for functional programming.
The tool analyzes the dependencies of a given application and outputs
a dependency graph in a format specified by the chosen plugin.
Currently, the tool supports JSON and Graphviz output formats.

The tool consists of the following modules:
- ProjectNode: Represents a node in the dependency graph.
- analyzeDependencies: Analyzes the dependencies of a given application.
- plugins: Defines the available plugins.
- toJSON: Converts the dependency graph to JSON format.
- toGraphviz: Converts the dependency graph to Graphviz format.

The tool can be used as follows:
```
node build/src/index.js <path>
```
where `<path>` is the path to the application directory to analyze.

The tool adds the following dependencies:
- @inquirer/prompts
- ts-graphviz

The tool now generates dependency graphs, allowing developers to
visualize and understand the relationships between different parts
of their applications.
…rity

This commit renames the variable `chosenPlugin` to `chosen` to
improve code readability and clarity. The variable represents the
plugin chosen by the user, and the new name is more concise and
easier to understand.
ktun95 added 3 commits June 20, 2025 10:23
…dency graphs in Mermaid format

This commit introduces a new plugin that allows users to generate dependency graphs in Mermaid format. Mermaid is a popular diagramming and charting tool that uses a simple, text-based syntax. The new plugin provides an alternative output format that can be easily integrated into documentation, wikis, and other platforms that support Mermaid.
The plugin traverses the project dependency tree, creating nodes and edges for each project and its dependencies. The resulting Mermaid code can then be rendered into a visual diagram.
…non-local dependencies

This change introduces a new `--local-only` flag to the
`generate-dependency-graph` package. When this flag is used, the
dependency tree will only include local dependencies (i.e., those
found within the `localPackages` record). This is achieved by
filtering the dependencies object before generating the dependency
tree. A global variable `localOnly` is used to pass the flag value
to the `getDependencyTree2` function.
This commit introduces functionality to identify and remove
redundant dependencies within a project's dependency graph.

- Adds `removeRedundantDependencies` function to remove redundant
  dependencies from the dependency tree.
- Adds `findRedundantDependencies` function to identify redundant
  dependencies without removing them.
- Adds `getAllDescendantDependencies` method to `ProjectNode` class
  to get all dependencies of a node's children.
- Adds a test case for redundant dependency removal.
- Renames the "generate" script in `package.json` to
  "dependency-tree" for clarity.
- Adds a new command "list-redundant" to the CLI to list
  redundant dependencies.

The changes enable users to analyze and optimize their project's
dependencies by removing unnecessary duplicates, leading to smaller
bundle sizes and improved performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant