create-jant 0.3.11 → 0.3.13
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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/template/README.md +92 -115
- package/template/_github/workflows/deploy.yml +11 -9
- package/template/_gitignore +1 -0
- package/template/package.json +1 -1
- package/template/scripts/seed-demo.sql +3 -3
- package/template/wrangler.toml +7 -0
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ my-site/
|
|
|
73
73
|
```bash
|
|
74
74
|
pnpm dev # Start dev server (http://localhost:9019)
|
|
75
75
|
pnpm build # Build for production
|
|
76
|
-
pnpm deploy # Build + deploy to Cloudflare Workers
|
|
76
|
+
pnpm cf:deploy # Build + deploy to Cloudflare Workers
|
|
77
77
|
pnpm typecheck # Run TypeScript checks
|
|
78
78
|
pnpm lint # Run ESLint
|
|
79
79
|
pnpm format # Format code with Prettier
|
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.13";
|
|
13
13
|
var TEMPLATE_DIR = fs.existsSync(path.resolve(__dirname, "../template")) ? path.resolve(__dirname, "../template") : path.resolve(__dirname, "../../../templates/jant-site");
|
|
14
14
|
function isValidProjectName(name) {
|
|
15
15
|
return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(name);
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
# Jant Site
|
|
2
2
|
|
|
3
|
-
A personal website/blog powered by [Jant](https://github.com/
|
|
3
|
+
A personal website/blog powered by [Jant](https://github.com/jant-me/jant).
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# Install dependencies
|
|
9
|
-
pnpm install
|
|
10
|
-
|
|
11
|
-
# Set up environment variables
|
|
12
|
-
cp .dev.vars.example .dev.vars
|
|
13
|
-
# Edit .dev.vars and set AUTH_SECRET (32+ random characters)
|
|
14
|
-
|
|
15
|
-
# Start development server
|
|
16
8
|
pnpm dev
|
|
17
9
|
```
|
|
18
10
|
|
|
@@ -20,84 +12,92 @@ Visit http://localhost:9019 to see your site.
|
|
|
20
12
|
|
|
21
13
|
## Deploy to Cloudflare
|
|
22
14
|
|
|
23
|
-
### 1.
|
|
15
|
+
### 1. Prerequisites
|
|
24
16
|
|
|
25
|
-
|
|
17
|
+
Install [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/) and log in:
|
|
26
18
|
|
|
27
19
|
```bash
|
|
28
|
-
# Install wrangler if not already installed
|
|
29
|
-
npm install -g wrangler
|
|
30
|
-
|
|
31
|
-
# Login to Cloudflare
|
|
32
20
|
wrangler login
|
|
33
21
|
```
|
|
34
22
|
|
|
35
|
-
Create
|
|
23
|
+
### 2. Create D1 Database
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
# Create D1 database
|
|
39
|
-
wrangler d1 create my-blog-db
|
|
40
|
-
# Note the database_id from the output!
|
|
25
|
+
Check the `database_name` in your `wrangler.toml` (defaults to `<your-project>-db`), then create it:
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
wrangler
|
|
27
|
+
```bash
|
|
28
|
+
wrangler d1 create <your-project>-db
|
|
29
|
+
# Copy the database_id from the output!
|
|
44
30
|
```
|
|
45
31
|
|
|
46
|
-
###
|
|
32
|
+
### 3. Update Configuration
|
|
47
33
|
|
|
48
|
-
Edit `wrangler.toml
|
|
34
|
+
Edit `wrangler.toml`:
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
- Replace `database_id = "local"` with the ID from step 2
|
|
37
|
+
- Set `SITE_URL` to your production URL
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # From step 1
|
|
39
|
+
> R2 bucket is automatically created on first deploy — no manual setup needed.
|
|
40
|
+
>
|
|
41
|
+
> **Note:** Changing `database_id` resets your local development database (local data is stored per database ID). This is why we recommend setting up deployment before starting local development.
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
binding = "R2"
|
|
60
|
-
bucket_name = "my-blog-media"
|
|
61
|
-
```
|
|
43
|
+
### 4. Set Production Secrets
|
|
62
44
|
|
|
63
|
-
|
|
45
|
+
Generate a production secret and save it somewhere safe (you'll need it again for CI):
|
|
64
46
|
|
|
65
47
|
```bash
|
|
66
|
-
#
|
|
48
|
+
# Generate a secret
|
|
49
|
+
openssl rand -base64 32
|
|
50
|
+
|
|
51
|
+
# Set it in Cloudflare
|
|
67
52
|
wrangler secret put AUTH_SECRET
|
|
68
|
-
#
|
|
53
|
+
# Paste the generated value when prompted
|
|
69
54
|
```
|
|
70
55
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# Apply database migrations
|
|
75
|
-
wrangler d1 migrations apply my-blog-db --remote
|
|
76
|
-
```
|
|
56
|
+
> **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 `pnpm reset-password` to generate a password reset link.
|
|
77
57
|
|
|
78
58
|
### 5. Deploy
|
|
79
59
|
|
|
80
60
|
```bash
|
|
61
|
+
# Apply database migrations to production
|
|
62
|
+
pnpm db:migrate:remote
|
|
63
|
+
|
|
81
64
|
# Build and deploy
|
|
82
|
-
pnpm deploy
|
|
65
|
+
pnpm cf:deploy
|
|
83
66
|
```
|
|
84
67
|
|
|
85
|
-
Your site is now live at `https
|
|
68
|
+
Your site is now live at `https://<your-project>.<your-subdomain>.workers.dev`!
|
|
69
|
+
|
|
70
|
+
### 6. Custom Domain (Optional)
|
|
71
|
+
|
|
72
|
+
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com) → Workers & Pages
|
|
73
|
+
2. Select your worker → Settings → Domains & Routes
|
|
74
|
+
3. Click **Add -> Custom domain** and enter your domain
|
|
86
75
|
|
|
87
|
-
|
|
76
|
+
## GitHub Actions (CI/CD)
|
|
88
77
|
|
|
89
|
-
A workflow file is
|
|
78
|
+
A workflow file is included at `.github/workflows/deploy.yml`. Complete the [manual deployment](#deploy-to-cloudflare) first, then set up CI for automatic deployments.
|
|
90
79
|
|
|
91
|
-
|
|
80
|
+
> Runtime secrets (`AUTH_SECRET`, S3 keys, etc.) are already stored in Cloudflare from the manual deployment step. CI only needs deployment credentials.
|
|
81
|
+
|
|
82
|
+
### 1. Push to GitHub
|
|
83
|
+
|
|
84
|
+
Create a new repository on [GitHub](https://github.com/new), then commit and push your project:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
git add -A
|
|
88
|
+
git commit -m "Initial setup"
|
|
89
|
+
git remote add origin https://github.com/<your-username>/<your-repo>.git
|
|
90
|
+
git push -u origin main
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 2. Create API Token
|
|
92
94
|
|
|
93
95
|
1. Go to [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens)
|
|
94
|
-
2. Click **Create Token**
|
|
95
|
-
3.
|
|
96
|
-
|
|
97
|
-
- Click **+ Add more**
|
|
98
|
-
- Select: **Account** → **D1** → **Edit**
|
|
96
|
+
2. Click **Create Token** → **Use template** next to **Edit Cloudflare Workers**
|
|
97
|
+
3. **Add D1 permission** (not in template by default):
|
|
98
|
+
- Click **+ Add more** → **Account** → **D1** → **Edit**
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
Your permissions should include:
|
|
101
101
|
|
|
102
102
|
| Scope | Permission | Access |
|
|
103
103
|
| ------- | ------------------ | ----------------------------- |
|
|
@@ -106,80 +106,67 @@ A workflow file is already included at `.github/workflows/deploy.yml`. You just
|
|
|
106
106
|
| Account | **D1** | **Edit** ← Must add manually! |
|
|
107
107
|
| Zone | Workers Routes | Edit |
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
4. Set **Account Resources** → **Include** → your account
|
|
110
|
+
5. Set **Zone Resources** → **Include** → **All zones from an account** → your account
|
|
111
|
+
6. **Create Token** and copy it
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
- Select **Include** → **All zones from an account** → Choose your account
|
|
113
|
+
### 3. Add GitHub Secrets
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
9. Copy the token (you won't see it again!)
|
|
115
|
+
Go to your repo → **Settings** → **Secrets and variables** → **Actions**:
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
| Secret Name | Value |
|
|
118
|
+
| --------------- | ------------------------------------------------------------------------ |
|
|
119
|
+
| `CF_API_TOKEN` | API token from above |
|
|
120
|
+
| `CF_ACCOUNT_ID` | Your Cloudflare Account ID (found in dashboard URL or `wrangler whoami`) |
|
|
119
121
|
|
|
120
|
-
|
|
122
|
+
### 4. Enable Auto-Deploy
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
| --------------- | -------------------------------------------------------------------------- |
|
|
124
|
-
| `CF_API_TOKEN` | Your API token from above |
|
|
125
|
-
| `CF_ACCOUNT_ID` | Your Cloudflare Account ID (find it in dashboard URL or `wrangler whoami`) |
|
|
126
|
-
| `AUTH_SECRET` | Random string for authentication (**must be at least 32 characters**) |
|
|
124
|
+
Uncomment the push trigger in `.github/workflows/deploy.yml`:
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
```yaml
|
|
127
|
+
on:
|
|
128
|
+
push:
|
|
129
|
+
branches:
|
|
130
|
+
- main
|
|
131
|
+
workflow_dispatch:
|
|
132
|
+
```
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
Now every push to `main` will auto-deploy.
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
### Using Environments (Optional)
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
For separate staging/production, update `.github/workflows/deploy.yml`:
|
|
139
139
|
|
|
140
140
|
```yaml
|
|
141
141
|
jobs:
|
|
142
142
|
deploy:
|
|
143
|
-
uses:
|
|
143
|
+
uses: jant-me/jant/.github/workflows/deploy.yml@main
|
|
144
144
|
with:
|
|
145
145
|
environment: production # Uses [env.production] in wrangler.toml
|
|
146
146
|
secrets:
|
|
147
147
|
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
|
148
148
|
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
|
149
|
-
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
|
|
150
149
|
```
|
|
151
150
|
|
|
152
|
-
### 7. Custom Domain (Optional)
|
|
153
|
-
|
|
154
|
-
To use your own domain:
|
|
155
|
-
|
|
156
|
-
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com) > Workers & Pages
|
|
157
|
-
2. Select your worker > Settings > Triggers
|
|
158
|
-
3. Click "Add Custom Domain"
|
|
159
|
-
4. Enter your domain (e.g., `blog.example.com`)
|
|
160
|
-
|
|
161
151
|
## Commands
|
|
162
152
|
|
|
163
|
-
| Command
|
|
164
|
-
|
|
|
165
|
-
| `pnpm dev`
|
|
166
|
-
| `pnpm build`
|
|
167
|
-
| `pnpm deploy`
|
|
168
|
-
| `pnpm preview`
|
|
169
|
-
| `pnpm typecheck`
|
|
153
|
+
| Command | Description |
|
|
154
|
+
| ------------------------ | ---------------------------------- |
|
|
155
|
+
| `pnpm dev` | Start development server |
|
|
156
|
+
| `pnpm build` | Build for production |
|
|
157
|
+
| `pnpm cf:deploy` | Build and deploy to Cloudflare |
|
|
158
|
+
| `pnpm preview` | Preview production build |
|
|
159
|
+
| `pnpm typecheck` | Run TypeScript checks |
|
|
160
|
+
| `pnpm db:migrate:remote` | Apply database migrations (remote) |
|
|
170
161
|
|
|
171
162
|
## Environment Variables
|
|
172
163
|
|
|
173
|
-
Core environment variables:
|
|
174
|
-
|
|
175
164
|
| Variable | Description | Location |
|
|
176
165
|
| ------------- | ----------------------------------------- | ---------------- |
|
|
177
166
|
| `AUTH_SECRET` | Secret key for authentication (32+ chars) | `.dev.vars` file |
|
|
178
167
|
| `SITE_URL` | Your site's public URL | `wrangler.toml` |
|
|
179
168
|
|
|
180
|
-
For
|
|
181
|
-
|
|
182
|
-
**[📖 Full Configuration Guide](https://github.com/nicepkg/jant/blob/main/docs/configuration.md)**
|
|
169
|
+
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)**.
|
|
183
170
|
|
|
184
171
|
## Customization
|
|
185
172
|
|
|
@@ -247,33 +234,23 @@ export default createApp({
|
|
|
247
234
|
|
|
248
235
|
## Updating
|
|
249
236
|
|
|
250
|
-
1. Update the `@jant/core` package:
|
|
251
|
-
|
|
252
237
|
```bash
|
|
238
|
+
# Update @jant/core
|
|
253
239
|
pnpm update @jant/core
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
2. Apply database migrations locally (this happens automatically when you run `pnpm dev`):
|
|
257
240
|
|
|
258
|
-
|
|
241
|
+
# Start dev server (auto-applies migrations locally)
|
|
259
242
|
pnpm dev
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
3. Before deploying to production, apply migrations to your remote D1 database:
|
|
263
243
|
|
|
264
|
-
|
|
244
|
+
# Before deploying: apply migrations to production
|
|
265
245
|
pnpm db:migrate:remote
|
|
266
|
-
```
|
|
267
246
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
```bash
|
|
271
|
-
pnpm deploy
|
|
247
|
+
# Deploy
|
|
248
|
+
pnpm cf:deploy
|
|
272
249
|
```
|
|
273
250
|
|
|
274
|
-
>
|
|
251
|
+
> New versions of `@jant/core` may include database migrations. Always run `pnpm db:migrate:remote` before deploying after an update. Check the [release notes](https://github.com/jant-me/jant/releases) for any breaking changes.
|
|
275
252
|
|
|
276
253
|
## Documentation
|
|
277
254
|
|
|
278
255
|
- [Jant Documentation](https://jant.me/docs)
|
|
279
|
-
- [GitHub Repository](https://github.com/
|
|
256
|
+
- [GitHub Repository](https://github.com/jant-me/jant)
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
# Deploy to Cloudflare Workers
|
|
2
2
|
# Documentation: https://jant.me/docs/deployment
|
|
3
3
|
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
4
|
+
# Prerequisites:
|
|
5
|
+
# 1. Complete manual deployment first (see README.md → Deploy to Cloudflare)
|
|
6
|
+
# 2. Set GitHub secrets: CF_API_TOKEN and CF_ACCOUNT_ID
|
|
7
|
+
#
|
|
8
|
+
# Runtime secrets (AUTH_SECRET, S3 keys, etc.) are managed via
|
|
9
|
+
# `wrangler secret put` and persist across deployments.
|
|
8
10
|
|
|
9
11
|
name: Deploy
|
|
10
12
|
|
|
11
13
|
on:
|
|
12
|
-
push:
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
# Uncomment to auto-deploy on push after configuring secrets:
|
|
15
|
+
# push:
|
|
16
|
+
# branches:
|
|
17
|
+
# - main
|
|
15
18
|
workflow_dispatch:
|
|
16
19
|
|
|
17
20
|
jobs:
|
|
18
21
|
deploy:
|
|
19
|
-
uses:
|
|
22
|
+
uses: jant-me/jant/.github/workflows/deploy.yml@main
|
|
20
23
|
secrets:
|
|
21
24
|
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
|
22
25
|
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
|
23
|
-
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
|
package/template/_gitignore
CHANGED
package/template/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dev": "pnpm db:migrate:local && vite dev",
|
|
9
9
|
"dev:debug": "pnpm db:migrate:local && vite dev --port 19019",
|
|
10
10
|
"build": "vite build",
|
|
11
|
-
"deploy": "pnpm build && wrangler deploy",
|
|
11
|
+
"cf:deploy": "pnpm build && wrangler deploy",
|
|
12
12
|
"preview": "vite preview",
|
|
13
13
|
"typecheck": "tsc --noEmit",
|
|
14
14
|
"db:migrate:local": "yes | wrangler d1 migrations apply DB --local",
|
|
@@ -44,7 +44,7 @@ pnpm dev
|
|
|
44
44
|
</code></pre>
|
|
45
45
|
<p>Visit the <a href="/dash">dashboard</a> to create your own posts!</p>',NULL,NULL,NULL,NULL,NULL,NULL,1770689095,1770689095,1770689095);
|
|
46
46
|
INSERT INTO posts VALUES(2,'note','quiet',NULL,NULL,'This is a demo note. Notes are short posts without titles, perfect for quick thoughts and updates.','<p>This is a demo note. Notes are short posts without titles, perfect for quick thoughts and updates.</p>',NULL,NULL,NULL,NULL,NULL,NULL,1770685495,1770685495,1770685495);
|
|
47
|
-
INSERT INTO posts VALUES(3,'link','quiet','Jant on GitHub',NULL,'Check out the source code and documentation for Jant.','<p>Check out the source code and documentation for Jant.</p>','https://github.com/
|
|
47
|
+
INSERT INTO posts VALUES(3,'link','quiet','Jant on GitHub',NULL,'Check out the source code and documentation for Jant.','<p>Check out the source code and documentation for Jant.</p>','https://github.com/jant-me/jant','GitHub','github.com',NULL,NULL,NULL,1770681895,1770681895,1770681895);
|
|
48
48
|
INSERT INTO posts VALUES(4,'quote','quiet',NULL,NULL,'The best way to predict the future is to invent it.','<p>The best way to predict the future is to invent it.</p>',NULL,'Alan Kay',NULL,NULL,NULL,NULL,1770678295,1770678295,1770678295);
|
|
49
49
|
INSERT INTO posts VALUES(5,'image','quiet',NULL,NULL,'Image 1','<p>Image 1</p>
|
|
50
50
|
',NULL,NULL,NULL,NULL,NULL,NULL,1770758516,1770758516,1770758516);
|
|
@@ -82,7 +82,7 @@ cd my-blog
|
|
|
82
82
|
pnpm dev
|
|
83
83
|
|
|
84
84
|
# Deploy to Cloudflare
|
|
85
|
-
pnpm deploy
|
|
85
|
+
pnpm cf:deploy
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
## Documentation
|
|
@@ -147,7 +147,7 @@ cd my-blog
|
|
|
147
147
|
pnpm dev
|
|
148
148
|
|
|
149
149
|
# Deploy to Cloudflare
|
|
150
|
-
pnpm deploy
|
|
150
|
+
pnpm cf:deploy
|
|
151
151
|
</code></pre>
|
|
152
152
|
<h2>Documentation</h2>
|
|
153
153
|
<ul>
|
package/template/wrangler.toml
CHANGED
|
@@ -42,11 +42,18 @@ R2_PUBLIC_URL = "https://demo-media.jant.me" # @create-jant: @remove
|
|
|
42
42
|
# Optional: S3-compatible storage (alternative to R2)
|
|
43
43
|
# Set STORAGE_DRIVER = "s3" and configure the options below.
|
|
44
44
|
# When using S3, the [[r2_buckets]] section can be removed.
|
|
45
|
+
# STORAGE_DRIVER = "s3"
|
|
46
|
+
# S3_ENDPOINT = "https://s3.example.com"
|
|
47
|
+
# S3_BUCKET = "my-bucket"
|
|
48
|
+
# S3_REGION = "us-east-1"
|
|
49
|
+
# S3_PUBLIC_URL = "https://cdn.example.com"
|
|
50
|
+
# @create-jant: @remove-start
|
|
45
51
|
STORAGE_DRIVER = "s3"
|
|
46
52
|
S3_ENDPOINT = "https://s3.us-east-005.backblazeb2.com"
|
|
47
53
|
S3_BUCKET = "jant-media"
|
|
48
54
|
S3_REGION = "us-east-005"
|
|
49
55
|
S3_PUBLIC_URL = "https://files.owenyoung.com/file/jant-media"
|
|
56
|
+
# @create-jant: @remove-end
|
|
50
57
|
|
|
51
58
|
[[d1_databases]]
|
|
52
59
|
binding = "DB"
|