Pulling feat/dep-tree-gen into develop#1082
Open
github-actions[bot] wants to merge 33 commits into
Open
Conversation
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
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
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.
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.