vibecarbon 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/carbon/content/docs/cli.mdx +5 -4
- package/carbon/docker-compose.yml +25 -2
- package/carbon/functions/main/index.ts +17 -0
- package/carbon/src/client/components/ui/button.tsx +2 -7
- package/carbon/vite.config.ts +13 -1
- package/carbon/volumes/db/wal-archive.sh +43 -0
- package/carbon/volumes/loki/loki-config.yml +8 -0
- package/package.json +1 -1
- package/src/create.js +16 -20
|
@@ -55,12 +55,12 @@ npx vibecarbon create
|
|
|
55
55
|
|
|
56
56
|
# Power-user / CI
|
|
57
57
|
npx vibecarbon create my-saas -y -admin-email admin@example.com -admin-password secret123
|
|
58
|
-
npx vibecarbon create my-saas -
|
|
58
|
+
npx vibecarbon create my-saas -install
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
Generates secure secrets (JWT, database password, Supabase keys), copies the
|
|
62
|
-
template,
|
|
63
|
-
|
|
62
|
+
template, initializes a git repository (with pre-commit + pre-push hooks),
|
|
63
|
+
optionally runs `pnpm install`, and creates the admin user in Supabase Auth.
|
|
64
64
|
|
|
65
65
|
| Flag | Description |
|
|
66
66
|
|------|-------------|
|
|
@@ -68,9 +68,10 @@ repository, and creates the admin user in Supabase Auth.
|
|
|
68
68
|
| `-admin-email <email>` | Admin email for dashboard access |
|
|
69
69
|
| `-admin-password <pw>` | Admin password for dashboard access |
|
|
70
70
|
| `-pm <name>` | Package manager: `npm`, `pnpm` (default), or `bun` |
|
|
71
|
-
| `-git` | Initialize a git repository (default: off; opt-in) |
|
|
72
71
|
| `-install` | Run `<pm> install` during create (default: deferred to first `vibecarbon up`) |
|
|
73
72
|
|
|
73
|
+
A git repository is initialized automatically (with pre-commit + pre-push hooks). If `git` isn't on PATH, this step is skipped silently with a hint to run `git init` manually afterwards.
|
|
74
|
+
|
|
74
75
|
---
|
|
75
76
|
|
|
76
77
|
## up
|
|
@@ -129,9 +129,31 @@ services:
|
|
|
129
129
|
- -c
|
|
130
130
|
- archive_mode=on
|
|
131
131
|
- -c
|
|
132
|
-
-
|
|
132
|
+
# Fault-tolerant wrapper around `wal-g wal-push`. If wal-g fails (S3
|
|
133
|
+
# outage, bad creds, missing bucket), the wrapper retries with backoff
|
|
134
|
+
# then logs "WAL_ARCHIVE_FAILED" to stderr and exits 0 so PG can recycle
|
|
135
|
+
# the segment instead of pinning the entire pg_wal directory. Without
|
|
136
|
+
# this, a single archive failure pins WAL forever and fills the disk
|
|
137
|
+
# within days (~20 GiB/day of WAL on an idle Supabase DB given
|
|
138
|
+
# archive_timeout below, because supabase extensions like pg_cron,
|
|
139
|
+
# pg_stat_statements, realtime publications all generate background
|
|
140
|
+
# writes every minute). RCA: prod-1 2026-05-26, 58 GiB of WAL retained
|
|
141
|
+
# in 3 days because wal-g couldn't reach the configured S3 bucket;
|
|
142
|
+
# disk filled, db went into Error state, /api/v1/notifications 500'd,
|
|
143
|
+
# whole stack down. Trade-off: a persistent archive outage leaves a
|
|
144
|
+
# PITR gap, but the DB stays up — strictly better than the previous
|
|
145
|
+
# behavior for a SaaS template. Grep `docker logs db` for
|
|
146
|
+
# WAL_ARCHIVE_FAILED to detect silent backup regressions.
|
|
147
|
+
- archive_command=/etc/postgresql/wal-archive.sh %p
|
|
133
148
|
- -c
|
|
134
|
-
|
|
149
|
+
# 60s was too aggressive — on an idle Supabase DB, that forces a
|
|
150
|
+
# 16 MiB segment switch every minute regardless of write volume (PG14+
|
|
151
|
+
# is supposed to skip empty switches but supabase's bundled extensions
|
|
152
|
+
# write enough every minute to trip it). 23 GiB/day of WAL baseline.
|
|
153
|
+
# 900s (15 min) drops baseline to ~1.5 GiB/day with an RPO cap that's
|
|
154
|
+
# plenty for SaaS workloads. Override via postgresql.conf or compose
|
|
155
|
+
# if tighter RPO is needed.
|
|
156
|
+
- archive_timeout=900
|
|
135
157
|
- -c
|
|
136
158
|
# hot_standby=on lets a server in recovery mode (i.e. our standby)
|
|
137
159
|
# accept read-only psql connections. Required so failover's
|
|
@@ -167,6 +189,7 @@ services:
|
|
|
167
189
|
WALG_COMPRESSION_METHOD: lz4
|
|
168
190
|
volumes:
|
|
169
191
|
- db_data:/var/lib/postgresql/data
|
|
192
|
+
- ./volumes/db/wal-archive.sh:/etc/postgresql/wal-archive.sh:ro,Z
|
|
170
193
|
- ./volumes/db/roles.sql:/docker-entrypoint-initdb.d/init-scripts/98-roles.sql:Z
|
|
171
194
|
- ./volumes/db/jwt.sql:/docker-entrypoint-initdb.d/init-scripts/99-jwt.sql:Z
|
|
172
195
|
- ./volumes/db/realtime.sql:/docker-entrypoint-initdb.d/migrations/99-realtime.sql:Z
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Edge Functions main entrypoint.
|
|
2
|
+
//
|
|
3
|
+
// docker-compose.prod.yml starts the supabase/edge-runtime container with
|
|
4
|
+
// `--main-service /home/deno/functions/main`, which requires this file to
|
|
5
|
+
// exist. Without it the container crash-loops with
|
|
6
|
+
// "could not find an appropriate entrypoint".
|
|
7
|
+
//
|
|
8
|
+
// This stub returns 404 for any path. Add real edge functions by routing in
|
|
9
|
+
// the request handler below, or by mounting per-function directories under
|
|
10
|
+
// functions/<name>/index.ts and updating this dispatcher.
|
|
11
|
+
|
|
12
|
+
Deno.serve((_req: Request) => {
|
|
13
|
+
return new Response(
|
|
14
|
+
JSON.stringify({ error: 'No edge function configured for this path' }),
|
|
15
|
+
{ status: 404, headers: { 'content-type': 'application/json' } }
|
|
16
|
+
);
|
|
17
|
+
});
|
|
@@ -3,10 +3,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
|
-
|
|
7
|
-
const SparkBurst = React.lazy(() =>
|
|
8
|
-
import('../effects/SparkBurst').then((m) => ({ default: m.SparkBurst }))
|
|
9
|
-
);
|
|
6
|
+
import { SparkBurst } from '../effects/SparkBurst';
|
|
10
7
|
|
|
11
8
|
const buttonVariants = cva(
|
|
12
9
|
"cursor-pointer focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-4xl border border-transparent text-sm leading-none font-medium focus-visible:ring-[3px] aria-invalid:ring-[3px] [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all disabled:cursor-default [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none",
|
|
@@ -109,9 +106,7 @@ function Button({
|
|
|
109
106
|
>
|
|
110
107
|
{resolvedChildren}
|
|
111
108
|
{hasSparkle && (
|
|
112
|
-
<
|
|
113
|
-
<SparkBurst delay={0.05} count={10} palette="primary" trigger={sparkTrigger} />
|
|
114
|
-
</React.Suspense>
|
|
109
|
+
<SparkBurst delay={0.05} count={10} palette="primary" trigger={sparkTrigger} />
|
|
115
110
|
)}
|
|
116
111
|
</ButtonPrimitive>
|
|
117
112
|
);
|
package/carbon/vite.config.ts
CHANGED
|
@@ -68,7 +68,19 @@ export default defineConfig(({ mode }) => {
|
|
|
68
68
|
return 'vendor-react';
|
|
69
69
|
if (id.includes('node_modules/@supabase/')) return 'vendor-supabase';
|
|
70
70
|
if (id.includes('node_modules/@tanstack/react-query')) return 'vendor-query';
|
|
71
|
-
|
|
71
|
+
// DO NOT split recharts into its own chunk. With rolldown-vite (Vite 8 +
|
|
72
|
+
// rolldown 1.x), splitting a CJS-React consumer causes rolldown to bundle
|
|
73
|
+
// a *second* copy of React inside that chunk to satisfy the CJS interop
|
|
74
|
+
// for `import * as React from 'react'`. The main entry then imports its
|
|
75
|
+
// React namespace (X.lazy, X.useState) from the recharts chunk while
|
|
76
|
+
// page chunks still import from vendor-react — two Reacts in one app.
|
|
77
|
+
// React.lazy elements created by one and rendered by the other resolve
|
|
78
|
+
// to {} and React throws minified #306 ("Lazy element type must resolve
|
|
79
|
+
// to a class or function") on first render → ErrorBoundary catches →
|
|
80
|
+
// white screen. Verified 2026-05-26 against rolldown 1.0.1 by patching
|
|
81
|
+
// the deployed vendor-react and dumping the failing lazy's payload.
|
|
82
|
+
// Leave recharts in the default chunk so React stays single-copy.
|
|
83
|
+
// if (id.includes('node_modules/recharts')) return 'vendor-charts';
|
|
72
84
|
if (id.includes('node_modules/framer-motion')) return 'vendor-motion';
|
|
73
85
|
if (
|
|
74
86
|
id.includes('node_modules/cmdk') ||
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Fault-tolerant archive_command for Postgres + wal-g.
|
|
3
|
+
#
|
|
4
|
+
# Standard archive_command (`wal-g wal-push %p`) blocks WAL recycling until it
|
|
5
|
+
# succeeds. If wal-g fails for any reason (S3 outage, bad credentials, bucket
|
|
6
|
+
# missing, network), pg_wal grows unbounded — combined with archive_timeout
|
|
7
|
+
# this fills the disk in days even on an idle DB.
|
|
8
|
+
#
|
|
9
|
+
# This wrapper:
|
|
10
|
+
# 1. Tries `wal-g wal-push` with $RETRIES attempts and exponential backoff.
|
|
11
|
+
# 2. On final failure, logs loudly to stderr (visible in `docker logs db`)
|
|
12
|
+
# and exits 0 so PG can recycle the segment. PITR coverage degrades for
|
|
13
|
+
# the failed segment; the database stays up.
|
|
14
|
+
#
|
|
15
|
+
# Trade-off: a persistent archive outage means a gap in your PITR chain. The
|
|
16
|
+
# alternative — letting WAL fill the disk and taking the DB offline — is worse
|
|
17
|
+
# for any SaaS template. Monitor for the "WAL_ARCHIVE_FAILED" line to detect
|
|
18
|
+
# silent backup regressions.
|
|
19
|
+
#
|
|
20
|
+
# Invoked by postgres as: wal-archive.sh <wal-file-path>
|
|
21
|
+
# %p is passed by Postgres and is the absolute path to the WAL segment.
|
|
22
|
+
|
|
23
|
+
set -u
|
|
24
|
+
WAL_PATH="${1:?archive_command requires a WAL file path}"
|
|
25
|
+
RETRIES="${WAL_ARCHIVE_RETRIES:-3}"
|
|
26
|
+
SLEEP_BASE="${WAL_ARCHIVE_SLEEP:-2}"
|
|
27
|
+
|
|
28
|
+
attempt=1
|
|
29
|
+
while [ "$attempt" -le "$RETRIES" ]; do
|
|
30
|
+
if /usr/local/bin/wal-g wal-push "$WAL_PATH"; then
|
|
31
|
+
exit 0
|
|
32
|
+
fi
|
|
33
|
+
if [ "$attempt" -lt "$RETRIES" ]; then
|
|
34
|
+
sleep_for=$((SLEEP_BASE ** attempt))
|
|
35
|
+
sleep "$sleep_for"
|
|
36
|
+
fi
|
|
37
|
+
attempt=$((attempt + 1))
|
|
38
|
+
done
|
|
39
|
+
|
|
40
|
+
# All retries exhausted. Loud, greppable log line so monitoring/alerting can
|
|
41
|
+
# catch this — but exit 0 so PG recycles the segment instead of pinning it.
|
|
42
|
+
echo "WAL_ARCHIVE_FAILED: wal-g wal-push '$WAL_PATH' failed after $RETRIES attempts; allowing PG to recycle (PITR gap for this segment)" >&2
|
|
43
|
+
exit 0
|
|
@@ -56,3 +56,11 @@ compactor:
|
|
|
56
56
|
retention_enabled: true
|
|
57
57
|
retention_delete_delay: 2h
|
|
58
58
|
compaction_interval: 10m
|
|
59
|
+
# Loki 3.x requires delete_request_store when retention_enabled is true,
|
|
60
|
+
# otherwise the container fails to start with "CONFIG ERROR: invalid
|
|
61
|
+
# compactor config: compactor.delete-request-store should be configured
|
|
62
|
+
# when retention is enabled" and crash-loops. RCA: prod-1 2026-05-26,
|
|
63
|
+
# loki had been restart-looping since first deploy because of this.
|
|
64
|
+
# filesystem matches the storage_config above; switch to s3/gcs if the
|
|
65
|
+
# rest of loki storage moves off filesystem.
|
|
66
|
+
delete_request_store: filesystem
|
package/package.json
CHANGED
package/src/create.js
CHANGED
|
@@ -152,11 +152,6 @@ const SPEC = {
|
|
|
152
152
|
boolean: true,
|
|
153
153
|
description: 'Skip prompts (requires -admin-email and -admin-password)',
|
|
154
154
|
},
|
|
155
|
-
{
|
|
156
|
-
name: 'git',
|
|
157
|
-
boolean: true,
|
|
158
|
-
description: 'Initialize a git repository (default: off; opt-in)',
|
|
159
|
-
},
|
|
160
155
|
{
|
|
161
156
|
name: 'install',
|
|
162
157
|
boolean: true,
|
|
@@ -476,14 +471,13 @@ async function bootstrap(cliArgs) {
|
|
|
476
471
|
}
|
|
477
472
|
|
|
478
473
|
// Build the legacy `args` shape that the orchestration code reads.
|
|
479
|
-
//
|
|
480
|
-
//
|
|
474
|
+
// Git init always runs when `git` is on PATH; falls back to no-repo silently
|
|
475
|
+
// if git isn't installed. No CLI flag needed either way.
|
|
481
476
|
const args = {
|
|
482
477
|
projectName: positional.projectName || null,
|
|
483
478
|
yes: !!values.y,
|
|
484
479
|
install: !!values.install,
|
|
485
480
|
skipLockfile: !!values['skip-lockfile'],
|
|
486
|
-
noGit: !values.git,
|
|
487
481
|
packageManager: /** @type {string|null} */ (values.pm),
|
|
488
482
|
adminEmail: /** @type {string|null} */ (values['admin-email']),
|
|
489
483
|
adminPassword: /** @type {string|null} */ (values['admin-password']),
|
|
@@ -502,7 +496,6 @@ async function bootstrap(cliArgs) {
|
|
|
502
496
|
// and can't escape cwd (CVE-class path-traversal).
|
|
503
497
|
let projectName = args.projectName;
|
|
504
498
|
let packageManager = args.packageManager || detectPackageManager();
|
|
505
|
-
let initGit = !args.noGit;
|
|
506
499
|
let adminEmail = args.adminEmail;
|
|
507
500
|
let adminPassword = args.adminPassword;
|
|
508
501
|
|
|
@@ -566,13 +559,6 @@ async function bootstrap(cliArgs) {
|
|
|
566
559
|
initialValue: packageManager,
|
|
567
560
|
});
|
|
568
561
|
},
|
|
569
|
-
git: () => {
|
|
570
|
-
if (args.noGit) return Promise.resolve(false);
|
|
571
|
-
return p.confirm({
|
|
572
|
-
message: 'Initialize a git repository for version control?',
|
|
573
|
-
initialValue: true,
|
|
574
|
-
});
|
|
575
|
-
},
|
|
576
562
|
},
|
|
577
563
|
{
|
|
578
564
|
onCancel: () => {
|
|
@@ -586,7 +572,6 @@ async function bootstrap(cliArgs) {
|
|
|
586
572
|
adminEmail = project.adminEmail;
|
|
587
573
|
adminPassword = project.adminPassword;
|
|
588
574
|
packageManager = project.packageManager;
|
|
589
|
-
initGit = project.git;
|
|
590
575
|
} else {
|
|
591
576
|
// Non-interactive validation
|
|
592
577
|
if (!projectName) {
|
|
@@ -633,7 +618,6 @@ async function bootstrap(cliArgs) {
|
|
|
633
618
|
`Project: ${projectName}`,
|
|
634
619
|
`Admin: ${adminEmail}`,
|
|
635
620
|
`Package manager: ${packageManager}`,
|
|
636
|
-
`Git: ${initGit ? 'yes' : 'no'}`,
|
|
637
621
|
].join('\n'),
|
|
638
622
|
'Configuration',
|
|
639
623
|
);
|
|
@@ -1120,8 +1104,16 @@ async function bootstrap(cliArgs) {
|
|
|
1120
1104
|
}
|
|
1121
1105
|
}
|
|
1122
1106
|
|
|
1123
|
-
// Initialize git
|
|
1124
|
-
if (
|
|
1107
|
+
// Initialize git. Always attempted; skipped silently with a friendly note
|
|
1108
|
+
// if the `git` binary isn't on PATH (no flag exposed for opt-out).
|
|
1109
|
+
let gitAvailable = true;
|
|
1110
|
+
try {
|
|
1111
|
+
execFileSync('git', ['--version'], { stdio: 'ignore' });
|
|
1112
|
+
} catch {
|
|
1113
|
+
gitAvailable = false;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
if (gitAvailable) {
|
|
1125
1117
|
s.message('Initializing git repository');
|
|
1126
1118
|
copyTemplate('.gitignore', join(projectDir, '.gitignore'), variables);
|
|
1127
1119
|
|
|
@@ -1205,6 +1197,10 @@ ${runCmd} test:prepush
|
|
|
1205
1197
|
writeFileSync(join(hooksDir, 'pre-push'), prePushHook);
|
|
1206
1198
|
chmodSync(join(hooksDir, 'pre-push'), 0o755);
|
|
1207
1199
|
await tick();
|
|
1200
|
+
} else {
|
|
1201
|
+
p.log.info(
|
|
1202
|
+
"git not found on PATH — skipping repo init. Install git and run 'git init' in this directory to enable version control + pre-commit/pre-push hooks.",
|
|
1203
|
+
);
|
|
1208
1204
|
}
|
|
1209
1205
|
|
|
1210
1206
|
// Store template version and file checksums for `vibecarbon upgrade`
|