try to build

This commit is contained in:
dylan 2024-03-26 00:48:09 -07:00
parent 2c82e50b57
commit bda375284d
3 changed files with 351 additions and 952 deletions

1277
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@
"@firebox/tsutil": "^0.1.2",
"@sinclair/typebox": "^0.31.5",
"dotenv": "^16.4.5",
"execa": "^8.0.1",
"fastify": "^4.22.0",
"isomorphic-git": "^1.25.6",
"react-pico-8": "^4.1.0",
@ -42,6 +43,7 @@
"@databases/pg-migrations": "^5.0.2",
"@emotion/css": "^11.11.2",
"@emotion/react": "^11.11.1",
"@types/node": "^20.11.30",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/uuid": "^9.0.7",

View File

@ -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;
};