create-jant 0.3.11 → 0.3.12
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
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.12";
|
|
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,103 +1,77 @@
|
|
|
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
|
|
|
19
11
|
Visit http://localhost:9019 to see your site.
|
|
20
12
|
|
|
13
|
+
> Your `.dev.vars` file was automatically generated with a secure `AUTH_SECRET`. See `.dev.vars.example` for all available secret variables.
|
|
14
|
+
|
|
21
15
|
## Deploy to Cloudflare
|
|
22
16
|
|
|
23
|
-
### 1.
|
|
17
|
+
### 1. Prerequisites
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
Install [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/) and log in:
|
|
26
20
|
|
|
27
21
|
```bash
|
|
28
|
-
# Install wrangler if not already installed
|
|
29
|
-
npm install -g wrangler
|
|
30
|
-
|
|
31
|
-
# Login to Cloudflare
|
|
32
22
|
wrangler login
|
|
33
23
|
```
|
|
34
24
|
|
|
35
|
-
Create
|
|
25
|
+
### 2. Create D1 Database
|
|
36
26
|
|
|
37
27
|
```bash
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# Note the database_id from the output!
|
|
41
|
-
|
|
42
|
-
# Create R2 bucket for media storage
|
|
43
|
-
wrangler r2 bucket create my-blog-media
|
|
28
|
+
wrangler d1 create <your-project>-db
|
|
29
|
+
# Copy the database_id from the output!
|
|
44
30
|
```
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
Replace `<your-project>` with your project name (must match `database_name` in `wrangler.toml`).
|
|
47
33
|
|
|
48
|
-
|
|
34
|
+
### 3. Update Configuration
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
name = "my-blog" # Your worker name
|
|
36
|
+
Edit `wrangler.toml`:
|
|
52
37
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
database_name = "my-blog-db"
|
|
56
|
-
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # From step 1
|
|
38
|
+
- Replace `database_id = "local"` with the ID from step 2
|
|
39
|
+
- Set `SITE_URL` to your production URL
|
|
57
40
|
|
|
58
|
-
|
|
59
|
-
binding = "R2"
|
|
60
|
-
bucket_name = "my-blog-media"
|
|
61
|
-
```
|
|
41
|
+
> R2 bucket is automatically created on first deploy — no manual setup needed.
|
|
62
42
|
|
|
63
|
-
###
|
|
43
|
+
### 4. Set Production Secrets
|
|
64
44
|
|
|
65
45
|
```bash
|
|
66
|
-
# Set authentication secret (use a random 32+ character string)
|
|
67
46
|
wrangler secret put AUTH_SECRET
|
|
68
|
-
# Enter
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### 4. Run Migrations
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# Apply database migrations
|
|
75
|
-
wrangler d1 migrations apply my-blog-db --remote
|
|
47
|
+
# Enter a random 32+ character string when prompted
|
|
48
|
+
# Generate one with: openssl rand -base64 32
|
|
76
49
|
```
|
|
77
50
|
|
|
78
51
|
### 5. Deploy
|
|
79
52
|
|
|
80
53
|
```bash
|
|
54
|
+
# Apply database migrations to production
|
|
55
|
+
pnpm db:migrate:remote
|
|
56
|
+
|
|
81
57
|
# Build and deploy
|
|
82
58
|
pnpm deploy
|
|
83
59
|
```
|
|
84
60
|
|
|
85
|
-
Your site is now live at `https
|
|
61
|
+
Your site is now live at `https://<your-project>.<your-subdomain>.workers.dev`!
|
|
86
62
|
|
|
87
63
|
### 6. GitHub Actions (CI/CD)
|
|
88
64
|
|
|
89
|
-
A workflow file is
|
|
65
|
+
A workflow file is included at `.github/workflows/deploy.yml`. You just need to configure secrets.
|
|
90
66
|
|
|
91
67
|
#### Create API Token
|
|
92
68
|
|
|
93
69
|
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**
|
|
70
|
+
2. Click **Create Token** → **Use template** next to **Edit Cloudflare Workers**
|
|
71
|
+
3. **Add D1 permission** (not in template by default):
|
|
72
|
+
- Click **+ Add more** → **Account** → **D1** → **Edit**
|
|
99
73
|
|
|
100
|
-
|
|
74
|
+
Your permissions should include:
|
|
101
75
|
|
|
102
76
|
| Scope | Permission | Access |
|
|
103
77
|
| ------- | ------------------ | ----------------------------- |
|
|
@@ -106,41 +80,30 @@ A workflow file is already included at `.github/workflows/deploy.yml`. You just
|
|
|
106
80
|
| Account | **D1** | **Edit** ← Must add manually! |
|
|
107
81
|
| Zone | Workers Routes | Edit |
|
|
108
82
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
7. **Zone Resources**:
|
|
113
|
-
- Select **Include** → **All zones from an account** → Choose your account
|
|
114
|
-
|
|
115
|
-
8. Click **Continue to summary** → **Create Token**
|
|
116
|
-
9. Copy the token (you won't see it again!)
|
|
83
|
+
4. Set **Account Resources** → **Include** → your account
|
|
84
|
+
5. Set **Zone Resources** → **Include** → **All zones from an account** → your account
|
|
85
|
+
6. **Create Token** and copy it
|
|
117
86
|
|
|
118
87
|
#### Add GitHub Secrets
|
|
119
88
|
|
|
120
|
-
Go to your
|
|
89
|
+
Go to your repo → **Settings** → **Secrets and variables** → **Actions**:
|
|
121
90
|
|
|
122
|
-
| Secret Name | Value
|
|
123
|
-
| --------------- |
|
|
124
|
-
| `CF_API_TOKEN` |
|
|
125
|
-
| `CF_ACCOUNT_ID` | Your Cloudflare Account ID (
|
|
126
|
-
| `AUTH_SECRET` | Random
|
|
91
|
+
| Secret Name | Value |
|
|
92
|
+
| --------------- | ------------------------------------------------------------------------ |
|
|
93
|
+
| `CF_API_TOKEN` | API token from above |
|
|
94
|
+
| `CF_ACCOUNT_ID` | Your Cloudflare Account ID (found in dashboard URL or `wrangler whoami`) |
|
|
95
|
+
| `AUTH_SECRET` | Random 32+ character string (`openssl rand -base64 32`) |
|
|
127
96
|
|
|
128
|
-
|
|
129
|
-
>
|
|
130
|
-
> ```bash
|
|
131
|
-
> openssl rand -base64 32
|
|
132
|
-
> ```
|
|
133
|
-
|
|
134
|
-
That's it! Push to `main` branch to trigger deployment.
|
|
97
|
+
Push to `main` to trigger deployment.
|
|
135
98
|
|
|
136
99
|
#### Using Environments (Optional)
|
|
137
100
|
|
|
138
|
-
|
|
101
|
+
For separate staging/production, update `.github/workflows/deploy.yml`:
|
|
139
102
|
|
|
140
103
|
```yaml
|
|
141
104
|
jobs:
|
|
142
105
|
deploy:
|
|
143
|
-
uses:
|
|
106
|
+
uses: jant-me/jant/.github/workflows/deploy.yml@v1
|
|
144
107
|
with:
|
|
145
108
|
environment: production # Uses [env.production] in wrangler.toml
|
|
146
109
|
secrets:
|
|
@@ -151,35 +114,29 @@ jobs:
|
|
|
151
114
|
|
|
152
115
|
### 7. Custom Domain (Optional)
|
|
153
116
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
2. Select your worker > Settings > Triggers
|
|
158
|
-
3. Click "Add Custom Domain"
|
|
159
|
-
4. Enter your domain (e.g., `blog.example.com`)
|
|
117
|
+
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com) → Workers & Pages
|
|
118
|
+
2. Select your worker → Settings → Triggers
|
|
119
|
+
3. Click **Add Custom Domain** and enter your domain
|
|
160
120
|
|
|
161
121
|
## Commands
|
|
162
122
|
|
|
163
|
-
| Command
|
|
164
|
-
|
|
|
165
|
-
| `pnpm dev`
|
|
166
|
-
| `pnpm build`
|
|
167
|
-
| `pnpm deploy`
|
|
168
|
-
| `pnpm preview`
|
|
169
|
-
| `pnpm typecheck`
|
|
123
|
+
| Command | Description |
|
|
124
|
+
| ------------------------ | ---------------------------------- |
|
|
125
|
+
| `pnpm dev` | Start development server |
|
|
126
|
+
| `pnpm build` | Build for production |
|
|
127
|
+
| `pnpm deploy` | Build and deploy to Cloudflare |
|
|
128
|
+
| `pnpm preview` | Preview production build |
|
|
129
|
+
| `pnpm typecheck` | Run TypeScript checks |
|
|
130
|
+
| `pnpm db:migrate:remote` | Apply database migrations (remote) |
|
|
170
131
|
|
|
171
132
|
## Environment Variables
|
|
172
133
|
|
|
173
|
-
Core environment variables:
|
|
174
|
-
|
|
175
134
|
| Variable | Description | Location |
|
|
176
135
|
| ------------- | ----------------------------------------- | ---------------- |
|
|
177
136
|
| `AUTH_SECRET` | Secret key for authentication (32+ chars) | `.dev.vars` file |
|
|
178
137
|
| `SITE_URL` | Your site's public URL | `wrangler.toml` |
|
|
179
138
|
|
|
180
|
-
For
|
|
181
|
-
|
|
182
|
-
**[📖 Full Configuration Guide](https://github.com/nicepkg/jant/blob/main/docs/configuration.md)**
|
|
139
|
+
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
140
|
|
|
184
141
|
## Customization
|
|
185
142
|
|
|
@@ -247,33 +204,23 @@ export default createApp({
|
|
|
247
204
|
|
|
248
205
|
## Updating
|
|
249
206
|
|
|
250
|
-
1. Update the `@jant/core` package:
|
|
251
|
-
|
|
252
207
|
```bash
|
|
208
|
+
# Update @jant/core
|
|
253
209
|
pnpm update @jant/core
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
2. Apply database migrations locally (this happens automatically when you run `pnpm dev`):
|
|
257
210
|
|
|
258
|
-
|
|
211
|
+
# Start dev server (auto-applies migrations locally)
|
|
259
212
|
pnpm dev
|
|
260
|
-
```
|
|
261
213
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
```bash
|
|
214
|
+
# Before deploying: apply migrations to production
|
|
265
215
|
pnpm db:migrate:remote
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
4. Deploy:
|
|
269
216
|
|
|
270
|
-
|
|
217
|
+
# Deploy
|
|
271
218
|
pnpm deploy
|
|
272
219
|
```
|
|
273
220
|
|
|
274
|
-
>
|
|
221
|
+
> 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
222
|
|
|
276
223
|
## Documentation
|
|
277
224
|
|
|
278
225
|
- [Jant Documentation](https://jant.me/docs)
|
|
279
|
-
- [GitHub Repository](https://github.com/
|
|
226
|
+
- [GitHub Repository](https://github.com/jant-me/jant)
|
package/template/_gitignore
CHANGED
|
@@ -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);
|
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"
|