ghostcn 1.0.3 β 1.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 +96 -5
- package/dist/commands/add.js +41 -36
- package/dist/commands/create.d.ts +5 -0
- package/dist/commands/create.js +115 -0
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +7 -0
- package/dist/commands/init.js +134 -26
- package/dist/commands/pack.d.ts +1 -0
- package/dist/commands/pack.js +8 -0
- package/dist/index.js +12 -0
- 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 +5 -5
- 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/templates/theme-tools.mjs +178 -0
- package/dist/utils/component-installer.d.ts +16 -0
- package/dist/utils/component-installer.js +60 -0
- package/dist/utils/registry.d.ts +1 -0
- package/dist/utils/registry.js +42 -19
- package/dist/utils/styles.d.ts +3 -0
- package/dist/utils/styles.js +20 -0
- package/dist/utils/theme-files.d.ts +13 -0
- package/dist/utils/theme-files.js +108 -0
- package/dist/utils/theme-project.d.ts +29 -0
- package/dist/utils/theme-project.js +46 -0
- package/dist/utils/theme-scaffold.d.ts +21 -0
- package/dist/utils/theme-scaffold.js +313 -0
- package/dist/utils/theme-tooling.d.ts +2 -0
- package/dist/utils/theme-tooling.js +20 -0
- package/dist/utils/theme.d.ts +46 -0
- package/dist/utils/theme.js +429 -0
- package/package.json +7 -4
- package/dist/test/registry.test.d.ts +0 -1
- package/dist/test/registry.test.js +0 -62
package/README.md
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
<a href="https://www.npmjs.com/package/ghostcn"><img src="https://img.shields.io/npm/v/ghostcn?color=6366f1&style=flat-square" alt="npm version" /></a>
|
|
10
10
|
<a href="https://www.npmjs.com/package/ghostcn"><img src="https://img.shields.io/npm/dm/ghostcn?color=3b82f6&style=flat-square" alt="npm downloads" /></a>
|
|
11
11
|
<a href="https://ghost.org"><img src="https://img.shields.io/badge/Ghost-%3E%3D5.0.0-15171a?style=flat-square" alt="Ghost Version" /></a>
|
|
12
|
-
<a href="https://gscan.ghost.org"><img src="https://img.shields.io/badge/gscan-100%25%20valid-22c55e?style=flat-square" alt="gscan validation" /></a>
|
|
13
12
|
<a href="https://github.com/Geekbits-Org/ghost-ui/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License" /></a>
|
|
14
13
|
</p>
|
|
15
14
|
|
|
@@ -32,7 +31,7 @@ You own the code. You customize the classes. Zero vendor lock-in.
|
|
|
32
31
|
- π― **Interactive Multi-Select**: Run `npx ghostcn add` without arguments to select and batch-install multiple components interactively.
|
|
33
32
|
- π¨ **Tailwind & Vanilla CSS**: Pre-styled with utility classes and full Vanilla CSS stylesheets with Ghost CSS custom properties.
|
|
34
33
|
- π **Ghost Members API**: Native support for Ghost attributes (`data-members-form="subscribe"`, Portal checkout triggers).
|
|
35
|
-
- π‘οΈ **
|
|
34
|
+
- π‘οΈ **Theme validation**: Generated themes include offline diagnostics and official gscan validation. Validate your customized theme against your target Ghost version before shipping.
|
|
36
35
|
|
|
37
36
|
---
|
|
38
37
|
|
|
@@ -41,14 +40,87 @@ You own the code. You customize the classes. Zero vendor lock-in.
|
|
|
41
40
|
| Component | Description | Files |
|
|
42
41
|
| :--- | :--- | :--- |
|
|
43
42
|
| **`newsletter-form`** | Native Ghost members subscription form with success/error states | `newsletter-form.hbs`, `newsletter-form.css` |
|
|
44
|
-
| **`pricing-table`** |
|
|
43
|
+
| **`pricing-table`** | Public Ghost tiers with live prices, currencies, benefits and tier-specific Portal checkout | `pricing-table.hbs`, `pricing-table.css` |
|
|
45
44
|
| **`author-card`** | Author bio box with avatar, biography, social links, and post counts | `author-card.hbs`, `author-card.css` |
|
|
46
45
|
| **`post-card`** | Post loop preview card with feature image, tags, excerpt, and reading time | `post-card.hbs`, `post-card.css` |
|
|
46
|
+
| **`site-header`** | Responsive navigation with search, mobile menu, sign-in, and subscribe actions | `site-header.hbs`, `site-header.css` |
|
|
47
|
+
| **`site-footer`** | Secondary navigation, publication information, social links, and attribution | `site-footer.hbs`, `site-footer.css` |
|
|
48
|
+
| **`featured-posts`** | Homepage hero grid backed by Ghost featured posts | `featured-posts.hbs`, `featured-posts.css` |
|
|
49
|
+
| **`pagination`** | Accessible replacement for Ghostβs native pagination partial | `partials/pagination.hbs`, `pagination.css` |
|
|
50
|
+
| **`post-header`** | Editorial post heading, author metadata, reading time, and responsive image | `post-header.hbs`, `post-header.css` |
|
|
51
|
+
| **`member-cta`** | Context-aware calls to action for visitors, free members, and paid members | `member-cta.hbs`, `member-cta.css` |
|
|
47
52
|
|
|
48
53
|
---
|
|
49
54
|
|
|
50
55
|
## Quick Start
|
|
51
56
|
|
|
57
|
+
### Create a complete Ghost theme
|
|
58
|
+
|
|
59
|
+
Start a new, production-ready theme with an interactive setup:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npx ghostcn create my-theme
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
Use recommended defaults without installing dependencies:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx ghostcn create my-theme -y --skip-install
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Tailwind themes include a complete Tailwind CLI build and watch pipeline. Vanilla themes include a zero-dependency CSS copy/watch pipeline. In both cases:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
cd my-theme
|
|
77
|
+
npm run dev
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
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.
|
|
81
|
+
|
|
82
|
+
`npm run dev` watches CSS; it does **not** start Ghost. To preview, place the theme folder under a local Ghost installation's `content/themes`, restart Ghost from its installation directory, activate the theme in Ghost Admin β Settings β Design β Change theme, then visit your site's URL. Follow the [local Ghost setup guide](https://docs.ghost.org/install/local/) if you do not have an installation yet. Generated starters require Ghost 5.54.1+; use Node 22.13.1+ or Node 24 for gscan (Tailwind builds need Node 20+).
|
|
83
|
+
|
|
84
|
+
Build, validate and package for a remote site:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm test
|
|
88
|
+
npm run validate
|
|
89
|
+
npm run zip
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The ZIP is written to `dist/<theme-name>-<version>.zip`, with runtime templates and assets at its root. It excludes dependencies, scripts, lockfiles and repository metadata. Upload it in Ghost Admin's theme picker. Re-running replaces the generated ZIP.
|
|
93
|
+
|
|
94
|
+
For an existing theme, run `npx ghostcn doctor` to check configuration, linked assets, partials and Ghost hooks. After running **your theme's build**, `npx ghostcn pack` packages it without invoking or changing its build system. Doctor is an offline diagnostic, not a replacement for gscan or browser testing.
|
|
95
|
+
|
|
96
|
+
### Styling components
|
|
97
|
+
|
|
98
|
+
For a generated Tailwind theme, customize the markup with ordinary utilities:
|
|
99
|
+
|
|
100
|
+
```handlebars
|
|
101
|
+
<a class="ghcn-button bg-purple-600 hover:bg-purple-700 text-white" href="#/portal/signup" data-portal="signup">Subscribe</a>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
No `!` modifier is required to override ghostcn defaults. Component styles and primitives use Tailwind's `components` layer; utilities take precedence, even if a component stylesheet loads later. Semantic colors (`bg-primary`, `text-muted-foreground`, `border-border`, `ring-ring`) and `rounded-ghostcn` are mapped by `assets/css/ghostcn-tailwind.css`. Ghost's explicit and automatic dark modes are supported.
|
|
105
|
+
|
|
106
|
+
For **existing Tailwind v4 themes**, import the generated `ghostcn-tailwind.css` into your Tailwind source and make sure the build scans `.hbs` files. For example, when using `assets/css/source.css`:
|
|
107
|
+
|
|
108
|
+
```css
|
|
109
|
+
@import "tailwindcss";
|
|
110
|
+
@import "./ghostcn-tailwind.css";
|
|
111
|
+
@source "../../**/*.hbs";
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`init` and `add` do not replace an existing theme's build pipeline. Unlayered host CSS can still override layered styles; place such host rules in an appropriate lower layer or adjust your theme deliberately. Older Tailwind builds must configure their own semantic token mappings.
|
|
115
|
+
|
|
116
|
+
Vanilla themes ship standalone CSS: edit component files or put token and selector overrides in `assets/css/source.css`. The generated build stylesheet loads after ghostcn defaults. On an existing theme, link your override stylesheet after the managed ghostcn block.
|
|
117
|
+
|
|
118
|
+
Membership components respect disabled, invite-only and self-signup settings. Paid pricing is shown only when Ghost enables paid membership, using active public tiers configured in Ghost Adminβnot sample amounts or invented benefits. The starter uses `partials/content-cta.hbs` for one custom paywall; adding `member-cta` below native `{{content}}` on an existing protected post can otherwise duplicate Ghost's paywall. Follow the starter pattern rather than rendering both.
|
|
119
|
+
|
|
120
|
+
### Updating an existing ghostcn theme
|
|
121
|
+
|
|
122
|
+
Your copied files are yours; an npm update does not silently rewrite them. Back up or commit your theme first. Compare the new components in a fresh throwaway theme, then merge the changes you want. To replace unmodified files directly, run `ghostcn init` with your existing palette/paths and re-add the relevant components. Initialization regenerates tokens; `add -y` overwrites component customizations, so use it only deliberately. Existing Tailwind styles from older ghostcn releases are unlayered and need the new token/component CSS for ordinary utility overrides to work.
|
|
123
|
+
|
|
52
124
|
### 1. Initialize your Ghost Theme
|
|
53
125
|
|
|
54
126
|
Run the `init` command from the root of any Ghost theme (must have `engines.ghost` in its `package.json`):
|
|
@@ -62,17 +134,36 @@ Or pass `-y` to use default paths non-interactively:
|
|
|
62
134
|
npx ghostcn init -y
|
|
63
135
|
```
|
|
64
136
|
|
|
65
|
-
This
|
|
137
|
+
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`).
|
|
138
|
+
|
|
139
|
+
It generates `assets/css/ghostcn.css` with semantic design tokens, creates `components.json`, and adds a managed stylesheet block to `default.hbs`:
|
|
66
140
|
```json
|
|
67
141
|
{
|
|
142
|
+
"$schema": "https://ghostcn.com/schema.json",
|
|
68
143
|
"style": "tailwind",
|
|
144
|
+
"theme": {
|
|
145
|
+
"baseColor": "zinc",
|
|
146
|
+
"accentColor": "ghost",
|
|
147
|
+
"radius": "0.5rem"
|
|
148
|
+
},
|
|
69
149
|
"aliases": {
|
|
70
150
|
"partials": "partials/components",
|
|
71
151
|
"styles": "assets/css/components"
|
|
72
|
-
}
|
|
152
|
+
},
|
|
153
|
+
"cssFile": "assets/css/ghostcn.css"
|
|
73
154
|
}
|
|
74
155
|
```
|
|
75
156
|
|
|
157
|
+
The CLI keeps the token stylesheet and every installed component stylesheet linked automatically:
|
|
158
|
+
```handlebars
|
|
159
|
+
{{!-- ghostcn:styles:start --}}
|
|
160
|
+
<link rel="stylesheet" href="{{asset "css/ghostcn.css"}}" />
|
|
161
|
+
{{!-- Component styles are added here by `ghostcn add` --}}
|
|
162
|
+
{{!-- ghostcn:styles:end --}}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
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.
|
|
166
|
+
|
|
76
167
|
### 2. Browse Components
|
|
77
168
|
|
|
78
169
|
List all available components in the registry:
|
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,46 +22,45 @@ 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 = {}) {
|
|
@@ -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,115 @@
|
|
|
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
|
+
process.exitCode = 1;
|
|
95
|
+
installDependencies = false;
|
|
96
|
+
console.warn(chalk_1.default.yellow(`Dependency installation did not finish. The generated theme is intact; run "${packageManager} install" inside it.`));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const run = packageManager === 'npm' ? 'npm run' : `${packageManager} run`;
|
|
100
|
+
console.log(`\n${chalk_1.default.bold.green('Your Ghost theme files are ready.')}`);
|
|
101
|
+
console.log(` ${chalk_1.default.cyan(`cd ${path_1.default.basename(scaffold.themeRoot)}`)}`);
|
|
102
|
+
if (!installDependencies)
|
|
103
|
+
console.log(` ${chalk_1.default.cyan(`${packageManager} install`)}`);
|
|
104
|
+
console.log(` ${chalk_1.default.cyan(`${run} dev`)}\n`);
|
|
105
|
+
console.log('The dev command watches CSS; it does not start Ghost.');
|
|
106
|
+
console.log('Move this folder into your local Ghost content/themes directory, restart Ghost,');
|
|
107
|
+
console.log('then activate the theme in Ghost Admin β Settings β Design β Change theme.');
|
|
108
|
+
console.log(`Open your Ghost site to preview. See README.md for the full workflow.`);
|
|
109
|
+
console.log(`For upload: ${run} test β ${run} validate β ${run} zip.\n`);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
spinner.fail(chalk_1.default.red(error.message));
|
|
113
|
+
process.exitCode = 1;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function doctor(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doctor = doctor;
|
|
4
|
+
const theme_tooling_1 = require("../utils/theme-tooling");
|
|
5
|
+
function doctor() {
|
|
6
|
+
process.exitCode = (0, theme_tooling_1.runThemeTool)('doctor', process.cwd());
|
|
7
|
+
}
|
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 ghostcn
|
|
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,136 @@ 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`);
|
|
173
|
+
if (style === 'tailwind') {
|
|
174
|
+
console.log('Component defaults use @layer components so normal Tailwind utilities can override them.');
|
|
175
|
+
console.log('For Tailwind v4 semantic utilities, import ghostcn-tailwind.css from your Tailwind source.');
|
|
176
|
+
console.log('Existing themes must already have a Tailwind build scanning their .hbs files; init does not replace their build system.');
|
|
177
|
+
}
|
|
70
178
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pack(): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pack = pack;
|
|
4
|
+
const theme_tooling_1 = require("../utils/theme-tooling");
|
|
5
|
+
function pack() {
|
|
6
|
+
console.log('Build your theme first. This command packages existing runtime files only.');
|
|
7
|
+
process.exitCode = (0, theme_tooling_1.runThemeTool)('pack', process.cwd());
|
|
8
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -8,12 +8,22 @@ 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");
|
|
12
|
+
const doctor_1 = require("./commands/doctor");
|
|
13
|
+
const pack_1 = require("./commands/pack");
|
|
11
14
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
12
15
|
function main() {
|
|
13
16
|
const program = new commander_1.Command()
|
|
14
17
|
.name('ghostcn')
|
|
15
18
|
.description('The shadcn/ui for Ghost CMS themes')
|
|
16
19
|
.version(package_json_1.default.version || '1.0.0');
|
|
20
|
+
program
|
|
21
|
+
.command('create')
|
|
22
|
+
.description('Create a complete Ghost theme with ghostcn components')
|
|
23
|
+
.argument('[theme-name]', 'Directory and package name for the new theme')
|
|
24
|
+
.option('-y, --yes', 'Skip prompts and use recommended defaults')
|
|
25
|
+
.option('--skip-install', 'Generate the theme without installing dependencies')
|
|
26
|
+
.action(create_1.create);
|
|
17
27
|
program
|
|
18
28
|
.command('init')
|
|
19
29
|
.description('Initialize your Ghost theme and choose a component structure')
|
|
@@ -29,6 +39,8 @@ function main() {
|
|
|
29
39
|
.argument('[component]', 'The component to add (leave blank for interactive selection)')
|
|
30
40
|
.option('-y, --yes', 'Overwrite existing files without prompting')
|
|
31
41
|
.action(add_1.add);
|
|
42
|
+
program.command('doctor').description('Check theme configuration, local assets, partials and build readiness').action(doctor_1.doctor);
|
|
43
|
+
program.command('pack').description('Package built theme runtime files as a Ghost-uploadable ZIP').action(pack_1.pack);
|
|
32
44
|
program.parse();
|
|
33
45
|
}
|
|
34
46
|
main();
|