forked from version-fox/version-fox-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.lua
96 lines (89 loc) · 2.94 KB
/
template.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
--- Common libraries provided by VersionFox (optional)
local http = require("http")
local json = require("json")
local html = require("html")
--- The following two parameters are injected by VersionFox at runtime
--- Operating system type at runtime (Windows, Linux, Darwin)
------ Default global variable
----- OS_TYPE: windows, linux, darwin
----- ARCH_TYPE: 386, amd64, arm, arm64 ...
OS_TYPE = ""
--- Operating system architecture at runtime (amd64, arm64, etc.)
ARCH_TYPE = ""
PLUGIN = {
--- Plugin name, only numbers, letters, and underscores are allowed
name = "java",
--- Plugin author
author = "Lihan",
--- Plugin version
version = "0.0.1",
-- Update URL
updateUrl = "{URL}/sdk.lua",
}
--- Return information about the specified version based on ctx.version, including version, download URL, etc.
--- @param ctx table
--- @field ctx.version string User-input version
--- @return table Version information
function PLUGIN:PreInstall(ctx)
return {
--- Version number
version = "xxx",
--- Download URL, support tar.gz tar.xz zip three formats
url = "xxx",
--- You just choose one of the checksum algorithms.
--- SHA256 checksum, first choice!
sha256 = "xxx",
--- sha1 checksum [optional]
sha1= "xxx",
--- sha512 checksum [optional]
sha512= "xxx",
--- md5 checksum [optional]
md5= "xxx",
}
end
--- Extension point, called after PreInstall, can perform additional operations,
--- such as file operations for the SDK installation directory
--- Currently can be left unimplemented!
function PLUGIN:PostInstall(ctx)
--- ctx.rootPath SDK installation directory
local rootPath = ctx.rootPath
local sdkInfo = ctx.sdkInfo['sdk-name']
local path = sdkInfo.path
local version = sdkInfo.version
local name = sdkInfo.name
end
--- Return all available versions provided by this plugin
--- @param ctx table Empty table used as context, for future extension
--- @return table Descriptions of available versions and accompanying tool descriptions
function PLUGIN:Available(ctx)
return {
{
version = "xxxx",
note = "LTS",
addition = {
{
name = "npm",
version = "8.8.8",
}
}
}
}
end
--- Each SDK may have different environment variable configurations.
--- This allows plugins to define custom environment variables (including PATH settings)
--- Note: Be sure to distinguish between environment variable settings for different platforms!
--- @param ctx table Context information
--- @field ctx.version_path string SDK installation directory
function PLUGIN:EnvKeys(ctx)
local mainPath = ctx.version_path
return {
{
key = "JAVA_HOME",
value = mainPath
},
{
key = "PATH",
value = mainPath .. "/bin"
}
}
end