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:
27
scripts/build-package-dist.js
Executable file
27
scripts/build-package-dist.js
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
// The build script used to be here but has been moved to `scripts/build/` in PR
|
||||
// https://github.com/angular/angular/pull/35780. This is a temporary placeholder script for people
|
||||
// that are not aware of the change and expect to find the script here.
|
||||
//
|
||||
// TODO: This script can be removed early May 2020.
|
||||
'use strict';
|
||||
|
||||
const {red} = require('chalk');
|
||||
const {relative, resolve} = require('path');
|
||||
|
||||
|
||||
const absoluteScriptPath = resolve(`${__dirname}/build/build-packages-dist.js`);
|
||||
const relativeScriptPath = relative(process.cwd(), absoluteScriptPath);
|
||||
|
||||
console.error(red('ERROR: The build script has been moved to \'scripts/build/\'.'));
|
||||
console.error(red(` Run: node ${relativeScriptPath}`));
|
||||
|
||||
process.exit(1);
|
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* @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,
|
||||
buildTargetPackages,
|
||||
exec,
|
||||
scriptPath,
|
||||
} = require('./package-builder');
|
||||
|
||||
|
||||
// Build the legacy (view engine) npm packages into `dist/packages-dist/`.
|
||||
buildTargetPackages('dist/packages-dist', false, 'Production');
|
||||
|
||||
// Build the `zone.js` npm package (into `dist/bin/packages/zone.js/npm_package/`), because it might
|
||||
// be needed by other scripts/tests.
|
||||
//
|
||||
// NOTE: The `zone.js` package is not built as part of `buildTargetPackages()` above, nor is it
|
||||
// copied into the `dist/packages-dist/` directory (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).
|
||||
console.info('');
|
||||
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.
|
||||
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);
|
@ -6,10 +6,11 @@
|
||||
* 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 {buildTargetPackages} = require('./package-builder');
|
||||
|
||||
|
||||
// Build the ivy packages.
|
||||
// Build the ivy packages into `dist/packages-dist-ivy-aot/`.
|
||||
buildTargetPackages('dist/packages-dist-ivy-aot', true, 'Ivy AOT');
|
21
scripts/build/build-packages-dist.js
Executable file
21
scripts/build/build-packages-dist.js
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* @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 {buildZoneJsPackage} = require('./zone-js-builder');
|
||||
const {buildTargetPackages} = require('./package-builder');
|
||||
|
||||
|
||||
// Build the legacy (view engine) npm packages into `dist/packages-dist/`.
|
||||
buildTargetPackages('dist/packages-dist', false, 'Production');
|
||||
|
||||
// Build the `zone.js` npm package into `dist/zone.js-dist/`, because it might be needed by other
|
||||
// scripts/tests.
|
||||
buildZoneJsPackage();
|
6
scripts/package-builder.js → scripts/build/package-builder.js
Executable file → Normal file
6
scripts/package-builder.js → scripts/build/package-builder.js
Executable file → Normal file
@ -31,7 +31,7 @@ set('-e');
|
||||
|
||||
|
||||
/** @type {string} The absolute path to the project root directory. */
|
||||
const baseDir = resolve(`${__dirname}/..`);
|
||||
const baseDir = resolve(`${__dirname}/../..`);
|
||||
|
||||
/** @type {string} The command to use for running bazel. */
|
||||
const bazelCmd = `yarn --cwd "${baseDir}" --silent bazel`;
|
||||
@ -47,7 +47,7 @@ const bazelBin = exec(`${bazelCmd} info bazel-bin`, true);
|
||||
const scriptPath = relative(baseDir, require.main.filename);
|
||||
|
||||
module.exports = {
|
||||
baseDir, bazelBin, bazelCmd, buildTargetPackages, exec, scriptPath,
|
||||
baseDir, bazelBin, bazelCmd, buildTargetPackages, exec, scriptPath,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -93,6 +93,8 @@ function buildTargetPackages(destPath, enableIvy, description) {
|
||||
chmod('-R', 'u+w', destDir);
|
||||
}
|
||||
});
|
||||
|
||||
console.info('');
|
||||
}
|
||||
|
||||
/**
|
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