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

thin-install

v2.0.2

Published

For large projects it can be a pain to install the entire project if you only need a subset of dependencies to accomplish a specific task like running tests or tooling.

Downloads

25,042

Readme

thin-install

For large projects it can be a pain to install the entire project if you only need a subset of dependencies to accomplish a specific task like running tests or tooling.

Install

Local

npm install thin-install

Global

npm install -g thin-install

Setup

Add a subsets entry to your package.json. Each entry maps the subset name to an array of dependency names.

{
  "name": "foo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "a": "1.0.0",
    "b": "2.2.2",
    "c": "3.3.3",
    "d": "4.4.4"
  },
  "subsets": {
    "test": [
      "a",
      "b"
    ],
    "analysis": [
      "c"
    ],
    "build": [
      "a",
      "d"
    ]
  }
}

Run

CLI

Available options

  • --srcDir The directory where the source package.json file lives. The current running directly will be used if not provided.
  • --subset Install a single subset of dependencies.
  • --subsets Install multiple subsets of dependencies. Separate subset names with a space!
  • --workingDir Install the subset of dependencies into a directory other than where the source package.json file is.
  • --installCommand Use a custom install command. Useful if using Yarn or another package manager.
  • --timeout Set the amount of time (in milliseconds) that can be spent installing dependencies. Default is 300000ms
  • --force thin-install performs file operations. If something happens during the process files can be irreparably changed. By default we will only write to Git protected folders. Use this option to override that protection if you know what you are doing or are using another version control system.

Examples below are using the package.json defined above. You must provide exactly one of the subset or the subsets options.

Install in current directory

Install a subset into the current directory. (installs dependency c) npx thin-install --subset analysis

Use package.json in different directory

Use the srcDir to point to the directory where the package.json resides. (installs dependencies a and d) npx thin-install --srcDir test-dir --subset build

Single Subset

To install just a single subset of dependencies use the subset option. (installs dependencies a and b) npx thin-install --subset test

Multiple Subsets

To install multiple subsets use the subsets directory and a space separated list of subsets to install. (installs dependencies a, c, and d) npx thin-install --subsets analysis build

Install to different directory

The workingDir option allows you to install the subsets into a directory other than where the source package.json lives. npx thin-install --subset test --workingDir other-dir

Custom install command

If you are using a different tool to install node packages such as Yarn, you can provide that with the installCommand option. Default is npm install. (installs dependencies a, b, and d) npx thin-install --subsets build test --workingDir other-dir

Change install timeout

By default thin-install will timeout the installation process after a set time in milliseconds. This can be extended with the timeout option. (installs a, b, and c) npx thin-install --subsets analysis test --timeout 400000

Skip Git Check

By default, thin-install will not write the subset package.json file to a directory that is not protected by Git. Use force to override this check.

npx thin-install --subsets analysis build --force

Code

JavaScript

const ThinInstaller = require("thin-install").ThinInstaller;
const ThinInstallConfig = require("thin-install").ThinInstallConfig;

(async () => {
  const sourceDir = "";
  const force = false;
  const installCommand = "yarn";
  const subset = "foo";
  const subsets = undefined;
  const workingDir = "some-dir";
  const timeout = Number.MAX_SAFE_INTEGER;
  const config: ThinInstallConfig = {
    sourceDir,
    force,
    installCommand,
    subset,
    subsets,
    workingDir,
    timeout,
  };

  await new ThinInstaller(config).run();
})();

TypeScript

import { ThinInstaller, ThinInstallConfig } from "thin-install";

(async () => {
  const sourceDir = "";
  const force = false;
  const installCommand = "yarn";
  const subset = undefined;
  const subsets = ["foo", "bar"];
  const workingDir = "some-dir";
  const timeout = Number.MAX_SAFE_INTEGER;
  const config: ThinInstallConfig = {
    sourceDir,
    force,
    installCommand,
    subset,
    subsets,
    workingDir,
    timeout,
  };

  await new ThinInstaller(config).run();
})();

Contribute

Code

You can get all source code by running.

Install

Install dependencies

  • npm install

Build

Build once

  • npm run tsc

Build on saved changes

  • npm run watch

Test

Single Run

npm test

Test on Save

npm run test:watch

Debug Test

Run the Test task in VSCode

Debug

  • In VSCode, use the Run launch config. You can change inputs in the launch.json file.