Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --filter option to API docs script #62888

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/dev/run_check_published_api_changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ interface Options {
accept: boolean;
docs: boolean;
help: boolean;
filter: string;
}

async function run(
Expand Down Expand Up @@ -205,6 +206,7 @@ async function run(
const extraFlags: string[] = [];
const opts = (getopts(process.argv.slice(2), {
boolean: ['accept', 'docs', 'help'],
string: ['filter'],
default: {
project: undefined,
},
Expand All @@ -222,6 +224,8 @@ async function run(
opts.help = true;
}

const folders = ['core/public', 'core/server', 'plugins/data/server', 'plugins/data/public'];

if (opts.help) {
process.stdout.write(
dedent(chalk`
Expand All @@ -240,9 +244,13 @@ async function run(
{dim # Checks for and automatically accepts and updates documentation for any changes to the Kibana Core API}
{dim $} node scripts/check_published_api_changes --accept

{dim # Only checks the core/public directory}
{dim $} node scripts/check_published_api_changes --filter=core/public

Options:
--accept {dim Accepts all changes by updating the API Review files and documentation}
--docs {dim Updates the Core API documentation}
--only {dim RegExp that folder names must match, folders: [${folders.join(', ')}]}
--help {dim Show this message}
`)
);
Expand All @@ -258,9 +266,11 @@ async function run(
return false;
}

const folders = ['core/public', 'core/server', 'plugins/data/server', 'plugins/data/public'];

const results = await Promise.all(folders.map(folder => run(folder, { log, opts })));
const results = await Promise.all(
folders
.filter(folder => (opts.filter.length ? folder.match(opts.filter) : true))
.map(folder => run(folder, { log, opts }))
);

if (results.find(r => r === false) !== undefined) {
process.exitCode = 1;
Expand Down