From 44d56aab0f7639cdc8973ae6d019d5c9ea13f22b Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 21 Jul 2024 01:17:10 -0400 Subject: [PATCH] feat(update): consolidate update msgs and format at end --- apps/update/src/app.ts | 48 +++++++++++++++++++++++++++++++++++++---- apps/update/src/misc.ts | 2 ++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/apps/update/src/app.ts b/apps/update/src/app.ts index 1ee3f770..2b88226e 100644 --- a/apps/update/src/app.ts +++ b/apps/update/src/app.ts @@ -1,8 +1,18 @@ +import { spawnSync } from 'node:child_process'; + import { parseArgs } from './lib.ts'; import { updateFirefoxAddons } from '././firefox.ts'; import { updateDocker, updateFlakeInputs, updateVuetorrent } from './misc.ts'; +/* Constants */ +const FLAKE = process.env.FLAKE; + +if (!FLAKE) { + console.error('Env var FLAKE not found'); + process.exit(1); +} + const args = parseArgs(); if (args['d'] || args['docker']) { @@ -22,8 +32,38 @@ if (args['v'] || args['vuetorrent']) { } if (args['a'] || args['all']) { - console.log(updateDocker()); - console.log(updateFlakeInputs()); - console.log(updateFirefoxAddons()); - console.log(updateVuetorrent()); + const flakeOutput = updateFlakeInputs(); + + console.log(flakeOutput); + + + const dockerOutput = updateDocker(); + + console.log(dockerOutput); + + + const firefoxOutput = updateFirefoxAddons(); + + console.log(firefoxOutput); + + + const vuetorrentOutput = updateVuetorrent(); + + console.log(vuetorrentOutput); + + + spawnSync('nix-fast-build', ['-f', `${FLAKE}#checks`], { + shell: true, + stdio: [process.stdin, process.stdout, process.stderr], + }); + + console.log([ + 'chore: update flake.lock', + `Flake Inputs:\n${flakeOutput}`, + `Docker Images:\n${dockerOutput}`, + `Firefox Addons:\n${firefoxOutput}`, + `Misc Sources:\n${vuetorrentOutput}`, + ].join('\n\n')); } + +spawnSync('alejandra', ['-q', FLAKE], { shell: true }); diff --git a/apps/update/src/misc.ts b/apps/update/src/misc.ts index 7f3d4ace..3fba2153 100644 --- a/apps/update/src/misc.ts +++ b/apps/update/src/misc.ts @@ -14,8 +14,10 @@ export const updateFlakeInputs = () => { { shell: true }, ).stdout .toString() + // Add an extra blank line between inputs .split('\n•') .join('\n\n•') + // Shorten git revs to help readability .split('\n') .map((l) => l .replace(/.{33}\?narHash=sha256[^']*/, '')