module-analyzr
*module-analyzr* is a simple CLI and toolbox to analyze the usage of a package.
Last updated a year ago by taneba .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install module-analyzr 
SYNC missed versions from official npm registry.

module-analyzr

module-analyzr is a simple CLI and toolbox to analyze the usage of a package.

input:

import 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";

output:

{
  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 <moduleName> <path> [options]

    moduleName    A name of module.
    path          File path or directory path or glob pattern

  Options:
    -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

const analyzr = require('module-analyzr')
const usageInfo = analyzr('react', 'src/**/*.js')

output JSON

Parameter Description
importModules Array of {moduleName: <string>, usageAmount: <number>} 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

Current Tags

  • 1.2.2                                ...           latest (a year ago)

5 Versions

  • 1.2.2                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (6)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |