diff --git a/app/build_npms.py b/app/build_npms.py index 48161248..8091a8a0 100644 --- a/app/build_npms.py +++ b/app/build_npms.py @@ -22,7 +22,9 @@ import os from decouple import config import click import importlib.resources +from pathlib import Path from python_on_whales import docker +import yaml from .util import include_exclude_check @click.command() @@ -37,6 +39,7 @@ def command(ctx, include, exclude): dry_run = ctx.obj.dry_run local_stack = ctx.obj.local_stack debug = ctx.obj.debug + stack = ctx.obj.stack if local_stack: dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")] @@ -53,10 +56,22 @@ def command(ctx, include, exclude): # See: https://stackoverflow.com/a/20885799/1701505 from . import data with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file: - packages = package_list_file.read().splitlines() + all_packages = package_list_file.read().splitlines() + + packages_in_scope = [] + if stack: + # In order to be compatible with Python 3.8 we need to use this hack to get the path: + # See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure + stack_file_path = Path(__file__).absolute().parent.joinpath("data", "stacks", stack, "stack.yml") + with stack_file_path: + stack_config = yaml.safe_load(open(stack_file_path, "r")) + # TODO: syntax check the input here + packages_in_scope = stack_config['npms'] + else: + packages_in_scope = all_packages if verbose: - print(f'Packages: {packages}') + print(f'Packages: {packages_in_scope}') def build_package(package): if not quiet: @@ -84,7 +99,7 @@ def command(ctx, include, exclude): else: print("Skipped") - for package in packages: + for package in packages_in_scope: if include_exclude_check(package, include, exclude): build_package(package) else: diff --git a/app/data/stacks/laconicd/README.md b/app/data/stacks/fixturenet-laconicd/README.md similarity index 100% rename from app/data/stacks/laconicd/README.md rename to app/data/stacks/fixturenet-laconicd/README.md diff --git a/app/data/stacks/laconicd/stack.yml b/app/data/stacks/fixturenet-laconicd/stack.yml similarity index 82% rename from app/data/stacks/laconicd/stack.yml rename to app/data/stacks/fixturenet-laconicd/stack.yml index d47a6fe5..1d059b52 100644 --- a/app/data/stacks/laconicd/stack.yml +++ b/app/data/stacks/fixturenet-laconicd/stack.yml @@ -4,6 +4,9 @@ repos: - cerc-io/laconicd - cerc-io/laconic-sdk - cerc-io/laconic-registry-cli +npms: + - laconic-sdk + - laconic-registry-cli containers: - cerc/laconicd - cerc/laconic-registry-cli