Skip to content

Commit 8da55b2

Browse files
kormidefilipesilva
authored andcommitted
build: move engine substitutions out of jq filter
1 parent 9539d15 commit 8da55b2

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

constants.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Engine versions to stamp in a release package.json
2+
RELEASE_ENGINES_NODE = "^12.20.0 || ^14.15.0 || >=16.10.0"
3+
RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0"
4+
RELEASE_ENGINES_YARN = ">= 1.13.0"

tools/defaults.bzl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ load("@aspect_bazel_lib//lib:utils.bzl", "to_label")
88
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
99
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
1010
load("//tools:link_package_json_to_tarballs.bzl", "link_package_json_to_tarballs")
11+
load("//:constants.bzl", "RELEASE_ENGINES_NODE", "RELEASE_ENGINES_NPM", "RELEASE_ENGINES_YARN")
1112

1213
_DEFAULT_TSCONFIG = "//:tsconfig-build.json"
1314
_DEFAULT_TSCONFIG_TEST = "//:tsconfig-test.json"
@@ -64,12 +65,16 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs):
6465

6566
visibility = kwargs.pop("visibility", None)
6667

67-
common_substitutions = dict(kwargs.pop("substitutions", {}))
68-
substitutions = dict(common_substitutions, **{
69-
"0.0.0-PLACEHOLDER": "0.0.0",
70-
})
71-
stamped_substitutions = dict(common_substitutions, **{
68+
NPM_PACKAGE_SUBSTITUTIONS = {
69+
# Version of the local package being built, generated via the `--workspace_status_command` flag.
7270
"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}",
71+
"0.0.0-ENGINES-NODE": RELEASE_ENGINES_NODE,
72+
"0.0.0-ENGINES-NPM": RELEASE_ENGINES_NPM,
73+
"0.0.0-ENGINES-YARN": RELEASE_ENGINES_YARN,
74+
}
75+
76+
NO_STAMP_PACKAGE_SUBSTITUTIONS = dict(NPM_PACKAGE_SUBSTITUTIONS, **{
77+
"0.0.0-PLACEHOLDER": "0.0.0",
7378
})
7479

7580
deps = kwargs.pop("deps", [])
@@ -161,8 +166,8 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs):
161166
package_name = None,
162167
validate = False,
163168
substitutions = select({
164-
"//:stamp": stamped_substitutions,
165-
"//conditions:default": substitutions,
169+
"//:stamp": NPM_PACKAGE_SUBSTITUTIONS,
170+
"//conditions:default": NO_STAMP_PACKAGE_SUBSTITUTIONS,
166171
}),
167172
visibility = visibility,
168173
nested_packages = ["package"],

tools/package_json_release_filter.jq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
# Remove devDependencies
2929
| del(.devDependencies)
3030

31-
# Add engines
32-
+ {"engines": {"node": "^12.20.0 || ^14.15.0 || >=16.10.0", "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", "yarn": ">= 1.13.0"}}
31+
# Add engines; versions substituted via pkg_npm
32+
+ {"engines": {"node": "0.0.0-ENGINES-NODE", "npm": "0.0.0-ENGINES-NPM", "yarn": "0.0.0-ENGINES-YARN"}}

0 commit comments

Comments
 (0)