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] Add version prop to picobook.json
|
||||||
- [x] "Compile" carts in server
|
- [x] "Compile" carts in server
|
||||||
- [x] Save compiled carts to db
|
- [x] Save compiled carts to db
|
||||||
- [ ] Load cart by URL in React
|
- [x] Load cart by URL in React
|
||||||
- [ ] Update GH Workflow to be by push
|
- [x] Update GH Workflow to be by push
|
||||||
|
|
||||||
|
## Next
|
||||||
|
- [ ] Fix css bug on chromium
|
||||||
|
- [ ] Add user page to show all projects
|
||||||
|
|
||||||
## Later
|
## Later
|
||||||
- [ ] Update pico console handle
|
- [ ] Update pico console handle
|
||||||
@@ -14,6 +18,7 @@
|
|||||||
- [ ] More console support (touch detected, gamepad count, etc.)
|
- [ ] More console support (touch detected, gamepad count, etc.)
|
||||||
- [ ] User accounts to manage published games, and user accounts for players to save progress
|
- [ ] 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")
|
- [ ] GPIO Support (maybe gpio prop in picobook.json can have values like "ignore" | "v1")
|
||||||
|
- [ ] Persistent cart data
|
||||||
|
|
||||||
## GPIO ideas
|
## GPIO ideas
|
||||||
- RGB background color
|
- 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);
|
const carts = await getCarts(repoPath, manifest.carts);
|
||||||
|
|
||||||
insertRelease({
|
await insertRelease({
|
||||||
manifest,
|
manifest,
|
||||||
carts,
|
carts,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
// Database Access Layer stuff goes here
|
// Database Access Layer stuff goes here
|
||||||
|
|
||||||
// Database Access Layer stuff goes here
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { db, sql } from "../../database/db"
|
import { db, sql } from "../../database/db";
|
||||||
import { JsonValue } from '@firebox/tsutil';
|
|
||||||
import { PicobookManifest } from '../types';
|
import { PicobookManifest } from '../types';
|
||||||
|
|
||||||
export type DbRelease = {
|
export type DbRelease = {
|
||||||
@@ -16,6 +14,16 @@ export type DbRelease = {
|
|||||||
manifest: PicobookManifest;
|
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 compareVersions = (a: string, b: string) => {
|
||||||
const [a1, a2] = a.split(".").map(x => Number(x));
|
const [a1, a2] = a.split(".").map(x => Number(x));
|
||||||
const [b1, b2] = b.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;
|
version?: string;
|
||||||
}): Promise<DbRelease[]> => {
|
}): Promise<DbRelease[]> => {
|
||||||
const {author, slug, version} = where;
|
const {author, slug, version} = where;
|
||||||
|
let rows: DbReleaseInternal[];
|
||||||
if (!version) {
|
if (!version) {
|
||||||
const rows = await db.query(sql`
|
rows = await db.query(sql`
|
||||||
SELECT * from releases
|
SELECT * from releases
|
||||||
WHERE
|
WHERE
|
||||||
slug = ${slug} AND
|
slug = ${slug} AND
|
||||||
author = ${author}
|
author = ${author}
|
||||||
`);
|
`);
|
||||||
return rows;
|
|
||||||
} else {
|
} else {
|
||||||
const rows = await db.query(sql`
|
rows = await db.query(sql`
|
||||||
SELECT * from releases
|
SELECT * from releases
|
||||||
WHERE
|
WHERE
|
||||||
slug = ${slug} AND
|
slug = ${slug} AND
|
||||||
author = ${author} AND
|
author = ${author} AND
|
||||||
version = ${version}
|
version = ${version}
|
||||||
`);
|
`);
|
||||||
return rows;
|
|
||||||
}
|
}
|
||||||
|
return rows.map(row => ({...row, carts: row.carts.carts}));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRelease = async (where: {
|
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[]}[]}) => {
|
export const insertRelease = async (props: {manifest: PicobookManifest, carts: {name: string; rom: number[]}[]}) => {
|
||||||
const {manifest, carts} = props;
|
const {manifest, carts} = props;
|
||||||
|
// console.log('carts', JSON.stringify(carts));
|
||||||
const {id: slug, author, repo, version} = manifest;
|
const {id: slug, author, repo, version} = manifest;
|
||||||
const id = uuidv4();
|
const id = uuidv4();
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
await db.query(sql`
|
await db.query(sql`
|
||||||
INSERT INTO chats (id, slug, repo, version, author, carts, manifest, created_at)
|
INSERT INTO releases (id, slug, repo, version, author, carts, manifest, created_at)
|
||||||
VALUES (${id}, ${slug}, ${repo}, ${version}, ${author} ${carts}, ${manifest}, ${now})
|
VALUES (${id}, ${slug}, ${repo}, ${version}, ${author}, ${{carts}}, ${manifest}, ${now})
|
||||||
`);
|
`);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import echo from "./api/echo.ts";
|
import echo from "./api/echo.ts";
|
||||||
|
import getRelease from "./api/getRelease.ts";
|
||||||
import release from "./api/release.ts";
|
import release from "./api/release.ts";
|
||||||
import webhook from "./api/webhook.ts";
|
import webhook from "./api/webhook.ts";
|
||||||
|
|
||||||
@@ -6,6 +7,7 @@ export const routeList = [
|
|||||||
echo,
|
echo,
|
||||||
webhook,
|
webhook,
|
||||||
release,
|
release,
|
||||||
|
getRelease,
|
||||||
];
|
];
|
||||||
|
|
||||||
export type RouteList = typeof routeList;
|
export type RouteList = typeof routeList;
|
||||||
Reference in New Issue
Block a user