Giter Site home page Giter Site logo

dependents's Issues

New Feature: Copy dependents paths to clipboard

Often times someone will ask in a chat: "who uses this module?". Can use dependents but need to find a way of copying those filenames and pasting them.

  • Backdoor is to use the ST console to get those lines
  • Should have a menu option of copying dependents to clipboard (show status of finding dependents then show status of the results being copied to the clipboard)

Click on identifier to jump to dependency

You see an instance of a module used within the code and want to jump to it immediately

instead of tracing the variable as follows:

  • Look up where the variable was created
  • Look up the class instantiated
  • Find the class within the factory function (for AMD)
  • Find the path of the class (using position or name matching)

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Auto update node-dependents as a precondition

Run npm update -g dependents in the shell.

Although, this may need to be altered due to Python sucking balls at executing anything in usr/local/bin by default.

Will likely have to run /usr/local/bin/npm update -g dependents

Add a right click menu

Right click menu on the entire file should now have an option to "Find dependents".

Possibly have multiple options:

  • Find Dependents for File
  • Find Dependents for Selection (based on where your mouse is)

Jump to the module under your cursor

Not sure which key binding to use.

Implementation:

  • Get text under cursor
  • Need a root supplied in the key binding configuration
  • Open the file: root + string under cursor
  • If file isn't there, show a dialog warning

Windows support

  1. Needs an easy way of invoking a globally installed npm module or supplying the local install path for windows machines where /usr/local/bin is currently hardcoded
    • Python can't find these executables (for OSX at least) using shutils
  2. Add default keymaps and mousemaps

Global install of node-dependents

Will then need to fall back to local install if a global is not found

Can use which dependents to check for global install and then fall back to running the local node_modules/node-dependents/bin/dependents.js if not found.

Pros:

  • Avoids dependents being placed in your codebase (unfortunately syncs over to a VM if you're using a watcher)

Cons:

  • Makes auto-updating the node tool harder since you may need to sudo npm install dependents
    • Actually not a problem, since npm update -g dependents will also update it if it's globally installed

Pubsub features

  • Find all listeners of an event
  • Find all triggers of an event
  • Open all files that care about an event

Different codebases have different roots

Specifying the root in the keymap implies that all of your projects have the same root name.

Solutions:

  1. Automatically deduce the root

Each time the command is triggered, traverse up the directory tree to see the top-most directory that doesn't contain a .js file.

  • Could do this once and save the result in a file somewhere? Not in the current codebase
    • Look at how package manager caches data
  1. Use a .dependentsrc file in the root directory.
  2. Ask users to add root and config .editorconfig

"substring not found" error

Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 526, in run_ return self.run() File "/Users/justinpagano/Library/Application Support/Sublime Text 3/Packages/Dependents/JumpToDependency.py", line 35, in run self.view.pathWithinRoot = self.view.filename[self.view.filename.index(self.window.root) + len(self.window.root):] ValueError: substring not found

Started getting this suddenly.

Jump to driver script

Often, you're in a module and want to know which app(s), not just containing modules, use it.

Will need to add support for this to node-dependents.

  • Could programmatically search for all driver scripts, generate dependency trees for each, then check which sets the current modules is a member of.
    • Optimization: support a requirejs build script that has a list of modules and uses mrjoelkemp/node-get-modules-to-build to avoid computing the set of driver scripts each time.
    • Optimization: Make sure dependency tree generation uses a memoized traversal to speed up the process of generating trees for each driver script.

Test fixtures

Create a test directory with sample apps for manual testing.

Apps:

  • AMD
  • CommonJS
  • ES6
  • SASS

Must include:

  • Relative pathing
  • Aliased paths

Perf ideas

Sample stats

  • 1097 files
  • 2152.46 ms to find the dependencies for all
  • 258ms to traverse all files using node-dir

Server idea

Create a long-running server that does the following:

  1. builds the dependent matrix on load
  2. On file change, compute dependencies, remove/add the file as a dependent of the other files.
    • Slow in that you have to find out who you're a dependent of. Unless we keep another hash of the inverse relationship (file -> list of files the file depends on).

This way, it's O(1) to modify the dependent matrix.

Pros:

  • Super fast

Cons:

  • Server needs to always run otherwise the sublime plugin is dead (possibly use monit or something to keep it alive (or restart)

File system matrix storage?

Possibly pickle?

Still need on save hook to recompute the matrix and flush to disk.

Stream the dependents as we compute them

Need a way of refreshing the quick panel with the new items

Extend this idea to sass

Show stylesheets that import/depend-on the current partial

  • Good for gauging the severity of your changes
  • Need a new node tool that parses SASS' ast but is similar to node-dependents

Jump to a partial using the same behavior as defined for JS files

Jump to SASS Partial

Should just need a "sass_config" that defines the root of the sass codebase. Jumping around should have the same logic as JS

Strange 'substring' error

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 524, in run_
    return self.run(**args)
  File "Dependents in /Users/jokemp/Library/Application Support/Sublime Text 3/Installed Packages/Dependents.sublime-package", line 21, in run
  File "Dependents in /Users/jokemp/Library/Application Support/Sublime Text 3/Installed Packages/Dependents.sublime-package", line 46, in __init__
ValueError: substring not found

in test/sync.js trying to jump to dependency

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.