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.
- package/README.md +77 -16
- package/dist/commands/add.js +42 -37
- package/dist/commands/create.d.ts +5 -0
- package/dist/commands/create.js +108 -0
- package/dist/commands/init.js +129 -26
- package/dist/commands/list.js +4 -4
- package/dist/index.js +9 -1
- package/dist/registry/components/author-card.json +2 -2
- package/dist/registry/components/featured-posts.json +27 -0
- package/dist/registry/components/member-cta.json +27 -0
- package/dist/registry/components/newsletter-form.json +9 -6
- package/dist/registry/components/pagination.json +28 -0
- package/dist/registry/components/post-card.json +2 -2
- package/dist/registry/components/post-header.json +27 -0
- package/dist/registry/components/pricing-table.json +2 -2
- package/dist/registry/components/site-footer.json +27 -0
- package/dist/registry/components/site-header.json +27 -0
- package/dist/registry/index.json +61 -1
- package/dist/utils/component-installer.d.ts +16 -0
- package/dist/utils/component-installer.js +59 -0
- package/dist/utils/registry.d.ts +1 -0
- package/dist/utils/registry.js +42 -19
- package/dist/utils/theme-files.d.ts +13 -0
- package/dist/utils/theme-files.js +104 -0
- package/dist/utils/theme-project.d.ts +29 -0
- package/dist/utils/theme-project.js +41 -0
- package/dist/utils/theme-scaffold.d.ts +21 -0
- package/dist/utils/theme-scaffold.js +288 -0
- package/dist/utils/theme.d.ts +46 -0
- package/dist/utils/theme.js +427 -0
- package/package.json +2 -1
- package/dist/test/registry.test.d.ts +0 -1
- package/dist/test/registry.test.js +0 -62
package/README.md
CHANGED
|
@@ -27,12 +27,12 @@ You own the code. You customize the classes. Zero vendor lock-in.
|
|
|
27
27
|
|
|
28
28
|
## Features
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
30
|
+
- π¦ **Theme-Native**: Directly installs raw Handlebars partials and CSS into your theme folders.
|
|
31
|
+
- β‘ **Zero Latency**: Bundled offline registry ensures blazing fast installation even without internet.
|
|
32
|
+
- π― **Interactive Multi-Select**: Run `npx ghostcn add` without arguments to select and batch-install multiple components interactively.
|
|
33
|
+
- π¨ **Tailwind & Vanilla CSS**: Pre-styled with utility classes and full Vanilla CSS stylesheets with Ghost CSS custom properties.
|
|
34
|
+
- π **Ghost Members API**: Native support for Ghost attributes (`data-members-form="subscribe"`, Portal checkout triggers).
|
|
35
|
+
- π‘οΈ **100% gscan Validated**: All components strictly adhere to Ghost theme guidelines and pass official `gscan` checks with 0 errors.
|
|
36
36
|
|
|
37
37
|
---
|
|
38
38
|
|
|
@@ -44,11 +44,42 @@ You own the code. You customize the classes. Zero vendor lock-in.
|
|
|
44
44
|
| **`pricing-table`** | Membership tiers (Free, Monthly, Annual) with native Portal checkout triggers | `pricing-table.hbs`, `pricing-table.css` |
|
|
45
45
|
| **`author-card`** | Author bio box with avatar, biography, social links, and post counts | `author-card.hbs`, `author-card.css` |
|
|
46
46
|
| **`post-card`** | Post loop preview card with feature image, tags, excerpt, and reading time | `post-card.hbs`, `post-card.css` |
|
|
47
|
+
| **`site-header`** | Responsive navigation with search, mobile menu, sign-in, and subscribe actions | `site-header.hbs`, `site-header.css` |
|
|
48
|
+
| **`site-footer`** | Secondary navigation, publication information, social links, and attribution | `site-footer.hbs`, `site-footer.css` |
|
|
49
|
+
| **`featured-posts`** | Homepage hero grid backed by Ghost featured posts | `featured-posts.hbs`, `featured-posts.css` |
|
|
50
|
+
| **`pagination`** | Accessible replacement for Ghostβs native pagination partial | `partials/pagination.hbs`, `pagination.css` |
|
|
51
|
+
| **`post-header`** | Editorial post heading, author metadata, reading time, and responsive image | `post-header.hbs`, `post-header.css` |
|
|
52
|
+
| **`member-cta`** | Context-aware calls to action for visitors, free members, and paid members | `member-cta.hbs`, `member-cta.css` |
|
|
47
53
|
|
|
48
54
|
---
|
|
49
55
|
|
|
50
56
|
## Quick Start
|
|
51
57
|
|
|
58
|
+
### Create a complete Ghost theme
|
|
59
|
+
|
|
60
|
+
Start a new, production-ready theme with an interactive setup:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx ghostcn create my-theme
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The wizard configures Tailwind CSS or vanilla CSS, design tokens, color mode, package manager, optional components, and dependency installation. The generated theme includes Ghost templates for the home page, posts, pages, tags, and authors; responsive navigation; member flows; build scripts; and gscan validation.
|
|
67
|
+
|
|
68
|
+
Use recommended defaults without installing dependencies:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx ghostcn create my-theme -y --skip-install
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Tailwind themes include a complete Tailwind CLI build and watch pipeline. Vanilla themes include a zero-dependency CSS copy/watch pipeline. In both cases:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
cd my-theme
|
|
78
|
+
npm run dev
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Generated themes also include `npm test` for offline scaffold checks and `npm run validate` for official, pinned gscan validation. The validator is downloaded only when requested, keeping validator-only dependencies out of the day-to-day theme install.
|
|
82
|
+
|
|
52
83
|
### 1. Initialize your Ghost Theme
|
|
53
84
|
|
|
54
85
|
Run the `init` command from the root of any Ghost theme (must have `engines.ghost` in its `package.json`):
|
|
@@ -62,17 +93,36 @@ Or pass `-y` to use default paths non-interactively:
|
|
|
62
93
|
npx ghostcn init -y
|
|
63
94
|
```
|
|
64
95
|
|
|
65
|
-
This
|
|
96
|
+
This prompts you to choose your styling system (`tailwind` or `css`), base color palette (`zinc`, `slate`, `stone`, `gray`, `neutral`), accent color (`ghost` native dynamic accent, `indigo`, `violet`, etc.), and border radius (`none`, `sm`, `md`, `lg`, `full`).
|
|
97
|
+
|
|
98
|
+
It generates `assets/css/ghostcn.css` with semantic design tokens, creates `components.json`, and adds a managed stylesheet block to `default.hbs`:
|
|
66
99
|
```json
|
|
67
100
|
{
|
|
101
|
+
"$schema": "https://ghostcn.com/schema.json",
|
|
68
102
|
"style": "tailwind",
|
|
103
|
+
"theme": {
|
|
104
|
+
"baseColor": "zinc",
|
|
105
|
+
"accentColor": "ghost",
|
|
106
|
+
"radius": "0.5rem"
|
|
107
|
+
},
|
|
69
108
|
"aliases": {
|
|
70
109
|
"partials": "partials/components",
|
|
71
110
|
"styles": "assets/css/components"
|
|
72
|
-
}
|
|
111
|
+
},
|
|
112
|
+
"cssFile": "assets/css/ghostcn.css"
|
|
73
113
|
}
|
|
74
114
|
```
|
|
75
115
|
|
|
116
|
+
The CLI keeps the token stylesheet and every installed component stylesheet linked automatically:
|
|
117
|
+
```handlebars
|
|
118
|
+
{{!-- ghostcn:styles:start --}}
|
|
119
|
+
<link rel="stylesheet" href="{{asset "css/ghostcn.css"}}" />
|
|
120
|
+
{{!-- Component styles are added here by `ghostcn add` --}}
|
|
121
|
+
{{!-- ghostcn:styles:end --}}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
If a theme uses a layout other than `default.hbs`, the CLI leaves the layout untouched and prints the link you need to add manually.
|
|
125
|
+
|
|
76
126
|
### 2. Browse Components
|
|
77
127
|
|
|
78
128
|
List all available components in the registry:
|
|
@@ -125,13 +175,14 @@ Include the installed partial anywhere in your Handlebars templates:
|
|
|
125
175
|
## Project Structure
|
|
126
176
|
|
|
127
177
|
```text
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
178
|
+
ghostcn/
|
|
179
|
+
βββ packages/
|
|
180
|
+
β βββ cli/ # ghostcn CLI (Commander, Prompts, TypeScript, tests)
|
|
181
|
+
βββ registry/
|
|
182
|
+
β βββ index.json # Registry catalog index
|
|
183
|
+
β βββ components/ # Component manifests and templates
|
|
184
|
+
βββ example-theme/ # Sample Ghost theme showing integration
|
|
185
|
+
βββ .github/workflows/ # Automated CI pipeline
|
|
135
186
|
```
|
|
136
187
|
|
|
137
188
|
---
|
|
@@ -155,6 +206,16 @@ npx gscan .
|
|
|
155
206
|
|
|
156
207
|
---
|
|
157
208
|
|
|
209
|
+
## Troubleshooting
|
|
210
|
+
|
|
211
|
+
### Clearing npx cache
|
|
212
|
+
If you've previously run an older version of `ghostcn`, npx may cache it locally. To always run the latest version:
|
|
213
|
+
```bash
|
|
214
|
+
npx ghostcn@latest <command>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
158
219
|
## License
|
|
159
220
|
|
|
160
|
-
MIT
|
|
221
|
+
MIT Β© [Geekbits Org](https://github.com/Geekbits-Org)
|
package/dist/commands/add.js
CHANGED
|
@@ -10,6 +10,7 @@ const prompts_1 = __importDefault(require("prompts"));
|
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
11
|
const ora_1 = __importDefault(require("ora"));
|
|
12
12
|
const registry_1 = require("../utils/registry");
|
|
13
|
+
const component_installer_1 = require("../utils/component-installer");
|
|
13
14
|
async function installSingleComponent(componentName, config, options) {
|
|
14
15
|
let sanitizedName;
|
|
15
16
|
try {
|
|
@@ -21,53 +22,52 @@ async function installSingleComponent(componentName, config, options) {
|
|
|
21
22
|
}
|
|
22
23
|
const cwd = process.cwd();
|
|
23
24
|
const spinner = (0, ora_1.default)(`Fetching component "${sanitizedName}"...`).start();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let result;
|
|
26
|
+
try {
|
|
27
|
+
result = await (0, component_installer_1.installComponent)({
|
|
28
|
+
themeRoot: cwd,
|
|
29
|
+
componentName: sanitizedName,
|
|
30
|
+
config,
|
|
31
|
+
overwrite: options.yes,
|
|
32
|
+
shouldOverwrite: async (relativePath) => {
|
|
33
|
+
const response = await (0, prompts_1.default)({
|
|
34
|
+
type: 'confirm',
|
|
35
|
+
name: 'overwrite',
|
|
36
|
+
message: `File ${relativePath} already exists. Overwrite?`,
|
|
37
|
+
initial: false
|
|
38
|
+
}, {
|
|
39
|
+
onCancel: () => {
|
|
40
|
+
console.log(chalk_1.default.yellow('\nOperation cancelled.'));
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return Boolean(response.overwrite);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
spinner.fail(chalk_1.default.red(error.message));
|
|
27
50
|
return false;
|
|
28
51
|
}
|
|
29
52
|
spinner.succeed(`Found "${sanitizedName}"!`);
|
|
30
|
-
for (const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
else if (file.type === 'js')
|
|
37
|
-
targetDirAlias = config.aliases?.js || 'assets/js/components';
|
|
38
|
-
if (!targetDirAlias)
|
|
39
|
-
continue;
|
|
40
|
-
const targetDir = path_1.default.join(cwd, targetDirAlias);
|
|
41
|
-
const targetPath = path_1.default.join(targetDir, file.name);
|
|
42
|
-
if (!fs_1.default.existsSync(targetDir)) {
|
|
43
|
-
fs_1.default.mkdirSync(targetDir, { recursive: true });
|
|
44
|
-
}
|
|
45
|
-
if (fs_1.default.existsSync(targetPath) && !options.yes) {
|
|
46
|
-
const response = await (0, prompts_1.default)({
|
|
47
|
-
type: 'confirm',
|
|
48
|
-
name: 'overwrite',
|
|
49
|
-
message: `File ${targetDirAlias}/${file.name} already exists. Overwrite?`,
|
|
50
|
-
initial: false
|
|
51
|
-
});
|
|
52
|
-
if (!response.overwrite) {
|
|
53
|
-
console.log(chalk_1.default.yellow(`Skipped ${file.name}.`));
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
fs_1.default.writeFileSync(targetPath, file.content, 'utf8');
|
|
58
|
-
console.log(chalk_1.default.green(`Installed ${file.name} to ${targetDirAlias}/${file.name}`));
|
|
53
|
+
for (const installed of result.installed)
|
|
54
|
+
console.log(chalk_1.default.green(` β Installed ${installed}`));
|
|
55
|
+
for (const skipped of result.skipped)
|
|
56
|
+
console.log(chalk_1.default.yellow(` - Skipped ${skipped}`));
|
|
57
|
+
if (result.styleSync?.status === 'missing-template') {
|
|
58
|
+
console.warn(chalk_1.default.yellow(' β default.hbs was not found, so component styles could not be linked automatically.'));
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
console.log(chalk_1.default.yellow(`Note: Import ${config.aliases?.styles || 'assets/css/components'}/<style>.css into your main stylesheet if using Vanilla CSS.`));
|
|
60
|
+
else if (result.styleSync?.status === 'updated') {
|
|
61
|
+
console.log(chalk_1.default.green(' β Updated the managed stylesheet links in default.hbs'));
|
|
63
62
|
}
|
|
63
|
+
console.log(chalk_1.default.bold.blue(`Component "${sanitizedName}" successfully installed!`));
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
async function add(componentName, options = {}) {
|
|
67
67
|
const cwd = process.cwd();
|
|
68
68
|
const configPath = path_1.default.join(cwd, 'components.json');
|
|
69
69
|
if (!fs_1.default.existsSync(configPath)) {
|
|
70
|
-
console.error(chalk_1.default.red('components.json not found. Please run "ghostcn init" first.'));
|
|
70
|
+
console.error(chalk_1.default.red('components.json not found. Please run "npx ghostcn init" first.'));
|
|
71
71
|
process.exit(1);
|
|
72
72
|
}
|
|
73
73
|
let config;
|
|
@@ -103,6 +103,11 @@ async function add(componentName, options = {}) {
|
|
|
103
103
|
value: item.name
|
|
104
104
|
})),
|
|
105
105
|
hint: '- Space to select. Return to submit'
|
|
106
|
+
}, {
|
|
107
|
+
onCancel: () => {
|
|
108
|
+
console.log(chalk_1.default.yellow('\nCancelled.'));
|
|
109
|
+
process.exit(0);
|
|
110
|
+
}
|
|
106
111
|
});
|
|
107
112
|
if (!response.selected || response.selected.length === 0) {
|
|
108
113
|
console.log(chalk_1.default.yellow('No components selected. Exiting.'));
|
|
@@ -113,5 +118,5 @@ async function add(componentName, options = {}) {
|
|
|
113
118
|
await installSingleComponent(item, config, options);
|
|
114
119
|
console.log('');
|
|
115
120
|
}
|
|
116
|
-
console.log(chalk_1.default.green('All selected components have been installed!'));
|
|
121
|
+
console.log(chalk_1.default.bold.green('All selected components have been installed!'));
|
|
117
122
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
exports.create = create;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const ora_1 = __importDefault(require("ora"));
|
|
11
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
12
|
+
const component_installer_1 = require("../utils/component-installer");
|
|
13
|
+
const theme_project_1 = require("../utils/theme-project");
|
|
14
|
+
const theme_scaffold_1 = require("../utils/theme-scaffold");
|
|
15
|
+
async function create(themeNameArgument, options = {}) {
|
|
16
|
+
let themeName = themeNameArgument || '';
|
|
17
|
+
let style = 'tailwind';
|
|
18
|
+
let baseColor = 'zinc';
|
|
19
|
+
let accentColor = 'ghost';
|
|
20
|
+
let radius = '0.5rem';
|
|
21
|
+
let colorScheme = 'Auto';
|
|
22
|
+
let packageManager = 'npm';
|
|
23
|
+
let authorName = 'Theme Author';
|
|
24
|
+
let authorEmail = 'hello@example.com';
|
|
25
|
+
let optionalComponents = ['newsletter-form', 'author-card'];
|
|
26
|
+
let installDependencies = !options.skipInstall;
|
|
27
|
+
if (!options.yes) {
|
|
28
|
+
const response = await (0, prompts_1.default)([
|
|
29
|
+
...(!themeName ? [{ type: 'text', name: 'themeName', message: 'What should the theme be called?', initial: 'my-ghost-theme' }] : []),
|
|
30
|
+
{ type: 'select', name: 'style', message: 'Which styling system?', choices: [{ title: 'Tailwind CSS', value: 'tailwind' }, { title: 'Vanilla CSS', value: 'css' }], initial: 0 },
|
|
31
|
+
{ type: 'select', name: 'baseColor', message: 'Choose a base palette', choices: ['zinc', 'slate', 'stone', 'gray', 'neutral'].map(value => ({ title: value[0].toUpperCase() + value.slice(1), value })), initial: 0 },
|
|
32
|
+
{ type: 'select', name: 'accentColor', message: 'Choose an accent color', choices: ['ghost', 'indigo', 'violet', 'blue', 'emerald', 'rose', 'orange', 'zinc'].map(value => ({ title: value === 'ghost' ? 'Ghost accent (Recommended)' : value[0].toUpperCase() + value.slice(1), value })), initial: 0 },
|
|
33
|
+
{ type: 'select', name: 'radius', message: 'Choose a border radius', choices: [{ title: 'Medium', value: '0.5rem' }, { title: 'Small', value: '0.25rem' }, { title: 'Large', value: '0.75rem' }, { title: 'Extra large', value: '1rem' }, { title: 'None', value: '0' }, { title: 'Pill', value: '9999px' }], initial: 0 },
|
|
34
|
+
{ type: 'select', name: 'colorScheme', message: 'Choose the initial color scheme', choices: ['Auto', 'Light', 'Dark'].map(value => ({ title: value, value })), initial: 0 },
|
|
35
|
+
{ type: 'multiselect', name: 'optionalComponents', message: 'Add optional starter components', choices: [{ title: 'Newsletter form', value: 'newsletter-form', selected: true }, { title: 'Author card', value: 'author-card', selected: true }, { title: 'Pricing table', value: 'pricing-table', selected: false }], hint: '- Space to select. Return to submit' },
|
|
36
|
+
{ type: 'select', name: 'packageManager', message: 'Choose a package manager', choices: ['npm', 'pnpm', 'yarn', 'bun'].map(value => ({ title: value, value })), initial: 0 },
|
|
37
|
+
{ type: 'text', name: 'authorName', message: 'Theme author name', initial: 'Theme Author' },
|
|
38
|
+
{ type: 'text', name: 'authorEmail', message: 'Theme author email', initial: 'hello@example.com', validate: value => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) ? true : 'Enter a valid email address' },
|
|
39
|
+
...(!options.skipInstall ? [{ type: 'confirm', name: 'installDependencies', message: 'Install dependencies now?', initial: true }] : [])
|
|
40
|
+
], {
|
|
41
|
+
onCancel: () => {
|
|
42
|
+
console.log(chalk_1.default.yellow('\nTheme creation cancelled.'));
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
themeName = response.themeName || themeName;
|
|
47
|
+
style = response.style || style;
|
|
48
|
+
baseColor = response.baseColor || baseColor;
|
|
49
|
+
accentColor = response.accentColor || accentColor;
|
|
50
|
+
radius = response.radius || radius;
|
|
51
|
+
colorScheme = response.colorScheme || colorScheme;
|
|
52
|
+
optionalComponents = response.optionalComponents || [];
|
|
53
|
+
packageManager = response.packageManager || packageManager;
|
|
54
|
+
authorName = response.authorName || authorName;
|
|
55
|
+
authorEmail = response.authorEmail || authorEmail;
|
|
56
|
+
if (typeof response.installDependencies === 'boolean')
|
|
57
|
+
installDependencies = response.installDependencies;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
themeName = (0, theme_scaffold_1.sanitizeThemeName)(themeName);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error(chalk_1.default.red(error.message));
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const spinner = (0, ora_1.default)(`Creating Ghost theme "${themeName}"...`).start();
|
|
68
|
+
try {
|
|
69
|
+
const includeNewsletter = optionalComponents.includes('newsletter-form');
|
|
70
|
+
const includeAuthorCard = optionalComponents.includes('author-card');
|
|
71
|
+
const includePricing = optionalComponents.includes('pricing-table');
|
|
72
|
+
const scaffold = (0, theme_scaffold_1.scaffoldTheme)({
|
|
73
|
+
parentDirectory: process.cwd(), themeName, style, colorScheme, packageManager,
|
|
74
|
+
authorName, authorEmail,
|
|
75
|
+
includeNewsletter, includeAuthorCard, includePricing
|
|
76
|
+
});
|
|
77
|
+
const themeConfig = { style, baseColor, accentColor, radius };
|
|
78
|
+
const config = (0, theme_project_1.buildGhostcnConfig)(themeConfig);
|
|
79
|
+
(0, theme_project_1.initializeThemeProject)({ themeRoot: scaffold.themeRoot, config });
|
|
80
|
+
const components = [...theme_scaffold_1.REQUIRED_STARTER_COMPONENTS, ...optionalComponents];
|
|
81
|
+
for (const componentName of components) {
|
|
82
|
+
await (0, component_installer_1.installComponent)({ themeRoot: scaffold.themeRoot, componentName, config, overwrite: true });
|
|
83
|
+
}
|
|
84
|
+
spinner.succeed(chalk_1.default.green(`Created ${themeName} with ${components.length} components.`));
|
|
85
|
+
if (installDependencies) {
|
|
86
|
+
const installSpinner = (0, ora_1.default)(`Installing dependencies with ${packageManager}...`).start();
|
|
87
|
+
installSpinner.stop();
|
|
88
|
+
const installed = (0, child_process_1.spawnSync)(packageManager, ['install'], {
|
|
89
|
+
cwd: scaffold.themeRoot,
|
|
90
|
+
stdio: 'inherit',
|
|
91
|
+
shell: process.platform === 'win32'
|
|
92
|
+
});
|
|
93
|
+
if (installed.status !== 0) {
|
|
94
|
+
console.warn(chalk_1.default.yellow(`Dependency installation did not finish. The generated theme is intact; run "${packageManager} install" inside it.`));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const run = packageManager === 'npm' ? 'npm run' : `${packageManager} run`;
|
|
98
|
+
console.log(`\n${chalk_1.default.bold.green('Your Ghost theme is ready.')}`);
|
|
99
|
+
console.log(` ${chalk_1.default.cyan(`cd ${path_1.default.basename(scaffold.themeRoot)}`)}`);
|
|
100
|
+
if (!installDependencies)
|
|
101
|
+
console.log(` ${chalk_1.default.cyan(`${packageManager} install`)}`);
|
|
102
|
+
console.log(` ${chalk_1.default.cyan(`${run} dev`)}\n`);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
spinner.fail(chalk_1.default.red(error.message));
|
|
106
|
+
process.exitCode = 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
package/dist/commands/init.js
CHANGED
|
@@ -4,12 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.init = init;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const prompts_1 = __importDefault(require("prompts"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const ora_1 = __importDefault(require("ora"));
|
|
12
|
+
const theme_project_1 = require("../utils/theme-project");
|
|
11
13
|
async function init(options = {}) {
|
|
12
|
-
console.log(chalk_1.default.blue('Initializing
|
|
14
|
+
console.log(chalk_1.default.bold.blue('\n⨠Initializing ghostcn theming system...\n'));
|
|
13
15
|
const cwd = process.cwd();
|
|
14
16
|
// Verify it's a ghost theme
|
|
15
17
|
const packageJsonPath = path_1.default.join(cwd, 'package.json');
|
|
@@ -17,13 +19,23 @@ async function init(options = {}) {
|
|
|
17
19
|
console.error(chalk_1.default.red('No package.json found. Please run this command from the root of a Ghost theme.'));
|
|
18
20
|
process.exit(1);
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
try {
|
|
23
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8').replace(/^\uFEFF/, ''));
|
|
24
|
+
if (!packageJson.engines || (!packageJson.engines.ghost && !packageJson.engines['ghost-api'])) {
|
|
25
|
+
console.warn(chalk_1.default.yellow('β οΈ Warning: No "ghost" engine found in package.json. Continuing anyway, but ensure this is a Ghost theme.'));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
console.error(chalk_1.default.red('Error reading package.json. Ensure it is valid JSON.'));
|
|
30
|
+
process.exit(1);
|
|
23
31
|
}
|
|
24
32
|
let style = 'tailwind';
|
|
33
|
+
let baseColor = 'zinc';
|
|
34
|
+
let accentColor = 'ghost';
|
|
35
|
+
let radius = '0.5rem';
|
|
25
36
|
let partialsAlias = 'partials/components';
|
|
26
37
|
let stylesAlias = 'assets/css/components';
|
|
38
|
+
let cssFile = 'assets/css/ghostcn.css';
|
|
27
39
|
if (!options.yes) {
|
|
28
40
|
const response = await (0, prompts_1.default)([
|
|
29
41
|
{
|
|
@@ -31,40 +43,131 @@ async function init(options = {}) {
|
|
|
31
43
|
name: 'style',
|
|
32
44
|
message: 'Which styling system are you using?',
|
|
33
45
|
choices: [
|
|
34
|
-
{ title: 'Tailwind CSS', value: 'tailwind' },
|
|
35
|
-
{ title: 'Vanilla CSS', value: 'css' }
|
|
36
|
-
]
|
|
46
|
+
{ title: 'Tailwind CSS', value: 'tailwind', description: 'Utility-first CSS' },
|
|
47
|
+
{ title: 'Vanilla CSS', value: 'css', description: 'Raw Ghost CSS with Custom Properties' }
|
|
48
|
+
],
|
|
49
|
+
initial: 0
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: 'select',
|
|
53
|
+
name: 'baseColor',
|
|
54
|
+
message: 'Which base color palette would you like to use?',
|
|
55
|
+
choices: [
|
|
56
|
+
{ title: 'Zinc', value: 'zinc', description: 'Modern neutral with cool undertones' },
|
|
57
|
+
{ title: 'Slate', value: 'slate', description: 'Cool gray with subtle blue tones' },
|
|
58
|
+
{ title: 'Stone', value: 'stone', description: 'Warm, earthy neutral' },
|
|
59
|
+
{ title: 'Gray', value: 'gray', description: 'Clean, balanced neutral gray' },
|
|
60
|
+
{ title: 'Neutral', value: 'neutral', description: 'Pure monochromatic neutral' }
|
|
61
|
+
],
|
|
62
|
+
initial: 0
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'select',
|
|
66
|
+
name: 'accentColor',
|
|
67
|
+
message: 'Which accent / primary color would you like to use?',
|
|
68
|
+
choices: [
|
|
69
|
+
{
|
|
70
|
+
title: 'Ghost Accent (Recommended)',
|
|
71
|
+
value: 'ghost',
|
|
72
|
+
description: 'Dynamically connects to Ghost Admin brand color (@site.accent_color)'
|
|
73
|
+
},
|
|
74
|
+
{ title: 'Indigo', value: 'indigo', description: 'Deep tech indigo' },
|
|
75
|
+
{ title: 'Violet', value: 'violet', description: 'Vibrant modern violet' },
|
|
76
|
+
{ title: 'Blue', value: 'blue', description: 'Classic editorial blue' },
|
|
77
|
+
{ title: 'Emerald', value: 'emerald', description: 'Lush natural green' },
|
|
78
|
+
{ title: 'Rose', value: 'rose', description: 'Warm crimson rose' },
|
|
79
|
+
{ title: 'Orange', value: 'orange', description: 'Energetic warm orange' },
|
|
80
|
+
{ title: 'Zinc / Monochrome', value: 'zinc', description: 'Minimalist black/white' }
|
|
81
|
+
],
|
|
82
|
+
initial: 0
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'select',
|
|
86
|
+
name: 'radius',
|
|
87
|
+
message: 'Which border radius style would you like?',
|
|
88
|
+
choices: [
|
|
89
|
+
{ title: 'Medium (0.5rem)', value: '0.5rem' },
|
|
90
|
+
{ title: 'Small (0.25rem)', value: '0.25rem' },
|
|
91
|
+
{ title: 'Large (0.75rem)', value: '0.75rem' },
|
|
92
|
+
{ title: 'Extra Large (1.0rem)', value: '1rem' },
|
|
93
|
+
{ title: 'None (0px)', value: '0' },
|
|
94
|
+
{ title: 'Full (Pill / 9999px)', value: '9999px' }
|
|
95
|
+
],
|
|
96
|
+
initial: 0
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'text',
|
|
100
|
+
name: 'cssFile',
|
|
101
|
+
message: 'Where should the theme CSS tokens file be written?',
|
|
102
|
+
initial: 'assets/css/ghostcn.css'
|
|
37
103
|
},
|
|
38
104
|
{
|
|
39
105
|
type: 'text',
|
|
40
106
|
name: 'partialsAlias',
|
|
41
|
-
message: 'Where should partials be installed?',
|
|
107
|
+
message: 'Where should Handlebars partials be installed?',
|
|
42
108
|
initial: 'partials/components'
|
|
43
109
|
},
|
|
44
110
|
{
|
|
45
111
|
type: 'text',
|
|
46
112
|
name: 'stylesAlias',
|
|
47
|
-
message: 'Where should
|
|
113
|
+
message: 'Where should component CSS stylesheets be installed?',
|
|
48
114
|
initial: 'assets/css/components'
|
|
49
115
|
}
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
116
|
+
], {
|
|
117
|
+
onCancel: () => {
|
|
118
|
+
console.log(chalk_1.default.red('\nInitialization cancelled.'));
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
55
122
|
style = response.style || style;
|
|
56
|
-
|
|
57
|
-
|
|
123
|
+
baseColor = response.baseColor || baseColor;
|
|
124
|
+
accentColor = response.accentColor || accentColor;
|
|
125
|
+
radius = response.radius || radius;
|
|
126
|
+
cssFile = response.cssFile || cssFile;
|
|
127
|
+
partialsAlias = response.partialsAlias || partialsAlias;
|
|
128
|
+
stylesAlias = response.stylesAlias || stylesAlias;
|
|
58
129
|
}
|
|
59
|
-
const
|
|
130
|
+
const themeConfig = {
|
|
60
131
|
style,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
132
|
+
baseColor,
|
|
133
|
+
accentColor,
|
|
134
|
+
radius
|
|
65
135
|
};
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
136
|
+
const config = (0, theme_project_1.buildGhostcnConfig)(themeConfig, {
|
|
137
|
+
partials: partialsAlias,
|
|
138
|
+
styles: stylesAlias,
|
|
139
|
+
cssFile
|
|
140
|
+
});
|
|
141
|
+
const spinner = (0, ora_1.default)('Setting up theme configuration & design tokens...').start();
|
|
142
|
+
let styleSync;
|
|
143
|
+
try {
|
|
144
|
+
styleSync = (0, theme_project_1.initializeThemeProject)({ themeRoot: cwd, config }).styleSync;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
spinner.fail(chalk_1.default.red(error.message));
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
spinner.succeed(chalk_1.default.green('Configuration & design tokens successfully initialized!'));
|
|
151
|
+
console.log('\n' + chalk_1.default.bold('Summary:'));
|
|
152
|
+
console.log(` β’ Style: ${chalk_1.default.cyan(style)}`);
|
|
153
|
+
console.log(` β’ Base Palette: ${chalk_1.default.cyan(baseColor)}`);
|
|
154
|
+
console.log(` β’ Accent Color: ${chalk_1.default.cyan(accentColor)}`);
|
|
155
|
+
console.log(` β’ Border Radius: ${chalk_1.default.cyan(radius)}`);
|
|
156
|
+
console.log(` β’ Theme Tokens: ${chalk_1.default.cyan(cssFile)}`);
|
|
157
|
+
console.log(` β’ Partials: ${chalk_1.default.cyan(partialsAlias)}`);
|
|
158
|
+
console.log(` β’ Styles: ${chalk_1.default.cyan(stylesAlias)}`);
|
|
159
|
+
console.log(` β’ Template: ${styleSync.status === 'missing-template'
|
|
160
|
+
? chalk_1.default.yellow('default.hbs not found; stylesheet link not added')
|
|
161
|
+
: chalk_1.default.cyan('default.hbs (managed automatically)')}`);
|
|
162
|
+
console.log('\n' + chalk_1.default.bold.green('Next Steps:'));
|
|
163
|
+
if (styleSync.status === 'missing-template') {
|
|
164
|
+
console.log(` 1. Add this stylesheet to your layout's <head>:`);
|
|
165
|
+
console.log(` ${chalk_1.default.dim('<link rel="stylesheet" href="{{asset "' + cssFile.replace('assets/', '') + '"}}">')}`);
|
|
166
|
+
console.log(` 2. Add components to your theme:`);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
console.log(` 1. Add components to your theme:`);
|
|
170
|
+
}
|
|
171
|
+
console.log(` ${chalk_1.default.cyan('npx ghostcn add')}`);
|
|
172
|
+
console.log(` ${chalk_1.default.cyan('npx ghostcn add newsletter-form')}\n`);
|
|
70
173
|
}
|
package/dist/commands/list.js
CHANGED
|
@@ -8,14 +8,14 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const ora_1 = __importDefault(require("ora"));
|
|
9
9
|
const registry_1 = require("../utils/registry");
|
|
10
10
|
async function list() {
|
|
11
|
-
const spinner = (0, ora_1.default)('Fetching available components from
|
|
11
|
+
const spinner = (0, ora_1.default)('Fetching available components from ghostcn registry...').start();
|
|
12
12
|
try {
|
|
13
13
|
const items = await (0, registry_1.getRegistryIndex)();
|
|
14
14
|
if (!items || items.length === 0) {
|
|
15
15
|
spinner.warn('No components found in the registry.');
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
spinner.succeed(`Found ${items.length} components in
|
|
18
|
+
spinner.succeed(`Found ${items.length} components in ghostcn registry:\n`);
|
|
19
19
|
for (const item of items) {
|
|
20
20
|
console.log(` ${chalk_1.default.bold.cyan(item.name)}`);
|
|
21
21
|
console.log(` ${chalk_1.default.gray(item.description)}`);
|
|
@@ -24,8 +24,8 @@ async function list() {
|
|
|
24
24
|
}
|
|
25
25
|
console.log('');
|
|
26
26
|
}
|
|
27
|
-
console.log(`Install any component using: ${chalk_1.default.green('ghostcn add <component>')}`);
|
|
28
|
-
console.log(`Or run ${chalk_1.default.green('ghostcn add')} to select interactively.\n`);
|
|
27
|
+
console.log(`Install any component using: ${chalk_1.default.green('npx ghostcn add <component>')}`);
|
|
28
|
+
console.log(`Or run ${chalk_1.default.green('npx ghostcn add')} to select interactively.\n`);
|
|
29
29
|
}
|
|
30
30
|
catch (err) {
|
|
31
31
|
spinner.fail(`Failed to fetch component catalog: ${err.message || err}`);
|
package/dist/index.js
CHANGED
|
@@ -8,12 +8,20 @@ const commander_1 = require("commander");
|
|
|
8
8
|
const init_1 = require("./commands/init");
|
|
9
9
|
const add_1 = require("./commands/add");
|
|
10
10
|
const list_1 = require("./commands/list");
|
|
11
|
+
const create_1 = require("./commands/create");
|
|
11
12
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
12
13
|
function main() {
|
|
13
14
|
const program = new commander_1.Command()
|
|
14
15
|
.name('ghostcn')
|
|
15
16
|
.description('The shadcn/ui for Ghost CMS themes')
|
|
16
17
|
.version(package_json_1.default.version || '1.0.0');
|
|
18
|
+
program
|
|
19
|
+
.command('create')
|
|
20
|
+
.description('Create a complete Ghost theme with ghostcn components')
|
|
21
|
+
.argument('[theme-name]', 'Directory and package name for the new theme')
|
|
22
|
+
.option('-y, --yes', 'Skip prompts and use recommended defaults')
|
|
23
|
+
.option('--skip-install', 'Generate the theme without installing dependencies')
|
|
24
|
+
.action(create_1.create);
|
|
17
25
|
program
|
|
18
26
|
.command('init')
|
|
19
27
|
.description('Initialize your Ghost theme and choose a component structure')
|
|
@@ -21,7 +29,7 @@ function main() {
|
|
|
21
29
|
.action(init_1.init);
|
|
22
30
|
program
|
|
23
31
|
.command('list')
|
|
24
|
-
.description('List all available components in the
|
|
32
|
+
.description('List all available components in the ghostcn registry')
|
|
25
33
|
.action(list_1.list);
|
|
26
34
|
program
|
|
27
35
|
.command('add')
|