Skip to content

Commit

Permalink
chore(NA): downgrades rules nodejs into v4.7.0 (#130347)
Browse files Browse the repository at this point in the history
* chore(NA): downgrade rules nodejs into v4.0.0

* chore(NA): include windows patch

* chore(NA): polish downgrade code

* chore(NA): include yarn.lock
  • Loading branch information
mistic authored Apr 15, 2022
1 parent 874bfb3 commit 0b2da10
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 37 deletions.
12 changes: 4 additions & 8 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_nodejs",
patch_args = ["-p1"],
patches = ["//:src/dev/bazel/rules_nodejs_patches/exclude_npm_directory_copies_from_remote_cache.patch"],
sha256 = "2b2004784358655f334925e7eadc7ba80f701144363df949b3293e1ae7a2fb7b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.0/rules_nodejs-5.4.0.tar.gz"],
patches = ["//:src/dev/bazel/rules_nodejs_patches/normalized_paths_for_windows_runfiles.patch"],
sha256 = "6f15d75f9e99c19d9291ff8e64e4eb594a6b7d25517760a75ad3621a7a48c2df",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.7.0/rules_nodejs-4.7.0.tar.gz"],
)

# Build Node.js rules dependencies
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
build_bazel_rules_nodejs_dependencies()

# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")

Expand All @@ -41,7 +37,7 @@ node_repositories(
node_urls = [
"https://nodejs.org/dist/v{version}/{filename}",
],
yarn_releases = {
yarn_repositories = {
"1.21.1": ("yarn-v1.21.1.tar.gz", "yarn-v1.21.1", "d1d9f4a0f16f5ed484e814afeb98f39b82d4728c6c8beaafb5abc99c02db6674"),
},
yarn_version = "1.21.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
"@babel/traverse": "^7.17.3",
"@babel/types": "^7.17.0",
"@bazel/ibazel": "^0.16.2",
"@bazel/typescript": "5.4.0",
"@bazel/typescript": "4.6.2",
"@cypress/code-coverage": "^3.9.12",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.6.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-type-summarizer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@rules_nodejs//nodejs:directory_file_path.bzl", "directory_file_path")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "nodejs_binary")
load("@build_bazel_rules_nodejs//:index.bzl", "directory_file_path", "js_library", "nodejs_binary")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_BASE_NAME = "kbn-type-summarizer"
Expand Down
4 changes: 2 additions & 2 deletions src/dev/bazel/pkg_npm_types.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Side Public License, v 1.
#

load("@rules_nodejs//nodejs/private:ts_config.bzl", "TsConfigInfo")
load("@npm//@bazel/typescript/internal:ts_config.bzl", "TsConfigInfo")
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node", "LinkablePackageInfo", "DeclarationInfo", "declaration_info")
load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect")

Expand Down Expand Up @@ -142,7 +142,7 @@ pkg_npm_types = rule(
"_packager": attr.label(
doc = "Target that executes the npm types package assembler binary",
executable = True,
cfg = "exec",
cfg = "host",
default = Label("//packages/kbn-type-summarizer:bazel-cli"),
),
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/internal/node/launcher.sh b/internal/node/launcher.sh
index fd832d02..64820f48 100644
--- a/internal/node/launcher.sh
+++ b/internal/node/launcher.sh
@@ -13,6 +13,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.

+# It helps to determine if we are running on a Windows environment (excludes WSL as it acts like Unix)
+function isWindows {
+ case "$(uname -s)" in
+ CYGWIN*) local IS_WINDOWS=1 ;;
+ MINGW*) local IS_WINDOWS=1 ;;
+ MSYS_NT*) local IS_WINDOWS=1 ;;
+ *) local IS_WINDOWS=0 ;;
+ esac
+
+ echo $IS_WINDOWS
+ return
+}
+
+# It helps to normalizes paths when running on Windows.
+#
+# Example:
+# C:/Users/XUser/_bazel_XUser/7q7kkv32/execroot/A/b/C -> /c/users/xuser/_bazel_xuser/7q7kkv32/execroot/a/b/c
+function normalizeWindowsPath {
+ # Apply the followings paths transformations to normalize paths on Windows
+ # -process driver letter
+ # -convert path separator
+ # -lowercase everything
+ echo $(sed -e 's#^\(.\):#/\L\1#' -e 's#\\#/#g' -e 's/[A-Z]/\L&/g' <<< "$1")
+ return
+}
+
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
@@ -49,7 +75,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
# Case 6a is handled like case 3.
if [[ -n "${RUNFILES_MANIFEST_ONLY:-}" ]]; then
# Windows only has a manifest file instead of symlinks.
- RUNFILES=${RUNFILES_MANIFEST_FILE%/MANIFEST}
+ if [[ $(isWindows) -eq "1" ]]; then
+ # If Windows normalizing the path and case insensitive removing the `/MANIFEST` part of the path
+ NORMALIZED_RUNFILES_MANIFEST_FILE_PATH=$(normalizeWindowsPath $RUNFILES_MANIFEST_FILE)
+ RUNFILES=$(sed 's|\/MANIFEST$||i' <<< $NORMALIZED_RUNFILES_MANIFEST_FILE_PATH)
+ else
+ RUNFILES=${RUNFILES_MANIFEST_FILE%/MANIFEST}
+ fi
elif [[ -n "${TEST_SRCDIR:-}" ]]; then
# Case 4, bazel has identified runfiles for us.
RUNFILES="${TEST_SRCDIR:-}"
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1228,21 +1228,21 @@
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.16.2.tgz#05dd7f06659759fda30f87b15534f1e42f1201bb"
integrity sha512-KgqAWMH0emL6f3xH6nqyTryoBMqlJ627LBIe9PT1PRRQPz2FtHib3FIHJPukp1slzF3hJYZvdiVwgPnHbaSOOA==

"@bazel/typescript@5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.4.0.tgz#0a24e8d47152728f71b26b73adc3913645e5309e"
integrity sha512-AWmS9HcnjqGsPQv5lnqecA8xof+d4ChpbI/Z6aiSM0qOemc8e1WT9wb1VzM6g6hRfV5foWyIHt0VhTonTsPhYw==
"@bazel/typescript@4.6.2":
version "4.6.2"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-4.6.2.tgz#9f07b6f8cfb6b0a0e228e5971de412911c910a90"
integrity sha512-AUF7kq82bP6DX9Brihr/eQqvNccxVfSXosFxt80h94og5cmMyoc/euXha6rxlOBP3yWXmSo+/qjzO7o8PWJduQ==
dependencies:
"@bazel/worker" "5.4.0"
"@bazel/worker" "4.6.2"
protobufjs "6.8.8"
semver "5.6.0"
source-map-support "0.5.9"
tsutils "3.21.0"

"@bazel/worker@5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-5.4.0.tgz#ce50e34951ccf7233b651f0be665bbd43d7ed7f1"
integrity sha512-Rtkol9WoYs0NCZl1wt4Q8T7Rs0wbQjIvFiJzVeeoC/00TG0e/qi4mYE5iQwUJmO8st3N8VnaWz2N31UHc6yhRA==
"@bazel/worker@4.6.2":
version "4.6.2"
resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-4.6.2.tgz#0bd105344533335327c2edfa3fc65b04c39cdea8"
integrity sha512-DLpN6iQAH6uiUraAs4CESyqs60u55fcKmYgOOVObGuLSQQuX49Lw7XRIN90NibRPwpbBDQichWE3zfra0yKTTw==
dependencies:
google-protobuf "^3.6.1"

Expand Down

0 comments on commit 0b2da10

Please sign in to comment.