create-jant 0.3.29 → 0.3.31
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/dist/index.js +2 -1
- package/package.json +1 -1
- package/template/README.md +181 -66
- package/template/_github/workflows/deploy.yml +2 -1
- package/template/package.json +2 -1
- package/template/wrangler.toml +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from "path";
|
|
|
9
9
|
import { fileURLToPath } from "url";
|
|
10
10
|
var __filename = fileURLToPath(import.meta.url);
|
|
11
11
|
var __dirname = path.dirname(__filename);
|
|
12
|
-
var CORE_VERSION = "0.3.
|
|
12
|
+
var CORE_VERSION = "0.3.31";
|
|
13
13
|
var TEMPLATE_DIR = fs.existsSync(path.resolve(__dirname, "../template")) ? path.resolve(__dirname, "../template") : path.resolve(__dirname, "../../../sites/demo");
|
|
14
14
|
function isValidProjectName(name) {
|
|
15
15
|
return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(name);
|
|
@@ -237,6 +237,7 @@ async function main() {
|
|
|
237
237
|
spinner2.start("Installing dependencies...");
|
|
238
238
|
installOk = runCommand(`${packageManager} install`, targetDir);
|
|
239
239
|
if (installOk) {
|
|
240
|
+
runCommand(`${packageManager} install`, targetDir);
|
|
240
241
|
spinner2.stop("Dependencies installed.");
|
|
241
242
|
} else {
|
|
242
243
|
spinner2.stop(
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -1,14 +1,46 @@
|
|
|
1
|
-
# Jant
|
|
1
|
+
# Jant Site
|
|
2
2
|
|
|
3
|
-
A personal
|
|
3
|
+
A personal website/blog powered by [Jant](https://github.com/jant-me/jant).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Option A: One-Click Deploy
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Deploy to Cloudflare instantly — no local setup required:
|
|
8
8
|
|
|
9
9
|
[](https://deploy.workers.cloudflare.com/?url=https://github.com/jant-me/jant-starter)
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Deploy form fields
|
|
12
|
+
|
|
13
|
+
| Field | What to do |
|
|
14
|
+
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| **Git account** | Select your GitHub account. A new repo will be created for you. |
|
|
16
|
+
| **D1 database** | Keep "Create new". The default name is fine. |
|
|
17
|
+
| **Database location hint** | Pick a region close to you (optional, Cloudflare auto-selects). |
|
|
18
|
+
| **R2 bucket** | Keep "Create new". The default name is fine. Used for media uploads. |
|
|
19
|
+
| **AUTH_SECRET** | Used for login session encryption. Keep the pre-filled value or generate your own with `openssl rand -base64 32`. |
|
|
20
|
+
| **SITE_URL** | Change this to your production URL (e.g. `https://my-blog.example.com`). If you don't have a custom domain yet, leave it empty — you can set it later in the Cloudflare dashboard after you know your `*.workers.dev` URL. |
|
|
21
|
+
|
|
22
|
+
### After deploy
|
|
23
|
+
|
|
24
|
+
1. Visit your site at the URL shown in the Cloudflare dashboard (e.g. `https://<project>.<account>.workers.dev`)
|
|
25
|
+
2. Go to `/dash` to set up your admin account
|
|
26
|
+
3. If you set `SITE_URL` to a custom domain, add it in: Cloudflare dashboard → Workers & Pages → your worker → Settings → Domains & Routes → Add Custom Domain
|
|
27
|
+
4. If you left `SITE_URL` empty, set it to your `*.workers.dev` URL: Cloudflare dashboard → Workers & Pages → your worker → Settings → Variables and Secrets
|
|
28
|
+
|
|
29
|
+
### Develop locally
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Clone the repo that was created for you
|
|
33
|
+
git clone git@github.com:<your-username>/<your-repo>.git
|
|
34
|
+
cd <your-repo>
|
|
35
|
+
npm install
|
|
36
|
+
npm run dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Visit http://localhost:9019. Changes pushed to `main` will auto-deploy.
|
|
40
|
+
|
|
41
|
+
## Option B: Create with CLI
|
|
42
|
+
|
|
43
|
+
Set up a new project locally, then deploy manually:
|
|
12
44
|
|
|
13
45
|
```bash
|
|
14
46
|
npm create jant my-site
|
|
@@ -16,103 +48,186 @@ cd my-site
|
|
|
16
48
|
npm run dev
|
|
17
49
|
```
|
|
18
50
|
|
|
19
|
-
|
|
51
|
+
Visit http://localhost:9019. When you're ready to go live, continue with [Deploy to Cloudflare](#deploy-to-cloudflare) below.
|
|
52
|
+
|
|
53
|
+
### Deploy to Cloudflare
|
|
54
|
+
|
|
55
|
+
#### 1. Prerequisites
|
|
56
|
+
|
|
57
|
+
Install [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/) and log in:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
wrangler login
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### 2. Create D1 Database
|
|
20
64
|
|
|
21
|
-
|
|
65
|
+
Check the `database_name` in your `wrangler.toml` (defaults to `<your-project>-db`), then create it:
|
|
22
66
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
67
|
+
```bash
|
|
68
|
+
wrangler d1 create <your-project>-db
|
|
69
|
+
# Copy the database_id from the output!
|
|
70
|
+
```
|
|
26
71
|
|
|
27
|
-
|
|
72
|
+
#### 3. Update Configuration
|
|
28
73
|
|
|
29
|
-
|
|
74
|
+
Edit `wrangler.toml`:
|
|
30
75
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```
|
|
76
|
+
- Replace `database_id = "local"` with the ID from step 2
|
|
77
|
+
- Set `SITE_URL` to your production URL (e.g. `https://example.com`)
|
|
34
78
|
|
|
35
|
-
|
|
79
|
+
> R2 bucket is automatically created on first deploy — no manual setup needed.
|
|
80
|
+
>
|
|
81
|
+
> **Note:** Changing `database_id` resets your local development database (local data is stored per database ID). If you've already started local development, you'll need to go through the setup wizard again to create your admin account.
|
|
36
82
|
|
|
37
|
-
|
|
38
|
-
npm run deploy
|
|
39
|
-
```
|
|
83
|
+
#### 4. Set Production Secrets
|
|
40
84
|
|
|
41
|
-
|
|
85
|
+
Generate a production secret and save it somewhere safe (you'll need it again for CI):
|
|
42
86
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
| `npm run deploy` | Deploy to Cloudflare (applies migrations) |
|
|
87
|
+
```bash
|
|
88
|
+
# Generate a secret
|
|
89
|
+
openssl rand -base64 32
|
|
47
90
|
|
|
48
|
-
|
|
91
|
+
# Set it in Cloudflare
|
|
92
|
+
wrangler secret put AUTH_SECRET
|
|
93
|
+
# Paste the generated value when prompted
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
> **Important:** This is separate from the `AUTH_SECRET` in `.dev.vars` (which is for local development only). Do not change the production secret after your site is live — it will invalidate all sessions. If you get locked out, use `npm run reset-password` to generate a password reset link.
|
|
97
|
+
|
|
98
|
+
#### 5. Deploy
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Apply database migrations and deploy
|
|
102
|
+
npm run deploy
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Your site is now live at `https://<your-project>.<your-subdomain>.workers.dev`!
|
|
106
|
+
|
|
107
|
+
#### 6. Custom Domain (Optional)
|
|
108
|
+
|
|
109
|
+
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com) → Workers & Pages
|
|
110
|
+
2. Select your worker → Settings → Domains & Routes
|
|
111
|
+
3. Click **Add -> Custom domain** and enter your domain
|
|
112
|
+
|
|
113
|
+
### GitHub Actions (CI/CD)
|
|
114
|
+
|
|
115
|
+
A workflow file is included at `.github/workflows/deploy.yml`. Complete the [deployment](#deploy-to-cloudflare) first, then set up CI for automatic deployments.
|
|
116
|
+
|
|
117
|
+
> Runtime secrets (`AUTH_SECRET`, S3 keys, etc.) are already stored in Cloudflare from the manual deployment step. CI only needs deployment credentials.
|
|
118
|
+
|
|
119
|
+
#### 1. Push to GitHub
|
|
120
|
+
|
|
121
|
+
Create a new repository on [GitHub](https://github.com/new), then commit and push your project:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
git add -A
|
|
125
|
+
git commit -m "Initial setup"
|
|
126
|
+
git remote add origin git@github.com:<your-username>/<your-repo>.git
|
|
127
|
+
git push -u origin main
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### 2. Create API Token
|
|
49
131
|
|
|
50
|
-
|
|
132
|
+
1. Go to [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens)
|
|
133
|
+
2. Click **Create Token** → **Use template** next to **Edit Cloudflare Workers**
|
|
134
|
+
3. **Add D1 permission** (not in template by default):
|
|
135
|
+
- Click **+ Add more** → **Account** → **D1** → **Edit**
|
|
51
136
|
|
|
52
|
-
|
|
137
|
+
Your permissions should include:
|
|
53
138
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
139
|
+
| Scope | Permission | Access |
|
|
140
|
+
| ------- | ------------------ | ----------------------------- |
|
|
141
|
+
| Account | Workers Scripts | Edit |
|
|
142
|
+
| Account | Workers R2 Storage | Edit |
|
|
143
|
+
| Account | **D1** | **Edit** ← Must add manually! |
|
|
144
|
+
| Zone | Workers Routes | Edit |
|
|
58
145
|
|
|
59
|
-
**
|
|
146
|
+
4. Set **Account Resources** → **Include** → your account
|
|
147
|
+
5. Set **Zone Resources** → **Include** → **All zones from an account** → your account
|
|
148
|
+
6. **Create Token** and copy it
|
|
60
149
|
|
|
61
|
-
|
|
62
|
-
| --------------------- | ----------------------------------------- |
|
|
63
|
-
| `SITE_NAME` | Display name (also settable in dashboard) |
|
|
64
|
-
| `SITE_DESCRIPTION` | Meta description / RSS subtitle |
|
|
65
|
-
| `SITE_LANGUAGE` | Language code (`en`, `zh`, etc.) |
|
|
66
|
-
| `R2_PUBLIC_URL` | Public URL for R2 media bucket |
|
|
67
|
-
| `IMAGE_TRANSFORM_URL` | Cloudflare Image Transformations URL |
|
|
150
|
+
#### 3. Add GitHub Secrets
|
|
68
151
|
|
|
69
|
-
|
|
152
|
+
Go to your repo → **Settings** → **Secrets and variables** → **Actions**:
|
|
70
153
|
|
|
71
|
-
|
|
154
|
+
| Secret Name | Value |
|
|
155
|
+
| --------------- | ------------------------------------------------------------------------ |
|
|
156
|
+
| `CF_API_TOKEN` | API token from above |
|
|
157
|
+
| `CF_ACCOUNT_ID` | Your Cloudflare Account ID (found in dashboard URL or `wrangler whoami`) |
|
|
72
158
|
|
|
73
|
-
|
|
159
|
+
#### 4. Verify Auto-Deploy
|
|
74
160
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
161
|
+
The workflow is pre-configured to deploy on every push to `main`. After pushing your code, check the **Actions** tab in your GitHub repo to confirm the deployment succeeded.
|
|
162
|
+
|
|
163
|
+
## Commands
|
|
164
|
+
|
|
165
|
+
| Command | Description |
|
|
166
|
+
| ------------------------ | ------------------------------------------------ |
|
|
167
|
+
| `npm run dev` | Start local dev server (auto-applies migrations) |
|
|
168
|
+
| `npm run deploy` | Apply remote migrations, build, and deploy |
|
|
169
|
+
| `npm run reset-password` | Generate a password reset link if locked out |
|
|
170
|
+
| `npm run export` | Export D1 database to a SQL file |
|
|
171
|
+
|
|
172
|
+
> Use `--remote` to run commands against your production database (e.g. `npx jant reset-password --remote`).
|
|
173
|
+
|
|
174
|
+
## Environment Variables
|
|
175
|
+
|
|
176
|
+
| Variable | Description | Location |
|
|
177
|
+
| ------------- | ----------------------------------------- | ---------------- |
|
|
178
|
+
| `AUTH_SECRET` | Secret key for authentication (32+ chars) | `.dev.vars` file |
|
|
179
|
+
| `SITE_URL` | Your site's public URL | `wrangler.toml` |
|
|
180
|
+
|
|
181
|
+
For all available variables (site name, language, R2 storage, image optimization, S3, demo mode, etc.), see the **[Configuration Guide](https://github.com/jant-me/jant/blob/main/docs/configuration.md)**.
|
|
83
182
|
|
|
84
183
|
## Customization
|
|
85
184
|
|
|
86
|
-
###
|
|
185
|
+
### Color Themes
|
|
186
|
+
|
|
187
|
+
Pick a color theme from the dashboard: **Settings > Appearance**.
|
|
87
188
|
|
|
88
|
-
|
|
189
|
+
### Custom CSS
|
|
190
|
+
|
|
191
|
+
Inject custom CSS from the dashboard: **Settings > Appearance > Custom CSS**. This CSS is applied with the highest priority, so you can override any built-in styles.
|
|
89
192
|
|
|
90
193
|
### Data Attributes
|
|
91
194
|
|
|
92
|
-
Target specific elements
|
|
195
|
+
Target specific elements with stable data attributes:
|
|
93
196
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
| `data-post-body` | Post body content |
|
|
197
|
+
```css
|
|
198
|
+
/* Style only note-format posts */
|
|
199
|
+
[data-format="note"] {
|
|
200
|
+
border-left: 3px solid var(--primary);
|
|
201
|
+
}
|
|
100
202
|
|
|
101
|
-
|
|
203
|
+
/* Style the home page differently */
|
|
204
|
+
[data-page="home"] {
|
|
205
|
+
background: var(--muted);
|
|
206
|
+
}
|
|
102
207
|
|
|
103
|
-
|
|
208
|
+
/* Hide compose prompt for unauthenticated visitors */
|
|
209
|
+
body:not([data-authenticated]) .compose-prompt {
|
|
210
|
+
display: none;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
104
213
|
|
|
105
214
|
## Updating
|
|
106
215
|
|
|
107
216
|
```bash
|
|
108
|
-
|
|
217
|
+
# Update @jant/core to latest version
|
|
218
|
+
npm install @jant/core@latest
|
|
219
|
+
|
|
220
|
+
# Start dev server (auto-applies migrations locally)
|
|
221
|
+
npm run dev
|
|
222
|
+
|
|
223
|
+
# Deploy (includes remote migrations)
|
|
109
224
|
npm run deploy
|
|
110
225
|
```
|
|
111
226
|
|
|
112
|
-
Check the [
|
|
227
|
+
> New versions of `@jant/core` may include database migrations. Check the [release notes](https://github.com/jant-me/jant/releases) for any breaking changes.
|
|
113
228
|
|
|
114
229
|
## Documentation
|
|
115
230
|
|
|
116
|
-
- [Configuration](https://github.com/jant-me/jant/blob/main/docs/configuration.md)
|
|
117
|
-
- [Theming](https://github.com/jant-me/jant/blob/main/docs/theming.md)
|
|
118
|
-
- [GitHub](https://github.com/jant-me/jant)
|
|
231
|
+
- [Configuration Guide](https://github.com/jant-me/jant/blob/main/docs/configuration.md)
|
|
232
|
+
- [Theming Guide](https://github.com/jant-me/jant/blob/main/docs/theming.md)
|
|
233
|
+
- [GitHub Repository](https://github.com/jant-me/jant)
|
package/template/package.json
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "wrangler d1 migrations apply DB --local && wrangler dev",
|
|
7
7
|
"deploy": "wrangler d1 migrations apply DB --remote && wrangler deploy",
|
|
8
|
-
"reset-password": "jant
|
|
8
|
+
"reset-password": "jant reset-password",
|
|
9
|
+
"export": "jant export"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
11
12
|
"@jant/core": "workspace:*"
|
package/template/wrangler.toml
CHANGED
|
@@ -24,7 +24,7 @@ port = 9019
|
|
|
24
24
|
[vars]
|
|
25
25
|
# Required: Your site's public URL (e.g. https://my-blog.example.com)
|
|
26
26
|
# https://github.com/jant-me/jant/blob/main/docs/configuration.md#required
|
|
27
|
-
SITE_URL = "https://demo.jant.me" # @create-jant: ""
|
|
27
|
+
SITE_URL = "https://demo.jant.me" # @create-jant: "https://example.com"
|
|
28
28
|
|
|
29
29
|
# Optional: Site configuration
|
|
30
30
|
# You can also set these in the dashboard UI at /dash/settings
|