mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
write manifest
This commit is contained in:
parent
332c60773d
commit
c2655129f9
@ -24,6 +24,22 @@ function checkDistIntegrity() {
|
||||
return true
|
||||
}
|
||||
|
||||
function fetchDistManifest() {
|
||||
if (!fs.existsSync(global.distPath)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const pkgPath = path.join(global.distPath, "manifest.json")
|
||||
|
||||
if (!fs.existsSync(pkgPath)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const pkg = require(pkgPath)
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
async function runServer() {
|
||||
const app = express()
|
||||
|
||||
@ -39,6 +55,16 @@ async function runServer() {
|
||||
|
||||
app.use(express.static(global.distPath))
|
||||
|
||||
app.get("/_dist_manifest", async (req, res) => {
|
||||
const manifest = fetchDistManifest()
|
||||
|
||||
if (!manifest) {
|
||||
return res.status(500).send("Dist not found")
|
||||
}
|
||||
|
||||
return res.json(manifest)
|
||||
})
|
||||
|
||||
app.get("*", function (req, res) {
|
||||
res.sendFile(path.join(global.distPath, "index.html"))
|
||||
})
|
||||
|
@ -8,14 +8,28 @@ const octokit = new Octokit({
|
||||
// auth: process.env.GITHUB_TOKEN
|
||||
})
|
||||
|
||||
async function getLatestReleaseBundleFromGithub() {
|
||||
console.log("Getting latest release bundle from github...")
|
||||
async function getLatestReleaseFromGithub() {
|
||||
console.log("Getting latest release from github...")
|
||||
|
||||
const release = await octokit.repos.getLatestRelease({
|
||||
owner: global.remoteRepo.split("/")[0],
|
||||
repo: global.remoteRepo.split("/")[1]
|
||||
})
|
||||
|
||||
return release.data
|
||||
}
|
||||
|
||||
async function getBundleFromRelease(release) {
|
||||
const bundle = release.assets.find(asset => asset.name === "app_dist.7z")
|
||||
|
||||
return bundle
|
||||
}
|
||||
|
||||
async function getLatestReleaseBundleFromGithub() {
|
||||
console.log("Getting latest release bundle from github...")
|
||||
|
||||
const release = await getLatestReleaseFromGithub()
|
||||
|
||||
const bundle = release.data.assets.find(asset => asset.name === "app_dist.7z")
|
||||
|
||||
return bundle
|
||||
@ -68,7 +82,18 @@ async function setupLatestRelease() {
|
||||
fs.mkdirSync(global.distPath)
|
||||
}
|
||||
|
||||
const bundle = await getLatestReleaseBundleFromGithub()
|
||||
const release = await getLatestReleaseFromGithub()
|
||||
|
||||
const bundle = await getBundleFromRelease(release)
|
||||
|
||||
// wirte a manifest file with bundle version and other info
|
||||
fs.writeFileSync(path.join(global.distPath, "manifest.json"), JSON.stringify(
|
||||
{
|
||||
version: release.tag_name,
|
||||
date: release.published_at,
|
||||
stable: !release.prerelease,
|
||||
}
|
||||
))
|
||||
|
||||
await downloadBundle(bundle)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user