@caartzee/theme-sdk 1.2.0 → 1.2.2
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 +469 -54
- package/dist/lib/index.js +469 -54
- package/dist/types/src/blocks/block-contract.d.ts +10 -10
- package/dist/types/src/cli/mcp/ui-patterns-tools.d.ts +26 -0
- package/dist/types/src/cli/mcp/v2-api-catalog.d.ts +69 -0
- package/dist/types/src/cli/mcp/v2-commerce-tools.d.ts +18 -0
- package/dist/types/src/contracts/manifest.d.ts +77 -77
- package/dist/types/src/scaffold/design-presets.d.ts +41 -0
- package/dist/types/src/scaffold/template-generator.d.ts +2 -0
- package/dist/types/src/sections/section-contract.d.ts +12 -12
- package/package.json +1 -1
- package/templates/commerce/manifest.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.
|
|
@@ -3484,6 +3812,7 @@ var SettingTypeSchema = z3.enum([
|
|
|
3484
3812
|
"range",
|
|
3485
3813
|
"url",
|
|
3486
3814
|
"json",
|
|
3815
|
+
"html",
|
|
3487
3816
|
"code",
|
|
3488
3817
|
"javascript",
|
|
3489
3818
|
"category_list",
|
|
@@ -3596,7 +3925,7 @@ var RAW_HTML_SECTION_MANIFEST = {
|
|
|
3596
3925
|
settings: [
|
|
3597
3926
|
{
|
|
3598
3927
|
id: "html",
|
|
3599
|
-
type: "
|
|
3928
|
+
type: "html",
|
|
3600
3929
|
label: "HTML Content",
|
|
3601
3930
|
placeholder: "<div>Custom HTML content...</div>",
|
|
3602
3931
|
required: false,
|
|
@@ -6589,6 +6918,9 @@ function loadCandyThemeFromSource(source, fallbackSlug = "candy-theme") {
|
|
|
6589
6918
|
});
|
|
6590
6919
|
}
|
|
6591
6920
|
}
|
|
6921
|
+
if (!sectionSchemas["raw-html"]) {
|
|
6922
|
+
sectionSchemas["raw-html"] = RAW_HTML_SECTION_MANIFEST;
|
|
6923
|
+
}
|
|
6592
6924
|
for (const entry of source.list("assets")) {
|
|
6593
6925
|
assets[entry] = source.read(`assets/${entry}`) ?? "";
|
|
6594
6926
|
}
|
|
@@ -8439,7 +8771,7 @@ ${productCard}`;
|
|
|
8439
8771
|
slug,
|
|
8440
8772
|
version,
|
|
8441
8773
|
packageHash,
|
|
8442
|
-
sdkVersion: "1.2.
|
|
8774
|
+
sdkVersion: "1.2.1",
|
|
8443
8775
|
runtimeVersion: "candy-1.0",
|
|
8444
8776
|
status: summary.failed > 0 ? "failed" : summary.warnings > 0 ? "partial" : "passed",
|
|
8445
8777
|
summary,
|
|
@@ -8447,6 +8779,58 @@ ${productCard}`;
|
|
|
8447
8779
|
};
|
|
8448
8780
|
}
|
|
8449
8781
|
|
|
8782
|
+
// src/cli/mcp/ui-patterns-tools.ts
|
|
8783
|
+
import { existsSync as existsSync11, readFileSync as readFileSync11 } from "node:fs";
|
|
8784
|
+
import { join as join11, resolve as resolve9 } from "node:path";
|
|
8785
|
+
import { z as z6 } from "zod";
|
|
8786
|
+
function auditCandyUiConsistency(themeDir) {
|
|
8787
|
+
const dir = resolve9(themeDir);
|
|
8788
|
+
const readRel = (rel) => {
|
|
8789
|
+
const p = join11(dir, rel);
|
|
8790
|
+
return existsSync11(p) ? readFileSync11(p, "utf8") : "";
|
|
8791
|
+
};
|
|
8792
|
+
const css = readRel("assets/theme.css");
|
|
8793
|
+
const productCard = readRel("snippets/product-card.candy");
|
|
8794
|
+
const cart = readRel("templates/cart.candy");
|
|
8795
|
+
const search = readRel("templates/search.candy");
|
|
8796
|
+
const collection = readRel("templates/collection.candy");
|
|
8797
|
+
const checks = [
|
|
8798
|
+
{
|
|
8799
|
+
id: "ui.design_tokens",
|
|
8800
|
+
status: css.includes(":root") && (css.includes("--cz-") || css.includes("--sf-")) ? "passed" : "warning",
|
|
8801
|
+
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."
|
|
8802
|
+
},
|
|
8803
|
+
{
|
|
8804
|
+
id: "ui.uniform_card_aspect_ratio",
|
|
8805
|
+
status: css.includes("aspect-ratio") && css.includes("object-fit") ? "passed" : "warning",
|
|
8806
|
+
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."
|
|
8807
|
+
},
|
|
8808
|
+
{
|
|
8809
|
+
id: "ui.responsive_breakpoints",
|
|
8810
|
+
status: /@media\s*\(max-width:/i.test(css) ? "passed" : "warning",
|
|
8811
|
+
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."
|
|
8812
|
+
},
|
|
8813
|
+
{
|
|
8814
|
+
id: "ui.reusable_product_card",
|
|
8815
|
+
status: productCard.trim().length > 0 ? "passed" : "failed",
|
|
8816
|
+
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."
|
|
8817
|
+
},
|
|
8818
|
+
{
|
|
8819
|
+
id: "ui.empty_states",
|
|
8820
|
+
status: [cart, search, collection].every((t) => /else|empty|no\s+/i.test(t)) ? "passed" : "warning",
|
|
8821
|
+
message: "Checked Cart, Search, and Collection templates for empty/zero-result states."
|
|
8822
|
+
}
|
|
8823
|
+
];
|
|
8824
|
+
const failed = checks.filter((c) => c.status === "failed").length;
|
|
8825
|
+
const warnings = checks.filter((c) => c.status === "warning").length;
|
|
8826
|
+
return {
|
|
8827
|
+
themeDir: dir,
|
|
8828
|
+
status: failed > 0 ? "failed" : warnings > 0 ? "partial" : "passed",
|
|
8829
|
+
summary: { passed: checks.length - failed - warnings, failed, warnings },
|
|
8830
|
+
checks
|
|
8831
|
+
};
|
|
8832
|
+
}
|
|
8833
|
+
|
|
8450
8834
|
// src/cli/caartzee-cli.ts
|
|
8451
8835
|
async function runCli(rawArgs, io = {}) {
|
|
8452
8836
|
const log = io.stdout ?? console.log;
|
|
@@ -8494,8 +8878,8 @@ async function runCli(rawArgs, io = {}) {
|
|
|
8494
8878
|
case "dev":
|
|
8495
8879
|
return await handleDev(args, log, error);
|
|
8496
8880
|
case "sync-manifest": {
|
|
8497
|
-
const theme = await loadLocalTheme(
|
|
8498
|
-
writeFileSync5(
|
|
8881
|
+
const theme = await loadLocalTheme(resolve10(args[0] || process.cwd()));
|
|
8882
|
+
writeFileSync5(resolve10(args[0] || process.cwd(), "manifest.json"), JSON.stringify(theme.manifest, null, 2));
|
|
8499
8883
|
log("Exported runtime theme manifest.");
|
|
8500
8884
|
return 0;
|
|
8501
8885
|
}
|
|
@@ -8517,9 +8901,11 @@ async function runCli(rawArgs, io = {}) {
|
|
|
8517
8901
|
return await handleTestSuite(args, "commerce", log, error);
|
|
8518
8902
|
case "test-report":
|
|
8519
8903
|
return await handleTestReport(args, log, error);
|
|
8904
|
+
case "ui-audit":
|
|
8905
|
+
return await handleUiAudit(args, log, error);
|
|
8520
8906
|
case "ide":
|
|
8521
8907
|
case "ide-setup": {
|
|
8522
|
-
const targetDir = args[0] ?
|
|
8908
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8523
8909
|
const res = installCandyIdeSupport({ workspaceDir: targetDir });
|
|
8524
8910
|
log(`
|
|
8525
8911
|
\uD83C\uDFA8 Installed Candy (.candy) IDE language support:`);
|
|
@@ -8561,6 +8947,15 @@ async function handleInit(args, log, error) {
|
|
|
8561
8947
|
throw new Error("The commerce scaffold uses TypeScript.");
|
|
8562
8948
|
if (engineIndex >= 0)
|
|
8563
8949
|
args = args.filter((_, index) => index !== engineIndex && index !== engineIndex + 1);
|
|
8950
|
+
const presetIndex = args.indexOf("--preset");
|
|
8951
|
+
const presetRaw = presetIndex < 0 ? undefined : args[presetIndex + 1];
|
|
8952
|
+
if (presetIndex >= 0) {
|
|
8953
|
+
if (!presetRaw || !CANDY_DESIGN_PRESET_IDS.includes(presetRaw)) {
|
|
8954
|
+
throw new Error(`Supported presets: ${CANDY_DESIGN_PRESET_IDS.join(", ")}`);
|
|
8955
|
+
}
|
|
8956
|
+
args = args.filter((_, index) => index !== presetIndex && index !== presetIndex + 1);
|
|
8957
|
+
}
|
|
8958
|
+
const preset = presetRaw;
|
|
8564
8959
|
const dirIndex = args.indexOf("--dir");
|
|
8565
8960
|
const dir = dirIndex < 0 ? undefined : args[dirIndex + 1];
|
|
8566
8961
|
if (dirIndex >= 0 && !dir)
|
|
@@ -8568,7 +8963,7 @@ async function handleInit(args, log, error) {
|
|
|
8568
8963
|
if (dirIndex >= 0)
|
|
8569
8964
|
args = args.filter((_, index) => index !== dirIndex && index !== dirIndex + 1);
|
|
8570
8965
|
const nameArg = args[0];
|
|
8571
|
-
const targetDir =
|
|
8966
|
+
const targetDir = resolve10(dir || args[1] || nameArg || "my-caartzee-theme");
|
|
8572
8967
|
const themeName = nameArg || "My Caartzee Theme";
|
|
8573
8968
|
log(`
|
|
8574
8969
|
\uD83D\uDCE6 Scaffolding new Caartzee theme in: ${targetDir}`);
|
|
@@ -8578,7 +8973,8 @@ async function handleInit(args, log, error) {
|
|
|
8578
8973
|
targetDir,
|
|
8579
8974
|
sdkPath: fileURLToPath3(new URL("../../", import.meta.url)),
|
|
8580
8975
|
name: themeName,
|
|
8581
|
-
engine
|
|
8976
|
+
engine,
|
|
8977
|
+
...preset ? { preset } : {}
|
|
8582
8978
|
});
|
|
8583
8979
|
log(`✨ Successfully generated theme "${result.name}" (${result.slug})!`);
|
|
8584
8980
|
log(` Created ${result.createdFiles.length} files:`);
|
|
@@ -8716,7 +9112,7 @@ async function handleDev(args, log, error) {
|
|
|
8716
9112
|
port = parseInt(args[i + 1], 10);
|
|
8717
9113
|
i++;
|
|
8718
9114
|
} else if (args[i] === "--dir" && args[i + 1]) {
|
|
8719
|
-
themeDir =
|
|
9115
|
+
themeDir = resolve10(args[i + 1]);
|
|
8720
9116
|
i++;
|
|
8721
9117
|
} else if (args[i] === "--store") {
|
|
8722
9118
|
store = args[++i];
|
|
@@ -8783,21 +9179,21 @@ Shutting down dev server...`);
|
|
|
8783
9179
|
}
|
|
8784
9180
|
}
|
|
8785
9181
|
async function handleValidate(args, log, error) {
|
|
8786
|
-
const targetDir = args[0] ?
|
|
9182
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8787
9183
|
log(`
|
|
8788
9184
|
\uD83D\uDEE1️ Running Caartzee Theme Security & Package Validation...`);
|
|
8789
9185
|
log(` Target: ${targetDir}`);
|
|
8790
|
-
const manifestPath =
|
|
8791
|
-
if (!
|
|
9186
|
+
const manifestPath = join12(targetDir, "manifest.json");
|
|
9187
|
+
if (!existsSync12(manifestPath)) {
|
|
8792
9188
|
error(`❌ Missing manifest.json in ${targetDir}`);
|
|
8793
9189
|
return 1;
|
|
8794
9190
|
}
|
|
8795
9191
|
try {
|
|
8796
|
-
if (
|
|
9192
|
+
if (existsSync12(join12(targetDir, "src/manifest.ts")) && typeof Bun !== "undefined") {
|
|
8797
9193
|
const theme = await loadLocalTheme(targetDir);
|
|
8798
9194
|
writeFileSync5(manifestPath, JSON.stringify(theme.manifest, null, 2));
|
|
8799
9195
|
}
|
|
8800
|
-
const rawManifest = JSON.parse(
|
|
9196
|
+
const rawManifest = JSON.parse(readFileSync12(manifestPath, "utf-8"));
|
|
8801
9197
|
const manifestCheck = ThemePackageValidator.validateManifest(rawManifest);
|
|
8802
9198
|
if (!manifestCheck.success) {
|
|
8803
9199
|
error(`❌ Manifest validation failed:`);
|
|
@@ -8836,7 +9232,7 @@ async function handleValidate(args, log, error) {
|
|
|
8836
9232
|
}
|
|
8837
9233
|
}
|
|
8838
9234
|
async function handleBuild(args, log, error) {
|
|
8839
|
-
const targetDir = args[0] ?
|
|
9235
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8840
9236
|
log(`
|
|
8841
9237
|
\uD83D\uDD28 Building Caartzee Theme Package...`);
|
|
8842
9238
|
log(` Source directory: ${targetDir}`);
|
|
@@ -8848,9 +9244,9 @@ async function handleBuild(args, log, error) {
|
|
|
8848
9244
|
}
|
|
8849
9245
|
return 1;
|
|
8850
9246
|
}
|
|
8851
|
-
const isCandy =
|
|
8852
|
-
const distDir =
|
|
8853
|
-
if (!
|
|
9247
|
+
const isCandy = existsSync12(join12(targetDir, "candy.config.json")) || existsSync12(join12(targetDir, "layout", "theme.candy")) || valResult.manifest?.engine === "candy";
|
|
9248
|
+
const distDir = join12(targetDir, "dist");
|
|
9249
|
+
if (!existsSync12(distDir)) {
|
|
8854
9250
|
mkdirSync5(distDir, { recursive: true });
|
|
8855
9251
|
}
|
|
8856
9252
|
if (isCandy) {
|
|
@@ -8863,8 +9259,8 @@ async function handleBuild(args, log, error) {
|
|
|
8863
9259
|
}
|
|
8864
9260
|
return 1;
|
|
8865
9261
|
}
|
|
8866
|
-
const bundlePath =
|
|
8867
|
-
const manifestOutPath =
|
|
9262
|
+
const bundlePath = join12(distDir, "candy-theme-bundle.json");
|
|
9263
|
+
const manifestOutPath = join12(distDir, "manifest.json");
|
|
8868
9264
|
writeFileSync5(bundlePath, JSON.stringify(bundle, null, 2), "utf-8");
|
|
8869
9265
|
writeFileSync5(manifestOutPath, JSON.stringify(bundle.manifest, null, 2), "utf-8");
|
|
8870
9266
|
log(`✓ Extracted ${Object.keys(bundle.sectionSchemas).length} section schemas`);
|
|
@@ -8874,7 +9270,7 @@ async function handleBuild(args, log, error) {
|
|
|
8874
9270
|
return 0;
|
|
8875
9271
|
}
|
|
8876
9272
|
if (valResult.manifest) {
|
|
8877
|
-
const manifestOutPath =
|
|
9273
|
+
const manifestOutPath = join12(distDir, "manifest.json");
|
|
8878
9274
|
writeFileSync5(manifestOutPath, JSON.stringify(valResult.manifest, null, 2), "utf-8");
|
|
8879
9275
|
log(`✓ Wrote validated manifest to ${manifestOutPath}
|
|
8880
9276
|
`);
|
|
@@ -8893,10 +9289,10 @@ async function handlePush(args, log, error) {
|
|
|
8893
9289
|
error(`❌ Insufficient scope. Your account lacks "theme:publish" permissions.`);
|
|
8894
9290
|
return 1;
|
|
8895
9291
|
}
|
|
8896
|
-
const targetDir = args[0] ?
|
|
8897
|
-
if (
|
|
9292
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
9293
|
+
if (existsSync12(join12(targetDir, "src/manifest.ts")) && typeof Bun !== "undefined") {
|
|
8898
9294
|
const theme = await loadLocalTheme(targetDir);
|
|
8899
|
-
writeFileSync5(
|
|
9295
|
+
writeFileSync5(join12(targetDir, "manifest.json"), JSON.stringify(theme.manifest, null, 2));
|
|
8900
9296
|
}
|
|
8901
9297
|
const valResult = await ThemePackageValidator.validatePackage(targetDir);
|
|
8902
9298
|
if (!valResult.valid) {
|
|
@@ -8918,7 +9314,7 @@ async function handlePush(args, log, error) {
|
|
|
8918
9314
|
return 0;
|
|
8919
9315
|
}
|
|
8920
9316
|
async function handleDoctor(args, log, error) {
|
|
8921
|
-
const targetDir = args[0] ?
|
|
9317
|
+
const targetDir = args[0] ? resolve10(args[0]) : process.cwd();
|
|
8922
9318
|
log(`
|
|
8923
9319
|
\uD83E\uDE7A Running Caartzee Candy Theme Doctor...`);
|
|
8924
9320
|
log(` Target: ${targetDir}
|
|
@@ -8927,8 +9323,8 @@ async function handleDoctor(args, log, error) {
|
|
|
8927
9323
|
const warnings = [];
|
|
8928
9324
|
const passed = [];
|
|
8929
9325
|
const readIfExists = (rel) => {
|
|
8930
|
-
const full =
|
|
8931
|
-
return
|
|
9326
|
+
const full = join12(targetDir, rel);
|
|
9327
|
+
return existsSync12(full) ? readFileSync12(full, "utf8") : null;
|
|
8932
9328
|
};
|
|
8933
9329
|
const configRaw = readIfExists("candy.config.json");
|
|
8934
9330
|
const manifestRaw = readIfExists("manifest.json");
|
|
@@ -8972,7 +9368,7 @@ async function handleDoctor(args, log, error) {
|
|
|
8972
9368
|
}
|
|
8973
9369
|
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
9370
|
for (const name of templateNames) {
|
|
8975
|
-
const content = readIfExists(
|
|
9371
|
+
const content = readIfExists(join12("templates", name));
|
|
8976
9372
|
if (!content)
|
|
8977
9373
|
continue;
|
|
8978
9374
|
if (usesShell && /\{%\s*layout\s+/i.test(content)) {
|
|
@@ -8982,7 +9378,7 @@ async function handleDoctor(args, log, error) {
|
|
|
8982
9378
|
issues.push(`templates/${name} emits a synthetic "-default" variant ID, which causes POST /_api/cart 422 errors.`);
|
|
8983
9379
|
}
|
|
8984
9380
|
}
|
|
8985
|
-
const productCard = readIfExists(
|
|
9381
|
+
const productCard = readIfExists(join12("snippets", "product-card.candy"));
|
|
8986
9382
|
if (productCard) {
|
|
8987
9383
|
if (/data-variant-id\s*=\s*["'][^"']*-default["']/i.test(productCard)) {
|
|
8988
9384
|
issues.push('snippets/product-card.candy emits a synthetic "-default" variant ID. Guard data-variant-id with product.has_inventory_variants.');
|
|
@@ -8990,7 +9386,7 @@ async function handleDoctor(args, log, error) {
|
|
|
8990
9386
|
passed.push("Product card variant ID contract looks safe");
|
|
8991
9387
|
}
|
|
8992
9388
|
}
|
|
8993
|
-
const headerCandy = readIfExists(
|
|
9389
|
+
const headerCandy = readIfExists(join12("sections", "header.candy"));
|
|
8994
9390
|
if (headerCandy) {
|
|
8995
9391
|
if (!headerCandy.includes("js-cart-count")) {
|
|
8996
9392
|
warnings.push("sections/header.candy is missing .js-cart-count on the cart badge (live Add to Cart count won't update).");
|
|
@@ -9003,7 +9399,7 @@ async function handleDoctor(args, log, error) {
|
|
|
9003
9399
|
passed.push("Header navigation menu (menuId + linklists) wired");
|
|
9004
9400
|
}
|
|
9005
9401
|
}
|
|
9006
|
-
const heroCandy = readIfExists(
|
|
9402
|
+
const heroCandy = readIfExists(join12("sections", "hero-banner.candy"));
|
|
9007
9403
|
if (heroCandy) {
|
|
9008
9404
|
if (!heroCandy.includes("mobile_sliders")) {
|
|
9009
9405
|
warnings.push("sections/hero-banner.candy does not read mobile_sliders (merchant Mobile Slider changes won't reflect).");
|
|
@@ -9011,8 +9407,8 @@ async function handleDoctor(args, log, error) {
|
|
|
9011
9407
|
passed.push("Hero banner mobile_sliders support present");
|
|
9012
9408
|
}
|
|
9013
9409
|
}
|
|
9014
|
-
const loginCandy = readIfExists(
|
|
9015
|
-
const registerCandy = readIfExists(
|
|
9410
|
+
const loginCandy = readIfExists(join12("templates", "login.candy"));
|
|
9411
|
+
const registerCandy = readIfExists(join12("templates", "register.candy"));
|
|
9016
9412
|
if (loginCandy) {
|
|
9017
9413
|
if (!loginCandy.includes("/_api/auth/login") || !loginCandy.includes("js-auth-form")) {
|
|
9018
9414
|
issues.push('templates/login.candy must post to /_api/auth/login with class="js-auth-form".');
|
|
@@ -9027,11 +9423,11 @@ async function handleDoctor(args, log, error) {
|
|
|
9027
9423
|
passed.push("Signup page (/signup, /register) auth contract verified");
|
|
9028
9424
|
}
|
|
9029
9425
|
}
|
|
9030
|
-
if (readIfExists(
|
|
9426
|
+
if (readIfExists(join12("assets", "theme.css")))
|
|
9031
9427
|
passed.push("assets/theme.css found");
|
|
9032
9428
|
else
|
|
9033
9429
|
warnings.push("assets/theme.css not found.");
|
|
9034
|
-
if (readIfExists(
|
|
9430
|
+
if (readIfExists(join12("assets", "theme.js")))
|
|
9035
9431
|
passed.push("assets/theme.js found");
|
|
9036
9432
|
else
|
|
9037
9433
|
warnings.push("assets/theme.js not found.");
|
|
@@ -9058,19 +9454,19 @@ async function handleDoctor(args, log, error) {
|
|
|
9058
9454
|
}
|
|
9059
9455
|
async function handleVersion(args, log, error) {
|
|
9060
9456
|
const bump = args[0]?.trim();
|
|
9061
|
-
const targetDir = args[1] ?
|
|
9457
|
+
const targetDir = args[1] ? resolve10(args[1]) : process.cwd();
|
|
9062
9458
|
if (!bump) {
|
|
9063
9459
|
error("Usage: caartzee-theme version <patch|minor|major|x.y.z> [path]");
|
|
9064
9460
|
return 1;
|
|
9065
9461
|
}
|
|
9066
|
-
const configPath =
|
|
9067
|
-
const manifestPath =
|
|
9068
|
-
if (!
|
|
9462
|
+
const configPath = join12(targetDir, "candy.config.json");
|
|
9463
|
+
const manifestPath = join12(targetDir, "manifest.json");
|
|
9464
|
+
if (!existsSync12(configPath) && !existsSync12(manifestPath)) {
|
|
9069
9465
|
error(`No candy.config.json or manifest.json found in ${targetDir}`);
|
|
9070
9466
|
return 1;
|
|
9071
9467
|
}
|
|
9072
|
-
const readJson = (p) => JSON.parse(
|
|
9073
|
-
const current =
|
|
9468
|
+
const readJson = (p) => JSON.parse(readFileSync12(p, "utf8"));
|
|
9469
|
+
const current = existsSync12(configPath) ? String(readJson(configPath).version || "1.0.0") : String(readJson(manifestPath).version || "1.0.0");
|
|
9074
9470
|
let nextVersion = bump;
|
|
9075
9471
|
if (bump === "patch" || bump === "minor" || bump === "major") {
|
|
9076
9472
|
const parts = current.split(".").map((n) => parseInt(n, 10) || 0);
|
|
@@ -9080,13 +9476,13 @@ async function handleVersion(args, log, error) {
|
|
|
9080
9476
|
error(`Invalid version "${bump}". Use patch, minor, major, or semver like 1.0.3.`);
|
|
9081
9477
|
return 1;
|
|
9082
9478
|
}
|
|
9083
|
-
if (
|
|
9479
|
+
if (existsSync12(configPath)) {
|
|
9084
9480
|
const cfg = readJson(configPath);
|
|
9085
9481
|
cfg.version = nextVersion;
|
|
9086
9482
|
writeFileSync5(configPath, JSON.stringify(cfg, null, 2) + `
|
|
9087
9483
|
`, "utf8");
|
|
9088
9484
|
}
|
|
9089
|
-
if (
|
|
9485
|
+
if (existsSync12(manifestPath)) {
|
|
9090
9486
|
const man = readJson(manifestPath);
|
|
9091
9487
|
man.version = nextVersion;
|
|
9092
9488
|
writeFileSync5(manifestPath, JSON.stringify(man, null, 2) + `
|
|
@@ -9098,7 +9494,7 @@ async function handleVersion(args, log, error) {
|
|
|
9098
9494
|
function parseTargetAndJson(args) {
|
|
9099
9495
|
const asJson = args.includes("--json");
|
|
9100
9496
|
const positional = args.filter((a) => !a.startsWith("-"));
|
|
9101
|
-
const targetDir = positional[0] ?
|
|
9497
|
+
const targetDir = positional[0] ? resolve10(positional[0]) : process.cwd();
|
|
9102
9498
|
return { targetDir, asJson };
|
|
9103
9499
|
}
|
|
9104
9500
|
async function handleTestEditor(args, log, error) {
|
|
@@ -9153,10 +9549,10 @@ ${failed === 0 ? "✅" : "❌"} Result: ${passed} passed, ${failed} failed, ${wa
|
|
|
9153
9549
|
async function handleTestReport(args, log, error) {
|
|
9154
9550
|
const { targetDir, asJson } = parseTargetAndJson(args);
|
|
9155
9551
|
const report = await runThemeReadinessAudit(targetDir);
|
|
9156
|
-
const distDir =
|
|
9157
|
-
if (!
|
|
9552
|
+
const distDir = join12(targetDir, "dist");
|
|
9553
|
+
if (!existsSync12(distDir))
|
|
9158
9554
|
mkdirSync5(distDir, { recursive: true });
|
|
9159
|
-
const outPath =
|
|
9555
|
+
const outPath = join12(distDir, "theme-readiness-report.json");
|
|
9160
9556
|
writeFileSync5(outPath, JSON.stringify(report, null, 2), "utf8");
|
|
9161
9557
|
if (asJson) {
|
|
9162
9558
|
log(JSON.stringify({ reportPath: outPath, ...report }, null, 2));
|
|
@@ -9173,10 +9569,28 @@ async function handleTestReport(args, log, error) {
|
|
|
9173
9569
|
}
|
|
9174
9570
|
return 0;
|
|
9175
9571
|
}
|
|
9572
|
+
async function handleUiAudit(args, log, error) {
|
|
9573
|
+
const { targetDir, asJson } = parseTargetAndJson(args);
|
|
9574
|
+
const report = auditCandyUiConsistency(targetDir);
|
|
9575
|
+
if (asJson) {
|
|
9576
|
+
log(JSON.stringify(report, null, 2));
|
|
9577
|
+
return report.summary.failed > 0 ? 1 : 0;
|
|
9578
|
+
}
|
|
9579
|
+
log(`
|
|
9580
|
+
\uD83C\uDFA8 Caartzee Candy UI Consistency Audit (${targetDir})`);
|
|
9581
|
+
for (const c of report.checks) {
|
|
9582
|
+
const icon = c.status === "passed" ? "✓" : c.status === "warning" ? "⚠️" : "❌";
|
|
9583
|
+
(c.status === "failed" ? error : log)(` ${icon} [${c.id}] ${c.message}`);
|
|
9584
|
+
}
|
|
9585
|
+
log(`
|
|
9586
|
+
${report.summary.failed === 0 ? "✅" : "❌"} UI Audit: ${report.summary.passed} passed, ${report.summary.failed} failed, ${report.summary.warnings} warning(s).
|
|
9587
|
+
`);
|
|
9588
|
+
return report.summary.failed > 0 ? 1 : 0;
|
|
9589
|
+
}
|
|
9176
9590
|
function printHelp(log) {
|
|
9177
9591
|
log(`
|
|
9178
9592
|
╔═══════════════════════════════════════════════════════════════╗
|
|
9179
|
-
║ CAARTZEE THEME SDK CLI (v1.2.
|
|
9593
|
+
║ CAARTZEE THEME SDK CLI (v1.2.1) ║
|
|
9180
9594
|
║ Build, test, and publish secure storefront themes locally ║
|
|
9181
9595
|
╚═══════════════════════════════════════════════════════════════╝
|
|
9182
9596
|
|
|
@@ -9185,8 +9599,9 @@ Usage:
|
|
|
9185
9599
|
npx @caartzee/theme-sdk <command> [options]
|
|
9186
9600
|
|
|
9187
9601
|
Commands:
|
|
9188
|
-
init [name]
|
|
9602
|
+
init [name] [--engine candy] [--preset minimal-luxury|streetwear-editorial|organic-wellness|modern-tech|vibrant-d2c]
|
|
9189
9603
|
dev [--port 3333] [--store DOMAIN] [--editor] Preview with full local commerce/auth & Theme Editor
|
|
9604
|
+
ui-audit [path] [--json] Audit design tokens, uniform card aspect ratios, responsive CSS & empty states
|
|
9190
9605
|
doctor [path] Audit storefront-shell, cart/variant hooks, auth forms, menus & mobile sliders
|
|
9191
9606
|
version <patch|minor|major|x.y.z> [path] Bump version across candy.config.json and manifest.json
|
|
9192
9607
|
sync-manifest [path] Export the locally authored theme manifest to JSON
|