This commit is contained in:
parent
a93ec6ad3f
commit
c816c15c50
9 changed files with 100 additions and 67 deletions
apps/update-sources/src
|
@ -29,15 +29,15 @@ const main = async() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['cp'] || args['caddy-plugins']) {
|
if (args['cp'] || args['caddy-plugins']) {
|
||||||
console.log(updateCaddyPlugins());
|
console.log(updateCaddyPlugins() ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['d'] || args['docker']) {
|
if (args['d'] || args['docker']) {
|
||||||
console.log(updateDocker());
|
console.log(updateDocker() ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['f'] || args['firefox']) {
|
if (args['f'] || args['firefox']) {
|
||||||
console.log(updateFirefoxAddons());
|
console.log(updateFirefoxAddons() ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['h'] || args['homepage']) {
|
if (args['h'] || args['homepage']) {
|
||||||
|
@ -45,7 +45,7 @@ const main = async() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['i'] || args['inputs']) {
|
if (args['i'] || args['inputs']) {
|
||||||
console.log(updateFlakeInputs());
|
console.log(updateFlakeInputs() ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['j'] || args['jmusicbot']) {
|
if (args['j'] || args['jmusicbot']) {
|
||||||
|
@ -57,7 +57,7 @@ const main = async() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['n'] || args['node_modules']) {
|
if (args['n'] || args['node_modules']) {
|
||||||
console.log(await updateNodeModules());
|
console.log((await updateNodeModules()) ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['p'] || args['pam-fprint-grosshack']) {
|
if (args['p'] || args['pam-fprint-grosshack']) {
|
||||||
|
@ -77,43 +77,43 @@ const main = async() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['v'] || args['vuetorrent']) {
|
if (args['v'] || args['vuetorrent']) {
|
||||||
console.log(updateVuetorrent());
|
console.log(updateVuetorrent() ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['a'] || args['all']) {
|
if (args['a'] || args['all']) {
|
||||||
// Update this first because of nix run cmd
|
// Update this first because of nix run cmd
|
||||||
const firefoxOutput = updateFirefoxAddons();
|
const firefoxOutput = updateFirefoxAddons();
|
||||||
|
|
||||||
console.log(firefoxOutput);
|
console.log(firefoxOutput ?? 'No updates');
|
||||||
|
|
||||||
|
|
||||||
const flakeOutput = updateFlakeInputs();
|
const flakeOutput = updateFlakeInputs();
|
||||||
|
|
||||||
console.log(flakeOutput);
|
console.log(flakeOutput ?? 'No updates');
|
||||||
|
|
||||||
|
|
||||||
const dockerOutput = updateDocker();
|
const dockerOutput = updateDocker();
|
||||||
|
|
||||||
console.log(dockerOutput);
|
console.log(dockerOutput ?? 'No updates');
|
||||||
|
|
||||||
|
|
||||||
const nodeModulesOutput = await updateNodeModules();
|
const nodeModulesOutput = await updateNodeModules();
|
||||||
|
|
||||||
console.log(nodeModulesOutput);
|
console.log(nodeModulesOutput ?? 'No updates');
|
||||||
|
|
||||||
|
|
||||||
const vuetorrentOutput = updateVuetorrent();
|
const vuetorrentOutput = updateVuetorrent();
|
||||||
|
|
||||||
console.log(vuetorrentOutput);
|
console.log(vuetorrentOutput ?? 'No updates');
|
||||||
|
|
||||||
|
|
||||||
const caddyPluginsOutput = updateCaddyPlugins();
|
const caddyPluginsOutput = updateCaddyPlugins();
|
||||||
|
|
||||||
console.log(caddyPluginsOutput);
|
console.log(caddyPluginsOutput ?? 'No updates');
|
||||||
|
|
||||||
|
|
||||||
// nix-update executions
|
// nix-update executions
|
||||||
let nixUpdateOutputs = '';
|
const nixUpdateOutputs: string[] = [];
|
||||||
|
|
||||||
const updatePackage = (
|
const updatePackage = (
|
||||||
attr: string,
|
attr: string,
|
||||||
|
@ -123,7 +123,7 @@ const main = async() => {
|
||||||
const execution = runNixUpdate(attr, scope, scopeAttr);
|
const execution = runNixUpdate(attr, scope, scopeAttr);
|
||||||
|
|
||||||
if (execution.changelog) {
|
if (execution.changelog) {
|
||||||
nixUpdateOutputs += execution.changelog;
|
nixUpdateOutputs.push(execution.changelog);
|
||||||
}
|
}
|
||||||
console.log(execution.stderr);
|
console.log(execution.stderr);
|
||||||
console.log(execution.stdout);
|
console.log(execution.stdout);
|
||||||
|
@ -139,6 +139,8 @@ const main = async() => {
|
||||||
updatePackage('scopedPackages', 'lovelace-components', 'material-rounded-theme');
|
updatePackage('scopedPackages', 'lovelace-components', 'material-rounded-theme');
|
||||||
|
|
||||||
|
|
||||||
|
spawnSync('alejandra', ['-q', FLAKE], { shell: true });
|
||||||
|
|
||||||
spawnSync('nixFastBuild', [], {
|
spawnSync('nixFastBuild', [], {
|
||||||
shell: true,
|
shell: true,
|
||||||
stdio: [process.stdin, process.stdout, process.stderr],
|
stdio: [process.stdin, process.stdout, process.stderr],
|
||||||
|
@ -149,41 +151,40 @@ const main = async() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const output = [
|
const output = [
|
||||||
'chore: update sources\n\n',
|
'chore: update sources',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (flakeOutput.length > 5) {
|
if (flakeOutput) {
|
||||||
output.push(`Flake Inputs:\n${indentOutput(flakeOutput)}\n\n\n`);
|
output.push(`Flake Inputs:\n${indentOutput(flakeOutput)}\n`);
|
||||||
}
|
}
|
||||||
if (dockerOutput.length > 5) {
|
if (dockerOutput) {
|
||||||
output.push(`Docker Images:\n${indentOutput(dockerOutput)}\n\n\n`);
|
output.push(`Docker Images:\n${indentOutput(dockerOutput)}\n`);
|
||||||
}
|
}
|
||||||
if (firefoxOutput.length > 5) {
|
if (firefoxOutput) {
|
||||||
output.push(`Firefox Addons:\n${indentOutput(firefoxOutput)}\n\n\n`);
|
output.push(`Firefox Addons:\n${indentOutput(firefoxOutput)}\n`);
|
||||||
}
|
}
|
||||||
if (nodeModulesOutput.length > 5) {
|
if (nodeModulesOutput) {
|
||||||
output.push(`Node modules:\n${indentOutput(nodeModulesOutput)}\n\n\n`);
|
output.push(`Node modules:\n${indentOutput(nodeModulesOutput)}\n`);
|
||||||
}
|
}
|
||||||
if (vuetorrentOutput.length > 5) {
|
if (vuetorrentOutput) {
|
||||||
output.push(`Misc Sources:\n${indentOutput(vuetorrentOutput)}\n\n\n`);
|
output.push(`qBittorrent Sources:\n${indentOutput(vuetorrentOutput)}\n`);
|
||||||
}
|
}
|
||||||
if (caddyPluginsOutput !== '') {
|
if (caddyPluginsOutput) {
|
||||||
output.push(`Caddy Plugins:\n${indentOutput(caddyPluginsOutput)}\n\n\n`);
|
output.push(`Caddy Plugins:\n${indentOutput(caddyPluginsOutput)}\n`);
|
||||||
}
|
}
|
||||||
if (nixUpdateOutputs !== '') {
|
if (nixUpdateOutputs.length > 0) {
|
||||||
output.push(`nix-update executions:\n${indentOutput(nixUpdateOutputs)}\n\n\n`);
|
output.push(`nix-update executions:\n${indentOutput(nixUpdateOutputs.join('\n'))}\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['f']) {
|
if (args['f']) {
|
||||||
writeFileSync(args['f'] as string, output.join(''));
|
console.log(styleText(['magenta'], `\n\nWriting commit message to ${args['f']}\n`));
|
||||||
|
writeFileSync(args['f'], output.join('\n\n'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log(styleText(['magenta'], '\n\nCommit message:\n'));
|
console.log(styleText(['magenta'], '\n\nCommit message:\n'));
|
||||||
console.log(output.join(''));
|
console.log(output.join('\n\n'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnSync('alejandra', ['-q', FLAKE], { shell: true });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
|
@ -34,10 +34,10 @@ ${Object.entries(plugins)
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default (): string => {
|
export default (): string | null => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating caddy plugins:\n'));
|
console.log(styleText(['magenta'], '\nUpdating caddy plugins:\n'));
|
||||||
|
|
||||||
let updates = '';
|
const updates: string[] = [];
|
||||||
const dir = `${FLAKE}/configurations/cluster/modules/caddy`;
|
const dir = `${FLAKE}/configurations/cluster/modules/caddy`;
|
||||||
|
|
||||||
// Setup workspace
|
// Setup workspace
|
||||||
|
@ -70,7 +70,7 @@ export default (): string => {
|
||||||
.split(' ')[1];
|
.split(' ')[1];
|
||||||
|
|
||||||
if (plugins[key].version !== NEW_VERSION) {
|
if (plugins[key].version !== NEW_VERSION) {
|
||||||
updates += `${key}: ${plugins[key].version} -> ${NEW_VERSION}\n`;
|
updates.push(`${key}: ${plugins[key].version} -> ${NEW_VERSION}`);
|
||||||
plugins[key].version = NEW_VERSION;
|
plugins[key].version = NEW_VERSION;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -88,5 +88,5 @@ export default (): string => {
|
||||||
|
|
||||||
replaceInFile(/hash = ".*";/, `hash = "${NEW_HASH}";`, `${dir}/plugins.nix`);
|
replaceInFile(/hash = ".*";/, `hash = "${NEW_HASH}";`, `${dir}/plugins.nix`);
|
||||||
|
|
||||||
return updates;
|
return updates.length > 0 ? updates.join('\n') : null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,21 +16,36 @@ const updateImages = (imagePath: string): string | undefined => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default () => {
|
export default (): string | null => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating docker images:\n'));
|
console.log(styleText(['magenta'], '\nUpdating docker images:\n'));
|
||||||
|
|
||||||
let updates = '';
|
const updates: string[] = [];
|
||||||
|
|
||||||
updates += updateImages(`${FLAKE}/configurations/nos/modules/jellyfin`) ?? '';
|
const jellfyinUpdates = updateImages(`${FLAKE}/configurations/nos/modules/jellyfin`);
|
||||||
updates += updateImages(`${FLAKE}/configurations/homie/modules/home-assistant/netdaemon`) ?? '';
|
|
||||||
|
if (jellfyinUpdates) {
|
||||||
|
updates.push(jellfyinUpdates);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hassUpdates = updateImages(`${FLAKE}/configurations/homie/modules/home-assistant/netdaemon`);
|
||||||
|
|
||||||
|
if (hassUpdates) {
|
||||||
|
updates.push(hassUpdates);
|
||||||
|
}
|
||||||
|
|
||||||
const DIR = `${FLAKE}/configurations/nos/modules/docker`;
|
const DIR = `${FLAKE}/configurations/nos/modules/docker`;
|
||||||
|
|
||||||
readdirSync(DIR, { withFileTypes: true, recursive: true }).forEach((path) => {
|
readdirSync(DIR, { withFileTypes: true, recursive: true }).forEach((path) => {
|
||||||
if (path.name === 'compose.nix') {
|
if (path.name === 'compose.nix') {
|
||||||
updates += updateImages(path.parentPath) ?? '';
|
const composeUpdates = updateImages(path.parentPath);
|
||||||
|
|
||||||
|
if (composeUpdates) {
|
||||||
|
updates.push(composeUpdates);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return updates;
|
return updates.length > 0 ?
|
||||||
|
updates.join('') :
|
||||||
|
null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { styleText } from 'node:util';
|
||||||
/* Constants */
|
/* Constants */
|
||||||
const FLAKE = process.env.FLAKE;
|
const FLAKE = process.env.FLAKE;
|
||||||
|
|
||||||
export default () => {
|
export default (): string | null => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating firefox addons using mozilla-addons-to-nix:\n'));
|
console.log(styleText(['magenta'], '\nUpdating firefox addons using mozilla-addons-to-nix:\n'));
|
||||||
|
|
||||||
const DIR = `${FLAKE}/scopedPackages/firefox-addons`;
|
const DIR = `${FLAKE}/scopedPackages/firefox-addons`;
|
||||||
|
@ -54,9 +54,12 @@ export default () => {
|
||||||
return [nameMap[pinfo[0]], pinfo[2]];
|
return [nameMap[pinfo[0]], pinfo[2]];
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return Object.keys(OLD_VERS)
|
const changelogs = Object.keys(OLD_VERS)
|
||||||
.sort()
|
.sort()
|
||||||
.filter((pname) => OLD_VERS[pname] !== NEW_VERS[pname])
|
.filter((pname) => OLD_VERS[pname] !== NEW_VERS[pname])
|
||||||
.map((pname) => `${pname}: ${OLD_VERS[pname]} -> ${NEW_VERS[pname]}`)
|
.map((pname) => `${pname}: ${OLD_VERS[pname]} -> ${NEW_VERS[pname]}`);
|
||||||
.join('\n');
|
|
||||||
|
return changelogs.length > 0 ?
|
||||||
|
changelogs.join('\n') :
|
||||||
|
null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,17 +5,18 @@ import { styleText } from 'node:util';
|
||||||
/* Constants */
|
/* Constants */
|
||||||
const FLAKE = process.env.FLAKE;
|
const FLAKE = process.env.FLAKE;
|
||||||
|
|
||||||
export default () => {
|
export default (): string | null => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating flake inputs:\n'));
|
console.log(styleText(['magenta'], '\nUpdating flake inputs:\n'));
|
||||||
|
|
||||||
const output = spawnSync(
|
const output: string = spawnSync(
|
||||||
`git restore flake.lock &> /dev/null; nix flake update --flake ${FLAKE}` +
|
`git restore flake.lock &> /dev/null; nix flake update --flake ${FLAKE}` +
|
||||||
' |& grep -v "warning: updating lock file" |& grep -v "unpacking"',
|
' |& grep -v "warning: updating lock file" |& grep -v "unpacking"',
|
||||||
[],
|
[],
|
||||||
{ shell: true },
|
{ shell: true },
|
||||||
).stdout
|
).stdout.toString();
|
||||||
.toString()
|
|
||||||
// Add an extra blank line between inputs
|
const inputsUpdates: string[] = output
|
||||||
|
// Get an array of each update / change
|
||||||
.split('\n•')
|
.split('\n•')
|
||||||
// Filter out some inputs
|
// Filter out some inputs
|
||||||
.filter((input) => ![
|
.filter((input) => ![
|
||||||
|
@ -29,9 +30,12 @@ export default () => {
|
||||||
'nix-gaming/umu',
|
'nix-gaming/umu',
|
||||||
'nix-github-actions',
|
'nix-github-actions',
|
||||||
'pre-commit-hooks',
|
'pre-commit-hooks',
|
||||||
].some((inputName) => input.startsWith(` Updated input '${inputName}'`)))
|
].some((inputName) => input.startsWith(` Updated input '${inputName}'`)));
|
||||||
|
|
||||||
|
const formattedOutput: string = inputsUpdates
|
||||||
|
// Add an extra blank line between inputs
|
||||||
.join('\n\n•')
|
.join('\n\n•')
|
||||||
// help readability of git revs
|
// Help readability of git revs
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((l) => l
|
.map((l) => l
|
||||||
.replace(
|
.replace(
|
||||||
|
@ -44,5 +48,7 @@ export default () => {
|
||||||
))
|
))
|
||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
||||||
return output;
|
return inputsUpdates.length > 0 ?
|
||||||
|
formattedOutput :
|
||||||
|
null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
import { readFileSync, writeFileSync } from 'node:fs';
|
import { readFileSync, writeFileSync } from 'node:fs';
|
||||||
|
|
||||||
|
/* Types */
|
||||||
|
interface Args {
|
||||||
|
f: string | undefined
|
||||||
|
[name: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
export const parseArgs = () => {
|
|
||||||
const args = {} as Record<string, unknown>;
|
export const parseArgs = (): Args => {
|
||||||
|
const args = {} as Args;
|
||||||
let lastFlag: string | null = null;
|
let lastFlag: string | null = null;
|
||||||
|
|
||||||
for (let i = 2; i < process.argv.length; ++i) {
|
for (let i = 2; i < process.argv.length; ++i) {
|
||||||
|
@ -25,12 +31,12 @@ export const parseArgs = () => {
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const parseFetchurl = (url: string) => JSON.parse(spawnSync(
|
export const parseFetchurl = (url: string): string => JSON.parse(spawnSync(
|
||||||
'nix', ['store', 'prefetch-file', '--refresh', '--json',
|
'nix', ['store', 'prefetch-file', '--refresh', '--json',
|
||||||
'--hash-type', 'sha256', url, '--name', '"escaped"'], { shell: true },
|
'--hash-type', 'sha256', url, '--name', '"escaped"'], { shell: true },
|
||||||
).stdout.toString()).hash;
|
).stdout.toString()).hash;
|
||||||
|
|
||||||
export const replaceInFile = (replace: RegExp, replacement: string, file: string) => {
|
export const replaceInFile = (replace: RegExp, replacement: string, file: string): void => {
|
||||||
const fileContents = readFileSync(file);
|
const fileContents = readFileSync(file);
|
||||||
|
|
||||||
const replaced = fileContents.toString().replace(replace, replacement);
|
const replaced = fileContents.toString().replace(replace, replacement);
|
||||||
|
@ -38,6 +44,6 @@ export const replaceInFile = (replace: RegExp, replacement: string, file: string
|
||||||
writeFileSync(file, replaced);
|
writeFileSync(file, replaced);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const npmRun = (args: string[], workspaceDir: string) => spawnSync(
|
export const npmRun = (args: string[], workspaceDir: string): string => spawnSync(
|
||||||
'npm', args, { cwd: workspaceDir },
|
'npm', args, { cwd: workspaceDir },
|
||||||
).stdout.toString();
|
).stdout.toString();
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default (
|
||||||
|
|
||||||
return {
|
return {
|
||||||
changelog: OLD_VERSION !== NEW_VERSION ?
|
changelog: OLD_VERSION !== NEW_VERSION ?
|
||||||
`${cleanAttr}: ${OLD_VERSION} -> ${NEW_VERSION}\n` :
|
`${cleanAttr}: ${OLD_VERSION} -> ${NEW_VERSION}` :
|
||||||
null,
|
null,
|
||||||
stdout: execution.stdout.toString(),
|
stdout: execution.stdout.toString(),
|
||||||
stderr: execution.stderr.toString(),
|
stderr: execution.stderr.toString(),
|
||||||
|
|
|
@ -71,7 +71,7 @@ const prefetchNpmDeps = (workspaceDir: string): string => {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default async() => {
|
export default async(): Promise<string | null> => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating node modules:\n'));
|
console.log(styleText(['magenta'], '\nUpdating node modules:\n'));
|
||||||
|
|
||||||
const updates = {};
|
const updates = {};
|
||||||
|
@ -115,7 +115,9 @@ export default async() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.entries(updates)
|
return Object.entries(updates).length > 0 ?
|
||||||
.map(([key, dep]) => `${key}: ${dep}`)
|
Object.entries(updates)
|
||||||
.join('\n');
|
.map(([key, dep]) => `${key}: ${dep}`)
|
||||||
|
.join('\n') :
|
||||||
|
null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ const genVueText = (
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default () => {
|
export default (): string | null => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating Vuetorrent:\n'));
|
console.log(styleText(['magenta'], '\nUpdating Vuetorrent:\n'));
|
||||||
|
|
||||||
const FILE = `${FLAKE}/configurations/nos/modules/qbittorrent/vuetorrent.nix`;
|
const FILE = `${FLAKE}/configurations/nos/modules/qbittorrent/vuetorrent.nix`;
|
||||||
|
@ -40,5 +40,5 @@ export default () => {
|
||||||
|
|
||||||
writeFileSync(FILE, fileText);
|
writeFileSync(FILE, fileText);
|
||||||
|
|
||||||
return OLD_VERSION !== VERSION ? `Vuetorrent: ${OLD_VERSION} -> ${VERSION}` : '';
|
return OLD_VERSION !== VERSION ? `Vuetorrent: ${OLD_VERSION} -> ${VERSION}\n` : null;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue