From ca194da822c6402ac1bb7496079c5329ba17af70 Mon Sep 17 00:00:00 2001
From: shuaiplus <2327005759@qq.com>
Date: Sat, 7 Mar 2026 03:47:21 +0800
Subject: [PATCH] feat: add workflow to import KV ID from NodeWarden2 and
update README for deployment instructions
---
.../import-kv-id-from-nodewarden2.yml | 59 +++++++++++++++++++
README.md | 23 ++++----
README_EN.md | 15 +++--
webapp/src/lib/i18n.ts | 7 ++-
4 files changed, 82 insertions(+), 22 deletions(-)
create mode 100644 .github/workflows/import-kv-id-from-nodewarden2.yml
diff --git a/.github/workflows/import-kv-id-from-nodewarden2.yml b/.github/workflows/import-kv-id-from-nodewarden2.yml
new file mode 100644
index 0000000..0884ad4
--- /dev/null
+++ b/.github/workflows/import-kv-id-from-nodewarden2.yml
@@ -0,0 +1,59 @@
+name: Import KV ID from NodeWarden2
+
+on:
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+jobs:
+ patch:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Configure git
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+
+ - name: Import KV namespace id from NodeWarden2
+ env:
+ REPO_OWNER: ${{ github.repository_owner }}
+ run: |
+ python - <<'PY'
+ import os
+ import re
+ from pathlib import Path
+ from urllib.request import urlopen
+
+ owner = os.environ["REPO_OWNER"]
+ source_url = f"https://raw.githubusercontent.com/{owner}/nodewarden2/main/wrangler.toml"
+ with urlopen(source_url) as response:
+ source_text = response.read().decode("utf-8")
+
+ source_match = re.search(r'id\s*=\s*"([^"]+)"', source_text)
+ if not source_match:
+ raise SystemExit('No `id = "..."` found in nodewarden2/wrangler.toml')
+
+ kv_id = source_match.group(1)
+
+ target_path = Path("wrangler.toml")
+ target_text = target_path.read_text(encoding="utf-8")
+ target_text, count = re.subn(r'id\s*=\s*"[^"]+"', f'id = "{kv_id}"', target_text, count=1)
+
+ if count == 0:
+ raise SystemExit('No `id = "..."` found in current wrangler.toml')
+
+ target_path.write_text(target_text, encoding="utf-8")
+ PY
+
+ - name: Commit imported KV id
+ run: |
+ git add wrangler.toml
+ git diff --cached --quiet && exit 0
+ git commit -m "chore: import kv id from nodewarden2"
+ git push origin main
diff --git a/README.md b/README.md
index 2be93d9..3c80ec8 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,6 @@ English:[`README_EN.md`](./README_EN.md)
### 一键部署
-**部署步骤:**
> **若你只是想快速体验,直接点击第 2 步的一键部署按钮即可;以下步骤主要为了后续长期更新。**
@@ -64,8 +63,8 @@ English:[`README_EN.md`](./README_EN.md)
[](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
-3. 部署完成后,在同一页面打开 Workers 设置,将 **Git 存储库** 断开连接。
-4. 在同一位置重新连接到第 1 步 Fork 的仓库,并在页面底部将 **名称** 改回 **NodeWarden**。
+3. 部署完成后,在同一页面打开 Workers 设置,将 `Git 存储库` 断开连接。
+4. 在同一位置重新连接到第 1 步 Fork 的仓库,并在页面底部将`名称` 改回 **NodeWarden**。
5. GitHub 仓库 **NodeWarden2** 可以删除。
@@ -76,20 +75,22 @@ English:[`README_EN.md`](./README_EN.md)
>- **R2**:需绑定银行卡;**单个附件 / Send 文件上限 100 MB**(代码限制,可自行修改);**总量 10 GB 免费**
>- **KV**:无需绑卡;**单个附件 / Send 文件上限 25 MiB**(Cloudflare 限制,不可修改);**总量 1 GB 免费**
>
->1. 先 Fork 本仓库,并命名为 **NodeWarden**。
->2. 打开 GitHub 仓库,进入 `Actions` 页面,运行 **Switch to KV mode**(自动将 [wrangler.toml](./wrangler.toml) 切换为 KV 配置。)
->3. **在你自己的仓库中**点击下面的按钮,在打开的页面中将项目名称改为 **NodeWarden2**,并将 **JWT_SECRET** 设置为 32 位随机字符串。
+>1. 先 Fork 本仓库,并命名为 **NodeWarden**(默认自动填写)
+>2. 进入新仓库,进入 `Actions` 页面,点击 `I understand my workflows, go ahead and enable them`,点击 `Switch to KV mode`,点击`Run Workflow`
+>3. 成功后**在你自己的仓库中**点击下面的按钮,在打开的页面中将项目名称改为 **NodeWarden2**,并将 **JWT_SECRET** 设置为 32 位随机字符串。
>
> [](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
>
->4. 部署完成后,在同一页面打开 Workers 设置,将 **Git 存储库** 断开连接。
->5. 在同一位置重新连接到第 1 步 Fork 的仓库,并在页面底部将 **名称** 改回 **NodeWarden**。
->6. GitHub 仓库 **NodeWarden2** 可以删除。
+>4. 在同一页面打开 Workers 设置,将 `Git 存储库` 断开连接。
+>5. 返回Github进入Fork后的仓库(NodeWarden),进入 `Actions` 页面,运行`Import KV ID from NodeWarden2`
+>6. 返回cloudflare,`Git 存储库`连接到Fork后的仓库(NodeWarden),并在页面底部将`名称`改回 **NodeWarden**。
+>7. GitHub 仓库 **NodeWarden2** 可以删除了。
+
> [!TIP]
-> 同步上游(更新仓库):
->- 手动:打开你 Fork 的 GitHub 仓库,看到顶部同步提示后,点击 `Sync fork`。
+> 同步方法(更新仓库):
+>- 手动:打开你 Fork 的 GitHub 仓库,看到顶部同步提示后,点击 `Sync fork`。(不要点Contribute)
>- 自动:进入你的 Fork 仓库 -> `Actions`,点击 `I understand my workflows, go ahead and enable them`,启用后,`Sync upstream` 会在每天凌晨 3 点自动同步上游 `main`,并保留你当前的 [wrangler.toml](./wrangler.toml) 配置不被覆盖。
diff --git a/README_EN.md b/README_EN.md
index dc2826a..aee0dd8 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -55,8 +55,6 @@
### One-click deploy
-**Deploy steps:**
-
> **If you only want a quick trial, simply click the one-click deploy button in step 2. The remaining steps are mainly for long-term maintenance.**
1. Fork this repository and name it **NodeWarden**.
@@ -76,19 +74,20 @@
>- **KV**: no card required; **single attachment / Send file limit is 25 MiB** (Cloudflare limit, not editable); **1 GB free storage**
>
>1. Fork this repository and name it **NodeWarden**.
->2. Open your GitHub repository, go to the `Actions` page, and run **Switch to KV mode** (this automatically switches [wrangler.toml](./wrangler.toml) to the KV configuration).
->3. **In your own repository**, click the button below. On the page that opens, rename the project to **NodeWarden2** and set **JWT_SECRET** to a random 32-character string.
+>2. Open your new repository, go to `Actions`, click `I understand my workflows, go ahead and enable them`, then run `Switch to KV mode`.
+>3. After that, **in your own repository**, click the button below. On the page that opens, rename the project to **NodeWarden2** and set **JWT_SECRET** to a random 32-character string.
>
> [](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
>
->4. After deployment, open the Worker settings on the same page and disconnect the **Git repository**.
->5. Reconnect the **Git repository** to the fork from step 1, then change the **Name** field at the bottom to **NodeWarden**.
->6. The GitHub repository **NodeWarden2** can be deleted.
+>4. On the same page, open the Worker settings and disconnect the `Git repository`.
+>5. Go back to your forked repository (**NodeWarden**) on GitHub, open `Actions`, and run `Import KV ID from NodeWarden2`.
+>6. Return to Cloudflare, reconnect the `Git repository` to your forked repository (**NodeWarden**), and change the `Name` field at the bottom back to **NodeWarden**.
+>7. The GitHub repository **NodeWarden2** can then be deleted.
> [!TIP]
> Sync upstream (keep your fork updated):
->- Manual: open your fork on GitHub and click `Sync fork` when prompted.
+>- Manual: open your fork on GitHub and click `Sync fork` when prompted. Do not click `Contribute`.
>- Automatic: in your fork, go to `Actions`, click `I understand my workflows, go ahead and enable them`. Once enabled, `Sync upstream` will automatically sync the upstream `main` branch every day at 3 AM and keep your current [wrangler.toml](./wrangler.toml) configuration unchanged.
### CLI deploy
diff --git a/webapp/src/lib/i18n.ts b/webapp/src/lib/i18n.ts
index d8e454f..980a44b 100644
--- a/webapp/src/lib/i18n.ts
+++ b/webapp/src/lib/i18n.ts
@@ -1,4 +1,4 @@
-type Locale = 'en' | 'zh-CN';
+type Locale = 'en' | 'zh-CN';
const LOCALE_STORAGE_KEY = 'nodewarden.locale';
@@ -153,7 +153,7 @@ const messages: Record> = {
txt_identity: "Identity",
txt_identity_details: "Identity Details",
txt_ie_browser: "IE Browser",
- txt_invite_code_optional: "Invite Code (Optional)",
+ txt_invite_code_optional: "Invite Code (Not required for the first account; required for all others)",
txt_invite_created: "Invite created",
txt_invite_revoked: "Invite revoked",
txt_invite_validity_hours: "Invite validity (hours)",
@@ -625,7 +625,7 @@ const zhCNOverrides: Record = {
txt_folder_created: '文件夹已创建',
txt_folder_name_is_required: '文件夹名称不能为空',
txt_ie_browser: 'IE 浏览器',
- txt_invite_code_optional: '邀请码(可选)',
+ txt_invite_code_optional: '邀请码(首位注册者无需填写,其他人必填)',
txt_invite_created: '邀请码已创建',
txt_invite_revoked: '邀请码已撤销',
txt_ios: 'iOS',
@@ -909,3 +909,4 @@ export function setLocale(next: Locale): void {
// ignore storage errors
}
}
+