@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/index.cjs
CHANGED
|
@@ -2298,10 +2298,9 @@ function parseThemeArgs() {
|
|
|
2298
2298
|
return result;
|
|
2299
2299
|
}
|
|
2300
2300
|
var ESSENTIAL_WIDGETS = [
|
|
2301
|
+
"Header",
|
|
2301
2302
|
"Footer",
|
|
2302
|
-
"
|
|
2303
|
-
"ProductInfo",
|
|
2304
|
-
"CollectionWidget"
|
|
2303
|
+
"PageContent"
|
|
2305
2304
|
];
|
|
2306
2305
|
function generateEssentialWidgets() {
|
|
2307
2306
|
const widgetsDir = getWidgetsDir();
|
|
@@ -2317,96 +2316,18 @@ function generateEssentialWidgets() {
|
|
|
2317
2316
|
}
|
|
2318
2317
|
}
|
|
2319
2318
|
}
|
|
2320
|
-
function
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS } from "@shopkit/builder";
|
|
2324
|
-
|
|
2325
|
-
/**
|
|
2326
|
-
* Home Page Template for ${merchantName}
|
|
2327
|
-
*/
|
|
2328
|
-
export const template: PageConfig = {
|
|
2329
|
-
id: "${themeId}-home",
|
|
2330
|
-
dataSources: {},
|
|
2331
|
-
sections: [
|
|
2332
|
-
// Header Section
|
|
2333
|
-
{
|
|
2334
|
-
id: "header-section",
|
|
2335
|
-
name: "Header",
|
|
2336
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2337
|
-
settings: {
|
|
2338
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2339
|
-
responsive: {
|
|
2340
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2341
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2342
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2343
|
-
},
|
|
2344
|
-
},
|
|
2345
|
-
widgets: [
|
|
2346
|
-
{
|
|
2347
|
-
id: "${themeId}-header",
|
|
2348
|
-
name: "Header",
|
|
2349
|
-
type: WIDGET_TYPES.Header,
|
|
2350
|
-
settings: {
|
|
2351
|
-
variant: "v1",
|
|
2352
|
-
logo: "t:common.logo",
|
|
2353
|
-
},
|
|
2354
|
-
},
|
|
2355
|
-
],
|
|
2356
|
-
},
|
|
2357
|
-
|
|
2358
|
-
// Hero Section
|
|
2359
|
-
{
|
|
2360
|
-
id: "hero-section",
|
|
2361
|
-
name: "Hero",
|
|
2362
|
-
type: SECTION_TYPES.HERO_SECTION,
|
|
2363
|
-
settings: {
|
|
2364
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2365
|
-
responsive: {
|
|
2366
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2367
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2368
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2369
|
-
},
|
|
2370
|
-
},
|
|
2371
|
-
widgets: [],
|
|
2372
|
-
},
|
|
2373
|
-
|
|
2374
|
-
// Footer Section
|
|
2375
|
-
{
|
|
2376
|
-
id: "footer-section",
|
|
2377
|
-
name: "Footer",
|
|
2378
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2379
|
-
settings: {
|
|
2380
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2381
|
-
responsive: {
|
|
2382
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2383
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2384
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2385
|
-
},
|
|
2386
|
-
},
|
|
2387
|
-
widgets: [
|
|
2388
|
-
{
|
|
2389
|
-
id: "${themeId}-footer",
|
|
2390
|
-
name: "Footer",
|
|
2391
|
-
type: WIDGET_TYPES.Footer,
|
|
2392
|
-
settings: { variant: "v1" },
|
|
2393
|
-
},
|
|
2394
|
-
],
|
|
2395
|
-
},
|
|
2396
|
-
],
|
|
2397
|
-
};
|
|
2398
|
-
`;
|
|
2399
|
-
}
|
|
2400
|
-
function generateHomeBTemplate(themeId, merchantName) {
|
|
2319
|
+
function generatePageTemplate(themeId, templateName, merchantName) {
|
|
2320
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
2321
|
+
const pageTitle = templateName.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
2401
2322
|
return `import type { PageConfig } from "@shopkit/builder";
|
|
2402
2323
|
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2403
2324
|
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS } from "@shopkit/builder";
|
|
2404
2325
|
|
|
2405
2326
|
/**
|
|
2406
|
-
*
|
|
2327
|
+
* ${pageTitle} Page Template for ${merchantName}
|
|
2407
2328
|
*/
|
|
2408
2329
|
export const template: PageConfig = {
|
|
2409
|
-
id: "${themeId}
|
|
2330
|
+
id: "${themeId}-${templateName}",
|
|
2410
2331
|
dataSources: {},
|
|
2411
2332
|
sections: [
|
|
2412
2333
|
// Header Section
|
|
@@ -2432,96 +2353,13 @@ export const template: PageConfig = {
|
|
|
2432
2353
|
],
|
|
2433
2354
|
},
|
|
2434
2355
|
|
|
2435
|
-
//
|
|
2436
|
-
{
|
|
2437
|
-
id: "hero-section-b",
|
|
2438
|
-
name: "Hero B",
|
|
2439
|
-
type: SECTION_TYPES.HERO_SECTION,
|
|
2440
|
-
settings: {
|
|
2441
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2442
|
-
responsive: {
|
|
2443
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2444
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2445
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2446
|
-
},
|
|
2447
|
-
},
|
|
2448
|
-
widgets: [],
|
|
2449
|
-
},
|
|
2450
|
-
|
|
2451
|
-
// Footer Section
|
|
2452
|
-
{
|
|
2453
|
-
id: "footer-section",
|
|
2454
|
-
name: "Footer",
|
|
2455
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2456
|
-
settings: {
|
|
2457
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2458
|
-
responsive: {
|
|
2459
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2460
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2461
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2462
|
-
},
|
|
2463
|
-
},
|
|
2464
|
-
widgets: [
|
|
2465
|
-
{
|
|
2466
|
-
id: "${themeId}-footer",
|
|
2467
|
-
name: "Footer",
|
|
2468
|
-
type: WIDGET_TYPES.Footer,
|
|
2469
|
-
settings: { variant: "v1" },
|
|
2470
|
-
},
|
|
2471
|
-
],
|
|
2472
|
-
},
|
|
2473
|
-
],
|
|
2474
|
-
};
|
|
2475
|
-
`;
|
|
2476
|
-
}
|
|
2477
|
-
function generateProductsTemplate(themeId, merchantName) {
|
|
2478
|
-
return `import type { PageConfig } from "@shopkit/builder";
|
|
2479
|
-
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2480
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS, DATA_SOURCE_TYPES } from "@shopkit/builder";
|
|
2481
|
-
|
|
2482
|
-
/**
|
|
2483
|
-
* Product Page Template for ${merchantName}
|
|
2484
|
-
*/
|
|
2485
|
-
export const template: PageConfig = {
|
|
2486
|
-
id: "${themeId}-product",
|
|
2487
|
-
dataSources: {
|
|
2488
|
-
product: {
|
|
2489
|
-
type: DATA_SOURCE_TYPES.PRODUCT,
|
|
2490
|
-
params: { handle: "{{productHandle}}" },
|
|
2491
|
-
required: true,
|
|
2492
|
-
},
|
|
2493
|
-
},
|
|
2494
|
-
sections: [
|
|
2495
|
-
// Header Section
|
|
2496
|
-
{
|
|
2497
|
-
id: "header-section",
|
|
2498
|
-
name: "Header",
|
|
2499
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2500
|
-
settings: {
|
|
2501
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2502
|
-
responsive: {
|
|
2503
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2504
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2505
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2506
|
-
},
|
|
2507
|
-
},
|
|
2508
|
-
widgets: [
|
|
2509
|
-
{
|
|
2510
|
-
id: "${themeId}-header",
|
|
2511
|
-
name: "Header",
|
|
2512
|
-
type: WIDGET_TYPES.Header,
|
|
2513
|
-
settings: { variant: "v1" },
|
|
2514
|
-
},
|
|
2515
|
-
],
|
|
2516
|
-
},
|
|
2517
|
-
|
|
2518
|
-
// Product Info Section
|
|
2356
|
+
// Main Content Section
|
|
2519
2357
|
{
|
|
2520
|
-
id: "
|
|
2521
|
-
name: "
|
|
2358
|
+
id: "main-content-section",
|
|
2359
|
+
name: "Main Content",
|
|
2522
2360
|
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2523
2361
|
settings: {
|
|
2524
|
-
layout: SECTION_LAYOUT_OPTIONS.
|
|
2362
|
+
layout: SECTION_LAYOUT_OPTIONS.PAGE,
|
|
2525
2363
|
responsive: {
|
|
2526
2364
|
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2527
2365
|
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
@@ -2530,18 +2368,14 @@ export const template: PageConfig = {
|
|
|
2530
2368
|
},
|
|
2531
2369
|
widgets: [
|
|
2532
2370
|
{
|
|
2533
|
-
id: "${themeId}-
|
|
2534
|
-
name: "
|
|
2535
|
-
type: WIDGET_TYPES.
|
|
2536
|
-
settings: {
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
name: "Product Info",
|
|
2542
|
-
type: WIDGET_TYPES.ProductInfo,
|
|
2543
|
-
settings: { variant: "v1" },
|
|
2544
|
-
dataSourceKey: "product",
|
|
2371
|
+
id: "${themeId}-${templateName}-content",
|
|
2372
|
+
name: "Page Content",
|
|
2373
|
+
type: WIDGET_TYPES.PageContent,
|
|
2374
|
+
settings: {
|
|
2375
|
+
variant: "v1",
|
|
2376
|
+
heading: "t:${keyName}.heading",
|
|
2377
|
+
description: "t:${keyName}.description",
|
|
2378
|
+
},
|
|
2545
2379
|
},
|
|
2546
2380
|
],
|
|
2547
2381
|
},
|
|
@@ -2572,285 +2406,26 @@ export const template: PageConfig = {
|
|
|
2572
2406
|
};
|
|
2573
2407
|
`;
|
|
2574
2408
|
}
|
|
2409
|
+
function generateHomeTemplate(themeId, merchantName) {
|
|
2410
|
+
return generatePageTemplate(themeId, "home", merchantName);
|
|
2411
|
+
}
|
|
2412
|
+
function generateHomeBTemplate(themeId, merchantName) {
|
|
2413
|
+
return generatePageTemplate(themeId, "home-b", merchantName);
|
|
2414
|
+
}
|
|
2415
|
+
function generateProductsTemplate(themeId, merchantName) {
|
|
2416
|
+
return generatePageTemplate(themeId, "products", merchantName);
|
|
2417
|
+
}
|
|
2575
2418
|
function generateProductsBTemplate(themeId, merchantName) {
|
|
2576
|
-
return
|
|
2577
|
-
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2578
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS, DATA_SOURCE_TYPES } from "@shopkit/builder";
|
|
2579
|
-
|
|
2580
|
-
/**
|
|
2581
|
-
* Product Page Template B (Variant) for ${merchantName}
|
|
2582
|
-
*/
|
|
2583
|
-
export const template: PageConfig = {
|
|
2584
|
-
id: "${themeId}-product-b",
|
|
2585
|
-
dataSources: {
|
|
2586
|
-
product: {
|
|
2587
|
-
type: DATA_SOURCE_TYPES.PRODUCT,
|
|
2588
|
-
params: { handle: "{{productHandle}}" },
|
|
2589
|
-
required: true,
|
|
2590
|
-
},
|
|
2591
|
-
},
|
|
2592
|
-
sections: [
|
|
2593
|
-
// Header Section
|
|
2594
|
-
{
|
|
2595
|
-
id: "header-section",
|
|
2596
|
-
name: "Header",
|
|
2597
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2598
|
-
settings: {
|
|
2599
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2600
|
-
responsive: {
|
|
2601
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2602
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2603
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2604
|
-
},
|
|
2605
|
-
},
|
|
2606
|
-
widgets: [
|
|
2607
|
-
{
|
|
2608
|
-
id: "${themeId}-header",
|
|
2609
|
-
name: "Header",
|
|
2610
|
-
type: WIDGET_TYPES.Header,
|
|
2611
|
-
settings: { variant: "v1" },
|
|
2612
|
-
},
|
|
2613
|
-
],
|
|
2614
|
-
},
|
|
2615
|
-
|
|
2616
|
-
// Product Info Section B
|
|
2617
|
-
{
|
|
2618
|
-
id: "product-info-section-b",
|
|
2619
|
-
name: "Product Info B",
|
|
2620
|
-
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2621
|
-
settings: {
|
|
2622
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2623
|
-
responsive: {
|
|
2624
|
-
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2625
|
-
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
2626
|
-
desktop: { padding: { top: 32, right: 32, bottom: 32, left: 32 } },
|
|
2627
|
-
},
|
|
2628
|
-
},
|
|
2629
|
-
widgets: [
|
|
2630
|
-
{
|
|
2631
|
-
id: "${themeId}-product-info-b",
|
|
2632
|
-
name: "Product Info",
|
|
2633
|
-
type: WIDGET_TYPES.ProductInfo,
|
|
2634
|
-
settings: { variant: "v1" },
|
|
2635
|
-
dataSourceKey: "product",
|
|
2636
|
-
},
|
|
2637
|
-
{
|
|
2638
|
-
id: "${themeId}-product-gallery-b",
|
|
2639
|
-
name: "Product Gallery",
|
|
2640
|
-
type: WIDGET_TYPES.ProductGallery,
|
|
2641
|
-
settings: { variant: "v1" },
|
|
2642
|
-
dataSourceKey: "product",
|
|
2643
|
-
},
|
|
2644
|
-
],
|
|
2645
|
-
},
|
|
2646
|
-
|
|
2647
|
-
// Footer Section
|
|
2648
|
-
{
|
|
2649
|
-
id: "footer-section",
|
|
2650
|
-
name: "Footer",
|
|
2651
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2652
|
-
settings: {
|
|
2653
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2654
|
-
responsive: {
|
|
2655
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2656
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2657
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2658
|
-
},
|
|
2659
|
-
},
|
|
2660
|
-
widgets: [
|
|
2661
|
-
{
|
|
2662
|
-
id: "${themeId}-footer",
|
|
2663
|
-
name: "Footer",
|
|
2664
|
-
type: WIDGET_TYPES.Footer,
|
|
2665
|
-
settings: { variant: "v1" },
|
|
2666
|
-
},
|
|
2667
|
-
],
|
|
2668
|
-
},
|
|
2669
|
-
],
|
|
2670
|
-
};
|
|
2671
|
-
`;
|
|
2419
|
+
return generatePageTemplate(themeId, "products-b", merchantName);
|
|
2672
2420
|
}
|
|
2673
2421
|
function generateCollectionTemplate(themeId, merchantName) {
|
|
2674
|
-
return
|
|
2675
|
-
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
2676
|
-
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS, DATA_SOURCE_TYPES } from "@shopkit/builder";
|
|
2677
|
-
|
|
2678
|
-
/**
|
|
2679
|
-
* Collection Page Template for ${merchantName}
|
|
2680
|
-
*/
|
|
2681
|
-
export const template: PageConfig = {
|
|
2682
|
-
id: "${themeId}-collection",
|
|
2683
|
-
dataSources: {
|
|
2684
|
-
collection: {
|
|
2685
|
-
type: DATA_SOURCE_TYPES.COLLECTION,
|
|
2686
|
-
params: { handle: "{{collectionHandle}}" },
|
|
2687
|
-
required: true,
|
|
2688
|
-
},
|
|
2689
|
-
},
|
|
2690
|
-
sections: [
|
|
2691
|
-
// Header Section
|
|
2692
|
-
{
|
|
2693
|
-
id: "header-section",
|
|
2694
|
-
name: "Header",
|
|
2695
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2696
|
-
settings: {
|
|
2697
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2698
|
-
responsive: {
|
|
2699
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2700
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2701
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2702
|
-
},
|
|
2703
|
-
},
|
|
2704
|
-
widgets: [
|
|
2705
|
-
{
|
|
2706
|
-
id: "${themeId}-header",
|
|
2707
|
-
name: "Header",
|
|
2708
|
-
type: WIDGET_TYPES.Header,
|
|
2709
|
-
settings: { variant: "v1" },
|
|
2710
|
-
},
|
|
2711
|
-
],
|
|
2712
|
-
},
|
|
2713
|
-
|
|
2714
|
-
// Collection Content Section
|
|
2715
|
-
{
|
|
2716
|
-
id: "collection-content-section",
|
|
2717
|
-
name: "Collection Products",
|
|
2718
|
-
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2719
|
-
settings: {
|
|
2720
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2721
|
-
responsive: {
|
|
2722
|
-
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2723
|
-
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
2724
|
-
desktop: { padding: { top: 32, right: 32, bottom: 32, left: 32 } },
|
|
2725
|
-
},
|
|
2726
|
-
},
|
|
2727
|
-
widgets: [
|
|
2728
|
-
{
|
|
2729
|
-
id: "${themeId}-collection-widget",
|
|
2730
|
-
name: "Collection Products",
|
|
2731
|
-
type: WIDGET_TYPES.CollectionWidget,
|
|
2732
|
-
settings: { variant: "v1" },
|
|
2733
|
-
dataSourceKey: "collection",
|
|
2734
|
-
},
|
|
2735
|
-
],
|
|
2736
|
-
},
|
|
2737
|
-
|
|
2738
|
-
// Footer Section
|
|
2739
|
-
{
|
|
2740
|
-
id: "footer-section",
|
|
2741
|
-
name: "Footer",
|
|
2742
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2743
|
-
settings: {
|
|
2744
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2745
|
-
responsive: {
|
|
2746
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2747
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2748
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2749
|
-
},
|
|
2750
|
-
},
|
|
2751
|
-
widgets: [
|
|
2752
|
-
{
|
|
2753
|
-
id: "${themeId}-footer",
|
|
2754
|
-
name: "Footer",
|
|
2755
|
-
type: WIDGET_TYPES.Footer,
|
|
2756
|
-
settings: { variant: "v1" },
|
|
2757
|
-
},
|
|
2758
|
-
],
|
|
2759
|
-
},
|
|
2760
|
-
],
|
|
2761
|
-
};
|
|
2762
|
-
`;
|
|
2422
|
+
return generatePageTemplate(themeId, "collection", merchantName);
|
|
2763
2423
|
}
|
|
2764
2424
|
function generateCollectionBTemplate(themeId, merchantName) {
|
|
2765
|
-
return
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
/**
|
|
2770
|
-
* Collection Page Template B (Variant) for ${merchantName}
|
|
2771
|
-
*/
|
|
2772
|
-
export const template: PageConfig = {
|
|
2773
|
-
id: "${themeId}-collection-b",
|
|
2774
|
-
dataSources: {
|
|
2775
|
-
collection: {
|
|
2776
|
-
type: DATA_SOURCE_TYPES.COLLECTION,
|
|
2777
|
-
params: { handle: "{{collectionHandle}}" },
|
|
2778
|
-
required: true,
|
|
2779
|
-
},
|
|
2780
|
-
},
|
|
2781
|
-
sections: [
|
|
2782
|
-
// Header Section
|
|
2783
|
-
{
|
|
2784
|
-
id: "header-section",
|
|
2785
|
-
name: "Header",
|
|
2786
|
-
type: SECTION_TYPES.HEADER_SECTION,
|
|
2787
|
-
settings: {
|
|
2788
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2789
|
-
responsive: {
|
|
2790
|
-
mobile: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2791
|
-
tablet: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2792
|
-
desktop: { padding: { top: 0, right: 0, bottom: 0, left: 0 } },
|
|
2793
|
-
},
|
|
2794
|
-
},
|
|
2795
|
-
widgets: [
|
|
2796
|
-
{
|
|
2797
|
-
id: "${themeId}-header",
|
|
2798
|
-
name: "Header",
|
|
2799
|
-
type: WIDGET_TYPES.Header,
|
|
2800
|
-
settings: { variant: "v1" },
|
|
2801
|
-
},
|
|
2802
|
-
],
|
|
2803
|
-
},
|
|
2804
|
-
|
|
2805
|
-
// Collection Content Section B
|
|
2806
|
-
{
|
|
2807
|
-
id: "collection-content-section-b",
|
|
2808
|
-
name: "Collection Products B",
|
|
2809
|
-
type: SECTION_TYPES.CONTENT_SECTION,
|
|
2810
|
-
settings: {
|
|
2811
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2812
|
-
responsive: {
|
|
2813
|
-
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
2814
|
-
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
2815
|
-
desktop: { padding: { top: 32, right: 32, bottom: 32, left: 32 } },
|
|
2816
|
-
},
|
|
2817
|
-
},
|
|
2818
|
-
widgets: [
|
|
2819
|
-
{
|
|
2820
|
-
id: "${themeId}-collection-widget-b",
|
|
2821
|
-
name: "Collection Products",
|
|
2822
|
-
type: WIDGET_TYPES.CollectionWidget,
|
|
2823
|
-
settings: { variant: "v1" },
|
|
2824
|
-
dataSourceKey: "collection",
|
|
2825
|
-
},
|
|
2826
|
-
],
|
|
2827
|
-
},
|
|
2828
|
-
|
|
2829
|
-
// Footer Section
|
|
2830
|
-
{
|
|
2831
|
-
id: "footer-section",
|
|
2832
|
-
name: "Footer",
|
|
2833
|
-
type: SECTION_TYPES.FOOTER_SECTION,
|
|
2834
|
-
settings: {
|
|
2835
|
-
layout: SECTION_LAYOUT_OPTIONS.FULL,
|
|
2836
|
-
responsive: {
|
|
2837
|
-
mobile: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2838
|
-
tablet: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2839
|
-
desktop: { padding: { top: 20, right: 0, bottom: 0, left: 0 } },
|
|
2840
|
-
},
|
|
2841
|
-
},
|
|
2842
|
-
widgets: [
|
|
2843
|
-
{
|
|
2844
|
-
id: "${themeId}-footer",
|
|
2845
|
-
name: "Footer",
|
|
2846
|
-
type: WIDGET_TYPES.Footer,
|
|
2847
|
-
settings: { variant: "v1" },
|
|
2848
|
-
},
|
|
2849
|
-
],
|
|
2850
|
-
},
|
|
2851
|
-
],
|
|
2852
|
-
};
|
|
2853
|
-
`;
|
|
2425
|
+
return generatePageTemplate(themeId, "collection-b", merchantName);
|
|
2426
|
+
}
|
|
2427
|
+
function generateOrdersTemplate(themeId, merchantName) {
|
|
2428
|
+
return generatePageTemplate(themeId, "orders", merchantName);
|
|
2854
2429
|
}
|
|
2855
2430
|
function generateVariantRegistry() {
|
|
2856
2431
|
return `/**
|
|
@@ -2880,6 +2455,9 @@ export const variantRegistry = {
|
|
|
2880
2455
|
[TEMPLATE_TYPES["collection-b"]]: {
|
|
2881
2456
|
default: () => import("./collection-b/default").then((m) => m.template),
|
|
2882
2457
|
},
|
|
2458
|
+
[TEMPLATE_TYPES.orders]: {
|
|
2459
|
+
default: () => import("./orders/default").then((m) => m.template),
|
|
2460
|
+
},
|
|
2883
2461
|
};
|
|
2884
2462
|
`;
|
|
2885
2463
|
}
|
|
@@ -2888,60 +2466,24 @@ function generateCommonLocale(merchantName) {
|
|
|
2888
2466
|
{
|
|
2889
2467
|
common: {
|
|
2890
2468
|
logo: `/images/${toKebabCase(merchantName)}/logo.svg`,
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
{ label: "Products", href: "/collections/all" },
|
|
2895
|
-
{ label: "About", href: "/pages/about" },
|
|
2896
|
-
{ label: "Contact", href: "/pages/contact" }
|
|
2897
|
-
]
|
|
2898
|
-
},
|
|
2899
|
-
footer: {
|
|
2900
|
-
copyright: `\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} ${merchantName}. All rights reserved.`,
|
|
2901
|
-
socialLinks: [
|
|
2902
|
-
{ platform: "instagram", url: "#", icon: "instagram" },
|
|
2903
|
-
{ platform: "facebook", url: "#", icon: "facebook" },
|
|
2904
|
-
{ platform: "twitter", url: "#", icon: "twitter" }
|
|
2905
|
-
],
|
|
2906
|
-
links: [
|
|
2907
|
-
{
|
|
2908
|
-
title: "Shop",
|
|
2909
|
-
items: [
|
|
2910
|
-
{ label: "All Products", href: "/collections/all" },
|
|
2911
|
-
{ label: "New Arrivals", href: "/collections/new-arrivals" }
|
|
2912
|
-
]
|
|
2913
|
-
},
|
|
2914
|
-
{
|
|
2915
|
-
title: "Support",
|
|
2916
|
-
items: [
|
|
2917
|
-
{ label: "Contact Us", href: "/pages/contact" },
|
|
2918
|
-
{ label: "FAQs", href: "/pages/faqs" }
|
|
2919
|
-
]
|
|
2920
|
-
}
|
|
2921
|
-
]
|
|
2922
|
-
},
|
|
2923
|
-
addToCartButtonText: "Add to Cart",
|
|
2924
|
-
goToCartText: "Go to Cart"
|
|
2469
|
+
site_name: merchantName,
|
|
2470
|
+
add_to_cart: "Add to Cart",
|
|
2471
|
+
go_to_cart: "Go to Cart"
|
|
2925
2472
|
}
|
|
2926
2473
|
},
|
|
2927
2474
|
null,
|
|
2928
2475
|
2
|
|
2929
2476
|
);
|
|
2930
2477
|
}
|
|
2931
|
-
function
|
|
2478
|
+
function generatePageLocale(templateName) {
|
|
2479
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
2480
|
+
const pageTitle = templateName.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
2932
2481
|
return JSON.stringify(
|
|
2933
2482
|
{
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
},
|
|
2939
|
-
sections: {
|
|
2940
|
-
featured: {
|
|
2941
|
-
title: "Featured Products",
|
|
2942
|
-
viewAllLink: "/collections/featured"
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2483
|
+
[keyName]: {
|
|
2484
|
+
page_title: `${pageTitle} Page`,
|
|
2485
|
+
heading: pageTitle,
|
|
2486
|
+
description: `Welcome to the ${pageTitle} page.`
|
|
2945
2487
|
}
|
|
2946
2488
|
},
|
|
2947
2489
|
null,
|
|
@@ -2997,10 +2539,17 @@ ${colors.bold(` \u{1F3A8} Creating Theme: ${colors.cyan(merchantName)}`)}
|
|
|
2997
2539
|
path.join(themeDir, "templates", "products-b"),
|
|
2998
2540
|
path.join(themeDir, "templates", "collection"),
|
|
2999
2541
|
path.join(themeDir, "templates", "collection-b"),
|
|
2542
|
+
path.join(themeDir, "templates", "orders"),
|
|
3000
2543
|
path.join(themeDir, "locales"),
|
|
3001
2544
|
path.join(themeDir, "locales", "common"),
|
|
3002
2545
|
path.join(themeDir, "locales", "pages"),
|
|
3003
|
-
path.join(themeDir, "locales", "pages", "home")
|
|
2546
|
+
path.join(themeDir, "locales", "pages", "home"),
|
|
2547
|
+
path.join(themeDir, "locales", "pages", "home-b"),
|
|
2548
|
+
path.join(themeDir, "locales", "pages", "products"),
|
|
2549
|
+
path.join(themeDir, "locales", "pages", "products-b"),
|
|
2550
|
+
path.join(themeDir, "locales", "pages", "collections"),
|
|
2551
|
+
path.join(themeDir, "locales", "pages", "collections-b"),
|
|
2552
|
+
path.join(themeDir, "locales", "pages", "orders")
|
|
3004
2553
|
];
|
|
3005
2554
|
for (const dir of dirs) {
|
|
3006
2555
|
ensureDir(dir);
|
|
@@ -3055,6 +2604,10 @@ ${colors.bold(` \u{1F3A8} Creating Theme: ${colors.cyan(merchantName)}`)}
|
|
|
3055
2604
|
path: path.join(themeDir, "templates", "collection-b", "default.ts"),
|
|
3056
2605
|
content: generateCollectionBTemplate(themeId, merchantName)
|
|
3057
2606
|
},
|
|
2607
|
+
{
|
|
2608
|
+
path: path.join(themeDir, "templates", "orders", "default.ts"),
|
|
2609
|
+
content: generateOrdersTemplate(themeId, merchantName)
|
|
2610
|
+
},
|
|
3058
2611
|
{
|
|
3059
2612
|
path: path.join(themeDir, "templates", "variant-registry.ts"),
|
|
3060
2613
|
content: generateVariantRegistry()
|
|
@@ -3065,7 +2618,31 @@ ${colors.bold(` \u{1F3A8} Creating Theme: ${colors.cyan(merchantName)}`)}
|
|
|
3065
2618
|
},
|
|
3066
2619
|
{
|
|
3067
2620
|
path: path.join(themeDir, "locales", "pages", "home", `${defaultLang}.json`),
|
|
3068
|
-
content:
|
|
2621
|
+
content: generatePageLocale("home")
|
|
2622
|
+
},
|
|
2623
|
+
{
|
|
2624
|
+
path: path.join(themeDir, "locales", "pages", "home-b", `${defaultLang}.json`),
|
|
2625
|
+
content: generatePageLocale("home-b")
|
|
2626
|
+
},
|
|
2627
|
+
{
|
|
2628
|
+
path: path.join(themeDir, "locales", "pages", "products", `${defaultLang}.json`),
|
|
2629
|
+
content: generatePageLocale("products")
|
|
2630
|
+
},
|
|
2631
|
+
{
|
|
2632
|
+
path: path.join(themeDir, "locales", "pages", "products-b", `${defaultLang}.json`),
|
|
2633
|
+
content: generatePageLocale("products-b")
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
path: path.join(themeDir, "locales", "pages", "collections", `${defaultLang}.json`),
|
|
2637
|
+
content: generatePageLocale("collections")
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
path: path.join(themeDir, "locales", "pages", "collections-b", `${defaultLang}.json`),
|
|
2641
|
+
content: generatePageLocale("collections-b")
|
|
2642
|
+
},
|
|
2643
|
+
{
|
|
2644
|
+
path: path.join(themeDir, "locales", "pages", "orders", `${defaultLang}.json`),
|
|
2645
|
+
content: generatePageLocale("orders")
|
|
3069
2646
|
}
|
|
3070
2647
|
];
|
|
3071
2648
|
for (const file of files) {
|
|
@@ -3119,7 +2696,23 @@ function parseTemplateArgs() {
|
|
|
3119
2696
|
}
|
|
3120
2697
|
return result;
|
|
3121
2698
|
}
|
|
2699
|
+
function generateTemplateLocale(templateName) {
|
|
2700
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
2701
|
+
const pageTitle = templateName.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
2702
|
+
return JSON.stringify(
|
|
2703
|
+
{
|
|
2704
|
+
[keyName]: {
|
|
2705
|
+
page_title: `${pageTitle} Page`,
|
|
2706
|
+
heading: pageTitle,
|
|
2707
|
+
description: `Welcome to the ${pageTitle} page.`
|
|
2708
|
+
}
|
|
2709
|
+
},
|
|
2710
|
+
null,
|
|
2711
|
+
2
|
|
2712
|
+
);
|
|
2713
|
+
}
|
|
3122
2714
|
function generateTemplateContent(selectedTheme, templateName) {
|
|
2715
|
+
const keyName = templateName.replace(/-/g, "_");
|
|
3123
2716
|
return `import type { PageConfig } from "@shopkit/builder";
|
|
3124
2717
|
import { WIDGET_TYPES } from "@/widgets/.generated/types";
|
|
3125
2718
|
import { SECTION_TYPES, SECTION_LAYOUT_OPTIONS } from "@shopkit/builder";
|
|
@@ -3162,7 +2755,7 @@ export const template: PageConfig = {
|
|
|
3162
2755
|
name: "Main Content",
|
|
3163
2756
|
type: SECTION_TYPES.CONTENT_SECTION,
|
|
3164
2757
|
settings: {
|
|
3165
|
-
layout: SECTION_LAYOUT_OPTIONS.
|
|
2758
|
+
layout: SECTION_LAYOUT_OPTIONS.PAGE,
|
|
3166
2759
|
responsive: {
|
|
3167
2760
|
mobile: { padding: { top: 16, right: 16, bottom: 16, left: 16 } },
|
|
3168
2761
|
tablet: { padding: { top: 24, right: 24, bottom: 24, left: 24 } },
|
|
@@ -3170,7 +2763,16 @@ export const template: PageConfig = {
|
|
|
3170
2763
|
},
|
|
3171
2764
|
},
|
|
3172
2765
|
widgets: [
|
|
3173
|
-
|
|
2766
|
+
{
|
|
2767
|
+
id: "${selectedTheme}-${templateName}-content",
|
|
2768
|
+
name: "Page Content",
|
|
2769
|
+
type: WIDGET_TYPES.PageContent,
|
|
2770
|
+
settings: {
|
|
2771
|
+
variant: "v1",
|
|
2772
|
+
heading: "t:${keyName}.heading",
|
|
2773
|
+
description: "t:${keyName}.description",
|
|
2774
|
+
},
|
|
2775
|
+
},
|
|
3174
2776
|
],
|
|
3175
2777
|
},
|
|
3176
2778
|
|
|
@@ -3265,6 +2867,24 @@ ${colors.bold(" \u{1F4C4} Create New Template")}
|
|
|
3265
2867
|
`
|
|
3266
2868
|
${colors.green("\u2713")} Created template: src/themes/${selectedTheme}/templates/${templateName}/default.ts`
|
|
3267
2869
|
);
|
|
2870
|
+
const localeDir = path.join(themesDir, selectedTheme, "locales", "pages", templateName);
|
|
2871
|
+
ensureDir(localeDir);
|
|
2872
|
+
const themeJsonPath = path.join(themesDir, selectedTheme, "theme.json");
|
|
2873
|
+
let supportedLanguages = ["en"];
|
|
2874
|
+
if (exists(themeJsonPath)) {
|
|
2875
|
+
try {
|
|
2876
|
+
const themeConfig = JSON.parse(readFile(themeJsonPath));
|
|
2877
|
+
if (themeConfig.supportedLanguages?.length > 0) {
|
|
2878
|
+
supportedLanguages = themeConfig.supportedLanguages;
|
|
2879
|
+
}
|
|
2880
|
+
} catch (e) {
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
const localeContent = generateTemplateLocale(templateName);
|
|
2884
|
+
for (const lang of supportedLanguages) {
|
|
2885
|
+
writeFile(path.join(localeDir, `${lang}.json`), localeContent);
|
|
2886
|
+
}
|
|
2887
|
+
log.success(`Created locale files for: ${supportedLanguages.join(", ")}`);
|
|
3268
2888
|
const variantRegistryPath = path.join(
|
|
3269
2889
|
themesDir,
|
|
3270
2890
|
selectedTheme,
|
|
@@ -3298,6 +2918,14 @@ ${colors.bold(" Generating template types...")}
|
|
|
3298
2918
|
} else {
|
|
3299
2919
|
log.warn(`Run ${colors.cyan("bun run generate:templates")} manually`);
|
|
3300
2920
|
}
|
|
2921
|
+
console.log(`
|
|
2922
|
+
${colors.bold(" Generating i18n manifest...")}
|
|
2923
|
+
`);
|
|
2924
|
+
if (runGenerator("i18n")) {
|
|
2925
|
+
log.success("i18n manifest regenerated");
|
|
2926
|
+
} else {
|
|
2927
|
+
log.warn(`Run ${colors.cyan("bun run generate:i18n")} manually`);
|
|
2928
|
+
}
|
|
3301
2929
|
console.log(
|
|
3302
2930
|
`
|
|
3303
2931
|
${colors.green(colors.bold(` \u2705 Template "${templateName}" created successfully!`))}
|