Skip to content

Commit 22bebbc

Browse files
Fabian Wilesalexeagle
authored andcommitted
feat(jasmine): check pkg version to rules_nodejs
1 parent 011278e commit 22bebbc

20 files changed

Lines changed: 106 additions & 16 deletions

File tree

BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ exports_files([
2525
"tsconfig.json",
2626
"package.json",
2727
"bootstrap.js",
28+
"tools/npm_version_check.js",
2829
])
2930

3031
bzl_library(
@@ -33,6 +34,7 @@ bzl_library(
3334
"index.bzl",
3435
"index.for_docs.bzl",
3536
"providers.bzl",
37+
"version.bzl",
3638
],
3739
visibility = ["//visibility:public"],
3840
deps = [

index.bzl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Users should not load files under "/internal"
1818
"""
1919

20-
load("//internal:version.bzl", "VERSION")
20+
load("//:version.bzl", "VERSION")
2121
load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_bazel_version")
2222
load("//internal/common:check_version.bzl", "check_version")
2323
load("//internal/common:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
@@ -84,12 +84,6 @@ def yarn_install(**kwargs):
8484
_node_repositories()
8585
_yarn_install(**kwargs)
8686

87-
# This version is synced with the version in package.json.
88-
# It will be automatically synced via the npm "version" script
89-
# that is run when running `npm version` during the release
90-
# process. See `Releasing` section in README.md.
91-
VERSION = "1.5.0"
92-
9387
# Currently used Bazel version. This version is what the rules here are tested
9488
# against.
9589
# This version should be updated together with the version of the Bazel

internal/npm_install/npm_install.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ as the package manager.
2121
See discussion in the README.
2222
"""
2323

24-
load("//internal:version.bzl", "VERSION")
24+
load("//:version.bzl", "VERSION")
2525
load("//internal/common:check_bazel_version.bzl", "check_bazel_version")
2626
load("//internal/common:os_name.bzl", "is_windows_os")
2727
load("//internal/node:node_labels.bzl", "get_node_label", "get_npm_label", "get_yarn_label")
@@ -276,7 +276,7 @@ cd /D "{root}" && "{npm}" {npm_args}
276276
env_key = "BAZEL_NPM_INSTALL"
277277
if env_key not in env.keys():
278278
env[env_key] = "1"
279-
env["build_bazel_rules_nodejs_version"] = VERSION
279+
env["BUILD_BAZEL_RULES_NODEJS_VERSION"] = VERSION
280280

281281
repository_ctx.report_progress("Running npm install on %s" % repository_ctx.attr.package_json)
282282
result = repository_ctx.execute(
@@ -414,7 +414,7 @@ cd /D "{root}" && "{yarn}" {yarn_args}
414414
env_key = "BAZEL_YARN_INSTALL"
415415
if env_key not in env.keys():
416416
env[env_key] = "1"
417-
env["build_bazel_rules_nodejs_version"] = VERSION
417+
env["BUILD_BAZEL_RULES_NODEJS_VERSION"] = VERSION
418418

419419
repository_ctx.report_progress("Running yarn install on %s" % repository_ctx.attr.package_json)
420420
result = repository_ctx.execute(

packages/jasmine/BUILD.bazel

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ genrule(
2929
visibility = ["//docs:__pkg__"],
3030
)
3131

32+
genrule(
33+
name = "npm_version_check",
34+
srcs = ["//:tools/npm_version_check.js"],
35+
outs = [":npm_version_check.js"],
36+
cmd = "cp $< $@",
37+
)
38+
3239
pkg_npm(
3340
name = "npm_package",
3441
srcs = [
@@ -38,7 +45,9 @@ pkg_npm(
3845
vendor_external = [
3946
"npm_bazel_jasmine",
4047
],
41-
deps = select({
48+
deps = [
49+
":npm_version_check",
50+
] + select({
4251
# FIXME: fix stardoc on Windows; @npm_bazel_jasmine//:index.md generation fails with:
4352
# ERROR: D:/b/62unjjin/external/npm_bazel_jasmine/BUILD.bazel:34:1: Couldn't build file
4453
# external/npm_bazel_jasmine/docs.raw: Generating proto for Starlark doc for docs failed (Exit 1)

packages/jasmine/src/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
"npm_bazel_jasmine": {
2727
"rootPath": "."
2828
}
29+
},
30+
"scripts": {
31+
"postinstall": "node npm_version_check.js"
2932
}
3033
}

packages/karma/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ genrule(
2929
visibility = ["//docs:__pkg__"],
3030
)
3131

32+
genrule(
33+
name = "npm_version_check",
34+
srcs = ["//:tools/npm_version_check.js"],
35+
outs = [":npm_version_check.js"],
36+
cmd = "cp $< $@",
37+
)
38+
3239
pkg_npm(
3340
name = "npm_package",
3441
srcs = [
@@ -40,6 +47,7 @@ pkg_npm(
4047
],
4148
deps = [
4249
"@npm_bazel_karma//:bazel_karma_lib",
50+
":npm_version_check",
4351
] + select({
4452
# FIXME: fix stardoc on Windows; @npm_bazel_karma//:index.md generation fails with:
4553
# ERROR: D:/b/62unjjin/external/npm_bazel_karma/BUILD.bazel:65:1: Couldn't build file

packages/karma/src/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@
3333
"npm_bazel_karma": {
3434
"rootPath": "."
3535
}
36+
},
37+
"scripts": {
38+
"postinstall": "node npm_version_check.js"
3639
}
3740
}

packages/protractor/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ genrule(
2929
visibility = ["//docs:__pkg__"],
3030
)
3131

32+
genrule(
33+
name = "npm_version_check",
34+
srcs = ["//:tools/npm_version_check.js"],
35+
outs = [":npm_version_check.js"],
36+
cmd = "cp $< $@",
37+
)
38+
3239
pkg_npm(
3340
name = "npm_package",
3441
srcs = [
@@ -39,6 +46,7 @@ pkg_npm(
3946
"npm_bazel_protractor",
4047
],
4148
deps = [
49+
":npm_version_check",
4250
"@npm_bazel_protractor//:utils_lib",
4351
] + select({
4452
# FIXME: fix stardoc on Windows; @npm_bazel_protractor//:index.md generation fails with:

packages/protractor/src/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
"npm_bazel_protractor": {
2323
"rootPath": "."
2424
}
25+
},
26+
"scripts": {
27+
"postinstall": "node npm_version_check.js"
2528
}
2629
}

packages/rollup/BUILD.bazel

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ copy_file(
5353
visibility = ["//visibility:public"],
5454
)
5555

56+
genrule(
57+
name = "npm_version_check",
58+
srcs = ["//:tools/npm_version_check.js"],
59+
outs = [":npm_version_check.js"],
60+
cmd = "cp $< $@",
61+
)
62+
5663
pkg_npm(
5764
name = "npm_package",
5865
srcs = [
@@ -65,7 +72,9 @@ pkg_npm(
6572
vendor_external = [
6673
"npm_bazel_rollup",
6774
],
68-
deps = select({
75+
deps = [
76+
":npm_version_check",
77+
] + select({
6978
# FIXME: fix stardoc on Windows; @npm_bazel_rollup//:index.md generation fails with:
7079
# ERROR: D:/b/62unjjin/external/npm_bazel_rollup/BUILD.bazel:32:1: Couldn't build file
7180
# external/npm_bazel_rollup/docs.raw: Generating proto for Starlark doc for docs failed (Exit 1)

0 commit comments

Comments
 (0)