Skip to content

Commit 9d1971e

Browse files
authored
[ADDED/CHANGED FILE/DIR: DELETED FILE/DIR: test_files/, CHANGED: plugin/commands.lua, NEW FILE/DIR: python/npm_install.py
2 parents 75c1d4d + 7712636 commit 9d1971e

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

.github/RELEASE_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### What changed
2-
Descript major changes in this release
2+
- Descript major changes in this release
3+
- Etc.,
34

45
---
56
### Supporting languages

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
package.json
2+
package-lock.json
3+
test_files/node_modules/
14
.env
25
python/__pycache__
36
*.pyc

plugin/commands.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ M.commands = function()
2020
-- Define script paths relative to config directory
2121
local python_script = vim.fn.stdpath("config") .. "/lua/LazyDeveloperHelper/python/pip_install.py"
2222
local lua_script = vim.fn.stdpath("config") .. "/lua/LazyDeveloperHelper/python/luarocks_install.py"
23+
2324
local rust_script = vim.fn.stdpath("config") .. "/lua/LazyDeveloperHelper/python/cargo_install.py"
25+
local js_script = vim.fn.stdpath("config") .. "/lua/LazyDeveloperHelper/python/npm_install.py"
2426
-- Function to safely execute external commands
2527
local function execute_command(script_path, lib)
2628
local cmd = string.format('python3 "%s" "%s"', script_path, lib)
@@ -37,14 +39,17 @@ M.commands = function()
3739
result = execute_command(python_script, lib)
3840

3941
elseif lang == "lua" then
40-
print("💎 Installing Lua package: " .. lib)
42+
vim.notify("💎 Installing Lua package: " .. lib)
4143
result = execute_command(lua_script, lib)
4244
elseif lang == "rust" then
43-
print ("🦀 Installing Rust package: ".. lib)
45+
vim.notify("🦀 Installing Rust package: ".. lib)
4446
result = execute_command(rust_script, lib)
47+
elseif lang == "javascript" then
48+
vim.notify("☕ Installing JS package: ".. lib)
49+
result = execute_command(js_script, lib)
4550
else
4651
print(string.format("❌ Unsupported filetype '%s'", lang))
47-
print("Supported filetypes: python, lua")
52+
print("Supported filetypes: python, lua, rust, javasript")
4853
goto continue
4954
end
5055

python/npm_install.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!usr/bin/python3
2+
import sys
3+
from subprocess import run, PIPE
4+
5+
def install_npm(lib):
6+
print(f"📦 Installing npm package: {lib} ...")
7+
result = run(['npm', 'list', lib], stdout=PIPE, stderr=PIPE, text=True)
8+
if lib in result.stdout:
9+
print(f"✅ {lib} already installed")
10+
return
11+
12+
# if lib not found - install
13+
result = run(['npm', 'install', lib.lower(), '--no-save'], stdout=PIPE, stderr=PIPE, text=True)
14+
if result.returncode == 0:
15+
print(f"✅ {lib} installed successfully")
16+
else:
17+
print(f"❌ Failed to install {lib}")
18+
print(result.stderr)
19+
20+
def main():
21+
if len(sys.argv) < 2:
22+
print("Provide at least one npm package name")
23+
return
24+
25+
for lib in sys.argv[1:]:
26+
install_npm(lib)
27+
28+
if __name__ == "__main__":
29+
main()

test_files/test.js

Whitespace-only changes.

0 commit comments

Comments
 (0)