feat(update): migrate flake inputs update script to typescript
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-07-20 23:40:06 -04:00
parent 322aeebd45
commit 262bcedbd2
2 changed files with 26 additions and 3 deletions

View file

@ -1,6 +1,6 @@
import { parseArgs } from './lib.ts'; import { parseArgs } from './lib.ts';
import { updateFirefoxAddons } from '././firefox.ts'; import { updateFirefoxAddons } from '././firefox.ts';
import { updateDocker, updateVuetorrent } from './misc.ts'; import { updateDocker, updateFlakeInputs, updateVuetorrent } from './misc.ts';
const args = parseArgs(); const args = parseArgs();
@ -9,6 +9,10 @@ if (args['d'] || args['docker']) {
console.log(updateDocker()); console.log(updateDocker());
} }
if (args['i'] || args['inputs']) {
console.log(updateFlakeInputs());
}
if (args['f'] || args['firefox']) { if (args['f'] || args['firefox']) {
console.log(updateFirefoxAddons()); console.log(updateFirefoxAddons());
} }
@ -18,7 +22,8 @@ if (args['v'] || args['vuetorrent']) {
} }
if (args['a'] || args['all']) { if (args['a'] || args['all']) {
console.log(updateVuetorrent());
console.log(updateFirefoxAddons());
console.log(updateDocker()); console.log(updateDocker());
console.log(updateFlakeInputs());
console.log(updateFirefoxAddons());
console.log(updateVuetorrent());
} }

View file

@ -7,6 +7,24 @@ import { parseFetchurl } from './lib.ts';
/* Constants */ /* Constants */
const FLAKE = process.env.FLAKE; const FLAKE = process.env.FLAKE;
export const updateFlakeInputs = () => {
const output = spawnSync(
`nix flake update --flake ${FLAKE} |& grep -v "warning: updating lock file"`,
[],
{ shell: true },
).stdout
.toString()
.split('\n•')
.join('\n\n•')
.split('\n')
.map((l) => l
.replace(/.{33}\?narHash=sha256[^']*/, '')
.replace(/&rev=(.{7})[^'&]*/, (_, backref) => `&rev=${backref}`))
.join('\n');
return output;
};
export const updateDocker = () => { export const updateDocker = () => {
let updates = ''; let updates = '';