From 2267ceb4e87f179b8df9b12934c189b3ba504104 Mon Sep 17 00:00:00 2001 From: lihan Date: Tue, 14 May 2024 09:40:09 +0800 Subject: [PATCH] doc: plugin howto section improve https://github.com/version-fox/vfox/pull/259#issuecomment-2108763225 --- docs/plugins/available.md | 4 ++-- docs/plugins/create/howto.md | 23 ++++++++++++++++++++++- docs/zh-hans/plugins/available.md | 6 +++--- docs/zh-hans/plugins/create/howto.md | 25 ++++++++++++++++++++++--- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/docs/plugins/available.md b/docs/plugins/available.md index b4cdff24..65089688 100644 --- a/docs/plugins/available.md +++ b/docs/plugins/available.md @@ -18,12 +18,12 @@ axios.get('https://vfox-plugins.lhan.me/index.json').then(res => { }) const parseGitHubUrl = (url) => { - const regex = /^https?:\/\/github\.com\/([^\/]+)\/([^\/]+)/; + const regex = /^https:\/\/github\.com\/version-fox\//; const match = url.match(regex); if (match) { return { isGitHub: true, - url: `https://img.shields.io/github/downloads/${match[1]}/${match[2]}/total?style=social`, + url: `https://img.shields.io/badge/official-a`, }; } else { return { diff --git a/docs/plugins/create/howto.md b/docs/plugins/create/howto.md index 9cd5bf9a..31f6354c 100644 --- a/docs/plugins/create/howto.md +++ b/docs/plugins/create/howto.md @@ -56,6 +56,8 @@ the specific version, download source, and other information. `vfox` will help y directory in advance. If it is a compressed package such as `tar`, `tar.gz`, `tar.xz`, `zip`, `vfox` will help you to decompress it directly. + + By default, `vfox` reads the file name from the URL. If the last item in the URL is not a valid file name, you should specify the file name by appending a fragment at the end, so that `vfox` can identify the file format and decompress it. For example: `https://example.com/1234567890#/filename.zip`. @@ -76,7 +78,7 @@ function PLUGIN:PreInstall(ctx) --- request headers for remote URL [optional] headers = { ["xxx"] = "xxx", - } + }, --- note information [optional] note = "xxx", --- SHA256 checksum [optional] @@ -288,6 +290,25 @@ Currently, VersionFox plugin testing is straightforward. You only need to place - PLUGIN:PostInstall -> `vfox install @` - PLUGIN:Available -> `vfox search ` - PLUGIN:EnvKeys -> `vfox use @` + +In addition, you can use the `--debug` parameter to view more log information, for example: + +```shell +vfox --debug install @ +vfox --debug use @ + +... +``` + + +## Example + +Here is an example of a plugin that supports the `Node.js`. + +https://github.com/version-fox/vfox-nodejs + +You can refer to this plugin to develop your own plugin. + ## Publish to the public registry diff --git a/docs/zh-hans/plugins/available.md b/docs/zh-hans/plugins/available.md index f246d669..6f2da1dd 100644 --- a/docs/zh-hans/plugins/available.md +++ b/docs/zh-hans/plugins/available.md @@ -18,12 +18,12 @@ axios.get('https://vfox-plugins.lhan.me/index.json').then(res => { }) const parseGitHubUrl = (url) => { - const regex = /^https?:\/\/github\.com\/([^\/]+)\/([^\/]+)/; + const regex = /^https:\/\/github\.com\/version-fox\//; const match = url.match(regex); if (match) { return { isGitHub: true, - url: `https://img.shields.io/github/downloads/${match[1]}/${match[2]}/total?style=social`, + url: `https://img.shields.io/badge/official-a`, }; } else { return { @@ -41,7 +41,7 @@ const parseGitHubUrl = (url) => { ::: tip 提醒 这些都是来自社区的 vfox 插件 -你可以通过一下命令来快速安装! +你可以通过以下命令来快速安装! ```shell vfox add diff --git a/docs/zh-hans/plugins/create/howto.md b/docs/zh-hans/plugins/create/howto.md index 5597642c..290d350f 100644 --- a/docs/zh-hans/plugins/create/howto.md +++ b/docs/zh-hans/plugins/create/howto.md @@ -51,7 +51,8 @@ ### PreInstall 返回预安装信息, 例如具体版本号、下载源等信息。 `vfox`会帮你提前将这些文件下载到特定目录下。如果是压缩包如`tar`、`tar.gz`、`tar.xz`、`zip`这四种压缩包, `vfox`会直接帮你解压处理。 -vfox默认从下载链接中获取文件名,如果下载链接最后一项不是有效的文件名,可以通过在链接末尾附加Fragment来指定文件名,以便于vfox识别文件格式并解压。如:`https://example.com/1234567890#/filename.zip` + +`vfox`默认从下载链接中获取文件名,如果下载链接最后一项不是有效的文件名,可以通过在链接末尾附加Fragment来指定文件名,以便于`vfox`识别文件格式并解压。 如:`https://example.com/1234567890#/filename.zip` 如果版本的返回值为空,表示未找到版本,`vfox`会询问用户是否进行搜索操作。 @@ -68,7 +69,7 @@ function PLUGIN:PreInstall(ctx) --- 下载链接的请求头 [可选] headers = { ["xxx"] = "xxx", - } + }, --- 备注信息 [可选] note = "xxx", --- SHA256 checksum [optional] @@ -266,13 +267,31 @@ end ## 测试插件 -目前,`vfox` 插件测试方法很简陋。您需要将插件放在 `${HOME}/.version-fox/plugins` 目录中,并使用不同的命令验证您的功能是否正常工作。您可以在c插件中使用 `print`/`printTable` 函数来打印日志进行调试。 +目前,`vfox` 插件测试方法很简陋。您需要将插件放在 `${HOME}/.version-fox/plugins` 目录中,并使用不同的命令验证您的功能是否正常工作。 +您可以在插件中使用 `print`/`printTable` 函数来打印日志进行调试。 - PLUGIN:PreInstall -> `vfox install @` - PLUGIN:PostInstall -> `vfox install @` - PLUGIN:Available -> `vfox search ` - PLUGIN:EnvKeys -> `vfox use @` +另外, 你可以通过添加 `--debug` 参数来查看更多的日志信息, 例如: + +```shell +vfox --debug install @ +vfox --debug use @ + +... +``` + + + +## 插件示例 + +https://github.com/version-fox/vfox-nodejs + +你可以参考这个插件来开发自己的插件。 + ## 向官方插件存储库提交插件