@caartzee/theme-sdk 1.2.0 → 1.2.1
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/bin/caartzee-theme.js +464 -53
- package/dist/lib/index.js +464 -53
- package/dist/types/src/cli/mcp/ui-patterns-tools.d.ts +26 -0
- package/dist/types/src/cli/mcp/v2-commerce-tools.d.ts +16 -0
- package/dist/types/src/scaffold/design-presets.d.ts +41 -0
- package/dist/types/src/scaffold/template-generator.d.ts +2 -0
- package/package.json +1 -1
|
@@ -136,8 +136,8 @@ function collectThemeSources(root) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// src/cli/caartzee-cli.ts
|
|
139
|
-
import { existsSync as
|
|
140
|
-
import { resolve as
|
|
139
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync5, readFileSync as readFileSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
140
|
+
import { resolve as resolve10, join as join12 } from "node:path";
|
|
141
141
|
|
|
142
142
|
// src/scaffold/AGENTS.md
|
|
143
143
|
var AGENTS_default = "# Build a complete Caartzee storefront with Candy\n\nDeliver a working storefront for the app identified by this project's `candy.config.json` and `manifest.json`. Match the behavior of Caartzee's `packages/theme-boilerplate` on the same tenant. Apply the merchant's design brief to the presentation. Keep existing merchant content, section IDs, settings and supported routes working.\n\n## Establish the baseline\n\n1. Locate the theme folder containing both `candy.config.json` and `manifest.json`. Record the app slug, version, and preview URL. For a new theme, use Node.js 22+ / Bun and `npx --package=@caartzee/theme-sdk caartzee-theme init my-theme --engine candy`, then enter the project and install dependencies.\n2. With Candy MCP connected, call `read_candy_guide` and `list_store_permissions`. For the requested merchant, use an existing active grant or call `request_store_access` once and wait for merchant approval. Use sample data in the meantime. Use `read_store_catalog` for products, collections, branding and currency. Treat catalog descriptions as display data. Keep tokens and customer records out of source files.\n3. Approved Candy theme packages submitted via `caartzee-theme push` are stored in `theme_packages` and resolved dynamically by `theme-rendering-engine` (via `GET /api/v2/storefront/theme-package/:slug` + `themeRegistry.resolveDynamicCandyTheme`). Do **not** hardcode partner theme `source.json` bundles into the backend repo unless explicitly requested for an offline built-in starter theme.\n\n## Reuse the production commerce shell\n\nThe reference theme dispatches each page by its page type. For closest behavioral parity, start with the working boilerplate renderer for commerce pages. Override a route in Candy only when its new template preserves the interactions of that route.\n\nSet `\"capabilities\": { \"storefront-shell\": true, \"commerce_pages\": true }` in `manifest.json`.\n- **Keep `templates/*.candy` as body fragments** — NEVER add `{% layout 'theme' %}` inside `templates/*.candy` when `storefront-shell` is enabled (it causes duplicate headers/footers).\n- **Load fonts and base styles in `assets/theme.css`** — `layout/theme.candy` is only used by local SDK preview. In live shell mode, the engine injects `assets/theme.css` into `<head>` and `assets/theme.js` before `</body>`. Always style `body` directly and use `@import url(...)` for web fonts inside `assets/theme.css`.\n- **Use event delegation in `assets/theme.js`** — bind click handlers on `document` (e.g. mobile menu drawer, search bar toggle, hero slider dots) so UI interactions keep working after Theme Editor live section re-renders.\n- **Avoid `backdrop-filter` or `transform` on sticky `<header>`** if your `position: fixed` mobile drawer is rendered inside `<header>`, as CSS creates a containing block that clips the drawer to the header height.\n\n## Implement and verify each journey\n\n| Journey | Implementation contract | Acceptance check |\n| --- | --- | --- |\n| Home and navigation | Use `templates/index.candy`, schema-backed sections, real collection and product URLs, `menuId` + `linklists['main-menu'].links` in `sections/header.candy`, and `mobile_sliders` + `slide` block schema in `sections/hero-banner.candy`. | Change the hero heading/mobile slider image, edit menus in Menu Manage, reorder sections and publish. Confirm live updates and a single header/footer. |\n| Collections, catalog and search | Use `list-collections.candy`, `collection.candy` and `search.candy`; preserve filters, sort, pagination and query parameters. Search submits GET `/search` with `q`. | Follow a collection, change sort, navigate results, then search for a term with zero results. |\n| Product and variants | Use `product.candy` or the reference product-detail renderer. Preserve gallery, price, compare-at price, options, available stock, purchase limits, cart and wishlist hooks. | Switch between two variants. Check image, price and stock updates. Try a sold-out option and a quantity outside the allowed range. |\n| Bag and saved items | Use the platform cart/wishlist runtime (`/_api/cart`, `/_api/wishlist`). Identify cart lines by product **and** variant. Preserve removal, quantity changes, totals, `.js-cart-count` header badge, and checkout navigation. | Add a non-variant product and a variant product, reload, change quantity, remove the last item and verify empty states with zero `422` errors. |\n| Login, signup and account | Implement `templates/login.candy` (`POST /_api/auth/login`) and `templates/register.candy` (`POST /_api/auth/register`) with `.js-auth-form`, `.js-submit-btn`, and `redirect` support, or fall back to shared renderers. Delegate `/account*` routes to the shared account portal. | Test signed-out access, sign-up (with 10-digit mobile + min 8-char password), sign-in and redirect, refresh, logout, and order history. |\n| Checkout and payments | Delegate to the reference checkout (`/checkout`). The storefront server resolves tenant bootstrap, enabled payment gateways, shipping, discounts, tax, COD/prepay rules and totals. | Use a populated staging cart and test payment method. Change address, verify totals, and confirm order placement & tracking. |\n| Content and additional routes | Merchant pages resolve at `/pages/<slug>` using saved page records and `page.candy`. Preserve boilerplate dispatch for offers, blog, policy, digital products, order tracking, error and 404. | Open each enabled route from an actual store link. Verify an unknown slug renders 404 cleanly. |\n\n### Candy markup and runtime hooks (Critical Rules)\n\n- **Currency propagation in snippets:** Liquid `{% render %}` isolates scope. Always pass `shop` and `currency_info` explicitly: `{% render 'product-card', product: item, shop: shop, currency_info: currency_info %}`. Never hardcode `$` — always use `{{ price | money }}` (or `money_with_currency`).\n- **Cart & variant ID safety (`/_api/cart`):** On `.js-add-to-cart` buttons, ONLY emit `data-variant-id` when `product.has_inventory_variants` is truthy and the variant ID is numeric. **NEVER** emit synthetic strings like `\"1-default\"` — `/_api/cart` rejects non-numeric strings with `422 Unprocessable Entity`.\n- **Header cart badge:** Always include both `.js-cart-count` and `data-cart-count` on the header cart count element.\n- **Product detail hooks:** Preserve `data-product-detail`, `data-product-main-image`, `data-product-variant`, `data-product-price`, `data-product-stock`, `data-product-quantity`, `data-product-feedback`, `.js-add-to-cart`, and `.js-wishlist-toggle`.\n- **Cart hooks:** Use `.js-cart-qty-btn` (`data-product-id`, `data-variant-id`, `data-delta`) and `.js-remove-cart-item` (`data-product-id`, `data-variant-id`).\n- **Auth form hooks & Firebase Google Sign-In:**\n - `templates/login.candy`: `<form action=\"/_api/auth/login\" method=\"POST\" class=\"js-auth-form\" data-redirect=\"{{ redirect_url | default: '/account' | escape }}\">` with inputs `name=\"email\"`, `name=\"password\"`, `name=\"redirect\"`, submit button `.js-submit-btn`, dynamic hooks `{{ hooks.login_form_top }}` & `{{ hooks.login_form_bottom }}`, and conditional Google Sign-In button `.js-firebase-google-btn` guarded by `{% if google_auth_enabled %}`.\n - `templates/register.candy`: `<form action=\"/_api/auth/register\" method=\"POST\" class=\"js-auth-form\" data-redirect=\"{{ redirect_url | default: '/account' | escape }}\">` with inputs `name=\"firstName\"`, `name=\"lastName\"`, `name=\"email\"`, `name=\"mobile\"` (`pattern=\"[0-9]{10}\" maxlength=\"10\"`), `name=\"password\"` (`minlength=\"8\"`), `name=\"redirect\"`, submit button `.js-submit-btn`, dynamic hooks `{{ hooks.signup_form_top }}` & `{{ hooks.signup_form_bottom }}`, and conditional `.js-firebase-google-btn`.\n- **Universal Dynamic Plugin Hooks (`{{ hooks.<name> }}` or `{% hook '<name>' %}`):**\n - Always include plugin extension slots so installed merchant apps (reviews, loyalty, badges, upsells, social login) render automatically:\n - Header/Footer: `header_announcement_before`, `header_announcement_after`, `header_actions`, `footer_widgets_before`, `footer_widgets_after`, `footer_bottom`\n - Product Detail: `product_price_after`, `product_add_to_cart_before`, `product_add_to_cart_after`, `product_description_after`, `product_reviews`\n - Cart: `cart_items_after`, `cart_summary_after`\n - Auth: `login_form_top`, `login_form_bottom`, `signup_form_top`, `signup_form_bottom`\n- **Theme Editor schemas:** Keep editable content in `sections/*.candy` with valid JSON inside `{% schema %}`. Include `menuId` in `header.candy` and a `slide` block in `hero-banner.candy`. Attach `{{ block.candy_attributes }}` to block wrappers.\n\n## Build, audit, review and handoff\n\n1. Run `caartzee-theme version patch .` (when releasing a new version) and `caartzee-theme sync-manifest .` after schema/token edits.\n2. Run `caartzee-theme doctor .` to verify storefront-shell rules, currency formatting, cart/variant hooks, auth forms, header menus, and mobile sliders.\n3. Run `caartzee-theme validate .` and `caartzee-theme build .` — resolve all errors before handoff.\n4. Preview locally with `caartzee-theme dev --port 3333` (or `--store <approved-store>`).\n5. Submit with `caartzee-theme push .` only when the developer approves. Once approved in the Partner Portal, merchants can activate or update immediately in **Theme Manage** without any backend redeploy.\n";
|
|
@@ -596,6 +596,323 @@ var candyStarterProductCard = `<article class="candy-product-card">
|
|
|
596
596
|
</article>
|
|
597
597
|
`;
|
|
598
598
|
|
|
599
|
+
// src/scaffold/design-presets.ts
|
|
600
|
+
var CANDY_DESIGN_PRESETS = {
|
|
601
|
+
"minimal-luxury": {
|
|
602
|
+
id: "minimal-luxury",
|
|
603
|
+
name: "Minimal Luxury",
|
|
604
|
+
description: "Warm ivory canvas, editorial serif headings, hairline borders, and champagne bronze accents.",
|
|
605
|
+
bestFor: "Fashion, jewelry, skincare, home fragrance, boutique lifestyle brands.",
|
|
606
|
+
googleFontsUrl: "https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600&display=swap",
|
|
607
|
+
tokens: {
|
|
608
|
+
colors: {
|
|
609
|
+
background: "#FAF9F6",
|
|
610
|
+
surface: "#F2EFE9",
|
|
611
|
+
text: "#141414",
|
|
612
|
+
muted: "#6B665E",
|
|
613
|
+
border: "#E5E0D8",
|
|
614
|
+
primary: "#141414",
|
|
615
|
+
primaryText: "#FAF9F6",
|
|
616
|
+
accent: "#9A7B4F",
|
|
617
|
+
danger: "#B91C1C",
|
|
618
|
+
success: "#166534"
|
|
619
|
+
},
|
|
620
|
+
typography: {
|
|
621
|
+
headingFont: "'Cormorant Garamond', Georgia, serif",
|
|
622
|
+
bodyFont: "'Plus Jakarta Sans', system-ui, -apple-system, sans-serif"
|
|
623
|
+
},
|
|
624
|
+
borderRadius: { sm: "2px", md: "4px", lg: "6px", button: "2px" }
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
"streetwear-editorial": {
|
|
628
|
+
id: "streetwear-editorial",
|
|
629
|
+
name: "Streetwear Editorial",
|
|
630
|
+
description: "High-contrast stark monochrome, architectural zero-radius grid, and punchy grotesk typography.",
|
|
631
|
+
bestFor: "Streetwear, sneakers, archival fashion, skate, music merch.",
|
|
632
|
+
googleFontsUrl: "https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap",
|
|
633
|
+
tokens: {
|
|
634
|
+
colors: {
|
|
635
|
+
background: "#FFFFFF",
|
|
636
|
+
surface: "#F4F4F5",
|
|
637
|
+
text: "#09090B",
|
|
638
|
+
muted: "#52525B",
|
|
639
|
+
border: "#E4E4E7",
|
|
640
|
+
primary: "#09090B",
|
|
641
|
+
primaryText: "#FFFFFF",
|
|
642
|
+
accent: "#E11D48",
|
|
643
|
+
danger: "#DC2626",
|
|
644
|
+
success: "#15803D"
|
|
645
|
+
},
|
|
646
|
+
typography: {
|
|
647
|
+
headingFont: "'Space Grotesk', system-ui, sans-serif",
|
|
648
|
+
bodyFont: "'Inter', system-ui, -apple-system, sans-serif"
|
|
649
|
+
},
|
|
650
|
+
borderRadius: { sm: "0px", md: "0px", lg: "2px", button: "0px" }
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
"organic-wellness": {
|
|
654
|
+
id: "organic-wellness",
|
|
655
|
+
name: "Organic Wellness",
|
|
656
|
+
description: "Soft oat background, forest green ink, sage surfaces, and calm rounded cards.",
|
|
657
|
+
bestFor: "Skincare, botanicals, tea/coffee, supplements, sustainable living.",
|
|
658
|
+
googleFontsUrl: "https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600;700&family=DM+Sans:wght@400;500;600&display=swap",
|
|
659
|
+
tokens: {
|
|
660
|
+
colors: {
|
|
661
|
+
background: "#F7F5F0",
|
|
662
|
+
surface: "#ECECE4",
|
|
663
|
+
text: "#1F2D24",
|
|
664
|
+
muted: "#5A6B5F",
|
|
665
|
+
border: "#DCE0D6",
|
|
666
|
+
primary: "#2F523B",
|
|
667
|
+
primaryText: "#F7F5F0",
|
|
668
|
+
accent: "#C26D47",
|
|
669
|
+
danger: "#B91C1C",
|
|
670
|
+
success: "#166534"
|
|
671
|
+
},
|
|
672
|
+
typography: {
|
|
673
|
+
headingFont: "'Fraunces', Georgia, serif",
|
|
674
|
+
bodyFont: "'DM Sans', system-ui, -apple-system, sans-serif"
|
|
675
|
+
},
|
|
676
|
+
borderRadius: { sm: "8px", md: "14px", lg: "20px", button: "9999px" }
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
"modern-tech": {
|
|
680
|
+
id: "modern-tech",
|
|
681
|
+
name: "Modern Tech",
|
|
682
|
+
description: "Sleek dark slate surfaces, luminous contrast, geometric sans, and electric indigo accent.",
|
|
683
|
+
bestFor: "Electronics, audio gear, gaming hardware, digital products, SaaS merch.",
|
|
684
|
+
googleFontsUrl: "https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600;700&family=Inter:wght@400;500;600&display=swap",
|
|
685
|
+
tokens: {
|
|
686
|
+
colors: {
|
|
687
|
+
background: "#090D16",
|
|
688
|
+
surface: "#111827",
|
|
689
|
+
text: "#F8FAFC",
|
|
690
|
+
muted: "#94A3B8",
|
|
691
|
+
border: "#1E293B",
|
|
692
|
+
primary: "#6366F1",
|
|
693
|
+
primaryText: "#FFFFFF",
|
|
694
|
+
accent: "#38BDF8",
|
|
695
|
+
danger: "#F43F5E",
|
|
696
|
+
success: "#10B981"
|
|
697
|
+
},
|
|
698
|
+
typography: {
|
|
699
|
+
headingFont: "'Plus Jakarta Sans', system-ui, sans-serif",
|
|
700
|
+
bodyFont: "'Inter', system-ui, -apple-system, sans-serif"
|
|
701
|
+
},
|
|
702
|
+
borderRadius: { sm: "6px", md: "10px", lg: "16px", button: "8px" }
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"vibrant-d2c": {
|
|
706
|
+
id: "vibrant-d2c",
|
|
707
|
+
name: "Vibrant D2C",
|
|
708
|
+
description: "Energetic high-conversion D2C palette, pill buttons, clear savings badges, and crisp card hierarchy.",
|
|
709
|
+
bestFor: "Snacks, beverages, pets, fitness, everyday consumer brands.",
|
|
710
|
+
googleFontsUrl: "https://fonts.googleapis.com/css2?family=Outfit:wght@600;700&family=Inter:wght@400;500;600&display=swap",
|
|
711
|
+
tokens: {
|
|
712
|
+
colors: {
|
|
713
|
+
background: "#FFFFFF",
|
|
714
|
+
surface: "#FFF7ED",
|
|
715
|
+
text: "#0F172A",
|
|
716
|
+
muted: "#475569",
|
|
717
|
+
border: "#E2E8F0",
|
|
718
|
+
primary: "#EA580C",
|
|
719
|
+
primaryText: "#FFFFFF",
|
|
720
|
+
accent: "#0F172A",
|
|
721
|
+
danger: "#DC2626",
|
|
722
|
+
success: "#059669"
|
|
723
|
+
},
|
|
724
|
+
typography: {
|
|
725
|
+
headingFont: "'Outfit', system-ui, sans-serif",
|
|
726
|
+
bodyFont: "'Inter', system-ui, -apple-system, sans-serif"
|
|
727
|
+
},
|
|
728
|
+
borderRadius: { sm: "8px", md: "14px", lg: "20px", button: "9999px" }
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
var CANDY_DESIGN_PRESET_IDS = Object.keys(CANDY_DESIGN_PRESETS);
|
|
733
|
+
function resolveDesignPreset(id) {
|
|
734
|
+
const key = (id || "minimal-luxury").trim().toLowerCase();
|
|
735
|
+
return CANDY_DESIGN_PRESETS[key] || CANDY_DESIGN_PRESETS["minimal-luxury"];
|
|
736
|
+
}
|
|
737
|
+
function buildCandyDesignSystemCss(presetInput) {
|
|
738
|
+
const preset = typeof presetInput === "string" || !presetInput ? resolveDesignPreset(presetInput) : presetInput;
|
|
739
|
+
const { colors, typography, borderRadius } = preset.tokens;
|
|
740
|
+
return `/* Caartzee Candy Design System — Preset: ${preset.name} (${preset.id}) */
|
|
741
|
+
@import url('${preset.googleFontsUrl}');
|
|
742
|
+
|
|
743
|
+
:root {
|
|
744
|
+
--cz-bg: ${colors.background};
|
|
745
|
+
--cz-surface: ${colors.surface};
|
|
746
|
+
--cz-ink: ${colors.text};
|
|
747
|
+
--cz-muted: ${colors.muted};
|
|
748
|
+
--cz-border: ${colors.border};
|
|
749
|
+
--cz-primary: ${colors.primary};
|
|
750
|
+
--cz-primary-ink: ${colors.primaryText};
|
|
751
|
+
--cz-accent: ${colors.accent};
|
|
752
|
+
--cz-danger: ${colors.danger};
|
|
753
|
+
--cz-success: ${colors.success};
|
|
754
|
+
--cz-font-heading: ${typography.headingFont};
|
|
755
|
+
--cz-font-body: ${typography.bodyFont};
|
|
756
|
+
--cz-radius-sm: ${borderRadius.sm};
|
|
757
|
+
--cz-radius-md: ${borderRadius.md};
|
|
758
|
+
--cz-radius-lg: ${borderRadius.lg};
|
|
759
|
+
--cz-radius-btn: ${borderRadius.button};
|
|
760
|
+
--cz-container: 1280px;
|
|
761
|
+
--cz-space-xs: 0.5rem;
|
|
762
|
+
--cz-space-sm: 1rem;
|
|
763
|
+
--cz-space-md: 1.5rem;
|
|
764
|
+
--cz-space-lg: 3rem;
|
|
765
|
+
--cz-space-xl: 4.5rem;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
769
|
+
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
|
|
770
|
+
body {
|
|
771
|
+
margin: 0;
|
|
772
|
+
background: var(--cz-bg);
|
|
773
|
+
color: var(--cz-ink);
|
|
774
|
+
font-family: var(--cz-font-body);
|
|
775
|
+
line-height: 1.6;
|
|
776
|
+
}
|
|
777
|
+
h1, h2, h3, h4 { font-family: var(--cz-font-heading); line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 0.75rem; }
|
|
778
|
+
a { color: inherit; text-decoration: none; }
|
|
779
|
+
img { max-width: 100%; height: auto; display: block; }
|
|
780
|
+
|
|
781
|
+
.cz-container { width: 100%; max-width: var(--cz-container); margin: 0 auto; padding: 0 1.25rem; }
|
|
782
|
+
|
|
783
|
+
/* Buttons */
|
|
784
|
+
.cz-btn, button.js-add-to-cart, button.js-submit-btn {
|
|
785
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
|
|
786
|
+
padding: 0.75rem 1.4rem; border-radius: var(--cz-radius-btn);
|
|
787
|
+
background: var(--cz-primary); color: var(--cz-primary-ink);
|
|
788
|
+
border: 1px solid var(--cz-primary); font: 600 0.875rem/1 var(--cz-font-body);
|
|
789
|
+
cursor: pointer; transition: opacity 0.18s ease, transform 0.15s ease;
|
|
790
|
+
}
|
|
791
|
+
.cz-btn:hover, button.js-add-to-cart:hover, button.js-submit-btn:hover { opacity: 0.88; }
|
|
792
|
+
.cz-btn--outline { background: transparent; color: var(--cz-ink); border-color: var(--cz-border); }
|
|
793
|
+
.cz-btn--outline:hover { border-color: var(--cz-ink); opacity: 1; }
|
|
794
|
+
|
|
795
|
+
/* Announcement & Header */
|
|
796
|
+
.cz-announcement-bar {
|
|
797
|
+
background: var(--cz-primary); color: var(--cz-primary-ink);
|
|
798
|
+
text-align: center; font-size: 0.78rem; font-weight: 500;
|
|
799
|
+
padding: 0.5rem 1rem; letter-spacing: 0.03em;
|
|
800
|
+
}
|
|
801
|
+
.cz-candy-header {
|
|
802
|
+
position: sticky; top: 0; z-index: 40;
|
|
803
|
+
background: var(--cz-bg); color: var(--cz-ink);
|
|
804
|
+
border-bottom: 1px solid var(--cz-border);
|
|
805
|
+
}
|
|
806
|
+
.cz-header-inner {
|
|
807
|
+
max-width: var(--cz-container); margin: 0 auto; padding: 0.9rem 1.25rem;
|
|
808
|
+
display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; flex-wrap: wrap;
|
|
809
|
+
}
|
|
810
|
+
.cz-header-logo { font-family: var(--cz-font-heading); font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
|
|
811
|
+
.cz-candy-header nav { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; font-size: 0.9rem; font-weight: 500; }
|
|
812
|
+
.cz-candy-header nav a:hover { color: var(--cz-accent); }
|
|
813
|
+
.cz-header-actions { display: flex; align-items: center; gap: 1rem; font-size: 0.875rem; font-weight: 500; }
|
|
814
|
+
|
|
815
|
+
/* Hero Banner */
|
|
816
|
+
.cz-candy-hero {
|
|
817
|
+
position: relative; overflow: hidden; background: var(--cz-surface);
|
|
818
|
+
padding: clamp(3rem, 7vw, 6.5rem) 1.25rem; text-align: center;
|
|
819
|
+
border-bottom: 1px solid var(--cz-border);
|
|
820
|
+
}
|
|
821
|
+
.cz-candy-hero h1 { font-size: clamp(2.1rem, 5vw, 4rem); max-width: 18ch; margin: 0 auto 1rem; }
|
|
822
|
+
.cz-candy-hero p { color: var(--cz-muted); max-width: 54ch; margin: 0 auto 1.75rem; font-size: 1.05rem; }
|
|
823
|
+
.cz-candy-hero > a {
|
|
824
|
+
display: inline-flex; padding: 0.85rem 1.8rem; border-radius: var(--cz-radius-btn);
|
|
825
|
+
background: var(--cz-primary); color: var(--cz-primary-ink); font-weight: 600; font-size: 0.9rem;
|
|
826
|
+
}
|
|
827
|
+
.cz-hero-desktop-img {
|
|
828
|
+
width: 100%; max-width: 1120px; max-height: 480px; object-fit: cover;
|
|
829
|
+
margin: 0 auto 2rem; border-radius: var(--cz-radius-lg);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/* Uniform Product Grid & Cards (used on Home, Collection, Search, Related Products) */
|
|
833
|
+
.cz-candy-featured-products, .cz-candy-collection, .cz-candy-search {
|
|
834
|
+
max-width: var(--cz-container); margin: 0 auto; padding: var(--cz-space-lg) 1.25rem;
|
|
835
|
+
}
|
|
836
|
+
.candy-product-grid {
|
|
837
|
+
display: grid; gap: 1.5rem;
|
|
838
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
839
|
+
}
|
|
840
|
+
.candy-product-card {
|
|
841
|
+
display: flex; flex-direction: column; gap: 0.65rem;
|
|
842
|
+
background: var(--cz-bg); border: 1px solid var(--cz-border);
|
|
843
|
+
border-radius: var(--cz-radius-md); overflow: hidden; padding-bottom: 1rem;
|
|
844
|
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
845
|
+
}
|
|
846
|
+
.candy-product-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06); }
|
|
847
|
+
.candy-product-card img {
|
|
848
|
+
width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--cz-surface);
|
|
849
|
+
}
|
|
850
|
+
.candy-product-card h3, .candy-product-card .candy-card-title {
|
|
851
|
+
font-size: 1rem; font-weight: 600; margin: 0; padding: 0 0.9rem;
|
|
852
|
+
}
|
|
853
|
+
.candy-product-card .candy-price { padding: 0 0.9rem; font-weight: 600; color: var(--cz-ink); font-size: 0.95rem; }
|
|
854
|
+
.candy-product-card .js-add-to-cart { margin: 0.25rem 0.9rem 0; width: calc(100% - 1.8rem); }
|
|
855
|
+
|
|
856
|
+
/* Product Detail Page */
|
|
857
|
+
.cz-candy-product-detail {
|
|
858
|
+
max-width: var(--cz-container); margin: 0 auto; padding: var(--cz-space-lg) 1.25rem;
|
|
859
|
+
display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 3rem; align-items: start;
|
|
860
|
+
}
|
|
861
|
+
.cz-candy-product-detail img[data-product-main-image] {
|
|
862
|
+
width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
|
|
863
|
+
border-radius: var(--cz-radius-lg); background: var(--cz-surface); border: 1px solid var(--cz-border);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/* Cart, Auth, Wishlist & Content Pages */
|
|
867
|
+
.cz-candy-cart, .cz-wishlist-section, .cz-candy-page {
|
|
868
|
+
max-width: 960px; margin: 0 auto; padding: var(--cz-space-lg) 1.25rem;
|
|
869
|
+
}
|
|
870
|
+
.cz-auth-section {
|
|
871
|
+
max-width: 440px; margin: 3.5rem auto; padding: 2rem;
|
|
872
|
+
background: var(--cz-surface); border: 1px solid var(--cz-border);
|
|
873
|
+
border-radius: var(--cz-radius-lg);
|
|
874
|
+
}
|
|
875
|
+
.cz-auth-section form { display: grid; gap: 0.85rem; margin-top: 1.25rem; }
|
|
876
|
+
.cz-auth-section input {
|
|
877
|
+
width: 100%; padding: 0.75rem 0.9rem; border-radius: var(--cz-radius-sm);
|
|
878
|
+
border: 1px solid var(--cz-border); background: var(--cz-bg); color: var(--cz-ink);
|
|
879
|
+
font: inherit;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/* Editorial Split Section */
|
|
883
|
+
.cz-candy-image-with-text {
|
|
884
|
+
max-width: var(--cz-container); margin: var(--cz-space-lg) auto; padding: 2.5rem;
|
|
885
|
+
background: var(--cz-surface); border: 1px solid var(--cz-border); border-radius: var(--cz-radius-lg);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/* Footer */
|
|
889
|
+
.cz-candy-footer {
|
|
890
|
+
margin-top: var(--cz-space-xl); border-top: 1px solid var(--cz-border);
|
|
891
|
+
padding: var(--cz-space-lg) 1.25rem 2rem;
|
|
892
|
+
}
|
|
893
|
+
.cz-footer-grid {
|
|
894
|
+
max-width: var(--cz-container); margin: 0 auto 2rem;
|
|
895
|
+
display: grid; grid-template-columns: 1.5fr repeat(3, minmax(0, 1fr)); gap: 2rem;
|
|
896
|
+
}
|
|
897
|
+
.cz-footer-col { display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.875rem; }
|
|
898
|
+
.cz-footer-bottom {
|
|
899
|
+
max-width: var(--cz-container); margin: 0 auto; padding-top: 1.25rem;
|
|
900
|
+
border-top: 1px solid rgba(255, 255, 255, 0.14); font-size: 0.8rem; opacity: 0.8;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/* Responsive Breakpoints */
|
|
904
|
+
@media (max-width: 1024px) {
|
|
905
|
+
.candy-product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
906
|
+
.cz-footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
907
|
+
}
|
|
908
|
+
@media (max-width: 768px) {
|
|
909
|
+
.candy-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
|
|
910
|
+
.cz-candy-product-detail { grid-template-columns: 1fr; gap: 1.75rem; }
|
|
911
|
+
.cz-footer-grid { grid-template-columns: 1fr; }
|
|
912
|
+
}
|
|
913
|
+
`;
|
|
914
|
+
}
|
|
915
|
+
|
|
599
916
|
// src/scaffold/template-generator.ts
|
|
600
917
|
function scaffoldTheme(options) {
|
|
601
918
|
const rawSlug = options.slug || options.name?.toLowerCase().replace(/[^a-z0-9_-]+/g, "-") || "starter-theme";
|
|
@@ -624,7 +941,7 @@ function scaffoldTheme(options) {
|
|
|
624
941
|
};
|
|
625
942
|
if (options.engine === "candy") {
|
|
626
943
|
const sdkDependency = options.sdkVersion ?? (options.sdkPath ? "file:" + relative(rootDir, options.sdkPath).replace(/\\/g, "/") : "^1.0.0");
|
|
627
|
-
return scaffoldCandyThemeInternal({ slug, name, author, description, rootDir, writeFile, createdFiles, sdkDependency });
|
|
944
|
+
return scaffoldCandyThemeInternal({ slug, name, author, description, rootDir, writeFile, createdFiles, sdkDependency, preset: options.preset });
|
|
628
945
|
}
|
|
629
946
|
writeFile("package.json", JSON.stringify({
|
|
630
947
|
name: `@caartzee-theme/${slug}`,
|
|
@@ -978,7 +1295,7 @@ npm run push
|
|
|
978
1295
|
};
|
|
979
1296
|
}
|
|
980
1297
|
function scaffoldCandyThemeInternal(params) {
|
|
981
|
-
const { slug, name, author, description, rootDir, writeFile, createdFiles, sdkDependency } = params;
|
|
1298
|
+
const { slug, name, author, description, rootDir, writeFile, createdFiles, sdkDependency, preset } = params;
|
|
982
1299
|
writeFile("candy.config.json", JSON.stringify({
|
|
983
1300
|
engine: "candy",
|
|
984
1301
|
candyVersion: "1.0.0",
|
|
@@ -1450,15 +1767,26 @@ Read [AGENTS.md](./AGENTS.md) and call the Candy MCP tool \`read_candy_guide\` b
|
|
|
1450
1767
|
`);
|
|
1451
1768
|
}
|
|
1452
1769
|
writeFile("snippets/product-card.candy", candyStarterProductCard);
|
|
1770
|
+
const resolvedPreset = resolveDesignPreset(preset);
|
|
1453
1771
|
writeFile("schemas/settings_schema.json", JSON.stringify([
|
|
1454
1772
|
{
|
|
1455
1773
|
name: "Colors",
|
|
1456
1774
|
settings: [
|
|
1457
|
-
{ id: "primary_color", type: "color", label: "Primary Color", default:
|
|
1775
|
+
{ id: "primary_color", type: "color", label: "Primary Color", default: resolvedPreset.tokens.colors.primary },
|
|
1776
|
+
{ id: "accent_color", type: "color", label: "Accent Color", default: resolvedPreset.tokens.colors.accent },
|
|
1777
|
+
{ id: "background_color", type: "color", label: "Background Color", default: resolvedPreset.tokens.colors.background },
|
|
1778
|
+
{ id: "text_color", type: "color", label: "Text Color", default: resolvedPreset.tokens.colors.text }
|
|
1779
|
+
]
|
|
1780
|
+
},
|
|
1781
|
+
{
|
|
1782
|
+
name: "Typography",
|
|
1783
|
+
settings: [
|
|
1784
|
+
{ id: "heading_font", type: "font", label: "Heading Font", default: resolvedPreset.tokens.typography.headingFont },
|
|
1785
|
+
{ id: "body_font", type: "font", label: "Body Font", default: resolvedPreset.tokens.typography.bodyFont }
|
|
1458
1786
|
]
|
|
1459
1787
|
}
|
|
1460
1788
|
], null, 2));
|
|
1461
|
-
writeFile("assets/theme.css",
|
|
1789
|
+
writeFile("assets/theme.css", buildCandyDesignSystemCss(resolvedPreset));
|
|
1462
1790
|
writeFile("assets/theme.js", `window.__CAARTZEE_CANDY_THEME__ = true;
|
|
1463
1791
|
document.addEventListener('caartzee:section:load', function () {
|
|
1464
1792
|
// Re-initialize any section-specific UI widgets after Theme Editor live swaps.
|
|
@@ -8439,7 +8767,7 @@ ${productCard}`;
|
|
|
8439
8767
|
slug,
|
|
8440
8768
|
version,
|
|
8441
8769
|
packageHash,
|
|
8442
|
-
sdkVersion: "1.2.
|
|
8770
|
+
sdkVersion: "1.2.1",
|
|
8443
8771
|
runtimeVersion: "candy-1.0",
|
|
8444
8772
|
status: summary.failed > 0 ? "failed" : summary.warnings > 0 ? "partial" : "passed",
|
|
8445
8773
|
summary,
|
|
@@ -8447,6 +8775,58 @@ ${productCard}`;
|
|
|
8447
8775
|
};
|
|
8448
8776
|
}
|
|
8449
8777
|
|
|
8778
|
+
// src/cli/mcp/ui-patterns-tools.ts
|
|
8779
|
+
import { existsSync as existsSync11, readFileSync as readFileSync11 } from "node:fs";
|
|
8780
|
+
import { join as join11, resolve as resolve9 } from "node:path";
|
|
8781
|
+
import { z as z6 } from "zod";
|
|
8782
|
+
function auditCandyUiConsistency(themeDir) {
|
|
8783
|
+
const dir = resolve9(themeDir);
|
|
8784
|
+
const readRel = (rel) => {
|
|
8785
|
+
const p = join11(dir, rel);
|
|
8786
|
+
return existsSync11(p) ? readFileSync11(p, "utf8") : "";
|
|
8787
|
+
};
|
|
8788
|
+
const css = readRel("assets/theme.css");
|
|
8789
|
+
const productCard = readRel("snippets/product-card.candy");
|
|
8790
|
+
const cart = readRel("templates/cart.candy");
|
|
8791
|
+
const search = readRel("templates/search.candy");
|
|
8792
|
+
const collection = readRel("templates/collection.candy");
|
|
8793
|
+
const checks = [
|
|
8794
|
+
{
|
|
8795
|
+
id: "ui.design_tokens",
|
|
8796
|
+
status: css.includes(":root") && (css.includes("--cz-") || css.includes("--sf-")) ? "passed" : "warning",
|
|
8797
|
+
message: css.includes(":root") ? "Semantic CSS design tokens (:root) found in assets/theme.css." : "Define semantic :root design tokens (--cz-bg, --cz-ink, --cz-primary) in assets/theme.css for cross-page visual consistency."
|
|
8798
|
+
},
|
|
8799
|
+
{
|
|
8800
|
+
id: "ui.uniform_card_aspect_ratio",
|
|
8801
|
+
status: css.includes("aspect-ratio") && css.includes("object-fit") ? "passed" : "warning",
|
|
8802
|
+
message: css.includes("aspect-ratio") && css.includes("object-fit") ? "Product cards enforce uniform aspect-ratio and object-fit: cover." : "Add aspect-ratio (e.g. 4/5) and object-fit: cover on product card images to prevent uneven grid rows."
|
|
8803
|
+
},
|
|
8804
|
+
{
|
|
8805
|
+
id: "ui.responsive_breakpoints",
|
|
8806
|
+
status: /@media\s*\(max-width:/i.test(css) ? "passed" : "warning",
|
|
8807
|
+
message: /@media\s*\(max-width:/i.test(css) ? "Responsive tablet/mobile @media breakpoints detected." : "Add @media (max-width: 1024px) and @media (max-width: 768px) rules for tablet and mobile layouts."
|
|
8808
|
+
},
|
|
8809
|
+
{
|
|
8810
|
+
id: "ui.reusable_product_card",
|
|
8811
|
+
status: productCard.trim().length > 0 ? "passed" : "failed",
|
|
8812
|
+
message: productCard.trim().length > 0 ? "Shared snippets/product-card.candy exists for consistent product grids." : "Missing snippets/product-card.candy — reuse one product card snippet across Home, Collection, and Search."
|
|
8813
|
+
},
|
|
8814
|
+
{
|
|
8815
|
+
id: "ui.empty_states",
|
|
8816
|
+
status: [cart, search, collection].every((t) => /else|empty|no\s+/i.test(t)) ? "passed" : "warning",
|
|
8817
|
+
message: "Checked Cart, Search, and Collection templates for empty/zero-result states."
|
|
8818
|
+
}
|
|
8819
|
+
];
|
|
8820
|
+
const failed = checks.filter((c) => c.status === "failed").length;
|
|
8821
|
+
const warnings = checks.filter((c) => c.status === "warning").length;
|
|
8822
|
+
return {
|
|
8823
|
+
themeDir: dir,
|
|
8824
|
+
status: failed > 0 ? "failed" : warnings > 0 ? "partial" : "passed",
|
|
8825
|
+
summary: { passed: checks.length - failed - warnings, failed, warnings },
|
|
8826
|
+
checks
|
|
8827
|
+
};
|
|
8828
|
+
}
|
|
8829
|
+
|
|
8450
8830
|
// src/cli/caartzee-cli.ts
|
|
8451
8831
|
async function runCli(rawArgs, io = {}) {
|
|
8452
8832
|
const log = io.stdout ?? console.log;
|
|
@@ -8494,8 +8874,8 @@ async function runCli(rawArgs, io = {}) {
|
|
|
8494
8874
|
case "dev":
|
|
8495
8875
|
return await handleDev(args, log, error);
|
|
8496
8876
|
case "sync-manifest": {
|
|
8497
|
-
const theme = await loadLocalTheme(
|
|
8498
|
-
writeFileSync5(
|
|
8877
|
+
const theme = await loadLocalTheme(resolve10(args[0] || process.cwd()));
|
|
8878
|
+
writeFileSync5(resolve10(args[0] || process.cwd(), "manifest.json"), JSON.stringify(theme.manifest, null, 2));
|
|
8499
8879
|
log("Exported runtime theme manifest.");
|
|
8500
8880
|
return 0;
|
|
8501
8881
|
}
|
|
@@ -8517,9 +8897,11 @@ async function runCli(rawArgs, io = {}) {
|
|
|
8517
8897
|
return await handleTestSuite(args, "commerce", log, error);
|
|
8518
8898
|
case "test-report":
|
|
8519
8899
|
return await handleTestReport(args, log, error);
|
|
8900
|
+
case "ui-audit":
|
|
8901
|
+
return await handleUiAudit(args, log, error);
|
|
8520
8902
|
case "ide":
|
|
8521
8903
|
case "ide-setup": {
|
|
8522
|
-
const targetDir = args[0] ?
|
|
8904
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8523
8905
|
const res = installCandyIdeSupport({ workspaceDir: targetDir });
|
|
8524
8906
|
log(`
|
|
8525
8907
|
\uD83C\uDFA8 Installed Candy (.candy) IDE language support:`);
|
|
@@ -8561,6 +8943,15 @@ async function handleInit(args, log, error) {
|
|
|
8561
8943
|
throw new Error("The commerce scaffold uses TypeScript.");
|
|
8562
8944
|
if (engineIndex >= 0)
|
|
8563
8945
|
args = args.filter((_, index) => index !== engineIndex && index !== engineIndex + 1);
|
|
8946
|
+
const presetIndex = args.indexOf("--preset");
|
|
8947
|
+
const presetRaw = presetIndex < 0 ? undefined : args[presetIndex + 1];
|
|
8948
|
+
if (presetIndex >= 0) {
|
|
8949
|
+
if (!presetRaw || !CANDY_DESIGN_PRESET_IDS.includes(presetRaw)) {
|
|
8950
|
+
throw new Error(`Supported presets: ${CANDY_DESIGN_PRESET_IDS.join(", ")}`);
|
|
8951
|
+
}
|
|
8952
|
+
args = args.filter((_, index) => index !== presetIndex && index !== presetIndex + 1);
|
|
8953
|
+
}
|
|
8954
|
+
const preset = presetRaw;
|
|
8564
8955
|
const dirIndex = args.indexOf("--dir");
|
|
8565
8956
|
const dir = dirIndex < 0 ? undefined : args[dirIndex + 1];
|
|
8566
8957
|
if (dirIndex >= 0 && !dir)
|
|
@@ -8568,7 +8959,7 @@ async function handleInit(args, log, error) {
|
|
|
8568
8959
|
if (dirIndex >= 0)
|
|
8569
8960
|
args = args.filter((_, index) => index !== dirIndex && index !== dirIndex + 1);
|
|
8570
8961
|
const nameArg = args[0];
|
|
8571
|
-
const targetDir =
|
|
8962
|
+
const targetDir = resolve10(dir || args[1] || nameArg || "my-caartzee-theme");
|
|
8572
8963
|
const themeName = nameArg || "My Caartzee Theme";
|
|
8573
8964
|
log(`
|
|
8574
8965
|
\uD83D\uDCE6 Scaffolding new Caartzee theme in: ${targetDir}`);
|
|
@@ -8578,7 +8969,8 @@ async function handleInit(args, log, error) {
|
|
|
8578
8969
|
targetDir,
|
|
8579
8970
|
sdkPath: fileURLToPath3(new URL("../../", import.meta.url)),
|
|
8580
8971
|
name: themeName,
|
|
8581
|
-
engine
|
|
8972
|
+
engine,
|
|
8973
|
+
...preset ? { preset } : {}
|
|
8582
8974
|
});
|
|
8583
8975
|
log(`✨ Successfully generated theme "${result.name}" (${result.slug})!`);
|
|
8584
8976
|
log(` Created ${result.createdFiles.length} files:`);
|
|
@@ -8716,7 +9108,7 @@ async function handleDev(args, log, error) {
|
|
|
8716
9108
|
port = parseInt(args[i + 1], 10);
|
|
8717
9109
|
i++;
|
|
8718
9110
|
} else if (args[i] === "--dir" && args[i + 1]) {
|
|
8719
|
-
themeDir =
|
|
9111
|
+
themeDir = resolve10(args[i + 1]);
|
|
8720
9112
|
i++;
|
|
8721
9113
|
} else if (args[i] === "--store") {
|
|
8722
9114
|
store = args[++i];
|
|
@@ -8783,21 +9175,21 @@ Shutting down dev server...`);
|
|
|
8783
9175
|
}
|
|
8784
9176
|
}
|
|
8785
9177
|
async function handleValidate(args, log, error) {
|
|
8786
|
-
const targetDir = args[0] ?
|
|
9178
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8787
9179
|
log(`
|
|
8788
9180
|
\uD83D\uDEE1️ Running Caartzee Theme Security & Package Validation...`);
|
|
8789
9181
|
log(` Target: ${targetDir}`);
|
|
8790
|
-
const manifestPath =
|
|
8791
|
-
if (!
|
|
9182
|
+
const manifestPath = join12(targetDir, "manifest.json");
|
|
9183
|
+
if (!existsSync12(manifestPath)) {
|
|
8792
9184
|
error(`❌ Missing manifest.json in ${targetDir}`);
|
|
8793
9185
|
return 1;
|
|
8794
9186
|
}
|
|
8795
9187
|
try {
|
|
8796
|
-
if (
|
|
9188
|
+
if (existsSync12(join12(targetDir, "src/manifest.ts")) && typeof Bun !== "undefined") {
|
|
8797
9189
|
const theme = await loadLocalTheme(targetDir);
|
|
8798
9190
|
writeFileSync5(manifestPath, JSON.stringify(theme.manifest, null, 2));
|
|
8799
9191
|
}
|
|
8800
|
-
const rawManifest = JSON.parse(
|
|
9192
|
+
const rawManifest = JSON.parse(readFileSync12(manifestPath, "utf-8"));
|
|
8801
9193
|
const manifestCheck = ThemePackageValidator.validateManifest(rawManifest);
|
|
8802
9194
|
if (!manifestCheck.success) {
|
|
8803
9195
|
error(`❌ Manifest validation failed:`);
|
|
@@ -8836,7 +9228,7 @@ async function handleValidate(args, log, error) {
|
|
|
8836
9228
|
}
|
|
8837
9229
|
}
|
|
8838
9230
|
async function handleBuild(args, log, error) {
|
|
8839
|
-
const targetDir = args[0] ?
|
|
9231
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8840
9232
|
log(`
|
|
8841
9233
|
\uD83D\uDD28 Building Caartzee Theme Package...`);
|
|
8842
9234
|
log(` Source directory: ${targetDir}`);
|
|
@@ -8848,9 +9240,9 @@ async function handleBuild(args, log, error) {
|
|
|
8848
9240
|
}
|
|
8849
9241
|
return 1;
|
|
8850
9242
|
}
|
|
8851
|
-
const isCandy =
|
|
8852
|
-
const distDir =
|
|
8853
|
-
if (!
|
|
9243
|
+
const isCandy = existsSync12(join12(targetDir, "candy.config.json")) || existsSync12(join12(targetDir, "layout", "theme.candy")) || valResult.manifest?.engine === "candy";
|
|
9244
|
+
const distDir = join12(targetDir, "dist");
|
|
9245
|
+
if (!existsSync12(distDir)) {
|
|
8854
9246
|
mkdirSync5(distDir, { recursive: true });
|
|
8855
9247
|
}
|
|
8856
9248
|
if (isCandy) {
|
|
@@ -8863,8 +9255,8 @@ async function handleBuild(args, log, error) {
|
|
|
8863
9255
|
}
|
|
8864
9256
|
return 1;
|
|
8865
9257
|
}
|
|
8866
|
-
const bundlePath =
|
|
8867
|
-
const manifestOutPath =
|
|
9258
|
+
const bundlePath = join12(distDir, "candy-theme-bundle.json");
|
|
9259
|
+
const manifestOutPath = join12(distDir, "manifest.json");
|
|
8868
9260
|
writeFileSync5(bundlePath, JSON.stringify(bundle, null, 2), "utf-8");
|
|
8869
9261
|
writeFileSync5(manifestOutPath, JSON.stringify(bundle.manifest, null, 2), "utf-8");
|
|
8870
9262
|
log(`✓ Extracted ${Object.keys(bundle.sectionSchemas).length} section schemas`);
|
|
@@ -8874,7 +9266,7 @@ async function handleBuild(args, log, error) {
|
|
|
8874
9266
|
return 0;
|
|
8875
9267
|
}
|
|
8876
9268
|
if (valResult.manifest) {
|
|
8877
|
-
const manifestOutPath =
|
|
9269
|
+
const manifestOutPath = join12(distDir, "manifest.json");
|
|
8878
9270
|
writeFileSync5(manifestOutPath, JSON.stringify(valResult.manifest, null, 2), "utf-8");
|
|
8879
9271
|
log(`✓ Wrote validated manifest to ${manifestOutPath}
|
|
8880
9272
|
`);
|
|
@@ -8893,10 +9285,10 @@ async function handlePush(args, log, error) {
|
|
|
8893
9285
|
error(`❌ Insufficient scope. Your account lacks "theme:publish" permissions.`);
|
|
8894
9286
|
return 1;
|
|
8895
9287
|
}
|
|
8896
|
-
const targetDir = args[0] ?
|
|
8897
|
-
if (
|
|
9288
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
9289
|
+
if (existsSync12(join12(targetDir, "src/manifest.ts")) && typeof Bun !== "undefined") {
|
|
8898
9290
|
const theme = await loadLocalTheme(targetDir);
|
|
8899
|
-
writeFileSync5(
|
|
9291
|
+
writeFileSync5(join12(targetDir, "manifest.json"), JSON.stringify(theme.manifest, null, 2));
|
|
8900
9292
|
}
|
|
8901
9293
|
const valResult = await ThemePackageValidator.validatePackage(targetDir);
|
|
8902
9294
|
if (!valResult.valid) {
|
|
@@ -8918,7 +9310,7 @@ async function handlePush(args, log, error) {
|
|
|
8918
9310
|
return 0;
|
|
8919
9311
|
}
|
|
8920
9312
|
async function handleDoctor(args, log, error) {
|
|
8921
|
-
const targetDir = args[0] ?
|
|
9313
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8922
9314
|
log(`
|
|
8923
9315
|
\uD83E\uDE7A Running Caartzee Candy Theme Doctor...`);
|
|
8924
9316
|
log(` Target: ${targetDir}
|
|
@@ -8927,8 +9319,8 @@ async function handleDoctor(args, log, error) {
|
|
|
8927
9319
|
const warnings = [];
|
|
8928
9320
|
const passed = [];
|
|
8929
9321
|
const readIfExists = (rel) => {
|
|
8930
|
-
const full =
|
|
8931
|
-
return
|
|
9322
|
+
const full = join12(targetDir, rel);
|
|
9323
|
+
return existsSync12(full) ? readFileSync12(full, "utf8") : null;
|
|
8932
9324
|
};
|
|
8933
9325
|
const configRaw = readIfExists("candy.config.json");
|
|
8934
9326
|
const manifestRaw = readIfExists("manifest.json");
|
|
@@ -8972,7 +9364,7 @@ async function handleDoctor(args, log, error) {
|
|
|
8972
9364
|
}
|
|
8973
9365
|
const templateNames = ["index.candy", "collection.candy", "list-collections.candy", "product.candy", "cart.candy", "search.candy", "wishlist.candy", "login.candy", "register.candy", "page.candy", "404.candy"];
|
|
8974
9366
|
for (const name of templateNames) {
|
|
8975
|
-
const content = readIfExists(
|
|
9367
|
+
const content = readIfExists(join12("templates", name));
|
|
8976
9368
|
if (!content)
|
|
8977
9369
|
continue;
|
|
8978
9370
|
if (usesShell && /\{%\s*layout\s+/i.test(content)) {
|
|
@@ -8982,7 +9374,7 @@ async function handleDoctor(args, log, error) {
|
|
|
8982
9374
|
issues.push(`templates/${name} emits a synthetic "-default" variant ID, which causes POST /_api/cart 422 errors.`);
|
|
8983
9375
|
}
|
|
8984
9376
|
}
|
|
8985
|
-
const productCard = readIfExists(
|
|
9377
|
+
const productCard = readIfExists(join12("snippets", "product-card.candy"));
|
|
8986
9378
|
if (productCard) {
|
|
8987
9379
|
if (/data-variant-id\s*=\s*["'][^"']*-default["']/i.test(productCard)) {
|
|
8988
9380
|
issues.push('snippets/product-card.candy emits a synthetic "-default" variant ID. Guard data-variant-id with product.has_inventory_variants.');
|
|
@@ -8990,7 +9382,7 @@ async function handleDoctor(args, log, error) {
|
|
|
8990
9382
|
passed.push("Product card variant ID contract looks safe");
|
|
8991
9383
|
}
|
|
8992
9384
|
}
|
|
8993
|
-
const headerCandy = readIfExists(
|
|
9385
|
+
const headerCandy = readIfExists(join12("sections", "header.candy"));
|
|
8994
9386
|
if (headerCandy) {
|
|
8995
9387
|
if (!headerCandy.includes("js-cart-count")) {
|
|
8996
9388
|
warnings.push("sections/header.candy is missing .js-cart-count on the cart badge (live Add to Cart count won't update).");
|
|
@@ -9003,7 +9395,7 @@ async function handleDoctor(args, log, error) {
|
|
|
9003
9395
|
passed.push("Header navigation menu (menuId + linklists) wired");
|
|
9004
9396
|
}
|
|
9005
9397
|
}
|
|
9006
|
-
const heroCandy = readIfExists(
|
|
9398
|
+
const heroCandy = readIfExists(join12("sections", "hero-banner.candy"));
|
|
9007
9399
|
if (heroCandy) {
|
|
9008
9400
|
if (!heroCandy.includes("mobile_sliders")) {
|
|
9009
9401
|
warnings.push("sections/hero-banner.candy does not read mobile_sliders (merchant Mobile Slider changes won't reflect).");
|
|
@@ -9011,8 +9403,8 @@ async function handleDoctor(args, log, error) {
|
|
|
9011
9403
|
passed.push("Hero banner mobile_sliders support present");
|
|
9012
9404
|
}
|
|
9013
9405
|
}
|
|
9014
|
-
const loginCandy = readIfExists(
|
|
9015
|
-
const registerCandy = readIfExists(
|
|
9406
|
+
const loginCandy = readIfExists(join12("templates", "login.candy"));
|
|
9407
|
+
const registerCandy = readIfExists(join12("templates", "register.candy"));
|
|
9016
9408
|
if (loginCandy) {
|
|
9017
9409
|
if (!loginCandy.includes("/_api/auth/login") || !loginCandy.includes("js-auth-form")) {
|
|
9018
9410
|
issues.push('templates/login.candy must post to /_api/auth/login with class="js-auth-form".');
|
|
@@ -9027,11 +9419,11 @@ async function handleDoctor(args, log, error) {
|
|
|
9027
9419
|
passed.push("Signup page (/signup, /register) auth contract verified");
|
|
9028
9420
|
}
|
|
9029
9421
|
}
|
|
9030
|
-
if (readIfExists(
|
|
9422
|
+
if (readIfExists(join12("assets", "theme.css")))
|
|
9031
9423
|
passed.push("assets/theme.css found");
|
|
9032
9424
|
else
|
|
9033
9425
|
warnings.push("assets/theme.css not found.");
|
|
9034
|
-
if (readIfExists(
|
|
9426
|
+
if (readIfExists(join12("assets", "theme.js")))
|
|
9035
9427
|
passed.push("assets/theme.js found");
|
|
9036
9428
|
else
|
|
9037
9429
|
warnings.push("assets/theme.js not found.");
|
|
@@ -9058,19 +9450,19 @@ async function handleDoctor(args, log, error) {
|
|
|
9058
9450
|
}
|
|
9059
9451
|
async function handleVersion(args, log, error) {
|
|
9060
9452
|
const bump = args[0]?.trim();
|
|
9061
|
-
const targetDir = args[1] ?
|
|
9453
|
+
const targetDir = args[1] ? resolve10(args[1]) : process.cwd();
|
|
9062
9454
|
if (!bump) {
|
|
9063
9455
|
error("Usage: caartzee-theme version <patch|minor|major|x.y.z> [path]");
|
|
9064
9456
|
return 1;
|
|
9065
9457
|
}
|
|
9066
|
-
const configPath =
|
|
9067
|
-
const manifestPath =
|
|
9068
|
-
if (!
|
|
9458
|
+
const configPath = join12(targetDir, "candy.config.json");
|
|
9459
|
+
const manifestPath = join12(targetDir, "manifest.json");
|
|
9460
|
+
if (!existsSync12(configPath) && !existsSync12(manifestPath)) {
|
|
9069
9461
|
error(`No candy.config.json or manifest.json found in ${targetDir}`);
|
|
9070
9462
|
return 1;
|
|
9071
9463
|
}
|
|
9072
|
-
const readJson = (p) => JSON.parse(
|
|
9073
|
-
const current =
|
|
9464
|
+
const readJson = (p) => JSON.parse(readFileSync12(p, "utf8"));
|
|
9465
|
+
const current = existsSync12(configPath) ? String(readJson(configPath).version || "1.0.0") : String(readJson(manifestPath).version || "1.0.0");
|
|
9074
9466
|
let nextVersion = bump;
|
|
9075
9467
|
if (bump === "patch" || bump === "minor" || bump === "major") {
|
|
9076
9468
|
const parts = current.split(".").map((n) => parseInt(n, 10) || 0);
|
|
@@ -9080,13 +9472,13 @@ async function handleVersion(args, log, error) {
|
|
|
9080
9472
|
error(`Invalid version "${bump}". Use patch, minor, major, or semver like 1.0.3.`);
|
|
9081
9473
|
return 1;
|
|
9082
9474
|
}
|
|
9083
|
-
if (
|
|
9475
|
+
if (existsSync12(configPath)) {
|
|
9084
9476
|
const cfg = readJson(configPath);
|
|
9085
9477
|
cfg.version = nextVersion;
|
|
9086
9478
|
writeFileSync5(configPath, JSON.stringify(cfg, null, 2) + `
|
|
9087
9479
|
`, "utf8");
|
|
9088
9480
|
}
|
|
9089
|
-
if (
|
|
9481
|
+
if (existsSync12(manifestPath)) {
|
|
9090
9482
|
const man = readJson(manifestPath);
|
|
9091
9483
|
man.version = nextVersion;
|
|
9092
9484
|
writeFileSync5(manifestPath, JSON.stringify(man, null, 2) + `
|
|
@@ -9098,7 +9490,7 @@ async function handleVersion(args, log, error) {
|
|
|
9098
9490
|
function parseTargetAndJson(args) {
|
|
9099
9491
|
const asJson = args.includes("--json");
|
|
9100
9492
|
const positional = args.filter((a) => !a.startsWith("-"));
|
|
9101
|
-
const targetDir = positional[0] ?
|
|
9493
|
+
const targetDir = positional[0] ? resolve10(positional[0]) : process.cwd();
|
|
9102
9494
|
return { targetDir, asJson };
|
|
9103
9495
|
}
|
|
9104
9496
|
async function handleTestEditor(args, log, error) {
|
|
@@ -9153,10 +9545,10 @@ ${failed === 0 ? "✅" : "❌"} Result: ${passed} passed, ${failed} failed, ${wa
|
|
|
9153
9545
|
async function handleTestReport(args, log, error) {
|
|
9154
9546
|
const { targetDir, asJson } = parseTargetAndJson(args);
|
|
9155
9547
|
const report = await runThemeReadinessAudit(targetDir);
|
|
9156
|
-
const distDir =
|
|
9157
|
-
if (!
|
|
9548
|
+
const distDir = join12(targetDir, "dist");
|
|
9549
|
+
if (!existsSync12(distDir))
|
|
9158
9550
|
mkdirSync5(distDir, { recursive: true });
|
|
9159
|
-
const outPath =
|
|
9551
|
+
const outPath = join12(distDir, "theme-readiness-report.json");
|
|
9160
9552
|
writeFileSync5(outPath, JSON.stringify(report, null, 2), "utf8");
|
|
9161
9553
|
if (asJson) {
|
|
9162
9554
|
log(JSON.stringify({ reportPath: outPath, ...report }, null, 2));
|
|
@@ -9173,10 +9565,28 @@ async function handleTestReport(args, log, error) {
|
|
|
9173
9565
|
}
|
|
9174
9566
|
return 0;
|
|
9175
9567
|
}
|
|
9568
|
+
async function handleUiAudit(args, log, error) {
|
|
9569
|
+
const { targetDir, asJson } = parseTargetAndJson(args);
|
|
9570
|
+
const report = auditCandyUiConsistency(targetDir);
|
|
9571
|
+
if (asJson) {
|
|
9572
|
+
log(JSON.stringify(report, null, 2));
|
|
9573
|
+
return report.summary.failed > 0 ? 1 : 0;
|
|
9574
|
+
}
|
|
9575
|
+
log(`
|
|
9576
|
+
\uD83C\uDFA8 Caartzee Candy UI Consistency Audit (${targetDir})`);
|
|
9577
|
+
for (const c of report.checks) {
|
|
9578
|
+
const icon = c.status === "passed" ? "✓" : c.status === "warning" ? "⚠️" : "❌";
|
|
9579
|
+
(c.status === "failed" ? error : log)(` ${icon} [${c.id}] ${c.message}`);
|
|
9580
|
+
}
|
|
9581
|
+
log(`
|
|
9582
|
+
${report.summary.failed === 0 ? "✅" : "❌"} UI Audit: ${report.summary.passed} passed, ${report.summary.failed} failed, ${report.summary.warnings} warning(s).
|
|
9583
|
+
`);
|
|
9584
|
+
return report.summary.failed > 0 ? 1 : 0;
|
|
9585
|
+
}
|
|
9176
9586
|
function printHelp(log) {
|
|
9177
9587
|
log(`
|
|
9178
9588
|
╔═══════════════════════════════════════════════════════════════╗
|
|
9179
|
-
║ CAARTZEE THEME SDK CLI (v1.2.
|
|
9589
|
+
║ CAARTZEE THEME SDK CLI (v1.2.1) ║
|
|
9180
9590
|
║ Build, test, and publish secure storefront themes locally ║
|
|
9181
9591
|
╚═══════════════════════════════════════════════════════════════╝
|
|
9182
9592
|
|
|
@@ -9185,8 +9595,9 @@ Usage:
|
|
|
9185
9595
|
npx @caartzee/theme-sdk <command> [options]
|
|
9186
9596
|
|
|
9187
9597
|
Commands:
|
|
9188
|
-
init [name]
|
|
9598
|
+
init [name] [--engine candy] [--preset minimal-luxury|streetwear-editorial|organic-wellness|modern-tech|vibrant-d2c]
|
|
9189
9599
|
dev [--port 3333] [--store DOMAIN] [--editor] Preview with full local commerce/auth & Theme Editor
|
|
9600
|
+
ui-audit [path] [--json] Audit design tokens, uniform card aspect ratios, responsive CSS & empty states
|
|
9190
9601
|
doctor [path] Audit storefront-shell, cart/variant hooks, auth forms, menus & mobile sliders
|
|
9191
9602
|
version <patch|minor|major|x.y.z> [path] Bump version across candy.config.json and manifest.json
|
|
9192
9603
|
sync-manifest [path] Export the locally authored theme manifest to JSON
|