2020-02-07 02:51:47 -05:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
import {cd, exec, rm, set} from 'shelljs';
|
2020-02-25 14:45:33 -05:00
|
|
|
import * as fs from 'fs';
|
2020-02-07 02:51:47 -05:00
|
|
|
|
|
|
|
// Fail on first error
|
|
|
|
set('-e');
|
|
|
|
|
|
|
|
// Install Angular packages that are built locally from HEAD.
|
|
|
|
// This also gets around the bug whereby yarn caches local `file://` urls.
|
|
|
|
// See https://github.com/yarnpkg/yarn/issues/2165
|
|
|
|
// The below packages are all required in a default CLI project.
|
|
|
|
const ngPackages = [
|
|
|
|
'animations',
|
|
|
|
'core',
|
|
|
|
'common',
|
|
|
|
'compiler',
|
|
|
|
'forms',
|
|
|
|
'platform-browser',
|
|
|
|
'platform-browser-dynamic',
|
|
|
|
'router',
|
|
|
|
'compiler-cli',
|
|
|
|
'language-service',
|
2020-02-25 14:45:33 -05:00
|
|
|
];
|
2020-02-07 02:51:47 -05:00
|
|
|
|
|
|
|
// Keep typescript, tslib, and @types/node versions in sync with the ones used in this repo
|
|
|
|
const nodePackages = [
|
|
|
|
'@types/node',
|
|
|
|
'tslib',
|
|
|
|
'typescript',
|
2020-02-25 14:45:33 -05:00
|
|
|
];
|
2020-02-07 02:51:47 -05:00
|
|
|
|
2020-02-25 14:45:33 -05:00
|
|
|
// Under Bazel integration tests are sand-boxed and cannot reference
|
|
|
|
// reference `../../dist/*` packages and should not do so as these are not
|
|
|
|
// inputs to the test. The npm_integeration_test rule instead provides a manifest
|
|
|
|
// file that contains all of the npm package mappings available to the test.
|
|
|
|
const bazelMappings: { [key: string]: string } = fs.existsSync('NPM_PACKAGE_MANIFEST.json') ? require('./NPM_PACKAGE_MANIFEST.json') : {};
|
|
|
|
|
|
|
|
const packages: { [key: string]: string } = {};
|
|
|
|
for (let p of ngPackages) {
|
|
|
|
const n = `@angular/${p}`;
|
|
|
|
packages[n] = `file:${bazelMappings[n]}` || `file:${__dirname}/../../dist/packages-dist/${p}`;
|
|
|
|
}
|
|
|
|
for (let p of nodePackages) {
|
|
|
|
packages[p] = `file:${bazelMappings[p]}` || `file:${__dirname}/../../node_modules/${p}`;
|
|
|
|
}
|
2020-02-07 02:51:47 -05:00
|
|
|
|
|
|
|
// Clean up previously run test
|
|
|
|
cd(__dirname);
|
|
|
|
rm('-rf', `demo`);
|
|
|
|
|
|
|
|
// Set up demo project
|
|
|
|
exec('ng version');
|
|
|
|
exec('ng new demo --skip-git --skip-install --style=css --no-interactive');
|
|
|
|
cd('demo');
|
|
|
|
|
2020-02-25 14:45:33 -05:00
|
|
|
// Install Angular packages that are built locally from HEAD and npm packages
|
|
|
|
// from root node modules that are to be kept in sync
|
|
|
|
const packageList = Object.keys(packages).map(p => `${p}@${packages[p]}`).join(' ');
|
|
|
|
exec(`yarn add --ignore-scripts --silent ${packageList}`);
|
2020-02-07 02:51:47 -05:00
|
|
|
|
|
|
|
// Add @angular/elements
|
2020-02-25 14:45:33 -05:00
|
|
|
exec(bazelMappings ? `ng add "${bazelMappings['@angular/elements']}"` : `ng add "${__dirname}/../../dist/packages-dist/elements"`);
|
2020-02-07 02:51:47 -05:00
|
|
|
|
|
|
|
// Test that build is successful after adding elements
|
|
|
|
exec('ng build --no-source-map');
|