⚡ small improvement of github-release.mjs + update
This commit is contained in:
parent
1456b4a315
commit
2c3b6dfc09
@ -8,9 +8,9 @@
|
||||
"file_name": "github-desktop",
|
||||
"exec": "yes",
|
||||
"description": "Fork of GitHub Desktop to support various Linux distributions",
|
||||
"last_update": "2024-07-01T20:15:47Z",
|
||||
"last_update": "2024-08-10T17:00:04Z",
|
||||
"downloads": "/home/jaandrle/bin/github-desktop",
|
||||
"version": "release-3.4.2-linux1",
|
||||
"version": "release-3.4.3-linux1",
|
||||
"glare": ".*x86_64.*.AppImage"
|
||||
},
|
||||
{
|
||||
@ -21,8 +21,8 @@
|
||||
"exec": "yes",
|
||||
"description": "AI Browser",
|
||||
"glare": "AppImage",
|
||||
"last_update": "2024-07-17T20:36:36Z",
|
||||
"version": "2.0.4",
|
||||
"last_update": "2024-07-29T15:29:11Z",
|
||||
"version": "2.1.17",
|
||||
"downloads": "/home/jaandrle/bin/pinokio"
|
||||
},
|
||||
{
|
||||
@ -44,9 +44,9 @@
|
||||
"group": "nondev",
|
||||
"file_name": "youtube-music",
|
||||
"exec": "yes",
|
||||
"last_update": "2024-07-14T15:26:52Z",
|
||||
"last_update": "2024-08-01T11:48:59Z",
|
||||
"downloads": "/home/jaandrle/bin/youtube-music",
|
||||
"version": "v3.4.1",
|
||||
"version": "v3.5.1",
|
||||
"glare": "AppImage"
|
||||
},
|
||||
{
|
||||
@ -176,9 +176,9 @@
|
||||
"group": "nondev",
|
||||
"file_name": "fedistar",
|
||||
"exec": "yes",
|
||||
"last_update": "2024-07-21T09:19:41Z",
|
||||
"last_update": "2024-08-08T13:46:23Z",
|
||||
"downloads": "/home/jaandrle/bin/fedistar",
|
||||
"version": "v1.9.9",
|
||||
"version": "v1.9.10",
|
||||
"glare": ".*amd64.*.AppImage"
|
||||
},
|
||||
{
|
||||
@ -188,9 +188,9 @@
|
||||
"group": "ai",
|
||||
"file_name": "ollama",
|
||||
"exec": "yes",
|
||||
"last_update": "2024-07-21T18:21:56Z",
|
||||
"last_update": "2024-08-13T20:27:42Z",
|
||||
"downloads": "/home/jaandrle/bin/ollama",
|
||||
"version": "v0.2.8-rc1",
|
||||
"version": "v0.3.6",
|
||||
"glare": "linux-amd64"
|
||||
},
|
||||
{
|
||||
@ -212,9 +212,9 @@
|
||||
"group": "dev",
|
||||
"file_name": "escrcpy",
|
||||
"exec": "yes",
|
||||
"last_update": "2024-07-14T08:47:24Z",
|
||||
"last_update": "2024-08-03T17:09:45Z",
|
||||
"downloads": "/home/jaandrle/bin/escrcpy",
|
||||
"version": "v1.21.4",
|
||||
"version": "v1.22.4",
|
||||
"glare": ".*x86_64.*.AppImage"
|
||||
},
|
||||
{
|
||||
|
@ -37,7 +37,11 @@ const path_config= $.xdg.config`github-releases`;
|
||||
const path_config_json= join(path_config, "config.json");
|
||||
const path_config_lock= join(path_config, "lock");
|
||||
const path_temp= $.xdg.temp`github-releases.json`;
|
||||
const url_api= "https://api.github.com/repos/"; // "https://ungh.cc/repos/";
|
||||
let url_api= "github";
|
||||
const urls_api= {
|
||||
github: "https://api.github.com/repos/",
|
||||
ungh: "https://ungh.cc/repos/"
|
||||
};
|
||||
const url_download= "https://glare.now.sh/"; // https://github.com/Contextualist/glare
|
||||
const css= echo.css`
|
||||
.pkg { color: lightcyan; }
|
||||
@ -48,9 +52,19 @@ const css= echo.css`
|
||||
`;
|
||||
|
||||
$.api()
|
||||
.version("2.0.0")
|
||||
.version("2.1.0")
|
||||
.describe("Helper for working with “packages” stored in GitHub releases.")
|
||||
.command("config [mode]", [ "Config (file), use `mode` with these options:",
|
||||
.option("--verbose", "Verbose output (WIP)")
|
||||
.option("--group, -G", "Filter by group (not awaiable for noGRA)")
|
||||
.option("--repository, -R", "Filter by repository (not awaiable for noGRA)")
|
||||
.option("--api", [ "Choose API URL",
|
||||
"- GitHub (default): https://api.github.com/repos/",
|
||||
"- Ungh: https://ungh.cc/repos/", "(not awaiable for noGRA)" ], "github")
|
||||
.command("unlock", "[noGRA] DANGER: Removes lock file. Use only if you know what you are doing!")
|
||||
.action(function(){
|
||||
s.rm(path_config_lock);
|
||||
})
|
||||
.command("config [mode]", [ "[noGR] Config (file), use `mode` with these options:",
|
||||
"- `edit`: opens config file in terminal editor using `$EDITOR` (defaults to vim)",
|
||||
"- `path`: prints path to config file"
|
||||
])
|
||||
@ -71,8 +85,6 @@ $.api()
|
||||
"These are registered by this script but not managed by it (updates, etc).",
|
||||
"Repositories marked with `+` signify that updates of the package are checked."
|
||||
])
|
||||
.option("--group, -G", "Filter by group")
|
||||
.option("--repository, -R", "Filter by repository")
|
||||
.action(function(filter){
|
||||
const config = readConfig();
|
||||
for(const { repository, version, description, group } of grepPackages(config, filter))
|
||||
@ -83,8 +95,6 @@ $.api()
|
||||
$.exit(0);
|
||||
})
|
||||
.command("check", "Shows/checks updates for registered packages")
|
||||
.option("--group, -G", "Filter by group")
|
||||
.option("--repository, -R", "Filter by repository")
|
||||
.option("--cache", "Use cache [yes, no]", "yes")
|
||||
.action(async function({ cache, ...filter }){
|
||||
const config = readConfig();
|
||||
@ -95,8 +105,6 @@ $.api()
|
||||
$.exit(0);
|
||||
})
|
||||
.command("update", "Updates registered packages")
|
||||
.option("--group, -G", "Filter by group")
|
||||
.option("--repository, -R", "Filter by repository")
|
||||
.action(async function(filter){
|
||||
if(s.test("-f", path_config_lock))
|
||||
return $.error(`The lock file '${path_config_lock}' already exists! Check if some other instance is running.`);
|
||||
@ -127,7 +135,7 @@ $.api()
|
||||
echo("Updating packages completed:");
|
||||
for (const { status, value, reason } of updates) {
|
||||
if(status==="rejected"){
|
||||
echo("%c✗ "+reason.local.repository+": %c"+reason.err, css.err);
|
||||
echo("%c✗ TBD reason.local.repository: %c"+reason.err, css.err);
|
||||
continue;
|
||||
}
|
||||
const { local, remote }= value;
|
||||
@ -162,11 +170,17 @@ async function download(value, onprogress, target){
|
||||
return value;
|
||||
}
|
||||
|
||||
function grepPackages({ packages }, { group, repository }){
|
||||
function grepPackages({ packages }, { group, repository, api, verbose }){
|
||||
if(api && api!==url_api && urls_api.hasOwnProperty(api))
|
||||
url_api= api;
|
||||
if(verbose)
|
||||
echo(`Using API: ${url_api} (${urls_api[url_api]})`);
|
||||
const f= {};
|
||||
let is_filter= false;
|
||||
if(group){ is_filter= true; f.group= group; }
|
||||
if(repository){ is_filter= true; f.repository= repository; }
|
||||
if(verbose)
|
||||
echo("Filter:", f);
|
||||
if(!is_filter) return packages;
|
||||
return packages.filter(r=> Object.keys(f).every(k=> r[k]===f[k]));
|
||||
}
|
||||
@ -211,7 +225,7 @@ function packageStatus({ last_update: local }, { published_at: remote }){
|
||||
async function fetchRelease({ repository, tag_name_regex }, cache){
|
||||
const headers= { 'User-Agent': 'node' };
|
||||
if(cache==="no") headers['Cache-Control'] = 'no-cache';
|
||||
const url= url_api+repository+"/releases";
|
||||
const url= urls_api[url_api]+repository+"/releases";
|
||||
const releases= await fetch(url, { headers }).then(res=> res.json());
|
||||
if(releases.message) return $.error(url+": "+releases.message);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user