Skip to content

Commit 2e93ccc

Browse files
committed
Add config API endpoint and fix install scripts
- Add /[username]/[slug]/config endpoint for CLI to fetch remote configs - Update install scripts to use --user flag instead of --packages - Fix ASCII logo scrollbar issue with overflow:hidden and responsive sizing
1 parent 5873753 commit 2e93ccc

4 files changed

Lines changed: 65 additions & 30 deletions

File tree

website/src/hooks.server.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import type { Handle } from '@sveltejs/kit';
22

3-
function generateInstallScript(username: string, configName: string, preset: string, packages: string[], customScript: string): string {
4-
const packagesArg = packages.length > 0 ? `--packages "${packages.join(',')}"` : '';
5-
3+
function generateInstallScript(username: string, slug: string, customScript: string): string {
64
return `#!/bin/bash
75
set -e
86
97
echo "========================================"
108
echo " OpenBoot - Custom Install"
11-
echo " Config: @${username}/${configName}"
9+
echo " Config: @${username}/${slug}"
1210
echo "========================================"
1311
echo ""
1412
@@ -30,18 +28,18 @@ echo "Downloading OpenBoot..."
3028
curl -fsSL "\$OPENBOOT_URL" -o "\$OPENBOOT_BIN"
3129
chmod +x "\$OPENBOOT_BIN"
3230
33-
echo "Running with preset: ${preset}"
34-
"\$OPENBOOT_BIN" --preset ${preset} ${packagesArg} "\$@"
31+
echo "Using remote config: @${username}/${slug}"
32+
"\$OPENBOOT_BIN" --user ${username}/${slug} "\$@"
3533
3634
${
37-
customScript
38-
? `
35+
customScript
36+
? `
3937
echo ""
4038
echo "=== Running Custom Post-Install Script ==="
4139
${customScript}
4240
`
43-
: ''
44-
}
41+
: ''
42+
}
4543
4644
echo ""
4745
echo "Installation complete!"
@@ -57,13 +55,12 @@ export const handle: Handle = async ({ event, resolve }) => {
5755
const env = event.platform?.env;
5856

5957
if (env) {
60-
const config = await env.DB.prepare('SELECT c.*, u.username FROM configs c JOIN users u ON c.user_id = u.id WHERE c.alias = ? AND c.is_public = 1')
58+
const config = await env.DB.prepare('SELECT c.slug, c.custom_script, u.username FROM configs c JOIN users u ON c.user_id = u.id WHERE c.alias = ? AND c.is_public = 1')
6159
.bind(alias)
62-
.first<{ username: string; base_preset: string; packages: string; custom_script: string }>();
60+
.first<{ slug: string; username: string; custom_script: string }>();
6361

6462
if (config) {
65-
const packages = JSON.parse(config.packages || '[]');
66-
const script = generateInstallScript(config.username, alias, config.base_preset, packages, config.custom_script);
63+
const script = generateInstallScript(config.username, config.slug, config.custom_script);
6764

6865
return new Response(script, {
6966
headers: {

website/src/routes/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@
255255
256256
.ascii-logo {
257257
font-family: 'JetBrains Mono', monospace;
258-
font-size: 10px;
258+
font-size: clamp(6px, 1.2vw, 10px);
259259
line-height: 1.2;
260260
color: var(--accent);
261261
white-space: pre;
262262
margin-bottom: 40px;
263-
overflow-x: auto;
263+
overflow: hidden;
264264
}
265265
266266
.hero h1 {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { json } from '@sveltejs/kit';
2+
import type { RequestHandler } from './$types';
3+
4+
export const GET: RequestHandler = async ({ platform, params }) => {
5+
const env = platform?.env;
6+
if (!env) {
7+
return json({ error: 'Platform env not available' }, { status: 500 });
8+
}
9+
10+
const user = await env.DB.prepare('SELECT id, username FROM users WHERE username = ?')
11+
.bind(params.username)
12+
.first<{ id: string; username: string }>();
13+
14+
if (!user) {
15+
return json({ error: 'User not found' }, { status: 404 });
16+
}
17+
18+
const config = await env.DB.prepare(
19+
'SELECT slug, name, base_preset, packages, is_public FROM configs WHERE user_id = ? AND slug = ?'
20+
)
21+
.bind(user.id, params.slug)
22+
.first<{ slug: string; name: string; base_preset: string; packages: string; is_public: number }>();
23+
24+
if (!config) {
25+
return json({ error: 'Config not found' }, { status: 404 });
26+
}
27+
28+
if (!config.is_public) {
29+
return json({ error: 'Config is private' }, { status: 403 });
30+
}
31+
32+
const packages = JSON.parse(config.packages || '[]');
33+
34+
return json({
35+
username: user.username,
36+
slug: config.slug,
37+
name: config.name,
38+
preset: config.base_preset,
39+
packages: packages
40+
});
41+
};

website/src/routes/[username]/[slug]/install/+server.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import type { RequestHandler } from './$types';
22

3-
function generateInstallScript(username: string, configName: string, preset: string, packages: string[], customScript: string): string {
4-
const packagesArg = packages.length > 0 ? `--packages "${packages.join(',')}"` : '';
5-
3+
function generateInstallScript(username: string, slug: string, customScript: string): string {
64
return `#!/bin/bash
75
set -e
86
97
echo "========================================"
108
echo " OpenBoot - Custom Install"
11-
echo " Config: @${username}/${configName}"
9+
echo " Config: @${username}/${slug}"
1210
echo "========================================"
1311
echo ""
1412
@@ -30,18 +28,18 @@ echo "Downloading OpenBoot..."
3028
curl -fsSL "\$OPENBOOT_URL" -o "\$OPENBOOT_BIN"
3129
chmod +x "\$OPENBOOT_BIN"
3230
33-
echo "Running with preset: ${preset}"
34-
"\$OPENBOOT_BIN" --preset ${preset} ${packagesArg} "\$@"
31+
echo "Using remote config: @${username}/${slug}"
32+
"\$OPENBOOT_BIN" --user ${username}/${slug} "\$@"
3533
3634
${
37-
customScript
38-
? `
35+
customScript
36+
? `
3937
echo ""
4038
echo "=== Running Custom Post-Install Script ==="
4139
${customScript}
4240
`
43-
: ''
44-
}
41+
: ''
42+
}
4543
4644
echo ""
4745
echo "Installation complete!"
@@ -59,9 +57,9 @@ export const GET: RequestHandler = async ({ platform, params }) => {
5957
return new Response('User not found', { status: 404 });
6058
}
6159

62-
const config = await env.DB.prepare('SELECT base_preset, packages, custom_script, is_public FROM configs WHERE user_id = ? AND slug = ?')
60+
const config = await env.DB.prepare('SELECT custom_script, is_public FROM configs WHERE user_id = ? AND slug = ?')
6361
.bind(user.id, params.slug)
64-
.first<{ base_preset: string; packages: string; custom_script: string; is_public: number }>();
62+
.first<{ custom_script: string; is_public: number }>();
6563

6664
if (!config) {
6765
return new Response('Config not found', { status: 404 });
@@ -71,8 +69,7 @@ export const GET: RequestHandler = async ({ platform, params }) => {
7169
return new Response('Config is private', { status: 403 });
7270
}
7371

74-
const packages = JSON.parse(config.packages || '[]');
75-
const script = generateInstallScript(params.username, params.slug, config.base_preset, packages, config.custom_script);
72+
const script = generateInstallScript(params.username, params.slug, config.custom_script);
7673

7774
return new Response(script, {
7875
headers: {

0 commit comments

Comments
 (0)