build: move build scripts to dedicated directory (#35780)
This commit moves the build-related scripts (`build-ivy-npm-packages.js`, `build-packages-dist.js` and `package-builder.js`) to a dedicated directory to keep the `scripts/` directory cleaner. It also moves the logic for building the `zone.js` package to a separate script, `zone-js-builder.js`, to make it re-usable. A subsequent commit will use it to build the `zone.js` package when building the Ivy Angular packages as well. PR Close #35780
This commit is contained in:
47
scripts/build/zone-js-builder.js
Normal file
47
scripts/build/zone-js-builder.js
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const {chmod, cp, mkdir, rm} = require('shelljs');
|
||||
const {baseDir, bazelBin, bazelCmd, exec, scriptPath} = require('./package-builder');
|
||||
|
||||
|
||||
module.exports = {
|
||||
buildZoneJsPackage,
|
||||
};
|
||||
|
||||
/**
|
||||
* Build the `zone.js` npm package into `dist/bin/packages/zone.js/npm_package/` and copy it to
|
||||
* `dist/zone.js-dist/` for other scripts/tests to use.
|
||||
*
|
||||
* 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.
|
||||
* `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).
|
||||
*/
|
||||
function buildZoneJsPackage() {
|
||||
console.info('##############################');
|
||||
console.info(`${scriptPath}:`);
|
||||
console.info(' Building zone.js npm package');
|
||||
console.info('##############################');
|
||||
exec(`${bazelCmd} build //packages/zone.js:npm_package`);
|
||||
|
||||
// Copy artifacts to `dist/zone.js-dist/`, so they can be easier persisted on CI and used by
|
||||
// non-bazel scripts/tests.
|
||||
const buildOutputDir = `${bazelBin}/packages/zone.js/npm_package`;
|
||||
const distTargetDir = `${baseDir}/dist/zone.js-dist/zone.js`;
|
||||
|
||||
console.info(`# Copy artifacts to ${distTargetDir}`);
|
||||
mkdir('-p', distTargetDir);
|
||||
rm('-rf', distTargetDir);
|
||||
cp('-R', buildOutputDir, distTargetDir);
|
||||
chmod('-R', 'u+w', distTargetDir);
|
||||
|
||||
console.info('');
|
||||
}
|
Reference in New Issue
Block a user