npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rebelle

v1.0.0

Published

Start a repl with the current module, dependencies, and arbitrary files loaded

Downloads

2

Readme

Rebelle

A small tool that starts a repl session with a given list of modules loaded. Use this to play around with a given node module in a read-eval-print-loop.

Example:

$ cd /tmp
$ npm install pursuit
$ rebelle
└─ pursuit: [email protected]

1 file loaded
cwd: /private/tmp
> pursuit
[function]

As the example shows, it will attempt to load the modules found in the node_modules folder in the current directory. The loading strategy is as follows:

  1. if rebelle is started with a javascript file as the first argument (the file ends in .js), it will load this into the session and give it the basename of the file. rebelle /tmp/hello.js would result in a session with the content of hello.js loaded into global.hello.

  2. if the first argument is a package.json file, it will attempt to load this package into the session and give it the name of the package. The dependencies will also be loaded in and the current working directory will be set to the path of the package.

  3. if a folder is given as the first argument it will look for a node_modules-folder and load the packages within that folder into the session.

  4. if no argument is given it will traverse the file-system upwards untill it finds a folder with a package.json-file or a node_modules-folder, and follow 2 for the former and 3 for the latter.

Extra javascript or JSON-files can be required into the session by using double dash arguments.

$ rebelle /tmp/node_modules/pursuit/package.json --hello /tmp/hello.js
├─ pursuit: [email protected]
├─ pursuitCore: [email protected]
├─ pursuitDictionary: [email protected]
└─ hello: /tmp/hello.js

4 files loaded
cwd: /private/tmp/node_modules/pursuit
>

There is support for more than one file, so by all means: go nuts!

Oh yeah, alpha software. Pull requests are welcome.

(FAILED) aka loading a module that throws an error

If a module require results in an error being thrown, it will get indicated by the label (FAILED) in the require report printed during initialization. A report about what happened can be found in the error object, bound to __errors.

(empty) aka loading a file that did not export anything

If a file did not export anything rebelle will put the label (empty) after its name in the initialization report.

Extending Rebelle

Rebelle supports extensions in the form of rc files and plugins.

User settings (~/.rebelle/)

Todo, write more about this.

If you install node modules that starts with rebelle- into node_modules-folder in ~/.rebelle/, they will get picked up and loaded when rebelle initializes. A rebelle plugin is a normal CommonJS file that exports a function. This function receives the repl session as its first argument.

~/.rebellerc.js (and /path/to/project/.rebellerc.js if enabled in configuration)

You can add functionality to your rebelle session by adding a .rebellerc.js file to your home directory or project root. The file should contain a CommonJS module that exports a function, which will get executed before rebelle loads packages into the session. The first parameter is the repl session, so you can basically do anything here:

// file: ~/.rebellerc.js
module.exports = function(session) {
    // ignore undefined return statements
    session.ignoreUndefined = false;

    // add a .hello-command
    session.commands['.hello'] = {
        help : 'Show the hello, world! message',
        action : function() {
            print('Hello, world!');
        }
    };

    // add something to the session context
    session.context.something = 'something';

    // change the prompt to a $ sign
    session.prompt = '$ ';
}

You can disable these files by setting session.rebelle.ignoreRCFiles to true; default is false. Further more you can choose to load rc files located in the root of the current project (disabled by default); and choose to ignore the rc file in your home directory.

  • session.rebelle.ignoreRCFiles, default false
  • session.rebelle.ignoreRCFileInHome, default false
  • session.rebelle.ignoreRCFileInProjects, default true

Rebelle events

The session is a event emitter that emit the following:

  • initialized when everything has been loaded and Rebelle is ready for user input. Receives nothing.
  • require:success when rebelle succeed to load a node module into the session. Receives the module.
  • require:failure when rebelle fails to load a node module into the session. Receives the module.

Feel free to add your own event emitters on your plugins.

Installation

Install it using npm install rebelle -g. A command line tool called rebelle should be available upon installation. Remove it again using npm uninstall rebelle -g.

License

The MIT License (MIT)

Copyright (c) 2014 Martin Gausby

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.