Skip to content

Commit 3ffd43a

Browse files
committed
build: preserve peerDependenciesMeta in snapshots
Addresses an issue where publishing snapshot builds would replace the value with the package SHAs in `peerDependenciesMeta`. See: https://github.com/angular/angular-build-builds/blob/d4d0f1ca0932bd4fe2df4cc2da10d132789dcd8f/package.json#L89 (cherry picked from commit 697d7e6)
1 parent cf4e676 commit 3ffd43a

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tools/snapshot_repo_filter.bzl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@
66
load("//:constants.bzl", "SNAPSHOT_REPOS")
77

88
def _generate_snapshot_repo_filter():
9-
filter = ""
10-
for (i, pkg_name) in enumerate(SNAPSHOT_REPOS.keys()):
11-
filter += "{sep}(..|objects|select(has(\"{pkg_name}\")))[\"{pkg_name}\"] |= \"github:{snapshot_repo}#BUILD_SCM_HASH-PLACEHOLDER\"\n".format(
12-
sep = "| " if i > 0 else "",
13-
pkg_name = pkg_name,
14-
snapshot_repo = SNAPSHOT_REPOS[pkg_name],
9+
individual_pkg_filters = []
10+
for pkg_name, snapshot_repo in SNAPSHOT_REPOS.items():
11+
individual_pkg_filters.append(
12+
"""
13+
. as $root
14+
| [paths(..)]
15+
| [(.[] | select(
16+
contains(["{pkg_name}"]) and
17+
contains(["peerDependenciesMeta"]) != true))] as $paths
18+
| $paths | reduce $paths[] as $path ($root; setpath($path; "github:{snapshot_repo}#BUILD_SCM_HASH-PLACEHOLDER")) | .
19+
""".format(
20+
pkg_name = pkg_name,
21+
snapshot_repo = snapshot_repo,
22+
),
1523
)
16-
return filter
24+
25+
return " | ".join(individual_pkg_filters)
1726

1827
# jq filter that replaces package.json dependencies with snapshot repos
1928
SNAPSHOT_REPO_JQ_FILTER = _generate_snapshot_repo_filter()

0 commit comments

Comments
 (0)