Skip to content

Commit

Permalink
Merge pull request #45915 from margelo/feat/react-compiler-ci-check
Browse files Browse the repository at this point in the history
compiler: `--json` option to healthcheck CLI
  • Loading branch information
rlinoz authored Jul 22, 2024
2 parents 6bd5dc4 + b480223 commit a207ab8
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
diff --git a/node_modules/react-compiler-healthcheck/dist/index.js b/node_modules/react-compiler-healthcheck/dist/index.js
index 4bf23db..f7dfdf6 100755
--- a/node_modules/react-compiler-healthcheck/dist/index.js
+++ b/node_modules/react-compiler-healthcheck/dist/index.js
@@ -69154,16 +69154,28 @@ var reactCompilerCheck = {
compile(source, path);
}
},
- report(verbose) {
+ report(verbose, json) {
const totalComponents =
SucessfulCompilation.length +
countUniqueLocInEvents(OtherFailures) +
countUniqueLocInEvents(ActionableFailures);
- console.log(
- chalk.green(
- `Successfully compiled ${SucessfulCompilation.length} out of ${totalComponents} components.`
- )
- );
+ if (!json) {
+ console.log(
+ chalk.green(
+ `Successfully compiled ${SucessfulCompilation.length} out of ${totalComponents} components.`
+ )
+ );
+ }
+
+ if (json) {
+ const extractFileName = (output) => output.fnLoc.filename;
+ const successfulFiles = SucessfulCompilation.map(extractFileName);
+ const unsuccessfulFiles = [...new Set([...OtherFailures, ...ActionableFailures].map(extractFileName))];
+ console.log({
+ success: successfulFiles,
+ failure: unsuccessfulFiles,
+ });
+ }

if (verbose) {
for (const compilation of [...SucessfulCompilation, ...ActionableFailures, ...OtherFailures]) {
@@ -69250,10 +69262,17 @@ function main() {
default: false,
alias: 'v',
})
+ .option('json', {
+ description: 'print a list of compiled/not-compiled files as JSON',
+ type: 'boolean',
+ default: false,
+ alias: 'j',
+ })
.parseSync();
const spinner = ora("Checking").start();
let src = argv.src;
let verbose = argv.verbose;
+ let json = argv.json;
const globOptions = {
onlyFiles: true,
ignore: [
@@ -69273,9 +69292,12 @@ function main() {
libraryCompatCheck.run(source, path);
}
spinner.stop();
- reactCompilerCheck.report(verbose);
- strictModeCheck.report();
- libraryCompatCheck.report();
+ reactCompilerCheck.report(verbose, json);
+ // using json option we only want to get list of files
+ if (!json) {
+ strictModeCheck.report();
+ libraryCompatCheck.report();
+ }
});
}
main();

0 comments on commit a207ab8

Please sign in to comment.