create-lacspace-app 2.8.0 → 2.10.0

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/README.md CHANGED
@@ -20,6 +20,16 @@ npx create-lacspace-app my-app --template saas --fullstack
20
20
 
21
21
  You choose the *kind* of site you're building. It writes a **real Next.js 15 + React 19 + Tailwind v4 app** — not a hello-world, but a genuinely **polished, modern site**: a fluid `clamp()` type scale, tight display headings, a refined light **and** dark palette, glass chrome, soft layered shadows, a smooth logo marquee, animated counters, scroll reveals and a shimmering primary CTA — every page filled in, an SEO stack wired end-to-end, and a **26-component UI kit** you can drop in anywhere.
22
22
 
23
+ > **New in v2.10 — three more add-ons (11 total).**
24
+ > - **`uploads`** — authenticated file uploads stored in MongoDB, served via **signed, expiring URLs** (`@lacspace/signed-url`) — no S3 required.
25
+ > - **`i18n`** — multi-language UI: a tiny dependency-free `t()` translator + a language switcher, with English + Nepali locales and an `i18n:check` lint script.
26
+ > - **`quality`** — one-command quality gates from the Lacspace dev-tools (bundle-size budget, dependency audit, fake fixtures) **plus a ready GitHub Actions CI workflow** (dropped at the repo root, monorepo-aware).
27
+
28
+ > **New in v2.9 — guided & discoverable.** Made for newcomers:
29
+ > - **Guided start** — the interactive prompt now offers a **recipe** first ("what are you building?"), so you can ship a whole product without knowing the flags.
30
+ > - **`list`** — `npx create-lacspace-app list` shows every template, add-on and recipe. **`explain <name>`** describes what any add-on or recipe gives you (packages, next steps, docs link).
31
+ > - **`--dry-run`** prints the exact files a command would create without writing anything. `--brand "#hex"` is an alias for `--theme`.
32
+
23
33
  > **New in v2.8 — recipes.** Scaffold a whole *kind of product* in one command with `--recipe <key>` (a curated template + full-stack mode + add-on stack):
24
34
  > - **`ai-saas`** → SaaS + accounts + payments + AI chat + analytics
25
35
  > - **`store`** → e-commerce + eSewa/Khalti checkout + email + analytics
package/dist/index.js CHANGED
@@ -1997,6 +1997,11 @@ function applyFeatures(files, ctx) {
1997
1997
  files[rel] = content;
1998
1998
  }
1999
1999
  }
2000
+ if (ctx.mode === "static") {
2001
+ for (const feat of features) {
2002
+ for (const [rel, content] of Object.entries(feat.rootFiles?.(ctx) ?? {})) files[rel] = content;
2003
+ }
2004
+ }
2000
2005
  const addDeps = {};
2001
2006
  const addScripts = {};
2002
2007
  for (const feat of features) {
@@ -2275,6 +2280,68 @@ var FEATURES = [
2275
2280
  "Reuse the helpers in backend/src/mail/mailer.ts: sendWelcome / sendVerify / sendReset."
2276
2281
  ],
2277
2282
  learn: "https://developer.lacspace.com/packages/mailer"
2283
+ },
2284
+ {
2285
+ key: "i18n",
2286
+ label: "i18n (multi-language)",
2287
+ description: "Multi-language UI: a tiny runtime translator (t() + a language switcher) with English + Nepali locales, plus an i18n:check lint script.",
2288
+ deps: {},
2289
+ scripts: { "i18n:check": "npx lacspace-i18n@0.2.0 check locales" },
2290
+ files: () => ({
2291
+ "lib/i18n.ts": i18nLib(),
2292
+ "components/language-provider.tsx": i18nProvider(),
2293
+ "app/i18n-demo/page.tsx": i18nDemoPage(),
2294
+ "locales/en.json": i18nEn(),
2295
+ "locales/ne.json": i18nNe()
2296
+ }),
2297
+ nextSteps: [
2298
+ "Wrap app/layout.tsx's <body> with <LanguageProvider> (from @/components/language-provider).",
2299
+ 'Use it in a client component: const { t } = useT(); then {t("hello", { name })}.',
2300
+ "Add keys in locales/*.json, then lint them with `npm run i18n:check`."
2301
+ ],
2302
+ learn: "https://developer.lacspace.com/tools/i18n"
2303
+ },
2304
+ {
2305
+ key: "quality",
2306
+ label: "Quality & CI",
2307
+ description: "One-command quality gates from the Lacspace dev-tools \u2014 bundle-size budget, dependency audit and fake fixtures \u2014 plus a ready GitHub Actions CI workflow.",
2308
+ deps: {},
2309
+ scripts: {
2310
+ "size:check": "npx lacspace-size@0.2.0 .next/static --metric gzip --max 500kb",
2311
+ "deps:audit": "npx lacspace-deps@0.2.0 . --fail-on duplicates",
2312
+ "fixtures:gen": 'npx lacspace-fake@0.2.0 --fields "id:autoincrement,name:fullName,email:unique(email)" -n 50 --pretty -o fixtures/users.json'
2313
+ },
2314
+ files: () => ({}),
2315
+ rootFiles: (ctx) => ({ ".github/workflows/ci.yml": qualityCiWorkflow(ctx) }),
2316
+ nextSteps: [
2317
+ "Run `npm run size:check` (bundle-size budget) and `npm run deps:audit` (dependency audit) \u2014 both fail loudly in CI.",
2318
+ "Generate sample data: `npm run fixtures:gen` \u2192 fixtures/users.json.",
2319
+ "The GitHub Actions workflow (.github/workflows/ci.yml) runs the checks on every push."
2320
+ ],
2321
+ learn: "https://developer.lacspace.com/tools/size"
2322
+ },
2323
+ {
2324
+ key: "uploads",
2325
+ label: "File uploads",
2326
+ description: "Authenticated file uploads stored in MongoDB, served via signed, expiring URLs (@lacspace/signed-url). No S3 required. Full-stack.",
2327
+ requiresBackend: true,
2328
+ deps: {},
2329
+ files: () => ({ "app/uploads/page.tsx": uploadsPage() }),
2330
+ backend: () => ({
2331
+ deps: { "@lacspace/signed-url": "^1.1.0" },
2332
+ files: {
2333
+ "src/models/upload.ts": uploadModel(),
2334
+ "src/routes/uploads.ts": uploadsRoutes()
2335
+ },
2336
+ routes: [{ path: "/uploads", handler: "uploadRoutes", auth: false, importLine: 'import uploadRoutes from "./uploads.js";' }],
2337
+ env: { UPLOAD_URL_SECRET: "Secret for signing file download URLs (blank = reuse JWT_SECRET)." }
2338
+ }),
2339
+ nextSteps: [
2340
+ "Sign in, then open http://localhost:3000/uploads and upload an image or file.",
2341
+ "Files are stored in MongoDB and served via signed, expiring links \u2014 no S3 required.",
2342
+ "For large files or production, swap the Mongo storage for disk or object storage."
2343
+ ],
2344
+ learn: "https://developer.lacspace.com/packages/signed-url"
2278
2345
  }
2279
2346
  ];
2280
2347
  var aiChatRoute = (_ctx) => `import { resolveConfig } from "@lacspace/providers";
@@ -6259,6 +6326,291 @@ export default function EmailTestPage() {
6259
6326
  );
6260
6327
  }
6261
6328
  `;
6329
+ var i18nLib = () => `import en from "@/locales/en.json";
6330
+ import ne from "@/locales/ne.json";
6331
+
6332
+ // how this works: a tiny, dependency-free translator. Locale files live in locales/,
6333
+ // keys are flat strings, and {vars} are interpolated. A missing key falls back to
6334
+ // English, then to the key itself. Lint the files with \`npm run i18n:check\`.
6335
+ export const locales = ["en", "ne"] as const;
6336
+ export type Locale = (typeof locales)[number];
6337
+ export const defaultLocale: Locale = "en";
6338
+
6339
+ const dicts: Record<Locale, Record<string, string>> = {
6340
+ en: en as Record<string, string>,
6341
+ ne: ne as Record<string, string>,
6342
+ };
6343
+
6344
+ export function translate(locale: Locale, key: string, vars?: Record<string, string | number>): string {
6345
+ const table = dicts[locale] ?? dicts[defaultLocale];
6346
+ let str = table[key] ?? dicts[defaultLocale][key] ?? key;
6347
+ if (vars) for (const [k, v] of Object.entries(vars)) str = str.split("{" + k + "}").join(String(v));
6348
+ return str;
6349
+ }
6350
+ `;
6351
+ var i18nProvider = () => `"use client";
6352
+ import { createContext, useContext, useEffect, useState } from "react";
6353
+ import { locales, defaultLocale, translate, type Locale } from "@/lib/i18n";
6354
+
6355
+ // how this works: holds the current locale (persisted in localStorage) and exposes
6356
+ // t() via the useT() hook. Wrap your app in <LanguageProvider> once (in layout.tsx).
6357
+ interface LocaleCtxValue { locale: Locale; setLocale: (l: Locale) => void; }
6358
+ const LocaleCtx = createContext<LocaleCtxValue>({ locale: defaultLocale, setLocale: () => {} });
6359
+
6360
+ export function LanguageProvider({ children }: { children: React.ReactNode }) {
6361
+ const [locale, setLocaleState] = useState<Locale>(defaultLocale);
6362
+ useEffect(() => {
6363
+ try {
6364
+ const saved = localStorage.getItem("locale");
6365
+ if (saved && (locales as readonly string[]).includes(saved)) setLocaleState(saved as Locale);
6366
+ } catch {}
6367
+ }, []);
6368
+ const setLocale = (l: Locale) => { setLocaleState(l); try { localStorage.setItem("locale", l); } catch {} };
6369
+ return <LocaleCtx.Provider value={{ locale, setLocale }}>{children}</LocaleCtx.Provider>;
6370
+ }
6371
+
6372
+ export function useT() {
6373
+ const { locale, setLocale } = useContext(LocaleCtx);
6374
+ return {
6375
+ t: (key: string, vars?: Record<string, string | number>) => translate(locale, key, vars),
6376
+ locale,
6377
+ setLocale,
6378
+ };
6379
+ }
6380
+
6381
+ export function LanguageSwitcher() {
6382
+ const { locale, setLocale } = useT();
6383
+ return (
6384
+ <div className="inline-flex gap-1 rounded-full border border-hairline p-1">
6385
+ {locales.map((l) => (
6386
+ <button
6387
+ key={l}
6388
+ onClick={() => setLocale(l)}
6389
+ className={"rounded-full px-3 py-1 text-sm transition " + (l === locale ? "gradient-bg on-accent" : "text-muted hover:text-fg")}
6390
+ >
6391
+ {l.toUpperCase()}
6392
+ </button>
6393
+ ))}
6394
+ </div>
6395
+ );
6396
+ }
6397
+ `;
6398
+ var i18nDemoPage = () => `"use client";
6399
+ import { LanguageProvider, LanguageSwitcher, useT } from "@/components/language-provider";
6400
+
6401
+ function Demo() {
6402
+ const { t } = useT();
6403
+ return (
6404
+ <div className="space-y-4">
6405
+ <h1 className="text-3xl font-bold">{t("hello", { name: "world" })}</h1>
6406
+ <p className="text-muted">{t("tagline")}</p>
6407
+ <LanguageSwitcher />
6408
+ </div>
6409
+ );
6410
+ }
6411
+
6412
+ export default function I18nDemoPage() {
6413
+ return (
6414
+ <main className="mx-auto max-w-md px-6 py-16">
6415
+ <LanguageProvider>
6416
+ <Demo />
6417
+ </LanguageProvider>
6418
+ </main>
6419
+ );
6420
+ }
6421
+ `;
6422
+ var i18nEn = () => JSON.stringify(
6423
+ { hello: "Hello, {name}!", tagline: "This text switches language instantly \u2014 no reload.", "nav.home": "Home", "nav.about": "About" },
6424
+ null,
6425
+ 2
6426
+ ) + "\n";
6427
+ var i18nNe = () => JSON.stringify(
6428
+ { hello: "\u0928\u092E\u0938\u094D\u0924\u0947, {name}!", tagline: "\u092F\u094B \u092A\u093E\u0920 \u0924\u0941\u0930\u0941\u0928\u094D\u0924\u0948 \u092D\u093E\u0937\u093E \u092B\u0947\u0930\u094D\u091B \u2014 \u0930\u093F\u0932\u094B\u0921 \u092C\u093F\u0928\u093E\u0964", "nav.home": "\u0917\u0943\u0939", "nav.about": "\u092C\u093E\u0930\u0947\u092E\u093E" },
6429
+ null,
6430
+ 2
6431
+ ) + "\n";
6432
+ var qualityCiWorkflow = (ctx) => {
6433
+ const sizePath = ctx.mode === "dynamic" ? "frontend/.next/static" : ".next/static";
6434
+ const depsGate = ctx.mode === "dynamic" ? "duplicates" : "missing,duplicates";
6435
+ return `name: CI
6436
+ on:
6437
+ push:
6438
+ branches: [main]
6439
+ pull_request:
6440
+ jobs:
6441
+ quality:
6442
+ runs-on: ubuntu-latest
6443
+ steps:
6444
+ - uses: actions/checkout@v4
6445
+ - uses: actions/setup-node@v4
6446
+ with:
6447
+ node-version: 20
6448
+ cache: npm
6449
+ - run: npm ci
6450
+ - run: npm run build
6451
+ - name: Bundle-size budget
6452
+ run: npx lacspace-size@0.2.0 ${sizePath} --metric gzip --max 500kb
6453
+ - name: Dependency audit
6454
+ run: npx lacspace-deps@0.2.0 . --fail-on ${depsGate}
6455
+ `;
6456
+ };
6457
+ var uploadModel = () => `import mongoose from "mongoose";
6458
+ import { uuidv7 } from "@lacspace/id";
6459
+
6460
+ // how this works: files are stored base64-in-Mongo so it works with NO S3/disk setup.
6461
+ // For large files or production, swap this for disk or object storage.
6462
+ export interface UploadDoc {
6463
+ _id: string;
6464
+ userId: string;
6465
+ filename: string;
6466
+ contentType: string;
6467
+ size: number;
6468
+ data: string; // base64
6469
+ createdAt: Date;
6470
+ }
6471
+
6472
+ const schema = new mongoose.Schema<UploadDoc>(
6473
+ {
6474
+ _id: { type: String, default: () => uuidv7() },
6475
+ userId: { type: String, required: true, index: true },
6476
+ filename: { type: String, required: true },
6477
+ contentType: { type: String, default: "application/octet-stream" },
6478
+ size: { type: Number, default: 0 },
6479
+ data: { type: String, required: true },
6480
+ },
6481
+ { timestamps: { createdAt: true, updatedAt: false } },
6482
+ );
6483
+
6484
+ export const Upload =
6485
+ (mongoose.models.Upload as mongoose.Model<UploadDoc>) ?? mongoose.model<UploadDoc>("Upload", schema);
6486
+ `;
6487
+ var uploadsRoutes = () => `import express from "express";
6488
+ import { signUrl, verifyUrl } from "@lacspace/signed-url";
6489
+ import { v } from "@lacspace/validate";
6490
+ import { asyncHandler, HttpError } from "../http.js";
6491
+ import { requireAuth } from "../middleware/auth.js";
6492
+ import { env } from "../env.js";
6493
+ import { Upload } from "../models/upload.js";
6494
+
6495
+ // how this works: uploads live in Mongo; each file is served from a PUBLIC route
6496
+ // protected by a signed, expiring URL (@lacspace/signed-url) \u2014 so <img src> works
6497
+ // without a bearer token, yet the link can't be forged or shared forever.
6498
+ const router = express.Router();
6499
+ const SECRET = process.env.UPLOAD_URL_SECRET ?? env.JWT_SECRET;
6500
+ const MAX_BYTES = 5 * 1024 * 1024; // 5 MB \u2014 base64-in-Mongo, keep it small
6501
+
6502
+ const UploadInput = v.object({ filename: v.string().min(1).max(200), dataUrl: v.string().min(1) });
6503
+
6504
+ // Sign a RELATIVE URL; the frontend prefixes it with the API base. Verified as-is.
6505
+ function signed(id: string): Promise<string> {
6506
+ return signUrl("/uploads/" + id + "/raw", { secret: SECRET, expiresIn: 3600 });
6507
+ }
6508
+
6509
+ // GET /uploads/:id/raw \u2014 PUBLIC, but the signed query params must verify.
6510
+ router.get("/:id/raw", asyncHandler(async (req, res) => {
6511
+ const check = await verifyUrl(req.originalUrl, { secret: SECRET, clockToleranceSec: 60 });
6512
+ if (!check.valid) throw new HttpError(check.reason === "expired" ? 410 : 403, "Link expired or invalid");
6513
+ const file = await Upload.findById(req.params.id);
6514
+ if (!file) throw new HttpError(404, "Not found");
6515
+ res.setHeader("Content-Type", file.contentType);
6516
+ res.send(Buffer.from(file.data, "base64"));
6517
+ }));
6518
+
6519
+ // POST /uploads \u2014 protected: store a base64 data URL.
6520
+ router.post("/", requireAuth, asyncHandler(async (req, res) => {
6521
+ const { filename, dataUrl } = UploadInput.parse(req.body);
6522
+ const m = /^data:(.+?);base64,(.*)$/.exec(dataUrl);
6523
+ if (!m) throw new HttpError(400, "Expected a base64 data URL");
6524
+ const contentType = m[1]!;
6525
+ const data = m[2]!;
6526
+ const size = Math.floor((data.length * 3) / 4);
6527
+ if (size > MAX_BYTES) throw new HttpError(413, "File too large (max 5 MB)");
6528
+ const file = await Upload.create({ userId: req.user!.sub, filename, contentType, size, data });
6529
+ res.status(201).json({ id: String(file._id), filename, contentType, size, url: await signed(String(file._id)) });
6530
+ }));
6531
+
6532
+ // GET /uploads \u2014 protected: this user's files (with fresh signed URLs).
6533
+ router.get("/", requireAuth, asyncHandler(async (req, res) => {
6534
+ const files = await Upload.find({ userId: req.user!.sub }).sort({ createdAt: -1 }).select("filename contentType size");
6535
+ const out = await Promise.all(
6536
+ files.map(async (f) => ({ id: String(f._id), filename: f.filename, contentType: f.contentType, size: f.size, url: await signed(String(f._id)) })),
6537
+ );
6538
+ res.json(out);
6539
+ }));
6540
+
6541
+ export default router;
6542
+ `;
6543
+ var uploadsPage = () => `"use client";
6544
+ import { useEffect, useState } from "react";
6545
+ import { useRouter } from "next/navigation";
6546
+ import { getToken } from "@/lib/api";
6547
+
6548
+ const API = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:4000";
6549
+ interface FileItem { id: string; filename: string; contentType: string; size: number; url: string; }
6550
+
6551
+ function readAsDataUrl(file: File): Promise<string> {
6552
+ return new Promise((resolve, reject) => {
6553
+ const r = new FileReader();
6554
+ r.onload = () => resolve(String(r.result));
6555
+ r.onerror = () => reject(new Error("read failed"));
6556
+ r.readAsDataURL(file);
6557
+ });
6558
+ }
6559
+
6560
+ export default function UploadsPage() {
6561
+ const router = useRouter();
6562
+ const [files, setFiles] = useState<FileItem[]>([]);
6563
+ const [busy, setBusy] = useState(false);
6564
+ const [error, setError] = useState<string | null>(null);
6565
+
6566
+ async function load() {
6567
+ const token = getToken();
6568
+ if (!token) { router.push("/login"); return; }
6569
+ const res = await fetch(API + "/uploads", { headers: { Authorization: "Bearer " + token } });
6570
+ if (res.ok) setFiles(await res.json());
6571
+ }
6572
+ useEffect(() => { void load(); }, []);
6573
+
6574
+ async function onPick(e: React.ChangeEvent<HTMLInputElement>) {
6575
+ const file = e.target.files?.[0];
6576
+ if (!file) return;
6577
+ setBusy(true); setError(null);
6578
+ try {
6579
+ const dataUrl = await readAsDataUrl(file);
6580
+ const token = getToken();
6581
+ const res = await fetch(API + "/uploads", {
6582
+ method: "POST",
6583
+ headers: { "Content-Type": "application/json", ...(token ? { Authorization: "Bearer " + token } : {}) },
6584
+ body: JSON.stringify({ filename: file.name, dataUrl }),
6585
+ });
6586
+ const data: unknown = await res.json().catch(() => ({}));
6587
+ if (!res.ok) throw new Error((data as { error?: string }).error ?? "Upload failed");
6588
+ await load();
6589
+ } catch (err) { setError(err instanceof Error ? err.message : "Upload failed"); }
6590
+ finally { setBusy(false); }
6591
+ }
6592
+
6593
+ return (
6594
+ <main className="mx-auto max-w-lg px-6 py-16">
6595
+ <h1 className="text-2xl font-bold">Uploads</h1>
6596
+ <p className="mt-1 text-muted">Stored in MongoDB, served via signed, expiring links.</p>
6597
+ <label className="mt-6 flex cursor-pointer items-center justify-center rounded-2xl border border-dashed border-hairline p-8 text-muted transition hover:bg-surface">
6598
+ <input type="file" className="hidden" onChange={onPick} disabled={busy} />
6599
+ {busy ? "Uploading\u2026" : "Choose a file (max 5 MB)"}
6600
+ </label>
6601
+ {error && <p className="mt-3 text-sm text-red-400">{error}</p>}
6602
+ <ul className="mt-6 space-y-2">
6603
+ {files.map((f) => (
6604
+ <li key={f.id} className="flex items-center justify-between rounded-xl border border-hairline p-3">
6605
+ <a href={API + f.url} target="_blank" rel="noreferrer" className="truncate underline">{f.filename}</a>
6606
+ <span className="ml-3 shrink-0 text-sm text-muted">{Math.max(1, Math.round(f.size / 1024))} KB</span>
6607
+ </li>
6608
+ ))}
6609
+ </ul>
6610
+ </main>
6611
+ );
6612
+ }
6613
+ `;
6262
6614
  var scope = (ctx) => `@${ctx.name}`;
6263
6615
  var typesPkgJson = (ctx) => JSON.stringify({
6264
6616
  name: `${scope(ctx)}/types`,
@@ -6658,6 +7010,9 @@ function buildFullStack(ctx) {
6658
7010
  out[".gitignore"] = rootGitignore();
6659
7011
  out[".env.example"] = rootEnvExample(ctx);
6660
7012
  out["README.md"] = rootReadme(ctx);
7013
+ for (const f of ctx.features) {
7014
+ for (const [rel, content] of Object.entries(f.rootFiles?.(ctx) ?? {})) out[rel] = content;
7015
+ }
6661
7016
  const envBase = out[".env.example"];
6662
7017
  const seen = new Set(
6663
7018
  (envBase.match(/^#?\s*([A-Z0-9_]+)=/gm) ?? []).map((l) => l.replace(/^#?\s*/, "").replace(/=.*/, ""))
@@ -7217,7 +7572,7 @@ function backendFiles(ctx) {
7217
7572
  }
7218
7573
  var splitList = (s) => s.split(",").map((x) => x.trim()).filter(Boolean);
7219
7574
  function parseArgs(list) {
7220
- const a = { features: [], yes: false, install: true, git: true, pm: "npm", help: false };
7575
+ const a = { features: [], yes: false, install: true, git: true, pm: "npm", help: false, dryRun: false };
7221
7576
  for (let i = 0; i < list.length; i++) {
7222
7577
  const arg = list[i];
7223
7578
  const next = () => list[++i] ?? "";
@@ -7225,8 +7580,9 @@ function parseArgs(list) {
7225
7580
  else if (arg === "-y" || arg === "--yes") a.yes = true;
7226
7581
  else if (arg === "--no-install") a.install = false;
7227
7582
  else if (arg === "--no-git") a.git = false;
7583
+ else if (arg === "--dry-run" || arg === "--dry") a.dryRun = true;
7228
7584
  else if (arg === "--pm") a.pm = next();
7229
- else if (arg === "--theme" || arg === "--accent") a.theme = next();
7585
+ else if (arg === "--theme" || arg === "--accent" || arg === "--brand") a.theme = next();
7230
7586
  else if (arg === "--with" || arg === "--features") a.features.push(...splitList(next()));
7231
7587
  else if (arg === "--fullstack" || arg === "--full-stack" || arg === "--dynamic") a.mode = "dynamic";
7232
7588
  else if (arg === "--static") a.mode = "static";
@@ -7242,6 +7598,7 @@ function parseArgs(list) {
7242
7598
  else if (arg.startsWith("--template=")) a.template = arg.slice(11);
7243
7599
  else if (arg.startsWith("--theme=")) a.theme = arg.slice(8);
7244
7600
  else if (arg.startsWith("--accent=")) a.theme = arg.slice(9);
7601
+ else if (arg.startsWith("--brand=")) a.theme = arg.slice(8);
7245
7602
  else if (arg.startsWith("--with=")) a.features.push(...splitList(arg.slice(7)));
7246
7603
  else if (arg.startsWith("--features=")) a.features.push(...splitList(arg.slice(11)));
7247
7604
  else if (!arg.startsWith("-") && !a.name) a.name = arg;
@@ -7332,6 +7689,8 @@ ${c("bold", "Usage")}
7332
7689
  npm create lacspace-app@latest <name> [options]
7333
7690
  npx create-lacspace-app <name> --template <key>
7334
7691
  npx create-lacspace-app add <section...> ${c("dim", "# grow an existing app")}
7692
+ npx create-lacspace-app list ${c("dim", "# templates, add-ons & recipes")}
7693
+ npx create-lacspace-app explain <name> ${c("dim", "# what an add-on/recipe gives you")}
7335
7694
 
7336
7695
  ${c("bold", "Templates")}
7337
7696
  ${TEMPLATES.map((t) => ` ${t.key.padEnd(10)} ${t.description}`).join("\n")}
@@ -7343,8 +7702,9 @@ ${c("bold", "Options")}
7343
7702
  ${c("dim", "(alias --dynamic; default is --static, a single Next.js app)")}
7344
7703
  --with <a,b> Feature add-ons, comma-separated (alias --features)
7345
7704
  --recipe <key> Start from a curated stack (${RECIPES.map((r) => r.key).join(" | ")})
7346
- --theme <name|hex> Accent: a preset, a "#hex", or "from,to" (e.g. --theme lacspace)
7705
+ --theme <name|hex> Accent: a preset, a "#hex", or "from,to" (alias --brand)
7347
7706
  --pm <npm|pnpm|yarn|bun> Package manager (default npm)
7707
+ --dry-run Print the files that would be created; write nothing
7348
7708
  --no-install Skip installing dependencies
7349
7709
  --no-git Skip git init
7350
7710
  -y, --yes Accept defaults (needs <name>)
@@ -7720,12 +8080,103 @@ ${c("bold", "Use them")} \u2014 import into any page:
7720
8080
  return;
7721
8081
  }
7722
8082
  }
8083
+ function runList() {
8084
+ stdout.write(`
8085
+ ${c("bold", c("magenta", "\u25C6 create-lacspace-app"))} ${c("dim", "\u2014 what you can build")}
8086
+ `);
8087
+ stdout.write(`
8088
+ ${c("bold", "Templates")} ${c("dim", "(-t / --template)")}
8089
+ `);
8090
+ for (const t of TEMPLATES) stdout.write(` ${c("cyan", t.key.padEnd(12))} ${c("dim", t.description)}
8091
+ `);
8092
+ stdout.write(`
8093
+ ${c("bold", "Add-ons")} ${c("dim", "(--with) \u2014 free & keyless")}
8094
+ `);
8095
+ for (const f of FEATURES) stdout.write(` ${c("cyan", f.key.padEnd(12))} ${c("dim", f.description)}${f.requiresBackend ? c("green", " [full-stack]") : ""}
8096
+ `);
8097
+ stdout.write(`
8098
+ ${c("bold", "Recipes")} ${c("dim", "(--recipe) \u2014 a whole product in one command")}
8099
+ `);
8100
+ for (const r of RECIPES) stdout.write(` ${c("cyan", r.key.padEnd(14))} ${c("dim", r.description)}
8101
+ `);
8102
+ stdout.write(`
8103
+ ${c("dim", "Learn one:")} ${c("cyan", "npx create-lacspace-app explain <name>")}
8104
+
8105
+ `);
8106
+ }
8107
+ function runExplain(rawNames) {
8108
+ const name = rawNames.find((n) => !n.startsWith("-"))?.toLowerCase();
8109
+ if (!name) {
8110
+ stdout.write(`Usage: ${c("cyan", "npx create-lacspace-app explain <template|add-on|recipe>")}
8111
+
8112
+ `);
8113
+ runList();
8114
+ return;
8115
+ }
8116
+ const feat = FEATURES.find((f) => f.key === name);
8117
+ const recipe = RECIPES.find((r) => r.key === name);
8118
+ const tmpl = TEMPLATES.find((t) => t.key === name);
8119
+ stdout.write("\n");
8120
+ if (feat) {
8121
+ stdout.write(`${c("bold", c("magenta", "add-on: " + feat.key))} ${feat.requiresBackend ? c("green", "[full-stack]") : c("dim", "[frontend]")}
8122
+
8123
+ ${feat.description}
8124
+ `);
8125
+ const deps = { ...feat.deps, ...feat.backend?.({ name: "app", template: TEMPLATES[0], features: [], mode: "dynamic" })?.deps ?? {} };
8126
+ if (Object.keys(deps).length) stdout.write(`
8127
+ ${c("bold", "Packages")}: ${Object.keys(deps).map((d) => c("cyan", d)).join(", ")}
8128
+ `);
8129
+ stdout.write(`
8130
+ ${c("bold", "Next steps")}:
8131
+ `);
8132
+ for (const s of feat.nextSteps) stdout.write(` ${c("dim", "\u2022")} ${s}
8133
+ `);
8134
+ if (feat.learn) stdout.write(`
8135
+ Learn more \u2192 ${c("cyan", feat.learn)}
8136
+ `);
8137
+ stdout.write(`
8138
+ Add it: ${c("cyan", "npx create-lacspace-app my-app --with " + feat.key)}
8139
+
8140
+ `);
8141
+ } else if (recipe) {
8142
+ stdout.write(`${c("bold", c("magenta", "recipe: " + recipe.key))}
8143
+
8144
+ ${recipe.description}
8145
+
8146
+ ${c("bold", "Template")}: ${c("cyan", recipe.template)}${recipe.mode ? c("dim", " \xB7 " + recipe.mode) : ""}
8147
+ ${c("bold", "Add-ons")}: ${recipe.features.map((f) => c("cyan", f)).join(", ")}
8148
+
8149
+ Use it: ${c("cyan", "npx create-lacspace-app my-app --recipe " + recipe.key)}
8150
+
8151
+ `);
8152
+ } else if (tmpl) {
8153
+ stdout.write(`${c("bold", c("magenta", "template: " + tmpl.key))}
8154
+
8155
+ ${tmpl.description}
8156
+
8157
+ Use it: ${c("cyan", "npx create-lacspace-app my-app --template " + tmpl.key)}
8158
+
8159
+ `);
8160
+ } else {
8161
+ stdout.write(c("yellow", `Unknown "${name}".
8162
+ `));
8163
+ runList();
8164
+ }
8165
+ }
7723
8166
  async function main() {
7724
8167
  const raw = argv.slice(2);
7725
8168
  if (raw[0] === "add") {
7726
8169
  runAdd(raw.slice(1));
7727
8170
  return;
7728
8171
  }
8172
+ if (raw[0] === "list" || raw[0] === "ls") {
8173
+ runList();
8174
+ return;
8175
+ }
8176
+ if (raw[0] === "explain" || raw[0] === "info") {
8177
+ runExplain(raw.slice(1));
8178
+ return;
8179
+ }
7729
8180
  const args = parseArgs(raw);
7730
8181
  if (args.help) {
7731
8182
  stdout.write(HELP + "\n");
@@ -7744,10 +8195,32 @@ ${c("bold", c("magenta", "\u25C6 create-lacspace-app"))} ${c("dim", "\u2014 a go
7744
8195
  let templateKey = args.template ?? recipe?.template;
7745
8196
  let mode = args.mode ?? recipe?.mode ?? "static";
7746
8197
  const featureKeys = [...recipe?.features ?? [], ...args.features];
8198
+ let usedRecipe = Boolean(recipe);
7747
8199
  if (!args.yes && stdin.isTTY) {
7748
8200
  const rl = createInterface({ input: stdin, output: stdout });
7749
8201
  try {
7750
8202
  if (!name) name = (await rl.question(`${c("green", "?")} Project name ${c("dim", "(my-app)")}: `)).trim() || "my-app";
8203
+ if (!usedRecipe && !templateKey && featureKeys.length === 0) {
8204
+ stdout.write(`
8205
+ Start from a recipe? ${c("dim", "(a template + add-ons, ready to go)")}
8206
+ `);
8207
+ RECIPES.forEach((r, i) => stdout.write(` ${c("cyan", String(i + 1))}. ${c("bold", r.label)} ${c("dim", "\u2014 " + r.description)}
8208
+ `));
8209
+ stdout.write(` ${c("cyan", "0")}. ${c("dim", "No recipe \u2014 I'll choose a template myself")}
8210
+ `);
8211
+ const ans = (await rl.question(`
8212
+ ${c("green", "?")} Recipe ${c("dim", "(0)")}: `)).trim() || "0";
8213
+ const idx = /^\d+$/.test(ans) ? parseInt(ans, 10) - 1 : RECIPES.findIndex((r) => r.key === ans);
8214
+ const chosen = ans === "0" ? void 0 : RECIPES[idx];
8215
+ if (chosen) {
8216
+ usedRecipe = true;
8217
+ templateKey = chosen.template;
8218
+ mode = chosen.mode ?? mode;
8219
+ for (const k of chosen.features) if (!featureKeys.includes(k)) featureKeys.push(k);
8220
+ stdout.write(` ${c("green", "\u2714")} Recipe ${c("cyan", chosen.key)}
8221
+ `);
8222
+ }
8223
+ }
7751
8224
  if (!templateKey) {
7752
8225
  stdout.write(`
7753
8226
  Choose a template:
@@ -7759,7 +8232,7 @@ ${c("green", "?")} Template ${c("dim", "(1)")}: `)).trim() || "1";
7759
8232
  const idx = /^\d+$/.test(ans) ? parseInt(ans, 10) - 1 : TEMPLATES.findIndex((t) => t.key === ans);
7760
8233
  templateKey = TEMPLATES[idx]?.key ?? "personal";
7761
8234
  }
7762
- if (args.mode === void 0 && !recipe) {
8235
+ if (args.mode === void 0 && !usedRecipe) {
7763
8236
  stdout.write(`
7764
8237
  What kind of app?
7765
8238
  `);
@@ -7818,6 +8291,19 @@ ${c("green", "?")} Add features? ${c("dim", "(comma-separated numbers, or Enter
7818
8291
  `);
7819
8292
  }
7820
8293
  const files = buildFiles({ name: projectName, template, features, mode });
8294
+ if (args.dryRun) {
8295
+ const keys = Object.keys(files).sort();
8296
+ stdout.write(`
8297
+ ${c("bold", "Dry run")} ${c("dim", `\u2014 ${keys.length} files (${mode}${features.length ? ", +" + features.map((f) => f.key).join(",") : ""}), nothing written`)}
8298
+ `);
8299
+ for (const rel of keys) stdout.write(` ${c("dim", "+ " + rel)}
8300
+ `);
8301
+ stdout.write(`
8302
+ ${c("dim", "Remove --dry-run to create the project.")}
8303
+
8304
+ `);
8305
+ return;
8306
+ }
7821
8307
  for (const [rel, content] of Object.entries(files)) {
7822
8308
  const full = join(dir, rel);
7823
8309
  mkdirSync(dirname(full), { recursive: true });