feat(update): migrate vuetorrent update script to typescript
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
60bc645ae0
commit
322aeebd45
2 changed files with 43 additions and 6 deletions
|
@ -1,19 +1,24 @@
|
||||||
import { parseArgs } from './lib.ts';
|
import { parseArgs } from './lib.ts';
|
||||||
import { updateFirefoxAddons } from '././firefox.ts';
|
import { updateFirefoxAddons } from '././firefox.ts';
|
||||||
import { updateDocker } from './misc.ts';
|
import { updateDocker, updateVuetorrent } from './misc.ts';
|
||||||
|
|
||||||
|
|
||||||
const args = parseArgs();
|
const args = parseArgs();
|
||||||
|
|
||||||
if (args['f'] || args['firefox']) {
|
|
||||||
console.log(updateFirefoxAddons());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args['d'] || args['docker']) {
|
if (args['d'] || args['docker']) {
|
||||||
console.log(updateDocker());
|
console.log(updateDocker());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args['f'] || args['firefox']) {
|
||||||
|
console.log(updateFirefoxAddons());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args['v'] || args['vuetorrent']) {
|
||||||
|
console.log(updateVuetorrent());
|
||||||
|
}
|
||||||
|
|
||||||
if (args['a'] || args['all']) {
|
if (args['a'] || args['all']) {
|
||||||
|
console.log(updateVuetorrent());
|
||||||
console.log(updateFirefoxAddons());
|
console.log(updateFirefoxAddons());
|
||||||
console.log(updateDocker());
|
console.log(updateDocker());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { readdirSync } from 'node:fs';
|
import { readdirSync, writeFileSync } from 'node:fs';
|
||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
|
|
||||||
|
import { parseFetchurl } from './lib.ts';
|
||||||
|
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
const FLAKE = process.env.FLAKE;
|
const FLAKE = process.env.FLAKE;
|
||||||
|
@ -19,3 +21,33 @@ export const updateDocker = () => {
|
||||||
|
|
||||||
return updates;
|
return updates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const genVueText = (version: string, hash: string, url: string) =>
|
||||||
|
`# This file was autogenerated. DO NOT EDIT!
|
||||||
|
{
|
||||||
|
version = "${version}";
|
||||||
|
url = "${url}";
|
||||||
|
hash = "${hash}";
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const updateVuetorrent = () => {
|
||||||
|
const FILE = `${FLAKE}/devices/nos/modules/qbittorrent/vuetorrent.nix`;
|
||||||
|
|
||||||
|
const OLD_VERSION = JSON.parse(spawnSync('nix',
|
||||||
|
['eval', '-f', FILE, '--json'],
|
||||||
|
{ shell: true }).stdout.toString()).version;
|
||||||
|
|
||||||
|
const VERSION = JSON.parse(spawnSync('curl',
|
||||||
|
['-s', 'https://api.github.com/repos/VueTorrent/VueTorrent/releases/latest'],
|
||||||
|
{ shell: true }).stdout.toString()).tag_name.replace('v', '');
|
||||||
|
|
||||||
|
const URL = `https://github.com/VueTorrent/VueTorrent/releases/download/v${VERSION}/vuetorrent.zip`;
|
||||||
|
const HASH = parseFetchurl(URL);
|
||||||
|
|
||||||
|
const fileText = genVueText(VERSION, HASH, URL);
|
||||||
|
|
||||||
|
writeFileSync(FILE, fileText);
|
||||||
|
|
||||||
|
return OLD_VERSION !== VERSION ? `Vuetorrent: ${OLD_VERSION} -> ${VERSION}}` : '';
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue