From 21f2a6b1b510f85615acfcc13f47d1c46be106c9 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 7 Mar 2018 16:26:52 -0800 Subject: [PATCH] build: fix build.sh for package group and add a test --- build.sh | 2 +- integration/ng_update/check.js | 42 ++++++++++++++++++++++++++++++ integration/ng_update/package.json | 30 +++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 integration/ng_update/check.js create mode 100644 integration/ng_update/package.json diff --git a/build.sh b/build.sh index e9334f1a59fe2..f94a03c4cb44a 100755 --- a/build.sh +++ b/build.sh @@ -34,7 +34,7 @@ NODE_PACKAGES=(compiler-cli benchpress) SCOPED_PACKAGES=$( - for P in ${PACKAGES[@]}; do echo @angular/${P}; done + for P in ${PACKAGES[@]}; do echo \\@angular/${P}; done ) NG_UPDATE_PACKAGE_GROUP=$( # The first sed creates an array of strings diff --git a/integration/ng_update/check.js b/integration/ng_update/check.js new file mode 100644 index 0000000000000..9b1898a23bc57 --- /dev/null +++ b/integration/ng_update/check.js @@ -0,0 +1,42 @@ +const fs = require('fs'); +const path = require('path'); + +const angularRoot = path.resolve('./node_modules/@angular'); +const angularModules = fs.readdirSync(angularRoot).map(function (name) { + const content = fs.readFileSync(path.join(angularRoot, name, 'package.json'), 'utf-8').toString(); + return JSON.parse(content); +}).reduce(function (acc, packageJson) { + acc[packageJson.name] = packageJson; + return acc; +}, Object.create(null)); + +var error = false; +Object.keys(angularModules).forEach(function (name) { + packageJson = angularModules[name]; + + const ngUpdate = packageJson['ng-update']; + if (!ngUpdate) { + console.error('Package ' + JSON.stringify(name) + ' does not have an "ng-update" key.'); + error = true; + return; + } + + const packageGroup = ngUpdate['packageGroup']; + if (!packageGroup) { + console.error('Package ' + JSON.stringify(name) + ' does not have a "packageGroup" key.'); + error = true; + return; + } + + // Verify that every packageGroup is represented in the list of modules. + Object.keys(angularModules).forEach(function (groupEntry) { + if (packageGroup.indexOf(groupEntry) == -1) { + console.error('Package ' + JSON.stringify(name) + ' is missing ' + JSON.stringify(groupEntry) + + ' as a packageGroup entry.'); + error = true; + return; + } + }); +}); + +process.exit(error ? 1 : 0); diff --git a/integration/ng_update/package.json b/integration/ng_update/package.json new file mode 100644 index 0000000000000..0bd79d2311e02 --- /dev/null +++ b/integration/ng_update/package.json @@ -0,0 +1,30 @@ +{ + "name": "ng_update", + "version": "0.0.0", + "scripts": { + "build": "", + "test": "node ./check.js" + }, + "license": "MIT", + "dependencies": { + "@angular/animations": "file:../../dist/packages-dist/animations", + "@angular/common": "file:../../dist/packages-dist/common", + "@angular/compiler": "file:../../dist/packages-dist/compiler", + "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", + "@angular/core": "file:../../dist/packages-dist/core", + "@angular/forms": "file:../../dist/packages-dist/forms", + "@angular/http": "file:../../dist/packages-dist/http", + "@angular/language-service": "file:../../dist/packages-dist/language-service", + "@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", + "@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic", + "@angular/platform-server": "file:../../dist/packages-dist/platform-server", + "@angular/platform-webworker": "file:../../dist/packages-dist/platform-webworker", + "@angular/platform-webworker-dynamic": "file:../../dist/packages-dist/platform-webworker-dynamic", + "@angular/router": "file:../../dist/packages-dist/router", + "@angular/service-worker": "file:../../dist/packages-dist/service-worker", + "@angular/upgrade": "file:../../dist/packages-dist/upgrade", + "rxjs": "file:../../node_modules/rxjs", + "typescript": "file:../../node_modules/typescript", + "zone.js": "file:../../node_modules/zone.js" + } +}