create-jant 0.3.18 → 0.3.20
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 +34 -24
- package/template/vite.config.ts +2 -2
- package/template/wrangler.toml +2 -2
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.20";
|
|
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);
|
|
@@ -116,6 +116,7 @@ async function copyTemplate(config) {
|
|
|
116
116
|
if (pkg.dependencies?.["@jant/core"] === "workspace:*") {
|
|
117
117
|
pkg.dependencies["@jant/core"] = `^${CORE_VERSION}`;
|
|
118
118
|
}
|
|
119
|
+
delete pkg.scripts["dev:debug"];
|
|
119
120
|
if (packageManager !== "pnpm") {
|
|
120
121
|
delete pkg.packageManager;
|
|
121
122
|
if (pkg.scripts) {
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -2,15 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
A personal website/blog powered by [Jant](https://github.com/jant-me/jant).
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
### Option A: One-Click Deploy
|
|
5
|
+
## Option A: One-Click Deploy
|
|
8
6
|
|
|
9
7
|
Deploy to Cloudflare instantly — no local setup required:
|
|
10
8
|
|
|
11
9
|
[](https://deploy.workers.cloudflare.com/?url=https://github.com/jant-me/jant-starter)
|
|
12
10
|
|
|
13
|
-
|
|
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
|
|
14
30
|
|
|
15
31
|
```bash
|
|
16
32
|
# Clone the repo that was created for you
|
|
@@ -22,9 +38,7 @@ npm run dev
|
|
|
22
38
|
|
|
23
39
|
Visit http://localhost:9019. Changes pushed to `main` will auto-deploy.
|
|
24
40
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Option B: Create with CLI
|
|
41
|
+
## Option B: Create with CLI
|
|
28
42
|
|
|
29
43
|
Set up a new project locally, then deploy manually:
|
|
30
44
|
|
|
@@ -36,11 +50,9 @@ npm run dev
|
|
|
36
50
|
|
|
37
51
|
Visit http://localhost:9019. When you're ready to go live, continue with [Deploy to Cloudflare](#deploy-to-cloudflare) below.
|
|
38
52
|
|
|
39
|
-
|
|
53
|
+
### Deploy to Cloudflare
|
|
40
54
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### 1. Prerequisites
|
|
55
|
+
#### 1. Prerequisites
|
|
44
56
|
|
|
45
57
|
Install [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/) and log in:
|
|
46
58
|
|
|
@@ -48,7 +60,7 @@ Install [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/instal
|
|
|
48
60
|
wrangler login
|
|
49
61
|
```
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
#### 2. Create D1 Database
|
|
52
64
|
|
|
53
65
|
Check the `database_name` in your `wrangler.toml` (defaults to `<your-project>-db`), then create it:
|
|
54
66
|
|
|
@@ -57,7 +69,7 @@ wrangler d1 create <your-project>-db
|
|
|
57
69
|
# Copy the database_id from the output!
|
|
58
70
|
```
|
|
59
71
|
|
|
60
|
-
|
|
72
|
+
#### 3. Update Configuration
|
|
61
73
|
|
|
62
74
|
Edit `wrangler.toml`:
|
|
63
75
|
|
|
@@ -68,7 +80,7 @@ Edit `wrangler.toml`:
|
|
|
68
80
|
>
|
|
69
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.
|
|
70
82
|
|
|
71
|
-
|
|
83
|
+
#### 4. Set Production Secrets
|
|
72
84
|
|
|
73
85
|
Generate a production secret and save it somewhere safe (you'll need it again for CI):
|
|
74
86
|
|
|
@@ -83,7 +95,7 @@ wrangler secret put AUTH_SECRET
|
|
|
83
95
|
|
|
84
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.
|
|
85
97
|
|
|
86
|
-
|
|
98
|
+
#### 5. Deploy
|
|
87
99
|
|
|
88
100
|
```bash
|
|
89
101
|
# Apply database migrations and deploy
|
|
@@ -92,21 +104,19 @@ npm run deploy
|
|
|
92
104
|
|
|
93
105
|
Your site is now live at `https://<your-project>.<your-subdomain>.workers.dev`!
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
#### 6. Custom Domain (Optional)
|
|
96
108
|
|
|
97
109
|
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com) → Workers & Pages
|
|
98
110
|
2. Select your worker → Settings → Domains & Routes
|
|
99
111
|
3. Click **Add -> Custom domain** and enter your domain
|
|
100
112
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
> This section is for **CLI-created projects** (Option B). One-click deploy users already have CI/CD configured.
|
|
113
|
+
### GitHub Actions (CI/CD)
|
|
104
114
|
|
|
105
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.
|
|
106
116
|
|
|
107
117
|
> Runtime secrets (`AUTH_SECRET`, S3 keys, etc.) are already stored in Cloudflare from the manual deployment step. CI only needs deployment credentials.
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
#### 1. Push to GitHub
|
|
110
120
|
|
|
111
121
|
Create a new repository on [GitHub](https://github.com/new), then commit and push your project:
|
|
112
122
|
|
|
@@ -117,7 +127,7 @@ git remote add origin git@github.com:<your-username>/<your-repo>.git
|
|
|
117
127
|
git push -u origin main
|
|
118
128
|
```
|
|
119
129
|
|
|
120
|
-
|
|
130
|
+
#### 2. Create API Token
|
|
121
131
|
|
|
122
132
|
1. Go to [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens)
|
|
123
133
|
2. Click **Create Token** → **Use template** next to **Edit Cloudflare Workers**
|
|
@@ -137,7 +147,7 @@ Your permissions should include:
|
|
|
137
147
|
5. Set **Zone Resources** → **Include** → **All zones from an account** → your account
|
|
138
148
|
6. **Create Token** and copy it
|
|
139
149
|
|
|
140
|
-
|
|
150
|
+
#### 3. Add GitHub Secrets
|
|
141
151
|
|
|
142
152
|
Go to your repo → **Settings** → **Secrets and variables** → **Actions**:
|
|
143
153
|
|
|
@@ -146,7 +156,7 @@ Go to your repo → **Settings** → **Secrets and variables** → **Actions**:
|
|
|
146
156
|
| `CF_API_TOKEN` | API token from above |
|
|
147
157
|
| `CF_ACCOUNT_ID` | Your Cloudflare Account ID (found in dashboard URL or `wrangler whoami`) |
|
|
148
158
|
|
|
149
|
-
|
|
159
|
+
#### 4. Enable Auto-Deploy
|
|
150
160
|
|
|
151
161
|
Uncomment the push trigger in `.github/workflows/deploy.yml`:
|
|
152
162
|
|
|
@@ -160,7 +170,7 @@ on:
|
|
|
160
170
|
|
|
161
171
|
Now every push to `main` will auto-deploy.
|
|
162
172
|
|
|
163
|
-
|
|
173
|
+
#### Using Environments (Optional)
|
|
164
174
|
|
|
165
175
|
For separate staging/production, update `.github/workflows/deploy.yml`:
|
|
166
176
|
|
package/template/vite.config.ts
CHANGED
|
@@ -191,9 +191,9 @@ export default defineConfig({
|
|
|
191
191
|
},
|
|
192
192
|
},
|
|
193
193
|
|
|
194
|
+
// @create-jant: @remove-start
|
|
194
195
|
resolve: {
|
|
195
196
|
alias: {
|
|
196
|
-
// @create-jant: @remove-start
|
|
197
197
|
// Monorepo development aliases
|
|
198
198
|
// - @lingui/react/macro: Prevents Vite dependency scan error. Source code imports
|
|
199
199
|
// from @lingui/react/macro (for SWC plugin), but we use Hono JSX. SWC rewrites
|
|
@@ -206,7 +206,7 @@ export default defineConfig({
|
|
|
206
206
|
"../../packages/core/src/i18n/index.ts",
|
|
207
207
|
),
|
|
208
208
|
"@jant/core": resolve(__dirname, "../../packages/core/src"),
|
|
209
|
-
// @create-jant: @remove-end
|
|
210
209
|
},
|
|
211
210
|
},
|
|
211
|
+
// @create-jant: @remove-end
|
|
212
212
|
});
|
package/template/wrangler.toml
CHANGED
|
@@ -17,8 +17,8 @@ port = 9019
|
|
|
17
17
|
# See docs/configuration.md for full details
|
|
18
18
|
|
|
19
19
|
[vars]
|
|
20
|
-
# Required: Your site's public URL
|
|
21
|
-
SITE_URL = "
|
|
20
|
+
# Required: Your site's public URL (e.g. https://my-blog.example.com)
|
|
21
|
+
SITE_URL = ""
|
|
22
22
|
|
|
23
23
|
# Optional: Site configuration
|
|
24
24
|
# These can be overridden in dashboard settings (/dash/settings)
|