2024-07-21 01:17:10 -04:00
|
|
|
import { spawnSync } from 'node:child_process';
|
2024-09-15 17:04:49 -04:00
|
|
|
import { writeFileSync } from 'node:fs';
|
2024-07-21 01:17:10 -04:00
|
|
|
|
2024-11-15 11:37:58 -05:00
|
|
|
import { parseArgs } from './lib';
|
2024-10-20 21:42:54 -04:00
|
|
|
|
2024-11-15 11:37:58 -05:00
|
|
|
import { updateDocker } from './docker';
|
|
|
|
import { updateFirefoxAddons } from '././firefox';
|
|
|
|
import { updateFlakeInputs } from './flake';
|
|
|
|
import { updateCustomPackage, updateVuetorrent } from './misc';
|
2024-07-20 20:30:43 -04:00
|
|
|
|
|
|
|
|
2024-07-21 01:17:10 -04:00
|
|
|
/* Constants */
|
|
|
|
const FLAKE = process.env.FLAKE;
|
|
|
|
|
|
|
|
if (!FLAKE) {
|
|
|
|
console.error('Env var FLAKE not found');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2024-07-20 21:06:52 -04:00
|
|
|
const args = parseArgs();
|
2024-07-20 20:30:43 -04:00
|
|
|
|
2024-07-20 22:33:14 -04:00
|
|
|
if (args['d'] || args['docker']) {
|
|
|
|
console.log(updateDocker());
|
|
|
|
}
|
|
|
|
|
2024-07-20 23:40:06 -04:00
|
|
|
if (args['i'] || args['inputs']) {
|
|
|
|
console.log(updateFlakeInputs());
|
|
|
|
}
|
|
|
|
|
2024-07-20 20:30:43 -04:00
|
|
|
if (args['f'] || args['firefox']) {
|
|
|
|
console.log(updateFirefoxAddons());
|
|
|
|
}
|
2024-07-20 22:02:22 -04:00
|
|
|
|
2024-07-20 22:33:14 -04:00
|
|
|
if (args['v'] || args['vuetorrent']) {
|
|
|
|
console.log(updateVuetorrent());
|
2024-07-20 22:02:22 -04:00
|
|
|
}
|
|
|
|
|
2024-10-20 21:42:54 -04:00
|
|
|
if (args['c'] || args['custom-sidebar']) {
|
2024-11-21 15:00:13 -05:00
|
|
|
console.log(updateCustomPackage('scopedPackages.x86_64-linux.lovelace-components.custom-sidebar'));
|
2024-10-31 15:35:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (args['s'] || args['some-sass-language-server']) {
|
|
|
|
console.log(updateCustomPackage('some-sass-language-server'));
|
2024-10-20 21:42:54 -04:00
|
|
|
}
|
|
|
|
|
2024-07-20 22:02:22 -04:00
|
|
|
if (args['a'] || args['all']) {
|
2024-07-30 01:45:01 -04:00
|
|
|
// Update this first because of nix run cmd
|
|
|
|
const firefoxOutput = updateFirefoxAddons();
|
|
|
|
|
|
|
|
console.log(firefoxOutput);
|
|
|
|
|
|
|
|
|
2024-07-21 01:17:10 -04:00
|
|
|
const flakeOutput = updateFlakeInputs();
|
|
|
|
|
|
|
|
console.log(flakeOutput);
|
|
|
|
|
|
|
|
|
|
|
|
const dockerOutput = updateDocker();
|
|
|
|
|
|
|
|
console.log(dockerOutput);
|
|
|
|
|
|
|
|
|
|
|
|
const vuetorrentOutput = updateVuetorrent();
|
|
|
|
|
|
|
|
console.log(vuetorrentOutput);
|
|
|
|
|
2024-10-20 21:42:54 -04:00
|
|
|
// This doesn't need to be added to commit msgs
|
2024-11-21 15:00:13 -05:00
|
|
|
console.log(updateCustomPackage('scopedPackages.x86_64-linux.lovelace-components.custom-sidebar'));
|
2024-10-31 15:35:03 -04:00
|
|
|
console.log(updateCustomPackage('some-sass-language-server'));
|
2024-10-20 21:42:54 -04:00
|
|
|
|
2024-07-21 01:17:10 -04:00
|
|
|
|
2024-08-06 22:23:42 -04:00
|
|
|
spawnSync('nix-fast-build', ['-f', `${FLAKE}#nixFastChecks`], {
|
2024-07-21 01:17:10 -04:00
|
|
|
shell: true,
|
|
|
|
stdio: [process.stdin, process.stdout, process.stderr],
|
|
|
|
});
|
|
|
|
|
2024-09-15 17:04:49 -04:00
|
|
|
const output = [
|
2024-11-13 16:02:45 -05:00
|
|
|
'chore: update sources\n\n',
|
|
|
|
];
|
|
|
|
|
|
|
|
if (flakeOutput.length > 5) {
|
|
|
|
output.push(`Flake Inputs:\n${flakeOutput}\n\n`);
|
|
|
|
}
|
|
|
|
if (dockerOutput.length > 5) {
|
|
|
|
output.push(`Docker Images:\n${dockerOutput}\n`);
|
|
|
|
}
|
|
|
|
if (firefoxOutput.length > 5) {
|
|
|
|
output.push(`Firefox Addons:\n${firefoxOutput}\n\n`);
|
|
|
|
}
|
|
|
|
if (vuetorrentOutput.length > 5) {
|
|
|
|
output.push(`Misc Sources:\n${vuetorrentOutput}\n`);
|
|
|
|
}
|
2024-09-15 17:04:49 -04:00
|
|
|
|
|
|
|
if (args['f']) {
|
2024-11-13 16:02:45 -05:00
|
|
|
writeFileSync(args['f'] as string, output.join(''));
|
2024-09-15 17:04:49 -04:00
|
|
|
}
|
|
|
|
else {
|
2024-11-13 16:02:45 -05:00
|
|
|
console.log(output.join(''));
|
2024-09-15 17:04:49 -04:00
|
|
|
}
|
2024-07-20 22:02:22 -04:00
|
|
|
}
|
2024-07-21 01:17:10 -04:00
|
|
|
|
|
|
|
spawnSync('alejandra', ['-q', FLAKE], { shell: true });
|