refactor(bazel): Schematics should fetch angular from distro (#28851)

PR Close #28851
This commit is contained in:
Keen Yee Liau 2019-02-19 17:58:21 -08:00 committed by Igor Minar
parent 96b597cfd0
commit e5e4e63e71
10 changed files with 209 additions and 101 deletions

View File

@ -3,6 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"postinstall": "ngc -p ./angular-metadata.tsconfig.json",
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
"test": "ng test", "test": "ng test",
@ -27,10 +28,11 @@
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "~0.12.0", "@angular-devkit/build-angular": "~0.12.0",
"@angular/bazel": "file:../angular/dist/packages-dist/bazel", "@angular/bazel": "file:../angular/dist/packages-dist/bazel",
"@angular/cli": "~7.2.1", "@angular/cli": "~7.3.0",
"@angular/compiler-cli": "file:../angular/dist/packages-dist/compiler-cli", "@angular/compiler-cli": "file:../angular/dist/packages-dist/compiler-cli",
"@angular/language-service": "file:../angular/dist/packages-dist/language-service", "@angular/language-service": "file:../angular/dist/packages-dist/language-service",
"@bazel/bazel": "^0.21.0", "@angular/upgrade": "file:../angular/dist/packages-dist/upgrade",
"@bazel/bazel": "^0.22.1",
"@bazel/ibazel": "^0.9.0", "@bazel/ibazel": "^0.9.0",
"@bazel/karma": "^0.23.2", "@bazel/karma": "^0.23.2",
"@bazel/typescript": "^0.23.2", "@bazel/typescript": "^0.23.2",

View File

@ -1,29 +0,0 @@
// TODO(kyliau): This file should be removed when we use Angular npm distro from
// Bazel projects.
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');
}
return content.replace(regex, `
local_repository(
name = "angular",
path = "../../..",
)`);
}
function main(argv) {
argv = argv.slice(2);
if (argv.length !== 1) {
throw new Error('Expect WORKSPACE to be first parameter');
}
const workspace = argv[0];
let content = fs.readFileSync(workspace, 'utf-8');
content = replaceAngular(content);
fs.writeFileSync(workspace, content);
}
main(process.argv)

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eux -o pipefail set -eux -o pipefail
readonly pwd=$(pwd)
function testBazel() { function testBazel() {
# Set up # Set up
@ -8,12 +9,12 @@ function testBazel() {
ng version ng version
rm -rf demo rm -rf demo
# Create project # Create project
ng new demo --collection=@angular/bazel --defaults --skip-git --style=scss ng new demo --collection=@angular/bazel --defaults --skip-git --skip-install --style=scss
node replace_angular_repo.js "./demo/WORKSPACE"
cd demo cd demo
yarn add @angular/bazel@file:../../../dist/packages-dist/bazel
yarn webdriver-manager update --gecko=false --standalone=false $CI_CHROMEDRIVER_VERSION_ARG
cp ../package.json.replace ./package.json cp ../package.json.replace ./package.json
sed -i "s#file:../angular#${pwd}/../..#" ./package.json
yarn
yarn webdriver-manager update --gecko=false --standalone=false $CI_CHROMEDRIVER_VERSION_ARG
ng generate component widget --style=css ng generate component widget --style=css
ng build ng build
ng test ng test
@ -23,7 +24,9 @@ function testBazel() {
function testNonBazel() { function testNonBazel() {
# Replace angular.json that uses Bazel builder with the default generated by CLI # Replace angular.json that uses Bazel builder with the default generated by CLI
mv ./angular.json.bak ./angular.json mv ./angular.json.bak ./angular.json
mv ./tsconfig.json.bak ./tsconfig.json
rm -rf dist src/main.dev.ts src/main.prod.ts rm -rf dist src/main.dev.ts src/main.prod.ts
sed -i 's/"es5BrowserSupport": true//' angular.json
ng build --progress=false ng build --progress=false
ng test --progress=false --watch=false ng test --progress=false --watch=false
ng e2e --configuration=production --webdriver-update=false ng e2e --configuration=production --webdriver-update=false

View File

@ -68,12 +68,13 @@
rxjs "6.3.3" rxjs "6.3.3"
"@angular/bazel@file:../../dist/packages-dist/bazel": "@angular/bazel@file:../../dist/packages-dist/bazel":
version "8.0.0-beta.2" version "8.0.0-beta.4"
dependencies: dependencies:
"@angular-devkit/architect" "^0.10.6" "@angular-devkit/architect" "^0.10.6"
"@angular-devkit/core" "^7.0.4" "@angular-devkit/core" "^7.0.4"
"@angular-devkit/schematics" "^7.3.0-rc.0" "@angular-devkit/schematics" "^7.3.0-rc.0"
"@bazel/typescript" "^0.23.2" "@bazel/typescript" "^0.23.2"
"@microsoft/api-extractor" "^7.0.17"
"@schematics/angular" "^7.0.4" "@schematics/angular" "^7.0.4"
"@types/node" "6.0.84" "@types/node" "6.0.84"
semver "^5.6.0" semver "^5.6.0"
@ -130,6 +131,51 @@
source-map-support "0.5.9" source-map-support "0.5.9"
tsutils "2.27.2" tsutils "2.27.2"
"@microsoft/api-extractor@^7.0.17":
version "7.0.18"
resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.0.18.tgz#4eb931436495177dfcef8f2d8da3d084d10eebb6"
integrity sha512-puQisjyoYK1A0I8DqyBoLPV9noyFUlxTE3WsjhgJw//TrmegGHYmsRlD3rnHeXcKPM1F7sd/VKJXeXC3IPTf2Q==
dependencies:
"@microsoft/node-core-library" "3.10.0"
"@microsoft/ts-command-line" "4.2.3"
"@microsoft/tsdoc" "0.12.5"
"@types/node" "8.5.8"
"@types/z-schema" "3.16.31"
colors "~1.2.1"
lodash "~4.17.5"
resolve "1.8.1"
typescript "~3.1.6"
z-schema "~3.18.3"
"@microsoft/node-core-library@3.10.0":
version "3.10.0"
resolved "https://registry.yarnpkg.com/@microsoft/node-core-library/-/node-core-library-3.10.0.tgz#70e089534d8e20f6a0f9c7a4a12a6aeafd6a1ddb"
integrity sha512-1SbU+XNYAabhV9noGXHtsUVPc5ELV+oEuJQtZQoCncbOd6WAMeTgB1xFwh96hmdEXyKQyML/pnByiKocmh/nbQ==
dependencies:
"@types/fs-extra" "5.0.4"
"@types/jju" "~1.4.0"
"@types/node" "8.5.8"
"@types/z-schema" "3.16.31"
colors "~1.2.1"
fs-extra "~7.0.1"
jju "~1.4.0"
z-schema "~3.18.3"
"@microsoft/ts-command-line@4.2.3":
version "4.2.3"
resolved "https://registry.yarnpkg.com/@microsoft/ts-command-line/-/ts-command-line-4.2.3.tgz#20d6a1684148b9fc0df25ee7335c3bb227d47d4f"
integrity sha512-SIs4q7RcG7efBbh5Ffrf6V4jVLxWihD4NDRY3+gPiOG8CYawBzE22tTEloZ1yj/FBvBZQkQ0GYwXoPhn6ElYXA==
dependencies:
"@types/argparse" "1.0.33"
"@types/node" "8.5.8"
argparse "~1.0.9"
colors "~1.2.1"
"@microsoft/tsdoc@0.12.5":
version "0.12.5"
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.12.5.tgz#c448a38902ccb5601c1b2ef3b1a105012ef7712c"
integrity sha512-xEAyvLXo4Cter/b0EMCWUZTgXOfLOPJ/Xr52WdjVclPx9eDmNTGFtZl8Pn/nqSnZsQBNcHL0eHk/YyRyyXXpiQ==
"@schematics/angular@7.3.0-rc.0": "@schematics/angular@7.3.0-rc.0":
version "7.3.0-rc.0" version "7.3.0-rc.0"
resolved "https://registry.yarnpkg.com/@schematics/angular/-/angular-7.3.0-rc.0.tgz#7519aa692dcaed63b9caa7d824846511905b1bfc" resolved "https://registry.yarnpkg.com/@schematics/angular/-/angular-7.3.0-rc.0.tgz#7519aa692dcaed63b9caa7d824846511905b1bfc"
@ -162,11 +208,43 @@
semver "5.6.0" semver "5.6.0"
semver-intersect "1.4.0" semver-intersect "1.4.0"
"@types/argparse@1.0.33":
version "1.0.33"
resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.33.tgz#2728669427cdd74a99e53c9f457ca2866a37c52d"
integrity sha512-VQgHxyPMTj3hIlq9SY1mctqx+Jj8kpQfoLvDlVSDNOyuYs8JYfkuY3OW/4+dO657yPmNhHpePRx0/Tje5ImNVQ==
"@types/fs-extra@5.0.4":
version "5.0.4"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.4.tgz#b971134d162cc0497d221adde3dbb67502225599"
integrity sha512-DsknoBvD8s+RFfSGjmERJ7ZOP1HI0UZRA3FSI+Zakhrc/Gy26YQsLI+m5V5DHxroHRJqCDLKJp7Hixn8zyaF7g==
dependencies:
"@types/node" "*"
"@types/jju@~1.4.0":
version "1.4.1"
resolved "https://registry.yarnpkg.com/@types/jju/-/jju-1.4.1.tgz#0a39f5f8e84fec46150a7b9ca985c3f89ad98e9f"
integrity sha512-LFt+YA7Lv2IZROMwokZKiPNORAV5N3huMs3IKnzlE430HWhWYZ8b+78HiwJXJJP1V2IEjinyJURuRJfGoaFSIA==
"@types/node@*":
version "11.9.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.9.4.tgz#ceb0048a546db453f6248f2d1d95e937a6f00a14"
integrity sha512-Zl8dGvAcEmadgs1tmSPcvwzO1YRsz38bVJQvH1RvRqSR9/5n61Q1ktcDL0ht3FXWR+ZpVmXVwN1LuH4Ax23NsA==
"@types/node@6.0.84": "@types/node@6.0.84":
version "6.0.84" version "6.0.84"
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.84.tgz#193ffe5a9f42864d425ffd9739d95b753c6a1eab" resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.84.tgz#193ffe5a9f42864d425ffd9739d95b753c6a1eab"
integrity sha512-1SvEazClhUBRNroJM3oB3xf3u2r6xGmHDGbdigqNPHvNKLl8/BtATgO9eC04ZLuovpSh0B20BF1QJxdi+qmTlg== integrity sha512-1SvEazClhUBRNroJM3oB3xf3u2r6xGmHDGbdigqNPHvNKLl8/BtATgO9eC04ZLuovpSh0B20BF1QJxdi+qmTlg==
"@types/node@8.5.8":
version "8.5.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.5.8.tgz#92509422653f10e9c0ac18d87e0610b39f9821c7"
integrity sha512-8KmlRxwbKZfjUHFIt3q8TF5S2B+/E5BaAoo/3mgc5h6FJzqxXkCK/VMetO+IRDtwtU6HUvovHMBn+XRj7SV9Qg==
"@types/z-schema@3.16.31":
version "3.16.31"
resolved "https://registry.yarnpkg.com/@types/z-schema/-/z-schema-3.16.31.tgz#2eb1d00a5e4ec3fa58c76afde12e182b66dc5c1c"
integrity sha1-LrHQCl5Ow/pYx2r94S4YK2bcXBw=
"@yarnpkg/lockfile@1.1.0": "@yarnpkg/lockfile@1.1.0":
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
@ -277,6 +355,13 @@ are-we-there-yet@~1.1.2:
delegates "^1.0.0" delegates "^1.0.0"
readable-stream "^2.0.6" readable-stream "^2.0.6"
argparse@~1.0.9:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
dependencies:
sprintf-js "~1.0.2"
arr-diff@^4.0.0: arr-diff@^4.0.0:
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520"
@ -529,11 +614,21 @@ color-name@1.1.3:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
colors@~1.2.1:
version "1.2.5"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.5.tgz#89c7ad9a374bc030df8013241f68136ed8835afc"
integrity sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==
colour@~0.7.1: colour@~0.7.1:
version "0.7.1" version "0.7.1"
resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778"
integrity sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g= integrity sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g=
commander@^2.7.1:
version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
component-emitter@^1.2.1: component-emitter@^1.2.1:
version "1.2.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
@ -811,6 +906,15 @@ from2@^2.1.0:
inherits "^2.0.1" inherits "^2.0.1"
readable-stream "^2.0.0" readable-stream "^2.0.0"
fs-extra@~7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"
fs-minipass@^1.2.5: fs-minipass@^1.2.5:
version "1.2.5" version "1.2.5"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
@ -892,7 +996,7 @@ glob@^7.0.0, glob@^7.0.5, glob@^7.1.3:
once "^1.3.0" once "^1.3.0"
path-is-absolute "^1.0.0" path-is-absolute "^1.0.0"
graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.15" version "4.1.15"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==
@ -1211,6 +1315,11 @@ jasmine-core@2.8.0:
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e" resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e"
integrity sha1-vMl5rh+f0FcB5F5S5l06XWPxok4= integrity sha1-vMl5rh+f0FcB5F5S5l06XWPxok4=
jju@~1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a"
integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo=
json-parse-better-errors@^1.0.0: json-parse-better-errors@^1.0.0:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
@ -1221,6 +1330,13 @@ json-schema-traverse@^0.4.1:
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
optionalDependencies:
graceful-fs "^4.1.6"
jsonparse@^1.2.0: jsonparse@^1.2.0:
version "1.3.1" version "1.3.1"
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
@ -1262,7 +1378,17 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
lodash@^4.17.10: lodash.get@^4.0.0:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
lodash.isequal@^4.0.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
lodash@^4.17.10, lodash@~4.17.5:
version "4.17.11" version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
@ -1706,7 +1832,7 @@ path-is-absolute@^1.0.0:
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
path-parse@^1.0.6: path-parse@^1.0.5, path-parse@^1.0.6:
version "1.0.6" version "1.0.6"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
@ -1853,6 +1979,13 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=
resolve@1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
integrity sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==
dependencies:
path-parse "^1.0.5"
resolve@^1.1.6: resolve@^1.1.6:
version "1.10.0" version "1.10.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.0.tgz#3bdaaeaf45cc07f375656dfd2e54ed0810b101ba" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.0.tgz#3bdaaeaf45cc07f375656dfd2e54ed0810b101ba"
@ -2102,6 +2235,11 @@ split-string@^3.0.1, split-string@^3.0.2:
dependencies: dependencies:
extend-shallow "^3.0.0" extend-shallow "^3.0.0"
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
ssri@^6.0.0, ssri@^6.0.1: ssri@^6.0.0, ssri@^6.0.1:
version "6.0.1" version "6.0.1"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
@ -2281,6 +2419,11 @@ typescript@3.2.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5"
integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg== integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==
typescript@~3.1.6:
version "3.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.6.tgz#b6543a83cfc8c2befb3f4c8fba6896f5b0c9be68"
integrity sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==
union-value@^1.0.0: union-value@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4"
@ -2305,6 +2448,11 @@ unique-slug@^2.0.0:
dependencies: dependencies:
imurmurhash "^0.1.4" imurmurhash "^0.1.4"
universalify@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
unset-value@^1.0.0: unset-value@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"
@ -2355,6 +2503,11 @@ validate-npm-package-name@^3.0.0:
dependencies: dependencies:
builtins "^1.0.3" builtins "^1.0.3"
validator@^8.0.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/validator/-/validator-8.2.0.tgz#3c1237290e37092355344fef78c231249dab77b9"
integrity sha512-Yw5wW34fSv5spzTXNkokD6S6/Oq92d8q/t14TqsS3fAiA1RYnxSFSIZ+CY3n6PGGRCq5HhJTSepQvFUS2QUDxA==
which@^1.3.1: which@^1.3.1:
version "1.3.1" version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
@ -2424,3 +2577,14 @@ yargs@^3.10.0:
string-width "^1.0.1" string-width "^1.0.1"
window-size "^0.1.4" window-size "^0.1.4"
y18n "^3.2.0" y18n "^3.2.0"
z-schema@~3.18.3:
version "3.18.4"
resolved "https://registry.yarnpkg.com/z-schema/-/z-schema-3.18.4.tgz#ea8132b279533ee60be2485a02f7e3e42541a9a2"
integrity sha512-DUOKC/IhbkdLKKiV89gw9DUauTV8U/8yJl1sjf6MtDmzevLKOF2duNJ495S3MFVjqZarr+qNGCPbkg4mu4PpLw==
dependencies:
lodash.get "^4.0.0"
lodash.isequal "^4.0.0"
validator "^8.0.0"
optionalDependencies:
commander "^2.7.1"

View File

@ -20,14 +20,6 @@ http_archive(
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/%s/rules_nodejs-%s.tar.gz" % (RULES_NODEJS_VERSION, RULES_NODEJS_VERSION), url = "https://github.com/bazelbuild/rules_nodejs/releases/download/%s/rules_nodejs-%s.tar.gz" % (RULES_NODEJS_VERSION, RULES_NODEJS_VERSION),
) )
# The @angular repo contains rule for building Angular applications
ANGULAR_VERSION = "<%= ANGULAR_VERSION %>"
http_archive(
name = "angular",
url = "https://github.com/angular/angular/archive/%s.zip" % ANGULAR_VERSION,
strip_prefix = "angular-%s" % ANGULAR_VERSION,
)
<% if (sass) { %> <% if (sass) { %>
# Rules for compiling sass # Rules for compiling sass
RULES_SASS_VERSION = "<%= RULES_SASS_VERSION %>" RULES_SASS_VERSION = "<%= RULES_SASS_VERSION %>"
@ -46,9 +38,7 @@ 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 data = ["//:angular-metadata.tsconfig.json"],
# 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",
) )
@ -72,5 +62,5 @@ ts_setup_workspace()
load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories") load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
sass_repositories() sass_repositories()
<% } %> <% } %>
load("@angular//:index.bzl", "ng_setup_workspace") load("@npm_angular_bazel//:index.bzl", "ng_setup_workspace")
ng_setup_workspace() ng_setup_workspace()

View File

@ -1,5 +1,5 @@
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "protractor_web_test_suite") load("@npm_angular_bazel//:index.bzl", "protractor_web_test_suite")
ts_library( ts_library(
name = "e2e_lib", name = "e2e_lib",
@ -22,7 +22,7 @@ ts_library(
protractor_web_test_suite( protractor_web_test_suite(
name = "prodserver_test", name = "prodserver_test",
data = [ data = [
"@angular//" + "packages/bazel/src/protractor/utils", "@npm//@angular/bazel",
"@npm//protractor", "@npm//protractor",
], ],
on_prepare = ":protractor.on-prepare.js", on_prepare = ":protractor.on-prepare.js",
@ -33,7 +33,7 @@ protractor_web_test_suite(
protractor_web_test_suite( protractor_web_test_suite(
name = "devserver_test", name = "devserver_test",
data = [ data = [
"@angular//" + "packages/bazel/src/protractor/utils", "@npm//@angular/bazel",
"@npm//protractor", "@npm//protractor",
], ],
on_prepare = ":protractor.on-prepare.js", on_prepare = ":protractor.on-prepare.js",

View File

@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("@angular//:index.bzl", "ng_module") load("@npm_angular_bazel//:index.bzl", "ng_module")
load("@build_bazel_rules_karma//:defs.bzl", "ts_web_test_suite") load("@build_bazel_rules_karma//:defs.bzl", "ts_web_test_suite")
load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "history_server") load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "history_server")
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package") load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
@ -37,9 +37,9 @@ ng_module(
"**/*.html", "**/*.html",
])<% if (sass) { %> + [":styles"]<% } %>, ])<% if (sass) { %> + [":styles"]<% } %>,
deps = [ deps = [
"@angular//packages/core", "@npm//@angular/core",
"@angular//packages/platform-browser",<% if (routing) { %> "@npm//@angular/platform-browser",<% if (routing) { %>
"@angular//packages/router",<% } %> "@npm//@angular/router",<% } %>
"@npm//@types", "@npm//@types",
"@npm//rxjs", "@npm//rxjs",
], ],
@ -79,6 +79,10 @@ ts_devserver(
entry_module = "<%= utils.underscore(name) %>/src/main.dev", entry_module = "<%= utils.underscore(name) %>/src/main.dev",
serving_path = "/bundle.min.js", serving_path = "/bundle.min.js",
scripts = [ scripts = [
"@npm//node_modules/@angular/common:bundles/common.umd.js",
"@npm//node_modules/@angular/common:bundles/common-http.umd.js",
"@npm//node_modules/@angular/core:bundles/core.umd.js",
"@npm//node_modules/@angular/platform-browser:bundles/platform-browser.umd.js",
"@npm//node_modules/tslib:tslib.js", "@npm//node_modules/tslib:tslib.js",
":rxjs_umd_modules", ":rxjs_umd_modules",
], ],
@ -95,7 +99,7 @@ ts_library(
srcs = glob(["**/*.spec.ts"]), srcs = glob(["**/*.spec.ts"]),
deps = [ deps = [
":src", ":src",
"@angular//packages/core/testing", "@npm//@angular/core",
"@npm//@types", "@npm//@types",
], ],
) )
@ -107,15 +111,26 @@ ts_library(
"initialize_testbed.ts", "initialize_testbed.ts",
], ],
deps = [ deps = [
"@angular//packages/core/testing", "@npm//@angular/core",
"@angular//packages/platform-browser-dynamic/testing", "@npm//@angular/platform-browser-dynamic",
"@npm//@types", "@npm//@types",
], ],
) )
ts_web_test_suite( ts_web_test_suite(
name = "test", name = "test",
srcs = ["@npm//node_modules/tslib:tslib.js"], srcs = [
"@npm//node_modules/@angular/common:bundles/common.umd.js",
"@npm//node_modules/@angular/compiler:bundles/compiler.umd.js",
"@npm//node_modules/@angular/compiler:bundles/compiler-testing.umd.js",
"@npm//node_modules/@angular/core:bundles/core.umd.js",
"@npm//node_modules/@angular/core:bundles/core-testing.umd.js",
"@npm//node_modules/@angular/platform-browser:bundles/platform-browser.umd.js",
"@npm//node_modules/@angular/platform-browser:bundles/platform-browser-testing.umd.js",
"@npm//node_modules/@angular/platform-browser-dynamic:bundles/platform-browser-dynamic.umd.js",
"@npm//node_modules/@angular/platform-browser-dynamic:bundles/platform-browser-dynamic-testing.umd.js",
"@npm//node_modules/tslib:tslib.js",
],
runtime_deps = [ runtime_deps = [
":initialize_testbed", ":initialize_testbed",
], ],

View File

@ -9,32 +9,12 @@
*/ */
import {strings} from '@angular-devkit/core'; import {strings} from '@angular-devkit/core';
import {Rule, SchematicContext, SchematicsException, Tree, apply, applyTemplates, mergeWith, move, url} from '@angular-devkit/schematics'; import {Rule, SchematicContext, Tree, apply, applyTemplates, mergeWith, url} from '@angular-devkit/schematics';
import {getWorkspace} from '@schematics/angular/utility/config'; import {getWorkspace} from '@schematics/angular/utility/config';
import {latestVersions} from '@schematics/angular/utility/latest-versions';
import {validateProjectName} from '@schematics/angular/utility/validation'; import {validateProjectName} from '@schematics/angular/utility/validation';
import {Schema as BazelWorkspaceOptions} from './schema'; import {Schema as BazelWorkspaceOptions} from './schema';
/**
* Look for package.json file for package with `packageName` in node_modules and
* extract its version.
*/
function findVersion(packageName: string, host: Tree): string|null {
const candidate = `node_modules/${packageName}/package.json`;
if (host.exists(candidate)) {
try {
const packageJson = JSON.parse(host.read(candidate).toString());
if (packageJson.name === packageName && packageJson.version) {
return packageJson.version;
}
} catch {
}
}
return null;
}
/** /**
* Clean the version string and return version in the form "1.2.3". Return * Clean the version string and return version in the form "1.2.3". Return
* null if version string is invalid. This is similar to semver.clean() but * null if version string is invalid. This is similar to semver.clean() but
@ -72,20 +52,6 @@ export default function(options: BazelWorkspaceOptions): Rule {
} }
validateProjectName(name); validateProjectName(name);
// If the project already has some deps installed, Bazel should use existing
// versions.
const existingVersions = {
Angular: findVersion('@angular/core', host),
RxJs: findVersion('rxjs', host),
};
Object.keys(existingVersions).forEach((name: 'Angular' | 'RxJs') => {
const version = existingVersions[name] as string;
if (version) {
context.logger.info(`Bazel will reuse existing version for ${name}: ${version}`);
}
});
if (!host.exists('yarn.lock')) { if (!host.exists('yarn.lock')) {
host.create('yarn.lock', ''); host.create('yarn.lock', '');
} }
@ -93,8 +59,6 @@ export default function(options: BazelWorkspaceOptions): Rule {
const workspaceVersions = { const workspaceVersions = {
'RULES_NODEJS_VERSION': '0.18.6', 'RULES_NODEJS_VERSION': '0.18.6',
'RULES_NODEJS_SHA256': '1416d03823fed624b49a0abbd9979f7c63bbedfd37890ddecedd2fe25cccebc6', 'RULES_NODEJS_SHA256': '1416d03823fed624b49a0abbd9979f7c63bbedfd37890ddecedd2fe25cccebc6',
'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
// TODO(kyliau): Consider moving this to latest-versions.ts
'RULES_SASS_VERSION': '1.17.0', 'RULES_SASS_VERSION': '1.17.0',
}; };

View File

@ -61,7 +61,7 @@ describe('Bazel-workspace Schematic', () => {
host = schematicRunner.runSchematic('bazel-workspace', options, host); host = schematicRunner.runSchematic('bazel-workspace', options, host);
expect(host.files).toContain('/src/BUILD.bazel'); expect(host.files).toContain('/src/BUILD.bazel');
const content = host.readContent('/src/BUILD.bazel'); const content = host.readContent('/src/BUILD.bazel');
expect(content).toContain('@angular//packages/router'); expect(content).toContain('@npm//@angular/router');
}); });
describe('WORKSPACE', () => { describe('WORKSPACE', () => {

View File

@ -44,7 +44,6 @@ function addDevDependenciesToPackageJson(options: Schema) {
const devDependencies: {[k: string]: string} = { const devDependencies: {[k: string]: string} = {
'@angular/bazel': angularCoreVersion, '@angular/bazel': angularCoreVersion,
'@angular/upgrade': angularCoreVersion, '@angular/upgrade': angularCoreVersion,
// TODO(kyliau): Consider moving this to latest-versions.ts
'@bazel/bazel': '^0.22.1', '@bazel/bazel': '^0.22.1',
'@bazel/ibazel': '^0.9.0', '@bazel/ibazel': '^0.9.0',
'@bazel/karma': '^0.23.2', '@bazel/karma': '^0.23.2',