try to build
This commit is contained in:
		| @@ -1,8 +1,13 @@ | ||||
| import { Type } from "@sinclair/typebox"; | ||||
| import { FirRouteInput, FirRouteOptions } from "../util/routewrap.js"; | ||||
| import {execa} from 'execa'; | ||||
| import fs from "fs"; | ||||
| import path from "path"; | ||||
| import git from "isomorphic-git"; | ||||
| import http from "isomorphic-git/http/node"; | ||||
| import {fileURLToPath} from 'url'; | ||||
| const __filename = fileURLToPath(import.meta.url); | ||||
| const __dirname = fileURLToPath(new URL('.', import.meta.url)); | ||||
|  | ||||
| const method = "POST"; | ||||
| const url = "/api/release"; | ||||
| @@ -13,10 +18,13 @@ const url = "/api/release"; | ||||
|  | ||||
| const payloadT = Type.Any(); | ||||
|  | ||||
| const repoPath = path.resolve(__dirname, "..", "..", "..", "repo"); | ||||
| const picoBinPath = path.resolve(__dirname, "..", "..", "..", "pico8", "pico8"); | ||||
|  | ||||
| const handler = async ({payload}: FirRouteInput<typeof payloadT>) => { | ||||
| 	const {manifest, token} = payload; | ||||
| 	if (!fs.existsSync("./repos")) { | ||||
| 		fs.mkdirSync("./repos", {recursive: true}) | ||||
| 	if (!fs.existsSync(repoPath)) { | ||||
| 		fs.mkdirSync(repoPath, {recursive: true}) | ||||
| 	} | ||||
| 	console.log(manifest); | ||||
| 	console.log("cloning..."); | ||||
| @@ -32,16 +40,20 @@ const handler = async ({payload}: FirRouteInput<typeof payloadT>) => { | ||||
| 				password: token, | ||||
| 			} | ||||
| 		}, | ||||
| 		dir: "./repos", | ||||
| 		dir: repoPath, | ||||
| 		url: manifest.repo, | ||||
| 	}); | ||||
| 	console.log("cloned"); | ||||
| 	const localManifest = JSON.parse(await fs.promises.readFile("./repos/picobook.json", "utf8")); | ||||
| 	console.log("read local manifest"); | ||||
| 	fs.promises.rm("./repos", {recursive: true, force: true}); | ||||
| 	await execa(picoBinPath, ["-export", path.join(repoPath, "result.html"), path.join(repoPath, manifest.main)]); | ||||
| 	await execa(picoBinPath, ["-export", path.join(repoPath, "result.png"), path.join(repoPath, manifest.main)]); | ||||
| 	const js = await fs.promises.readFile(path.join(repoPath, "result.js"), "utf8"); | ||||
| 	const png = new Buffer(await fs.promises.readFile(path.join(repoPath, "result.png"))).toString("base64"); | ||||
| 	fs.promises.rm(repoPath, {recursive: true, force: true}); | ||||
| 	console.log({ | ||||
| 		manifest, | ||||
| 		localManifest, | ||||
| 		js, | ||||
| 		png, | ||||
| 	}); | ||||
| 	return true; | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 dylan
					dylan