-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOP-4033]: Add oas-page-build and persistence module
- Loading branch information
Showing
6 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import { checkIfPatched, executeCliCommand, getCommitHash, getPatchId, getRepoDir } from '../helpers'; | ||
import { checkIfPatched, executeCliCommand, getCommitBranch, getCommitHash, getPatchId, getRepoDir } from '../helpers'; | ||
|
||
interface StageParams { | ||
repoName: string; | ||
mutPrefix: string; | ||
projectName: string; | ||
bucketName: string; | ||
url: string; | ||
} | ||
|
||
export async function nextGenStage({ repoName, mutPrefix, projectName, bucketName }: StageParams) { | ||
export async function nextGenStage({ repoName, mutPrefix, projectName, bucketName, url }: StageParams) { | ||
const repoDir = getRepoDir(repoName); | ||
|
||
const hasPatch = await checkIfPatched(repoDir); | ||
const [hasPatch, commitBranch] = await Promise.all([checkIfPatched(repoDir), getCommitBranch(repoDir)]); | ||
|
||
let hostedAtUrl = `${url}/${mutPrefix}/${process.env.USER}/${commitBranch}/`; | ||
|
||
const commandArgs = ['public', bucketName, '--stage']; | ||
|
||
if (hasPatch && projectName !== mutPrefix) { | ||
const [commitHash, patchId] = await Promise.all([getCommitHash(repoDir), getPatchId(repoDir)]); | ||
commandArgs.push(`--prefix="${commitHash}/${patchId}/${mutPrefix}"`); | ||
hostedAtUrl = `${url}/${commitHash}/${patchId}/${mutPrefix}/${process.env.USER}/${commitBranch}/`; | ||
} | ||
|
||
const result = await executeCliCommand({ command: 'mut-publish', args: commandArgs }); | ||
|
||
return result; | ||
const { stdout } = await executeCliCommand({ command: 'mut-publish', args: commandArgs }); | ||
const resultMessage = `${stdout}\n Hosted at ${hostedAtUrl}`; | ||
return resultMessage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { executeCliCommand } from '../helpers'; | ||
|
||
interface OasPageBuildParams { | ||
bundlePath: string; | ||
repoDir: string; | ||
siteUrl: string; | ||
} | ||
|
||
export async function oasPageBuild({ bundlePath, repoDir, siteUrl }: OasPageBuildParams) { | ||
const { stdout } = await executeCliCommand({ | ||
command: 'node', | ||
args: [ | ||
`${process.cwd()}/modules/oas-page-builder/dist/index.js`, | ||
'--output', | ||
`${repoDir}/public`, | ||
'--redoc', | ||
`${process.cwd()}/redoc/cli/index.js`, | ||
'--site-url', | ||
siteUrl, | ||
], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { executeCliCommand } from '../helpers'; | ||
|
||
interface PersistenceModuleParams { | ||
bundlePath: string; | ||
jobId: string; | ||
repoOwner?: string; | ||
} | ||
export async function persistenceModule({ | ||
bundlePath, | ||
jobId, | ||
repoOwner = 'docs-builder-bot', | ||
}: PersistenceModuleParams) { | ||
const { stdout } = await executeCliCommand({ | ||
command: 'node', | ||
args: [ | ||
`${process.cwd()}/modules/persistence/dist/index.js`, | ||
'--unhandled-rejections=strict', | ||
'--path', | ||
bundlePath, | ||
'--githubUser', | ||
repoOwner, | ||
'--jobId', | ||
jobId, | ||
], | ||
}); | ||
|
||
return stdout; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters