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

inpack

v0.2.8

Published

Nodejs invisible modules manager

Downloads

9

Readme

Inpack npm version Build Status XO code style

Inpack is a cli tool that makes it possible to use any directory as a Node.js module. It helps in avoiding long relative paths (like import responseParser from '../../../utils/responseParser') in your "require" or "import" without creating any additional files apart from its own config file called inpack.json. Also provokes build more clean and clear project architecture. You can use inpack with depy.

Spoiler

Use

import ComponentName from 'ComponentName';

instead

import Component from './../../../components/dummy/ComponentName';

Screencast

asciicast

Installation

Install it globally:

$ npm install -g inpack

Usage example

Suppose we have a project with the following structure:

~/Project:
  Components
    MainComponent
      index.js
    WelcomeComponent
      index.js
  index.js
  package.json

Use next command in the project’s root directory (valid package.json is required):

~/Project $ inpack init

You It will create inpack.json.

Use "add" to add existing directory as a Node.js module and save data to inpack.json:

~/Project $ inpack add Component/MainComponent

From now on, your ‘Component/MainComponent' directory can be added anywhere in the project in following ways:

const MainModule = require('MainModule');
// or
import MainModule from 'MainModule';

In future, if you need to deploy the project (or just clone it from github), you can simply run ‘link’. For example:

~/Project $ npm install
~/Project $ inpack link

All of your components are good to go now.

Commands list

inpack init

Creates a new project in the current directory.

Available options:

  • --name - project name (directory name by default)
  • --prefix - prefix for added modules. It makes sense using this option if you want to avoid conflicts with other modules. For example, suppose the project’s prefix is @Project/. Then, a module named MainComponent can be accessed via @Project/MainComponent. As a bonus, you always know that you are importing inpack module.
  • --add-postinstall - adds or modifies the postinstall attribute in the existing package.json by adding the inpack link command.

inpack add [module/relative/path]

Declares a directory as a Node.js module. Can be used in various ways: inpack add <relative-path> - adds specified directory as a module relative to the inpack master inpack add - adds current directory as a module.

For example:

~/Project $ inpack add Components/MainComponent

is equivalent to

~/Project/Components/MainComponent $ inpack add

Available options:

  • --name - module name (directory name by default)
  • --main - main file, does the same as the "main" attribute from package.json does. index.js by default.
  • --create - creates a directory and main file, in case if either the directory or main file doesn’t exist.

inpack remove [module name]

Removes specified module (from the configuration as well). Does not remove the source-directory. Can be used in various ways as well as ‘add’.

Available options:

  • --force - removes the module even if it’s not declared in the configuration file.

inpack link

Links all of the modules from inpack.json. Must be run from the master project.

inpack info [module name]

Alias: resolve

Displays information about the module. Can be used in various ways as well as ‘add’ or ‘remove’.

inpack list

Lists a brief information about all modules.

Available options:

  • --verbose - lists the full information about all modules.

Common options

Also there is the —context-dir option that is available for all of the commands and allows to specify a directory where you would like to run one or another command. For example:

~ $ inpack list 
✖ Searching for master project
Master project has not been found

~ $ inpack list --context-dir ./Project
[There goes the command output]

Author

Dmitry Pavlovsky