@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/README.md
CHANGED
|
@@ -48,6 +48,127 @@ bun run validate:template --theme=dawn
|
|
|
48
48
|
bun run cli
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
## Theme Generator Output
|
|
52
|
+
|
|
53
|
+
Running `bun run g theme <name>` creates the following structure:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
src/themes/{theme-id}/
|
|
57
|
+
├── theme.json # Theme configuration
|
|
58
|
+
├── templates/
|
|
59
|
+
│ ├── home/default.ts # Home page template
|
|
60
|
+
│ ├── home-b/default.ts # Home A/B variant
|
|
61
|
+
│ ├── products/default.ts # Products page template
|
|
62
|
+
│ ├── products-b/default.ts # Products A/B variant
|
|
63
|
+
│ ├── collection/default.ts # Collection page template
|
|
64
|
+
│ ├── collection-b/default.ts # Collection A/B variant
|
|
65
|
+
│ ├── orders/default.ts # Orders/Thank You page
|
|
66
|
+
│ └── variant-registry.ts # Template registry
|
|
67
|
+
└── locales/
|
|
68
|
+
├── common/{lang}.json # Common translations (logo, site_name, etc.)
|
|
69
|
+
└── pages/
|
|
70
|
+
├── home/{lang}.json
|
|
71
|
+
├── home-b/{lang}.json
|
|
72
|
+
├── products/{lang}.json
|
|
73
|
+
├── products-b/{lang}.json
|
|
74
|
+
├── collections/{lang}.json
|
|
75
|
+
├── collections-b/{lang}.json
|
|
76
|
+
└── orders/{lang}.json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Template Structure
|
|
80
|
+
|
|
81
|
+
All generated templates follow this consistent pattern:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Each template has three sections:
|
|
85
|
+
{
|
|
86
|
+
sections: [
|
|
87
|
+
// 1. Header Section
|
|
88
|
+
{
|
|
89
|
+
type: SECTION_TYPES.HEADER_SECTION,
|
|
90
|
+
widgets: [{ type: WIDGET_TYPES.Header }]
|
|
91
|
+
},
|
|
92
|
+
// 2. Main Content Section
|
|
93
|
+
{
|
|
94
|
+
type: SECTION_TYPES.CONTENT_SECTION,
|
|
95
|
+
widgets: [{
|
|
96
|
+
type: WIDGET_TYPES.PageContent,
|
|
97
|
+
settings: {
|
|
98
|
+
heading: "t:{page_name}.heading",
|
|
99
|
+
description: "t:{page_name}.description"
|
|
100
|
+
}
|
|
101
|
+
}]
|
|
102
|
+
},
|
|
103
|
+
// 3. Footer Section
|
|
104
|
+
{
|
|
105
|
+
type: SECTION_TYPES.FOOTER_SECTION,
|
|
106
|
+
widgets: [{ type: WIDGET_TYPES.Footer }]
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Translation Key Structure
|
|
113
|
+
|
|
114
|
+
Each page has a corresponding locale file with this structure:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"{page_name}": {
|
|
119
|
+
"page_title": "Page Title",
|
|
120
|
+
"heading": "Page Heading",
|
|
121
|
+
"description": "Welcome to the page."
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Translation keys are referenced in templates using the `t:` prefix:
|
|
127
|
+
- `t:home.heading` - Resolves to the heading from home locale
|
|
128
|
+
- `t:products.description` - Resolves to the description from products locale
|
|
129
|
+
|
|
130
|
+
### Essential Widgets
|
|
131
|
+
|
|
132
|
+
The theme generator creates these essential widgets if they don't exist:
|
|
133
|
+
|
|
134
|
+
| Widget | Purpose |
|
|
135
|
+
|--------|---------|
|
|
136
|
+
| `Header` | Site header with navigation |
|
|
137
|
+
| `Footer` | Site footer with links |
|
|
138
|
+
| `PageContent` | Displays translated heading and description |
|
|
139
|
+
|
|
140
|
+
### A/B Variant Templates
|
|
141
|
+
|
|
142
|
+
Templates with `-b` suffix (home-b, products-b, collection-b) are for A/B testing:
|
|
143
|
+
- Use the same translation structure as their base templates
|
|
144
|
+
- Allow different layouts/widgets for experimentation
|
|
145
|
+
- Can be served to different user segments
|
|
146
|
+
|
|
147
|
+
## Widget Generator Output
|
|
148
|
+
|
|
149
|
+
Running `bun run g widget <name>` creates:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
src/widgets/{scope}/{WidgetName}/
|
|
153
|
+
├── index.tsx # Widget entry point with variant resolution
|
|
154
|
+
├── types.ts # TypeScript interfaces (Settings, Data, Props)
|
|
155
|
+
├── variants.ts # Variant registry
|
|
156
|
+
└── V1/
|
|
157
|
+
└── index.tsx # Default V1 variant component
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Template Generator Output
|
|
161
|
+
|
|
162
|
+
Running `bun run g template <name>` creates:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
src/themes/{theme}/templates/{template-name}/
|
|
166
|
+
└── default.ts # Template configuration
|
|
167
|
+
|
|
168
|
+
src/themes/{theme}/locales/pages/{template-name}/
|
|
169
|
+
└── {lang}.json # Translation file for each supported language
|
|
170
|
+
```
|
|
171
|
+
|
|
51
172
|
## Programmatic Usage
|
|
52
173
|
|
|
53
174
|
```typescript
|
|
@@ -62,6 +183,9 @@ import {
|
|
|
62
183
|
// Generate a widget programmatically
|
|
63
184
|
await generateWidget({ name: "HeroBanner", scope: "common" });
|
|
64
185
|
|
|
186
|
+
// Generate a theme
|
|
187
|
+
await generateTheme({ name: "dawn", lang: "en" });
|
|
188
|
+
|
|
65
189
|
// Validate widgets
|
|
66
190
|
const { passed, errors } = await runWidgetValidation();
|
|
67
191
|
```
|