### Install Project Dependencies - NPM SH Source: https://github.com/pahen/madge/blob/master/README.md Installs the project dependencies listed in the package.json file using npm. ```sh npm install ``` -------------------------------- ### Show Modules Depending on a Module - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Shows which modules depend on a given module ('wheels.js' in this example) starting from a specified entry point using the madge command-line tool. ```sh madge --depends wheels.js path/src/app.js ``` -------------------------------- ### Install Graphviz via Homebrew - SH Source: https://github.com/pahen/madge/blob/master/README.md Installs Graphviz using the Homebrew package manager on macOS or Linux, potentially with GTS support if installed previously. ```sh brew install graphviz ``` -------------------------------- ### Install GTS via Homebrew - SH Source: https://github.com/pahen/madge/blob/master/README.md Installs the GNU Triangulated Surface library (GTS) using the Homebrew package manager, often required for Graphviz triangulation features. ```sh brew install gts ``` -------------------------------- ### Configure Madge via .madgerc (JSON) Source: https://github.com/pahen/madge/blob/master/README.md Example of configuring Madge using a .madgerc file. This JSON file allows setting various options like font size and Graphviz parameters to customize the graph output. ```json { "fontSize": "10px", "graphVizOptions": { "G": { "rankdir": "LR" } } } ``` -------------------------------- ### Configure Madge via package.json (JSON) Source: https://github.com/pahen/madge/blob/master/README.md Example of configuring Madge directly within the package.json file under the "madge" key. This provides an alternative way to set options like font size and Graphviz parameters alongside project metadata. ```json { "name": "foo", "version": "0.0.1", ... "madge": { "fontSize": "10px", "graphVizOptions": { "G": { "rankdir": "LR" } } } } ``` -------------------------------- ### Enable Debugging Output - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Runs madge with the --debug option to enable detailed debugging output for troubleshooting issues, starting analysis from a specified file. ```sh madge --debug path/src/app.js ``` -------------------------------- ### Find Circular Dependencies - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Finds and lists circular dependencies starting from a specified file using the madge command-line tool. ```sh madge --circular path/src/app.js ``` -------------------------------- ### Exclude Modules from Analysis - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Excludes modules matching a given regular expression pattern ('^(foo|bar)\.js$' in this example) from the dependency analysis starting from a specified file using the madge command-line tool. ```sh madge --exclude '^(foo|bar)\.js$' path/src/app.js ``` -------------------------------- ### Get Dependency Graph as SVG Buffer (JavaScript) Source: https://github.com/pahen/madge/blob/master/README.md Uses the .svg() method to retrieve the dependency graph as an SVG XML string within a Buffer. Returns a Promise that resolves with the Buffer containing the SVG data. The example converts the Buffer to a string for logging. ```javascript const madge = require('madge'); madge('path/to/app.js') .then((res) => res.svg()) .then((output) => { console.log(output.toString()); }); ``` -------------------------------- ### Save Dependency Graph as DOT File - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Saves the dependency graph as a DOT language file ('graph.gv') for further processing, starting from a specified file using the madge command-line tool. Requires Graphviz. ```sh madge --dot path/src/app.js > graph.gv ``` -------------------------------- ### Save Dependency Graph as SVG - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Saves the dependency graph as an SVG image file ('graph.svg') starting from a specified file using the madge command-line tool. Requires Graphviz. ```sh madge --image graph.svg path/src/app.js ``` -------------------------------- ### Save Circular Dependency Graph as SVG - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Finds circular dependencies and saves the graph containing only these dependencies as an SVG image file ('graph.svg') starting from a specified file using the madge command-line tool. Requires Graphviz. ```sh madge --circular --image graph.svg path/src/app.js ``` -------------------------------- ### Run Project Tests - NPM SH Source: https://github.com/pahen/madge/blob/master/README.md Runs the project's test suite as defined in the package.json file using npm. ```sh npm test ``` -------------------------------- ### List Dependencies from Multiple Files - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Lists the dependencies from multiple specified files using the madge command-line tool. ```sh madge path/src/foo.js path/src/bar.js ``` -------------------------------- ### List Dependencies from Directory - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Lists dependencies from all *.js files found in a specified directory using the madge command-line tool. ```sh madge path/src ``` -------------------------------- ### Create Project Release - NPM SH Source: https://github.com/pahen/madge/blob/master/README.md Executes the 'release' script defined in the package.json file using npm, typically used for publishing new versions. ```sh npm run release ``` -------------------------------- ### List Dependencies from Multiple Directories - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Lists dependencies from all *.js files found in multiple specified directories using the madge command-line tool. ```sh madge path/src/foo path/src/bar ``` -------------------------------- ### List Dependencies from Single File - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Lists the dependencies of a single specified file using the madge command-line tool. ```sh madge path/src/app.js ``` -------------------------------- ### List Dependencies with Specific Extensions - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Lists dependencies from files with specified extensions (js, jsx) found in a directory using the madge command-line tool. ```sh madge --extensions js,jsx path/src ``` -------------------------------- ### Show Modules with No Dependencies - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Shows modules that do not have any outgoing dependencies within the specified directory using the madge command-line tool. ```sh madge --leaves path/src/ ``` -------------------------------- ### Transform Dependency Tree via Pipe - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Outputs the dependency tree as JSON, pipes it through a transformation command (uppercasing paths), and then reads the transformed tree back into madge via standard input. ```sh madge --json path/src/app.js | tr '[a-z]' '[A-Z]' | madge --stdin ``` -------------------------------- ### Uninstall Graphviz via Homebrew - SH Source: https://github.com/pahen/madge/blob/master/README.md Uninstalls Graphviz using the Homebrew package manager on macOS or Linux. ```sh brew uninstall graphviz ``` -------------------------------- ### Write Dependency Graph Image (JavaScript) Source: https://github.com/pahen/madge/blob/master/README.md Uses the .image() method to save the dependency graph to a specified image path. The output format is determined by the file extension. Returns a Promise that resolves with the full path to the saved image. ```javascript const madge = require('madge'); madge('path/to/app.js') .then((res) => res.image('path/to/image.svg')) .then((writtenImagePath) => { console.log('Image written to ' + writtenImagePath); }); ``` -------------------------------- ### Show Orphan Modules - Madge SH Source: https://github.com/pahen/madge/blob/master/README.md Shows modules that are not depended upon by any other module within the specified directory using the madge command-line tool. ```sh madge --orphans path/src/ ``` -------------------------------- ### Configure Mixed TypeScript CommonJS Imports - Madge JSON Source: https://github.com/pahen/madge/blob/master/README.md Madge configuration snippet to enable detection of both TypeScript and CommonJS import syntaxes within the same file for TypeScript modules. ```json { "detectiveOptions": { "ts": { "mixedImports": true } } } ``` -------------------------------- ### Configure Mixed ES6 CommonJS Imports - Madge JSON Source: https://github.com/pahen/madge/blob/master/README.md Madge configuration snippet to enable detection of both ES6 and CommonJS import syntaxes within the same file for ES6 modules. ```json { "detectiveOptions": { "es6": { "mixedImports": true } } } ``` -------------------------------- ### Configure TSConfig for Mixed JS/TS Imports - TypeScript JSON Source: https://github.com/pahen/madge/blob/master/README.md TypeScript compiler options configuration snippet to allow mixing JavaScript and TypeScript imports by enabling CommonJS module output and allowing JavaScript files. ```json { "compilerOptions": { "module": "commonjs", "allowJs": true } } ``` -------------------------------- ### Configure Skipping Dynamic Imports - Madge JSON Source: https://github.com/pahen/madge/blob/master/README.md Madge configuration snippet to ignore dynamic 'import()' statements when analyzing TypeScript and TSX modules. ```json { "detectiveOptions": { "ts": { "skipAsyncImports": true }, "tsx": { "skipAsyncImports": true } } } ``` -------------------------------- ### Configure Skipping TypeScript Type Imports - Madge JSON Source: https://github.com/pahen/madge/blob/master/README.md Madge configuration snippet to ignore 'import' statements used within type annotations when analyzing TypeScript modules. ```json { "detectiveOptions": { "ts": { "skipTypeImports": true } } } ``` -------------------------------- ### Configure Skipping ES6 Flow Type Imports - Madge JSON Source: https://github.com/pahen/madge/blob/master/README.md Madge configuration snippet to ignore 'import type' statements when analyzing ES6 modules with Flow type annotations. ```json { "detectiveOptions": { "es6": { "skipTypeImports": true } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.