From 49fb8c3cb0d856271ab84702edf8016918ec20f0 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Wed, 13 Feb 2019 09:44:54 +0800 Subject: [PATCH] fix(bazel): Install angular repo before yarn_install (#28670) PR closes https://github.com/angular/angular/issues/28636 PR Close #28670 --- .../bazel-schematics/replace_angular_repo.js | 19 +------------------ .../bazel-workspace/files/WORKSPACE.template | 3 +++ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/integration/bazel-schematics/replace_angular_repo.js b/integration/bazel-schematics/replace_angular_repo.js index 1b5babb0f4..50a64e2986 100644 --- a/integration/bazel-schematics/replace_angular_repo.js +++ b/integration/bazel-schematics/replace_angular_repo.js @@ -6,7 +6,7 @@ const fs = require('fs'); function replaceAngular(content) { const regex = /ANGULAR_VERSION.*\nhttp_archive\((.*\n){4}\)/; if (!regex.test(content)) { - throw new Error("Failed to find http_archive rule for Angular in WORKSPACE"); + throw new Error('Failed to find http_archive rule for Angular in WORKSPACE'); } return content.replace(regex, ` local_repository( @@ -15,22 +15,6 @@ local_repository( )`); } -function replaceNpm(content) { - const regex = /yarn_install\((.*\n){4}\)/; - if (!regex.test(content)) { - throw new Error("Failed to find yarn_install rule for Angular in WORKSPACE"); - } - return content.replace(regex, ` -yarn_install( - name = "npm", - # Need a reference to @angular here so that Bazel sets up the - # external repository before calling yarn_install - data = ["@angular//:LICENSE"], - package_json = "//:package.json", - yarn_lock = "//:yarn.lock", -)`); -} - function main(argv) { argv = argv.slice(2); if (argv.length !== 1) { @@ -39,7 +23,6 @@ function main(argv) { const workspace = argv[0]; let content = fs.readFileSync(workspace, 'utf-8'); content = replaceAngular(content); - content = replaceNpm(content); fs.writeFileSync(workspace, content); } diff --git a/packages/bazel/src/schematics/bazel-workspace/files/WORKSPACE.template b/packages/bazel/src/schematics/bazel-workspace/files/WORKSPACE.template index b1d8ddf27b..0504d9ccc5 100644 --- a/packages/bazel/src/schematics/bazel-workspace/files/WORKSPACE.template +++ b/packages/bazel/src/schematics/bazel-workspace/files/WORKSPACE.template @@ -52,6 +52,9 @@ check_bazel_version("0.18.0") node_repositories() yarn_install( name = "npm", + # Need a reference to @angular here so that Bazel sets up the + # external repository before calling yarn_install + data = ["@angular//:LICENSE"], package_json = "//:package.json", yarn_lock = "//:yarn.lock", )