@pob/check-lib-dependency-in-root-dev-dependencies

6.3.3 • Public • Published

@pob/check-lib-dependency-in-root-dev-dependencies

Checks an lib dependency in root dev dependency. Ensures you have the version you want ! Very useful with yarn berry.

Install

npm install --save @pob/check-lib-dependency-in-root-dev-dependencies

Usage

import checkDep from "@pob/check-lib-dependency-in-root-dev-dependencies";

checkDep(require("package-name/package.json"));

Use Cases

eslint config lib

  • Ensures the plugin has the correct version
  • Avoids the app to have to install it, has it's optional in peerDependenciesMeta

package.json

{
  "name": "@pob/eslint-config",
  "peerDependencies": {
    "eslint": "^7.5.0",
    "eslint-plugin-prettier": "^3.1.4"
  },
  "peerDependenciesMeta": {
    "eslint-plugin-prettier": {
      "optional": true
    }
  },
  "dependencies": {
    "@pob/check-lib-dependency-in-root-dev-dependencies": "^1.0.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-prettier": "^3.1.4"
  }
}

index.js

"use strict";

const checkDep = require("@pob/check-lib-dependency-in-root-dev-dependencies");

checkDep(require("rollup/package.json"));

module.exports = {
  plugins: ["prettier"],
  extends: ["eslint-config-prettier"].map(require.resolve),

  rules: {
    "prettier/prettier": "error",
  },
};

Rollup

Use case for a lib wrapping rollup

package.json

{
  "name": "pob-babel",
  "peerDependencies": {
    "rollup": "^2.27.1"
  },
  "dependencies": {
    "rollup": "^2.27.1"
  }
}
"use strict";

const path = require("path");
const { spawnSync } = require("child_process");
const checkDep = require("@pob/check-lib-dependency-in-root-dev-dependencies");

checkDep(require("rollup/package.json"));

const configPath = path.resolve("rollup.config.js");

spawnSync("yarn", ["rollup", "--config", configPath], {
  stdio: "inherit",
});

Readme

Keywords

Package Sidebar

Install

npm i @pob/check-lib-dependency-in-root-dev-dependencies

Weekly Downloads

134

Version

6.3.3

License

ISC

Unpacked Size

12.6 kB

Total Files

6

Last publish

Collaborators

  • churpeau