List of community Packages #179
Replies: 1 comment
-
In my view ideally a package manager for Nelua should be done using just bare Lua without dependencies other than the Nelua compiler itself and git via command line.
A package list should exist ideally in a git repository, in a large Lua file with a big table (easy to load from Lua), people could add new packages making a pull request
To make things a little more safe, a trusted Nelua user would be able to review and accept PRs in the packages repository, he would check if the package works and does not have anything malicious before accepting it, this for example how Sublime Text does at https://github.com/wbond/package_control_channel/tree/master/repository .
The update script could also be usable in the preprocessor if made entirely in Lua.
Indeed, it can be made as a "compiler plugin", the user just requires a Nelua or Lua file via the preprocessor.
Here is a small simple example of a package pulling system made in Nelua via the Lua preprocessor, to give you inspiration: ##[[
-- Macro to install or update a package on demand.
local function require_package(pkg)
local fs = require 'nelua.utils.fs'
local executor = require 'nelua.utils.executor'
local neluaconfig = require 'nelua.configer'.get()
local pkgname = pkg.repo:match('([^/]+)$')
local pkgpath = fs.join(fs.dirname(fs.realpath(fs.scriptname())), 'nelua_packages', pkgname)
if not fs.isdir(fs.join(pkgpath, '.git')) then -- no git, clone for the first time
fs.makepath(pkgpath) -- ensure path exists
local gitargs = {"clone", "https://github.com/"..pkg.repo..".git", pkgpath, '--depth=1'}
if pkg.branch then -- specific branch
table.insert(gitargs, '--branch='..pkg.branch)
end
executor.exec("git", gitargs)
elseif UPDATE_PACKAGES then -- update (use -DUPDATE_PACKAGES in command line)
executor.exec("git", {'-C', pkgpath, "pull"})
end
-- add to Nelua package path (so Nelua's 'require' can find its files)
neluaconfig.path = neluaconfig.path..';'..
fs.join(fs.abspath(pkgpath), '?', 'init.nelua')..';'..
fs.join(fs.abspath(pkgpath), '?.nelua')
-- add to Lua package path (so Lua's 'require' can find its files)
local pathsep = _G.package.config:sub(1,1)
_G.package.path = _G.package.path..pathsep..
fs.join(fs.abspath(pkgpath), '?', 'init.lua')..pathsep..
fs.join(fs.abspath(pkgpath), '?.lua')
end
]]
-- Pull all required packages first.
## require_package{repo='edubart/nelua-batteries'}
## require_package{repo='Andre-LA/nene', branch='main'}
local fs = require 'fs' -- require fs from 'nelua-batteries'
require 'nene' The example will pull packages from github just in the first
If you want to tackle this, I agree on that, keep it simple and small, that means, few files, few steps to use, few commands, less code, just what is enough.
There is a unmaintained package system in Nelua, at https://github.com/linkpy/pancake-pm |
Beta Was this translation helpful? Give feedback.
-
Hello :) respect for your work!
I would propose some super simple version of package managing. Basically just a webpage where people can upload link to repositories, which contain a config.nelua file, where the data about the type of the package, the author, the version, some search keywords and so on is located.
If you want to use a library from this list, you copy the git path into a "package.nelua" in your project and run an "update" script, which just pulls all dependencies from git(lab/hub) into the lib-subfolder-dir (could be specified in the package.nelua).
The types of the packages could be:
like ease of use, performance, and so on.
Packages could be marked "safe" or "suspicious" after some nelua programmer read through it. On default, they are marked as "own risk" with a hint to be careful.
I would like to create a prototype of this process.
This kind of package managing doesn't need to be included into neolua from the start on, but could
be later on if it is proven.
But before I start, I would like to hear your opinion on it. Most likely you have your own thoughts on how to do package managing or maybe already some prototype exists, which in missed.
Greetings from Germany
Beta Was this translation helpful? Give feedback.
All reactions