try to build
This commit is contained in:
parent
2c82e50b57
commit
bda375284d
1277
package-lock.json
generated
1277
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -32,6 +32,7 @@
|
|||||||
"@firebox/tsutil": "^0.1.2",
|
"@firebox/tsutil": "^0.1.2",
|
||||||
"@sinclair/typebox": "^0.31.5",
|
"@sinclair/typebox": "^0.31.5",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
|
"execa": "^8.0.1",
|
||||||
"fastify": "^4.22.0",
|
"fastify": "^4.22.0",
|
||||||
"isomorphic-git": "^1.25.6",
|
"isomorphic-git": "^1.25.6",
|
||||||
"react-pico-8": "^4.1.0",
|
"react-pico-8": "^4.1.0",
|
||||||
@ -42,6 +43,7 @@
|
|||||||
"@databases/pg-migrations": "^5.0.2",
|
"@databases/pg-migrations": "^5.0.2",
|
||||||
"@emotion/css": "^11.11.2",
|
"@emotion/css": "^11.11.2",
|
||||||
"@emotion/react": "^11.11.1",
|
"@emotion/react": "^11.11.1",
|
||||||
|
"@types/node": "^20.11.30",
|
||||||
"@types/react": "^18.2.21",
|
"@types/react": "^18.2.21",
|
||||||
"@types/react-dom": "^18.2.7",
|
"@types/react-dom": "^18.2.7",
|
||||||
"@types/uuid": "^9.0.7",
|
"@types/uuid": "^9.0.7",
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import { Type } from "@sinclair/typebox";
|
import { Type } from "@sinclair/typebox";
|
||||||
import { FirRouteInput, FirRouteOptions } from "../util/routewrap.js";
|
import { FirRouteInput, FirRouteOptions } from "../util/routewrap.js";
|
||||||
|
import {execa} from 'execa';
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
import git from "isomorphic-git";
|
import git from "isomorphic-git";
|
||||||
import http from "isomorphic-git/http/node";
|
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 method = "POST";
|
||||||
const url = "/api/release";
|
const url = "/api/release";
|
||||||
@ -13,10 +18,13 @@ const url = "/api/release";
|
|||||||
|
|
||||||
const payloadT = Type.Any();
|
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 handler = async ({payload}: FirRouteInput<typeof payloadT>) => {
|
||||||
const {manifest, token} = payload;
|
const {manifest, token} = payload;
|
||||||
if (!fs.existsSync("./repos")) {
|
if (!fs.existsSync(repoPath)) {
|
||||||
fs.mkdirSync("./repos", {recursive: true})
|
fs.mkdirSync(repoPath, {recursive: true})
|
||||||
}
|
}
|
||||||
console.log(manifest);
|
console.log(manifest);
|
||||||
console.log("cloning...");
|
console.log("cloning...");
|
||||||
@ -32,16 +40,20 @@ const handler = async ({payload}: FirRouteInput<typeof payloadT>) => {
|
|||||||
password: token,
|
password: token,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dir: "./repos",
|
dir: repoPath,
|
||||||
url: manifest.repo,
|
url: manifest.repo,
|
||||||
});
|
});
|
||||||
console.log("cloned");
|
console.log("cloned");
|
||||||
const localManifest = JSON.parse(await fs.promises.readFile("./repos/picobook.json", "utf8"));
|
|
||||||
console.log("read local manifest");
|
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({
|
console.log({
|
||||||
manifest,
|
manifest,
|
||||||
localManifest,
|
js,
|
||||||
|
png,
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user