Browse Source

Working on implementing non github sources into spm

environments/production/deployments/4
Drew Short 7 years ago
parent
commit
2f1c57dc68
  1. 25
      gruntfile.js
  2. 15
      src/programs.cfg
  3. 5
      src/repos.cfg
  4. 53
      src/spm/spm.lua
  5. 0
      src/warricksothr/license
  6. 0
      src/warricksothr/license.min
  7. 0
      src/warricksothr/reactor_control/reactor_control.lua

25
gruntfile.js

@ -8,7 +8,7 @@ module.exports = function (grunt) {
files: [{
expand: true,
cwd: "./src",
src: ["**/license*"],
src: ["**/license*", "**/*.lua", "*.cfg"],
dest: "dist/",
filter: 'isFile'
}]
@ -20,31 +20,11 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks('grunt-file-append');
grunt.registerTask("add-rename-lua-module-tasks", "Finds and adds tasks to rename all main.lua to match their parent directory", function () {
grunt.file.expand({filter: 'isDirectory'}, "src/*").forEach(function (dir) {
var module_name = dir.substr(dir.lastIndexOf('/') + 1);
if (module_name !== 'lib') {
var copy_task = {};
try {
copy_task = grunt.config.get('copy');
} catch (exception) {
console.log("No copy config exists, generating empty one.");
}
copy_task[module_name] = {
src: [dir + '/**/main.lua'],
dest: 'dist/' + module_name + '/' + module_name + '.lua'
};
console.log("Added copy task for module [" + module_name + "]");
grunt.config.set('copy', copy_task);
}
});
});
grunt.registerTask("minify-lua-modules", "minifies lua modules", function () {
const fs = require('fs');
const luamin = require('luamin');
const util = require('util');
grunt.file.expand({filter: 'isDirectory'}, "dist/*").forEach(function (dir) {
grunt.file.expand({filter: 'isDirectory'}, "dist/**/*").forEach(function (dir) {
grunt.file.expand({filter: 'isFile'}, dir + "/*.lua").forEach(function (file) {
const directory = file.substr(0, file.lastIndexOf('/'));
const file_name = file.substr(file.lastIndexOf('/') + 1);
@ -67,7 +47,6 @@ module.exports = function (grunt) {
grunt.registerTask("default", [
"clean",
"add-rename-lua-module-tasks",
"copy",
"minify-lua-modules"
]);

15
src/programs.cfg

@ -0,0 +1,15 @@
{
["spm"] = {
files = {
["spm/spm.lua"] = "/"
},
dependencies = {},
name = "Sothr Package Manager",
description = "A Modified Package Manager For OpenOS",
authors = "WarrickSothr",
note = "SPM operates similarly to OPPM, with slight modifications to referential repositories",
hidden = false,
repo = "",
version = "0.1"
}
}

5
src/repos.cfg

@ -0,0 +1,5 @@
{
["Sothr's Software"] = {
src = "https://sothr.com/download/oc/releases"
}
}

53
src/spm/main.lua → src/spm/spm.lua

@ -1,6 +1,7 @@
--[[
OpenPrograms package manager, browser and downloader, for easy access to many programs
Author: Vexatos
Sothr Package Manager, browser and downloader, for easy access to many programs
Author: Vexatos, WarrickSothr
Forked and modified from: https://github.com/Wuerfel21/OpenComputers/blob/master/src/main/resources/assets/opencomputers/loot/OPPM/oppm.lua
]]
local component = require("component")
local event = require("event")
@ -20,7 +21,8 @@ if not component.isAvailable("internet") then
end
local internet = require("internet")
local repoLocationConfig="https://raw.githubusercontent.com/OpenPrograms/openprograms.github.io/master/repos.cfg"
--local repoLocationConfig="https://raw.githubusercontent.com/OpenPrograms/openprograms.github.io/master/repos.cfg"
local repoLocationConfig = "https://sothr.com/download/oc/releases/repos.cfg"
local args, options = shell.parse(...)
@ -60,7 +62,15 @@ local function getRepos()
return serial.unserialize(sRepos)
end
local function getPackages(repo)
local function getPackages(src)
local success, sPackages = pcall(getContent, src .. "/programs.cfg")
if not success or not sPackages then
return -1
end
return serial.unserialize(sPackages)
end
local function getGithubPackages(repo)
local success, sPackages = pcall(getContent, "https://raw.githubusercontent.com/" .. repo .. "/master/programs.cfg")
if not success or not sPackages then
return -1
@ -91,10 +101,10 @@ local function readFromFile(fNum)
if fNum == 1 then
path = "/etc/opdata.svd"
elseif fNum == 2 then
path = "/etc/oppm.cfg"
path = "/etc/spm.cfg"
if not fs.exists(path) then
local tProcess = process.running()
path = fs.concat(fs.path(shell.resolve(tProcess)),"/etc/oppm.cfg")
path = fs.concat(fs.path(shell.resolve(tProcess)), "/etc/spm.cfg")
end
end
if not fs.exists(fs.path(path)) then
@ -141,11 +151,19 @@ local function listPackages(filter)
return
end
for _, j in pairs(repos) do
if j.repo then
local lPacks
local target
if j.src then
print("Checking Repository " .. j.src)
lPacks = getPackages(j.src)
target = j.src
elseif j.repo then
print("Checking Repository " .. j.repo)
local lPacks = getPackages(j.repo)
lPacks = getGithubPackages(j.repo)
target = j.repo
end
if lPacks == nil then
io.stderr:write("Error while trying to receive package list for " .. j.repo.."\n")
io.stderr:write("Error while trying to receive package list for " .. target .. "\n")
return
elseif type(lPacks) == "table" then
for k in pairs(lPacks) do
@ -155,7 +173,6 @@ local function listPackages(filter)
end
end
end
end
local lRepos = readFromFile(2)
if lRepos then
for _, j in pairs(lRepos.repos) do
@ -218,15 +235,21 @@ local function getInformation(pack)
return
end
for _, j in pairs(repos) do
if j.repo then
local lPacks = getPackages(j.repo)
local lPacks
local target
if j.src then
lPacks = getPackages(j.src)
target = j.src
elseif j.repo then
lPacks = getGithubPackages(j.repo)
target = "https://raw.githubusercontent.com/" .. j.repo
end
if lPacks == nil then
io.stderr:write("Error while trying to receive package list for "..j.repo.."\n")
io.stderr:write("Error while trying to receive package list for " .. target .. "\n")
elseif type(lPacks) == "table" then
for k in pairs(lPacks) do
if k == pack then
return lPacks[k],j.repo
end
return lPacks[k], target
end
end
end

0
src/license → src/warricksothr/license

0
src/license.min → src/warricksothr/license.min

0
src/reactor_control/main.lua → src/warricksothr/reactor_control/reactor_control.lua

Loading…
Cancel
Save