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
13 changes: 6 additions & 7 deletions crates/vfox/plugins/dummy/Injection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ it's just there to show what objects are injected by vfox and what they do.
It's just handy when developing plugins, IDE can use this object for code hints!
--]]
RUNTIME = {
--- Operating system type at runtime (Windows, Linux, Darwin)
osType = "",
--- Operating system architecture at runtime (amd64, arm64, etc.)
archType = "",
--- vfox runtime version
version = "",
--- Operating system type at runtime (Windows, Linux, Darwin)
osType = "",
--- Operating system architecture at runtime (amd64, arm64, etc.)
archType = "",
--- vfox runtime version
version = "",
}

40 changes: 20 additions & 20 deletions crates/vfox/plugins/dummy/hooks/available.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
--- @param ctx table Empty table, no data provided. Always {}.
--- @return table Version list
function PLUGIN:Available(ctx)
if os.getenv("TEST_VFOX_LOG") then
local log = require("log")
log.trace("log.trace msg")
log.debug("log.debug msg")
log.info("log.info msg")
log.warn("log.warn msg")
log.error("log.error msg")
log.info("multi", "arg", 123)
print("print msg")
io.stderr:write("stderr msg\n")
end
return {
{
version = "1.0.0"
},
{
version = "1.0.1"
},
}
end
if os.getenv("TEST_VFOX_LOG") then
local log = require("log")
log.trace("log.trace msg")
log.debug("log.debug msg")
log.info("log.info msg")
log.warn("log.warn msg")
log.error("log.error msg")
log.info("multi", "arg", 123)
print("print msg")
io.stderr:write("stderr msg\n")
end
return {
{
version = "1.0.0",
},
{
version = "1.0.1",
},
}
end
37 changes: 18 additions & 19 deletions crates/vfox/plugins/dummy/hooks/env_keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
--- Note: Be sure to distinguish between environment variable settings for different platforms!
--- @param ctx {path: string} Context information (path = SDK installation directory)
function PLUGIN:EnvKeys(ctx)
--- this variable is same as ctx.sdkInfo['plugin-name'].path
local version_path = ctx.path
if RUNTIME.osType == "windows" then
return {
{
key = "PATH",
value = version_path
},
}
else
return {
{
key = "PATH",
value = version_path .. "/bin"
},
}
end

end
--- this variable is same as ctx.sdkInfo['plugin-name'].path
local version_path = ctx.path
if RUNTIME.osType == "windows" then
return {
{
key = "PATH",
value = version_path,
},
}
else
return {
{
key = "PATH",
value = version_path .. "/bin",
},
}
end
end
34 changes: 17 additions & 17 deletions crates/vfox/plugins/dummy/hooks/parse_legacy_file.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
--- Parse the legacy file found by vfox to determine the version of the tool.
--- Useful to extract version numbers from files like JavaScript's package.json or Golangs go.mod.
function PLUGIN:ParseLegacyFile(ctx)
local filename = ctx.filename
if filename == nil then
error("ctx.filename is nil")
end
if filename ~= ".dummy-version" then
error("Expected filename to be .dummy-version, got " .. filename)
end
local filepath = ctx.filepath
local file = require("file")
local content = file.read(filepath)
content = content:gsub("%s+", "")
if content == "" then
return {}
end
local filename = ctx.filename
if filename == nil then
error("ctx.filename is nil")
end
if filename ~= ".dummy-version" then
error("Expected filename to be .dummy-version, got " .. filename)
end
local filepath = ctx.filepath
local file = require("file")
local content = file.read(filepath)
content = content:gsub("%s+", "")
if content == "" then
return {}
end

return {
version = content,
}
return {
version = content,
}
end
26 changes: 13 additions & 13 deletions crates/vfox/plugins/dummy/hooks/post_install.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
function PLUGIN:PostInstall(ctx)
--- SDK installation root path
local rootPath = ctx.rootPath
local runtimeVersion = ctx.runtimeVersion
--- SDK installation root path
local rootPath = ctx.rootPath
local runtimeVersion = ctx.runtimeVersion

-- Create the installation directory structure for dummy plugin
os.execute("mkdir -p " .. rootPath .. "/bin")
-- Create the installation directory structure for dummy plugin
os.execute("mkdir -p " .. rootPath .. "/bin")

-- Create a dummy executable
local dummy_file = io.open(rootPath .. "/bin/dummy", "w")
if dummy_file then
dummy_file:write("#!/bin/sh\necho 'dummy version 1.0.0'\n")
dummy_file:close()
os.execute("chmod +x " .. rootPath .. "/bin/dummy")
end
end
-- Create a dummy executable
local dummy_file = io.open(rootPath .. "/bin/dummy", "w")
if dummy_file then
dummy_file:write("#!/bin/sh\necho 'dummy version 1.0.0'\n")
dummy_file:close()
os.execute("chmod +x " .. rootPath .. "/bin/dummy")
end
end
10 changes: 5 additions & 5 deletions crates/vfox/plugins/dummy/hooks/pre_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
--- @param ctx {version: string} Context information (version = User-input version)
--- @return table Version information
function PLUGIN:PreInstall(ctx)
local version = ctx.version
local version = ctx.version

return {
version = version,
}
end
return {
version = version,
}
end
4 changes: 2 additions & 2 deletions crates/vfox/plugins/dummy/metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ PLUGIN.notes = {}
--- List legacy configuration filenames for determining the specified version of the tool.
--- such as ".node-version", ".nvmrc", etc.
PLUGIN.legacyFilenames = {
".dummy-version"
}
".dummy-version",
}
16 changes: 8 additions & 8 deletions crates/vfox/plugins/hooks/available.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
--- @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 = "1.0.0",
},
{
version = "1.0.1",
},
}
return {
{
version = "1.0.0",
},
{
version = "1.0.1",
},
}
end
37 changes: 18 additions & 19 deletions crates/vfox/plugins/hooks/env_keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
--- Note: Be sure to distinguish between environment variable settings for different platforms!
--- @param ctx {path: string} Context information (path = SDK installation directory)
function PLUGIN:EnvKeys(ctx)
--- this variable is same as ctx.sdkInfo['plugin-name'].path
local version_path = ctx.path
if RUNTIME.osType == "windows" then
return {
{
key = "PATH",
value = version_path
},
}
else
return {
{
key = "PATH",
value = version_path .. "/bin"
},
}
end

end
--- this variable is same as ctx.sdkInfo['plugin-name'].path
local version_path = ctx.path
if RUNTIME.osType == "windows" then
return {
{
key = "PATH",
value = version_path,
},
}
else
return {
{
key = "PATH",
value = version_path .. "/bin",
},
}
end
end
18 changes: 9 additions & 9 deletions crates/vfox/plugins/hooks/post_install.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function PLUGIN:PostInstall(ctx)
--- SDK installation root path
local rootPath = ctx.rootPath
local runtimeVersion = ctx.runtimeVersion
--- Other SDK information, the `addition` field returned in PreInstall, obtained by name
--TODO
--local sdkInfo = ctx.sdkInfo['dummy']
--local path = sdkInfo.path
--local version = sdkInfo.version
--local name = sdkInfo.name
--- SDK installation root path
local rootPath = ctx.rootPath
local runtimeVersion = ctx.runtimeVersion
--- Other SDK information, the `addition` field returned in PreInstall, obtained by name
--TODO
--local sdkInfo = ctx.sdkInfo['dummy']
--local path = sdkInfo.path
--local version = sdkInfo.version
--local name = sdkInfo.name
end
8 changes: 4 additions & 4 deletions crates/vfox/plugins/hooks/pre_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
--- @param ctx {version: string} Context information (version = User-input version)
--- @return table Version information
function PLUGIN:PreInstall(ctx)
local version = ctx.version
local version = ctx.version

return {
version = version,
}
return {
version = version,
}
end
Loading
Loading