Skip to content

Commit

Permalink
port old package file to xim-pkgindex repo
Browse files Browse the repository at this point in the history
1. update c/cpp/dotnet
2. add python/devcpp/nodejs/npm/nvm/pnpm/wsl

Signed-off-by: sunrisepeak <[email protected]>
  • Loading branch information
Sunrisepeak committed Dec 16, 2024
1 parent fce363c commit dff6901
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkgs/c/cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function installed()
return toolchain.load("mingw"):check()
elseif pkginfo.version == "gnu" then
local output = os.iorun("gcc --version")
return string.find(output, "gcc") ~= nil
return string.find(output, "gcc", 1, true) ~= nil
else
return true
end
Expand Down
50 changes: 50 additions & 0 deletions pkgs/d/devcpp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package = {
name = "Dev-C++",
description = "A full-featured Integrated Development Environment (IDE) for the C/C++",
homepage = "https://sourceforge.net/projects/orwelldevcpp/",
maintainers = "Orwell (Johan Mes)",
license = "GPL",
repo = "https://sourceforge.net/projects/orwelldevcpp/",

-- xim pkg info
archs = {"x86_64"},
status = "stable", -- dev, stable, deprecated
categories = {"ide", "c", "c++"},
keywords = {"dev-cpp"},

xpm = {
windows = {
["latest"] = { ref = "5.11" },
["5.11"] = {
url = "https://gitee.com/sunrisepeak/xlings-pkg/releases/download/devcpp/devcpp.exe",
sha256 = "faad96bbcc51f115c9edd691785d1309e7663b67dcfcf7c11515c3d28c9c0f1f",
},
},
},
}

import("xim.base.runtime")

local pkginfo = runtime.get_pkginfo()

function installed()
return os.isfile("C:\\Program Files (x86)\\Dev-Cpp\\devcpp.exe")
end

function install()
print("[xlings]: suggestion use default install path for dev-c++")
print("Dev-C++安装建议:")
print("\t 0.打开安装提示")
print("\t 1.先选English")
print("\t 2.使用默认选项安装")
print("\t 3.打开Dev-C++(这里可以重新选择IDE语言)")
os.exec(pkginfo.install_file)
return true
end

function uninstall()
if os.isfile("C:\\Program Files (x86)\\Dev-Cpp\\uninstall.exe") then
os.exec("C:\\Program Files (x86)\\Dev-Cpp\\uninstall.exe")
end
return true
end
22 changes: 19 additions & 3 deletions pkgs/d/dotnet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ package = {
keywords = {"cross-platform", ".net", "dotnet"},

xpm = {
windows = {
deps = { "dotnet-9@winget" },
["latest"] = { ref = "9.0" },
["9.0"] = { },
},
debain = {
["latest"] = { ref = "9.0" },
["9.0"] = { url = installer_url, sha256 = nil },
Expand All @@ -31,29 +36,40 @@ package = {

import("xim.base.utils")
import("xim.base.runtime")
import("xim.xuninstall")

local pkginfo = runtime.get_pkginfo()
local dotnetdir = path.join(os.getenv("HOME"), ".dotnet")

function installed()
os.addenv("PATH", dotnetdir)
return os.iorun("dotnet --version")
end

function install()
if is_host("windows") then
return true -- install by deps
end

os.exec("chmod +x " .. pkginfo.install_file)
local cmd = pkginfo.install_file .. " --channel " .. pkginfo.version
print("exec: " .. cmd)
os.exec(cmd)

return true
end

function config()
utils.add_env_path(dotnetdir)
if not is_host("windows") then
utils.add_env_path(dotnetdir)
end
return true
end

function uninstall()
os.exec("rm -r " .. dotnetdir)
if is_host("windows") then
xuninstall("dotnet-9@winget")
else
os.exec("rm -r " .. dotnetdir)
end
return true
end
62 changes: 62 additions & 0 deletions pkgs/n/nodejs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package = {
homepage = "https://nodejs.org",
name = "nodejs",
description = "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine",
author = "Node.js Foundation",
licenses = "MIT",
repo = "https://github.com/nodejs/node",
docs = "https://nodejs.org/docs",

-- xim pkg info
archs = {"x86_64"},
status = "stable", -- dev, stable, deprecated
categories = {"nodejs", "javascript"},

xpm = {
windows = {
["latest"] = { ref = "22.12.0"},
["22.12.0"] = {
url = "https://nodejs.org/dist/v22.12.0/node-v22.12.0-win-x64.zip",
sha256 = "2b8f2256382f97ad51e29ff71f702961af466c4616393f767455501e6aece9b8",
},
},
ubuntu = {
["latest"] = { ref = "22.12.0"},
["22.12.0"] = {
url = "https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.xz",
sha256 = "22982235e1b71fa8850f82edd09cdae7e3f32df1764a9ec298c72d25ef2c164f",
},
},
debian = { ref = "ubuntu" },
archlinux = { ref = "ubuntu"},
},
}

import("xim.base.utils")
import("xim.base.runtime")

local pkginfo = runtime.get_pkginfo()

local node_dir = {
linux = "node-v22.12.0-linux-x64",
windows = "node-v22.12.0-win-x64",
}

function installed()
return os.iorun("node --version")
end

function install()
local bindir = path.join(
path.directory(pkginfo.install_file),
node_dir[os.host()]
)
bindir = path.join(bindir, "bin")
utils.add_env_path(bindir)
return true
end

function uninstall()
os.tryrm(node_dir[os.host()])
return true
end
1 change: 1 addition & 0 deletions pkgs/n/npm.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package = { ref = "[email protected]" }
76 changes: 76 additions & 0 deletions pkgs/n/nvm.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package = {
name = "nvm",
description = "Node Version Manager",
homepage = "https://github.com/nvm-sh/nvm",
author = "Tim Caswell",
maintainers = "https://github.com/nvm-sh/nvm?tab=readme-ov-file#maintainers",
licenses = "MIT",
repo = "https://github.com/nvm-sh/nvm",
docs = "https://github.com/nvm-sh/nvm#installing-and-updating",

-- xim pkg info
archs = {"x86_64"},
status = "stable", -- dev, stable, deprecated
categories = {"tools", "nodejs"},

xpm = {
windows = {
["latest"] = { ref = "1.1.11"},
["1.1.11"] = {
url = "https://github.com/coreybutler/nvm-windows/releases/download/1.1.11/nvm-setup.exe",
sha256 = "941561b7486cffc5b5090a99f6949bdc31dbaa6288025d4b2b1e3f710f0ed654",
}
},
ubuntu = {
["latest"] = { ref = "0.39.0"},
["0.39.0"] = {
url = "https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh",
sha256 = nil,
},
},
},
}

import("xim.base.utils")
import("xim.base.runtime")

local pkginfo = runtime.get_pkginfo()

function installed()
return os.iorun("nvm --version")
end

function install()
if is_host("windows") then
os.exec(pkginfo.install_file .. " /SILENT")

local nvm_home = "C:\\Users\\" .. os.getenv("USERNAME") .. "\\AppData\\Roaming\\nvm"
local node_home = "C:\\Program Files\\nodejs"

os.setenv("NVM_HOME", nvm_home)
os.setenv("NVM_SYMLINK", node_home)

-- update path
os.addenv("PATH", nvm_home)
os.addenv("PATH", node_home)
else
os.exec("sh " .. pkginfo.install_file)
utils.append_bashrc([[
# nvm config by xlings-xim
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
]])
end
return true
end

function uninstall()
if is_host("windows") then
-- TODO: uninstall nvm-windows
else
local nvm_home = path.join(os.getenv("HOME"), ".nvm")
os.tryrm(nvm_home)
end
return true
end
46 changes: 46 additions & 0 deletions pkgs/p/pnpm.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package = {
homepage = "https://pnpm.io",
name = "pnpm",
description = "Fast, disk space efficient package manager",
licenses = "MIT",
repo = "https://github.com/pnpm/pnpm",
docs = "https://pnpm.io/motivation",

-- xim pkg info
archs = {"x86_64"},
status = "stable", -- dev, stable, deprecated
categories = {"package-manager", "typescript"},

xpm = {
windows = {
deps = { "[email protected]" },
["latest"] = { ref = "9.15.0"},
["9.15.0"] = { },
},
ubuntu = {
deps = { "[email protected]" },
["latest"] = { ref = "9.15.0"},
["9.15.0"] = { },
},
debian = { ref = "ubuntu" },
archlinux = { ref = "ubuntu"},
},
}

import("xim.base.runtime")

local pkginfo = runtime.get_pkginfo()

function installed()
return os.iorun("pnpm --version")
end

function install()
os.iorun("npm install -g pnpm@" .. pkginfo.version)
return true
end

function uninstall()
os.iorun("npm uninstall -g pnpm")
return true
end
60 changes: 60 additions & 0 deletions pkgs/w/wsl-ubuntu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package = {
-- base info
name = "wsl-ubuntu",
description = "Windows Subsystem for Linux (WSL) Ubuntu",
repo = "https://github.com/d2learn/xim-pkgindex",

-- xim pkg info
type = "auto-config",
status = "stable", -- dev, stable, deprecated
categories = {"windows", "subsystem", "ubuntu"},
keywords = {"linux", "subsystem", "ubuntu"},

xpm = {
windows = {
deps = { "wsl@winget" },
["latest"] = { },
},
},
}

function installed()
local output = os.iorun("wsl --list --verbose")
return string.find(output, "Ubuntu", 1, true) ~= nil
end

function install()
os.exec("wsl --install -d Ubuntu")

cprint("\n\n ${yellow}Note${clear}: maybe need to restart your computer to complete WSL installation")
cprint(" ${yellow}注意${clear}: 可能需要重启让WSL安装和配置生效\n\n")

guide_wsl_setup()

return true
end

function uninstall()
os.exec("wsl --unregister Ubuntu")
return true
end

function guide_wsl_setup()
print([[
[xlings]: WSL Ubuntu 初步指导:
0. 运行wsl: 点击命令行窗口顶部的下拉菜单 v 按钮选择ubuntu
1. 等待 Ubuntu 初始化完成
2. 创建一个新的 UNIX 用户名(不需要跟 Windows 用户名相同)
3. 设置密码(输入时不会显示)
4. 确认密码
注意:
- 首次安装需要重启电脑才能生效
- 用户名只能使用小写字母
- 密码输入时屏幕上不会显示任何内容
- 请记住您设置的密码,后续会用到
]])
end
Loading

0 comments on commit dff6901

Please sign in to comment.