Skip to content

Commit d248d83

Browse files
devversionAndrewKushnir
authored andcommitted
build: convert release package build scripts to typescript (angular#46456)
Follow-up to: cce395a. PR Close angular#46456
1 parent 2d713f5 commit d248d83

25 files changed

+258
-324
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ build:release --workspace_status_command="yarn -s ng-dev release build-env-stamp
5353
build:release --stamp
5454

5555
# Snapshots should also be stamped with version control information.
56-
build:snapshot --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=snapshot"
57-
build:snapshot --stamp
56+
build:snapshot-build --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=snapshot"
57+
build:snapshot-build --stamp
5858

5959
###############################
6060
# Output #

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ jobs:
442442
steps:
443443
- custom_attach_workspace
444444
- init_environment
445-
- run: node scripts/build/build-packages-dist.js
445+
- run: yarn build
446446

447447
# Save the npm packages from //packages/... for other workflow jobs to read
448448
- persist_to_workspace:

.ng-dev/release.mts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {ReleaseConfig} from '@angular/dev-infra-private/ng-dev';
2-
import {join} from 'path';
32

43
/** Configuration for the `ng-dev release` command. */
54
export const release: ReleaseConfig = {
@@ -24,12 +23,10 @@ export const release: ReleaseConfig = {
2423
{name: '@angular/upgrade'},
2524
],
2625
buildPackages: async () => {
27-
// The buildTargetPackages function is loaded at runtime as the loading the script causes an
28-
// invocation of bazel.
29-
const packageBuilder = await import('../scripts/build/package-builder.js');
30-
31-
return packageBuilder.default.buildTargetPackages(
32-
'dist/release-output', 'Release', /* isRelease */ true);
26+
// The buildTargetPackages function is loaded at runtime as the loading the script
27+
// causes an invocation of Bazel.
28+
const {performNpmReleaseBuild} = await import('../scripts/build/package-builder.mjs');
29+
return performNpmReleaseBuild();
3330
},
3431
releaseNotes: {
3532
hiddenScopes: ['aio', 'bazel', 'dev-infra', 'docs-infra', 'zone.js', 'devtools'],

aio/tools/ng-packages-installer/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ const ANGULAR_ROOT_DIR = path.resolve(__dirname, '../../..');
1616
const ANGULAR_DIST_PACKAGES_DIR = path.join(ANGULAR_ROOT_DIR, 'dist/packages-dist');
1717
const AIMWA_DIST_PACKAGES_DIR = path.join(ANGULAR_ROOT_DIR, 'dist/angular-in-memory-web-api-dist');
1818
const ZONEJS_DIST_PACKAGES_DIR = path.join(ANGULAR_ROOT_DIR, 'dist/zone.js-dist');
19-
const DIST_PACKAGES_BUILD_SCRIPT = path.join(ANGULAR_ROOT_DIR, 'scripts/build/build-packages-dist.js');
20-
const DIST_PACKAGES_BUILD_CMD = `"${process.execPath}" "${DIST_PACKAGES_BUILD_SCRIPT}"`;
19+
const DIST_PACKAGES_BUILD_CMD = 'yarn -s build';
2120

2221
/**
2322
* A tool that can install Angular/Zone.js dependencies for a project from NPM or from the
@@ -181,14 +180,14 @@ class NgPackagesInstaller {
181180
const canBuild = process.platform !== 'win32';
182181

183182
if (canBuild) {
184-
this._log(`Building the local packages with: ${DIST_PACKAGES_BUILD_SCRIPT}`);
185-
shelljs.exec(DIST_PACKAGES_BUILD_CMD);
183+
this._log(`Building the local packages with: ${DIST_PACKAGES_BUILD_CMD} in ${ANGULAR_ROOT_DIR}`);
184+
shelljs.exec(DIST_PACKAGES_BUILD_CMD, {cwd: ANGULAR_ROOT_DIR});
186185
} else {
187186
this._warn([
188187
'Automatically building the local Angular/angular-in-memory-web-api/zone.js packages is currently not ' +
189188
'supported on Windows.',
190189
`Please, ensure '${ANGULAR_DIST_PACKAGES_DIR}', '${AIMWA_DIST_PACKAGES_DIR}' and ` +
191-
`'${ZONEJS_DIST_PACKAGES_DIR}' exist and are up-to-date (e.g. by running '${DIST_PACKAGES_BUILD_SCRIPT}' ` +
190+
`'${ZONEJS_DIST_PACKAGES_DIR}' exist and are up-to-date (e.g. by running "${DIST_PACKAGES_BUILD_CMD}" ` +
192191
'in Git Bash for Windows, Windows Subsystem for Linux or a Linux docker container or VM).',
193192
'',
194193
'Proceeding anyway...',

aio/tools/ng-packages-installer/index.spec.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,20 @@ describe('NgPackagesInstaller', () => {
305305
};
306306

307307
it('should build the local packages, when not on Windows', () => {
308-
const buildScript = path.join(ngRootDir, 'scripts/build/build-packages-dist.js');
309-
const buildCmd = `"${process.execPath}" "${buildScript}"`;
308+
const buildCmd = 'yarn -s build';
310309

311310
buildDistPackagesOnPlatform('linux');
312-
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd);
311+
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd, {cwd: ngRootDir});
313312

314313
shelljs.exec.calls.reset();
315314

316315
buildDistPackagesOnPlatform('darwin');
317-
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd);
316+
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd, {cwd: ngRootDir});
318317

319318
shelljs.exec.calls.reset();
320319

321320
buildDistPackagesOnPlatform('anythingButWindows :(');
322-
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd);
323-
324-
// Ensure that the script does actually exist (e.g. it was not renamed/moved).
325-
fs.existsSync.and.callThrough();
326-
expect(fs.existsSync(buildScript)).toBe(true);
321+
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd, {cwd: ngRootDir});
327322
});
328323

329324
it('should print a warning, when on Windows', () => {

devtools/src/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pkg_web(
283283
"@npm//:node_modules/tslib/tslib.js",
284284
],
285285
# Currently, ibazel doesn't allow passing in flags to bazel run.
286-
# This means we are not able to use --config snapshot
286+
# This means we are not able to use --config snapshot-build
287287
# to access the current commit SHA.
288288
# Since we still want to be able to use ibazel to speed up
289289
# local development, we supply an empty string for the SHA substitution.

docs/BAZEL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ The `msys64` library and associated tools (like `mkdir`) are required to build A
297297

298298
Make sure you have `C:\msys64\usr\bin` in the "system" `PATH` rather than the "user" `PATH`.
299299

300-
After that, a `git clean -xfd`, `yarn`, and `node scripts\build\build-packages-dist.js` should resolve this issue.
300+
After that, a `git clean -xfd`, `yarn`, and `yarn build` should resolve this issue.
301301

302302
### Xcode
303303

docs/DEBUG_COMPONENTS_REPO_IVY.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Currently all changes to Ivy are validated against the test suite of the
44
`angular/components` repository. In order to debug the `components-repo-unit-tests` CI
55
job, the following steps can be used:
66

7-
1\) Build the Ivy package output by running `node ./scripts/build/build-packages-dist.js` in
8-
the `angular/angular` repo.
7+
1\) Build the Ivy package output by running `yarn build` in the `angular/angular` repo.
98

109
2\) Clone the `angular/components` repository if not done yet ([quick link to repo](https://github.com/angular/components)).
1110

docs/DEVELOPER.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ yarn install
6767
To build Angular run:
6868

6969
```shell
70-
node ./scripts/build/build-packages-dist.js
70+
yarn build
7171
```
7272

7373
* Results are put in the `dist/packages-dist` folder.
@@ -197,7 +197,7 @@ c. Some package managers (such as `pnpm` or `yarn pnp`) might not work correctly
197197
### Publishing to GitHub Repos
198198
You can also manually publish `*-builds` snapshots just like our CircleCI build does for upstream
199199
builds. Before being able to publish the packages, you need to build them locally by running the
200-
`./scripts/build/build-packages-dist.js` script.
200+
`yarn build` command.
201201

202202
First time, you need to create the GitHub repositories:
203203

integration/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This directory contains end-to-end tests for Angular. Each directory is a self-c
44
that exactly mimics how a user might expect Angular to work, so they allow high-fidelity
55
reproductions of real-world issues.
66

7-
For this to work, we first build the Angular distribution via `./scripts/build/build-packages-dist.js`, then
7+
For this to work, we first build the Angular distribution via `yarn build`, then
88
install the distribution into each app.
99

1010
To test Angular CLI applications, we use the `cli-hello-world-*` integration tests.

0 commit comments

Comments
 (0)