Skip to content

Commit 0fa25de

Browse files
committed
build: remove shelljs usage
The script `goldens/public-api/manage.js` is no longer functional due to the removal of the public API bazel tasks. This script was responsible for managing the public API golden files, but it is now obsolete. As part of this change, the `shelljs` dependency has been replaced with native `node:fs` calls, and the associated npm scripts and documentation have been removed.
1 parent b356bb1 commit 0fa25de

File tree

7 files changed

+65
-118
lines changed

7 files changed

+65
-118
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,3 @@ changes to be accepted, the CLA must be signed. It's a quick process, we promise
301301
[js-style-guide]: https://google.github.io/styleguide/jsguide.html
302302
[stackoverflow]: https://stackoverflow.com/questions/tagged/angular-devkit
303303

304-
## <a name="public-api"></a> Updating the Public API
305-
Our Public API surface is tracked using golden files.
306-
307-
You check all golden files by running:
308-
```bash
309-
pnpm public-api:check
310-
```
311-
312-
If you modified the public API, the test will fail. To update the golden files you need to run:
313-
```bash
314-
pnpm public-api:update
315-
```

goldens/public-api/manage.js

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

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
"postinstall": "pnpm -s webdriver-update && husky",
2222
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
2323
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 106.0.5249.21",
24-
"public-api:check": "node goldens/public-api/manage.js test",
2524
"ng-dev": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only node_modules/@angular/ng-dev/bundles/cli.mjs",
26-
"public-api:update": "node goldens/public-api/manage.js accept",
2725
"ts-circular-deps": "pnpm -s ng-dev ts-circular-deps --config ./scripts/circular-deps-test.conf.mjs",
2826
"check-tooling-setup": "tsc --project .ng-dev/tsconfig.json",
2927
"diff-release-package": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/diff-release-package.mts"
@@ -89,7 +87,6 @@
8987
"@types/progress": "^2.0.3",
9088
"@types/resolve": "^1.17.1",
9189
"@types/semver": "^7.3.12",
92-
"@types/shelljs": "^0.8.11",
9390
"@types/watchpack": "^2.4.4",
9491
"@types/yargs": "^17.0.20",
9592
"@types/yargs-parser": "^21.0.0",
@@ -133,7 +130,6 @@
133130
"rollup-plugin-dts": "6.2.3",
134131
"rollup-plugin-sourcemaps2": "0.5.4",
135132
"semver": "7.7.3",
136-
"shelljs": "^0.10.0",
137133
"source-map-support": "0.5.21",
138134
"tar": "^7.0.0",
139135
"ts-node": "^10.9.1",

pnpm-lock.yaml

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

scripts/build-packages-dist.mts

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414

1515
import { BuiltPackage } from '@angular/ng-dev';
1616
import { execSync } from 'node:child_process';
17-
import { chmodSync, copyFileSync, mkdirSync, rmSync } from 'node:fs';
17+
import {
18+
chmodSync,
19+
copyFileSync,
20+
cpSync,
21+
existsSync,
22+
lstatSync,
23+
mkdirSync,
24+
readdirSync,
25+
rmSync,
26+
} from 'node:fs';
1827
import { dirname, join } from 'node:path';
19-
import sh from 'shelljs';
2028

2129
/** Name of the Bazel tag that will be used to find release package targets. */
2230
const releaseTargetTag = 'release-package';
@@ -89,14 +97,15 @@ function buildReleasePackages(
8997
// Archive output is created by the npm_package_archive target
9098
const archiveOutputPath = directoryOutputPath + '_archive.tgz';
9199

92-
if (sh.test('-d', directoryOutputPath)) {
93-
sh.chmod('-R', 'u+w', directoryOutputPath);
94-
sh.rm('-rf', directoryOutputPath);
100+
if (existsSync(directoryOutputPath)) {
101+
chmodRecursiveSync(directoryOutputPath, '0755');
102+
rmSync(directoryOutputPath, { recursive: true, force: true });
95103
}
96-
try {
104+
105+
if (existsSync(archiveOutputPath)) {
97106
chmodSync(archiveOutputPath, '0755');
98107
rmSync(archiveOutputPath, { force: true });
99-
} catch {}
108+
}
100109
});
101110

102111
// Build both the npm_package and npm_package_archive targets for each package
@@ -123,8 +132,8 @@ function buildReleasePackages(
123132
mkdirSync(dirname(targetFolder), { recursive: true });
124133

125134
// Copy package contents to target directory
126-
sh.cp('-R', directoryOutputPath, targetFolder);
127-
sh.chmod('-R', 'u+w', targetFolder);
135+
cpSync(directoryOutputPath, targetFolder, { recursive: true });
136+
chmodRecursiveSync(targetFolder, '0755');
128137

129138
// Copy archive of package to target directory
130139
const archiveTargetPath = join(distPath, `${pkgName.replace('/', '_')}.tgz`);
@@ -176,3 +185,25 @@ function exec(command: string, captureStdout?: true) {
176185
return stdout.toString().trim();
177186
}
178187
}
188+
189+
/**
190+
* Recursively changes the permissions (mode) of a directory and all its contents (files and subdirectories).
191+
* @param startPath The starting directory path.
192+
* @param mode The new permissions mode (e.g., 0755).
193+
*/
194+
function chmodRecursiveSync(startPath: string, mode: string): void {
195+
chmodSync(startPath, mode);
196+
197+
const files = readdirSync(startPath);
198+
199+
for (const file of files) {
200+
const filePath = join(startPath, file);
201+
const stat = lstatSync(filePath);
202+
203+
if (stat.isDirectory()) {
204+
chmodRecursiveSync(filePath, mode);
205+
} else {
206+
chmodSync(filePath, mode);
207+
}
208+
}
209+
}

scripts/diff-release-package.mts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818

1919
import { GitClient } from '@angular/ng-dev';
2020
import childProcess from 'node:child_process';
21-
import fs from 'node:fs';
21+
import fs, { chmodSync, lstatSync, readdirSync } from 'node:fs';
2222
import os from 'node:os';
23-
import path from 'node:path';
24-
import sh from 'shelljs';
23+
import path, { join } from 'node:path';
2524

2625
// Do not remove `.git` as we use Git for comparisons later.
2726
// Also preserve `uniqueId` as it's irrelevant for the diff and not included via Bazel.
@@ -130,6 +129,28 @@ async function deleteDir(dirPath: string) {
130129
}
131130

132131
// Needed as Bazel artifacts are readonly and cannot be deleted otherwise.
133-
sh.chmod('-R', 'u+w', dirPath);
132+
chmodRecursiveSync(dirPath, '0755');
134133
await fs.promises.rm(dirPath, { recursive: true, force: true, maxRetries: 3 });
135134
}
135+
136+
/**
137+
* Recursively changes the permissions (mode) of a directory and all its contents (files and subdirectories).
138+
* @param startPath The starting directory path.
139+
* @param mode The new permissions mode (e.g., 0755).
140+
*/
141+
function chmodRecursiveSync(startPath: string, mode: string): void {
142+
chmodSync(startPath, mode);
143+
144+
const files = readdirSync(startPath);
145+
146+
for (const file of files) {
147+
const filePath = join(startPath, file);
148+
const stat = lstatSync(filePath);
149+
150+
if (stat.isDirectory()) {
151+
chmodRecursiveSync(filePath, mode);
152+
} else {
153+
chmodSync(filePath, mode);
154+
}
155+
}
156+
}

scripts/templates/contributing.ejs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,3 @@ changes to be accepted, the CLA must be signed. It's a quick process, we promise
291291
[js-style-guide]: https://google.github.io/styleguide/jsguide.html
292292
[stackoverflow]: https://stackoverflow.com/questions/tagged/angular-devkit
293293

294-
## <a name="public-api"></a> Updating the Public API
295-
Our Public API surface is tracked using golden files.
296-
297-
You check all golden files by running:
298-
```bash
299-
pnpm public-api:check
300-
```
301-
302-
If you modified the public API, the test will fail. To update the golden files you need to run:
303-
```bash
304-
pnpm public-api:update
305-
```

0 commit comments

Comments
 (0)