()
| 86 | } |
| 87 | |
| 88 | async function getBundledFiles() { |
| 89 | // Get the github/github repo branch name and pull latest |
| 90 | const githubBranch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: GITHUB_REP_DIR }) |
| 91 | .toString() |
| 92 | .trim() |
| 93 | |
| 94 | // Only pull master branch because development mode branches are assumed |
| 95 | // to be up-to-date during active work. |
| 96 | if (githubBranch === 'master') { |
| 97 | execSync('git pull', { cwd: GITHUB_REP_DIR }) |
| 98 | } |
| 99 | |
| 100 | // Create a tmp directory to store schema files generated from github/github |
| 101 | rimraf.sync(TEMP_DOCS_DIR) |
| 102 | await mkdirp(TEMP_DOCS_DIR) |
| 103 | |
| 104 | console.log( |
| 105 | `\n🏃♀️🏃🏃♀️Running \`bin/openapi bundle\` in branch '${githubBranch}' of your github/github checkout to generate the dereferenced OpenAPI schema files.\n` |
| 106 | ) |
| 107 | // Format the command supplied to the bundle script in `github/github` |
| 108 | const bundlerOptions = await getBundlerOptions() |
| 109 | const bundleCommand = `bundle -v -w${next ? ' -n' : ''} -o ${TEMP_DOCS_DIR} ${bundlerOptions}` |
| 110 | try { |
| 111 | console.log(bundleCommand) |
| 112 | execSync(`${path.join(GITHUB_REP_DIR, 'bin/openapi')} ${bundleCommand}`, { stdio: 'inherit' }) |
| 113 | } catch (error) { |
| 114 | console.error(error) |
| 115 | const errorMsg = |
| 116 | '🛑 Whoops! It looks like the `bin/openapi bundle` command failed to run in your `github/github` repository checkout.\n\n✅ Troubleshooting:\n - Make sure you have a codespace with a checkout of `github/github` at the same level as your `github/docs-internal` repo before running this script. See this documentation for details: https://thehub.github.com/epd/engineering/products-and-services/public-apis/rest/openapi/openapi-in-the-docs/#previewing-changes-in-the-docs.\n - Ensure that your OpenAPI schema YAML is formatted correctly. A CI test runs on your `github/github` PR that flags malformed YAML. You can check the PR diff view for comments left by the OpenAPI CI test to find and fix any formatting errors.\n\n' |
| 117 | throw new Error(errorMsg) |
| 118 | } |
| 119 | |
| 120 | // Moving the dereferenced files to the docs directory creates a consistent |
| 121 | // place to generate the decorated files from. This is where they will be |
| 122 | // delivered in automated pull requests and because of that we move them |
| 123 | // to the same location during local development. |
| 124 | await mkdirp(DOCS_DEREF_OPENAPI_DIR) |
| 125 | execSync( |
| 126 | `find ${TEMP_DOCS_DIR} -type f -name "*deref.json" -exec mv '{}' ${DOCS_DEREF_OPENAPI_DIR} ';'` |
| 127 | ) |
| 128 | |
| 129 | rimraf.sync(TEMP_DOCS_DIR) |
| 130 | } |
| 131 | |
| 132 | async function getBundlerOptions() { |
| 133 | let includeParams = [] |
no test coverage detected