diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 36af5e0..49834e5 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -59,4 +59,4 @@ jobs:
artifactErrorsFailBuild: true
artifacts: "package.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- prerelease: true
+ prerelease: false
diff --git a/README.md b/README.md
index f0b2a1c..648dcb7 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,14 @@
4. Provides a github action template to automatically generate package.zip and upload to new release
+> [!TIP]
+> You can also use our maintained [siyuan-plugin-cli](https://www.npmjs.com/package/siyuan-plugin-cli) command-line tool to directly build plugins in your local terminal.
+>
+> Additionally, for the `make-link` related commands mentioned in this plugin, all future updates will be made in [siyuan-plugin-cli](https://www.npmjs.com/package/siyuan-plugin-cli).
+>
+> The built-in `make-link` scripts may also be removed in a future version, in favor of using the `siyuan-plugin-cli` tool, aiming to simplify the workload of maintaining multiple plugin templates.
+
+
## Get started
1. Use the Use this template button to make a copy of this repo as a template. Note that the repository name should match the plugin name, and the default branch must be `main`.
diff --git a/README_zh_CN.md b/README_zh_CN.md
index e60f454..0ac9fca 100644
--- a/README_zh_CN.md
+++ b/README_zh_CN.md
@@ -26,6 +26,13 @@
5. 执行 `pnpm run dev` 进行实时编译
6. 在思源中打开集市并在下载选项卡中启用插件
+> [!TIP]
+> 你也可以使用我们维护的 [siyuan-plugin-cli](https://www.npmjs.com/package/siyuan-plugin-cli) 命令行工具,在本地终端中直接构建插件。
+>
+> 此外,对于本插件以下提及到的 `make-link` 相关的命令,后续所有更新将在 [siyuan-plugin-cli](https://www.npmjs.com/package/siyuan-plugin-cli) 中进行。
+>
+> 模板内置的 `make-link` 脚本也可能会在未来某个版本中移除,转而使用 `siyuan-plugin-cli` 工具,意在简化同时维护多个插件模板的工作量。
+
### 设置 make-link 命令的目标目录
make-link 命令会创建符号链接将你的 `dev` 目录绑定到思源的插件目录下。你可以有三种方式来配置目标的思源工作空间并创建符号链接:
diff --git a/package.json b/package.json
index 971fd74..2b7cdec 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "plugin-sample-vite-svelte",
- "version": "0.3.5",
+ "version": "0.3.6",
"type": "module",
"description": "This is a sample plugin based on vite and svelte for Siyuan (https://b3log.org/siyuan)",
"repository": "",
@@ -8,28 +8,30 @@
"author": "frostime",
"license": "MIT",
"scripts": {
+ "dev": "cross-env NODE_ENV=development VITE_SOURCEMAP=inline vite build --watch",
+ "build": "cross-env NODE_ENV=production vite build",
"make-link": "node --no-warnings ./scripts/make_dev_link.js",
"make-link-win": "powershell.exe -NoProfile -ExecutionPolicy Bypass -File ./scripts/elevate.ps1 -scriptPath ./scripts/make_dev_link.js",
- "dev": "vite build --watch",
- "build": "vite build",
+ "update-version": "node --no-warnings ./scripts/update_version.js",
"make-install": "vite build && node --no-warnings ./scripts/make_install.js"
},
"devDependencies": {
- "@sveltejs/vite-plugin-svelte": "^3.0.0",
+ "@sveltejs/vite-plugin-svelte": "^3.1.0",
"@tsconfig/svelte": "^4.0.1",
"@types/node": "^20.3.0",
+ "cross-env": "^7.0.3",
"fast-glob": "^3.2.12",
- "glob": "^7.2.3",
+ "glob": "^10.0.0",
"js-yaml": "^4.1.0",
"minimist": "^1.2.8",
"rollup-plugin-livereload": "^2.0.5",
"sass": "^1.63.3",
- "siyuan": "0.9.9",
- "svelte": "^4.2.0",
+ "siyuan": "1.0.4",
+ "svelte": "^4.2.19",
"ts-node": "^10.9.1",
"typescript": "^5.1.3",
- "vite": "^5.0.0",
+ "vite": "^5.2.9",
"vite-plugin-static-copy": "^1.0.2",
"vite-plugin-zip-pack": "^1.0.5"
}
-}
+}
\ No newline at end of file
diff --git a/plugin.json b/plugin.json
index 1af2cfe..fd63a3c 100644
--- a/plugin.json
+++ b/plugin.json
@@ -2,15 +2,16 @@
"name": "plugin-sample-vite-svelte",
"author": "frostime",
"url": "https://github.com/siyuan-note/plugin-sample-vite-svelte",
- "version": "0.3.5",
+ "version": "0.3.6",
"minAppVersion": "3.0.12",
"backends": [
"windows",
"linux",
"darwin",
- "docker",
"ios",
- "android"
+ "android",
+ "harmony",
+ "docker"
],
"frontends": [
"desktop",
@@ -37,6 +38,8 @@
]
},
"keywords": [
- "plugin", "sample", "插件样例"
+ "plugin",
+ "sample",
+ "插件样例"
]
}
diff --git a/public/i18n/README.md b/public/i18n/README.md
new file mode 100644
index 0000000..af8de98
--- /dev/null
+++ b/public/i18n/README.md
@@ -0,0 +1,12 @@
+思源支持的 i18n 文件范围,可以在控制台 `siyuan.config.langs` 中查看。以下是目前(2024-10-24)支持的语言方案:
+
+The range of i18n files supported by SiYuan can be viewed in the console under `siyuan.config.langs`. Below are the language schemes currently supported as of now (October 24, 2024) :
+
+```js
+>>> siyuan.config.langs.map( lang => lang.name)
+['de_DE', 'en_US', 'es_ES', 'fr_FR', 'he_IL', 'it_IT', 'ja_JP', 'pl_PL', 'ru_RU', 'zh_CHT', 'zh_CN']
+```
+
+在插件开发中,默认使用 JSON 格式作为国际化(i18n)的载体文件。如果您更喜欢使用 YAML 语法,可以将 JSON 文件替换为 YAML 文件(例如 `en_US.yaml`),并在其中编写 i18n 文本。本模板提供了相关的 Vite 插件,可以在编译时自动将 YAML 文件转换为 JSON 文件(请参见 `/yaml-plugin.js`)。本 MD 文件 和 YAML 文件会在 `npm run build` 时自动从 `dist` 目录下删除,仅保留必要的 JSON 文件共插件系统使用。
+
+In plugin development, JSON format is used by default as the carrier file for internationalization (i18n). If you prefer to use YAML syntax, you can replace the JSON file with a YAML file (e.g., `en_US.yaml`) and write the i18n text within it. This template provides a related Vite plugin that can automatically convert YAML files to JSON files during the compilation process (see `/yaml-plugin.js`). This markdown file and YAML files will be automatically removed from the `dist` directory during `npm run build`, leaving only the necessary JSON files for plugin system to use.
diff --git a/public/i18n/zh_CN.json b/public/i18n/zh_CN.json
new file mode 100644
index 0000000..6600f6a
--- /dev/null
+++ b/public/i18n/zh_CN.json
@@ -0,0 +1,20 @@
+{
+ "addTopBarIcon": "使用插件添加一个顶栏按钮",
+ "cancel": "取消",
+ "save": "保存",
+ "byeMenu": "再见,菜单!",
+ "helloPlugin": "你好,插件!",
+ "byePlugin": "再见,插件!",
+ "showDialog": "弹出一个对话框",
+ "removedData": "数据已删除",
+ "confirmRemove": "确认删除 ${name} 中的数据?",
+ "insertEmoji": "插入表情",
+ "removeSpace": "移除空格",
+ "getTab": "在日志中打印出已打开的所有自定义页签",
+ "name": "思源",
+ "hello": {
+ "makesure": "使用这个模板之前,请阅读官方教程, 确保自己已经理解了插件的基本开发流程。"
+ },
+ "hintTitle": "关于",
+ "hintDesc": "🔗 plugin-sample-vite-svelte
💻 @frostime
💻 @88250
💻 @zxkmm"
+}
\ No newline at end of file
diff --git a/public/i18n/zh_CN.yaml b/public/i18n/zh_CN.yaml
deleted file mode 100644
index 16099a3..0000000
--- a/public/i18n/zh_CN.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
----
-addTopBarIcon: 使用插件添加一个顶栏按钮
-cancel: 取消
-save: 保存
-byeMenu: 再见,菜单!
-helloPlugin: 你好,插件!
-byePlugin: 再见,插件!
-showDialog: 弹出一个对话框
-removedData: 数据已删除
-confirmRemove: 确认删除 ${name} 中的数据?
-insertEmoji: 插入表情
-removeSpace: 移除空格
-getTab: 在日志中打印出已打开的所有自定义页签
-name: 思源
-hello:
- makesure: 使用这个模板之前,请阅读官方教程,
- 确保自己已经理解了插件的基本开发流程。
-hintTitle: 关于
-hintDesc: "\U0001F517
- plugin-sample-vite-svelte
\U0001F4BB @frostime
\U0001F4BB @88250
\U0001F4BB
- @zxkmm"
diff --git a/scripts/update_version.js b/scripts/update_version.js
new file mode 100644
index 0000000..775c98a
--- /dev/null
+++ b/scripts/update_version.js
@@ -0,0 +1,141 @@
+// const fs = require('fs');
+// const path = require('path');
+// const readline = require('readline');
+import fs from 'node:fs';
+import path from 'node:path';
+import readline from 'node:readline';
+
+// Utility to read JSON file
+function readJsonFile(filePath) {
+ return new Promise((resolve, reject) => {
+ fs.readFile(filePath, 'utf8', (err, data) => {
+ if (err) return reject(err);
+ try {
+ const jsonData = JSON.parse(data);
+ resolve(jsonData);
+ } catch (e) {
+ reject(e);
+ }
+ });
+ });
+}
+
+// Utility to write JSON file
+function writeJsonFile(filePath, jsonData) {
+ return new Promise((resolve, reject) => {
+ fs.writeFile(filePath, JSON.stringify(jsonData, null, 2), 'utf8', (err) => {
+ if (err) return reject(err);
+ resolve();
+ });
+ });
+}
+
+// Utility to prompt the user for input
+function promptUser(query) {
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout
+ });
+ return new Promise((resolve) => rl.question(query, (answer) => {
+ rl.close();
+ resolve(answer);
+ }));
+}
+
+// Function to parse the version string
+function parseVersion(version) {
+ const [major, minor, patch] = version.split('.').map(Number);
+ return { major, minor, patch };
+}
+
+// Function to auto-increment version parts
+function incrementVersion(version, type) {
+ let { major, minor, patch } = parseVersion(version);
+
+ switch (type) {
+ case 'major':
+ major++;
+ minor = 0;
+ patch = 0;
+ break;
+ case 'minor':
+ minor++;
+ patch = 0;
+ break;
+ case 'patch':
+ patch++;
+ break;
+ default:
+ break;
+ }
+
+ return `${major}.${minor}.${patch}`;
+}
+
+// Main script
+(async function () {
+ try {
+ const pluginJsonPath = path.join(process.cwd(), 'plugin.json');
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
+
+ // Read both JSON files
+ const pluginData = await readJsonFile(pluginJsonPath);
+ const packageData = await readJsonFile(packageJsonPath);
+
+ // Get the current version from both files (assuming both have the same version)
+ const currentVersion = pluginData.version || packageData.version;
+ console.log(`\n🌟 Current version: \x1b[36m${currentVersion}\x1b[0m\n`);
+
+ // Calculate potential new versions for auto-update
+ const newPatchVersion = incrementVersion(currentVersion, 'patch');
+ const newMinorVersion = incrementVersion(currentVersion, 'minor');
+ const newMajorVersion = incrementVersion(currentVersion, 'major');
+
+ // Prompt the user with formatted options
+ console.log('🔄 How would you like to update the version?\n');
+ console.log(` 1️⃣ Auto update \x1b[33mpatch\x1b[0m version (new version: \x1b[32m${newPatchVersion}\x1b[0m)`);
+ console.log(` 2️⃣ Auto update \x1b[33mminor\x1b[0m version (new version: \x1b[32m${newMinorVersion}\x1b[0m)`);
+ console.log(` 3️⃣ Auto update \x1b[33mmajor\x1b[0m version (new version: \x1b[32m${newMajorVersion}\x1b[0m)`);
+ console.log(` 4️⃣ Input version \x1b[33mmanually\x1b[0m`);
+ // Press 0 to skip version update
+ console.log(' 0️⃣ Quit without updating\n');
+
+ const updateChoice = await promptUser('👉 Please choose (1/2/3/4): ');
+
+ let newVersion;
+
+ switch (updateChoice.trim()) {
+ case '1':
+ newVersion = newPatchVersion;
+ break;
+ case '2':
+ newVersion = newMinorVersion;
+ break;
+ case '3':
+ newVersion = newMajorVersion;
+ break;
+ case '4':
+ newVersion = await promptUser('✍️ Please enter the new version (in a.b.c format): ');
+ break;
+ case '0':
+ console.log('\n🛑 Skipping version update.');
+ return;
+ default:
+ console.log('\n❌ Invalid option, no version update.');
+ return;
+ }
+
+ // Update the version in both plugin.json and package.json
+ pluginData.version = newVersion;
+ packageData.version = newVersion;
+
+ // Write the updated JSON back to files
+ await writeJsonFile(pluginJsonPath, pluginData);
+ await writeJsonFile(packageJsonPath, packageData);
+
+ console.log(`\n✅ Version successfully updated to: \x1b[32m${newVersion}\x1b[0m\n`);
+
+ } catch (error) {
+ console.error('❌ Error:', error);
+ }
+})();
diff --git a/src/hello.svelte b/src/hello.svelte
index cc9f0dd..967c7f6 100644
--- a/src/hello.svelte
+++ b/src/hello.svelte
@@ -1,3 +1,11 @@
+