build: fix build.sh for package group and add a test (#22638)

PR Close #22638
This commit is contained in:
Hans Larsen 2018-03-07 16:26:52 -08:00 committed by Miško Hevery
parent dd20898bd5
commit f256c02b5e
3 changed files with 73 additions and 1 deletions

View File

@ -34,7 +34,7 @@ NODE_PACKAGES=(compiler-cli
benchpress) benchpress)
SCOPED_PACKAGES=$( SCOPED_PACKAGES=$(
for P in ${PACKAGES[@]}; do echo @angular/${P}; done for P in ${PACKAGES[@]}; do echo \\@angular/${P}; done
) )
NG_UPDATE_PACKAGE_GROUP=$( NG_UPDATE_PACKAGE_GROUP=$(
# The first sed creates an array of strings # The first sed creates an array of strings

View File

@ -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);

View File

@ -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"
}
}