fix(bazel): Install angular repo before yarn_install (#28670)
PR closes https://github.com/angular/angular/issues/28636 PR Close #28670
This commit is contained in:
parent
0c7581da89
commit
49fb8c3cb0
|
@ -6,7 +6,7 @@ const fs = require('fs');
|
||||||
function replaceAngular(content) {
|
function replaceAngular(content) {
|
||||||
const regex = /ANGULAR_VERSION.*\nhttp_archive\((.*\n){4}\)/;
|
const regex = /ANGULAR_VERSION.*\nhttp_archive\((.*\n){4}\)/;
|
||||||
if (!regex.test(content)) {
|
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, `
|
return content.replace(regex, `
|
||||||
local_repository(
|
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) {
|
function main(argv) {
|
||||||
argv = argv.slice(2);
|
argv = argv.slice(2);
|
||||||
if (argv.length !== 1) {
|
if (argv.length !== 1) {
|
||||||
|
@ -39,7 +23,6 @@ function main(argv) {
|
||||||
const workspace = argv[0];
|
const workspace = argv[0];
|
||||||
let content = fs.readFileSync(workspace, 'utf-8');
|
let content = fs.readFileSync(workspace, 'utf-8');
|
||||||
content = replaceAngular(content);
|
content = replaceAngular(content);
|
||||||
content = replaceNpm(content);
|
|
||||||
fs.writeFileSync(workspace, content);
|
fs.writeFileSync(workspace, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ check_bazel_version("0.18.0")
|
||||||
node_repositories()
|
node_repositories()
|
||||||
yarn_install(
|
yarn_install(
|
||||||
name = "npm",
|
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",
|
package_json = "//:package.json",
|
||||||
yarn_lock = "//:yarn.lock",
|
yarn_lock = "//:yarn.lock",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue