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