@shopkit/cli 0.1.0 → 0.2.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/README.md +124 -0
- package/dist/cli.cjs +137 -509
- package/dist/cli.js +137 -509
- package/dist/index.cjs +137 -509
- package/dist/index.js +137 -509
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2276,10 +2276,9 @@ function parseThemeArgs() {
|
|
|
2276
2276
|
return result;
|
|
2277
2277
|
}
|
|
2278
2278
|
var ESSENTIAL_WIDGETS = [
|
|
2279
|
+
"Header",
|
|
2279
2280
|
"Footer",
|
|
2280
|
-
"
|
|
2281
|
-
"ProductInfo",
|
|
2282
|
-
"CollectionWidget"
|
|
2281
|
+
"PageContent"
|
|
2283
2282
|
];
|
|
2284
2283
|
function generateEssentialWidgets() {
|
|
2285
2284
|
const widgetsDir = getWidgetsDir();
|
|
@@ -2295,96 +2294,18 @@ function generateEssentialWidgets() {
|
|
|
2295
2294
|
}
|
|
2296
2295
|
}
|
|
2297
2296
|
}
|
|
2298
|
-
function
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS } from "@shopkit/builder";
|
|
2302
|
-
|
|
2303
|
-
/**
|
|
2304
|
-
* Home Page Template for ${merchantName}
|
|
2305
|
-
*/
|
|
2306
|
-
export const template: PageConfig = {
|
|
2307
|
-
id: "${themeId}-home",
|
|
2308
|
-
dataSources: {},
|
|
2309
|
-
sections: [
|
|
2310
|
-
// Header Section
|
|
2311
|
-
{
|
|
2312
|
-
id: "header-section",
|
|
2313
|
-
name: "Header",
|
|
2314
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2315
|
-
settings: {
|
|
2316
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2317
|
-
responsive: {
|
|
2318
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2319
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2320
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2321
|
-
},
|
|
2322
|
-
},
|
|
2323
|
-
widgets: [
|
|
2324
|
-
{
|
|
2325
|
-
id: "${themeId}-header",
|
|
2326
|
-
name: "Header",
|
|
2327
|
-
type: WIDGET_TYPES.Header,
|
|
2328
|
-
settings: {
|
|
2329
|
-
variant: "v1",
|
|
2330
|
-
logo: "t:common.logo",
|
|
2331
|
-
},
|
|
2332
|
-
},
|
|
2333
|
-
],
|
|
2334
|
-
},
|
|
2335
|
-
|
|
2336
|
-
// Hero Section
|
|
2337
|
-
{
|
|
2338
|
-
id: "hero-section",
|
|
2339
|
-
name: "Hero",
|
|
2340
|
-
type: SECTION_TYPES.HERO_SECTION,
|
|
2341
|
-
settings: {
|
|
2342
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2343
|
-
responsive: {
|
|
2344
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2345
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2346
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2347
|
-
},
|
|
2348
|
-
},
|
|
2349
|
-
widgets: [],
|
|
2350
|
-
},
|
|
2351
|
-
|
|
2352
|
-
// Footer Section
|
|
2353
|
-
{
|
|
2354
|
-
id: "footer-section",
|
|
2355
|
-
name: "Footer",
|
|
2356
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2357
|
-
settings: {
|
|
2358
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2359
|
-
responsive: {
|
|
2360
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2361
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2362
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2363
|
-
},
|
|
2364
|
-
},
|
|
2365
|
-
widgets: [
|
|
2366
|
-
{
|
|
2367
|
-
id: "${themeId}-footer",
|
|
2368
|
-
name: "Footer",
|
|
2369
|
-
type: WIDGET_TYPES.Footer,
|
|
2370
|
-
settings: { variant: "v1" },
|
|
2371
|
-
},
|
|
2372
|
-
],
|
|
2373
|
-
},
|
|
2374
|
-
],
|
|
2375
|
-
};
|
|
2376
|
-
`;
|
|
2377
|
-
}
|
|
2378
|
-
function generateHomeBTemplate(themeId, merchantName) {
|
|
2297
|
+
function generatePageTemplate(themeId, templateName, merchantName) {
|
|
2298
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
2299
|
+
const pageTitle = templateName.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
2379
2300
|
return `import type { PageConfig } from "@shopkit/builder";
|
|
2380
2301
|
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2381
2302
|
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS } from "@shopkit/builder";
|
|
2382
2303
|
|
|
2383
2304
|
/**
|
|
2384
|
-
*
|
|
2305
|
+
* ${pageTitle} Page Template for ${merchantName}
|
|
2385
2306
|
*/
|
|
2386
2307
|
export const template: PageConfig = {
|
|
2387
|
-
id: "${themeId}
|
|
2308
|
+
id: "${themeId}-${templateName}",
|
|
2388
2309
|
dataSources: {},
|
|
2389
2310
|
sections: [
|
|
2390
2311
|
// Header Section
|
|
@@ -2410,96 +2331,13 @@ export const template: PageConfig = {
|
|
|
2410
2331
|
],
|
|
2411
2332
|
},
|
|
2412
2333
|
|
|
2413
|
-
//
|
|
2414
|
-
{
|
|
2415
|
-
id: "hero-section-b",
|
|
2416
|
-
name: "Hero B",
|
|
2417
|
-
type: SECTION_TYPES.HERO_SECTION,
|
|
2418
|
-
settings: {
|
|
2419
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2420
|
-
responsive: {
|
|
2421
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2422
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2423
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2424
|
-
},
|
|
2425
|
-
},
|
|
2426
|
-
widgets: [],
|
|
2427
|
-
},
|
|
2428
|
-
|
|
2429
|
-
// Footer Section
|
|
2430
|
-
{
|
|
2431
|
-
id: "footer-section",
|
|
2432
|
-
name: "Footer",
|
|
2433
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2434
|
-
settings: {
|
|
2435
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2436
|
-
responsive: {
|
|
2437
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2438
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2439
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2440
|
-
},
|
|
2441
|
-
},
|
|
2442
|
-
widgets: [
|
|
2443
|
-
{
|
|
2444
|
-
id: "${themeId}-footer",
|
|
2445
|
-
name: "Footer",
|
|
2446
|
-
type: WIDGET_TYPES.Footer,
|
|
2447
|
-
settings: { variant: "v1" },
|
|
2448
|
-
},
|
|
2449
|
-
],
|
|
2450
|
-
},
|
|
2451
|
-
],
|
|
2452
|
-
};
|
|
2453
|
-
`;
|
|
2454
|
-
}
|
|
2455
|
-
function generateProductsTemplate(themeId, merchantName) {
|
|
2456
|
-
return `import type { PageConfig } from "@shopkit/builder";
|
|
2457
|
-
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2458
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS, DATA_SOURCE_TYPES } from "@shopkit/builder";
|
|
2459
|
-
|
|
2460
|
-
/**
|
|
2461
|
-
* Product Page Template for ${merchantName}
|
|
2462
|
-
*/
|
|
2463
|
-
export const template: PageConfig = {
|
|
2464
|
-
id: "${themeId}-product",
|
|
2465
|
-
dataSources: {
|
|
2466
|
-
product: {
|
|
2467
|
-
type: DATA_SOURCE_TYPES.PRODUCT,
|
|
2468
|
-
params: { handle: "{{productHandle}}" },
|
|
2469
|
-
required: true,
|
|
2470
|
-
},
|
|
2471
|
-
},
|
|
2472
|
-
sections: [
|
|
2473
|
-
// Header Section
|
|
2474
|
-
{
|
|
2475
|
-
id: "header-section",
|
|
2476
|
-
name: "Header",
|
|
2477
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2478
|
-
settings: {
|
|
2479
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2480
|
-
responsive: {
|
|
2481
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2482
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2483
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2484
|
-
},
|
|
2485
|
-
},
|
|
2486
|
-
widgets: [
|
|
2487
|
-
{
|
|
2488
|
-
id: "${themeId}-header",
|
|
2489
|
-
name: "Header",
|
|
2490
|
-
type: WIDGET_TYPES.Header,
|
|
2491
|
-
settings: { variant: "v1" },
|
|
2492
|
-
},
|
|
2493
|
-
],
|
|
2494
|
-
},
|
|
2495
|
-
|
|
2496
|
-
// Product Info Section
|
|
2334
|
+
// Main Content Section
|
|
2497
2335
|
{
|
|
2498
|
-
id: "
|
|
2499
|
-
name: "
|
|
2336
|
+
id: "main-content-section",
|
|
2337
|
+
name: "Main Content",
|
|
2500
2338
|
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2501
2339
|
settings: {
|
|
2502
|
-
layout: SECTION_LAYOUT_OPTIONS.
|
|
2340
|
+
layout: SECTION_LAYOUT_OPTIONS.PAGE,
|
|
2503
2341
|
responsive: {
|
|
2504
2342
|
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2505
2343
|
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
@@ -2508,18 +2346,14 @@ export const template: PageConfig = {
|
|
|
2508
2346
|
},
|
|
2509
2347
|
widgets: [
|
|
2510
2348
|
{
|
|
2511
|
-
id: "${themeId}-
|
|
2512
|
-
name: "
|
|
2513
|
-
type: WIDGET_TYPES.
|
|
2514
|
-
settings: {
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
name: "Product Info",
|
|
2520
|
-
type: WIDGET_TYPES.ProductInfo,
|
|
2521
|
-
settings: { variant: "v1" },
|
|
2522
|
-
dataSourceKey: "product",
|
|
2349
|
+
id: "${themeId}-${templateName}-content",
|
|
2350
|
+
name: "Page Content",
|
|
2351
|
+
type: WIDGET_TYPES.PageContent,
|
|
2352
|
+
settings: {
|
|
2353
|
+
variant: "v1",
|
|
2354
|
+
heading: "t:${keyName}.heading",
|
|
2355
|
+
description: "t:${keyName}.description",
|
|
2356
|
+
},
|
|
2523
2357
|
},
|
|
2524
2358
|
],
|
|
2525
2359
|
},
|
|
@@ -2550,285 +2384,26 @@ export const template: PageConfig = {
|
|
|
2550
2384
|
};
|
|
2551
2385
|
`;
|
|
2552
2386
|
}
|
|
2387
|
+
function generateHomeTemplate(themeId, merchantName) {
|
|
2388
|
+
return generatePageTemplate(themeId, "home", merchantName);
|
|
2389
|
+
}
|
|
2390
|
+
function generateHomeBTemplate(themeId, merchantName) {
|
|
2391
|
+
return generatePageTemplate(themeId, "home-b", merchantName);
|
|
2392
|
+
}
|
|
2393
|
+
function generateProductsTemplate(themeId, merchantName) {
|
|
2394
|
+
return generatePageTemplate(themeId, "products", merchantName);
|
|
2395
|
+
}
|
|
2553
2396
|
function generateProductsBTemplate(themeId, merchantName) {
|
|
2554
|
-
return
|
|
2555
|
-
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2556
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS, DATA_SOURCE_TYPES } from "@shopkit/builder";
|
|
2557
|
-
|
|
2558
|
-
/**
|
|
2559
|
-
* Product Page Template B (Variant) for ${merchantName}
|
|
2560
|
-
*/
|
|
2561
|
-
export const template: PageConfig = {
|
|
2562
|
-
id: "${themeId}-product-b",
|
|
2563
|
-
dataSources: {
|
|
2564
|
-
product: {
|
|
2565
|
-
type: DATA_SOURCE_TYPES.PRODUCT,
|
|
2566
|
-
params: { handle: "{{productHandle}}" },
|
|
2567
|
-
required: true,
|
|
2568
|
-
},
|
|
2569
|
-
},
|
|
2570
|
-
sections: [
|
|
2571
|
-
// Header Section
|
|
2572
|
-
{
|
|
2573
|
-
id: "header-section",
|
|
2574
|
-
name: "Header",
|
|
2575
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2576
|
-
settings: {
|
|
2577
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2578
|
-
responsive: {
|
|
2579
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2580
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2581
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2582
|
-
},
|
|
2583
|
-
},
|
|
2584
|
-
widgets: [
|
|
2585
|
-
{
|
|
2586
|
-
id: "${themeId}-header",
|
|
2587
|
-
name: "Header",
|
|
2588
|
-
type: WIDGET_TYPES.Header,
|
|
2589
|
-
settings: { variant: "v1" },
|
|
2590
|
-
},
|
|
2591
|
-
],
|
|
2592
|
-
},
|
|
2593
|
-
|
|
2594
|
-
// Product Info Section B
|
|
2595
|
-
{
|
|
2596
|
-
id: "product-info-section-b",
|
|
2597
|
-
name: "Product Info B",
|
|
2598
|
-
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2599
|
-
settings: {
|
|
2600
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2601
|
-
responsive: {
|
|
2602
|
-
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2603
|
-
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
2604
|
-
desktop: { padding: { top: 32, right: 32, bottom: 32, left: 32 } },
|
|
2605
|
-
},
|
|
2606
|
-
},
|
|
2607
|
-
widgets: [
|
|
2608
|
-
{
|
|
2609
|
-
id: "${themeId}-product-info-b",
|
|
2610
|
-
name: "Product Info",
|
|
2611
|
-
type: WIDGET_TYPES.ProductInfo,
|
|
2612
|
-
settings: { variant: "v1" },
|
|
2613
|
-
dataSourceKey: "product",
|
|
2614
|
-
},
|
|
2615
|
-
{
|
|
2616
|
-
id: "${themeId}-product-gallery-b",
|
|
2617
|
-
name: "Product Gallery",
|
|
2618
|
-
type: WIDGET_TYPES.ProductGallery,
|
|
2619
|
-
settings: { variant: "v1" },
|
|
2620
|
-
dataSourceKey: "product",
|
|
2621
|
-
},
|
|
2622
|
-
],
|
|
2623
|
-
},
|
|
2624
|
-
|
|
2625
|
-
// Footer Section
|
|
2626
|
-
{
|
|
2627
|
-
id: "footer-section",
|
|
2628
|
-
name: "Footer",
|
|
2629
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2630
|
-
settings: {
|
|
2631
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2632
|
-
responsive: {
|
|
2633
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2634
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2635
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2636
|
-
},
|
|
2637
|
-
},
|
|
2638
|
-
widgets: [
|
|
2639
|
-
{
|
|
2640
|
-
id: "${themeId}-footer",
|
|
2641
|
-
name: "Footer",
|
|
2642
|
-
type: WIDGET_TYPES.Footer,
|
|
2643
|
-
settings: { variant: "v1" },
|
|
2644
|
-
},
|
|
2645
|
-
],
|
|
2646
|
-
},
|
|
2647
|
-
],
|
|
2648
|
-
};
|
|
2649
|
-
`;
|
|
2397
|
+
return generatePageTemplate(themeId, "products-b", merchantName);
|
|
2650
2398
|
}
|
|
2651
2399
|
function generateCollectionTemplate(themeId, merchantName) {
|
|
2652
|
-
return
|
|
2653
|
-
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2654
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS, DATA_SOURCE_TYPES } from "@shopkit/builder";
|
|
2655
|
-
|
|
2656
|
-
/**
|
|
2657
|
-
* Collection Page Template for ${merchantName}
|
|
2658
|
-
*/
|
|
2659
|
-
export const template: PageConfig = {
|
|
2660
|
-
id: "${themeId}-collection",
|
|
2661
|
-
dataSources: {
|
|
2662
|
-
collection: {
|
|
2663
|
-
type: DATA_SOURCE_TYPES.COLLECTION,
|
|
2664
|
-
params: { handle: "{{collectionHandle}}" },
|
|
2665
|
-
required: true,
|
|
2666
|
-
},
|
|
2667
|
-
},
|
|
2668
|
-
sections: [
|
|
2669
|
-
// Header Section
|
|
2670
|
-
{
|
|
2671
|
-
id: "header-section",
|
|
2672
|
-
name: "Header",
|
|
2673
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2674
|
-
settings: {
|
|
2675
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2676
|
-
responsive: {
|
|
2677
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2678
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2679
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2680
|
-
},
|
|
2681
|
-
},
|
|
2682
|
-
widgets: [
|
|
2683
|
-
{
|
|
2684
|
-
id: "${themeId}-header",
|
|
2685
|
-
name: "Header",
|
|
2686
|
-
type: WIDGET_TYPES.Header,
|
|
2687
|
-
settings: { variant: "v1" },
|
|
2688
|
-
},
|
|
2689
|
-
],
|
|
2690
|
-
},
|
|
2691
|
-
|
|
2692
|
-
// Collection Content Section
|
|
2693
|
-
{
|
|
2694
|
-
id: "collection-content-section",
|
|
2695
|
-
name: "Collection Products",
|
|
2696
|
-
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2697
|
-
settings: {
|
|
2698
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2699
|
-
responsive: {
|
|
2700
|
-
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2701
|
-
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
2702
|
-
desktop: { padding: { top: 32, right: 32, bottom: 32, left: 32 } },
|
|
2703
|
-
},
|
|
2704
|
-
},
|
|
2705
|
-
widgets: [
|
|
2706
|
-
{
|
|
2707
|
-
id: "${themeId}-collection-widget",
|
|
2708
|
-
name: "Collection Products",
|
|
2709
|
-
type: WIDGET_TYPES.CollectionWidget,
|
|
2710
|
-
settings: { variant: "v1" },
|
|
2711
|
-
dataSourceKey: "collection",
|
|
2712
|
-
},
|
|
2713
|
-
],
|
|
2714
|
-
},
|
|
2715
|
-
|
|
2716
|
-
// Footer Section
|
|
2717
|
-
{
|
|
2718
|
-
id: "footer-section",
|
|
2719
|
-
name: "Footer",
|
|
2720
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2721
|
-
settings: {
|
|
2722
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2723
|
-
responsive: {
|
|
2724
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2725
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2726
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2727
|
-
},
|
|
2728
|
-
},
|
|
2729
|
-
widgets: [
|
|
2730
|
-
{
|
|
2731
|
-
id: "${themeId}-footer",
|
|
2732
|
-
name: "Footer",
|
|
2733
|
-
type: WIDGET_TYPES.Footer,
|
|
2734
|
-
settings: { variant: "v1" },
|
|
2735
|
-
},
|
|
2736
|
-
],
|
|
2737
|
-
},
|
|
2738
|
-
],
|
|
2739
|
-
};
|
|
2740
|
-
`;
|
|
2400
|
+
return generatePageTemplate(themeId, "collection", merchantName);
|
|
2741
2401
|
}
|
|
2742
2402
|
function generateCollectionBTemplate(themeId, merchantName) {
|
|
2743
|
-
return
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
/**
|
|
2748
|
-
* Collection Page Template B (Variant) for ${merchantName}
|
|
2749
|
-
*/
|
|
2750
|
-
export const template: PageConfig = {
|
|
2751
|
-
id: "${themeId}-collection-b",
|
|
2752
|
-
dataSources: {
|
|
2753
|
-
collection: {
|
|
2754
|
-
type: DATA_SOURCE_TYPES.COLLECTION,
|
|
2755
|
-
params: { handle: "{{collectionHandle}}" },
|
|
2756
|
-
required: true,
|
|
2757
|
-
},
|
|
2758
|
-
},
|
|
2759
|
-
sections: [
|
|
2760
|
-
// Header Section
|
|
2761
|
-
{
|
|
2762
|
-
id: "header-section",
|
|
2763
|
-
name: "Header",
|
|
2764
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2765
|
-
settings: {
|
|
2766
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2767
|
-
responsive: {
|
|
2768
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2769
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2770
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2771
|
-
},
|
|
2772
|
-
},
|
|
2773
|
-
widgets: [
|
|
2774
|
-
{
|
|
2775
|
-
id: "${themeId}-header",
|
|
2776
|
-
name: "Header",
|
|
2777
|
-
type: WIDGET_TYPES.Header,
|
|
2778
|
-
settings: { variant: "v1" },
|
|
2779
|
-
},
|
|
2780
|
-
],
|
|
2781
|
-
},
|
|
2782
|
-
|
|
2783
|
-
// Collection Content Section B
|
|
2784
|
-
{
|
|
2785
|
-
id: "collection-content-section-b",
|
|
2786
|
-
name: "Collection Products B",
|
|
2787
|
-
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2788
|
-
settings: {
|
|
2789
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2790
|
-
responsive: {
|
|
2791
|
-
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2792
|
-
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
2793
|
-
desktop: { padding: { top: 32, right: 32, bottom: 32, left: 32 } },
|
|
2794
|
-
},
|
|
2795
|
-
},
|
|
2796
|
-
widgets: [
|
|
2797
|
-
{
|
|
2798
|
-
id: "${themeId}-collection-widget-b",
|
|
2799
|
-
name: "Collection Products",
|
|
2800
|
-
type: WIDGET_TYPES.CollectionWidget,
|
|
2801
|
-
settings: { variant: "v1" },
|
|
2802
|
-
dataSourceKey: "collection",
|
|
2803
|
-
},
|
|
2804
|
-
],
|
|
2805
|
-
},
|
|
2806
|
-
|
|
2807
|
-
// Footer Section
|
|
2808
|
-
{
|
|
2809
|
-
id: "footer-section",
|
|
2810
|
-
name: "Footer",
|
|
2811
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2812
|
-
settings: {
|
|
2813
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2814
|
-
responsive: {
|
|
2815
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2816
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2817
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2818
|
-
},
|
|
2819
|
-
},
|
|
2820
|
-
widgets: [
|
|
2821
|
-
{
|
|
2822
|
-
id: "${themeId}-footer",
|
|
2823
|
-
name: "Footer",
|
|
2824
|
-
type: WIDGET_TYPES.Footer,
|
|
2825
|
-
settings: { variant: "v1" },
|
|
2826
|
-
},
|
|
2827
|
-
],
|
|
2828
|
-
},
|
|
2829
|
-
],
|
|
2830
|
-
};
|
|
2831
|
-
`;
|
|
2403
|
+
return generatePageTemplate(themeId, "collection-b", merchantName);
|
|
2404
|
+
}
|
|
2405
|
+
function generateOrdersTemplate(themeId, merchantName) {
|
|
2406
|
+
return generatePageTemplate(themeId, "orders", merchantName);
|
|
2832
2407
|
}
|
|
2833
2408
|
function generateVariantRegistry() {
|
|
2834
2409
|
return `/**
|
|
@@ -2858,6 +2433,9 @@ export const variantRegistry = {
|
|
|
2858
2433
|
[TEMPLATE_TYPES["collection-b"]]: {
|
|
2859
2434
|
default: () => import("./collection-b/default").then((m) => m.template),
|
|
2860
2435
|
},
|
|
2436
|
+
[TEMPLATE_TYPES.orders]: {
|
|
2437
|
+
default: () => import("./orders/default").then((m) => m.template),
|
|
2438
|
+
},
|
|
2861
2439
|
};
|
|
2862
2440
|
`;
|
|
2863
2441
|
}
|
|
@@ -2866,60 +2444,24 @@ function generateCommonLocale(merchantName) {
|
|
|
2866
2444
|
{
|
|
2867
2445
|
common: {
|
|
2868
2446
|
logo: `/images/${toKebabCase(merchantName)}/logo.svg`,
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
{ label: "Products", href: "/collections/all" },
|
|
2873
|
-
{ label: "About", href: "/pages/about" },
|
|
2874
|
-
{ label: "Contact", href: "/pages/contact" }
|
|
2875
|
-
]
|
|
2876
|
-
},
|
|
2877
|
-
footer: {
|
|
2878
|
-
copyright: `\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} ${merchantName}. All rights reserved.`,
|
|
2879
|
-
socialLinks: [
|
|
2880
|
-
{ platform: "instagram", url: "#", icon: "instagram" },
|
|
2881
|
-
{ platform: "facebook", url: "#", icon: "facebook" },
|
|
2882
|
-
{ platform: "twitter", url: "#", icon: "twitter" }
|
|
2883
|
-
],
|
|
2884
|
-
links: [
|
|
2885
|
-
{
|
|
2886
|
-
title: "Shop",
|
|
2887
|
-
items: [
|
|
2888
|
-
{ label: "All Products", href: "/collections/all" },
|
|
2889
|
-
{ label: "New Arrivals", href: "/collections/new-arrivals" }
|
|
2890
|
-
]
|
|
2891
|
-
},
|
|
2892
|
-
{
|
|
2893
|
-
title: "Support",
|
|
2894
|
-
items: [
|
|
2895
|
-
{ label: "Contact Us", href: "/pages/contact" },
|
|
2896
|
-
{ label: "FAQs", href: "/pages/faqs" }
|
|
2897
|
-
]
|
|
2898
|
-
}
|
|
2899
|
-
]
|
|
2900
|
-
},
|
|
2901
|
-
addToCartButtonText: "Add to Cart",
|
|
2902
|
-
goToCartText: "Go to Cart"
|
|
2447
|
+
site_name: merchantName,
|
|
2448
|
+
add_to_cart: "Add to Cart",
|
|
2449
|
+
go_to_cart: "Go to Cart"
|
|
2903
2450
|
}
|
|
2904
2451
|
},
|
|
2905
2452
|
null,
|
|
2906
2453
|
2
|
|
2907
2454
|
);
|
|
2908
2455
|
}
|
|
2909
|
-
function
|
|
2456
|
+
function generatePageLocale(templateName) {
|
|
2457
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
2458
|
+
const pageTitle = templateName.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
2910
2459
|
return JSON.stringify(
|
|
2911
2460
|
{
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
},
|
|
2917
|
-
sections: {
|
|
2918
|
-
featured: {
|
|
2919
|
-
title: "Featured Products",
|
|
2920
|
-
viewAllLink: "/collections/featured"
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2461
|
+
[keyName]: {
|
|
2462
|
+
page_title: `${pageTitle} Page`,
|
|
2463
|
+
heading: pageTitle,
|
|
2464
|
+
description: `Welcome to the ${pageTitle} page.`
|
|
2923
2465
|
}
|
|
2924
2466
|
},
|
|
2925
2467
|
null,
|
|
@@ -2975,10 +2517,17 @@ ${colors.bold(` \u{1F3A8} Creating Theme: ${colors.cyan(merchantName)}`)}
|
|
|
2975
2517
|
join(themeDir, "templates", "products-b"),
|
|
2976
2518
|
join(themeDir, "templates", "collection"),
|
|
2977
2519
|
join(themeDir, "templates", "collection-b"),
|
|
2520
|
+
join(themeDir, "templates", "orders"),
|
|
2978
2521
|
join(themeDir, "locales"),
|
|
2979
2522
|
join(themeDir, "locales", "common"),
|
|
2980
2523
|
join(themeDir, "locales", "pages"),
|
|
2981
|
-
join(themeDir, "locales", "pages", "home")
|
|
2524
|
+
join(themeDir, "locales", "pages", "home"),
|
|
2525
|
+
join(themeDir, "locales", "pages", "home-b"),
|
|
2526
|
+
join(themeDir, "locales", "pages", "products"),
|
|
2527
|
+
join(themeDir, "locales", "pages", "products-b"),
|
|
2528
|
+
join(themeDir, "locales", "pages", "collections"),
|
|
2529
|
+
join(themeDir, "locales", "pages", "collections-b"),
|
|
2530
|
+
join(themeDir, "locales", "pages", "orders")
|
|
2982
2531
|
];
|
|
2983
2532
|
for (const dir of dirs) {
|
|
2984
2533
|
ensureDir(dir);
|
|
@@ -3033,6 +2582,10 @@ ${colors.bold(` \u{1F3A8} Creating Theme: ${colors.cyan(merchantName)}`)}
|
|
|
3033
2582
|
path: join(themeDir, "templates", "collection-b", "default.ts"),
|
|
3034
2583
|
content: generateCollectionBTemplate(themeId, merchantName)
|
|
3035
2584
|
},
|
|
2585
|
+
{
|
|
2586
|
+
path: join(themeDir, "templates", "orders", "default.ts"),
|
|
2587
|
+
content: generateOrdersTemplate(themeId, merchantName)
|
|
2588
|
+
},
|
|
3036
2589
|
{
|
|
3037
2590
|
path: join(themeDir, "templates", "variant-registry.ts"),
|
|
3038
2591
|
content: generateVariantRegistry()
|
|
@@ -3043,7 +2596,31 @@ ${colors.bold(` \u{1F3A8} Creating Theme: ${colors.cyan(merchantName)}`)}
|
|
|
3043
2596
|
},
|
|
3044
2597
|
{
|
|
3045
2598
|
path: join(themeDir, "locales", "pages", "home", `${defaultLang}.json`),
|
|
3046
|
-
content:
|
|
2599
|
+
content: generatePageLocale("home")
|
|
2600
|
+
},
|
|
2601
|
+
{
|
|
2602
|
+
path: join(themeDir, "locales", "pages", "home-b", `${defaultLang}.json`),
|
|
2603
|
+
content: generatePageLocale("home-b")
|
|
2604
|
+
},
|
|
2605
|
+
{
|
|
2606
|
+
path: join(themeDir, "locales", "pages", "products", `${defaultLang}.json`),
|
|
2607
|
+
content: generatePageLocale("products")
|
|
2608
|
+
},
|
|
2609
|
+
{
|
|
2610
|
+
path: join(themeDir, "locales", "pages", "products-b", `${defaultLang}.json`),
|
|
2611
|
+
content: generatePageLocale("products-b")
|
|
2612
|
+
},
|
|
2613
|
+
{
|
|
2614
|
+
path: join(themeDir, "locales", "pages", "collections", `${defaultLang}.json`),
|
|
2615
|
+
content: generatePageLocale("collections")
|
|
2616
|
+
},
|
|
2617
|
+
{
|
|
2618
|
+
path: join(themeDir, "locales", "pages", "collections-b", `${defaultLang}.json`),
|
|
2619
|
+
content: generatePageLocale("collections-b")
|
|
2620
|
+
},
|
|
2621
|
+
{
|
|
2622
|
+
path: join(themeDir, "locales", "pages", "orders", `${defaultLang}.json`),
|
|
2623
|
+
content: generatePageLocale("orders")
|
|
3047
2624
|
}
|
|
3048
2625
|
];
|
|
3049
2626
|
for (const file of files) {
|
|
@@ -3097,7 +2674,23 @@ function parseTemplateArgs() {
|
|
|
3097
2674
|
}
|
|
3098
2675
|
return result;
|
|
3099
2676
|
}
|
|
2677
|
+
function generateTemplateLocale(templateName) {
|
|
2678
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
2679
|
+
const pageTitle = templateName.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
2680
|
+
return JSON.stringify(
|
|
2681
|
+
{
|
|
2682
|
+
[keyName]: {
|
|
2683
|
+
page_title: `${pageTitle} Page`,
|
|
2684
|
+
heading: pageTitle,
|
|
2685
|
+
description: `Welcome to the ${pageTitle} page.`
|
|
2686
|
+
}
|
|
2687
|
+
},
|
|
2688
|
+
null,
|
|
2689
|
+
2
|
|
2690
|
+
);
|
|
2691
|
+
}
|
|
3100
2692
|
function generateTemplateContent(selectedTheme, templateName) {
|
|
2693
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
3101
2694
|
return `import type { PageConfig } from "@shopkit/builder";
|
|
3102
2695
|
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
3103
2696
|
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS } from "@shopkit/builder";
|
|
@@ -3140,7 +2733,7 @@ export const template: PageConfig = {
|
|
|
3140
2733
|
name: "Main Content",
|
|
3141
2734
|
type: SECTION_TYPES.CONTENT_SECTION,
|
|
3142
2735
|
settings: {
|
|
3143
|
-
layout: SECTION_LAYOUT_OPTIONS.
|
|
2736
|
+
layout: SECTION_LAYOUT_OPTIONS.PAGE,
|
|
3144
2737
|
responsive: {
|
|
3145
2738
|
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
3146
2739
|
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
@@ -3148,7 +2741,16 @@ export const template: PageConfig = {
|
|
|
3148
2741
|
},
|
|
3149
2742
|
},
|
|
3150
2743
|
widgets: [
|
|
3151
|
-
|
|
2744
|
+
{
|
|
2745
|
+
id: "${selectedTheme}-${templateName}-content",
|
|
2746
|
+
name: "Page Content",
|
|
2747
|
+
type: WIDGET_TYPES.PageContent,
|
|
2748
|
+
settings: {
|
|
2749
|
+
variant: "v1",
|
|
2750
|
+
heading: "t:${keyName}.heading",
|
|
2751
|
+
description: "t:${keyName}.description",
|
|
2752
|
+
},
|
|
2753
|
+
},
|
|
3152
2754
|
],
|
|
3153
2755
|
},
|
|
3154
2756
|
|
|
@@ -3243,6 +2845,24 @@ ${colors.bold(" \u{1F4C4} Create New Template")}
|
|
|
3243
2845
|
`
|
|
3244
2846
|
${colors.green("\u2713")} Created template: src/themes/${selectedTheme}/templates/${templateName}/default.ts`
|
|
3245
2847
|
);
|
|
2848
|
+
const localeDir = join(themesDir, selectedTheme, "locales", "pages", templateName);
|
|
2849
|
+
ensureDir(localeDir);
|
|
2850
|
+
const themeJsonPath = join(themesDir, selectedTheme, "theme.json");
|
|
2851
|
+
let supportedLanguages = ["en"];
|
|
2852
|
+
if (exists(themeJsonPath)) {
|
|
2853
|
+
try {
|
|
2854
|
+
const themeConfig = JSON.parse(readFile(themeJsonPath));
|
|
2855
|
+
if (themeConfig.supportedLanguages?.length > 0) {
|
|
2856
|
+
supportedLanguages = themeConfig.supportedLanguages;
|
|
2857
|
+
}
|
|
2858
|
+
} catch (e) {
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
const localeContent = generateTemplateLocale(templateName);
|
|
2862
|
+
for (const lang of supportedLanguages) {
|
|
2863
|
+
writeFile(join(localeDir, `${lang}.json`), localeContent);
|
|
2864
|
+
}
|
|
2865
|
+
log.success(`Created locale files for: ${supportedLanguages.join(", ")}`);
|
|
3246
2866
|
const variantRegistryPath = join(
|
|
3247
2867
|
themesDir,
|
|
3248
2868
|
selectedTheme,
|
|
@@ -3276,6 +2896,14 @@ ${colors.bold(" Generating template types...")}
|
|
|
3276
2896
|
} else {
|
|
3277
2897
|
log.warn(`Run ${colors.cyan("bun run generate:templates")} manually`);
|
|
3278
2898
|
}
|
|
2899
|
+
console.log(`
|
|
2900
|
+
${colors.bold(" Generating i18n manifest...")}
|
|
2901
|
+
`);
|
|
2902
|
+
if (runGenerator("i18n")) {
|
|
2903
|
+
log.success("i18n manifest regenerated");
|
|
2904
|
+
} else {
|
|
2905
|
+
log.warn(`Run ${colors.cyan("bun run generate:i18n")} manually`);
|
|
2906
|
+
}
|
|
3279
2907
|
console.log(
|
|
3280
2908
|
`
|
|
3281
2909
|
${colors.green(colors.bold(` \u2705 Template "${templateName}" created successfully!`))}
|