Code Monkey home page Code Monkey logo

howfat's Introduction

howfat

Tests NPM version

Shows how fat is a package together with its dependencies

howfat

Usage

Simple

npx howfat mkdirp

Specified version or version range:

npx howfat mkdirp@^0.5.0

Local packages

cd my-project
npx howfat

npx howfat ../my-other-package

Git or github

npx howfat https://github.com/substack/node-mkdirp

npx howfat ssh://[email protected]:substack/node-mkdirp.git#0.3.4

Different reporters

Just show a simple stats:

$ npx howfat -r simple [email protected]
Dependencies: 1
Size: 41.49kb
Files: 37

as a table:

$ npx howfat -r table [email protected]
[email protected] (1 dep, 41.49kb, 37 files)
╭────────────────┬──────────────┬─────────┬───────╮
│ Name           │ Dependencies │    Size │ Files │
├────────────────┼──────────────┼─────────┼───────┤
│ [email protected] │            0 │ 20.78kb │    14 │
╰────────────────┴──────────────┴─────────┴───────╯

as a json:

$ npx howfat -r json [email protected] --space 2

{
  "package": "[email protected]",
  "dependencyCount": 1,
  "fileCount": 37,
  "unpackedSize": 42486,
  "duplicate": false,
  "error": false,
  "unmet": false,
  "author": "{name:James Halliday,email:[email protected],url:http://substack.net}",
  "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)",
  "description": "Recursively mkdir, like `mkdir -p`",
  "license": "MIT",
  "maintainers": "[{name:isaacs,email:[email protected]}]",
  "ownStats": {
    "dependencyCount": 1,
    "fileCount": 23,
    "unpackedSize": 21212
  },
  "children": [
    {
      "package": "[email protected]",
      "dependencyCount": 0,
      "fileCount": 14,
      "unpackedSize": 21274,
      "duplicate": false,
      "error": false,
      "unmet": false,
      "author": "{name:James Halliday,email:[email protected],url:http://substack.net}",
      "deprecated": "",
      "description": "parse argument options",
      "license": "MIT",
      "maintainers": "[{email:[email protected],name:ljharb},{email:[email protected],name:emilbayes}]",
      "ownStats": {
        "dependencyCount": 1,
        "fileCount": 14,
        "unpackedSize": 21274
      },
      "children": []
    }
  ]
}

Other options

  -d, --dev-dependencies BOOLEAN   Fetch dev dependencies, default false
  -p, --peer-dependencies BOOLEAN  Fetch peer dependencies, default false
  
  -r, --reporter STRING            'json', 'simple', 'table', 'tree', default tree
      --fields STRING              Displayed fields separated by a comma:
                                   dependencies,size,files,license,
                                   author,description,maintainers,deprec,
                                   deprecated,node,os,platform
      --sort STRING                Sort field. Add minus sign for 
                                   desc order, like size-. Default to 'name'
      --space NUMBER               Use spaces in json output, default null
                                   
  -v, --verbose BOOLEAN            Show additional logs
      --no-colors BOOLEAN          Prevent color output
      --no-human-readable BOOLEAN  Show size in bytes
      
  --registry-url STRING            Default to https://registry.npmjs.org/
                            
  --http                           Node.js RequestOptions, like:
  --http.timeout NUMBER            Request timeout in ms, default 10000
  --http.connection-limit NUMBER   Max simultaneous connections, default 10
  --http.retry-count NUMBER        Try to fetch again of failure, default 5
  --http.proxy STRING              A proxy server url
  
  --show-config                    Show the current configuration
  --version                        Show howfat version
  --help                           Show this help

Accuracy

Different package managers use different dependency resolution algorithms. Even different versions of the same manager will resolve different dependency tree. So, this package tries to calculate stats similar to npm, but keep in mind that it provides approximate results.

Why should I care about my package size?

  • Small package is installed much faster on CI
  • Runs faster via npx
  • Less dependencies = less troubles

howfat's People

Contributors

chris2011 avatar dependabot[bot] avatar megahertz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

howfat's Issues

add field sizeOnDisk?

It would be nice to have another field that shows the size on disk of a package in node_modules as there can be quite big differences:

$ howfat picocolors
[email protected] (5.52kb, 7 files, ©ISC)
$ du -sh node_modules/picocolors
28K	node_modules/picocolors

https://www.npmjs.com/package/picocolors shows 5.66kB for 'Unpacked Size' - I don't know what data howfat uses.

This is of course only possible if the package is installed locally.
The size on disk could be shown by default when running

  • howfat . and ./node_modules exists, or
  • howfat x and ./node_modules/x exists.

Private registry authentication or package ignore list

We are using an internal registry, that requires authentication.
Since howfat does not reuse npmrc configuration for authentication and does not provide parameters for that neither, it is not possible to use it for projects that depends on internal libraries.

Another approach could be to provide a --ignore parameter where we could set a list of internal packages to ignore.

can get license information

I think, this tool also help us to extract license information on dependent libraries.Please provide option to extract license information

listener argument must be a function

when i try to run the below command i get the error "listener argument must be a function"
npx howfat jasmine
or
howfat jasmine

please guide me how to resolve this

timeouts

I am getting lots of

# npx howfat
Warning: Timeout error when requesting http://registry.npmjs.org/<package>
Warning: Timeout error when requesting http://registry.npmjs.org/<package>
Warning: Timeout error when requesting http://registry.npmjs.org/<package>
Warning: Timeout error when requesting http://registry.npmjs.org/<package>
Warning: Timeout error when requesting http://registry.npmjs.org/<package>
Error: Timeout error when requesting http://registry.npmjs.org/<package>

When I restart I get to the next package.

feat: support pnpm workspaces

It would be great if howfat supports pnpm workspaces.

"dependencies": {
  "@example/core": "workspace:*"
},

Running howfat local inside a monorepo package using "workspace:*", currently throws an error.

Error: Unsupported URL Type "workspace:": workspace:*

Ignore missing packages

Sometimes packages are not on npm registry: local development, monrepos, etc.
It would be nice to get these ignored and not failing, maybe behind a flag: --ignoreMissing.
Although looking at the code it seems that pulling 404 all the way up to the high level can be non-trivial.

Error: Cannot read properties of undefined (reading 'toString')

this is my package.json

{
	"scripts": {
		"build": "webpack build"
	},
	"devDependencies": {
		"webpack": "^5.89.0",
		"webpack-cli": "^5.1.4"
	},
	"dependencies": {
		"@types/react": "^18.2.33",
		"@types/react-dom": "^18.2.14",
		"antd": "^5.10.2",
		"react": "^18.2.0",
		"react-dom": "^18.2.0"
	}
}

and i got such error

➜  barrel-file-test npx howfat --fields=module
Error: Cannot read properties of undefined (reading 'toString')
➜  barrel-file-test npx howfat -r --fields=module
Error: Cannot read properties of undefined (reading 'toString')
➜  barrel-file-test 

it works fine with this command npx howfat antd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.