Skip to content

Implement NodeJS API #204

@bmish

Description

@bmish

DONE AS OF 2023-05-20:


Considering a few possible options for how to expose our functionality for programmatic usage instead of just as a CLI binary. We could possibly expose both raw functions and a class.

1. Expose functions

import { check, fix } from 'check-dependency-version-consistency';

const path = 'path/to/workspace/root';

const versionMismatches = check({ path }); // pass any options
const versionMismatchesRemaining = fix({ path }); // pass any options

2. Expose a class

import CheckDependencyVersionConsistency from 'check-dependency-version-consistency';

const path = 'path/to/workspace/root';
const checker = new CheckDependencyVersionConsistency({ path }); // pass any options

const versionMismatches = checker.check();
const versionMismatchesRemaining = checker.fix();

Types

Version mismatches would be an object of this type (currently used internally).

export type MismatchingDependencyVersions = Array<{
  dependency: string;
  versions: {
    version: string;
    packages: string[];
  }[];
}>;

Note: this is low priority since I haven't heard had a need or use case for this yet. If you have one, please comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions