Skip to content

Commit 60d28b9

Browse files
crisbetojelbourn
authored andcommitted
build: add script for approving public API changes (#19231)
The Bazel targets for approving public API changes are a little convoluted and hard to remember. These changes add a small script to make it easier to manage. E.g. `yarn api:approve material/chips`.
1 parent 7e63f4a commit 60d28b9

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

DEV_ENVIRONMENT.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ packages locally and test them by either of the following ways:
5858
1. Update the dependencies in `package.json` to point to the local uncompressed package directories.
5959
2. Directly copy the local uncompressed package directories into the `node_modules/` directory
6060
of a project.
61+
62+
63+
### Approving public API changes
64+
If you're making changes to a public API, they need to be propagated to our public API golden files.
65+
To save the changes you can run `yarn approve-api <target>` and to review the changes, you can look
66+
at the file under `tools/public_api_guard/<target>.d.ts`.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"resync-caretaker-app": "ts-node --project scripts scripts/caretaking/resync-caretaker-app-prs.ts",
4444
"ts-circular-deps:check": "yarn -s ts-circular-deps check --config ./src/circular-deps-test.conf.js",
4545
"ts-circular-deps:approve": "yarn -s ts-circular-deps approve --config ./src/circular-deps-test.conf.js",
46-
"merge": "ts-node --project scripts scripts/merge-script/cli.ts --config ./merge-config.js"
46+
"merge": "ts-node --project scripts scripts/merge-script/cli.ts --config ./merge-config.js",
47+
"approve-api": "node ./scripts/approve-api-golden.js"
4748
},
4849
"version": "9.2.2",
4950
"dependencies": {

scripts/approve-api-golden.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const shelljs = require('shelljs');
2+
const chalk = require('chalk');
3+
const path = require('path');
4+
const packageName = process.argv[2];
5+
6+
if (!packageName) {
7+
console.error(chalk.red('No package name has been passed in for API golden approval.'));
8+
process.exit(1);
9+
}
10+
11+
// ShellJS should exit if any command fails.
12+
shelljs.set('-e');
13+
shelljs.cd(path.join(__dirname, '../'));
14+
shelljs.exec(`yarn bazel run //tools/public_api_guard:${packageName}.d.ts_api.accept`);

0 commit comments

Comments
 (0)