create-jant 0.3.28 → 0.3.30
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 +12 -1
- package/package.json +2 -2
- package/template/.dev.vars.example +12 -0
- package/template/README.md +118 -0
- package/template/_github/workflows/deploy.yml +48 -0
- package/template/_gitignore +12 -0
- package/template/package.json +2 -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.30";
|
|
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);
|
|
@@ -96,6 +96,17 @@ async function copyTemplate(config) {
|
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
+
const renames = [
|
|
100
|
+
["_gitignore", ".gitignore"],
|
|
101
|
+
["_github", ".github"]
|
|
102
|
+
];
|
|
103
|
+
for (const [from, to] of renames) {
|
|
104
|
+
const fromPath = path.join(targetDir, from);
|
|
105
|
+
const toPath = path.join(targetDir, to);
|
|
106
|
+
if (await fs.pathExists(fromPath)) {
|
|
107
|
+
await fs.rename(fromPath, toPath);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
99
110
|
const pkgPath = path.join(targetDir, "package.json");
|
|
100
111
|
if (await fs.pathExists(pkgPath)) {
|
|
101
112
|
const pkg = await fs.readJson(pkgPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-jant",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.30",
|
|
4
4
|
"description": "Create a new Jant project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"build": "tsup src/index.ts --format esm --clean --outDir dist",
|
|
54
54
|
"dev": "tsup src/index.ts --format esm --watch",
|
|
55
55
|
"typecheck": "tsc --noEmit",
|
|
56
|
-
"copy-template": "rm -rf template && rsync -a --exclude node_modules --exclude .wrangler --exclude .dev.vars ../../sites/demo/ template/",
|
|
56
|
+
"copy-template": "rm -rf template && rsync -a --exclude node_modules --exclude .wrangler --exclude .dev.vars --exclude scripts ../../sites/demo/ template/ && mv template/.gitignore template/_gitignore && mv template/.github template/_github",
|
|
57
57
|
"inject-version": "node -e \"const fs=require('fs');const v=require('../core/package.json').version;const f='dist/index.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace('__JANT_CORE_VERSION__',v))\"",
|
|
58
58
|
"test-template": "node scripts/test-template.js"
|
|
59
59
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Secrets — do not commit this file
|
|
2
|
+
#
|
|
3
|
+
# Cloudflare Workers: copy to .dev.vars
|
|
4
|
+
# VPS / Docker: copy to .env
|
|
5
|
+
|
|
6
|
+
# AUTH_SECRET must be at least 32 characters
|
|
7
|
+
# Generate one with: openssl rand -base64 32
|
|
8
|
+
AUTH_SECRET=your-secret-key-at-least-32-chars-long
|
|
9
|
+
|
|
10
|
+
# Required when STORAGE_DRIVER=s3:
|
|
11
|
+
# S3_ACCESS_KEY_ID=your-access-key
|
|
12
|
+
# S3_SECRET_ACCESS_KEY=your-secret-key
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Jant
|
|
2
|
+
|
|
3
|
+
A personal microblogging system — self-hosted, single-author, and stripped of all social mechanics. Runs on Cloudflare Workers.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### One-Click Deploy
|
|
8
|
+
|
|
9
|
+
[](https://deploy.workers.cloudflare.com/?url=https://github.com/jant-me/jant-starter)
|
|
10
|
+
|
|
11
|
+
### CLI
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm create jant my-site
|
|
15
|
+
cd my-site
|
|
16
|
+
npm run dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Manual Deploy
|
|
20
|
+
|
|
21
|
+
1. **Create a D1 database:**
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx wrangler d1 create my-site-db
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. **Update `wrangler.toml`** with the `database_id` from step 1 and set your `SITE_URL`.
|
|
28
|
+
|
|
29
|
+
3. **Set production secrets:**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx wrangler secret put AUTH_SECRET
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
4. **Deploy:**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run deploy
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Commands
|
|
42
|
+
|
|
43
|
+
| Command | Description |
|
|
44
|
+
| ---------------- | ------------------------------------------- |
|
|
45
|
+
| `npm run dev` | Start local dev server (applies migrations) |
|
|
46
|
+
| `npm run deploy` | Deploy to Cloudflare (applies migrations) |
|
|
47
|
+
|
|
48
|
+
## Environment Variables
|
|
49
|
+
|
|
50
|
+
Configuration is set in `wrangler.toml` and `.dev.vars`. See [Configuration](https://github.com/jant-me/jant/blob/main/docs/configuration.md) for the full reference.
|
|
51
|
+
|
|
52
|
+
**Required:**
|
|
53
|
+
|
|
54
|
+
| Variable | Where | Description |
|
|
55
|
+
| ------------- | --------------- | ---------------------------------- |
|
|
56
|
+
| `SITE_URL` | `wrangler.toml` | Your site's public URL |
|
|
57
|
+
| `AUTH_SECRET` | `.dev.vars` | Session encryption key (32+ chars) |
|
|
58
|
+
|
|
59
|
+
**Optional (in `wrangler.toml`):**
|
|
60
|
+
|
|
61
|
+
| Variable | Description |
|
|
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 |
|
|
68
|
+
|
|
69
|
+
## GitHub Actions CI/CD
|
|
70
|
+
|
|
71
|
+
The included workflow (`.github/workflows/deploy.yml`) deploys on every push to `main`.
|
|
72
|
+
|
|
73
|
+
**Setup:**
|
|
74
|
+
|
|
75
|
+
1. Add these **repository secrets** in Settings > Secrets and variables > Actions:
|
|
76
|
+
- `CF_API_TOKEN` — Cloudflare API token with Workers, D1, and R2 permissions
|
|
77
|
+
- `CF_ACCOUNT_ID` — your Cloudflare account ID
|
|
78
|
+
2. Set your production `AUTH_SECRET`:
|
|
79
|
+
```bash
|
|
80
|
+
npx wrangler secret put AUTH_SECRET
|
|
81
|
+
```
|
|
82
|
+
3. Push to `main` — the workflow handles migrations and deployment.
|
|
83
|
+
|
|
84
|
+
## Customization
|
|
85
|
+
|
|
86
|
+
### CSS Tokens
|
|
87
|
+
|
|
88
|
+
Customize colors through the dashboard (Settings > Appearance) or by overriding CSS variables. See [Theming](https://github.com/jant-me/jant/blob/main/docs/theming.md).
|
|
89
|
+
|
|
90
|
+
### Data Attributes
|
|
91
|
+
|
|
92
|
+
Target specific elements for styling with stable data attributes:
|
|
93
|
+
|
|
94
|
+
| Attribute | Purpose |
|
|
95
|
+
| ---------------- | ----------------------------- |
|
|
96
|
+
| `data-page` | Page type identifier |
|
|
97
|
+
| `data-post` | Post marker |
|
|
98
|
+
| `data-format` | Post format (note/link/quote) |
|
|
99
|
+
| `data-post-body` | Post body content |
|
|
100
|
+
|
|
101
|
+
### Code-Level
|
|
102
|
+
|
|
103
|
+
For deeper changes, fork the project and modify `@jant/core` directly.
|
|
104
|
+
|
|
105
|
+
## Updating
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm update @jant/core
|
|
109
|
+
npm run deploy
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Check the [changelog](https://github.com/jant-me/jant/releases) for breaking changes before updating.
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
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)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Deploy your Jant site to Cloudflare Workers.
|
|
2
|
+
#
|
|
3
|
+
# Prerequisites:
|
|
4
|
+
# 1. Create a D1 database: npx wrangler d1 create <name>
|
|
5
|
+
# 2. Update wrangler.toml with the database_id
|
|
6
|
+
# 3. Add repository secrets: CF_API_TOKEN, CF_ACCOUNT_ID
|
|
7
|
+
# 4. Set production secret: npx wrangler secret put AUTH_SECRET
|
|
8
|
+
#
|
|
9
|
+
# Full setup guide: https://github.com/jant-me/jant
|
|
10
|
+
|
|
11
|
+
name: Deploy
|
|
12
|
+
|
|
13
|
+
on:
|
|
14
|
+
push:
|
|
15
|
+
branches:
|
|
16
|
+
- main
|
|
17
|
+
workflow_dispatch:
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
deploy:
|
|
21
|
+
name: Deploy
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout
|
|
26
|
+
uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- name: Setup Node.js
|
|
29
|
+
uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version: "lts/*"
|
|
32
|
+
cache: npm
|
|
33
|
+
|
|
34
|
+
- name: Install dependencies
|
|
35
|
+
run: npm ci
|
|
36
|
+
|
|
37
|
+
- name: Run migrations
|
|
38
|
+
run: npx wrangler d1 migrations apply DB --remote
|
|
39
|
+
env:
|
|
40
|
+
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
|
41
|
+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
|
42
|
+
|
|
43
|
+
- name: Deploy to Cloudflare Workers
|
|
44
|
+
uses: cloudflare/wrangler-action@v3
|
|
45
|
+
with:
|
|
46
|
+
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
47
|
+
accountId: ${{ secrets.CF_ACCOUNT_ID }}
|
|
48
|
+
command: deploy
|
package/template/package.json
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "wrangler d1 migrations apply DB --local && wrangler dev",
|
|
7
|
-
"deploy": "wrangler d1 migrations apply DB --remote && wrangler deploy"
|
|
7
|
+
"deploy": "wrangler d1 migrations apply DB --remote && wrangler deploy",
|
|
8
|
+
"reset-password": "jant-reset-password"
|
|
8
9
|
},
|
|
9
10
|
"dependencies": {
|
|
10
11
|
"@jant/core": "workspace:*"
|