Skip to content

Commit 0d19121

Browse files
committed
build: update chalk
Updates to the latest version of Chalk which was tripping up the bot. As a result of this, some scripts had to be converted to `.mts`.
1 parent 1393844 commit 0d19121

9 files changed

+52
-47
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
- name: Verify tooling setup
150150
run: pnpm check-tooling-setup
151151
- name: Build and create package artifacts
152-
run: ./scripts/create-package-archives.js --suffix "pr${{github.event.number}}-$(git rev-parse --short HEAD)"
152+
run: ./scripts/create-package-archives.mjs --suffix "pr${{github.event.number}}-$(git rev-parse --short HEAD)"
153153
- name: Upload artifacts
154154
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
155155
with:

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
"lint": "pnpm -s tslint && pnpm -s stylelint && pnpm -s ownerslint && pnpm -s ng-dev format changed --check",
3030
"e2e": "bazel test //src/... --build_tag_filters=e2e --test_tag_filters=e2e --build_tests_only",
3131
"deploy-dev-app": "node ./scripts/deploy-dev-app.js",
32-
"breaking-changes": "ts-node --project scripts/tsconfig.json scripts/breaking-changes.ts",
33-
"check-entry-point-setup": "node ./scripts/check-entry-point-setup.js",
34-
"check-package-externals": "ts-node --project scripts/tsconfig.json scripts/check-package-externals.ts",
32+
"breaking-changes": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/breaking-changes.mts",
33+
"check-entry-point-setup": "node ./scripts/check-entry-point-setup.mjs",
34+
"check-package-externals": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/check-package-externals.mts",
3535
"format": "pnpm -s ng-dev format changed",
3636
"cherry-pick-patch": "ts-node --project tools/cherry-pick-patch/tsconfig.json tools/cherry-pick-patch/cherry-pick-patch.ts",
37-
"ownerslint": "ts-node --project scripts/tsconfig.json scripts/ownerslint.ts",
38-
"detect-component-id-collisions": "ts-node --project scripts/tsconfig.json scripts/detect-component-id-collisions.ts",
37+
"ownerslint": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/ownerslint.mts",
38+
"detect-component-id-collisions": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/detect-component-id-collisions.mts",
3939
"tslint": "tslint -c tslint.json --project ./tsconfig.json",
4040
"stylelint": "stylelint \"(src|docs)/**/*.+(css|scss)\" --config .stylelintrc.json",
4141
"resync-caretaker-app": "ts-node --project scripts/tsconfig.json scripts/caretaking/resync-caretaker-app-prs.ts",
@@ -103,7 +103,7 @@
103103
"@types/yargs": "^17.0.8",
104104
"autoprefixer": "^10.4.2",
105105
"axe-core": "^4.10.3",
106-
"chalk": "^4.1.0",
106+
"chalk": "^5.4.1",
107107
"dgeni": "^0.4.14",
108108
"dgeni-packages": "^0.30.0",
109109
"esbuild": "^0.25.0",

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/breaking-changes.ts renamed to scripts/breaking-changes.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import ts from 'typescript';
55

66
const projectRoot = process.cwd();
77

8+
const packageJson = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8'));
9+
810
// Current version from the package.json. Splits it on the dash to ignore pre-release labels.
9-
const packageVersion = require(join(projectRoot, 'package.json')).version.split('-')[0];
11+
const packageVersion = packageJson.version.split('-')[0];
1012

1113
// Regex used to extract versions from a string.
1214
const versionRegex = /\d+\.\d+\.\d+/;

scripts/check-entry-point-setup.js renamed to scripts/check-entry-point-setup.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
* script through a manifest file (generated by Bazel)
88
*/
99

10-
const {join, dirname} = require('path');
11-
const {sync: globSync} = require('glob');
12-
const minimatch = require('minimatch');
13-
const fs = require('fs');
14-
const chalk = require('chalk');
10+
import {join, dirname} from 'path';
11+
import {sync as globSync} from 'glob';
12+
import {readFileSync} from 'fs';
13+
import minimatch from 'minimatch';
14+
import chalk from 'chalk';
1515

1616
const [entryPointManifest] = process.argv.slice(2);
17-
const entryPoints = JSON.parse(fs.readFileSync(entryPointManifest, 'utf8'));
18-
const packagesDir = join(__dirname, '../src');
17+
const entryPoints = JSON.parse(readFileSync(entryPointManifest, 'utf8'));
18+
const packagesDir = join(process.cwd(), 'src');
1919

2020
/**
2121
* Globs that matches directories which should never be considered

scripts/check-package-externals.ts renamed to scripts/check-package-externals.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import minimatch from 'minimatch';
1414
import {join, relative} from 'path';
1515
import ts from 'typescript';
1616

17-
const projectRoot = join(__dirname, '../');
17+
const projectRoot = process.cwd();
1818
const args = process.argv.slice(2);
1919

2020
if (args.length !== 1) {

scripts/create-package-archives.js renamed to scripts/create-package-archives.mjs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
* the primary `cdk` and `material` packages, and also don't run for pull requests.
1010
*/
1111

12-
const {join} = require('path');
13-
const {rm, mkdir, test, ls, set, exec, cd} = require('shelljs');
14-
const {red, green} = require('chalk');
15-
const yargs = require('yargs');
12+
import {join} from 'path';
13+
import sh from 'shelljs';
14+
import chalk from 'chalk';
15+
import yargs from 'yargs';
1616

17-
const projectDir = join(__dirname, '../');
1817
const archivesDir = 'dist/release-archives';
1918
const releasesDir = 'dist/releases';
2019
const {suffix} = yargs(process.argv.slice(2))
@@ -23,34 +22,35 @@ const {suffix} = yargs(process.argv.slice(2))
2322
.parseSync();
2423

2524
// Fail if any ShellJS command fails.
26-
set('-e');
25+
sh.set('-e');
2726

28-
cd(projectDir);
29-
30-
if (!test('-e', releasesDir)) {
31-
console.error(red('The release output has not been built.'));
27+
if (!sh.test('-e', releasesDir)) {
28+
console.error(chalk.red('The release output has not been built.'));
3229
process.exit(1);
3330
}
3431

35-
rm('-Rf', archivesDir);
36-
mkdir('-p', archivesDir);
32+
sh.rm('-Rf', archivesDir);
33+
sh.mkdir('-p', archivesDir);
3734

38-
const builtPackages = ls(releasesDir)
35+
const builtPackages = sh
36+
.ls(releasesDir)
3937
.map(name => ({name, path: join(releasesDir, name)}))
40-
.filter(pkg => test('-d', pkg.path));
38+
.filter(pkg => sh.test('-d', pkg.path));
4139

4240
// If multiple packages should be archived, we also generate a single archive that
4341
// contains all packages. This makes it easier to transfer the release packages.
4442
if (builtPackages.length > 1) {
4543
console.info('Creating archive with all packages..');
46-
exec(`tar --create --gzip --directory ${releasesDir} --file ${archivesDir}/all-${suffix}.tgz .`);
44+
sh.exec(
45+
`tar --create --gzip --directory ${releasesDir} --file ${archivesDir}/all-${suffix}.tgz .`,
46+
);
4747
}
4848

4949
for (const pkg of builtPackages) {
5050
console.info(`Creating archive for package: ${pkg.name}`);
51-
exec(
51+
sh.exec(
5252
`tar --create --gzip --directory ${pkg.path} --file ${archivesDir}/${pkg.name}-${suffix}.tgz .`,
5353
);
5454
}
5555

56-
console.info(green(`Created package archives in: ${archivesDir}`));
56+
console.info(chalk.green(`Created package archives in: ${archivesDir}`));

scripts/detect-component-id-collisions.ts renamed to scripts/detect-component-id-collisions.mts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {sync as glob} from 'glob';
99

1010
const errors: string[] = [];
1111
const seenMetadata = new Map<string, ts.ClassDeclaration>();
12-
const fileToCheck = join(__dirname, '../src/**/!(*.spec).ts');
12+
const fileToCheck = join(process.cwd(), 'src/**/!(*.spec).ts');
1313
const ignoredPatterns = [
1414
'**/components-examples/**',
1515
'**/dev-app/**',
@@ -141,13 +141,16 @@ function serializeValue(node: ts.Node): string {
141141
.slice()
142142
// Sort the fields since JS engines preserve the order properties in object literals.
143143
.sort((a, b) => (a.name?.getText() || '').localeCompare(b.name?.getText() || ''))
144-
.reduce((accumulator, prop) => {
145-
if (ts.isPropertyAssignment(prop)) {
146-
accumulator[prop.name.getText()] = serializeValue(prop.initializer);
147-
}
148-
149-
return accumulator;
150-
}, {} as Record<string, string>);
144+
.reduce(
145+
(accumulator, prop) => {
146+
if (ts.isPropertyAssignment(prop)) {
147+
accumulator[prop.name.getText()] = serializeValue(prop.initializer);
148+
}
149+
150+
return accumulator;
151+
},
152+
{} as Record<string, string>,
153+
);
151154

152155
return JSON.stringify(serialized);
153156
}

scripts/ownerslint.ts renamed to scripts/ownerslint.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import chalk from 'chalk';
22
import {readdirSync, readFileSync, statSync} from 'fs';
3-
import {IMinimatch, Minimatch} from 'minimatch';
3+
import minimatch from 'minimatch';
44
import {join} from 'path';
55

66
/**
@@ -23,7 +23,7 @@ const ownedPaths = readFileSync(ownersFilePath, 'utf8')
2323
// Split off just the path glob.
2424
.map(line => line.split(/\s+/)[0])
2525
// Turn paths into Minimatch objects.
26-
.map(path => new Minimatch(path, {dot: true, matchBase: true}));
26+
.map(path => new minimatch.Minimatch(path, {dot: true, matchBase: true}));
2727

2828
const ignoredPaths = readFileSync(gitIgnorePath, 'utf8')
2929
.split('\n')
@@ -32,7 +32,7 @@ const ignoredPaths = readFileSync(gitIgnorePath, 'utf8')
3232
// Remove empty lines and comments.
3333
.filter(line => line && !line.startsWith('#'))
3434
// Turn paths into Minimatch objects.
35-
.map(path => new Minimatch(path, {dot: true, matchBase: true}));
35+
.map(path => new minimatch.Minimatch(path, {dot: true, matchBase: true}));
3636

3737
for (let paths = getChildPaths('.'); paths.length; ) {
3838
paths = Array.prototype.concat(
@@ -72,7 +72,7 @@ if (errors) {
7272
}
7373

7474
/** Check if the given path is owned by the given owned path matcher. */
75-
function isOwnedBy(path: string, ownedPath: IMinimatch) {
75+
function isOwnedBy(path: string, ownedPath: minimatch.IMinimatch) {
7676
// If the owned path ends with `**` its safe to eliminate whole directories.
7777
if (ownedPath.pattern.endsWith('**') || statSync(path).isFile()) {
7878
return ownedPath.match('/' + path);

0 commit comments

Comments
 (0)