create-abcart-theme 0.0.0-stage → 0.10.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/CHANGELOG.md +127 -0
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +64 -2
- package/bin/create-abcart-theme.mjs +4 -0
- package/package.json +47 -4
- package/src/args.mjs +113 -0
- package/src/banner.mjs +21 -0
- package/src/cli.mjs +119 -0
- package/src/create.mjs +82 -0
- package/src/package-manager.mjs +32 -0
- package/src/style.mjs +17 -0
- package/templates/default/.agents/skills/shopify-theme-asset-collector/SKILL.md +125 -0
- package/templates/default/.agents/skills/shopify-theme-asset-collector/scripts/collect_public_assets.py +370 -0
- package/templates/default/.agents/skills/wocart-docs/SKILL.md +146 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/SKILL.md +58 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/inputs-and-rights.md +47 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/layout-rtl-and-phone.md +36 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/measure-the-design.md +60 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/tokens-sections-content.md +103 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/references/verify-and-report.md +102 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/scripts/compare-design.cjs +230 -0
- package/templates/default/.agents/skills/wocart-theme-from-design/scripts/qa-pages.cjs +219 -0
- package/templates/default/.dev.vars.example +12 -0
- package/templates/default/AGENTS.md +240 -0
- package/templates/default/README.md +184 -0
- package/templates/default/_gitignore +11 -0
- package/templates/default/astro.config.mjs +85 -0
- package/templates/default/package.json +36 -0
- package/templates/default/public/fonts/OFL.txt +96 -0
- package/templates/default/public/fonts/alexandria-arabic.woff2 +0 -0
- package/templates/default/public/fonts/fraunces-latin.woff2 +0 -0
- package/templates/default/src/actions/index.ts +22 -0
- package/templates/default/src/components/cart/AddToCartButton.astro +45 -0
- package/templates/default/src/components/cart/CartDrawer.astro +47 -0
- package/templates/default/src/components/cart/CartSummary.astro +11 -0
- package/templates/default/src/components/cart/FreeShipping.astro +7 -0
- package/templates/default/src/components/checkout/CheckoutMain.astro +29 -0
- package/templates/default/src/components/checkout/OrderForm.astro +280 -0
- package/templates/default/src/components/checkout/ThankYouMain.astro +68 -0
- package/templates/default/src/components/landing/LandingImages.astro +51 -0
- package/templates/default/src/components/landing/LandingOrder.astro +46 -0
- package/templates/default/src/components/landing/LandingProduct.astro +41 -0
- package/templates/default/src/components/listing/ListingMain.astro +93 -0
- package/templates/default/src/components/listing/PageMain.astro +52 -0
- package/templates/default/src/components/listing/Pagination.astro +31 -0
- package/templates/default/src/components/listing/SortControl.astro +35 -0
- package/templates/default/src/components/product/BuyBox.astro +96 -0
- package/templates/default/src/components/product/Description.astro +24 -0
- package/templates/default/src/components/product/Gallery.astro +66 -0
- package/templates/default/src/components/product/MobileBuyBar.astro +29 -0
- package/templates/default/src/components/product/OfferChoice.astro +66 -0
- package/templates/default/src/components/product/ProductMain.astro +40 -0
- package/templates/default/src/components/product/ProductReviews.astro +72 -0
- package/templates/default/src/components/product/RelatedProducts.astro +30 -0
- package/templates/default/src/components/product/blocks/BenefitsBlock.astro +13 -0
- package/templates/default/src/components/product/blocks/CollapsibleBlock.astro +20 -0
- package/templates/default/src/components/product/blocks/DescriptionBlock.astro +19 -0
- package/templates/default/src/components/product/blocks/DetailsBlock.astro +33 -0
- package/templates/default/src/components/product/blocks/GalleryBlock.astro +12 -0
- package/templates/default/src/components/product/blocks/OrderBlock.astro +30 -0
- package/templates/default/src/components/product/blocks/PriceBlock.astro +23 -0
- package/templates/default/src/components/product/blocks/RatingBlock.astro +16 -0
- package/templates/default/src/components/product/blocks/StockBlock.astro +22 -0
- package/templates/default/src/components/product/blocks/TextBlock.astro +11 -0
- package/templates/default/src/components/product/blocks/TitleBlock.astro +20 -0
- package/templates/default/src/components/reviews/ReviewCard.astro +46 -0
- package/templates/default/src/components/reviews/ReviewForm.astro +113 -0
- package/templates/default/src/components/reviews/VoiceNote.astro +60 -0
- package/templates/default/src/components/sections/CollectionCards.astro +65 -0
- package/templates/default/src/components/sections/Countdown.astro +57 -0
- package/templates/default/src/components/sections/Faq.astro +44 -0
- package/templates/default/src/components/sections/FeaturedProduct.astro +71 -0
- package/templates/default/src/components/sections/Hero.astro +99 -0
- package/templates/default/src/components/sections/ImageBanner.astro +46 -0
- package/templates/default/src/components/sections/ProductGrid.astro +47 -0
- package/templates/default/src/components/sections/RichText.astro +35 -0
- package/templates/default/src/components/sections/Steps.astro +46 -0
- package/templates/default/src/components/sections/Testimonials.astro +57 -0
- package/templates/default/src/components/shell/Footer.astro +80 -0
- package/templates/default/src/components/shell/Header.astro +89 -0
- package/templates/default/src/components/shell/LanguageMenu.astro +33 -0
- package/templates/default/src/components/shell/MobileMenu.astro +65 -0
- package/templates/default/src/components/shell/SearchDialog.astro +19 -0
- package/templates/default/src/components/shell/TopBar.astro +54 -0
- package/templates/default/src/components/shell/WhatsAppWidget.astro +111 -0
- package/templates/default/src/components/store/ContactMain.astro +79 -0
- package/templates/default/src/components/store/SearchMain.astro +56 -0
- package/templates/default/src/components/store/TrackOrderMain.astro +161 -0
- package/templates/default/src/components/surface/Area.astro +20 -0
- package/templates/default/src/components/surface/PreviewBridge.astro +24 -0
- package/templates/default/src/components/surface/Sections.astro +35 -0
- package/templates/default/src/components/ui/Breadcrumbs.astro +36 -0
- package/templates/default/src/components/ui/Button.astro +45 -0
- package/templates/default/src/components/ui/EditorPlaceholder.astro +24 -0
- package/templates/default/src/components/ui/Icon.astro +93 -0
- package/templates/default/src/components/ui/Logo.astro +36 -0
- package/templates/default/src/components/ui/Photo.astro +46 -0
- package/templates/default/src/components/ui/Price.astro +24 -0
- package/templates/default/src/components/ui/ProductCard.astro +41 -0
- package/templates/default/src/components/ui/Rating.astro +22 -0
- package/templates/default/src/components/ui/Section.astro +34 -0
- package/templates/default/src/components/ui/SectionHeading.astro +19 -0
- package/templates/default/src/env.d.ts +23 -0
- package/templates/default/src/layouts/StoreLayout.astro +145 -0
- package/templates/default/src/lib/browser-copy.ts +37 -0
- package/templates/default/src/lib/context.ts +89 -0
- package/templates/default/src/lib/coupon-notice.ts +47 -0
- package/templates/default/src/lib/i18n.ts +32 -0
- package/templates/default/src/lib/images.ts +38 -0
- package/templates/default/src/lib/listing-query.ts +41 -0
- package/templates/default/src/lib/money.ts +16 -0
- package/templates/default/src/lib/motion.ts +16 -0
- package/templates/default/src/lib/nav.ts +26 -0
- package/templates/default/src/lib/offer-tiles.ts +105 -0
- package/templates/default/src/lib/order-outcome.ts +66 -0
- package/templates/default/src/lib/otp-message.ts +21 -0
- package/templates/default/src/lib/products.ts +38 -0
- package/templates/default/src/lib/review-refusals.ts +31 -0
- package/templates/default/src/lib/store.ts +31 -0
- package/templates/default/src/lib/whatsapp.ts +29 -0
- package/templates/default/src/middleware.ts +23 -0
- package/templates/default/src/pages/404.astro +22 -0
- package/templates/default/src/pages/api/abandoned/convert.ts +4 -0
- package/templates/default/src/pages/api/abandoned/upsert.ts +4 -0
- package/templates/default/src/pages/api/cart/validate.ts +4 -0
- package/templates/default/src/pages/api/communes/[wilayaId].ts +4 -0
- package/templates/default/src/pages/api/otp/send.ts +4 -0
- package/templates/default/src/pages/api/otp/verify.ts +4 -0
- package/templates/default/src/pages/api/reviews/[productId].ts +3 -0
- package/templates/default/src/pages/api/reviews/eligibility.ts +3 -0
- package/templates/default/src/pages/api/reviews/submit.ts +3 -0
- package/templates/default/src/pages/api/reviews/upload.ts +3 -0
- package/templates/default/src/pages/category/[slug].astro +20 -0
- package/templates/default/src/pages/checkout.astro +25 -0
- package/templates/default/src/pages/collections/[handle].astro +20 -0
- package/templates/default/src/pages/contact.astro +17 -0
- package/templates/default/src/pages/index.astro +9 -0
- package/templates/default/src/pages/lp/[slug].astro +47 -0
- package/templates/default/src/pages/pages/[slug].astro +16 -0
- package/templates/default/src/pages/products/[handle].astro +37 -0
- package/templates/default/src/pages/products/index.astro +15 -0
- package/templates/default/src/pages/robots.txt.ts +9 -0
- package/templates/default/src/pages/search.astro +19 -0
- package/templates/default/src/pages/sitemap.xml.ts +12 -0
- package/templates/default/src/pages/thank-you.astro +33 -0
- package/templates/default/src/pages/track-order.astro +17 -0
- package/templates/default/src/pages/wocart-preview.astro +43 -0
- package/templates/default/src/pages/wocart-revalidate.ts +10 -0
- package/templates/default/src/pages/wocart-styles.css.ts +5 -0
- package/templates/default/src/pages/wocart-theme.json.ts +5 -0
- package/templates/default/src/scripts/cart.ts +371 -0
- package/templates/default/src/scripts/checkout/coupon.ts +96 -0
- package/templates/default/src/scripts/checkout/delivery.ts +86 -0
- package/templates/default/src/scripts/checkout/form.ts +54 -0
- package/templates/default/src/scripts/checkout/otp.ts +106 -0
- package/templates/default/src/scripts/checkout/picker.ts +169 -0
- package/templates/default/src/scripts/checkout/quote.ts +169 -0
- package/templates/default/src/scripts/checkout/submit.ts +113 -0
- package/templates/default/src/scripts/checkout/tracking.ts +74 -0
- package/templates/default/src/scripts/countdown.ts +29 -0
- package/templates/default/src/scripts/events.ts +4 -0
- package/templates/default/src/scripts/hero.ts +49 -0
- package/templates/default/src/scripts/listing.ts +13 -0
- package/templates/default/src/scripts/order-form.ts +100 -0
- package/templates/default/src/scripts/product.ts +306 -0
- package/templates/default/src/scripts/public-config.ts +79 -0
- package/templates/default/src/scripts/reviews.ts +358 -0
- package/templates/default/src/scripts/site.ts +131 -0
- package/templates/default/src/scripts/thank-you.ts +11 -0
- package/templates/default/src/scripts/voice-note.ts +94 -0
- package/templates/default/src/styles/base.css +1030 -0
- package/templates/default/src/styles/checkout.css +1111 -0
- package/templates/default/src/styles/global.css +12 -0
- package/templates/default/src/styles/product.css +871 -0
- package/templates/default/src/styles/reviews.css +533 -0
- package/templates/default/src/styles/sections.css +931 -0
- package/templates/default/src/styles/shell.css +970 -0
- package/templates/default/src/styles/tokens.css +583 -0
- package/templates/default/src/theme/api-routes.ts +10 -0
- package/templates/default/src/theme/content/catalog.ts +117 -0
- package/templates/default/src/theme/content/checkout.ts +168 -0
- package/templates/default/src/theme/content/editor.ts +21 -0
- package/templates/default/src/theme/content/index.ts +45 -0
- package/templates/default/src/theme/content/reviews.ts +76 -0
- package/templates/default/src/theme/content/shell.ts +59 -0
- package/templates/default/src/theme/content/types.ts +12 -0
- package/templates/default/src/theme/documents/catalog.json +11 -0
- package/templates/default/src/theme/documents/category.json +11 -0
- package/templates/default/src/theme/documents/checkout.json +11 -0
- package/templates/default/src/theme/documents/collection.json +11 -0
- package/templates/default/src/theme/documents/contact.json +11 -0
- package/templates/default/src/theme/documents/footer.area.json +11 -0
- package/templates/default/src/theme/documents/header.area.json +16 -0
- package/templates/default/src/theme/documents/home.json +313 -0
- package/templates/default/src/theme/documents/landing.json +8 -0
- package/templates/default/src/theme/documents/page.json +11 -0
- package/templates/default/src/theme/documents/product.json +125 -0
- package/templates/default/src/theme/documents/search.json +11 -0
- package/templates/default/src/theme/documents/thank-you.json +11 -0
- package/templates/default/src/theme/documents/track-order.json +11 -0
- package/templates/default/src/theme/fields.ts +61 -0
- package/templates/default/src/theme/key.ts +11 -0
- package/templates/default/src/theme/labels.ts +231 -0
- package/templates/default/src/theme/locales.ts +11 -0
- package/templates/default/src/theme/palette.ts +14 -0
- package/templates/default/src/theme/sections/collection-cards.ts +65 -0
- package/templates/default/src/theme/sections/faq.ts +74 -0
- package/templates/default/src/theme/sections/featured-product.ts +42 -0
- package/templates/default/src/theme/sections/hero.ts +47 -0
- package/templates/default/src/theme/sections/image-banner.ts +25 -0
- package/templates/default/src/theme/sections/index.ts +40 -0
- package/templates/default/src/theme/sections/landing.ts +150 -0
- package/templates/default/src/theme/sections/listing.ts +84 -0
- package/templates/default/src/theme/sections/product-grid.ts +42 -0
- package/templates/default/src/theme/sections/product.ts +297 -0
- package/templates/default/src/theme/sections/rich-text.ts +39 -0
- package/templates/default/src/theme/sections/shared.ts +54 -0
- package/templates/default/src/theme/sections/shell.ts +85 -0
- package/templates/default/src/theme/sections/store-pages.ts +101 -0
- package/templates/default/src/theme/sections/testimonials.ts +61 -0
- package/templates/default/src/theme/sections/thank-you.ts +35 -0
- package/templates/default/src/theme/settings.ts +124 -0
- package/templates/default/src/theme/theme.ts +65 -0
- package/templates/default/tests/fixtures/canvas-tote.json +62 -0
- package/templates/default/tests/fixtures/linen-shirt.json +128 -0
- package/templates/default/tests/unit/checkout.test.ts +241 -0
- package/templates/default/tests/unit/contract.test.ts +169 -0
- package/templates/default/tests/unit/contrast.test.ts +68 -0
- package/templates/default/tests/unit/copy.test.ts +101 -0
- package/templates/default/tests/unit/design-values.test.ts +95 -0
- package/templates/default/tests/unit/editability.test.ts +180 -0
- package/templates/default/tests/unit/fixtures.ts +91 -0
- package/templates/default/tests/unit/footer.test.ts +54 -0
- package/templates/default/tests/unit/guards.test.ts +340 -0
- package/templates/default/tests/unit/images.test.ts +26 -0
- package/templates/default/tests/unit/landing.test.ts +151 -0
- package/templates/default/tests/unit/languages.test.ts +42 -0
- package/templates/default/tests/unit/middleware.test.ts +53 -0
- package/templates/default/tests/unit/offer-tiles.test.ts +75 -0
- package/templates/default/tests/unit/render.ts +38 -0
- package/templates/default/tests/unit/reviews.test.ts +25 -0
- package/templates/default/tests/unit/rules.test.ts +59 -0
- package/templates/default/tests/unit/source.ts +75 -0
- package/templates/default/tests/unit/store-pages.test.ts +147 -0
- package/templates/default/tests/unit/studio.test.ts +202 -0
- package/templates/default/tests/unit/testimonials.test.ts +52 -0
- package/templates/default/tests/unit/thank-you.test.ts +52 -0
- package/templates/default/tests/unit/tracking.test.ts +29 -0
- package/templates/default/tests/unit/voice-note.test.ts +42 -0
- package/templates/default/tsconfig.json +13 -0
- package/templates/default/vitest.config.ts +15 -0
- package/templates/default/wrangler.jsonc +17 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.10.0 — 2026-11-13
|
|
4
|
+
|
|
5
|
+
- A new theme starts on `@wocart/storefront` 4.7.0: a shopper who comes back
|
|
6
|
+
by typing the address keeps where they first came from, and Google, Microsoft
|
|
7
|
+
and Snapchat ads are recognised by the parameters those platforms add.
|
|
8
|
+
|
|
9
|
+
## 0.9.0 — 2026-11-13
|
|
10
|
+
|
|
11
|
+
- A new theme starts on `@wocart/storefront` 4.6.0: a shopper's first visit
|
|
12
|
+
from Google Search keeps its source even when Google prefetched the page, and
|
|
13
|
+
the Android app that opened the store (the Google app, Facebook, Gmail…) is
|
|
14
|
+
named.
|
|
15
|
+
|
|
16
|
+
## 0.8.0 — 2026-11-12
|
|
17
|
+
|
|
18
|
+
- A new theme starts on `@wocart/storefront` 4.5.0: every order says where the
|
|
19
|
+
shopper came from (an ad, a social link, search, another site, or a direct
|
|
20
|
+
visit), and an ad is credited only for a real ad click.
|
|
21
|
+
|
|
22
|
+
## 0.7.0 — 2026-11-11
|
|
23
|
+
|
|
24
|
+
- A new theme starts on `@wocart/storefront` 4.4.0: every order carries the ad,
|
|
25
|
+
the click and the landing page its visit came from, with no theme code. The
|
|
26
|
+
order form no longer copies the Meta cookies itself; the storefront reads them
|
|
27
|
+
from the shopper's request for every order.
|
|
28
|
+
|
|
29
|
+
## 0.6.0 — 2026-11-10
|
|
30
|
+
|
|
31
|
+
- A new theme starts on `@wocart/storefront` 4.3.0, and a refused order says
|
|
32
|
+
why in the store's language: the product that ran out or can no longer be
|
|
33
|
+
ordered (named from platform v9.3.1), a delivery the store does not make, the
|
|
34
|
+
bot check, the phone code, the fields to fix, or a failure with the
|
|
35
|
+
reference to quote. The order action is `placeOrder` in one line.
|
|
36
|
+
- The checkout reads the order form's outcome once per request, like the
|
|
37
|
+
product and landing pages.
|
|
38
|
+
|
|
39
|
+
## 0.5.0 — 2026-11-10
|
|
40
|
+
|
|
41
|
+
- A new theme starts on `@wocart/storefront` 4.2.1: Algeria's 69 wilayas and
|
|
42
|
+
1,541 communes, and the checkout context its order form sends with each
|
|
43
|
+
order.
|
|
44
|
+
- It says it needs platform v9.0.0, as `@wocart/storefront` 4.1.0 does; the
|
|
45
|
+
template's README names the SDK versions it pins, and a test keeps both true.
|
|
46
|
+
|
|
47
|
+
## 0.4.0 — 2026-11-07
|
|
48
|
+
|
|
49
|
+
- A new theme starts on `@wocart/storefront` 4.0.0 and `@wocart/theme` 4.3.0,
|
|
50
|
+
and reports through the SDK's tracking: the layout renders
|
|
51
|
+
`trackingHead(pixelId)` and calls `storefrontTracking().start()`, the
|
|
52
|
+
product page, the basket and the checkout report `productViewed`,
|
|
53
|
+
`addedToCart` and `checkoutStarted`, and the thank-you page renders the
|
|
54
|
+
server's sale with `conversionTag`. The theme writes no pixel call; a guard
|
|
55
|
+
test (`tests/unit/tracking.test.ts`) fails on one. The thank-you page loads
|
|
56
|
+
no pixel when the order's tracking cannot be read.
|
|
57
|
+
|
|
58
|
+
## 0.3.0 — 2026-11-06
|
|
59
|
+
|
|
60
|
+
- `npm create wocart-theme` opens with the Wocart wordmark and the version on a
|
|
61
|
+
terminal. Its steps and headings use the brand colour and bold. Output piped
|
|
62
|
+
to a file or a CI log stays plain text, and `NO_COLOR` turns colour off. No new
|
|
63
|
+
dependency.
|
|
64
|
+
- The starter's WhatsApp widget names its caption and greeting in each language,
|
|
65
|
+
and its launcher uses a green that passes WCAG AA with white.
|
|
66
|
+
- The current nav link takes the accent text colour, so it reads on a light header.
|
|
67
|
+
- On a phone the product gallery keeps its thumbnails; only the arrows hide.
|
|
68
|
+
- On a touch screen a long list (wilayas, communes) opens as a themed list, not
|
|
69
|
+
the phone's own wheel. The native select stays in the form.
|
|
70
|
+
- Three skills, one route each. `wocart-theme-from-design` builds a theme that
|
|
71
|
+
must match a design (a screenshot, a live URL or a Shopify theme): its design
|
|
72
|
+
values as tokens, its sections, content and claims, right-to-left and phone
|
|
73
|
+
layouts, and a `compare-design` script that measures the match. It replaces
|
|
74
|
+
the screenshot and design skills, and its steps live in `references/`.
|
|
75
|
+
`shopify-theme-asset-collector` collects a Shopify theme's public pages and
|
|
76
|
+
assets, with a manifest of the homepage sections, to measure a design. Its
|
|
77
|
+
output is never shipped. `wocart-docs` says where each platform rule is
|
|
78
|
+
defined, and the test that checks it. `AGENTS.md` and `README.md` name the
|
|
79
|
+
three.
|
|
80
|
+
- The starter's own design values are tokens: its stylesheets hold no literal
|
|
81
|
+
size, line height, letter-spacing, weight, colour, radius, shadow, border,
|
|
82
|
+
surface, filter, aspect ratio, motion or opacity. Its scripts read their
|
|
83
|
+
timings from `--motion-*` tokens through `src/lib/motion.ts`. The look is the
|
|
84
|
+
same: each token holds the value it replaced.
|
|
85
|
+
- `tests/unit/design-values.test.ts` enforces those rules: a literal design value
|
|
86
|
+
in a stylesheet, a literal timing in a script, a number in an inline style, and
|
|
87
|
+
a colour-dependent token outside the colour scheme all fail, naming the line.
|
|
88
|
+
- The footer gives its columns only to the blocks that render, so no empty column
|
|
89
|
+
is left when there are no contact details.
|
|
90
|
+
- The back-to-top button keeps clear of the footer's last line on a phone.
|
|
91
|
+
- A reviewer's name follows the card's direction, so it aligns in Arabic.
|
|
92
|
+
|
|
93
|
+
## 0.2.1 — 2026-11-04
|
|
94
|
+
|
|
95
|
+
- Writes the command's `bin` entry as 0.1.0 did (`bin/…`, without `./`).
|
|
96
|
+
npm warned on publish about the `./` form; 0.2.0 installs and runs
|
|
97
|
+
correctly, and so does 0.2.1.
|
|
98
|
+
|
|
99
|
+
## 0.2.0 — 2026-11-04
|
|
100
|
+
|
|
101
|
+
Three agent skills, now final, for building a theme with an agent.
|
|
102
|
+
|
|
103
|
+
- `wocart-theme-from-screenshot`: the route from a screenshot, a design image
|
|
104
|
+
or a live website URL to a running theme on a store, native on phones. It
|
|
105
|
+
has the brief an agent needs, defaults for every unanswered question, the
|
|
106
|
+
never-drift rules, gates per step, the premium bar, how to run unattended
|
|
107
|
+
(commit per gate, bounded compare rounds, a fixed final report) and a
|
|
108
|
+
kickoff message.
|
|
109
|
+
- `wocart-theme-from-design`: reading a design, the design system, mapping
|
|
110
|
+
sections, content and claims; now points to the route for whole themes.
|
|
111
|
+
- `wocart-docs`: where to find each SDK answer; lists the cases that stop a
|
|
112
|
+
build.
|
|
113
|
+
- `AGENTS.md` routes each request to the right skill.
|
|
114
|
+
- The generated code is unchanged from 0.1.0.
|
|
115
|
+
|
|
116
|
+
## 0.1.0 — 2026-11-03
|
|
117
|
+
|
|
118
|
+
The first version, for Wocart's own themes.
|
|
119
|
+
|
|
120
|
+
- The `default` template on `@wocart/storefront` 3.1.0 and `@wocart/theme`
|
|
121
|
+
4.1.0, for platform v7.0.0 or newer: every page type, product and basket
|
|
122
|
+
checkout with the phone check and codes, Studio preview and revalidation,
|
|
123
|
+
Arabic, French and English.
|
|
124
|
+
- Every theme is whole: it builds for Cloudflare Workers and Vercel and
|
|
125
|
+
carries every platform feature, each shown when the store turns it on.
|
|
126
|
+
- Options: `--name`, `--key`, `--no-install`, `--git`, `--yes`, `--force`,
|
|
127
|
+
`--template`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-wocart-theme
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create a Wocart storefront theme: an Astro project that sells cash on
|
|
4
|
+
delivery in Algeria, in Arabic, French and English, on
|
|
5
|
+
[`@wocart/storefront`](https://docs.wocart.store/sdk/storefront) and
|
|
6
|
+
[`@wocart/theme`](https://docs.wocart.store/sdk/theme). It renders every page
|
|
7
|
+
a Wocart store has, takes orders (product form and basket, phone check,
|
|
8
|
+
codes, reviews), builds for both Cloudflare Workers and Vercel, and is ready
|
|
9
|
+
for Wocart Studio. Every theme it creates is whole, so Wocart Cloud can
|
|
10
|
+
deploy it on whichever host a merchant picks. It looks deliberately plain: the
|
|
11
|
+
brand lives in one file.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm create wocart-theme@latest my-theme
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Also `pnpm create wocart-theme`, `yarn create wocart-theme` or
|
|
18
|
+
`bun create wocart-theme`: the project installs with the manager you use.
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Node.js 22.12 or newer.
|
|
23
|
+
- A Wocart store to read (its API address and a store API key) on platform
|
|
24
|
+
v9.0.0 or newer.
|
|
25
|
+
|
|
26
|
+
## Options
|
|
27
|
+
|
|
28
|
+
| Option | What it does |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `[dir]` | Where the theme goes (asked when missing) |
|
|
31
|
+
| `--name <name>` | Package name; the directory's name by default |
|
|
32
|
+
| `--key <key>` | Theme key; from the name by default. **Permanent** once a store edits the theme: the platform keeps merchants' edits under it |
|
|
33
|
+
| `--no-install` | Write the files, install nothing |
|
|
34
|
+
| `--git` | Run `git init` in the project |
|
|
35
|
+
| `--yes`, `-y` | Ask nothing; take every default |
|
|
36
|
+
| `--force` | Write into a non-empty directory; an existing file is never overwritten |
|
|
37
|
+
| `--template <name>` | The template to start from (`default`) |
|
|
38
|
+
| `--help`, `--version` | |
|
|
39
|
+
|
|
40
|
+
The generator asks only in a terminal and never with `--yes`. Pass options
|
|
41
|
+
to `npm create` after `--`:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm create wocart-theme@latest summer-shop -- --key summer-shop --yes
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## What it does, and never does
|
|
48
|
+
|
|
49
|
+
It copies the template and stamps the project with its package name, theme
|
|
50
|
+
key, Worker name and README title. The `wocart` field in the new `package.json` records the template, this
|
|
51
|
+
generator's version and the platform the project needs.
|
|
52
|
+
|
|
53
|
+
It never deletes a file, never writes outside the new directory, never
|
|
54
|
+
overwrites a file, reaches the network only through your package manager's
|
|
55
|
+
install, and sends no telemetry.
|
|
56
|
+
|
|
57
|
+
## Then
|
|
58
|
+
|
|
59
|
+
The new project's `README.md` and `AGENTS.md` explain everything else: the
|
|
60
|
+
first run, the variables, the project map, restyling, deploying to
|
|
61
|
+
Cloudflare Workers or Vercel, and how Studio support is checked locally.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-abcart-theme",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.10.1",
|
|
4
|
+
"description": "Create an Abcart storefront theme: an Astro project on @abcart/storefront and @abcart/theme, ready for Abcart Studio.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"abcart",
|
|
7
|
+
"create",
|
|
8
|
+
"theme",
|
|
9
|
+
"storefront",
|
|
10
|
+
"ecommerce",
|
|
11
|
+
"astro",
|
|
12
|
+
"starter"
|
|
13
|
+
],
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/abderrahmenbouzaroura/abcart-sdk.git",
|
|
18
|
+
"directory": "packages/create-theme"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"bin": {
|
|
25
|
+
"create-abcart-theme": "bin/create-abcart-theme.mjs"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"bin",
|
|
29
|
+
"src",
|
|
30
|
+
"templates",
|
|
31
|
+
"!templates/*/node_modules",
|
|
32
|
+
"!templates/*/dist",
|
|
33
|
+
"!templates/*/.astro",
|
|
34
|
+
"!templates/*/.wrangler",
|
|
35
|
+
"!templates/*/.vercel",
|
|
36
|
+
"!templates/*/.dev.vars",
|
|
37
|
+
"!templates/*/package-lock.json",
|
|
38
|
+
"README.md",
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"NOTICE"
|
|
42
|
+
],
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22.12.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"test": "echo \"create-abcart-theme tests managed by monorepo root\""
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/args.mjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command line, read and checked without touching the disk: what the
|
|
3
|
+
* developer asked for, and why a value cannot be used.
|
|
4
|
+
*/
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The theme key rule the platform applies: `THEME_KEY_PATTERN` from
|
|
9
|
+
* `@abcart/theme`, copied so the generator runs before anything is installed.
|
|
10
|
+
* A test fails when the two differ.
|
|
11
|
+
*/
|
|
12
|
+
export const THEME_KEY_PATTERN = /^(?=.{1,64}$)[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
13
|
+
/** Keys Wocart's own themes hold: a new theme under one would read their merchants' edits. */
|
|
14
|
+
export const RESERVED_KEYS = ["theme-00", "theme-baby"];
|
|
15
|
+
/** The oldest Node.js the generated project's build tools run on. */
|
|
16
|
+
export const MIN_NODE = [22, 12, 0];
|
|
17
|
+
export const TEMPLATES = ["default"];
|
|
18
|
+
|
|
19
|
+
const OPTIONS = {
|
|
20
|
+
name: { type: "string" },
|
|
21
|
+
key: { type: "string" },
|
|
22
|
+
install: { type: "boolean", default: true },
|
|
23
|
+
git: { type: "boolean", default: false },
|
|
24
|
+
yes: { type: "boolean", short: "y", default: false },
|
|
25
|
+
force: { type: "boolean", default: false },
|
|
26
|
+
template: { type: "string", default: "default" },
|
|
27
|
+
help: { type: "boolean", short: "h", default: false },
|
|
28
|
+
version: { type: "boolean", short: "v", default: false },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** The parsed command line; throws a readable error for an unknown flag. */
|
|
32
|
+
export function parseCliArgs(argv) {
|
|
33
|
+
const { values, positionals } = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true, allowNegative: true, strict: true });
|
|
34
|
+
if (positionals.length > 1) throw new Error(`One directory, please: got ${positionals.join(" ")}`);
|
|
35
|
+
return { dir: positionals[0] ?? null, ...values };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Why a package name cannot be used, or null (npm's rules for a new package). */
|
|
39
|
+
export function packageNameProblem(name) {
|
|
40
|
+
if (!name) return "the package name is empty";
|
|
41
|
+
if (name.length > 214) return "a package name is at most 214 characters";
|
|
42
|
+
if (name !== name.toLowerCase()) return "a package name is lowercase";
|
|
43
|
+
if (name.trim() !== name) return "a package name has no spaces around it";
|
|
44
|
+
const bare = name.startsWith("@") ? name.split("/")[1] : name;
|
|
45
|
+
if (name.startsWith("@") && (!bare || name.split("/").length !== 2)) return "a scoped name is @scope/name";
|
|
46
|
+
if (/^[._]/.test(bare)) return "a package name does not start with . or _";
|
|
47
|
+
if (!/^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name)) return "a package name uses only a-z, 0-9, - . _ ~";
|
|
48
|
+
if (["node_modules", "favicon.ico"].includes(bare)) return `"${bare}" is not a package name`;
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Why a theme key cannot be used, or null. */
|
|
53
|
+
export function themeKeyProblem(key) {
|
|
54
|
+
if (!key) return "the theme key is empty";
|
|
55
|
+
if (!THEME_KEY_PATTERN.test(key)) return "a theme key is lowercase words joined by single dashes, starting with a letter, at most 64 characters (my-theme)";
|
|
56
|
+
if (RESERVED_KEYS.includes(key)) return `"${key}" is the key of a Wocart theme; pick your own`;
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Why this Node.js cannot build the project, or null. */
|
|
61
|
+
export function nodeProblem(version = process.versions.node) {
|
|
62
|
+
const parts = version.split(".").map(Number);
|
|
63
|
+
for (let i = 0; i < 3; i++) {
|
|
64
|
+
if (parts[i] > MIN_NODE[i]) return null;
|
|
65
|
+
if (parts[i] < MIN_NODE[i]) return `Node.js ${MIN_NODE.join(".")} or newer is needed; this is ${version}`;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A package name from a directory name: lowercase, npm-safe. */
|
|
71
|
+
export function nameFromDir(dir) {
|
|
72
|
+
return dir
|
|
73
|
+
.split(/[\\/]/)
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.pop()
|
|
76
|
+
.toLowerCase()
|
|
77
|
+
.replace(/[^a-z0-9-._~]+/g, "-")
|
|
78
|
+
.replace(/^[-._]+|-+$/g, "")
|
|
79
|
+
.slice(0, 214)
|
|
80
|
+
.replace(/[-._]+$/, "") || "my-wocart-theme";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A theme key from a package name: the name without its scope, as kebab-case. */
|
|
84
|
+
export function keyFromName(name) {
|
|
85
|
+
const key = name
|
|
86
|
+
.replace(/^@[^/]+\//, "")
|
|
87
|
+
.toLowerCase()
|
|
88
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
89
|
+
.replace(/^[^a-z]+|-+$/g, "")
|
|
90
|
+
.slice(0, 64)
|
|
91
|
+
.replace(/-+$/, "");
|
|
92
|
+
return key || "my-theme";
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A title for the README from a theme key: "summer-shop" → "Summer Shop". */
|
|
96
|
+
export function titleFromKey(key) {
|
|
97
|
+
return key
|
|
98
|
+
.split("-")
|
|
99
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
100
|
+
.join(" ");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A Cloudflare Worker name from a package name: lowercase letters, digits and dashes, at most 63. */
|
|
104
|
+
export function workerNameFromName(name) {
|
|
105
|
+
return (
|
|
106
|
+
name
|
|
107
|
+
.replace(/^@[^/]+\//, "")
|
|
108
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
109
|
+
.replace(/^-+|-+$/g, "")
|
|
110
|
+
.slice(0, 63)
|
|
111
|
+
.replace(/-+$/, "") || "my-wocart-theme"
|
|
112
|
+
);
|
|
113
|
+
}
|
package/src/banner.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Wocart wordmark for the terminal: figlet's ANSI Shadow font, drawn once
|
|
3
|
+
* here so the generator needs no font package.
|
|
4
|
+
*/
|
|
5
|
+
const WORDMARK = [
|
|
6
|
+
"██╗ ██╗ ██████╗ ██████╗ █████╗ ██████╗ ████████╗",
|
|
7
|
+
"██║ ██║██╔═══██╗██╔════╝██╔══██╗██╔══██╗╚══██╔══╝",
|
|
8
|
+
"██║ █╗ ██║██║ ██║██║ ███████║██████╔╝ ██║ ",
|
|
9
|
+
"██║███╗██║██║ ██║██║ ██╔══██║██╔══██╗ ██║ ",
|
|
10
|
+
"╚███╔███╔╝╚██████╔╝╚██████╗██║ ██║██║ ██║ ██║ ",
|
|
11
|
+
" ╚══╝╚══╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ",
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
/** The banner's lines: the wordmark in the brand colour, then the product line and the version. */
|
|
15
|
+
export function bannerLines(style, version) {
|
|
16
|
+
return [
|
|
17
|
+
...WORDMARK.map((line) => ` ${style.brand(line.trimEnd())}`),
|
|
18
|
+
"",
|
|
19
|
+
` ${style.bold("Create an Abcart storefront theme")} ${style.dim(`v${version}`)}`,
|
|
20
|
+
];
|
|
21
|
+
}
|