@wix/agent-skills 1.0.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/LICENSE +21 -0
- package/README.md +111 -0
- package/package.json +29 -0
- package/skills/wix-app/SKILL.md +344 -0
- package/skills/wix-app/references/APP_IDENTIFIERS.md +35 -0
- package/skills/wix-app/references/APP_MARKET_REVIEW.md +311 -0
- package/skills/wix-app/references/APP_VALIDATION.md +171 -0
- package/skills/wix-app/references/BACKEND_API.md +233 -0
- package/skills/wix-app/references/BACKEND_EVENT.md +116 -0
- package/skills/wix-app/references/CODE_QUALITY.md +33 -0
- package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +587 -0
- package/skills/wix-app/references/DASHBOARD_MENU_PLUGIN.md +157 -0
- package/skills/wix-app/references/DASHBOARD_MODAL.md +283 -0
- package/skills/wix-app/references/DASHBOARD_PAGE.md +403 -0
- package/skills/wix-app/references/DASHBOARD_PLUGIN.md +205 -0
- package/skills/wix-app/references/DATA_COLLECTION.md +451 -0
- package/skills/wix-app/references/DOCUMENTATION.md +42 -0
- package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +65 -0
- package/skills/wix-app/references/EMBEDDED_SCRIPT.md +468 -0
- package/skills/wix-app/references/EXTENSION_REGISTRATION.md +96 -0
- package/skills/wix-app/references/SERVICE_PLUGIN.md +235 -0
- package/skills/wix-app/references/SITE_PLUGIN.md +436 -0
- package/skills/wix-app/references/STORES_VERSIONING.md +334 -0
- package/skills/wix-app/references/backend-event/COMMON-EVENTS.md +84 -0
- package/skills/wix-app/references/custom-element-widget/SETTINGS_PANEL.md +345 -0
- package/skills/wix-app/references/dashboard-menu-plugin/blog-slots.md +71 -0
- package/skills/wix-app/references/dashboard-menu-plugin/bookings-slots.md +58 -0
- package/skills/wix-app/references/dashboard-menu-plugin/crm-slots.md +8 -0
- package/skills/wix-app/references/dashboard-menu-plugin/ecommerce-slots.md +17 -0
- package/skills/wix-app/references/dashboard-menu-plugin/events-slots.md +29 -0
- package/skills/wix-app/references/dashboard-menu-plugin/restaurants-slots.md +27 -0
- package/skills/wix-app/references/dashboard-menu-plugin/stores-slots.md +35 -0
- package/skills/wix-app/references/dashboard-page/API_SPEC.md +138 -0
- package/skills/wix-app/references/dashboard-page/DASHBOARD_API.md +573 -0
- package/skills/wix-app/references/dashboard-page/DYNAMIC_PARAMETERS.md +269 -0
- package/skills/wix-app/references/dashboard-page/ECOM_NAVIGATION.md +164 -0
- package/skills/wix-app/references/dashboard-plugin/SLOTS.md +294 -0
- package/skills/wix-app/references/data-collection/WIX_DATA.md +270 -0
- package/skills/wix-app/references/data-collection/extension-template.ts +107 -0
- package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +138 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +454 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +165 -0
- package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +576 -0
- package/skills/wix-app/references/editor-react-component/DIRECTIONALITY.md +170 -0
- package/skills/wix-app/references/editor-react-component/EDIT-FLOW.md +6 -0
- package/skills/wix-app/references/editor-react-component/PARTS.md +25 -0
- package/skills/wix-app/references/editor-react-component/PROPS-VS-CSS.md +203 -0
- package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +167 -0
- package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +137 -0
- package/skills/wix-app/references/service-plugin/ADDITIONAL-FEES.md +112 -0
- package/skills/wix-app/references/service-plugin/BOOKINGS-STAFF-SORTING.md +118 -0
- package/skills/wix-app/references/service-plugin/DISCOUNT-TRIGGERS.md +87 -0
- package/skills/wix-app/references/service-plugin/GIFT-CARDS.md +86 -0
- package/skills/wix-app/references/service-plugin/PAYMENT-SETTINGS.md +135 -0
- package/skills/wix-app/references/service-plugin/SHIPPING-RATES.md +79 -0
- package/skills/wix-app/references/service-plugin/VALIDATIONS.md +68 -0
- package/skills/wix-app/references/site-plugin/EXAMPLES.md +311 -0
- package/skills/wix-app/references/site-plugin/SLOTS.md +263 -0
- package/skills/wix-design-system/SKILL.md +129 -0
- package/skills/wix-design-system/references/file-structure.md +56 -0
- package/skills/wix-design-system/scripts/wds.cjs +531 -0
- package/skills/wix-headless/SKILL.md +418 -0
- package/skills/wix-headless/references/DISCOVERY.md +332 -0
- package/skills/wix-headless/references/ORCHESTRATION.md +269 -0
- package/skills/wix-headless/references/SETUP.md +154 -0
- package/skills/wix-headless/references/blog/BLOG_CONTENT.md +152 -0
- package/skills/wix-headless/references/blog/BLOG_PAGES.md +299 -0
- package/skills/wix-headless/references/blog/BLOG_SETUP.md +218 -0
- package/skills/wix-headless/references/blog/INSTRUCTIONS.md +32 -0
- package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +373 -0
- package/skills/wix-headless/references/cms/FAQ_KNOWLEDGE_BASE.md +229 -0
- package/skills/wix-headless/references/cms/INSTRUCTIONS.md +40 -0
- package/skills/wix-headless/references/cms/PORTFOLIO.md +454 -0
- package/skills/wix-headless/references/cms/RESOURCE_LIBRARY.md +356 -0
- package/skills/wix-headless/references/cms/TEAM_DIRECTORY.md +299 -0
- package/skills/wix-headless/references/commands/install-app.md +42 -0
- package/skills/wix-headless/references/commands/known-apps.json +5 -0
- package/skills/wix-headless/references/commands/mcp-bootstrap.md +28 -0
- package/skills/wix-headless/references/designer/INSTRUCTIONS.md +828 -0
- package/skills/wix-headless/references/ecom/CART_PAGES.md +120 -0
- package/skills/wix-headless/references/ecom/CART_WIRING.md +103 -0
- package/skills/wix-headless/references/ecom/COMPONENTS_CSS.md +132 -0
- package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +59 -0
- package/skills/wix-headless/references/forms/CONTACT_FORM.md +477 -0
- package/skills/wix-headless/references/forms/INSTRUCTIONS.md +43 -0
- package/skills/wix-headless/references/gift-cards/COMPONENTS.md +119 -0
- package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +51 -0
- package/skills/wix-headless/references/gift-cards/PAGES.md +129 -0
- package/skills/wix-headless/references/images/INSTRUCTIONS.md +359 -0
- package/skills/wix-headless/references/shared/BUILD_NOISE.md +8 -0
- package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +185 -0
- package/skills/wix-headless/references/shared/IMPLEMENTER.md +155 -0
- package/skills/wix-headless/references/shared/MCP_PREFIX.md +105 -0
- package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +97 -0
- package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +423 -0
- package/skills/wix-headless/references/shared/STYLING.md +117 -0
- package/skills/wix-headless/references/stores/BACK_IN_STOCK.md +178 -0
- package/skills/wix-headless/references/stores/CATEGORY_PAGES.md +86 -0
- package/skills/wix-headless/references/stores/COMPONENTS_CSS.md +129 -0
- package/skills/wix-headless/references/stores/HOME_AND_NAV.md +227 -0
- package/skills/wix-headless/references/stores/INSTRUCTIONS.md +96 -0
- package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +249 -0
- package/skills/wix-headless/references/stores/PRODUCT_PAGES.md +213 -0
- package/skills/wix-headless/references/stores/SHARED_WIRING.md +164 -0
- package/skills/wix-headless/references/verticals/_schema.json +160 -0
- package/skills/wix-headless/references/verticals/_schema.md +185 -0
- package/skills/wix-headless/references/verticals/blog.md +125 -0
- package/skills/wix-headless/references/verticals/cms.md +121 -0
- package/skills/wix-headless/references/verticals/ecom.md +96 -0
- package/skills/wix-headless/references/verticals/forms.md +106 -0
- package/skills/wix-headless/references/verticals/gift-cards.md +121 -0
- package/skills/wix-headless/references/verticals/stores.md +167 -0
- package/skills/wix-headless/scripts/check-manifest.mjs +198 -0
- package/skills/wix-headless/scripts/copy-utility-templates.mjs +153 -0
- package/skills/wix-headless/scripts/emit-design-tokens.mjs +77 -0
- package/skills/wix-headless/scripts/finalize-run-json.mjs +141 -0
- package/skills/wix-headless/scripts/init-site-json.mjs +63 -0
- package/skills/wix-headless/scripts/patch-decorative-slots.mjs +124 -0
- package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +190 -0
- package/skills/wix-headless/scripts/preview.sh +45 -0
- package/skills/wix-headless/scripts/release.sh +73 -0
- package/skills/wix-headless/scripts/scaffold.sh +53 -0
- package/skills/wix-headless/scripts/seed-utilities.sh +55 -0
- package/skills/wix-headless/shared-utilities/analytics.ts +40 -0
- package/skills/wix-headless/shared-utilities/ricos.ts +179 -0
- package/skills/wix-headless/shared-utilities/wix-image.ts +72 -0
- package/skills/wix-headless/templates/ecom/CartBadge.tsx +84 -0
- package/skills/wix-headless/templates/ecom/CartView.tsx +543 -0
- package/skills/wix-headless/templates/ecom/cart.astro +13 -0
- package/skills/wix-headless/templates/ecom/components-ecom.css +215 -0
- package/skills/wix-headless/templates/ecom/discounts.ts +71 -0
- package/skills/wix-headless/templates/ecom/thank-you.astro +24 -0
- package/skills/wix-headless/templates/gift-cards/GiftCardPurchase.tsx +172 -0
- package/skills/wix-headless/templates/gift-cards/_home-teaser-snippet.astro +42 -0
- package/skills/wix-headless/templates/gift-cards/_nav-snippet.astro +11 -0
- package/skills/wix-headless/templates/gift-cards/components-gift-cards.css +219 -0
- package/skills/wix-headless/templates/gift-cards/gift-cards.astro +51 -0
- package/skills/wix-headless/templates/gift-cards/gift-cards.ts +75 -0
- package/skills/wix-headless/templates/stores/AddToCartButton.tsx +77 -0
- package/skills/wix-headless/templates/stores/BackInStockForm.tsx +176 -0
- package/skills/wix-headless/templates/stores/CategoryRail.astro +69 -0
- package/skills/wix-headless/templates/stores/ProductCard.astro +79 -0
- package/skills/wix-headless/templates/stores/ProductPurchase.tsx +397 -0
- package/skills/wix-headless/templates/stores/SeoTags.astro +21 -0
- package/skills/wix-headless/templates/stores/back-in-stock.ts +67 -0
- package/skills/wix-headless/templates/stores/categories.ts +155 -0
- package/skills/wix-headless/templates/stores/category/[slug].astro +130 -0
- package/skills/wix-headless/templates/stores/components-stores.css +295 -0
- package/skills/wix-headless/templates/stores/products/[slug].astro +128 -0
- package/skills/wix-headless/templates/stores/products/index.astro +101 -0
- package/skills/wix-manage/SKILL.md +280 -0
- package/skills/wix-manage/references/app-installation/install-wix-apps.md +155 -0
- package/skills/wix-manage/references/app-installation/list-installed-apps.md +124 -0
- package/skills/wix-manage/references/blog/how-to-create-blog-posts.md +226 -0
- package/skills/wix-manage/references/bookings/booking-service-policy-setup.md +95 -0
- package/skills/wix-manage/references/bookings/booking-system-integration-gaps.md +416 -0
- package/skills/wix-manage/references/bookings/bookings-staff-setup.md +255 -0
- package/skills/wix-manage/references/bookings/create-and-update-booking-services.md +462 -0
- package/skills/wix-manage/references/bookings/end-to-end-booking-flow.md +278 -0
- package/skills/wix-manage/references/bookings/external-calendar-integration.md +258 -0
- package/skills/wix-manage/references/bookings/multi-resource-service-creation.md +231 -0
- package/skills/wix-manage/references/calendar/configure-default-business-hours.md +226 -0
- package/skills/wix-manage/references/cms/cms-data-items-crud.md +422 -0
- package/skills/wix-manage/references/cms/cms-data-operations-extended.md +263 -0
- package/skills/wix-manage/references/cms/cms-ecommerce-catalog-integration.md +136 -0
- package/skills/wix-manage/references/cms/cms-references-and-relationships.md +160 -0
- package/skills/wix-manage/references/cms/cms-schema-management.md +143 -0
- package/skills/wix-manage/references/contacts/bulk-delete-contacts.md +73 -0
- package/skills/wix-manage/references/contacts/bulk-label-and-unlabel-contacts.md +67 -0
- package/skills/wix-manage/references/domains/domain-search-and-purchase.md +434 -0
- package/skills/wix-manage/references/ecommerce/api-recommendation-tracking.md +420 -0
- package/skills/wix-manage/references/ecommerce/flow-add-free-shipping.md +267 -0
- package/skills/wix-manage/references/ecommerce/flow-bundle-and-save.md +290 -0
- package/skills/wix-manage/references/ecommerce/flow-fix-coverage-gaps.md +300 -0
- package/skills/wix-manage/references/ecommerce/flow-optimize-shipping-rates.md +364 -0
- package/skills/wix-manage/references/ecommerce/flow-seasonal-promotion.md +315 -0
- package/skills/wix-manage/references/ecommerce/flow-stock-mover.md +308 -0
- package/skills/wix-manage/references/ecommerce/flow-upsell-boost.md +271 -0
- package/skills/wix-manage/references/ecommerce/goal-clear-inventory.md +118 -0
- package/skills/wix-manage/references/ecommerce/goal-drive-cross-sells.md +122 -0
- package/skills/wix-manage/references/ecommerce/goal-increase-aov.md +132 -0
- package/skills/wix-manage/references/ecommerce/goal-reduce-cart-abandonment.md +148 -0
- package/skills/wix-manage/references/ecommerce/goal-seasonal-revenue.md +146 -0
- package/skills/wix-manage/references/ecommerce/guardrail-discount-conflicts.md +118 -0
- package/skills/wix-manage/references/ecommerce/guardrail-margin-protection.md +88 -0
- package/skills/wix-manage/references/ecommerce/guardrail-rate-pricing-sanity.md +108 -0
- package/skills/wix-manage/references/ecommerce/guardrail-shipping-health.md +124 -0
- package/skills/wix-manage/references/ecommerce/recipe-apply-shipping-recommendations.md +299 -0
- package/skills/wix-manage/references/ecommerce/recommend-ecommerce-strategy.md +582 -0
- package/skills/wix-manage/references/ecommerce/setup-coupons.md +338 -0
- package/skills/wix-manage/references/ecommerce/setup-discount-rules.md +444 -0
- package/skills/wix-manage/references/ecommerce/setup-shipping-rates.md +86 -0
- package/skills/wix-manage/references/ecommerce/setup-shipping-regions.md +56 -0
- package/skills/wix-manage/references/ecommerce/setup-store-pickup-location.md +209 -0
- package/skills/wix-manage/references/ecommerce/skill-graph.md +139 -0
- package/skills/wix-manage/references/ecommerce/troubleshoot-checkout-delivery-dropoff.md +124 -0
- package/skills/wix-manage/references/ecommerce/troubleshoot-discount-not-applying.md +95 -0
- package/skills/wix-manage/references/events/list-events.md +203 -0
- package/skills/wix-manage/references/forms/create-form.md +260 -0
- package/skills/wix-manage/references/get-paid/create-payment-links.md +212 -0
- package/skills/wix-manage/references/get-paid/how-to-setup-wix-payments.md +57 -0
- package/skills/wix-manage/references/get-paid/payment-links-for-bookings.md +101 -0
- package/skills/wix-manage/references/media/upload-media-to-wix.md +216 -0
- package/skills/wix-manage/references/pricing-plans/create-and-update-pricing-plans.md +77 -0
- package/skills/wix-manage/references/pricing-plans/pricing-plans-bookings-integration.md +166 -0
- package/skills/wix-manage/references/restaurants/wix-restaurants-setup.md +336 -0
- package/skills/wix-manage/references/rich-content/ricos-converter-service.md +295 -0
- package/skills/wix-manage/references/site-properties/change-payment-currency-site-properties.md +59 -0
- package/skills/wix-manage/references/sites/create-site-from-template.md +183 -0
- package/skills/wix-manage/references/sites/query-sites.md +125 -0
- package/skills/wix-manage/references/stores/add-store-pages-to-site.md +57 -0
- package/skills/wix-manage/references/stores/bulk-create-products-with-options.md +1041 -0
- package/skills/wix-manage/references/stores/create-product-catalog-v1.md +125 -0
- package/skills/wix-manage/references/stores/create-product-from-image.md +824 -0
- package/skills/wix-manage/references/stores/create-product-with-options-catalog-v3.md +566 -0
- package/skills/wix-manage/references/stores/find-products-query-and-search-catalog-v3.md +194 -0
- package/skills/wix-manage/references/stores/query-products-catalog-v1.md +80 -0
- package/skills/wix-manage/references/stores/setup-online-store-catalog-v3.md +99 -0
- package/skills/wix-manage/references/stores/update-product-pre-order.md +213 -0
- package/skills/wix-manage/references/stores/update-product-with-options.md +318 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WDS Documentation Helper
|
|
5
|
+
*
|
|
6
|
+
* Auto-discovers @wix/design-system in node_modules and provides
|
|
7
|
+
* fast, focused lookups for components, props, examples, and icons.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node <path-to>/wds.cjs search <keyword>
|
|
11
|
+
* node <path-to>/wds.cjs component <Name>
|
|
12
|
+
* node <path-to>/wds.cjs components <Name1> <Name2>...
|
|
13
|
+
* node <path-to>/wds.cjs example <Name> <ExampleName>
|
|
14
|
+
* node <path-to>/wds.cjs testkit <Name> [method]
|
|
15
|
+
* node <path-to>/wds.cjs icons <query>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require("fs");
|
|
19
|
+
const path = require("path");
|
|
20
|
+
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Path discovery
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
function tryEnablePnp() {
|
|
26
|
+
// Yarn Berry PnP projects have no node_modules. Walk up from cwd looking for
|
|
27
|
+
// .pnp.cjs and activate it so require.resolve can see PnP-managed packages.
|
|
28
|
+
let dir = process.cwd();
|
|
29
|
+
while (true) {
|
|
30
|
+
const pnp = path.join(dir, ".pnp.cjs");
|
|
31
|
+
if (fs.existsSync(pnp)) {
|
|
32
|
+
try {
|
|
33
|
+
require(pnp).setup();
|
|
34
|
+
} catch {
|
|
35
|
+
// ignore — fall through to other discovery paths
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const parent = path.dirname(dir);
|
|
40
|
+
if (parent === dir) return;
|
|
41
|
+
dir = parent;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function findDocsDir() {
|
|
46
|
+
tryEnablePnp();
|
|
47
|
+
|
|
48
|
+
// Primary: use Node's module resolver (handles symlinks, pnpm, yarn PnP, etc.)
|
|
49
|
+
try {
|
|
50
|
+
const pkgPath = require.resolve("@wix/design-system/package.json", {
|
|
51
|
+
paths: [process.cwd()],
|
|
52
|
+
});
|
|
53
|
+
const docsDir = path.join(path.dirname(pkgPath), "dist", "docs");
|
|
54
|
+
if (fs.existsSync(docsDir)) return docsDir;
|
|
55
|
+
} catch {
|
|
56
|
+
// resolve failed — fall through to filesystem scan
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Fallback: walk up from cwd looking for node_modules
|
|
60
|
+
let dir = process.cwd();
|
|
61
|
+
while (true) {
|
|
62
|
+
const candidate = path.join(
|
|
63
|
+
dir,
|
|
64
|
+
"node_modules",
|
|
65
|
+
"@wix",
|
|
66
|
+
"design-system",
|
|
67
|
+
"dist",
|
|
68
|
+
"docs"
|
|
69
|
+
);
|
|
70
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
71
|
+
|
|
72
|
+
const parent = path.dirname(dir);
|
|
73
|
+
if (parent === dir) break;
|
|
74
|
+
dir = parent;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function readFile(filePath) {
|
|
81
|
+
try {
|
|
82
|
+
return fs.readFileSync(filePath, "utf8");
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Helpers
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
function escapeRegex(str) {
|
|
93
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function buildTermsPattern(args) {
|
|
97
|
+
// Tolerate both `search foo bar` (separate args) and `search "foo bar"`
|
|
98
|
+
// (single quoted arg). Without the split, a single quoted string becomes a
|
|
99
|
+
// literal-phrase match instead of OR-of-words and silently returns nothing.
|
|
100
|
+
return args
|
|
101
|
+
.flatMap((a) => a.split(/\s+/))
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.map(escapeRegex)
|
|
104
|
+
.join("|");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function validateComponentName(name) {
|
|
108
|
+
if (!/^[A-Za-z0-9]+$/.test(name)) {
|
|
109
|
+
console.error(
|
|
110
|
+
`Invalid component name "${name}". Names may only contain letters and digits.`
|
|
111
|
+
);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Commands
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
function cmdSearch(docsDir, terms) {
|
|
121
|
+
if (terms.length === 0) {
|
|
122
|
+
console.error("Usage: wds.cjs search <keyword> [keyword...]");
|
|
123
|
+
console.error('Example: wds.cjs search form input validation');
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const content = readFile(path.join(docsDir, "components.md"));
|
|
128
|
+
if (!content) {
|
|
129
|
+
console.error("Error: components.md not found");
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const regex = new RegExp(buildTermsPattern(terms), "i");
|
|
134
|
+
const sections = content.split(/^\s*### /m).slice(1);
|
|
135
|
+
const matches = [];
|
|
136
|
+
|
|
137
|
+
for (const section of sections) {
|
|
138
|
+
if (regex.test(section)) {
|
|
139
|
+
const lines = section.split("\n");
|
|
140
|
+
const name = lines[0].trim();
|
|
141
|
+
const descLine = lines.find((l) => l.trimStart().startsWith("- description:"));
|
|
142
|
+
const desc = descLine ? descLine.replace(/.*- description:/, "").trim() : "";
|
|
143
|
+
const doLine = lines.find((l) => l.trimStart().startsWith("- do:"));
|
|
144
|
+
const doText = doLine ? doLine.replace(/.*- do:/, "").trim() : "";
|
|
145
|
+
const dontLine = lines.find((l) => l.trimStart().startsWith("- donts:"));
|
|
146
|
+
const dontText = dontLine ? dontLine.replace(/.*- donts:/, "").trim() : "";
|
|
147
|
+
matches.push({ name, description: desc, do: doText, donts: dontText });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (matches.length === 0) {
|
|
152
|
+
console.log(`No components found matching "${terms.join(" ")}".`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
console.log(`Found ${matches.length} component(s):\n`);
|
|
157
|
+
for (const r of matches) {
|
|
158
|
+
console.log(`### ${r.name}`);
|
|
159
|
+
if (r.description) console.log(` ${r.description}`);
|
|
160
|
+
if (r.do) console.log(` Do: ${r.do}`);
|
|
161
|
+
if (r.donts) console.log(` Don't: ${r.donts}`);
|
|
162
|
+
console.log();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Renders one component's props + examples list. Returns true on success,
|
|
167
|
+
// false if the component wasn't found (so batch callers can keep going).
|
|
168
|
+
function printComponent(docsDir, componentName) {
|
|
169
|
+
validateComponentName(componentName);
|
|
170
|
+
|
|
171
|
+
const componentsDir = path.join(docsDir, "components");
|
|
172
|
+
|
|
173
|
+
// --- Props ---
|
|
174
|
+
const propsPath = path.join(componentsDir, `${componentName}Props.md`);
|
|
175
|
+
const propsContent = readFile(propsPath);
|
|
176
|
+
|
|
177
|
+
if (!propsContent) {
|
|
178
|
+
console.error(
|
|
179
|
+
`Component "${componentName}" not found. Run: wds.cjs search <keyword>`
|
|
180
|
+
);
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const propsLines = propsContent.split("\n");
|
|
185
|
+
const propsLineCount = propsLines.length;
|
|
186
|
+
|
|
187
|
+
console.log(`## ${componentName} Props (${propsLineCount} lines)\n`);
|
|
188
|
+
|
|
189
|
+
if (propsLineCount <= 200) {
|
|
190
|
+
// Small file — include full props
|
|
191
|
+
console.log(propsContent);
|
|
192
|
+
} else {
|
|
193
|
+
// Large file — summarize prop names and types only
|
|
194
|
+
console.log(
|
|
195
|
+
`(Large props file — showing summary. Use grep for specific prop details.)\n`
|
|
196
|
+
);
|
|
197
|
+
for (const line of propsLines) {
|
|
198
|
+
if (line.startsWith("### ")) {
|
|
199
|
+
const propName = line.replace("### ", "").trim();
|
|
200
|
+
// Find the type line (next line starting with "- type:")
|
|
201
|
+
const idx = propsLines.indexOf(line);
|
|
202
|
+
const typeLine = propsLines[idx + 1];
|
|
203
|
+
const type =
|
|
204
|
+
typeLine && typeLine.startsWith("- type:")
|
|
205
|
+
? typeLine.replace("- type:", "").trim()
|
|
206
|
+
: "";
|
|
207
|
+
console.log(` ${propName}: ${type}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// --- Examples list ---
|
|
213
|
+
const examplesPath = path.join(componentsDir, `${componentName}Examples.md`);
|
|
214
|
+
const examplesContent = readFile(examplesPath);
|
|
215
|
+
|
|
216
|
+
if (examplesContent) {
|
|
217
|
+
const exLines = examplesContent.split("\n");
|
|
218
|
+
const examples = [];
|
|
219
|
+
for (let i = 0; i < exLines.length; i++) {
|
|
220
|
+
if (exLines[i].startsWith("### ")) {
|
|
221
|
+
examples.push(exLines[i].replace("### ", "").trim());
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (examples.length > 0) {
|
|
226
|
+
console.log(`\n## Available Examples (${examples.length})\n`);
|
|
227
|
+
for (const ex of examples) {
|
|
228
|
+
console.log(` - ${ex}`);
|
|
229
|
+
}
|
|
230
|
+
console.log(
|
|
231
|
+
`\nGet an example: wds.cjs example ${componentName} "<ExampleName>"`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function cmdComponent(docsDir, componentName) {
|
|
240
|
+
if (!componentName) {
|
|
241
|
+
console.error("Usage: wds.cjs component <ComponentName>");
|
|
242
|
+
console.error("Example: wds.cjs component Button");
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
if (!printComponent(docsDir, componentName)) {
|
|
246
|
+
process.exit(1);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Cheap pre-check so cmdComponents can decide whether to emit a `---`
|
|
251
|
+
// separator before invoking the actual renderer. Avoids stale separators
|
|
252
|
+
// when a middle component is missing.
|
|
253
|
+
function componentExists(docsDir, componentName) {
|
|
254
|
+
if (!/^[A-Za-z0-9]+$/.test(componentName)) return false;
|
|
255
|
+
return fs.existsSync(
|
|
256
|
+
path.join(docsDir, "components", `${componentName}Props.md`)
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function cmdComponents(docsDir, args) {
|
|
261
|
+
// Accept either `components Button Card` or `components "Button Card"`.
|
|
262
|
+
const names = args.flatMap((a) => a.split(/\s+/)).filter(Boolean);
|
|
263
|
+
|
|
264
|
+
if (names.length === 0) {
|
|
265
|
+
console.error("Usage: wds.cjs components <Name1> [Name2] [Name3]...");
|
|
266
|
+
console.error("Example: wds.cjs components Button Card Table");
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
let printedAny = false;
|
|
271
|
+
let anyFailed = false;
|
|
272
|
+
for (const name of names) {
|
|
273
|
+
// Match the single-component flow: invalid names get a distinct error
|
|
274
|
+
// instead of being lumped under "not found".
|
|
275
|
+
if (!/^[A-Za-z0-9]+$/.test(name)) {
|
|
276
|
+
console.error(
|
|
277
|
+
`Invalid component name "${name}". Names may only contain letters and digits.`
|
|
278
|
+
);
|
|
279
|
+
anyFailed = true;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (!componentExists(docsDir, name)) {
|
|
283
|
+
console.error(
|
|
284
|
+
`Component "${name}" not found. Run: wds.cjs search <keyword>`
|
|
285
|
+
);
|
|
286
|
+
anyFailed = true;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (printedAny) console.log("\n---\n");
|
|
290
|
+
printComponent(docsDir, name);
|
|
291
|
+
printedAny = true;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Exit non-zero only if every requested component failed.
|
|
295
|
+
if (anyFailed && !printedAny) process.exit(1);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function cmdExample(docsDir, componentName, exampleName) {
|
|
299
|
+
if (!componentName || !exampleName) {
|
|
300
|
+
console.error('Usage: wds.cjs example <ComponentName> "<ExampleName>"');
|
|
301
|
+
console.error('Example: wds.cjs example Button "Loading state"');
|
|
302
|
+
process.exit(1);
|
|
303
|
+
}
|
|
304
|
+
validateComponentName(componentName);
|
|
305
|
+
|
|
306
|
+
const filePath = path.join(
|
|
307
|
+
docsDir,
|
|
308
|
+
"components",
|
|
309
|
+
`${componentName}Examples.md`
|
|
310
|
+
);
|
|
311
|
+
const content = readFile(filePath);
|
|
312
|
+
|
|
313
|
+
if (!content) {
|
|
314
|
+
console.error(`No examples file for "${componentName}".`);
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const lines = content.split("\n");
|
|
319
|
+
let startLine = -1;
|
|
320
|
+
let endLine = lines.length;
|
|
321
|
+
const searchName = exampleName.toLowerCase();
|
|
322
|
+
|
|
323
|
+
for (let i = 0; i < lines.length; i++) {
|
|
324
|
+
if (lines[i].startsWith("### ")) {
|
|
325
|
+
const name = lines[i].replace("### ", "").trim().toLowerCase();
|
|
326
|
+
if (startLine >= 0) {
|
|
327
|
+
// Found the next section — stop here
|
|
328
|
+
endLine = i;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
if (name === searchName || name.includes(searchName)) {
|
|
332
|
+
startLine = i;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (startLine < 0) {
|
|
338
|
+
console.error(
|
|
339
|
+
`Example "${exampleName}" not found for ${componentName}.\n`
|
|
340
|
+
);
|
|
341
|
+
// List available examples
|
|
342
|
+
const available = [];
|
|
343
|
+
for (const line of lines) {
|
|
344
|
+
if (line.startsWith("### ")) {
|
|
345
|
+
available.push(line.replace("### ", "").trim());
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (available.length > 0) {
|
|
349
|
+
console.log("Available examples:");
|
|
350
|
+
for (const ex of available) {
|
|
351
|
+
console.log(` - ${ex}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
process.exit(1);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
console.log(lines.slice(startLine, endLine).join("\n"));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function cmdTestkit(docsDir, componentName, methodName) {
|
|
361
|
+
if (!componentName) {
|
|
362
|
+
console.error("Usage: wds.cjs testkit <ComponentName> [methodName]");
|
|
363
|
+
console.error("Example: wds.cjs testkit Button");
|
|
364
|
+
console.error('Example: wds.cjs testkit Button click');
|
|
365
|
+
process.exit(1);
|
|
366
|
+
}
|
|
367
|
+
validateComponentName(componentName);
|
|
368
|
+
|
|
369
|
+
const filePath = path.join(
|
|
370
|
+
docsDir,
|
|
371
|
+
"components",
|
|
372
|
+
`${componentName}Testkit.md`,
|
|
373
|
+
);
|
|
374
|
+
const content = readFile(filePath);
|
|
375
|
+
|
|
376
|
+
if (!content) {
|
|
377
|
+
console.error(
|
|
378
|
+
`Testkit docs for "${componentName}" not found. Run: wds.cjs search <keyword>`,
|
|
379
|
+
);
|
|
380
|
+
process.exit(1);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (!methodName) {
|
|
384
|
+
console.log(content);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const lines = content.split("\n");
|
|
389
|
+
const searchName = methodName.toLowerCase();
|
|
390
|
+
let startLine = -1;
|
|
391
|
+
let endLine = lines.length;
|
|
392
|
+
|
|
393
|
+
for (let i = 0; i < lines.length; i++) {
|
|
394
|
+
if (lines[i].startsWith("### ") && !lines[i].startsWith("### API")) {
|
|
395
|
+
const name = lines[i].replace("### ", "").trim().toLowerCase();
|
|
396
|
+
if (startLine >= 0) {
|
|
397
|
+
endLine = i;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
if (name === searchName || name.includes(searchName)) {
|
|
401
|
+
startLine = i;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (startLine < 0) {
|
|
407
|
+
console.error(
|
|
408
|
+
`Method "${methodName}" not found on ${componentName} testkit.\n`,
|
|
409
|
+
);
|
|
410
|
+
const available = [];
|
|
411
|
+
let inApiSection = false;
|
|
412
|
+
for (const line of lines) {
|
|
413
|
+
if (line.startsWith("### API")) {
|
|
414
|
+
inApiSection = true;
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (inApiSection && line.startsWith("### ")) {
|
|
418
|
+
available.push(line.replace("### ", "").trim());
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (available.length > 0) {
|
|
422
|
+
console.log("Available methods:");
|
|
423
|
+
for (const m of available) {
|
|
424
|
+
console.log(` - ${m}`);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
process.exit(1);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
console.log(lines.slice(startLine, endLine).join("\n"));
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function cmdIcons(docsDir, terms) {
|
|
434
|
+
if (terms.length === 0) {
|
|
435
|
+
console.error("Usage: wds.cjs icons <query> [query...]");
|
|
436
|
+
console.error("Example: wds.cjs icons Add Edit Delete");
|
|
437
|
+
process.exit(1);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const content = readFile(path.join(docsDir, "icons.md"));
|
|
441
|
+
if (!content) {
|
|
442
|
+
console.error("Error: icons.md not found");
|
|
443
|
+
process.exit(1);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const regex = new RegExp(buildTermsPattern(terms), "i");
|
|
447
|
+
const matches = [];
|
|
448
|
+
|
|
449
|
+
for (const line of content.split("\n")) {
|
|
450
|
+
if (line.trim() && regex.test(line)) {
|
|
451
|
+
matches.push(line.trim());
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (matches.length === 0) {
|
|
456
|
+
console.log(`No icons found matching "${terms.join(" ")}".`);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
console.log(`Found ${matches.length} icon(s):\n`);
|
|
461
|
+
for (const m of matches) {
|
|
462
|
+
console.log(` ${m}`);
|
|
463
|
+
}
|
|
464
|
+
console.log(
|
|
465
|
+
"\nIcons are from @wix/wix-ui-icons-common. Each icon has a Small variant (e.g., Add + AddSmall)."
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function cmdHelp(docsDir) {
|
|
470
|
+
const scriptPath = path.resolve(__dirname, "wds.cjs");
|
|
471
|
+
console.log(`WDS Documentation Helper
|
|
472
|
+
|
|
473
|
+
Usage:
|
|
474
|
+
node ${scriptPath} search <keyword> Search components by keyword
|
|
475
|
+
node ${scriptPath} component <Name> Get props + example list
|
|
476
|
+
node ${scriptPath} components <Name1> <Name2>... Get props + example list for multiple components in one call
|
|
477
|
+
node ${scriptPath} example <Name> "<ExampleName>" Get a specific example
|
|
478
|
+
node ${scriptPath} testkit <Name> [method] Get testkit imports + API (or one method)
|
|
479
|
+
node ${scriptPath} icons <query> Search for icons
|
|
480
|
+
|
|
481
|
+
Examples:
|
|
482
|
+
node ${scriptPath} search table list
|
|
483
|
+
node ${scriptPath} search form input validation
|
|
484
|
+
node ${scriptPath} component Button
|
|
485
|
+
node ${scriptPath} components Button Card Table Input
|
|
486
|
+
node ${scriptPath} example Button "Loading state"
|
|
487
|
+
node ${scriptPath} testkit Button
|
|
488
|
+
node ${scriptPath} testkit Button click
|
|
489
|
+
node ${scriptPath} icons Add Edit Delete
|
|
490
|
+
|
|
491
|
+
Docs found at: ${docsDir}`);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// ---------------------------------------------------------------------------
|
|
495
|
+
// Main
|
|
496
|
+
// ---------------------------------------------------------------------------
|
|
497
|
+
|
|
498
|
+
const docsDir = findDocsDir();
|
|
499
|
+
if (!docsDir) {
|
|
500
|
+
console.error(
|
|
501
|
+
"Error: @wix/design-system not found in node_modules.\n" +
|
|
502
|
+
"Install it first: npm i @wix/design-system"
|
|
503
|
+
);
|
|
504
|
+
process.exit(1);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const [command, ...args] = process.argv.slice(2);
|
|
508
|
+
|
|
509
|
+
switch (command) {
|
|
510
|
+
case "search":
|
|
511
|
+
cmdSearch(docsDir, args);
|
|
512
|
+
break;
|
|
513
|
+
case "component":
|
|
514
|
+
cmdComponent(docsDir, args[0]);
|
|
515
|
+
break;
|
|
516
|
+
case "components":
|
|
517
|
+
cmdComponents(docsDir, args);
|
|
518
|
+
break;
|
|
519
|
+
case "example":
|
|
520
|
+
cmdExample(docsDir, args[0], args.slice(1).join(" "));
|
|
521
|
+
break;
|
|
522
|
+
case "testkit":
|
|
523
|
+
cmdTestkit(docsDir, args[0], args[1]);
|
|
524
|
+
break;
|
|
525
|
+
case "icons":
|
|
526
|
+
cmdIcons(docsDir, args);
|
|
527
|
+
break;
|
|
528
|
+
default:
|
|
529
|
+
cmdHelp(docsDir);
|
|
530
|
+
break;
|
|
531
|
+
}
|