Skip to content

Commit 7eb3e3b

Browse files
gkalpakalxhub
authored andcommitted
build: fix build scripts on macOS (angular#33854)
In angular#33823, `scripts/package-builds.sh` (which is used by both `build-packages-dist.sh` and `build-ivy-npm-packages.sh`) was updated to use `realpath`. It turns out that `realpath` does not exist on macOS, so the build scripts do not work there. In order to fix this (and also reduce the likelihood of introducing similar issues in the future), this commit changes these bash scripts to Node.js scripts (using [ShellJS](https://github.com/shelljs/shelljs) for a cross-platform implementation of Unix shell commands where necessary). PR Close angular#33854
1 parent c89eed5 commit 7eb3e3b

File tree

19 files changed

+203
-134
lines changed

19 files changed

+203
-134
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ jobs:
502502
- setup_circleci_bazel_config
503503
- setup_bazel_rbe
504504

505-
- run: scripts/build-packages-dist.sh
505+
- run: node scripts/build-packages-dist.js
506506

507507
# Save the npm packages from //packages/... for other workflow jobs to read
508508
- persist_to_workspace:
@@ -530,7 +530,7 @@ jobs:
530530
- setup_circleci_bazel_config
531531
- setup_bazel_rbe
532532

533-
- run: scripts/build-ivy-npm-packages.sh
533+
- run: node scripts/build-ivy-npm-packages.js
534534

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

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const PACKAGE_JSON_REGEX = /^[^/]+\/package\.json$/;
1515

1616
const ANGULAR_ROOT_DIR = path.resolve(__dirname, '../../..');
1717
const ANGULAR_DIST_PACKAGES = path.join(ANGULAR_ROOT_DIR, 'dist/packages-dist');
18-
const ANGULAR_DIST_PACKAGES_BUILD_CMD = path.join(ANGULAR_ROOT_DIR, 'scripts/build-packages-dist.sh');
18+
const ANGULAR_DIST_PACKAGES_BUILD_SCRIPT = path.join(ANGULAR_ROOT_DIR, 'scripts/build-packages-dist.js');
19+
const ANGULAR_DIST_PACKAGES_BUILD_CMD = `"${process.execPath}" "${ANGULAR_DIST_PACKAGES_BUILD_SCRIPT}"`;
1920

2021
/**
2122
* A tool that can install Angular dependencies for a project from NPM or from the
@@ -173,13 +174,13 @@ class NgPackagesInstaller {
173174
const canBuild = process.platform !== 'win32';
174175

175176
if (canBuild) {
176-
this._log(`Building the Angular packages with: ${ANGULAR_DIST_PACKAGES_BUILD_CMD}`);
177+
this._log(`Building the Angular packages with: ${ANGULAR_DIST_PACKAGES_BUILD_SCRIPT}`);
177178
shelljs.exec(ANGULAR_DIST_PACKAGES_BUILD_CMD);
178179
} else {
179180
this._warn([
180181
'Automatically building the local Angular packages is currently not supported on Windows.',
181182
`Please, ensure '${ANGULAR_DIST_PACKAGES}' exists and is up-to-date (e.g. by running ` +
182-
`'${ANGULAR_DIST_PACKAGES_BUILD_CMD}' in Git Bash for Windows, Windows Subsystem for Linux or a Linux ` +
183+
`'${ANGULAR_DIST_PACKAGES_BUILD_SCRIPT}' in Git Bash for Windows, Windows Subsystem for Linux or a Linux ` +
183184
'docker container or VM).',
184185
'',
185186
'Proceeding anyway...',

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,21 @@ describe('NgPackagesInstaller', () => {
253253
};
254254

255255
it('should build the local packages, when not on Windows', () => {
256-
const buildScript = path.join(ngRootDir, 'scripts/build-packages-dist.sh');
256+
const buildScript = path.join(ngRootDir, 'scripts/build-packages-dist.js');
257+
const buildCmd = `"${process.execPath}" "${buildScript}"`;
257258

258259
buildDistPackagesOnPlatform('linux');
259-
expect(shelljs.exec).toHaveBeenCalledWith(buildScript);
260+
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd);
260261

261262
shelljs.exec.calls.reset();
262263

263264
buildDistPackagesOnPlatform('darwin');
264-
expect(shelljs.exec).toHaveBeenCalledWith(buildScript);
265+
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd);
265266

266267
shelljs.exec.calls.reset();
267268

268269
buildDistPackagesOnPlatform('anythingButWindows :(');
269-
expect(shelljs.exec).toHaveBeenCalledWith(buildScript);
270+
expect(shelljs.exec).toHaveBeenCalledWith(buildCmd);
270271

271272
// Ensure that the script does actually exist (e.g. it was not renamed/moved).
272273
fs.existsSync.and.callThrough();

docs/DEBUG_MATERIAL_IVY.md

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

7-
1\) Build the Ivy package output by running `./scripts/build-ivy-npm-packages.sh` in
7+
1\) Build the Ivy package output by running `node ./scripts/build-ivy-npm-packages.js` in
88
the `angular/angular` repo.
99

1010
2\) Clone the `angular/components` repository if not done yet ([quick link to repo](https://github.com/angular/components)).
@@ -32,9 +32,9 @@ selecting a given test target.
3232

3333
Here is an example of commands that run individual test targets. Note that it is
3434
**important** to specify the `--define=compile=aot` flag in order to run tests with Ivy.
35-
35+
3636
```bash
3737
yarn bazel test --define=compile=aot src/material/slider:unit_tests
3838
yarn bazel test --define=compile=aot src/cdk/a11y:unit_tests
3939
yarn bazel test --define=compile=aot src/material/toolbar:unit_tests
40-
```
40+
```

docs/DEVELOPER.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ yarn install
6969
To build Angular run:
7070

7171
```shell
72-
./scripts/build-packages-dist.sh
72+
node ./scripts/build-packages-dist.js
7373
```
7474

7575
* Results are put in the `dist/packages-dist` folder.
@@ -190,7 +190,7 @@ c. Some package managers (such as `pnpm` or `yarn pnp`) might not work correctly
190190
### Publishing to GitHub repos
191191
You can also manually publish `*-builds` snapshots just like our CircleCI build does for upstream
192192
builds. Before being able to publish the packages, you need to build them locally by running the
193-
`./scripts/build-packages-dist.sh` script.
193+
`./scripts/build-packages-dist.js` script.
194194

195195
First time, you need to create the GitHub repositories:
196196

integration/cli-hello-world-ivy-compat/debug-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -u -e -o pipefail
1111

1212
cd "$(dirname "$0")"
1313

14-
$(pwd)/../../scripts/build-packages-dist.sh
14+
node $(pwd)/../../scripts/build-packages-dist.js
1515

1616
# Workaround https://github.com/yarnpkg/yarn/issues/2165
1717
# Yarn will cache file://dist URIs and not update Angular code
@@ -26,4 +26,4 @@ trap rm_cache EXIT
2626
rm -rf dist
2727
rm -rf node_modules
2828
yarn install --cache-folder $cache
29-
yarn test
29+
yarn test

integration/cli-hello-world-ivy-minimal/debug-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -u -e -o pipefail
1111

1212
cd "$(dirname "$0")"
1313

14-
$(pwd)/../../scripts/build-packages-dist.sh
14+
node $(pwd)/../../scripts/build-packages-dist.js
1515

1616
# Workaround https://github.com/yarnpkg/yarn/issues/2165
1717
# Yarn will cache file://dist URIs and not update Angular code
@@ -26,4 +26,4 @@ trap rm_cache EXIT
2626
rm -rf dist
2727
rm -rf node_modules
2828
yarn install --cache-folder $cache
29-
yarn test
29+
yarn test

integration/ivy-i18n/debug-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -u -e -o pipefail
1111

1212
cd "$(dirname "$0")"
1313

14-
$(pwd)/../../scripts/build-packages-dist.sh
14+
node $(pwd)/../../scripts/build-packages-dist.js
1515

1616
# Workaround https://github.com/yarnpkg/yarn/issues/2165
1717
# Yarn will cache file://dist URIs and not update Angular code
@@ -26,4 +26,4 @@ trap rm_cache EXIT
2626
rm -rf dist
2727
rm -rf node_modules
2828
yarn install --cache-folder $cache
29-
yarn test
29+
yarn test

integration/language_service_plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"scripts": {
1414
"build": "tsc -p tsconfig.json",
15-
"build-dist": "../../scripts/build-packages-dist.sh && yarn install --check-files",
15+
"build-dist": "node ../../scripts/build-packages-dist.js && yarn install --check-files",
1616
"cleanup": "rm -rf ti-*.log tsserver.log",
1717
"golden": "yarn build && node generate.js",
1818
"test": "yarn cleanup && yarn build && jasmine test.js"

integration/ngcc/debug-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -u -e -o pipefail
1111

1212
cd "$(dirname "$0")"
1313

14-
$(pwd)/../../scripts/build-packages-dist.sh
14+
node $(pwd)/../../scripts/build-packages-dist.js
1515

1616
# Workaround https://github.com/yarnpkg/yarn/issues/2165
1717
# Yarn will cache file://dist URIs and not update Angular code
@@ -26,4 +26,4 @@ trap rm_cache EXIT
2626
rm -rf dist
2727
rm -rf node_modules
2828
yarn install --cache-folder $cache
29-
yarn test
29+
yarn test

0 commit comments

Comments
 (0)