Skip to content

Commit

Permalink
add-new-bcd: Add --verbose argument (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg authored Jan 12, 2024
1 parent 4179b02 commit 2eb196a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
32 changes: 29 additions & 3 deletions scripts/add-new-bcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {execSync} from "node:child_process";
import {Identifier} from "@mdn/browser-compat-data/types";
import fs from "fs-extra";
import esMain from "es-main";
import yargs from "yargs";
import {hideBin} from "yargs/helpers";

import {BCD_DIR} from "../lib/constants.js";
import {namespaces as jsNamespaces} from "../test-builder/javascript.js";
Expand Down Expand Up @@ -221,20 +223,24 @@ export const collectMissing = async (filepath: string): Promise<void> => {
/* c8 ignore start */
/**
* Main function that generates missing BCD, updates BCD, injects BCD, cleans up, and completes the process.
* @param paths - The report paths to get data from
* @param verbose - Enable verbose logging
* @returns A Promise that resolves when the process is complete.
*/
const main = async (): Promise<void> => {
const main = async (paths: string[], verbose = false): Promise<void> => {
const filepath = path.resolve(
path.join(BCD_DIR, "__missing", "__missing.json"),
);

console.log("Generating missing BCD...");
await collectMissing(filepath);
await updateBcd(
["../mdn-bcd-results/"],
paths,
{addNewFeatures: true},
bcd.browsers,
overrides,
null,

Check failure on line 242 in scripts/add-new-bcd.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

Argument of type 'null' is not assignable to parameter of type 'string | undefined'.
verbose,
);

console.log("Injecting BCD...");
Expand All @@ -249,6 +255,26 @@ const main = async (): Promise<void> => {
};

if (esMain(import.meta)) {
await main();
const {argv}: {argv: any} = yargs(hideBin(process.argv)).command(
"$0 [reports..]",
"Add missing features to BCD from a specified set of report files",
(yargs) => {
yargs
.positional("reports", {
describe: "The report files to update from (also accepts folders)",
type: "string",
array: true,
default: ["../mdn-bcd-results/"],
})
.option("verbose", {
alias: "v",
describe: "Enable verbosity",
type: "boolean",
default: false,
});
},
);

await main(argv.reports, argv.verbose);
}
/* c8 ignore stop */
4 changes: 3 additions & 1 deletion scripts/find-missing-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ const getMissing = (
const bcdEntries = traverseFeatures(bcd, "", includeAliases).filter(
filterPath,
);
const collectorEntries = Object.keys(tests).filter(filterPath);
const collectorEntries = Object.keys(tests)
.filter((p) => p !== "__resources")
.filter(filterPath);

switch (direction) {
case "bcd-from-collector":
Expand Down

0 comments on commit 2eb196a

Please sign in to comment.