Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update ng-dev config to work with Node.js 18.19 #27338

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .ng-dev/caretaker.mts → .ng-dev/caretaker.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { CaretakerConfig } from '@angular/ng-dev';

/** The configuration for `ng-dev caretaker` commands. */
export const caretaker: CaretakerConfig = {
/**
* The configuration for `ng-dev caretaker` commands.
*
* @type { import("@angular/ng-dev").CaretakerConfig }
*/
export const caretaker = {
githubQueries: [
{
name: 'Merge Queue',
Expand Down
9 changes: 5 additions & 4 deletions .ng-dev/commit-message.mts → .ng-dev/commit-message.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { CommitMessageConfig } from '@angular/ng-dev';
import packages from '../lib/packages.js';
import { getReleasablePackages } from '../lib/packages.mjs';

/**
* The configuration for `ng-dev commit-message` commands.
*
* @type { import("@angular/ng-dev").CommitMessageConfig }
*/
export const commitMessage: CommitMessageConfig = {
export const commitMessage = {
maxLineLength: Infinity,
minBodyLength: 0,
minBodyLengthTypeExcludes: ['docs'],
// Note: When changing this logic, also change the `contributing.ejs` file.
scopes: [...Object.keys(packages.packages)],
scopes: getReleasablePackages().map(({ name }) => name),
};
File renamed without changes.
6 changes: 3 additions & 3 deletions .ng-dev/format.mts → .ng-dev/format.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FormatConfig } from '@angular/ng-dev';

/**
* Configuration for the `ng-dev format` command.
*
* @type { import("@angular/ng-dev").FormatConfig }
*/
export const format: FormatConfig = {
export const format = {
'prettier': {
matchers: ['**/*.{ts,js,json,yml,yaml,md}'],
},
Expand Down
8 changes: 4 additions & 4 deletions .ng-dev/github.mts → .ng-dev/github.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { GithubConfig } from '@angular/ng-dev';

/**
* Github configuration for the ng-dev command. This repository is
* uses as remote for the merge script.
* used as remote for the merge script.
*
* @type { import("@angular/ng-dev").GithubConfig }
*/
export const github: GithubConfig = {
export const github = {
owner: 'angular',
name: 'angular-cli',
mainBranchName: 'main',
Expand Down
6 changes: 3 additions & 3 deletions .ng-dev/pull-request.mts → .ng-dev/pull-request.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PullRequestConfig } from '@angular/ng-dev';

/**
* Configuration for the merge tool in `ng-dev`. This sets up the labels which
* are respected by the merge script (e.g. the target labels).
*
* @type { import("@angular/ng-dev").PullRequestConfig }
*/
export const pullRequest: PullRequestConfig = {
export const pullRequest = {
githubApiMerge: {
default: 'rebase',
labels: [{ pattern: 'merge: squash commits', method: 'squash' }],
Expand Down
22 changes: 11 additions & 11 deletions .ng-dev/release.mts → .ng-dev/release.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import semver from 'semver';
import { ReleaseConfig } from '@angular/ng-dev';
import packages from '../lib/packages.js';
import { getReleasablePackages } from '../lib/packages.mjs';

const npmPackages = Object.entries(packages.releasePackages).map(([name, { experimental }]) => ({
name,
experimental,
}));
const packages = getReleasablePackages();

/** Configuration for the `ng-dev release` command. */
export const release: ReleaseConfig = {
/**
* Configuration for the `ng-dev release` command.
*
* @type { import("@angular/ng-dev").ReleaseConfig }
*/
export const release = {
representativeNpmPackage: '@angular/cli',
npmPackages,
npmPackages: packages.map(({ name, experimental }) => ({ name, experimental })),
buildPackages: async () => {
// The `performNpmReleaseBuild` function is loaded at runtime to avoid loading additional
// files and dependencies unless a build is required.
const { performNpmReleaseBuild } = await import('../scripts/build-packages-dist.mjs');
return performNpmReleaseBuild();
},
prereleaseCheck: async (newVersionStr: string) => {
prereleaseCheck: async (newVersionStr) => {
const newVersion = new semver.SemVer(newVersionStr);
const { assertValidDependencyRanges } = await import(
'../scripts/release-checks/dependency-ranges/index.mjs'
);

await assertValidDependencyRanges(newVersion, packages.releasePackages);
await assertValidDependencyRanges(newVersion, packages);
},
releaseNotes: {
groupOrder: [
Expand Down
5 changes: 4 additions & 1 deletion .ng-dev/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true,
"allowJs": true,
"module": "Node16",
"moduleResolution": "Node16",
"checkJs": true,
"noEmit": true,
"types": []
},
"include": ["**/*.mts"],
"include": ["**/*.mjs"],
"exclude": []
}
32 changes: 32 additions & 0 deletions lib/packages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @license
* Copyright Google LLC 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
*/

import fastGlob from 'fast-glob';
import { readFileSync } from 'node:fs';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const monorepoData = require('../.monorepo.json');

export function getReleasablePackages() {
const packages = [];
for (const pkg of fastGlob.sync('./packages/*/*/package.json')) {
const data = JSON.parse(readFileSync(pkg, 'utf-8'));
if (!(data.name in monorepoData.packages)) {
throw new Error(`${data.name} does not exist in .monorepo.json`);
}

if (data.private) {
continue;
}

packages.push(data);
}

return packages;
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"build:bazel": "node ./bin/devkit-admin build-bazel",
"build-tsc": "tsc -p tsconfig.json",
"lint": "eslint --cache --max-warnings=0 \"**/*.ts\"",
"ng-dev": "ts-node --esm --project .ng-dev/tsconfig.json --transpile-only node_modules/@angular/ng-dev/bundles/cli.mjs",
"templates": "node ./bin/devkit-admin templates",
"validate": "node ./bin/devkit-admin validate",
"postinstall": "yarn webdriver-update && yarn husky install",
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 106.0.5249.21",
"public-api:check": "node goldens/public-api/manage.js test",
"ng-dev": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only node_modules/@angular/ng-dev/bundles/cli.mjs",
"public-api:update": "node goldens/public-api/manage.js accept",
"ts-circular-deps:check": "yarn -s ng-dev ts-circular-deps check --config ./packages/circular-deps-test.conf.js",
"ts-circular-deps:approve": "yarn -s ng-dev ts-circular-deps approve --config ./packages/circular-deps-test.conf.js",
Expand Down Expand Up @@ -75,7 +75,7 @@
"@angular/forms": "15.2.0-rc.0",
"@angular/localize": "15.2.0-rc.0",
"@angular/material": "15.1.4",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#fa4d4694084d46886ca28fd09768a7df69b5b84d",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#262c6ede0815bb2ba6fbe6f1790eaaa77ce84c9c",
"@angular/platform-browser": "15.2.0-rc.0",
"@angular/platform-browser-dynamic": "15.2.0-rc.0",
"@angular/platform-server": "15.2.0-rc.0",
Expand Down
7 changes: 3 additions & 4 deletions scripts/release-checks/dependency-ranges/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/

import { Log, ReleasePrecheckError, bold } from '@angular/ng-dev';
import semver from 'semver';
import { Log, bold, ReleasePrecheckError } from '@angular/ng-dev';
import { checkPeerDependencies } from './peer-deps-check.mjs';
import { checkSchematicsAngularLatestVersion } from './latest-versions-check.mjs';
import { PackageMap } from '../../../lib/packages.js';
import { PackageJson, checkPeerDependencies } from './peer-deps-check.mjs';

/** Environment variable that can be used to skip this pre-check. */
const skipEnvVar = 'SKIP_DEPENDENCY_RANGE_PRECHECK';
Expand All @@ -26,7 +25,7 @@ const skipEnvVar = 'SKIP_DEPENDENCY_RANGE_PRECHECK';
*/
export async function assertValidDependencyRanges(
newVersion: semver.SemVer,
allPackages: PackageMap,
allPackages: PackageJson[],
) {
if (process.env[skipEnvVar] === '1') {
return;
Expand Down
14 changes: 4 additions & 10 deletions scripts/release-checks/dependency-ranges/peer-deps-check.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,20 @@
* found in the LICENSE file at https://angular.io/license
*/

import path from 'path';
import url from 'url';
import semver from 'semver';
import { PackageMap } from '../../../lib/packages.js';

/** Path to the current directory. */
const currentDir = path.dirname(url.fileURLToPath(import.meta.url));

/** Path to the project directory. */
const projectDir = path.join(currentDir, '../../../');

/** Describes a parsed `package.json` file. */
interface PackageJson {
export interface PackageJson {
name?: string;
peerDependencies?: Record<string, string>;
}

export async function checkPeerDependencies(
newVersion: semver.SemVer,
allPackages: PackageMap,
allPackages: PackageJson[],
): Promise<string[]> {
const { major, minor } = newVersion;
const isPrerelease = !!newVersion.prerelease[0];
Expand All @@ -39,8 +33,8 @@ export async function checkPeerDependencies(
}

const failures: string[] = [];
for (const pkgInfo of Object.values(allPackages)) {
failures.push(...checkPackage(pkgInfo.packageJson, expectedFwPeerDep));
for (const pkgInfo of allPackages) {
failures.push(...checkPackage(pkgInfo, expectedFwPeerDep));
}

return failures;
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@
"@material/typography" "15.0.0-canary.684e33d25.0"
tslib "^2.3.0"

"@angular/ng-dev@https://github.com/angular/dev-infra-private-ng-dev-builds.git#fa4d4694084d46886ca28fd09768a7df69b5b84d":
version "0.0.0-98bdad2a2ff3cd66c78048a3d2f48d50389c494a"
resolved "https://github.com/angular/dev-infra-private-ng-dev-builds.git#fa4d4694084d46886ca28fd09768a7df69b5b84d"
"@angular/ng-dev@https://github.com/angular/dev-infra-private-ng-dev-builds.git#262c6ede0815bb2ba6fbe6f1790eaaa77ce84c9c":
version "0.0.0-96a8277d21eb61a2370061717ffa8dee5668caa0"
resolved "https://github.com/angular/dev-infra-private-ng-dev-builds.git#262c6ede0815bb2ba6fbe6f1790eaaa77ce84c9c"
dependencies:
"@yarnpkg/lockfile" "^1.1.0"
typescript "~4.9.0"
Expand Down
Loading