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