Skip to content

Commit

Permalink
build: update ng-dev config to work with Node.js 18.19
Browse files Browse the repository at this point in the history
Update ng-dev setup to work with 18.19 For more details, refer to: TypeStrong/ts-node#2094

(cherry picked from commit a6129a6)
  • Loading branch information
alan-agius4 committed Mar 15, 2024
1 parent 4b72f78 commit c3376ad
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .ng-dev/commit-message.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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 = {
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),
};
15 changes: 6 additions & 9 deletions .ng-dev/release.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import semver from 'semver';
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.
*
*
* @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.
Expand All @@ -26,7 +23,7 @@ export const release = {
'../scripts/release-checks/dependency-ranges/index.mjs'
);

await assertValidDependencyRanges(newVersion, packages.releasePackages);
await assertValidDependencyRanges(newVersion, packages);
},
releaseNotes: {
groupOrder: [
Expand Down
2 changes: 2 additions & 0 deletions .ng-dev/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true,
"allowJs": true,
"module": "Node16",
"moduleResolution": "Node16",
"checkJs": true,
"noEmit": true,
"types": []
},
Expand Down
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;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"build": "node ./bin/devkit-admin build",
"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 && patch-package --patch-dir tools/postinstall/patches",
"//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
15 changes: 9 additions & 6 deletions packages/angular/cli/src/commands/command-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ export const RootCommands: Record<
},
};

export const RootCommandsAliases = Object.values(RootCommands).reduce((prev, current) => {
current.aliases?.forEach((alias) => {
prev[alias] = current;
});
export const RootCommandsAliases = Object.values(RootCommands).reduce(
(prev, current) => {
current.aliases?.forEach((alias) => {
prev[alias] = current;
});

return prev;
}, {} as Record<string, CommandConfig>);
return prev;
},
{} as Record<string, CommandConfig>,
);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { NodePackageName, NodePackageTaskOptions } from './options';
export class NodePackageLinkTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
quiet = true;

constructor(public packageName?: string, public workingDirectory?: string) {}
constructor(
public packageName?: string,
public workingDirectory?: string,
) {}

toConfiguration(): TaskConfiguration<NodePackageTaskOptions> {
return {
Expand Down

0 comments on commit c3376ad

Please sign in to comment.