()
| 54 | main() |
| 55 | |
| 56 | async function main() { |
| 57 | await validateInputParameters() |
| 58 | // Generate the dereferenced OpenAPI schema files |
| 59 | if (!decorateOnly) { |
| 60 | await getBundledFiles() |
| 61 | } |
| 62 | |
| 63 | // When we get the dereferenced OpenAPI files from the open-source |
| 64 | // github/rest-api-description repo, we need to remove any versions |
| 65 | // that are deprecated. |
| 66 | if (openSource) { |
| 67 | const currentOpenApiVersions = Object.values(allVersions).map((elem) => elem.openApiVersionName) |
| 68 | const allSchemas = await readdir(DOCS_DEREF_OPENAPI_DIR) |
| 69 | allSchemas.forEach((schema) => { |
| 70 | // if the schema does not start with a current version name, delete it |
| 71 | if (!currentOpenApiVersions.some((version) => schema.startsWith(version))) { |
| 72 | rimraf.sync(path.join(DOCS_DEREF_OPENAPI_DIR, schema)) |
| 73 | } |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | const schemas = await readdir(DOCS_DEREF_OPENAPI_DIR) |
| 78 | // Decorate the dereferenced files in a format ingestible by docs.github.com |
| 79 | await decorate(schemas) |
| 80 | console.log( |
| 81 | '\n🏁 The static REST API files are now up-to-date with your local `github/github` checkout. To revert uncommitted changes, run `git checkout src/rest/data/*`.\n\n' |
| 82 | ) |
| 83 | if (!keepDereferencedFiles) { |
| 84 | rimraf.sync(DOCS_DEREF_OPENAPI_DIR) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | async function getBundledFiles() { |
| 89 | // Get the github/github repo branch name and pull latest |
no test coverage detected