def update_required_node_and_angular_versions()

in tools/build-release.py [0:0]


def update_required_node_and_angular_versions(base_path, local_repo_path):
    print("updating required Node.js version")
    nvmrc_file = os.path.join(local_repo_path, ".nvmrc")
    if not os.path.isfile(nvmrc_file):
        fail("web repo .nvmrc does not exist")
    with open(nvmrc_file) as f:
        node_version = f.readline().strip()
    if not node_version:
        fail("web repo .nvmrc is empty")
    print(f" - node version:  {node_version}")
    replace(os.path.join(base_path, "README.md"), 'Node.js 16.14.2', 'Node ' + node_version)

    print("updating required Angular version")
    package_json_file = os.path.join(local_repo_path, "package.json")
    if not os.path.isfile(package_json_file):
        fail("web repo package.json does not exist")
    with open(package_json_file) as f:
        try:
            data = json.load(f)
        except json.JSONDecodeError:
            fail("load web package.json: unexpected json decode failure")
    angular_version_match = re.search("\d+\.\d+\.\d+", data.get("dependencies", {}).get("@angular/core", ""))
    if not angular_version_match:
        fail("web repo package.json: unexpected @angular/core version")
    angular_version = angular_version_match.group()
    print(f" - angular version:  {angular_version}")
    replace(os.path.join(base_path, "README.md"), 'Angular CLI 13.3.0', 'Angular CLI ' + angular_version)