Compare commits
9 Commits
eccd9afdcd
...
281cc0dda7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
281cc0dda7 | ||
|
|
03ea59c7e3 | ||
|
|
f17578af17 | ||
|
|
e5039232c8 | ||
|
|
a3b07d6028 | ||
|
|
008e5777c5 | ||
|
|
7fec78ff84 | ||
|
|
b37d5933a7 | ||
|
|
c7d4ffa9dd |
9
TODO.md
9
TODO.md
@@ -4,8 +4,12 @@
|
||||
- [x] Add version prop to picobook.json
|
||||
- [x] "Compile" carts in server
|
||||
- [x] Save compiled carts to db
|
||||
- [ ] Load cart by URL in React
|
||||
- [ ] Update GH Workflow to be by push
|
||||
- [x] Load cart by URL in React
|
||||
- [x] Update GH Workflow to be by push
|
||||
|
||||
## Next
|
||||
- [ ] Fix css bug on chromium
|
||||
- [ ] Add user page to show all projects
|
||||
|
||||
## Later
|
||||
- [ ] Update pico console handle
|
||||
@@ -14,6 +18,7 @@
|
||||
- [ ] More console support (touch detected, gamepad count, etc.)
|
||||
- [ ] User accounts to manage published games, and user accounts for players to save progress
|
||||
- [ ] GPIO Support (maybe gpio prop in picobook.json can have values like "ignore" | "v1")
|
||||
- [ ] Persistent cart data
|
||||
|
||||
## GPIO ideas
|
||||
- RGB background color
|
||||
|
||||
2
src/database/migrations/5-fifth-migration.sql
Normal file
2
src/database/migrations/5-fifth-migration.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE releases DROP COLUMN created_at;
|
||||
ALTER TABLE releases ADD created_at timestamp;
|
||||
@@ -38,7 +38,7 @@ const handler = async ({payload}: FirRouteInput<typeof payloadT>) => {
|
||||
|
||||
const carts = await getCarts(repoPath, manifest.carts);
|
||||
|
||||
insertRelease({
|
||||
await insertRelease({
|
||||
manifest,
|
||||
carts,
|
||||
});
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// Database Access Layer stuff goes here
|
||||
|
||||
// Database Access Layer stuff goes here
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { db, sql } from "../../database/db"
|
||||
import { JsonValue } from '@firebox/tsutil';
|
||||
import { db, sql } from "../../database/db";
|
||||
import { PicobookManifest } from '../types';
|
||||
|
||||
export type DbRelease = {
|
||||
@@ -16,6 +14,16 @@ export type DbRelease = {
|
||||
manifest: PicobookManifest;
|
||||
}
|
||||
|
||||
export type DbReleaseInternal = {
|
||||
id: string;
|
||||
slug: string;
|
||||
repo: string;
|
||||
version: string;
|
||||
carts: {carts: {name: string; rom: number[]}[]};
|
||||
author: string;
|
||||
manifest: PicobookManifest;
|
||||
}
|
||||
|
||||
const compareVersions = (a: string, b: string) => {
|
||||
const [a1, a2] = a.split(".").map(x => Number(x));
|
||||
const [b1, b2] = b.split(".").map(x => Number(x));
|
||||
@@ -34,24 +42,24 @@ export const getReleases = async (where: {
|
||||
version?: string;
|
||||
}): Promise<DbRelease[]> => {
|
||||
const {author, slug, version} = where;
|
||||
let rows: DbReleaseInternal[];
|
||||
if (!version) {
|
||||
const rows = await db.query(sql`
|
||||
rows = await db.query(sql`
|
||||
SELECT * from releases
|
||||
WHERE
|
||||
slug = ${slug} AND
|
||||
author = ${author}
|
||||
`);
|
||||
return rows;
|
||||
} else {
|
||||
const rows = await db.query(sql`
|
||||
rows = await db.query(sql`
|
||||
SELECT * from releases
|
||||
WHERE
|
||||
slug = ${slug} AND
|
||||
author = ${author} AND
|
||||
version = ${version}
|
||||
`);
|
||||
return rows;
|
||||
}
|
||||
return rows.map(row => ({...row, carts: row.carts.carts}));
|
||||
}
|
||||
|
||||
export const getRelease = async (where: {
|
||||
@@ -78,12 +86,13 @@ export const getRelease = async (where: {
|
||||
|
||||
export const insertRelease = async (props: {manifest: PicobookManifest, carts: {name: string; rom: number[]}[]}) => {
|
||||
const {manifest, carts} = props;
|
||||
// console.log('carts', JSON.stringify(carts));
|
||||
const {id: slug, author, repo, version} = manifest;
|
||||
const id = uuidv4();
|
||||
const now = new Date();
|
||||
await db.query(sql`
|
||||
INSERT INTO chats (id, slug, repo, version, author, carts, manifest, created_at)
|
||||
VALUES (${id}, ${slug}, ${repo}, ${version}, ${author} ${carts}, ${manifest}, ${now})
|
||||
INSERT INTO releases (id, slug, repo, version, author, carts, manifest, created_at)
|
||||
VALUES (${id}, ${slug}, ${repo}, ${version}, ${author}, ${{carts}}, ${manifest}, ${now})
|
||||
`);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import echo from "./api/echo.ts";
|
||||
import getRelease from "./api/getRelease.ts";
|
||||
import release from "./api/release.ts";
|
||||
import webhook from "./api/webhook.ts";
|
||||
|
||||
@@ -6,6 +7,7 @@ export const routeList = [
|
||||
echo,
|
||||
webhook,
|
||||
release,
|
||||
getRelease,
|
||||
];
|
||||
|
||||
export type RouteList = typeof routeList;
|
||||
Reference in New Issue
Block a user