build: make the build scripts for the various packages consistent (#41429)
This commit makes the build scripts for the various packages (framework, `@angular/dev-infra-private`, `angular-in-memory-web-api`, `zone.js`) consistent. This makes it easier to maintain them (e.g. make similar changes across all build scripts). PR Close #41429
This commit is contained in:
parent
a623bf4e70
commit
3c48037d24
|
@ -8,29 +8,42 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {chmod, cp, mkdir, rm} = require('shelljs');
|
const {resolve} = require('path');
|
||||||
|
const {chmod, cp, mkdir, rm, test} = require('shelljs');
|
||||||
const {baseDir, bazelBin, bazelCmd, exec, scriptPath} = require('./package-builder');
|
const {baseDir, bazelBin, bazelCmd, exec, scriptPath} = require('./package-builder');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
buildAngularInMemoryWebApiPackage,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the `angular-in-memory-web-api` npm package and copy it to `dist/packages-dist/misc`.
|
* Build the `angular-in-memory-web-api` npm package and copy it to `destDir` for other
|
||||||
|
* scripts/tests to use.
|
||||||
|
*
|
||||||
|
* @param {string} destDir Path to the output directory into which we copy the npm package.
|
||||||
|
* This path should either be absolute or relative to the project root.
|
||||||
*/
|
*/
|
||||||
function buildAngularInMemoryWebAPIPackage() {
|
function buildAngularInMemoryWebApiPackage(destDir) {
|
||||||
console.info('##############################');
|
console.info('##############################');
|
||||||
console.info(`${scriptPath}:`);
|
console.info(`${scriptPath}:`);
|
||||||
console.info(' Building angular-in-memory-web-api npm package');
|
console.info(' Building angular-in-memory-web-api npm package');
|
||||||
console.info('##############################');
|
console.info('##############################');
|
||||||
exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package`);
|
exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package`);
|
||||||
|
|
||||||
|
// Create the output directory.
|
||||||
|
const absDestDir = resolve(baseDir, destDir);
|
||||||
|
if (!test('-d', absDestDir)) {
|
||||||
|
mkdir('-p', absDestDir);
|
||||||
|
}
|
||||||
|
|
||||||
const buildOutputDir = `${bazelBin}/packages/misc/angular-in-memory-web-api/npm_package`;
|
const buildOutputDir = `${bazelBin}/packages/misc/angular-in-memory-web-api/npm_package`;
|
||||||
const distTargetDir = `${baseDir}/dist/packages-dist/misc/angular-in-memory-web-api`;
|
const distTargetDir = `${absDestDir}/angular-in-memory-web-api`;
|
||||||
|
|
||||||
console.info(`# Copy artifacts to ${distTargetDir}`);
|
console.info(`# Copy artifacts to ${distTargetDir}`);
|
||||||
mkdir('-p', distTargetDir);
|
|
||||||
rm('-rf', distTargetDir);
|
rm('-rf', distTargetDir);
|
||||||
cp('-R', buildOutputDir, distTargetDir);
|
cp('-R', buildOutputDir, distTargetDir);
|
||||||
chmod('-R', 'u+w', distTargetDir);
|
chmod('-R', 'u+w', distTargetDir);
|
||||||
|
|
||||||
console.info('');
|
console.info('');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {buildAngularInMemoryWebAPIPackage};
|
|
||||||
|
|
|
@ -9,22 +9,22 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {buildZoneJsPackage} = require('./zone-js-builder');
|
const {buildAngularInMemoryWebApiPackage} = require('./angular-in-memory-web-api');
|
||||||
const {buildDevInfraPackage} = require('./dev-infra-builder');
|
const {buildDevInfraPackage} = require('./dev-infra-builder');
|
||||||
const {buildTargetPackages} = require('./package-builder');
|
const {buildTargetPackages} = require('./package-builder');
|
||||||
const {buildAngularInMemoryWebAPIPackage} = require('./angular-in-memory-web-api');
|
const {buildZoneJsPackage} = require('./zone-js-builder');
|
||||||
|
|
||||||
|
|
||||||
// Build the legacy (view engine) npm packages into `dist/packages-dist/`.
|
// Build the legacy (view engine) npm packages into `dist/packages-dist/`.
|
||||||
buildTargetPackages('dist/packages-dist', false, 'Production');
|
buildTargetPackages('dist/packages-dist', false, 'Production');
|
||||||
|
|
||||||
|
// Build the `angular-dev-infra` npm package into `dist/packages-dist/`.
|
||||||
|
buildDevInfraPackage('dist/packages-dist');
|
||||||
|
|
||||||
|
// Build the `angular-in-memory-web-api` npm package into `dist/packages-dist/misc/`, because it
|
||||||
|
// might be needed by other scripts/targets.
|
||||||
|
buildAngularInMemoryWebApiPackage('dist/packages-dist/misc');
|
||||||
|
|
||||||
// Build the `zone.js` npm package into `dist/zone.js-dist/`, because it might be needed by other
|
// Build the `zone.js` npm package into `dist/zone.js-dist/`, because it might be needed by other
|
||||||
// scripts/tests.
|
// scripts/tests.
|
||||||
buildZoneJsPackage('dist/zone.js-dist');
|
buildZoneJsPackage('dist/zone.js-dist');
|
||||||
|
|
||||||
// Build the `angular-dev-infra` npm package into `dist/packages-dist/@angular/dev-infra-private`
|
|
||||||
buildDevInfraPackage();
|
|
||||||
|
|
||||||
// Build the `angular-in-memory-web-api` npm package into
|
|
||||||
// `dist/packages-dist/misc/angular-in-memory-web-api`
|
|
||||||
buildAngularInMemoryWebAPIPackage();
|
|
||||||
|
|
|
@ -8,29 +8,41 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {chmod, cp, mkdir, rm} = require('shelljs');
|
const {resolve} = require('path');
|
||||||
|
const {chmod, cp, mkdir, rm, test} = require('shelljs');
|
||||||
const {baseDir, bazelBin, bazelCmd, exec, scriptPath} = require('./package-builder');
|
const {baseDir, bazelBin, bazelCmd, exec, scriptPath} = require('./package-builder');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
buildDevInfraPackage,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the `@angular/dev-infra-private` npm package and copies it to `dist/packages-dist`.
|
* Build the `@angular/dev-infra-private` npm package into `destDir`.
|
||||||
|
*
|
||||||
|
* @param {string} destDir Path to the output directory into which we copy the npm package.
|
||||||
|
* This path should either be absolute or relative to the project root.
|
||||||
*/
|
*/
|
||||||
function buildDevInfraPackage() {
|
function buildDevInfraPackage(destDir) {
|
||||||
console.info('##############################');
|
console.info('##############################');
|
||||||
console.info(`${scriptPath}:`);
|
console.info(`${scriptPath}:`);
|
||||||
console.info(' Building @angular/dev-infra-private npm package');
|
console.info(' Building @angular/dev-infra-private npm package');
|
||||||
console.info('##############################');
|
console.info('##############################');
|
||||||
exec(`${bazelCmd} build //dev-infra:npm_package`);
|
exec(`${bazelCmd} build //dev-infra:npm_package`);
|
||||||
|
|
||||||
|
// Create the output directory.
|
||||||
|
const absDestDir = resolve(baseDir, destDir);
|
||||||
|
if (!test('-d', absDestDir)) {
|
||||||
|
mkdir('-p', absDestDir);
|
||||||
|
}
|
||||||
|
|
||||||
const buildOutputDir = `${bazelBin}/dev-infra/npm_package`;
|
const buildOutputDir = `${bazelBin}/dev-infra/npm_package`;
|
||||||
const distTargetDir = `${baseDir}/dist/packages-dist/dev-infra-private`;
|
const distTargetDir = `${absDestDir}/dev-infra-private`;
|
||||||
|
|
||||||
console.info(`# Copy artifacts to ${distTargetDir}`);
|
console.info(`# Copy artifacts to ${distTargetDir}`);
|
||||||
mkdir('-p', distTargetDir);
|
|
||||||
rm('-rf', distTargetDir);
|
rm('-rf', distTargetDir);
|
||||||
cp('-R', buildOutputDir, distTargetDir);
|
cp('-R', buildOutputDir, distTargetDir);
|
||||||
chmod('-R', 'u+w', distTargetDir);
|
chmod('-R', 'u+w', distTargetDir);
|
||||||
|
|
||||||
console.info('');
|
console.info('');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {buildDevInfraPackage};
|
|
||||||
|
|
|
@ -58,14 +58,14 @@ module.exports = {
|
||||||
/**
|
/**
|
||||||
* Build the Angular packages.
|
* Build the Angular packages.
|
||||||
*
|
*
|
||||||
* @param {string} destPath Path to the output directory into which we copy the npm packages.
|
* @param {string} destDir Path to the output directory into which we copy the npm packages.
|
||||||
* This path should either be absolute or relative to the project root.
|
* This path should either be absolute or relative to the project root.
|
||||||
* @param {boolean} enableIvy True, if Ivy should be used.
|
* @param {boolean} enableIvy True, if Ivy should be used.
|
||||||
* @param {string} description Human-readable description of the build.
|
* @param {string} description Human-readable description of the build.
|
||||||
* @param {boolean?} isRelease True, if the build should be stamped for a release.
|
* @param {boolean?} isRelease True, if the build should be stamped for a release.
|
||||||
* @returns {Array<{name: string, outputPath: string}} A list of packages built.
|
* @returns {Array<{name: string, outputPath: string}} A list of packages built.
|
||||||
*/
|
*/
|
||||||
function buildTargetPackages(destPath, enableIvy, description, isRelease = false) {
|
function buildTargetPackages(destDir, enableIvy, description, isRelease = false) {
|
||||||
console.info('##################################');
|
console.info('##################################');
|
||||||
console.info(`${scriptPath}:`);
|
console.info(`${scriptPath}:`);
|
||||||
console.info(' Building @angular/* npm packages');
|
console.info(' Building @angular/* npm packages');
|
||||||
|
@ -87,15 +87,17 @@ function buildTargetPackages(destPath, enableIvy, description, isRelease = false
|
||||||
enableIvy ? 'ivy' : 'view-engine'} ${targets.join(' ')}`);
|
enableIvy ? 'ivy' : 'view-engine'} ${targets.join(' ')}`);
|
||||||
|
|
||||||
// Create the output directory.
|
// Create the output directory.
|
||||||
const absDestPath = resolve(baseDir, destPath);
|
const absDestDir = resolve(baseDir, destDir);
|
||||||
if (!test('-d', absDestPath)) mkdir('-p', absDestPath);
|
if (!test('-d', absDestDir)) {
|
||||||
|
mkdir('-p', absDestDir);
|
||||||
|
}
|
||||||
|
|
||||||
targets.forEach(target => {
|
targets.forEach(target => {
|
||||||
const pkg = target.replace(/\/\/packages\/(.*):npm_package/, '$1');
|
const pkg = target.replace(/\/\/packages\/(.*):npm_package/, '$1');
|
||||||
|
|
||||||
// Skip any that don't have an "npm_package" target.
|
// Skip any that don't have an "npm_package" target.
|
||||||
const srcDir = `${bazelBin}/packages/${pkg}/npm_package`;
|
const srcDir = `${bazelBin}/packages/${pkg}/npm_package`;
|
||||||
const destDir = `${absDestPath}/${pkg}`;
|
const destDir = `${absDestDir}/${pkg}`;
|
||||||
|
|
||||||
if (test('-d', srcDir)) {
|
if (test('-d', srcDir)) {
|
||||||
console.info(`# Copy artifacts to ${destDir}`);
|
console.info(`# Copy artifacts to ${destDir}`);
|
||||||
|
|
|
@ -20,17 +20,17 @@ module.exports = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the `zone.js` npm package into `dist/bin/packages/zone.js/npm_package/` and copy it to
|
* Build the `zone.js` npm package into `dist/bin/packages/zone.js/npm_package/` and copy it to
|
||||||
* `destPath` for other scripts/tests to use.
|
* `destDir` for other scripts/tests to use.
|
||||||
*
|
*
|
||||||
* NOTE: The `zone.js` package is not built as part of `package-builder`'s `buildTargetPackages()`
|
* NOTE: The `zone.js` package is not built as part of `package-builder`'s `buildTargetPackages()`
|
||||||
* nor is it copied into the same directory as the Angular packages (e.g.
|
* nor is it copied into the same directory as the Angular packages (e.g.
|
||||||
* `dist/packages-dist/`) despite its source's being inside `packages/`, because it is not
|
* `dist/packages-dist/`) despite its source's being inside `packages/`, because it is not
|
||||||
* published to npm under the `@angular` scope (as happens for the rest of the packages).
|
* published to npm under the `@angular` scope (as happens for the rest of the packages).
|
||||||
*
|
*
|
||||||
* @param {string} destPath Path to the output directory into which we copy the npm package.
|
* @param {string} destDir Path to the output directory into which we copy the npm package.
|
||||||
* This path should either be absolute or relative to the project root.
|
* This path should either be absolute or relative to the project root.
|
||||||
*/
|
*/
|
||||||
function buildZoneJsPackage(destPath) {
|
function buildZoneJsPackage(destDir) {
|
||||||
console.info('##############################');
|
console.info('##############################');
|
||||||
console.info(`${scriptPath}:`);
|
console.info(`${scriptPath}:`);
|
||||||
console.info(' Building zone.js npm package');
|
console.info(' Building zone.js npm package');
|
||||||
|
@ -38,22 +38,24 @@ function buildZoneJsPackage(destPath) {
|
||||||
exec(`${bazelCmd} run //packages/zone.js:npm_package.pack`);
|
exec(`${bazelCmd} run //packages/zone.js:npm_package.pack`);
|
||||||
|
|
||||||
// Create the output directory.
|
// Create the output directory.
|
||||||
const absDestPath = resolve(baseDir, destPath);
|
const absDestDir = resolve(baseDir, destDir);
|
||||||
if (!test('-d', absDestPath)) mkdir('-p', absDestPath);
|
if (!test('-d', absDestDir)) {
|
||||||
|
mkdir('-p', absDestDir);
|
||||||
|
}
|
||||||
|
|
||||||
// Copy artifacts to `destPath`, so they can be easier persisted on CI and used by non-bazel
|
// Copy artifacts to `destDir`, so they can be easier persisted on CI and used by non-bazel
|
||||||
// scripts/tests.
|
// scripts/tests.
|
||||||
const buildOutputDir = `${bazelBin}/packages/zone.js/npm_package`;
|
const buildOutputDir = `${bazelBin}/packages/zone.js/npm_package`;
|
||||||
const distTargetDir = `${absDestPath}/zone.js`;
|
const distTargetDir = `${absDestDir}/zone.js`;
|
||||||
|
|
||||||
console.info(`# Copy npm_package artifacts to ${distTargetDir}`);
|
console.info(`# Copy npm_package artifacts to ${distTargetDir}`);
|
||||||
rm('-rf', distTargetDir);
|
rm('-rf', distTargetDir);
|
||||||
cp('-R', buildOutputDir, distTargetDir);
|
cp('-R', buildOutputDir, distTargetDir);
|
||||||
chmod('-R', 'u+w', distTargetDir);
|
chmod('-R', 'u+w', distTargetDir);
|
||||||
|
|
||||||
// Copy `zone.js.tgz` to `destPath`, so we can test
|
// Copy `zone.js.tgz` to `destDir`, so we can test
|
||||||
// the archive generated by the `npm_package.pack` rule.
|
// the archive generated by the `npm_package.pack` rule.
|
||||||
const distArchiveTargetDir = `${absDestPath}/archive`;
|
const distArchiveTargetDir = `${absDestDir}/archive`;
|
||||||
console.info(`# Copy npm_package archive file to ${distArchiveTargetDir}`);
|
console.info(`# Copy npm_package archive file to ${distArchiveTargetDir}`);
|
||||||
rm('-rf', distArchiveTargetDir);
|
rm('-rf', distArchiveTargetDir);
|
||||||
mkdir('-p', distArchiveTargetDir);
|
mkdir('-p', distArchiveTargetDir);
|
||||||
|
|
Loading…
Reference in New Issue