| # Copyright 2018 The Bazel Authors. All rights reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| """Package file which defines build_bazel_rules_typescript version in skylark |
| |
| check_rules_typescript_version can be used in downstream WORKSPACES to check |
| against a minimum dependent build_bazel_rules_typescript version. |
| """ |
| |
| load("@build_bazel_rules_nodejs//internal/common:check_version.bzl", "check_version") |
| |
| # This version is synced with the version in package.json. |
| # It will be automatically synced via the npm "version" script |
| # that is run when running `npm version` during the release |
| # process. See `Releasing` section in README.md. |
| VERSION = "0.15.3" |
| |
| def check_rules_typescript_version(minimum_version_string): |
| """ |
| Verify that a minimum build_bazel_rules_typescript is loaded a WORKSPACE. |
| |
| This should be called from the `WORKSPACE` file so that the build fails as |
| early as possible. For example: |
| |
| ``` |
| # in WORKSPACE: |
| load("@build_bazel_rules_typescript//:defs.bzl", "check_rules_typescript_version") |
| check_rules_typescript_version("0.15.3") |
| ``` |
| |
| Args: |
| minimum_version_string: a string indicating the minimum version |
| """ |
| if not check_version(VERSION, minimum_version_string): |
| fail("\nCurrent build_bazel_rules_typescript version is {}, expected at least {}\n".format( |
| VERSION, |
| minimum_version_string, |
| )) |