1.0.4 • Published 2 years ago

file-dependency-analyzer v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

File dependency analyzer

Maintaining a project is not easy, especially large ones. To help, this tool is used to detect and optionally cleanup not dependent files.

You can analyze and cleanup any files you want (svg, js, etc). Just provide configuration and you are ready to go. Tool is fully customizable, you can specify folders you want to analyze files in, or exclude folders from analyzing.

Installation


 npm install -D file-dependency-analyzer

Usage


To run a script you need npx (npm is not currently supported)

// package.json

"scripts": {
  "analyze": npx file-dependency-analyzer ./path-to-config-file.json
}

Config

Default ignore patterns (analyzing will be excluded in below folders)

[
    'node_modules',
    'git',
    'vscode',
    'idea',
    'package.json',
    'package-lock.json',
    'README.md',
    'dist',
]

You can add specific globalIgnorePatterns in config


PropertyTypeDefaultDescription
globalIgnorePatternsArray[]List of all folders/paths you want exclude from analyzing
extensionsObject{}Object of extensions with specific configuration

Extensions

Is a key value object with specific configuration


PropertyTypeDefaultDescription
analyzeFromArray[]List of folders where files to analyze are located
analyzeInArray[]List of folders you want to analyze files
ignorePatternsArray[]List of folders you exclude from analyzing
modeStringanalyzeanalyze or cleanup (analyze and remove unused files)

If analyzeFrom, analyzeIn are empty or not defined, files will be analyzed for all project files.

Config example


{
  "globalIgnorePatterns": [".docker-cache"],
  "extensions": {
    "svg": {
      "analyzeFrom": [], <- it will search for all svg files throughout the project
      "analyzeIn": ["/components"],
      "ignorePatterns": ["/configs"],
      "mode": "cleanup",
    },
    "js": {
      "analyzeFrom": ["/configs", "/assets"],
      "analyzeIn": [], <- files will be analyzed throughout the project
      "ignorePatterns": [],
      "mode": "analyze"
    }
  }
}

License


Copyright (c) 2022 Rafal Poreba. Licensed under the MIT license.