Skip to content

cli

get_dist_tags(pkg_name)

Fetch all the npm tags for a package.

Parameters:

Name Type Description Default
pkg_name str

The name of the npm package.

required

Returns:

Type Description
OneOf[Issue, Dict[str, str]]

A OneOf containing an Issue or map specifying the tags to a

OneOf[Issue, Dict[str, str]]

published version.

Source code in m/npm/cli.py
def get_dist_tags(pkg_name: str) -> OneOf[Issue, Dict[str, str]]:
    """Fetch all the npm tags for a package.

    Args:
        pkg_name: The name of the npm package.

    Returns:
        A `OneOf` containing an `Issue` or map specifying the tags to a
        published version.
    """
    cmd = f'npm info {pkg_name} dist-tags --json'
    return one_of(lambda: [
        tag_map
        for payload in subprocess.eval_cmd(cmd)
        for tag_map in parse_json(payload)
    ])

remove_dist_tag(pkg_name, tag)

Remove an npm tag.

Parameters:

Name Type Description Default
pkg_name str

The name of the npm package.

required
tag str

The tag to remove.

required

Returns:

Type Description
OneOf[Issue, str]

A OneOf containing an Issue or the output of the npm command.

Source code in m/npm/cli.py
def remove_dist_tag(pkg_name: str, tag: str) -> OneOf[Issue, str]:
    """Remove an npm tag.

    Args:
        pkg_name: The name of the npm package.
        tag: The tag to remove.

    Returns:
        A `OneOf` containing an `Issue` or the output of the npm command.
    """
    return subprocess.eval_cmd(f'npm dist-tag rm {pkg_name} {tag} --json')