Skip to content

Commit

Permalink
fix: fixed build monkey script fail when first build
Browse files Browse the repository at this point in the history
  • Loading branch information
Arylo committed Jun 19, 2024
1 parent 2a07d67 commit b645353
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion etc/build/monkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ const outPath = path.resolve(ROOT_PATH, 'dist/monkey')
const targetPath = path.resolve(outPath, user)
console.log(`Building ${path.relative(ROOT_PATH, sourcePath)} --outfile=${path.relative(ROOT_PATH, targetPath)} ...`)
const deployInfo = await exportLatestDeployInfo(sourcePath)
fs.writeFileSync(path.resolve(outPath, deployJson), JSON.stringify(deployInfo, null, 2), 'utf-8')
const banner = paresBanner(sourcePath, { version: deployInfo.version })
buildScript(sourcePath, {
banner: { js: banner },
outfile: targetPath,
})
const metaPath = path.resolve(outPath, meta)
fs.writeFileSync(path.resolve(outPath, deployJson), JSON.stringify(deployInfo, null, 2), 'utf-8')
fs.writeFileSync(metaPath, banner, 'utf-8')
console.log(`Building ${path.relative(ROOT_PATH, sourcePath)} --outfile=${path.relative(ROOT_PATH, targetPath)} ... Done!`)
}
Expand Down
4 changes: 4 additions & 0 deletions etc/build/monkey.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ export const exportLatestDeployInfo = async (filepath: string) => {
try {
await download(latestDeployUrl, os.tmpdir(), { filename: deployJson })
const downloadDeployJson = JSON.parse(fs.readFileSync(path.resolve(os.tmpdir(), deployJson), 'utf-8'))
console.log(downloadDeployJson)
if (downloadDeployJson.contentHash !== contentHash && downloadDeployJson.bannerHash !== bannerHash) {
version = Number(downloadDeployJson.version) + 1
} else {
version = Number(downloadDeployJson.version)
console.log(downloadDeployJson)
}
} catch (e) {}
return {
Expand Down

0 comments on commit b645353

Please sign in to comment.