create-abcart-theme 0.0.0-stage → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/src/cli.mjs
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `npm create wocart-theme`: asks what it needs (only in a terminal, never
|
|
3
|
+
* with --yes), writes the project, installs it with the manager that ran
|
|
4
|
+
* this, and says what to do next. No network but the install, no telemetry.
|
|
5
|
+
*/
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
+
import { basename, resolve } from "node:path";
|
|
9
|
+
import { createInterface } from "node:readline/promises";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { TEMPLATES, keyFromName, nameFromDir, nodeProblem, packageNameProblem, parseCliArgs, themeKeyProblem } from "./args.mjs";
|
|
12
|
+
import { MIN_PLATFORM, planProject, targetProblem, writeProject } from "./create.mjs";
|
|
13
|
+
import { detectPackageManager, runCommand } from "./package-manager.mjs";
|
|
14
|
+
import { bannerLines } from "./banner.mjs";
|
|
15
|
+
import { styler } from "./style.mjs";
|
|
16
|
+
|
|
17
|
+
const PACKAGE = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8"));
|
|
18
|
+
const templateDir = (name) => fileURLToPath(new URL(`../templates/${name}/`, import.meta.url));
|
|
19
|
+
|
|
20
|
+
export const HELP = `Create an Abcart storefront theme.
|
|
21
|
+
|
|
22
|
+
Usage: npm create abcart-theme@latest [dir] [-- options]
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--name <name> package name (default: the directory's name)
|
|
26
|
+
--key <key> theme key, permanent once a store edits the theme (default: from the name)
|
|
27
|
+
--no-install write the files, install nothing
|
|
28
|
+
--git run git init in the new project
|
|
29
|
+
--yes, -y ask nothing; take every default
|
|
30
|
+
--force write into a non-empty directory (never over an existing file)
|
|
31
|
+
--template <name> template to start from (${TEMPLATES.join(", ")})
|
|
32
|
+
--help, -h this help
|
|
33
|
+
--version, -v the generator's version
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
/** Runs the generator; returns the exit code. `io` carries the streams and environment, so tests drive it. */
|
|
37
|
+
export async function main(argv, io = { stdin: process.stdin, stdout: process.stdout, stderr: process.stderr, env: process.env, cwd: process.cwd() }) {
|
|
38
|
+
const out = (text = "") => io.stdout.write(`${text}\n`);
|
|
39
|
+
const fail = (text) => {
|
|
40
|
+
io.stderr.write(`✖ ${text}\n`);
|
|
41
|
+
return 1;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
let args;
|
|
45
|
+
try {
|
|
46
|
+
args = parseCliArgs(argv);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return fail(`${error.message}\n\n${HELP}`);
|
|
49
|
+
}
|
|
50
|
+
if (args.help) return out(HELP), 0;
|
|
51
|
+
if (args.version) return out(PACKAGE.version), 0;
|
|
52
|
+
const node = nodeProblem();
|
|
53
|
+
if (node) return fail(node);
|
|
54
|
+
if (!TEMPLATES.includes(args.template)) return fail(`unknown template "${args.template}"; there is ${TEMPLATES.join(", ")}`);
|
|
55
|
+
|
|
56
|
+
const style = styler(io.stdout, io.env);
|
|
57
|
+
if (io.stdout.isTTY) for (const line of bannerLines(style, PACKAGE.version)) out(line);
|
|
58
|
+
|
|
59
|
+
const interactive = Boolean(io.stdin.isTTY) && !args.yes;
|
|
60
|
+
const prompt = interactive ? createInterface({ input: io.stdin, output: io.stdout }) : null;
|
|
61
|
+
const ask = async (question, fallback, problem = () => null) => {
|
|
62
|
+
if (!prompt) return fallback;
|
|
63
|
+
for (;;) {
|
|
64
|
+
const answer = (await prompt.question(`${question} (${fallback}) `)).trim() || fallback;
|
|
65
|
+
const why = problem(answer);
|
|
66
|
+
if (!why) return answer;
|
|
67
|
+
out(` ${why}`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const dir = args.dir ?? (await ask("Where should the theme go?", "my-wocart-theme"));
|
|
73
|
+
const targetDir = resolve(io.cwd, dir);
|
|
74
|
+
const name = args.name ?? (await ask("Package name?", nameFromDir(basename(targetDir)), packageNameProblem));
|
|
75
|
+
const nameWhy = packageNameProblem(name);
|
|
76
|
+
if (nameWhy) return fail(`--name: ${nameWhy}`);
|
|
77
|
+
const key = args.key ?? (await ask("Theme key? It is permanent once a store edits the theme.", keyFromName(name), themeKeyProblem));
|
|
78
|
+
const keyWhy = themeKeyProblem(key);
|
|
79
|
+
if (keyWhy) return fail(`--key: ${keyWhy}`);
|
|
80
|
+
prompt?.close();
|
|
81
|
+
|
|
82
|
+
const manager = detectPackageManager(io.env.npm_config_user_agent);
|
|
83
|
+
const planned = planProject(templateDir(args.template), { name, key, generatorVersion: PACKAGE.version, packageManager: manager, template: args.template });
|
|
84
|
+
const problem = targetProblem(targetDir, planned, { force: args.force });
|
|
85
|
+
if (problem) return fail(problem);
|
|
86
|
+
writeProject(targetDir, planned);
|
|
87
|
+
|
|
88
|
+
const pkg = JSON.parse(readFileSync(resolve(targetDir, "package.json"), "utf8"));
|
|
89
|
+
const sdks = `@abcart/storefront ${pkg.dependencies["@abcart/storefront"]} + @abcart/theme ${pkg.dependencies["@abcart/theme"]}`;
|
|
90
|
+
out(`${style.brand("✔")} Created ${name} (theme key: ${key}) on ${sdks}`);
|
|
91
|
+
out(" Builds for Cloudflare Workers and Vercel; every platform feature included.");
|
|
92
|
+
out(` Needs a Wocart store on platform v${MIN_PLATFORM} or newer.`);
|
|
93
|
+
|
|
94
|
+
let installed = !args.install;
|
|
95
|
+
if (args.install) {
|
|
96
|
+
out(`\nInstalling with ${manager}…`);
|
|
97
|
+
installed = spawnSync(manager, ["install"], { cwd: targetDir, stdio: "inherit", shell: process.platform === "win32" }).status === 0;
|
|
98
|
+
if (!installed) io.stderr.write(`\n✖ ${manager} install failed; run it again in ${dir} when you are ready.\n`);
|
|
99
|
+
}
|
|
100
|
+
if (args.git && !existsSync(resolve(targetDir, ".git"))) {
|
|
101
|
+
const git = spawnSync("git", ["init", "--quiet"], { cwd: targetDir, stdio: "inherit" });
|
|
102
|
+
out(git.status === 0 ? `${style.brand("✔")} git init` : "✖ git init failed; the project is there all the same");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
out(`\n${style.bold("Next:")}`);
|
|
106
|
+
out(` cd ${dir}`);
|
|
107
|
+
if (!args.install || !installed) out(` ${manager} install`);
|
|
108
|
+
out(" cp .dev.vars.example .dev.vars # set COD_SERVER_URL and STORE_API_KEY");
|
|
109
|
+
out(` ${runCommand(manager, "dev")}${" ".repeat(Math.max(1, 35 - runCommand(manager, "dev").length))}# http://localhost:4321`);
|
|
110
|
+
out(`\n${style.bold("Before you deploy:")}`);
|
|
111
|
+
out(` ${runCommand(manager, "check")} && ${runCommand(manager, "test")} && ${runCommand(manager, "build")}`);
|
|
112
|
+
out(` The theme key "${key}" is permanent once a store edits its text.`);
|
|
113
|
+
out("\nDocs: https://docs.wocart.store/sdk/theme");
|
|
114
|
+
return 0;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
prompt?.close();
|
|
117
|
+
return fail(error.message);
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/create.mjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A new theme from the template: every file copied, and the project stamped
|
|
3
|
+
* with its own name and key. Every theme is whole: both hosts and every
|
|
4
|
+
* platform feature. Writes only inside the target, never over a file that is
|
|
5
|
+
* already there, and deletes nothing.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
9
|
+
import { titleFromKey, workerNameFromName } from "./args.mjs";
|
|
10
|
+
import { withOverrides } from "./package-manager.mjs";
|
|
11
|
+
|
|
12
|
+
/** Never copied: what a maintainer's working copy of the template makes. */
|
|
13
|
+
const LEFT_OUT = new Set(["node_modules", "dist", ".astro", ".wrangler", ".vercel", ".dev.vars", "package-lock.json", ".DS_Store"]);
|
|
14
|
+
/** The files a stamp goes into; everything else is copied as it is. */
|
|
15
|
+
const STAMPED = new Set(["package.json", "src/theme/key.ts", "wrangler.jsonc", "README.md"]);
|
|
16
|
+
/** Published under another name: npm drops a `.gitignore` from every package. */
|
|
17
|
+
const RENAMED = { _gitignore: ".gitignore" };
|
|
18
|
+
|
|
19
|
+
/** The platform the template's SDK pair needs (`@abcart/storefront` 4.1.0 requires platform v9.0.0). */
|
|
20
|
+
export const MIN_PLATFORM = "9.0.0";
|
|
21
|
+
|
|
22
|
+
function walk(dir, root = dir) {
|
|
23
|
+
return readdirSync(dir)
|
|
24
|
+
.filter((name) => !LEFT_OUT.has(name))
|
|
25
|
+
.flatMap((name) => {
|
|
26
|
+
const full = join(dir, name);
|
|
27
|
+
return statSync(full).isDirectory() ? walk(full, root) : [relative(root, full).split(sep).join("/")];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const target = (path) => path.split("/").map((part) => RENAMED[part] ?? part).join("/");
|
|
32
|
+
|
|
33
|
+
/** Replaces one placeholder that must appear exactly once: a template that drifted fails here, not in a project. */
|
|
34
|
+
function stamp(text, file, from, to) {
|
|
35
|
+
const count = text.split(from).length - 1;
|
|
36
|
+
if (count !== 1) throw new Error(`template ${file}: expected "${from}" once, found it ${count} times`);
|
|
37
|
+
return text.replace(from, to);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The files the project gets, as `{ path, content }`, without writing them.
|
|
42
|
+
* `options`: `name`, `key`, `generatorVersion`, `packageManager`, `template`.
|
|
43
|
+
*/
|
|
44
|
+
export function planProject(templateDir, options) {
|
|
45
|
+
const { name, key, generatorVersion, packageManager = "npm" } = options;
|
|
46
|
+
return walk(templateDir).map((path) => {
|
|
47
|
+
if (!STAMPED.has(path)) return { path: target(path), content: readFileSync(join(templateDir, path)) };
|
|
48
|
+
let text = readFileSync(join(templateDir, path), "utf8");
|
|
49
|
+
if (path === "package.json") {
|
|
50
|
+
const pkg = withOverrides(JSON.parse(text), packageManager);
|
|
51
|
+
text = `${JSON.stringify({ ...pkg, name, version: "0.1.0", wocart: { template: options.template ?? "default", generator: generatorVersion, platform: `>=${MIN_PLATFORM}` } }, null, 2)}\n`;
|
|
52
|
+
}
|
|
53
|
+
if (path === "src/theme/key.ts") text = stamp(text, path, 'export const THEME_KEY = "my-theme";', `export const THEME_KEY = "${key}";`);
|
|
54
|
+
if (path === "wrangler.jsonc") text = stamp(text, path, '"name": "my-wocart-theme"', `"name": "${workerNameFromName(name)}"`);
|
|
55
|
+
if (path === "README.md") text = stamp(text, path, "# My Theme\n", `# ${titleFromKey(key)}\n`);
|
|
56
|
+
return { path: target(path), content: text };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Why the project cannot be written to `targetDir`, or null. */
|
|
61
|
+
export function targetProblem(targetDir, planned, { force = false } = {}) {
|
|
62
|
+
if (!existsSync(targetDir)) return null;
|
|
63
|
+
if (!statSync(targetDir).isDirectory()) return `${targetDir} is a file`;
|
|
64
|
+
const present = readdirSync(targetDir).filter((name) => name !== ".DS_Store");
|
|
65
|
+
if (present.length === 0) return null;
|
|
66
|
+
if (!force) return `${targetDir} is not empty (pass --force to add the theme beside what is there)`;
|
|
67
|
+
const collisions = planned.filter(({ path }) => existsSync(join(targetDir, path))).map(({ path }) => path);
|
|
68
|
+
return collisions.length > 0 ? `${targetDir} already has ${collisions.slice(0, 5).join(", ")}${collisions.length > 5 ? ` and ${collisions.length - 5} more` : ""}; nothing is overwritten` : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Writes the planned files under `targetDir`; every path is checked to stay inside it. */
|
|
72
|
+
export function writeProject(targetDir, planned) {
|
|
73
|
+
const root = resolve(targetDir);
|
|
74
|
+
for (const { path, content } of planned) {
|
|
75
|
+
const file = resolve(root, path);
|
|
76
|
+
if (!file.startsWith(root + sep)) throw new Error(`refusing to write outside ${root}: ${path}`);
|
|
77
|
+
if (existsSync(file)) throw new Error(`refusing to overwrite ${file}`);
|
|
78
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
79
|
+
writeFileSync(file, content);
|
|
80
|
+
}
|
|
81
|
+
return planned.map(({ path }) => path);
|
|
82
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package manager that ran the generator (`npm create`, `pnpm create`,
|
|
3
|
+
* `yarn create`, `bun create`), so the project installs and runs with it.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const MANAGERS = ["npm", "pnpm", "yarn", "bun"];
|
|
7
|
+
|
|
8
|
+
/** The manager named by `npm_config_user_agent` ("pnpm/9.12.0 npm/? node/v22…"), npm when unknown. */
|
|
9
|
+
export function detectPackageManager(userAgent = process.env.npm_config_user_agent ?? "") {
|
|
10
|
+
const name = userAgent.split(" ")[0]?.split("/")[0];
|
|
11
|
+
return MANAGERS.includes(name) ? name : "npm";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** How to run a package.json script with a manager. */
|
|
15
|
+
export function runCommand(manager, script) {
|
|
16
|
+
if (manager === "npm") return script === "test" ? "npm test" : `npm run ${script}`;
|
|
17
|
+
return `${manager} ${script === "test" ? "test" : `run ${script}`}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The template's `overrides` in the manager's own field: npm and bun read
|
|
22
|
+
* `overrides`, pnpm `pnpm.overrides`, yarn `resolutions`. They pin what the
|
|
23
|
+
* build depends on (Vite's major for Astro and Vitest), so every manager
|
|
24
|
+
* must see them.
|
|
25
|
+
*/
|
|
26
|
+
export function withOverrides(pkg, manager) {
|
|
27
|
+
const overrides = pkg.overrides;
|
|
28
|
+
if (!overrides) return pkg;
|
|
29
|
+
if (manager === "pnpm") return { ...pkg, pnpm: { ...pkg.pnpm, overrides: { ...pkg.pnpm?.overrides, ...overrides } } };
|
|
30
|
+
if (manager === "yarn") return { ...pkg, resolutions: { ...pkg.resolutions, ...overrides } };
|
|
31
|
+
return pkg;
|
|
32
|
+
}
|
package/src/style.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal colour for the generator's own output. Colour is used only when the
|
|
3
|
+
* output is a terminal and NO_COLOR is not set to a non-empty value (no-color.org);
|
|
4
|
+
* a dumb terminal gets plain text. Plain output is the same text without codes.
|
|
5
|
+
*/
|
|
6
|
+
const BRAND = [101, 33, 238];
|
|
7
|
+
|
|
8
|
+
export function styler(stream, env = {}) {
|
|
9
|
+
const on = Boolean(stream.isTTY) && !env.NO_COLOR && env.TERM !== "dumb";
|
|
10
|
+
const wrap = (open, close) => (text) => (on ? `\x1b[${open}m${text}\x1b[${close}m` : text);
|
|
11
|
+
return {
|
|
12
|
+
on,
|
|
13
|
+
brand: wrap(`38;2;${BRAND.join(";")}`, "39"),
|
|
14
|
+
bold: wrap("1", "22"),
|
|
15
|
+
dim: wrap("2", "22"),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shopify-theme-asset-collector
|
|
3
|
+
description: Find the public demo domain for a Shopify Theme Store URL, collect the storefront's public HTML, CSS, JavaScript, fonts, SVGs, and images, organize assets by page and homepage section, and save the result as a manifest and ZIP archive. Use from any AI coding agent, terminal, or VS Code workflow.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Shopify theme asset collector
|
|
7
|
+
|
|
8
|
+
## Goal
|
|
9
|
+
|
|
10
|
+
Given a Shopify Theme Store URL or a public Shopify storefront URL, find the demo storefront, collect the public frontend assets it uses, and save a clean, organized archive. The archive is a **reference for measuring a design**. It feeds `wocart-theme-from-design`, which rebuilds the design on the Wocart starter.
|
|
11
|
+
|
|
12
|
+
## Rights
|
|
13
|
+
|
|
14
|
+
The collected files belong to the theme's author. Use them to measure and to understand the structure, and then write the new theme's own code and tokens.
|
|
15
|
+
|
|
16
|
+
- Do not ship the collected CSS, JavaScript, fonts, images, logos or text in a theme, in a repository, or on a store.
|
|
17
|
+
- A font ships only under its own open licence, self-hosted, with its licence line.
|
|
18
|
+
- Photos and words of a site are taken only if the developer says they own them, and only into test data.
|
|
19
|
+
- Use the collector on public pages only. It obeys the site's robots.txt, and it never disables certificate checks.
|
|
20
|
+
|
|
21
|
+
If the developer's goal is to sell a copy of a paid Shopify theme, stop and say so. A theme that looks like the reference, with its own code and tokens, is what this process is for.
|
|
22
|
+
|
|
23
|
+
## Steps
|
|
24
|
+
|
|
25
|
+
### 1. Find the demo storefront URL
|
|
26
|
+
|
|
27
|
+
If the input is already a storefront URL such as `https://example.myshopify.com`, use it directly.
|
|
28
|
+
|
|
29
|
+
If the input is a Shopify Theme Store URL:
|
|
30
|
+
|
|
31
|
+
- Open the page in a browser, Playwright, Selenium, or another browser automation tool.
|
|
32
|
+
- Activate or wait for **View demo**.
|
|
33
|
+
- Inspect the page for an iframe with a source URL. Useful selectors:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
document.querySelector('iframe[data-demo-store-target="iframe"]')?.src
|
|
37
|
+
[...document.querySelectorAll('iframe')].map(x => x.src)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- Choose the public storefront URL, normally ending in `myshopify.com`.
|
|
41
|
+
- Open the candidate URL and verify that its title, logo, preset, or content matches the requested theme.
|
|
42
|
+
|
|
43
|
+
For terminal-only work, use Playwright or Selenium if available. If the Theme Store page does not render in a static HTTP request, use a browser session to read the iframe source. Do not guess the domain.
|
|
44
|
+
|
|
45
|
+
### 2. Map pages and sections
|
|
46
|
+
|
|
47
|
+
Start with the homepage `/`. Note its final URL and title. Collect additional public pages when they are useful for the design: collections, products, blog, and theme-feature pages.
|
|
48
|
+
|
|
49
|
+
For each page, the collector records the page URL and path, its title, its navigation links, and its homepage section order. Each homepage section is a `div` whose `id` starts with `shopify-section-`. The section's order and heading give the names used in the manifest, such as `01 · Hero`, `02 · Featured products`.
|
|
50
|
+
|
|
51
|
+
### 3. Collect public resources
|
|
52
|
+
|
|
53
|
+
For each page, the collector downloads every public resource that the rendered HTML and its stylesheets reference:
|
|
54
|
+
|
|
55
|
+
- HTML source;
|
|
56
|
+
- stylesheets (`<link rel="stylesheet">`), and the fonts and images they reference through `url(...)` and `@import`;
|
|
57
|
+
- JavaScript files;
|
|
58
|
+
- images from `img`, `picture`, `source`, `srcset`, Open Graph tags, preload tags, `video` posters and inline styles;
|
|
59
|
+
- SVGs, icons, favicons and logos;
|
|
60
|
+
- fonts referenced by CSS.
|
|
61
|
+
|
|
62
|
+
Each file is stored once, in the assets folder, and the manifest records every page and section that uses it.
|
|
63
|
+
|
|
64
|
+
### 4. Run the bundled collector
|
|
65
|
+
|
|
66
|
+
Python 3.9 or later, standard library only. From the project root:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
python3 .agents/skills/shopify-theme-asset-collector/scripts/collect_public_assets.py \
|
|
70
|
+
https://example.myshopify.com/ \
|
|
71
|
+
https://example.myshopify.com/collections/all \
|
|
72
|
+
--out ./example-theme-assets --zip
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The first URL should be the homepage. The collector writes:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
example-theme-assets/
|
|
79
|
+
├── manifest.json every page, homepage section, resource and failure
|
|
80
|
+
├── README.txt the rights reminder
|
|
81
|
+
├── pages/
|
|
82
|
+
│ ├── home/source.html
|
|
83
|
+
│ └── collections-all/source.html
|
|
84
|
+
└── assets/
|
|
85
|
+
├── css/
|
|
86
|
+
├── js/
|
|
87
|
+
├── images/
|
|
88
|
+
├── fonts/
|
|
89
|
+
└── svg/
|
|
90
|
+
example-theme-assets.zip with --zip
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Each homepage section in `manifest.json` lists its heading and the URLs of the resources it uses. A resource lists the pages and sections that use it. A resource that could not be downloaded is listed under `failures` with its reason. A path that robots.txt disallows is skipped and reported.
|
|
94
|
+
|
|
95
|
+
### 5. Review, then hand off
|
|
96
|
+
|
|
97
|
+
Read `manifest.json`:
|
|
98
|
+
|
|
99
|
+
- `homepage_sections`: the order and the headings, to map the design's sections;
|
|
100
|
+
- `downloaded_by_kind`: the counts of stylesheets, scripts, images, fonts and SVGs;
|
|
101
|
+
- `failures`: each one's reason. A failed photo is a missing measurement; say so.
|
|
102
|
+
|
|
103
|
+
Then hand the folder to `wocart-theme-from-design`, step 1 ("From a Shopify theme"). That skill measures the design and builds the theme's own tokens and sections. It does not copy these files.
|
|
104
|
+
|
|
105
|
+
## Useful Shopify asset paths
|
|
106
|
+
|
|
107
|
+
Theme code assets commonly appear under:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
https://store.myshopify.com/cdn/shop/t/<theme-version>/assets/
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Store-uploaded images commonly appear under:
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
https://store.myshopify.com/cdn/shop/files/
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Typical style files have names such as critical.css, component-hero.css or section-rich-text.css. Confirm the filenames that the page actually loads instead of relying on these names.
|
|
120
|
+
|
|
121
|
+
## Result
|
|
122
|
+
|
|
123
|
+
Report: the demo domain found, the pages collected, the counts of HTML, CSS, JavaScript, image and font files, the failed downloads and their reasons, the output folder, and the ZIP path.
|
|
124
|
+
|
|
125
|
+
This skill collects the public rendered frontend and its public assets. It does not produce the store's private Liquid templates or its theme-editor settings, because those are not publicly served.
|