<commit_before>load("//:packages.bzl", "ALL_PACKAGES", "to_package_label")
load("@build_bazel_rules_nodejs//internal/linker:npm_link.bzl", "npm_link")

def link_local_packages(deps):
    """Stamp npm_link targets for packages in deps that has a local package equivalent.

    Args:
        deps: list of npm dependency labels
    """
    for dep in deps:
        if dep.startswith("@aio_npm//"):
            label = Label(dep)
            if label.package in ALL_PACKAGES:
                npm_link(
                    name = _npm_link_name(dep),
                    target = to_package_label(label.package),
                    package_name = label.package,
                    package_path = native.package_name(),
                    tags = ["manual"],
                )

def substitute_local_packages(deps):
    """Substitute npm dependencies for their local npm_link equivalent.

    Assumes that link_local_packages() was already called on these dependencies.
    Dependencies that are not associated with a local package are left alone.

    Args:
        deps: list of npm dependency labels

    Returns:
        substituted list of dependencies
    """
    substituted = []
    for dep in deps:
        if dep.startswith("@aio_npm//"):
            label = Label(dep)
            if label.package in ALL_PACKAGES:
                substituted.append(_npm_link_name(dep))
            else:
                substituted.append(dep)
    return substituted

def _npm_link_name(dep):
    label = Label(dep)
    return "local_%s" % label.package.replace("@", "_").replace("/", "_")<commit_msg>build(bazel): fix a bug where deps in aio local build were not included<commit_after>load("//:packages.bzl", "ALL_PACKAGES", "to_package_label")
load("@build_bazel_rules_nodejs//internal/linker:npm_link.bzl", "npm_link")

def link_local_packages(deps):
    """Stamp npm_link targets for packages in deps that has a local package equivalent.

    Args:
        deps: list of npm dependency labels
    """
    for dep in deps:
        if dep.startswith("@aio_npm//"):
            label = Label(dep)
            if label.package in ALL_PACKAGES:
                npm_link(
                    name = _npm_link_name(dep),
                    target = to_package_label(label.package),
                    package_name = label.package,
                    package_path = native.package_name(),
                    tags = ["manual"],
                )

def substitute_local_packages(deps):
    """Substitute npm dependencies for their local npm_link equivalent.

    Assumes that link_local_packages() was already called on these dependencies.
    Dependencies that are not associated with a local package are left alone.

    Args:
        deps: list of npm dependency labels

    Returns:
        substituted list of dependencies
    """
    substituted = []
    for dep in deps:
        if dep.startswith("@aio_npm//"):
            label = Label(dep)
            if label.package in ALL_PACKAGES:
                substituted.append(_npm_link_name(dep))
                continue

        substituted.append(dep)
    return substituted

def _npm_link_name(dep):
    label = Label(dep)
    return "local_%s" % label.package.replace("@", "_").replace("/", "_")
{'fraction_non_alphanumeric': 0.09617755856966707, 'fraction_numerical': 0.0, 'mean_word_length': 2.2645875251509056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1432984', 'n_tokens_mistral': 964, 'n_tokens_neox': 883, 'n_words': 250}