GithubHelp home page GithubHelp logo

deprank's Introduction

Deprank

Deprank uses the PageRank algorithm to find the most important files in your JavaScript or TypeScript codebase. It uses dependency-cruiser to build a dependency graph of your source files, then ranks those dependencies based on their importance. We define importance as those files which are directly or indirectly depended upon the most by other files in the codebase.

Deprank is particularly useful when converting an existing JavaScript codebase to TypeScript. Performing the conversion in strict PageRank order can dramatically increase type-precision, reduce the need for any and minimizes the amount of rework that is usually inherent in converting large codebases.

Usage

Rank all files in the src directory:

npx deprank ./src

Rank all .js and .jsx files in the src and test directories:

npx deprank --ext=".js,.jsx" ./src ./test

Example

npx deprank ./fixtures
| Filename               | Lines | Dependents | PageRank |
----------------------------------------------------------
| fixtures/core.js       | 3     | 1          | 0.284098 |
| fixtures/utils.js      | 4     | 3          | 0.268437 |
| fixtures/user/user.js  | 4     | 1          | 0.132253 |
| fixtures/todo.js       | 6     | 1          | 0.089796 |
| fixtures/user/index.js | 1     | 1          | 0.089796 |
| fixtures/concepts.js   | 4     | 1          | 0.079694 |
| fixtures/index.js      | 4     | 0          | 0.055926 |

Building Locally

  1. Clone this repository: git clone [email protected]:codemix/deprank.git
  2. Get yarn.
  3. Navigate into the project folder: cd deprank/.
  4. Run yarn install && yarn build.
  5. Run ./bin/deprank --help

TypeScript Conversion

To help convert your codebase to TypeScript whilst minimizing the amount of effort required, we suggest converting files in deprank --deps-first order. This option lifts the files that are depended upon by the most important files in the codebase to the top of the list. By tackling each file in order we help ensure that type errors are solved at their origin, rather than their point of use. This can reduce the number of type errors much more quickly than the more typical, ad-hoc order that such conversions usually take, and it helps TypeScript use inference which reduces the amount of manual typing required. It's not uncommon to see hundreds or thousands of type errors disappear just by fixing a few key files.

The following command will find all .js or .jsx files in a src folder, and sort them in dependency-first order.

npx deprank --ext=".js,.jsx" --deps-first ./src

Author

deprank was written by Charles Pick at Codemix

deprank's People

Contributors

dan-blank avatar phpnode 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deprank's Issues

Can not resolve alias paths

as alias setting in tsconfig.json

"paths": {
"@/": [
"./src/
"
]
}

it reports an error:
no such file or directory, open '@/pages/form/form.js'

Support for typescript

Is typescript intended to be supported? deprank is only printing out the header and doesn't seem to find any typescript files.

Here's the deprank command that I am running:

npx deprank js/ --ext ".ts,.tsx"
| Filename | Lines | Dependents | PageRank |
--------------------------------------------

But the following dependency cruiser command works fine and creates a svg with the files that I expect:

depcruise --include-only "^js" --output-type dot js | dot -T svg > dependencygraph.svg

Does deprank support Deno?

This is a great library, I was curious if Deno is supported as a JS/TS runtime or if there might be plans to do so?

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.