Skip to content

Commit

Permalink
doc: plugin howto section improve
Browse files Browse the repository at this point in the history
  • Loading branch information
aooohan committed May 14, 2024
1 parent f524c33 commit 2267ceb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/plugins/available.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 22 additions & 1 deletion docs/plugins/create/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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]
Expand Down Expand Up @@ -288,6 +290,25 @@ Currently, VersionFox plugin testing is straightforward. You only need to place
- PLUGIN:PostInstall -> `vfox install <sdk-name>@<version>`
- PLUGIN:Available -> `vfox search <sdk-name>`
- PLUGIN:EnvKeys -> `vfox use <sdk-name>@<version>`

In addition, you can use the `--debug` parameter to view more log information, for example:

```shell
vfox --debug install <sdk-name>@<version>
vfox --debug use <sdk-name>@<version>

...
```


## 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

Expand Down
6 changes: 3 additions & 3 deletions docs/zh-hans/plugins/available.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -41,7 +41,7 @@ const parseGitHubUrl = (url) => {
::: tip 提醒
这些都是来自社区的 vfox 插件

你可以通过一下命令来快速安装!
你可以通过以下命令来快速安装!

```shell
vfox add <name>
Expand Down
25 changes: 22 additions & 3 deletions docs/zh-hans/plugins/create/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`会询问用户是否进行搜索操作。

Expand All @@ -68,7 +69,7 @@ function PLUGIN:PreInstall(ctx)
--- 下载链接的请求头 [可选]
headers = {
["xxx"] = "xxx",
}
},
--- 备注信息 [可选]
note = "xxx",
--- SHA256 checksum [optional]
Expand Down Expand Up @@ -266,13 +267,31 @@ end

## 测试插件

目前,`vfox` 插件测试方法很简陋。您需要将插件放在 `${HOME}/.version-fox/plugins` 目录中,并使用不同的命令验证您的功能是否正常工作。您可以在c插件中使用 `print`/`printTable` 函数来打印日志进行调试。
目前,`vfox` 插件测试方法很简陋。您需要将插件放在 `${HOME}/.version-fox/plugins` 目录中,并使用不同的命令验证您的功能是否正常工作。
您可以在插件中使用 `print`/`printTable` 函数来打印日志进行调试。

- PLUGIN:PreInstall -> `vfox install <sdk-name>@<version>`
- PLUGIN:PostInstall -> `vfox install <sdk-name>@<version>`
- PLUGIN:Available -> `vfox search <sdk-name>`
- PLUGIN:EnvKeys -> `vfox use <sdk-name>@<version>`

另外, 你可以通过添加 `--debug` 参数来查看更多的日志信息, 例如:

```shell
vfox --debug install <sdk-name>@<version>
vfox --debug use <sdk-name>@<version>

...
```



## 插件示例

https://github.com/version-fox/vfox-nodejs

你可以参考这个插件来开发自己的插件。



## 向官方插件存储库提交插件
Expand Down

0 comments on commit 2267ceb

Please sign in to comment.