package opam-check-npm-deps

  1. Overview
  2. Docs
An opam plugin to check for npm depexts inside the node_modules folder

Install

Dune Dependency

Authors

Maintainers

Sources

opam-check-npm-deps-1.0.0.tbz
sha256=dce793b588d997b299e371847c9a4c85c3e446a55f6c6e56f99d71cfaf31c967
sha512=4cef4b1456d9da7a2539d43344c81aed6f19332125cfc08e183a18b3085bf421eee20e93fcaee4ff6cb7f4add295e343d2def877eb9680fe62a5d9fe23b88bbb

Description

Provides the opam check-npm-deps command, which given an opam switch, gathers all the depexts belonging to the npm platform and their version constraints, and checks the node_modules folder to see if the constraints are satisfied.

Published: 23 Aug 2023

README

opam-check-npm-deps

An opam plugin to allow using the depexts field to define requirements on npm packages.

When running the plugin, it checks the current opam switch to read all depexts fields that use the npm-version variable, and then reads the node_modules folder to see if the constraints are satisfied.

For bindings authors: defining constraints

Constraints are defined by adding an entry to depexts with the npm package name as the "system package" and and an equality formula that matches the npm-version variable to a version range. This range can be defined using the same format as package.json dependencies field.

For example, the reason-react bindings can define its dependency on the react npm package like this:

depexts: [
  ["react"] {npm-version = "^16.0.2"}
  ["react-dom"] {npm-version = "^16.0.2"}
]

Or, to simplify:

depexts: [
  ["react" "react-dom"] {npm-version = "^16.0.2"}
]

For bindings users: check

Install:

$ opam pin add opam-check-npm-deps.dev git+https://github.com/jchavarri/opam-check-npm-deps.git#main

Check the dependencies by running the plugin:

$ opam-check-npm-deps

If you don't want to the command to fail when errors are found, use the --dry-run flag:

$ opam-check-npm-deps --dry-run

Contributing

$ make init

$ make watch

Commands

You can see all available commands by running make help or just make. Here are a few of the most useful ones:

  • make init: set up opam local switch and download OCaml, Melange and JavaScript dependencies

  • make install: install OCaml dependencies

  • make watch: watch for the filesystem and have Dune rebuild on every change