Skip to content

Commit

Permalink
Update manage-project.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
p-zielinski committed Oct 17, 2023
1 parent 74af909 commit b671815
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/manage-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ const main = async ({
}
if (create) {
await createNewVersion(version);
} else if (!(await isVersionExists(version))) {
console.log(
colors.red(
`Version ${version} does not exist! Create it first. Use parameter --update instead of --create`
)
);
return;
}
await cleanProject(version);
await uploadOpenApiFile(version);
Expand All @@ -54,6 +61,23 @@ const main = async ({
);
};

const isVersionExists = async (version: string) => {
return (
(
await fetch(
`https://dash.readme.com/api/v1/api-specification?perPage=100&page=1`,
{
method: "GET",
headers: {
"x-readme-version": version,
authorization: "Basic " + btoa(process.env.README_IO_AUTH + ":"),
},
}
)
).status === 200
);
};

const uploadReferenceDocsWithMaxNumberOfAttempts = async (
version,
maxNumberOfUploadingAttempts = 6
Expand Down

0 comments on commit b671815

Please sign in to comment.