Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taneba/module-analyzr
Analyze the usage of a module.
https://github.com/taneba/module-analyzr
Last synced: 2 months ago
JSON representation
Analyze the usage of a module.
- Host: GitHub
- URL: https://github.com/taneba/module-analyzr
- Owner: taneba
- License: mit
- Created: 2018-06-01T04:57:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-25T23:18:30.000Z (almost 2 years ago)
- Last Synced: 2024-10-18T06:28:47.450Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 709 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# module-analyzr
*module-analyzr* is a simple CLI and toolbox to analyze the usage of certain npm package.Let's say you have code like this:
```js
// index.jsimport defaultExport from "test-module";
import * as name from "test-module";
import { export as alias } from "test-module";import { export1, export2 } from "test-module";
import { export1 } from "test-module";...
```And you can analyze the usage of "test-module"
```bash
module-analyzr test-module index.js=> {
importedModules: [
{ moduleName: 'export', usageAmount: 1 },
{ moduleName: 'export1', usageAmount: 2 },
{ moduleName: 'export2', usageAmount: 1 }
],
importedDefault: 1,
importedWithNameSpace: 1
}
```# install
```
npm install -g module-analyzr
```# CLI
After installing, you can use `module-analyzr` command in any directory in your system:```
Usage: module-analyzr [options]moduleName A name of module.
path File path or directory path or glob patternOptions:
-i File path or directory path or glob pattern to ignore. Default: [node_modules]
--type=typescript passes typescript plugin to the parser
--type=flow passes flow plugin to the parser# example and output
module-analyzr react src/**/*.js{ importedModules:
[ { moduleName: 'Component', usageAmount: 10 },
{ moduleName: 'Node', usageAmount: 2 },
{ moduleName: 'Fragment', usageAmount: 1 } ],
importedDefault: 20,
importedWithNameSpace: 23 }
```# API
```js
const analyzr = require('module-analyzr')
const usageInfo = analyzr('react', 'src/**/*.js')
```# output JSON
| Parameter | Description |
| -------------- | --------------- |
| importModules | Array of `{moduleName: , usageAmount: }` which shows usage count of named export. |
| importedDefault | Number of usage count of default exports |
| importedWithNameSpace | Number of usage count of named export, but all of exports with `*` (eg. `import * as Module from 'module'`). |# Motivation
`module-analyzr` is simple tool to analyze usage of a module in a file or directory(likely project). It is helpful for module's maintainer to grasp how their module used in projects. Also, it is helpful for application engineer when upgrade the module or remove the module.
In my case, as a creator of UI Library, it was nervous to add a breaking change. That is why I created `module-analyzr`.# License
MIT