Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Injection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ RUNTIME = {
--- Plugin directory
pluginDirPath = "",
}

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ Keep runtime resources under `lib/`. Shared checks validate metadata, required h
files and Lua syntax and build the same package used for publishing. They do not
run lifecycle hooks or install SDKs. See the [package contract](https://github.com/version-fox/plugin-manifest-action#插件包与检查范围).

## Lua checks and formatting

Use [StyLua 2.5.2](https://github.com/JohnnyMorganz/StyLua/releases/tag/v2.5.2)
with the included `stylua.toml` configuration:

```shell
stylua .
stylua --check .
```

The shared PR check validates metadata, required hooks and Lua 5.1 syntax.
Repositories with `stylua.toml` also receive a read-only format check after the
shared tool release containing that check is published. Existing plugins can opt
in by adding this configuration and formatting their Lua files together.
Plugin behavior tests remain separate from syntax and style checks.

## Publish a plugin

Merge your changes into the default branch, then open **Actions → Plugin → Run
Expand Down
8 changes: 4 additions & 4 deletions hooks/available.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function PLUGIN:Available(ctx)
{
name = "npm",
version = "8.8.8",
}
}
}
},
},
},
}
end
end
12 changes: 5 additions & 7 deletions hooks/env_keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ function PLUGIN:EnvKeys(ctx)
local mpath = mainSdkInfo.path
local mversion = mainSdkInfo.version
local mname = mainSdkInfo.name
local sdkInfo = ctx.sdkInfo['sdk-name']
local sdkInfo = ctx.sdkInfo["sdk-name"]
local path = sdkInfo.path
local version = sdkInfo.version
local name = sdkInfo.name
return {
{
key = "JAVA_HOME",
value = mainPath
value = mainPath,
},
{
key = "PATH",
value = mainPath .. "/bin"
value = mainPath .. "/bin",
},
{
key = "PATH",
value = mainPath .. "/bin2"
value = mainPath .. "/bin2",
},

}

end
end
4 changes: 2 additions & 2 deletions hooks/parse_legacy_file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ function PLUGIN:ParseLegacyFile(ctx)
local versions = ctx:getInstalledVersions()

return {
version = "xxx"
version = "xxx",
}
end
end
4 changes: 2 additions & 2 deletions hooks/post_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
function PLUGIN:PostInstall(ctx)
--- ctx.rootPath SDK installation directory
local rootPath = ctx.rootPath
local sdkInfo = ctx.sdkInfo['sdk-name']
local sdkInfo = ctx.sdkInfo["sdk-name"]
local path = sdkInfo.path
local version = sdkInfo.version
local name = sdkInfo.name
local note = sdkInfo.note
end
end
6 changes: 3 additions & 3 deletions hooks/pre_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function PLUGIN:PreInstall(ctx)
sha1 = "xxx",
--- sha512 checksum [optional]
sha512 = "xx",
}
}
},
},
}
end
end
3 changes: 1 addition & 2 deletions hooks/pre_uninstall.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

--- This is called before the SDK is uninstalled.
--- @param ctx table Context information
function PLUGIN:PreUninstall(ctx)
local mainSdkInfo = ctx.main
local mpath = mainSdkInfo.path
local mversion = mainSdkInfo.version
local mname = mainSdkInfo.name
end
end
4 changes: 2 additions & 2 deletions hooks/pre_use.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function PLUGIN:PreUse(ctx)
local previousVersion = ctx.previousVersion

--- installed sdks
local sdkInfo = ctx.installedSdks['version']
local sdkInfo = ctx.installedSdks["version"]
local path = sdkInfo.path
local name = sdkInfo.name
local version = sdkInfo.version
Expand All @@ -24,4 +24,4 @@ function PLUGIN:PreUse(ctx)
return {
version = version,
}
end
end
3 changes: 1 addition & 2 deletions lib/util.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

local util = {}

function util:DoSomeThing()
print("Do some thing")
end

return util
return util
7 changes: 2 additions & 5 deletions metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ PLUGIN.license = "Apache 2.0"
--- Plugin description
PLUGIN.description = "your plugin description"


--- !!! OPTIONAL !!!
--[[
NOTE:
Expand All @@ -35,10 +34,8 @@ NOTE:
--]]
PLUGIN.manifestUrl = "https://github.com/version-fox/vfox-plugin-template/releases/download/manifest/manifest.json"
-- Some things that need user to be attention!
PLUGIN.notes = {
}
PLUGIN.notes = {}

--- List legacy configuration filenames for determining the specified version of the tool.
--- such as ".node-version", ".nvmrc", etc.
PLUGIN.legacyFilenames = {
}
PLUGIN.legacyFilenames = {}
11 changes: 11 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "Lua51"
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "Never"

[sort_requires]
enabled = false