ghostcn 1.0.2 → 1.1.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.
Files changed (33) hide show
  1. package/README.md +77 -16
  2. package/dist/commands/add.js +42 -37
  3. package/dist/commands/create.d.ts +5 -0
  4. package/dist/commands/create.js +108 -0
  5. package/dist/commands/init.js +129 -26
  6. package/dist/commands/list.js +4 -4
  7. package/dist/index.js +9 -1
  8. package/dist/registry/components/author-card.json +2 -2
  9. package/dist/registry/components/featured-posts.json +27 -0
  10. package/dist/registry/components/member-cta.json +27 -0
  11. package/dist/registry/components/newsletter-form.json +9 -6
  12. package/dist/registry/components/pagination.json +28 -0
  13. package/dist/registry/components/post-card.json +2 -2
  14. package/dist/registry/components/post-header.json +27 -0
  15. package/dist/registry/components/pricing-table.json +2 -2
  16. package/dist/registry/components/site-footer.json +27 -0
  17. package/dist/registry/components/site-header.json +27 -0
  18. package/dist/registry/index.json +61 -1
  19. package/dist/utils/component-installer.d.ts +16 -0
  20. package/dist/utils/component-installer.js +59 -0
  21. package/dist/utils/registry.d.ts +1 -0
  22. package/dist/utils/registry.js +42 -19
  23. package/dist/utils/theme-files.d.ts +13 -0
  24. package/dist/utils/theme-files.js +104 -0
  25. package/dist/utils/theme-project.d.ts +29 -0
  26. package/dist/utils/theme-project.js +41 -0
  27. package/dist/utils/theme-scaffold.d.ts +21 -0
  28. package/dist/utils/theme-scaffold.js +288 -0
  29. package/dist/utils/theme.d.ts +46 -0
  30. package/dist/utils/theme.js +427 -0
  31. package/package.json +2 -1
  32. package/dist/test/registry.test.d.ts +0 -1
  33. package/dist/test/registry.test.js +0 -62
@@ -0,0 +1,427 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ACCENT_COLORS = exports.BASE_PALETTES = void 0;
4
+ exports.generateThemeCss = generateThemeCss;
5
+ exports.BASE_PALETTES = {
6
+ zinc: {
7
+ light: {
8
+ background: '#ffffff',
9
+ foreground: '#09090b',
10
+ card: '#ffffff',
11
+ cardForeground: '#09090b',
12
+ popover: '#ffffff',
13
+ popoverForeground: '#09090b',
14
+ secondary: '#f4f4f5',
15
+ secondaryForeground: '#18181b',
16
+ muted: '#f4f4f5',
17
+ mutedForeground: '#71717a',
18
+ accent: '#f4f4f5',
19
+ accentForeground: '#18181b',
20
+ destructive: '#ef4444',
21
+ destructiveForeground: '#fafafa',
22
+ border: '#e4e4e7',
23
+ input: '#e4e4e7',
24
+ ring: '#18181b'
25
+ },
26
+ dark: {
27
+ background: '#09090b',
28
+ foreground: '#fafafa',
29
+ card: '#09090b',
30
+ cardForeground: '#fafafa',
31
+ popover: '#09090b',
32
+ popoverForeground: '#fafafa',
33
+ secondary: '#27272a',
34
+ secondaryForeground: '#fafafa',
35
+ muted: '#27272a',
36
+ mutedForeground: '#a1a1aa',
37
+ accent: '#27272a',
38
+ accentForeground: '#fafafa',
39
+ destructive: '#7f1d1d',
40
+ destructiveForeground: '#fafafa',
41
+ border: '#27272a',
42
+ input: '#27272a',
43
+ ring: '#d4d4d8'
44
+ }
45
+ },
46
+ slate: {
47
+ light: {
48
+ background: '#ffffff',
49
+ foreground: '#020817',
50
+ card: '#ffffff',
51
+ cardForeground: '#020817',
52
+ popover: '#ffffff',
53
+ popoverForeground: '#020817',
54
+ secondary: '#f1f5f9',
55
+ secondaryForeground: '#0f172a',
56
+ muted: '#f1f5f9',
57
+ mutedForeground: '#64748b',
58
+ accent: '#f1f5f9',
59
+ accentForeground: '#0f172a',
60
+ destructive: '#ef4444',
61
+ destructiveForeground: '#f8fafc',
62
+ border: '#e2e8f0',
63
+ input: '#e2e8f0',
64
+ ring: '#0f172a'
65
+ },
66
+ dark: {
67
+ background: '#020817',
68
+ foreground: '#f8fafc',
69
+ card: '#020817',
70
+ cardForeground: '#f8fafc',
71
+ popover: '#020817',
72
+ popoverForeground: '#f8fafc',
73
+ secondary: '#1e293b',
74
+ secondaryForeground: '#f8fafc',
75
+ muted: '#1e293b',
76
+ mutedForeground: '#94a3b8',
77
+ accent: '#1e293b',
78
+ accentForeground: '#f8fafc',
79
+ destructive: '#7f1d1d',
80
+ destructiveForeground: '#f8fafc',
81
+ border: '#1e293b',
82
+ input: '#1e293b',
83
+ ring: '#cbd5e1'
84
+ }
85
+ },
86
+ stone: {
87
+ light: {
88
+ background: '#ffffff',
89
+ foreground: '#0c0a09',
90
+ card: '#ffffff',
91
+ cardForeground: '#0c0a09',
92
+ popover: '#ffffff',
93
+ popoverForeground: '#0c0a09',
94
+ secondary: '#f5f5f4',
95
+ secondaryForeground: '#1c1917',
96
+ muted: '#f5f5f4',
97
+ mutedForeground: '#78716c',
98
+ accent: '#f5f5f4',
99
+ accentForeground: '#1c1917',
100
+ destructive: '#ef4444',
101
+ destructiveForeground: '#fafaf9',
102
+ border: '#e7e5e4',
103
+ input: '#e7e5e4',
104
+ ring: '#1c1917'
105
+ },
106
+ dark: {
107
+ background: '#0c0a09',
108
+ foreground: '#fafaf9',
109
+ card: '#0c0a09',
110
+ cardForeground: '#fafaf9',
111
+ popover: '#0c0a09',
112
+ popoverForeground: '#fafaf9',
113
+ secondary: '#292524',
114
+ secondaryForeground: '#fafaf9',
115
+ muted: '#292524',
116
+ mutedForeground: '#a8a29e',
117
+ accent: '#292524',
118
+ accentForeground: '#fafaf9',
119
+ destructive: '#7f1d1d',
120
+ destructiveForeground: '#fafaf9',
121
+ border: '#292524',
122
+ input: '#292524',
123
+ ring: '#d6d3d1'
124
+ }
125
+ },
126
+ gray: {
127
+ light: {
128
+ background: '#ffffff',
129
+ foreground: '#111827',
130
+ card: '#ffffff',
131
+ cardForeground: '#111827',
132
+ popover: '#ffffff',
133
+ popoverForeground: '#111827',
134
+ secondary: '#f3f4f6',
135
+ secondaryForeground: '#1f2937',
136
+ muted: '#f3f4f6',
137
+ mutedForeground: '#6b7280',
138
+ accent: '#f3f4f6',
139
+ accentForeground: '#1f2937',
140
+ destructive: '#ef4444',
141
+ destructiveForeground: '#f9fafb',
142
+ border: '#e5e7eb',
143
+ input: '#e5e7eb',
144
+ ring: '#1f2937'
145
+ },
146
+ dark: {
147
+ background: '#030712',
148
+ foreground: '#f9fafb',
149
+ card: '#030712',
150
+ cardForeground: '#f9fafb',
151
+ popover: '#030712',
152
+ popoverForeground: '#f9fafb',
153
+ secondary: '#1f2937',
154
+ secondaryForeground: '#f9fafb',
155
+ muted: '#1f2937',
156
+ mutedForeground: '#9ca3af',
157
+ accent: '#1f2937',
158
+ accentForeground: '#f9fafb',
159
+ destructive: '#7f1d1d',
160
+ destructiveForeground: '#f9fafb',
161
+ border: '#1f2937',
162
+ input: '#1f2937',
163
+ ring: '#d1d5db'
164
+ }
165
+ },
166
+ neutral: {
167
+ light: {
168
+ background: '#ffffff',
169
+ foreground: '#0a0a0a',
170
+ card: '#ffffff',
171
+ cardForeground: '#0a0a0a',
172
+ popover: '#ffffff',
173
+ popoverForeground: '#0a0a0a',
174
+ secondary: '#f5f5f5',
175
+ secondaryForeground: '#171717',
176
+ muted: '#f5f5f5',
177
+ mutedForeground: '#737373',
178
+ accent: '#f5f5f5',
179
+ accentForeground: '#171717',
180
+ destructive: '#ef4444',
181
+ destructiveForeground: '#fafafa',
182
+ border: '#e5e5e5',
183
+ input: '#e5e5e5',
184
+ ring: '#171717'
185
+ },
186
+ dark: {
187
+ background: '#0a0a0a',
188
+ foreground: '#fafafa',
189
+ card: '#0a0a0a',
190
+ cardForeground: '#fafafa',
191
+ popover: '#0a0a0a',
192
+ popoverForeground: '#fafafa',
193
+ secondary: '#262626',
194
+ secondaryForeground: '#fafafa',
195
+ muted: '#262626',
196
+ mutedForeground: '#a3a3a3',
197
+ accent: '#262626',
198
+ accentForeground: '#fafafa',
199
+ destructive: '#7f1d1d',
200
+ destructiveForeground: '#fafafa',
201
+ border: '#262626',
202
+ input: '#262626',
203
+ ring: '#d4d4d4'
204
+ }
205
+ }
206
+ };
207
+ exports.ACCENT_COLORS = {
208
+ ghost: {
209
+ light: {
210
+ primary: 'var(--ghost-accent-color, #18181b)',
211
+ primaryForeground: '#ffffff',
212
+ ring: 'var(--ghost-accent-color, #18181b)'
213
+ },
214
+ dark: {
215
+ primary: 'var(--ghost-accent-color, #fafafa)',
216
+ primaryForeground: '#09090b',
217
+ ring: 'var(--ghost-accent-color, #d4d4d8)'
218
+ }
219
+ },
220
+ zinc: {
221
+ light: { primary: '#18181b', primaryForeground: '#fafafa', ring: '#18181b' },
222
+ dark: { primary: '#fafafa', primaryForeground: '#18181b', ring: '#d4d4d8' }
223
+ },
224
+ indigo: {
225
+ light: { primary: '#4f46e5', primaryForeground: '#ffffff', ring: '#4f46e5' },
226
+ dark: { primary: '#6366f1', primaryForeground: '#ffffff', ring: '#6366f1' }
227
+ },
228
+ violet: {
229
+ light: { primary: '#7c3aed', primaryForeground: '#ffffff', ring: '#7c3aed' },
230
+ dark: { primary: '#8b5cf6', primaryForeground: '#ffffff', ring: '#8b5cf6' }
231
+ },
232
+ blue: {
233
+ light: { primary: '#2563eb', primaryForeground: '#ffffff', ring: '#2563eb' },
234
+ dark: { primary: '#3b82f6', primaryForeground: '#ffffff', ring: '#3b82f6' }
235
+ },
236
+ emerald: {
237
+ light: { primary: '#059669', primaryForeground: '#ffffff', ring: '#059669' },
238
+ dark: { primary: '#10b981', primaryForeground: '#ffffff', ring: '#10b981' }
239
+ },
240
+ rose: {
241
+ light: { primary: '#e11d48', primaryForeground: '#ffffff', ring: '#e11d48' },
242
+ dark: { primary: '#f43f5e', primaryForeground: '#ffffff', ring: '#f43f5e' }
243
+ },
244
+ orange: {
245
+ light: { primary: '#ea580c', primaryForeground: '#ffffff', ring: '#ea580c' },
246
+ dark: { primary: '#f97316', primaryForeground: '#ffffff', ring: '#f97316' }
247
+ }
248
+ };
249
+ function generateThemeCss(config) {
250
+ const base = exports.BASE_PALETTES[config.baseColor] || exports.BASE_PALETTES.zinc;
251
+ const accent = exports.ACCENT_COLORS[config.accentColor] || exports.ACCENT_COLORS.ghost;
252
+ const radius = config.radius || '0.5rem';
253
+ const darkTokens = `
254
+ color-scheme: dark;
255
+ --background: ${base.dark.background};
256
+ --foreground: ${base.dark.foreground};
257
+ --card: ${base.dark.card};
258
+ --card-foreground: ${base.dark.cardForeground};
259
+ --popover: ${base.dark.popover};
260
+ --popover-foreground: ${base.dark.popoverForeground};
261
+ --primary: ${accent.dark.primary};
262
+ --primary-foreground: ${accent.dark.primaryForeground};
263
+ --secondary: ${base.dark.secondary};
264
+ --secondary-foreground: ${base.dark.secondaryForeground};
265
+ --muted: ${base.dark.muted};
266
+ --muted-foreground: ${base.dark.mutedForeground};
267
+ --accent: ${base.dark.accent};
268
+ --accent-foreground: ${base.dark.accentForeground};
269
+ --destructive: ${base.dark.destructive};
270
+ --destructive-foreground: ${base.dark.destructiveForeground};
271
+ --border: ${base.dark.border};
272
+ --input: ${base.dark.input};
273
+ --ring: ${accent.dark.ring || base.dark.ring};`;
274
+ return `/*
275
+ ghostcn Design Tokens & Theming System
276
+ Base: ${config.baseColor} | Accent: ${config.accentColor} | Radius: ${radius} | System: ${config.style}
277
+ */
278
+
279
+ :root {
280
+ color-scheme: light;
281
+ --background: ${base.light.background};
282
+ --foreground: ${base.light.foreground};
283
+ --card: ${base.light.card};
284
+ --card-foreground: ${base.light.cardForeground};
285
+ --popover: ${base.light.popover};
286
+ --popover-foreground: ${base.light.popoverForeground};
287
+ --primary: ${accent.light.primary};
288
+ --primary-foreground: ${accent.light.primaryForeground};
289
+ --secondary: ${base.light.secondary};
290
+ --secondary-foreground: ${base.light.secondaryForeground};
291
+ --muted: ${base.light.muted};
292
+ --muted-foreground: ${base.light.mutedForeground};
293
+ --accent: ${base.light.accent};
294
+ --accent-foreground: ${base.light.accentForeground};
295
+ --destructive: ${base.light.destructive};
296
+ --destructive-foreground: ${base.light.destructiveForeground};
297
+ --border: ${base.light.border};
298
+ --input: ${base.light.input};
299
+ --ring: ${accent.light.ring || base.light.ring};
300
+ --radius: ${radius};
301
+
302
+ /* Ghost Native Compatibility Fallbacks */
303
+ --ghost-card-bg: var(--card);
304
+ --ghost-border: var(--border);
305
+ --ghost-heading-color: var(--foreground);
306
+ --ghost-text-muted: var(--muted-foreground);
307
+ }
308
+
309
+ .dark, .dark-mode, [data-theme="dark"] {${darkTokens}
310
+ }
311
+
312
+ /* Casper and other Ghost themes use .auto-color for OS-level dark mode. */
313
+ @media (prefers-color-scheme: dark) {
314
+ .auto-color {${darkTokens}
315
+ }
316
+ }
317
+
318
+ /* ghostcn Semantic Utilities (Guarantees zero-breakage across Tailwind & Vanilla CSS) */
319
+ .bg-background { background-color: var(--background); }
320
+ .text-foreground { color: var(--foreground); }
321
+ .bg-card { background-color: var(--card); }
322
+ .text-card-foreground { color: var(--card-foreground); }
323
+ .bg-popover { background-color: var(--popover); }
324
+ .text-popover-foreground { color: var(--popover-foreground); }
325
+ .bg-primary { background-color: var(--primary); }
326
+ .text-primary-foreground { color: var(--primary-foreground); }
327
+ .bg-secondary { background-color: var(--secondary); }
328
+ .text-secondary-foreground { color: var(--secondary-foreground); }
329
+ .bg-muted { background-color: var(--muted); }
330
+ .text-muted-foreground { color: var(--muted-foreground); }
331
+ .bg-accent { background-color: var(--accent); }
332
+ .text-accent-foreground { color: var(--accent-foreground); }
333
+ .border-border { border-color: var(--border); }
334
+ .border-input { border-color: var(--input); }
335
+ .rounded-ghostcn { border-radius: var(--radius); }
336
+
337
+ /* Shared primitives used by ghostcn components. */
338
+ .ghcn-container {
339
+ box-sizing: border-box;
340
+ width: min(100% - 32px, 1152px);
341
+ margin-inline: auto;
342
+ }
343
+ .ghcn-button,
344
+ .ghcn-icon-button {
345
+ box-sizing: border-box;
346
+ display: inline-flex;
347
+ align-items: center;
348
+ justify-content: center;
349
+ gap: 8px;
350
+ min-height: 40px;
351
+ border: 1px solid transparent;
352
+ border-radius: var(--radius);
353
+ padding: 10px 16px;
354
+ color: var(--primary-foreground);
355
+ background: var(--primary);
356
+ font: inherit;
357
+ font-size: 14px;
358
+ font-weight: 600;
359
+ line-height: 1;
360
+ text-decoration: none;
361
+ cursor: pointer;
362
+ transition: opacity 150ms ease, background-color 150ms ease, border-color 150ms ease;
363
+ }
364
+ .ghcn-button:hover,
365
+ .ghcn-icon-button:hover { opacity: 0.9; }
366
+ .ghcn-button:focus-visible,
367
+ .ghcn-icon-button:focus-visible,
368
+ .ghcn-input:focus-visible {
369
+ outline: 2px solid var(--ring);
370
+ outline-offset: 2px;
371
+ }
372
+ .ghcn-button--outline {
373
+ border-color: var(--border);
374
+ color: var(--foreground);
375
+ background: var(--background);
376
+ }
377
+ .ghcn-button--ghost {
378
+ color: var(--foreground);
379
+ background: transparent;
380
+ }
381
+ .ghcn-icon-button {
382
+ width: 40px;
383
+ padding: 0;
384
+ }
385
+ .ghcn-input {
386
+ box-sizing: border-box;
387
+ min-height: 40px;
388
+ width: 100%;
389
+ border: 1px solid var(--input);
390
+ border-radius: var(--radius);
391
+ padding: 10px 14px;
392
+ color: var(--foreground);
393
+ background: var(--background);
394
+ font: inherit;
395
+ font-size: 14px;
396
+ }
397
+ .ghcn-badge {
398
+ display: inline-flex;
399
+ align-items: center;
400
+ border-radius: 9999px;
401
+ padding: 4px 10px;
402
+ color: var(--primary-foreground);
403
+ background: var(--primary);
404
+ font-size: 12px;
405
+ font-weight: 700;
406
+ line-height: 1;
407
+ }
408
+ .ghcn-avatar {
409
+ display: block;
410
+ width: 40px;
411
+ height: 40px;
412
+ border-radius: 9999px;
413
+ object-fit: cover;
414
+ }
415
+ .ghcn-sr-only {
416
+ position: absolute;
417
+ width: 1px;
418
+ height: 1px;
419
+ padding: 0;
420
+ margin: -1px;
421
+ overflow: hidden;
422
+ clip: rect(0, 0, 0, 0);
423
+ white-space: nowrap;
424
+ border: 0;
425
+ }
426
+ `;
427
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ghostcn",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "The shadcn/ui for Ghost CMS themes - component distribution system",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
+ "!dist/test",
13
14
  "README.md"
14
15
  ],
15
16
  "scripts": {
@@ -1 +0,0 @@
1
- export {};
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_test_1 = require("node:test");
7
- const node_assert_1 = __importDefault(require("node:assert"));
8
- const registry_1 = require("../utils/registry");
9
- (0, node_test_1.describe)('Ghost UI Registry Utils', () => {
10
- (0, node_test_1.describe)('sanitizeComponentName', () => {
11
- (0, node_test_1.test)('accepts valid kebab-case names', () => {
12
- node_assert_1.default.strictEqual((0, registry_1.sanitizeComponentName)('newsletter-form'), 'newsletter-form');
13
- node_assert_1.default.strictEqual((0, registry_1.sanitizeComponentName)('pricing-table'), 'pricing-table');
14
- node_assert_1.default.strictEqual((0, registry_1.sanitizeComponentName)('post-card-2'), 'post-card-2');
15
- });
16
- (0, node_test_1.test)('trims whitespace and converts uppercase to lowercase', () => {
17
- node_assert_1.default.strictEqual((0, registry_1.sanitizeComponentName)(' Newsletter-Form '), 'newsletter-form');
18
- });
19
- (0, node_test_1.test)('rejects path traversal and invalid characters', () => {
20
- node_assert_1.default.throws(() => (0, registry_1.sanitizeComponentName)('../secret'), /Invalid component name/);
21
- node_assert_1.default.throws(() => (0, registry_1.sanitizeComponentName)('component/nested'), /Invalid component name/);
22
- node_assert_1.default.throws(() => (0, registry_1.sanitizeComponentName)('name with spaces'), /Invalid component name/);
23
- node_assert_1.default.throws(() => (0, registry_1.sanitizeComponentName)('hello$world'), /Invalid component name/);
24
- });
25
- });
26
- (0, node_test_1.describe)('getRegistryIndex', () => {
27
- (0, node_test_1.test)('returns list of available components', async () => {
28
- const items = await (0, registry_1.getRegistryIndex)();
29
- node_assert_1.default.ok(Array.isArray(items));
30
- node_assert_1.default.ok(items.length >= 4, `Expected at least 4 components, got ${items.length}`);
31
- const names = items.map(i => i.name);
32
- node_assert_1.default.ok(names.includes('newsletter-form'));
33
- node_assert_1.default.ok(names.includes('pricing-table'));
34
- node_assert_1.default.ok(names.includes('author-card'));
35
- node_assert_1.default.ok(names.includes('post-card'));
36
- });
37
- });
38
- (0, node_test_1.describe)('getComponent', () => {
39
- (0, node_test_1.test)('retrieves newsletter-form manifest correctly', async () => {
40
- const manifest = await (0, registry_1.getComponent)('newsletter-form');
41
- node_assert_1.default.ok(manifest !== null);
42
- node_assert_1.default.strictEqual(manifest?.name, 'newsletter-form');
43
- node_assert_1.default.ok(Array.isArray(manifest?.files));
44
- node_assert_1.default.ok(manifest?.files.length >= 2);
45
- const hbs = manifest?.files.find(f => f.type === 'partial');
46
- node_assert_1.default.ok(hbs !== null);
47
- node_assert_1.default.ok(hbs?.content.includes('gh-newsletter-form'));
48
- const css = manifest?.files.find(f => f.type === 'style');
49
- node_assert_1.default.ok(css !== null);
50
- });
51
- (0, node_test_1.test)('retrieves pricing-table manifest correctly', async () => {
52
- const manifest = await (0, registry_1.getComponent)('pricing-table');
53
- node_assert_1.default.ok(manifest !== null);
54
- node_assert_1.default.strictEqual(manifest?.name, 'pricing-table');
55
- node_assert_1.default.ok(manifest?.files.some(f => f.name === 'pricing-table.hbs'));
56
- });
57
- (0, node_test_1.test)('returns null for non-existent component', async () => {
58
- const manifest = await (0, registry_1.getComponent)('non-existent-xyz-123');
59
- node_assert_1.default.strictEqual(manifest, null);
60
- });
61
- });
62
- });