Skip to content

Commit

Permalink
chore(release): 2.0.0 [skip ci]
Browse files Browse the repository at this point in the history
# [2.0.0](v1.1.2...v2.0.0) (2023-04-21)

### Features

* switch --paths to --prefix and make it do .startsWith instead of a strict string match ([d2dcb6b](d2dcb6b))

### BREAKING CHANGES

* Changes --paths to --prefixes.
  • Loading branch information
semantic-release-bot committed Apr 21, 2023
1 parent 45ef441 commit 65cf911
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ program
.option("-u, --url <URL>", "Input URL")
.option("-o, --output <output>", "Output File")
.option("-v, --version", "Display the current version.")
.option("-p, --paths <path>", "A comma-separated, zero-spaces list of paths to keep. (Ex. /api/v1/users,/api/v1/organizations)")
.option("-p, --prefixes <path>", "A comma-separated, zero-spaces list of paths to keep. (Ex. /api/v1/users,/api/v1/organizations)")
.option("--help", "Display all flags, commands, and descriptions.");
program.parse();
if (program.opts().help) {
Expand All @@ -29,7 +29,7 @@ const options = z
input: z.string().optional(),
url: z.string().url().optional(),
output: z.string(),
paths: z.string(),
prefixes: z.string(),
})
.refine((data) => {
if ((data.input && data.url) || (!data.input && !data.url)) {
Expand All @@ -53,12 +53,12 @@ else if (options.url) {
else {
throw new Error(`Found neither an input URL or an input file!`);
}
const pathsToRetain = options.paths.split(",");
console.log(chalk.gray(`Trimming to just paths ${pathsToRetain.join(", ")}...`));
const prefixes = options.prefixes.split(",");
console.log(chalk.gray(`Trimming to just paths ${prefixes.join(", ")}...`));
let parsed = load(data);
const paths = {};
for (const path of Object.keys(parsed.paths)) {
if (pathsToRetain.includes(path)) {
if (prefixes.some((retain) => path.startsWith(retain))) {
paths[path] = parsed.paths[path];
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openapi-endpoint-trimmer",
"version": "1.1.2",
"version": "2.0.0",
"description": "",
"type": "module",
"files": [
Expand Down

0 comments on commit 65cf911

Please sign in to comment.