Use PageRank to find the most important files in your codebase.

Overview

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

You might also like...

A superfast and easy to use knowledge base to help your customers get the info they need, when they need it most.

A superfast and easy to use knowledge base to help your customers get the info they need, when they need it most.

A superfast and easy to use knowledge base to help your customers get the info they need, when they need it most. helpkb is an open-source Next.js (A

Dec 5, 2022

Use XMind share to present your .xmind files on your blog or website.

XMind Embed Viewer Use XMind share to present your .xmind files on your blog or website. Demo Quick start Install As an npm module npm i xmind-embed-v

Dec 7, 2022

A plugin that can find the paths between two notes. Not sure who will want to use it...

Obsidian Path Finder Plugin Install BRAT Install Obsidian42-BRAT plugin. Click Add new beta plugin and fill in jerrywcy/obsidian-path-finder. Activate

Dec 31, 2022

Place your Bob-ombs so they surround opposing Bob-ombs. Captured Bob-ombs change color and join your team. The player uith the most Bob-ombs at the end is the Hinner.

Place your Bob-ombs so they surround opposing Bob-ombs. Captured Bob-ombs change color and join your team. The player uith the most Bob-ombs at the end is the Hinner.

Bob-omb Reverse with Arduino MKR 1010 Wifi 🐦 @cbarange & @j-peguet | 5th January 2022 Intro Docs MQTT with Arduino 👉 https://docs.arduino.cc/tutoria

Jan 13, 2022

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

Demo Profile Readme Generator The best profile readme generator you will find! About | Technologies | Requirements | Starting | Contributing 🎯 About

Jan 1, 2023

Add Your Skill & Find Your Developer Friend

Add Your Skill & Find Your Developer Friend! Want to contribute to this project? 📌 Tech Stack html css nextjs tailwind Contributing Pull requests are

Nov 17, 2022

Piplup: decompile Playdate Pulp .pdx files back to .json project files

Piplup: decompile Playdate Pulp .pdx files back to .json project files This doesn't work yet: I still need to: convert the graphics (.pdt files) back

Mar 25, 2022

🌸 A cli can automatically generate files from Excel files.

🌸 A cli can automatically generate files from Excel files.

unxlsx A cli can automatically generate files from Excel files. Why We often need to export some information from XLSX to generate our files, such as

Aug 22, 2022

JavaScript library for parsing Dirtywave M8 files, complete with a CLI for interacting with M8 files.

m8-js This repository contains a JavaScript library for parsing Dirtywave M8 files, as well as a CLI for interacting with M8 files. The hopes are not

Dec 17, 2022
Comments
  • Can not resolve alias paths

    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'

    opened by wrrwrr111 2
  • Support for typescript

    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
    
    opened by axelson 1
Owner
codemix
We help companies ship features, fix bugs and make teams even more productive with JavaScript.
codemix
Maintain your API development, documentation and experimentation all within your codebase.

dostman Maintain your API development, documentation and experimentation all within your codebase. This project is a new release! Feel free to contact

Ege Çavuşoğlu 16 Mar 11, 2022
Astrospeed is a performance monitor for your AstroJS codebase.

astroSpeed astroSpeed Performance monitor for Astro & Next.js web applications. Explore astrospeed.io » View Demo · Report Bug · Request Feature Table

OSLabs Beta 38 Dec 15, 2022
freeCodeCamp.org's open source codebase and curriculum. Learn to code for free.

freeCodeCamp.org's open-source codebase and curriculum freeCodeCamp.org is a friendly community where you can learn to code for free. It is run by a d

freeCodeCamp.org 359.2k Jan 7, 2023
4Web is a collection&creation of codebase, frameworks, libraries dedicated to web development 📦

?? You can also contribute to add / create your own collection in this repository Collection name Description ?? blinke

Raja Rakotonirina 5 Nov 14, 2022
4WEB is a collection & creation of codebase, frameworks, libraries and various resources dedicated to web development 📦🌐

?? Vous pouvez également contribuer à ajouter/créer votre propre collection dans ce référentiel ... Table des matières ?? Codebase ?? NPM packages ??

Raja Rakotonirina 5 Nov 14, 2022
Codú's open-source codebase. A space for coders.

Running the app $ npm install # development $ npm run dev Open http://localhost:3000 with your browser to see the result. You can start editing the p

Codú Community 18 Jan 2, 2023
A framewok for building efficient and scalable, cross-platform bots (WhatsApp, Discord, Telegram and more) in a single codebase

project... An over-engineered all-in-one bot framewok for building efficient and scalable bots. Yep that's not a typo u heard it right "scalable bots"

Shubham Badgujar 6 Dec 24, 2022
Find and fix dangling files and unused dependencies in your JavaScript projects.

unimported Find unused source files in javascript / typescript projects. While adding new code to our projects, we might forget to remove the old code

Stephan Meijer 1.6k Jan 4, 2023
✂️ Find unused files, dependencies and exports in your TypeScript project

✂️ Knip Knip scans your JavaScript and TypeScript projects for unused files, dependencies and exports: things that can be removed! Less code means bet

Lars Kappert 673 Jan 1, 2023
Find duplicate object values of your JSON files (VSCode Extension)

JASON Lint VS Code Extension Make your life easier, use this extension to defeat the horror of duplicate values from your JSON files. Very useful when

Leonardo Pizzoquero 3 Oct 20, 2022