create-lacspace-app 2.13.0 → 2.14.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/dist/lib.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { mkdir, writeFile } from 'fs/promises';
2
- import { resolve, basename, join, dirname } from 'path';
3
- import { existsSync, readdirSync, mkdirSync, writeFileSync } from 'fs';
2
+ import { basename, resolve, join, dirname } from 'path';
3
+ import { realpathSync, existsSync, readdirSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
4
4
  import { createInterface } from 'readline/promises';
5
- import { argv, stdout, exit, stdin, cwd } from 'process';
5
+ import { stdout, exit, argv, stdin, cwd } from 'process';
6
6
  import { spawnSync } from 'child_process';
7
- import { pathToFileURL } from 'url';
7
+ import { pathToFileURL, fileURLToPath } from 'url';
8
8
 
9
9
  // src/lib.ts
10
10
  var C = {
@@ -2435,8 +2435,364 @@ var FEATURES = [
2435
2435
  "SSE auto-reconnects and needs no WebSocket server \u2014 great for notifications and live feeds."
2436
2436
  ],
2437
2437
  learn: "https://developer.lacspace.com/packages/sse"
2438
+ },
2439
+ {
2440
+ key: "ui",
2441
+ label: "UI components",
2442
+ description: "The @lacspace/components library wired into this template \u2014 96 accessible components, a theme bridge so they inherit your accent and dark mode, and a working settings page. Frontend, any template.",
2443
+ deps: { "@lacspace/components": "^1.0.1" },
2444
+ files: () => ({
2445
+ "app/lacspace-ui.css": uiThemeBridge(),
2446
+ "app/ui/layout.tsx": uiRouteLayout(),
2447
+ "app/ui/page.tsx": uiShowcasePage(),
2448
+ "components/ui-provider.tsx": uiProviderComponent()
2449
+ }),
2450
+ nextSteps: [
2451
+ "Run `npm run dev` and open http://localhost:3000/ui \u2014 a real form, a confirm dialog and toasts, already themed.",
2452
+ 'Use the kit anywhere: import "@lacspace/components/styles.css" and "./lacspace-ui.css" in app/layout.tsx, then wrap <body> with <UIProvider> from @/components/ui-provider.',
2453
+ "Rebrand everything from app/lacspace-ui.css \u2014 it maps this template's accent, radius and font onto the kit's --lac-* variables, so dark mode follows your theme toggle."
2454
+ ],
2455
+ learn: "https://developer.lacspace.com/components"
2456
+ },
2457
+ {
2458
+ key: "dataviz",
2459
+ label: "Charts, tables & dates",
2460
+ description: "A working insights page from @lacspace/charts, @lacspace/table and @lacspace/date \u2014 SVG charts, a sortable/exportable data table and a date-range filter. No canvas, no D3, no grid licence. Frontend, any template.",
2461
+ deps: {
2462
+ "@lacspace/components": "^1.0.1",
2463
+ "@lacspace/charts": "^1.0.0",
2464
+ "@lacspace/table": "^1.0.0",
2465
+ "@lacspace/date": "^1.0.0"
2466
+ },
2467
+ files: () => ({
2468
+ "app/lacspace-ui.css": uiThemeBridge(),
2469
+ "app/insights/layout.tsx": dataVizRouteLayout(),
2470
+ "app/insights/page.tsx": dataVizPage()
2471
+ }),
2472
+ nextSteps: [
2473
+ "Run `npm run dev` and open http://localhost:3000/insights \u2014 stats, a line chart, a date-range filter and an exportable table.",
2474
+ "Swap the sample arrays at the top of app/insights/page.tsx for your own data; everything else is already wired.",
2475
+ "The CSV export neutralises leading =, +, - and @, so an exported cell can never run as a formula in Excel."
2476
+ ],
2477
+ learn: "https://developer.lacspace.com/components#charts"
2478
+ }
2479
+ ];
2480
+ var uiThemeBridge = () => `/* Map this app's tokens onto @lacspace/components.
2481
+ *
2482
+ * The kit's own dark palette lives behind \`prefers-color-scheme\` and a
2483
+ * \`data-theme\` attribute, but this app switches themes with a \`.dark\` class on
2484
+ * <html>. The repeated \`:root\` below is deliberate: it raises specificity just
2485
+ * enough to win against the kit's own theme blocks, whatever the OS setting is,
2486
+ * so the components follow YOUR toggle and never fight it.
2487
+ *
2488
+ * Every line here is a suggestion \u2014 change any of them and the whole kit
2489
+ * follows. The full token list is at the top of @lacspace/components/styles.css.
2490
+ */
2491
+ :root:root:root {
2492
+ /* Brand */
2493
+ --lac-accent: var(--accent-to);
2494
+ --lac-accent-hover: var(--accent-from);
2495
+ --lac-accent-active: var(--accent-from);
2496
+ --lac-accent-fg: var(--on-accent);
2497
+ --lac-accent-soft: color-mix(in oklab, var(--accent-to) 14%, transparent);
2498
+ --lac-accent-ring: color-mix(in oklab, var(--accent-to) 38%, transparent);
2499
+
2500
+ /* Surfaces & text \u2014 these already swap with the .dark class, so dark mode
2501
+ comes along for free. */
2502
+ --lac-bg: var(--bg);
2503
+ --lac-bg-subtle: var(--surface);
2504
+ --lac-bg-muted: var(--panel);
2505
+ --lac-surface: var(--surface);
2506
+ --lac-surface-raised: var(--panel);
2507
+ --lac-fg: var(--fg);
2508
+ --lac-fg-muted: var(--muted);
2509
+ --lac-fg-faint: var(--faint);
2510
+ --lac-fg-on-accent: var(--on-accent);
2511
+
2512
+ /* Lines & depth */
2513
+ --lac-border: var(--hairline);
2514
+ --lac-border-strong: color-mix(in oklab, var(--fg) 22%, transparent);
2515
+ --lac-shadow-sm: var(--shadow-sm);
2516
+ --lac-shadow: var(--shadow);
2517
+ --lac-shadow-lg: var(--shadow-lg);
2518
+
2519
+ /* Shape & type */
2520
+ --lac-radius: var(--radius);
2521
+ --lac-radius-lg: var(--radius-lg);
2522
+ --lac-font: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
2523
+ }
2524
+ `;
2525
+ var uiRouteLayout = () => `import "@lacspace/components/styles.css";
2526
+ import "../lacspace-ui.css";
2527
+ import { ToastProvider } from "@lacspace/components";
2528
+
2529
+ // Scoped to this route so the add-on needs no edits to app/layout.tsx. To use
2530
+ // the kit across the whole app, move these two imports there and wrap <body>
2531
+ // with <UIProvider> from @/components/ui-provider instead.
2532
+ export default function UILayout({ children }: { children: React.ReactNode }) {
2533
+ return <ToastProvider>{children}</ToastProvider>;
2534
+ }
2535
+ `;
2536
+ var uiProviderComponent = () => `"use client";
2537
+ import { ToastProvider } from "@lacspace/components";
2538
+
2539
+ /**
2540
+ * Wrap <body> with this once to use the component kit across the whole app,
2541
+ * and import the two stylesheets in app/layout.tsx:
2542
+ *
2543
+ * import "@lacspace/components/styles.css";
2544
+ * import "./lacspace-ui.css";
2545
+ */
2546
+ export function UIProvider({ children }: { children: React.ReactNode }) {
2547
+ return <ToastProvider position="bottom-right">{children}</ToastProvider>;
2548
+ }
2549
+ `;
2550
+ var uiShowcasePage = () => `"use client";
2551
+ import { useState } from "react";
2552
+ import {
2553
+ Alert,
2554
+ Badge,
2555
+ Button,
2556
+ Card,
2557
+ CardBody,
2558
+ CardDescription,
2559
+ CardHeader,
2560
+ CardTitle,
2561
+ ConfirmDialog,
2562
+ Field,
2563
+ Input,
2564
+ PasswordInput,
2565
+ Select,
2566
+ Stack,
2567
+ Switch,
2568
+ useToast,
2569
+ } from "@lacspace/components";
2570
+
2571
+ // Everything below is real: a form that validates, a dialog that waits for its
2572
+ // promise, and a toast queue \u2014 none of it styled with utility classes. The look
2573
+ // comes from app/lacspace-ui.css, which maps this template's tokens onto the kit.
2574
+ export default function UIPage() {
2575
+ const { toast } = useToast();
2576
+ const [confirming, setConfirming] = useState(false);
2577
+ const [updates, setUpdates] = useState(true);
2578
+ const [errors, setErrors] = useState<{ email?: string }>({});
2579
+
2580
+ function save(form: FormData) {
2581
+ const email = String(form.get("email") ?? "");
2582
+ if (!email.includes("@")) {
2583
+ setErrors({ email: "That doesn't look like an email address." });
2584
+ return;
2585
+ }
2586
+ setErrors({});
2587
+ toast({ title: "Settings saved", tone: "success" });
2438
2588
  }
2589
+
2590
+ return (
2591
+ <main className="mx-auto max-w-2xl px-6 py-16">
2592
+ <Stack gap={4}>
2593
+ <Card>
2594
+ <CardHeader>
2595
+ <CardTitle>Account settings</CardTitle>
2596
+ <CardDescription>
2597
+ 96 components from @lacspace/components \u2014 accessible, server-render safe, and
2598
+ themed by CSS variables instead of utility classes.
2599
+ </CardDescription>
2600
+ </CardHeader>
2601
+ <CardBody>
2602
+ <form action={save}>
2603
+ <Stack gap={3}>
2604
+ <Field label="Work email" hint="We never share it." error={errors.email}>
2605
+ {({ id, describedBy, invalid }) => (
2606
+ <Input
2607
+ id={id}
2608
+ name="email"
2609
+ type="email"
2610
+ defaultValue="you@company.com"
2611
+ aria-describedby={describedBy}
2612
+ invalid={invalid}
2613
+ />
2614
+ )}
2615
+ </Field>
2616
+
2617
+ <Field label="New password" hint="At least 12 characters.">
2618
+ {({ id, describedBy }) => (
2619
+ <PasswordInput id={id} name="password" aria-describedby={describedBy} strength />
2620
+ )}
2621
+ </Field>
2622
+
2623
+ <Field label="Plan">
2624
+ {({ id }) => (
2625
+ <Select
2626
+ id={id}
2627
+ name="plan"
2628
+ defaultValue="pro"
2629
+ options={[
2630
+ { value: "free", label: "Free" },
2631
+ { value: "pro", label: "Pro" },
2632
+ { value: "team", label: "Team" },
2633
+ ]}
2634
+ />
2635
+ )}
2636
+ </Field>
2637
+
2638
+ <Switch checked={updates} onChange={setUpdates} label="Email me about product updates" />
2639
+
2640
+ <Button type="submit" full>
2641
+ Save changes
2642
+ </Button>
2643
+ </Stack>
2644
+ </form>
2645
+ </CardBody>
2646
+ </Card>
2647
+
2648
+ <Alert tone="info" title="Rebrand the whole kit from one file">
2649
+ Open <code>app/lacspace-ui.css</code>. It maps this template&rsquo;s accent, radius and font
2650
+ onto the kit&rsquo;s variables, so the components already match \u2014 and they follow your
2651
+ existing dark-mode toggle.
2652
+ </Alert>
2653
+
2654
+ <Card>
2655
+ <CardBody>
2656
+ <Stack direction="row" gap={2} align="center" wrap>
2657
+ <Badge tone="success" dot>
2658
+ Live
2659
+ </Badge>
2660
+ <Button variant="soft" onClick={() => toast("Saved to drafts")}>
2661
+ Show a toast
2662
+ </Button>
2663
+ <Button tone="danger" variant="soft" onClick={() => setConfirming(true)}>
2664
+ Delete account
2665
+ </Button>
2666
+ </Stack>
2667
+ </CardBody>
2668
+ </Card>
2669
+ </Stack>
2670
+
2671
+ <ConfirmDialog
2672
+ open={confirming}
2673
+ onOpenChange={setConfirming}
2674
+ tone="danger"
2675
+ title="Delete this account?"
2676
+ message="Everything in it goes with it. This cannot be undone."
2677
+ confirmLabel="Delete account"
2678
+ onConfirm={async () => {
2679
+ // Return a promise and the button spins, blocks repeat clicks, and
2680
+ // keeps the dialog open if it rejects \u2014 a failed delete never looks
2681
+ // like a successful one.
2682
+ await new Promise((resolve) => setTimeout(resolve, 700));
2683
+ toast({ title: "Account deleted", tone: "success" });
2684
+ }}
2685
+ />
2686
+ </main>
2687
+ );
2688
+ }
2689
+ `;
2690
+ var dataVizRouteLayout = () => `import "@lacspace/components/styles.css";
2691
+ import "@lacspace/charts/styles.css";
2692
+ import "@lacspace/table/styles.css";
2693
+ import "@lacspace/date/styles.css";
2694
+ import "../lacspace-ui.css";
2695
+
2696
+ // Scoped to this route; move these imports to app/layout.tsx to use the kit
2697
+ // everywhere. Order matters: lacspace-ui.css maps this app's tokens onto the
2698
+ // kit, so it comes last.
2699
+ export default function InsightsLayout({ children }: { children: React.ReactNode }) {
2700
+ return <>{children}</>;
2701
+ }
2702
+ `;
2703
+ var dataVizPage = () => `"use client";
2704
+ import { useState } from "react";
2705
+ import { Heading, Grid, Stack, Stat, Text } from "@lacspace/components";
2706
+ import { LineChart } from "@lacspace/charts";
2707
+ import { DataTable, textColumn, badgeColumn, currencyColumn, numberColumn } from "@lacspace/table";
2708
+ import { DateRangePicker, defaultPresets } from "@lacspace/date";
2709
+
2710
+ // Swap these three arrays for your own data \u2014 nothing else needs to change.
2711
+ const MONTHS = ["Apr", "May", "Jun", "Jul", "Aug", "Sep"];
2712
+ const REVENUE = [18, 21, 25, 24, 31, 38];
2713
+ const TARGET = [20, 22, 24, 26, 28, 30];
2714
+
2715
+ type Account = {
2716
+ id: string;
2717
+ account: string;
2718
+ plan: string;
2719
+ seats: number;
2720
+ mrr: number;
2721
+ };
2722
+
2723
+ const ACCOUNTS: Account[] = [
2724
+ { id: "1", account: "Northwind", plan: "team", seats: 42, mrr: 1890 },
2725
+ { id: "2", account: "Umbrella", plan: "pro", seats: 12, mrr: 540 },
2726
+ { id: "3", account: "Initech", plan: "team", seats: 68, mrr: 3060 },
2727
+ { id: "4", account: "Hooli", plan: "free", seats: 3, mrr: 0 },
2728
+ { id: "5", account: "Stark Industries", plan: "pro", seats: 19, mrr: 855 },
2729
+ { id: "6", account: "Wayne Enterprises", plan: "team", seats: 51, mrr: 2295 },
2439
2730
  ];
2731
+
2732
+ export default function InsightsPage() {
2733
+ const [range, setRange] = useState<unknown>(null);
2734
+
2735
+ return (
2736
+ <main className="mx-auto max-w-5xl px-6 py-16">
2737
+ <Stack gap={5}>
2738
+ <Stack direction="row" justify="between" align="center" gap={3} wrap>
2739
+ <div>
2740
+ <Heading level={1}>Insights</Heading>
2741
+ <Text tone="muted">Charts, a data table and a date filter \u2014 all zero-dependency.</Text>
2742
+ </div>
2743
+ <DateRangePicker
2744
+ numberOfMonths={2}
2745
+ presets={defaultPresets()}
2746
+ separator=" \u2013 "
2747
+ onChange={setRange}
2748
+ />
2749
+ </Stack>
2750
+
2751
+ <Grid columns={{ base: 1, md: 3 }} gap={3}>
2752
+ <Stat label="MRR" value="$8,640" delta={12.4} comparison="vs last month" />
2753
+ <Stat label="Seats" value="195" delta={6.1} comparison="vs last month" />
2754
+ <Stat label="Churn" value="1.8%" delta={-0.3} invertDelta comparison="vs last month" />
2755
+ </Grid>
2756
+
2757
+ <LineChart
2758
+ labels={MONTHS}
2759
+ series={[
2760
+ { name: "Revenue", data: REVENUE, area: true },
2761
+ { name: "Target", data: TARGET, dashed: true },
2762
+ ]}
2763
+ curve
2764
+ dots
2765
+ tooltip
2766
+ responsive
2767
+ dataTable
2768
+ formatValue={(n) => "$" + n + "k"}
2769
+ />
2770
+
2771
+ <DataTable<Account>
2772
+ caption="Accounts"
2773
+ data={ACCOUNTS}
2774
+ getRowId={(row) => row.id}
2775
+ columns={[
2776
+ textColumn<Account>("account", { header: "Account", key: "account", pinned: "left" }),
2777
+ badgeColumn<Account>("plan", {
2778
+ header: "Plan",
2779
+ key: "plan",
2780
+ tones: { team: "success", pro: "info", free: "default" },
2781
+ }),
2782
+ numberColumn<Account>("seats", { header: "Seats", key: "seats", aggregate: "sum" }),
2783
+ currencyColumn<Account>("mrr", { header: "MRR", key: "mrr", currency: "USD", aggregate: "sum" }),
2784
+ ]}
2785
+ defaultSort={[{ id: "mrr", direction: "desc" }]}
2786
+ searchable
2787
+ selectable
2788
+ exportable
2789
+ stickyHeader
2790
+ />
2791
+ </Stack>
2792
+ </main>
2793
+ );
2794
+ }
2795
+ `;
2440
2796
  var aiChatRoute = (_ctx) => `import { resolveConfig } from "@lacspace/providers";
2441
2797
  import { stream } from "@lacspace/ai";
2442
2798
  import type { Message } from "@lacspace/ai";
@@ -8015,9 +8371,24 @@ function backendFiles(ctx) {
8015
8371
  }
8016
8372
  return files;
8017
8373
  }
8374
+ function cliVersion() {
8375
+ try {
8376
+ const here = dirname(fileURLToPath(import.meta.url));
8377
+ for (const rel of ["../package.json", "./package.json", "../../package.json"]) {
8378
+ const file = resolve(here, rel);
8379
+ if (!existsSync(file)) continue;
8380
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
8381
+ const version = parsed.version;
8382
+ const name = parsed.name;
8383
+ if (typeof version === "string" && (name === "create-lacspace-app" || rel !== "../../package.json")) return version;
8384
+ }
8385
+ } catch {
8386
+ }
8387
+ return "unknown";
8388
+ }
8018
8389
  var splitList = (s) => s.split(",").map((x) => x.trim()).filter(Boolean);
8019
8390
  function parseArgs(list) {
8020
- const a = { features: [], yes: false, install: true, git: true, pm: "npm", help: false, dryRun: false };
8391
+ const a = { features: [], yes: false, install: true, git: true, pm: "npm", help: false, version: false, dryRun: false, unknown: [] };
8021
8392
  for (let i = 0; i < list.length; i++) {
8022
8393
  const arg = list[i];
8023
8394
  const next = () => list[++i] ?? "";
@@ -8040,6 +8411,7 @@ function parseArgs(list) {
8040
8411
  } else if (arg === "--recipe") a.recipe = next();
8041
8412
  else if (arg.startsWith("--recipe=")) a.recipe = arg.slice(9);
8042
8413
  else if (arg === "-h" || arg === "--help") a.help = true;
8414
+ else if (arg === "-v" || arg === "-V" || arg === "--version") a.version = true;
8043
8415
  else if (arg.startsWith("--template=")) a.template = arg.slice(11);
8044
8416
  else if (arg.startsWith("--theme=")) a.theme = arg.slice(8);
8045
8417
  else if (arg.startsWith("--accent=")) a.theme = arg.slice(9);
@@ -8047,6 +8419,7 @@ function parseArgs(list) {
8047
8419
  else if (arg.startsWith("--with=")) a.features.push(...splitList(arg.slice(7)));
8048
8420
  else if (arg.startsWith("--features=")) a.features.push(...splitList(arg.slice(11)));
8049
8421
  else if (!arg.startsWith("-") && !a.name) a.name = arg;
8422
+ else if (arg.startsWith("-")) a.unknown.push(arg);
8050
8423
  }
8051
8424
  return a;
8052
8425
  }
@@ -8154,6 +8527,7 @@ ${c("bold", "Options")}
8154
8527
  --no-git Skip git init
8155
8528
  -y, --yes Accept defaults (needs <name>)
8156
8529
  -h, --help Show this help
8530
+ -v, --version Print the version and exit
8157
8531
 
8158
8532
  ${c("bold", "Feature add-ons")} ${c("dim", "(--with) \u2014 free & keyless, local by default")}
8159
8533
  ${FEATURES.map((f) => ` ${f.key.padEnd(11)} ${f.description}`).join("\n")}
@@ -8627,6 +9001,16 @@ async function main() {
8627
9001
  stdout.write(HELP + "\n");
8628
9002
  return;
8629
9003
  }
9004
+ if (args.version) {
9005
+ stdout.write(`create-lacspace-app ${cliVersion()}
9006
+ `);
9007
+ return;
9008
+ }
9009
+ if (args.unknown.length) {
9010
+ stdout.write(c("yellow", `
9011
+ ! Unknown option${args.unknown.length > 1 ? "s" : ""}: ${args.unknown.join(", ")} \u2014 ignoring. Run with --help to see every flag.
9012
+ `));
9013
+ }
8630
9014
  stdout.write(`
8631
9015
  ${c("bold", c("magenta", "\u25C6 create-lacspace-app"))} ${c("dim", "\u2014 a gorgeous Next.js starter, batteries wired")}
8632
9016
 
@@ -8825,8 +9209,18 @@ ${c("bold", "Your feature add-ons")} ${c("dim", "\u2014 details in LEARN.md")}
8825
9209
 
8826
9210
  `);
8827
9211
  }
8828
- var invokedAsCli = argv[1] ? import.meta.url === pathToFileURL(argv[1]).href : false;
8829
- if (invokedAsCli) {
9212
+ function isDirectRun() {
9213
+ const entry = argv[1];
9214
+ if (!entry) return false;
9215
+ const here = import.meta.url;
9216
+ if (here === pathToFileURL(entry).href) return true;
9217
+ try {
9218
+ if (here === pathToFileURL(realpathSync(entry)).href) return true;
9219
+ } catch {
9220
+ }
9221
+ return basename(entry).replace(/\.[cm]?js$/, "") === "create-lacspace-app";
9222
+ }
9223
+ if (isDirectRun()) {
8830
9224
  main().catch((err) => {
8831
9225
  stdout.write(c("red", `
8832
9226
  \u2717 ${err instanceof Error ? err.message : String(err)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lacspace-app",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Scaffold a beautiful, production-ready Next.js app from a Lacspace template — portfolio, business, e-commerce, SaaS, blog, docs, dashboard, restaurant or marketplace — pre-wired with SEO, security headers, sitemap and robots. Use it as a CLI (like create-next-app, but you start gorgeous) or import it as a library to generate projects programmatically.",
5
5
  "type": "module",
6
6
  "bin": {