Skip to content

Commit 621f209

Browse files
authored
build: update to the latest version of dev-infra with ESM (#25052)
* build: update to the latest version of dev-infra with ESM Updates to the latest version of dev-infra with full ESM. * build: enable `--strict` for tools typescript code * build: update notify slack script to ESM as it imports from `ng-dev`
1 parent 1256c6c commit 621f209

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1418
-433
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ var_20: &slack_notify_on_failure
128128
run:
129129
name: 'Notifying team about job failure'
130130
when: on_fail
131-
command: node ./scripts/circleci/notify-slack-job-failure.js
131+
command: node ./scripts/circleci/notify-slack-job-failure.mjs
132132

133133
# Branch filter that only matches the main branch.
134134
var_21: &only_main_branch_filter
@@ -509,7 +509,7 @@ jobs:
509509
name: Running size integration tests (failures are reported in Slack only).
510510
command: |
511511
# If the size integration tests fail, report the failure to a dedicated #components-ci-size-tracking Slack channel.
512-
yarn integration-tests:size-test || node ./scripts/circleci/notify-slack-job-failure.js components-ci-size-tracking
512+
yarn integration-tests:size-test || node ./scripts/circleci/notify-slack-job-failure.mjs components-ci-size-tracking
513513
- *slack_notify_on_failure
514514

515515
# ----------------------------------------------------------------------------
File renamed without changes.
File renamed without changes.

.ng-dev/config.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {format} from './format.mjs';
2+
import {github} from './github.mjs';
3+
import {pullRequest} from './pull-request.mjs';
4+
import {commitMessage} from './commit-message.mjs';
5+
import {caretaker} from './caretaker.mjs';
6+
import {release} from './release.mjs';
7+
8+
export {commitMessage, format, github, pullRequest, caretaker, release};

.ng-dev/config.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

.ng-dev/release.ts renamed to .ng-dev/release.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {SemVer} from 'semver';
1+
import semver from 'semver';
22
import {ReleaseConfig} from '@angular/dev-infra-private/ng-dev';
3-
import {assertValidFrameworkPeerDependency} from '../tools/release-checks/check-framework-peer-dependency';
4-
import {assertValidUpdateMigrationCollections} from '../tools/release-checks/check-migration-collections';
5-
import {assertValidNpmPackageOutput} from '../tools/release-checks/npm-package-output';
3+
import {assertValidFrameworkPeerDependency} from '../tools/release-checks/check-framework-peer-dependency.mjs';
4+
import {assertValidUpdateMigrationCollections} from '../tools/release-checks/check-migration-collections.mjs';
5+
import {assertValidNpmPackageOutput} from '../tools/release-checks/npm-package-output/index.mjs';
66

77
/**
88
* Packages that will be published as part of the project.
@@ -46,11 +46,11 @@ export const release: ReleaseConfig = {
4646
buildPackages: async () => {
4747
// The `performNpmReleaseBuild` function is loaded at runtime as loading of the
4848
// script results in an invocation of Bazel for any `yarn ng-dev` command.
49-
const {performNpmReleaseBuild} = await import('../scripts/build-packages-dist');
49+
const {performNpmReleaseBuild} = await import('../scripts/build-packages-dist.mjs');
5050
return performNpmReleaseBuild();
5151
},
5252
prereleaseCheck: async (newVersionStr, builtPackagesWithInfo) => {
53-
const newVersion = new SemVer(newVersionStr);
53+
const newVersion = new semver.SemVer(newVersionStr);
5454

5555
await assertValidFrameworkPeerDependency(newVersion);
5656
await assertValidUpdateMigrationCollections(newVersion);

.ng-dev/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
33
"strict": true,
4-
"target": "es2015",
5-
"module": "commonjs",
4+
"target": "es2020",
5+
"module": "Node16",
66
"esModuleInterop": true,
77
"noEmit": true,
88
"skipLibCheck": true,

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
},
1616
"scripts": {
1717
"postinstall": "node tools/postinstall/apply-patches.js",
18-
"build": "ts-node --project scripts/tsconfig.json ./scripts/build-packages-dist.ts",
19-
"build-and-check-release-output": "ts-node --project scripts/tsconfig.json scripts/build-and-check-release-output.ts",
20-
"build-docs-content": "ts-node --project scripts/tsconfig.json ./scripts/build-docs-content.ts",
18+
"ng-dev": "TS_NODE_PROJECT=$PWD/.ng-dev/tsconfig.json node_modules/@angular/dev-infra-private/ng-dev/bundles/cli.mjs",
19+
"build": "ts-node --esm --project scripts/tsconfig.json ./scripts/build-packages-dist-main.mts",
20+
"build-docs-content": "ts-node --esm --project scripts/tsconfig.json ./scripts/build-docs-content-main.mts",
21+
"build-and-check-release-output": "ts-node --esm --project scripts/tsconfig.json scripts/build-and-check-release-output.mts",
2122
"dev-app": "ibazel run //src/dev-app:devserver",
2223
"test": "node ./scripts/run-component-tests.js",
2324
"test-local": "yarn -s test --local",
@@ -48,8 +49,8 @@
4849
"check-mdc-exports": "ts-node --project scripts/tsconfig.json scripts/check-mdc-exports.ts",
4950
"check-tooling-setup": "yarn tsc --project tools/tsconfig.json && yarn tsc --project .ng-dev/tsconfig.json",
5051
"tsc": "node ./node_modules/typescript/bin/tsc",
51-
"ci-push-deploy-docs-app": "ts-node --project scripts/tsconfig.json scripts/docs-deploy/deploy-ci-push.ts",
52-
"ci-docs-monitor-test": "ts-node --project scripts/tsconfig.json scripts/docs-deploy/monitoring/ci-test.ts",
52+
"ci-push-deploy-docs-app": "ts-node --esm --project scripts/tsconfig.json scripts/docs-deploy/deploy-ci-push.mts",
53+
"ci-docs-monitor-test": "ts-node --esm --project scripts/tsconfig.json scripts/docs-deploy/monitoring/ci-test.mts",
5354
"prepare": "husky install"
5455
},
5556
"version": "14.1.0-next.0",
@@ -74,7 +75,7 @@
7475
"@angular/bazel": "^14.0.1",
7576
"@angular/cli": "^14.0.1",
7677
"@angular/compiler-cli": "^14.0.1",
77-
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#e45a962f80dbcd36bcdfe82497d8b6ce3990506c",
78+
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#136fa6e336fd635db4e16cd582e1fd9b6cf444a6",
7879
"@angular/localize": "^14.0.1",
7980
"@angular/platform-browser-dynamic": "^14.0.1",
8081
"@angular/platform-server": "^14.0.1",
@@ -154,7 +155,6 @@
154155
"@types/node": "^16.10.9",
155156
"@types/node-fetch": "^2.5.5",
156157
"@types/parse5": "^6.0.3",
157-
"@types/sass": "^1.43.1",
158158
"@types/selenium-webdriver": "^3.0.17",
159159
"@types/semver": "^7.3.9",
160160
"@types/send": "^0.17.1",
@@ -209,7 +209,7 @@
209209
"shelljs": "^0.8.5",
210210
"stylelint": "^14.5.0",
211211
"terser": "^5.10.0",
212-
"ts-node": "^10.4.0",
212+
"ts-node": "^10.8.1",
213213
"tsec": "0.2.2",
214214
"tsickle": "0.39.1",
215215
"tslint": "^6.1.3",
@@ -218,7 +218,7 @@
218218
"vrsource-tslint-rules": "6.0.0",
219219
"yaml": "^1.10.2",
220220
"yargs": "^17.3.1",
221-
"zx": "^4.3.0"
221+
"zx": "^6.2.4"
222222
},
223223
"resolutions": {
224224
"@angular/dev-infra-private/typescript": "~4.7.2",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Script that builds the NPM release output for all packages
3+
* and runs sanity checks against the NPM package output.
4+
*/
5+
6+
import fs from 'fs';
7+
import semver from 'semver';
8+
import {dirname, join} from 'path';
9+
import {fileURLToPath} from 'url';
10+
11+
import {performNpmReleaseBuild} from './build-packages-dist.mjs';
12+
import {assertValidNpmPackageOutput} from '../tools/release-checks/npm-package-output/index.mjs';
13+
14+
async function main() {
15+
const projectDir = join(dirname(fileURLToPath(import.meta.url)), '..');
16+
const packageJsonContent = await fs.promises.readFile(join(projectDir, 'package.json'), 'utf8');
17+
const packageJson = JSON.parse(packageJsonContent) as {version: string};
18+
19+
// Build the NPM package artifacts.
20+
const builtPackages = performNpmReleaseBuild();
21+
22+
// Run the release output validation checks.
23+
await assertValidNpmPackageOutput(builtPackages, semver.parse(packageJson.version)!);
24+
}
25+
26+
try {
27+
await main();
28+
} catch (e) {
29+
console.error(e);
30+
process.exit(1);
31+
}

scripts/build-and-check-release-output.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

scripts/build-docs-content-main.mts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script that builds the docs content NPM package and moves it into a conveniently
5+
* accessible distribution directory (the project `dist/` directory).
6+
*/
7+
8+
import {buildDocsContentPackage} from './build-docs-content.mjs';
9+
10+
const builtPackage = buildDocsContentPackage();
11+
console.info(`Built docs-content into: ${builtPackage.outputPath}`);
Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
#!/usr/bin/env node
2-
31
/**
42
* Script that builds the docs content NPM package and moves it into a conveniently
53
* accessible distribution directory (the project `dist/` directory).
64
*/
75

8-
import {cd, chmod, cp, exec, mkdir, rm, set} from 'shelljs';
9-
6+
import sh from 'shelljs';
107
import {BuiltPackage} from '@angular/dev-infra-private/ng-dev';
11-
import {join} from 'path';
8+
import {fileURLToPath} from 'url';
9+
import {join, dirname} from 'path';
1210

1311
/** Path to the project directory. */
14-
const projectDir = join(__dirname, '../');
12+
const projectDir = join(dirname(fileURLToPath(import.meta.url)), '../');
1513

1614
/** Path to the distribution directory. */
1715
const distDir = join(projectDir, 'dist/');
@@ -32,38 +30,33 @@ const bazelCmd = process.env.BAZEL || `yarn -s bazel`;
3230
*/
3331
export function buildDocsContentPackage(): BuiltPackage {
3432
// ShellJS should exit if a command fails.
35-
set('-e');
33+
sh.set('-e');
3634

3735
// Go to project directory.
38-
cd(projectDir);
36+
sh.cd(projectDir);
3937

4038
/** Path to the bazel bin output directory. */
41-
const bazelBinPath = exec(`${bazelCmd} info bazel-bin`).stdout.trim();
39+
const bazelBinPath = sh.exec(`${bazelCmd} info bazel-bin`).stdout.trim();
4240

4341
/** Path where the NPM package is built into by Bazel. */
4442
const bazelBinOutDir = join(bazelBinPath, 'src/components-examples/npm_package');
4543

4644
// Clean the output directory to ensure that the docs-content package
4745
// will not contain outdated files from previous builds.
48-
rm('-rf', outputDir);
49-
mkdir('-p', distDir);
46+
sh.rm('-rf', outputDir);
47+
sh.mkdir('-p', distDir);
5048

5149
// Build the docs-content package with the snapshot-build mode. That will help
5250
// determining which commit is associated with the built docs-content.
53-
exec(`${bazelCmd} build src/components-examples:npm_package --config=snapshot-build`);
51+
sh.exec(`${bazelCmd} build src/components-examples:npm_package --config=snapshot-build`);
5452

5553
// Copy the package output into the dist path. Also update the permissions
5654
// as Bazel by default marks files in the bazel-out as readonly.
57-
cp('-R', bazelBinOutDir, outputDir);
58-
chmod('-R', 'u+w', outputDir);
55+
sh.cp('-R', bazelBinOutDir, outputDir);
56+
sh.chmod('-R', 'u+w', outputDir);
5957

6058
return {
6159
name: '@angular/components-examples',
6260
outputPath: outputDir,
6361
};
6462
}
65-
66-
if (require.main === module) {
67-
const builtPackage = buildDocsContentPackage();
68-
console.info(`Built docs-content into: ${builtPackage.outputPath}`);
69-
}

scripts/build-packages-dist-main.mts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script that builds the release output of all packages which have the "release-package
5+
* Bazel tag set. The script builds all those packages and copies the release output to the
6+
* distribution folder within the project.
7+
*/
8+
9+
import {performDefaultSnapshotBuild} from './build-packages-dist.mjs';
10+
11+
// We always build as a snapshot build, unless the script is invoked directly by the
12+
// release publish script. The snapshot release configuration ensures that the current
13+
// Git `HEAD` sha is included for the version placeholders.
14+
performDefaultSnapshotBuild();

scripts/build-packages-dist.ts renamed to scripts/build-packages-dist.mts

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
#!/usr/bin/env node
2-
31
/**
42
* Script that builds the release output of all packages which have the "release-package
5-
* bazel tag set. The script builds all those packages and copies the release output to the
3+
* Bazel tag set. The script builds all those packages and copies the release output to the
64
* distribution folder within the project.
75
*/
86

97
import {execSync} from 'child_process';
10-
import {join} from 'path';
8+
import {join, dirname} from 'path';
119
import {BuiltPackage} from '@angular/dev-infra-private/ng-dev';
12-
import {chmod, cp, mkdir, rm, set, test} from 'shelljs';
10+
import {fileURLToPath} from 'url';
11+
import sh from 'shelljs';
1312

1413
// ShellJS should exit if a command fails.
15-
set('-e');
14+
sh.set('-e');
1615

1716
/** Name of the Bazel tag that will be used to find release package targets. */
1817
const releaseTargetTag = 'release-package';
1918

2019
/** Path to the project directory. */
21-
const projectDir = join(__dirname, '../');
20+
const projectDir = join(dirname(fileURLToPath(import.meta.url)), '../');
2221

2322
/** Command that runs Bazel. */
2423
const bazelCmd = process.env.BAZEL || `yarn -s bazel`;
@@ -31,18 +30,6 @@ const queryPackagesCmd =
3130
/** Path for the default distribution output directory. */
3231
const defaultDistPath = join(projectDir, 'dist/releases');
3332

34-
// Export the methods for building the release packages. These
35-
// can be consumed by the release tool.
36-
exports.performNpmReleaseBuild = performNpmReleaseBuild;
37-
exports.performDefaultSnapshotBuild = performDefaultSnapshotBuild;
38-
39-
if (module === require.main) {
40-
// We always build as a snapshot bu8ild, unless the script is invoked directly by the
41-
// release publish script. The snapshot release configuration ensures that the current
42-
// Git `HEAD` sha is included for the version placeholders.
43-
performDefaultSnapshotBuild();
44-
}
45-
4633
/** Builds the release packages for NPM. */
4734
export function performNpmReleaseBuild(): BuiltPackage[] {
4835
return buildReleasePackages(defaultDistPath, /* isSnapshotBuild */ false);
@@ -82,26 +69,26 @@ function buildReleasePackages(distPath: string, isSnapshotBuild: boolean): Built
8269
// do this to ensure that the version placeholders are properly populated.
8370
packageNames.forEach(pkgName => {
8471
const outputPath = getBazelOutputPath(pkgName);
85-
if (test('-d', outputPath)) {
86-
chmod('-R', 'u+w', outputPath);
87-
rm('-rf', outputPath);
72+
if (sh.test('-d', outputPath)) {
73+
sh.chmod('-R', 'u+w', outputPath);
74+
sh.rm('-rf', outputPath);
8875
}
8976
});
9077

9178
exec(`${bazelCmd} build ${stampConfigArg} ${targets.join(' ')}`);
9279

9380
// Delete the distribution directory so that the output is guaranteed to be clean. Re-create
9481
// the empty directory so that we can copy the release packages into it later.
95-
rm('-rf', distPath);
96-
mkdir('-p', distPath);
82+
sh.rm('-rf', distPath);
83+
sh.mkdir('-p', distPath);
9784

9885
// Copy the package output into the specified distribution folder.
9986
packageNames.forEach(pkgName => {
10087
const outputPath = getBazelOutputPath(pkgName);
10188
const targetFolder = getDistPath(pkgName);
10289
console.log(`> Copying package output to "${targetFolder}"`);
103-
cp('-R', outputPath, targetFolder);
104-
chmod('-R', 'u+w', targetFolder);
90+
sh.cp('-R', outputPath, targetFolder);
91+
sh.chmod('-R', 'u+w', targetFolder);
10592
});
10693

10794
return packageNames.map(pkg => {

scripts/circleci/notify-slack-job-failure.js renamed to scripts/circleci/notify-slack-job-failure.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* will be a noop when running for forked builds (i.e. PRs).
66
*/
77

8-
const {
8+
import {
99
isVersionBranch,
1010
getConfig,
1111
assertValidGithubConfig,
12-
} = require('@angular/dev-infra-private/ng-dev');
12+
} from '@angular/dev-infra-private/ng-dev';
1313

1414
if (process.env.CIRCLE_PR_NUMBER) {
1515
console.info('Skipping notifications for pull requests.');
@@ -23,7 +23,7 @@ const {
2323
SLACK_COMPONENTS_CI_FAILURES_WEBHOOK_URL: webhookUrl,
2424
} = process.env;
2525

26-
const {github} = getConfig([assertValidGithubConfig]);
26+
const {github} = await getConfig([assertValidGithubConfig]);
2727
const isPublishBranch = isVersionBranch(branchName) || branchName === github.mainBranchName;
2828

2929
// We don't want to spam the CI failures channel with e.g. Renovate branch failures.

0 commit comments

Comments
 (0)