parent
81b61228e0
commit
a93ec6ad3f
8 changed files with 53 additions and 52 deletions
apps/update-sources/src
|
@ -1,19 +1,16 @@
|
||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
import { writeFileSync } from 'node:fs';
|
import { writeFileSync } from 'node:fs';
|
||||||
|
import { styleText } from 'node:util';
|
||||||
|
|
||||||
import { parseArgs } from './lib';
|
import { parseArgs } from './lib';
|
||||||
|
|
||||||
import { updateCaddyPlugins } from './caddy';
|
import updateCaddyPlugins from './caddy';
|
||||||
import { updateDocker } from './docker';
|
import updateDocker from './docker';
|
||||||
import { updateFirefoxAddons } from '././firefox';
|
import updateFirefoxAddons from '././firefox';
|
||||||
import { updateFlakeInputs } from './flake';
|
import updateFlakeInputs from './flake';
|
||||||
|
import runNixUpdate from './nix-update';
|
||||||
import updateNodeModules from './node-modules';
|
import updateNodeModules from './node-modules';
|
||||||
|
import updateVuetorrent from './vuetorrent';
|
||||||
import {
|
|
||||||
runNixUpdate,
|
|
||||||
updateVuetorrent,
|
|
||||||
} from './misc';
|
|
||||||
import { styleText } from 'node:util';
|
|
||||||
|
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
|
|
|
@ -34,7 +34,7 @@ ${Object.entries(plugins)
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const updateCaddyPlugins = (): string => {
|
export default (): string => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating caddy plugins:\n'));
|
console.log(styleText(['magenta'], '\nUpdating caddy plugins:\n'));
|
||||||
|
|
||||||
let updates = '';
|
let updates = '';
|
||||||
|
|
|
@ -16,7 +16,7 @@ const updateImages = (imagePath: string): string | undefined => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateDocker = () => {
|
export default () => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating docker images:\n'));
|
console.log(styleText(['magenta'], '\nUpdating docker images:\n'));
|
||||||
|
|
||||||
let updates = '';
|
let updates = '';
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { styleText } from 'node:util';
|
||||||
/* Constants */
|
/* Constants */
|
||||||
const FLAKE = process.env.FLAKE;
|
const FLAKE = process.env.FLAKE;
|
||||||
|
|
||||||
export const updateFirefoxAddons = () => {
|
export default () => {
|
||||||
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`;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { styleText } from 'node:util';
|
||||||
/* Constants */
|
/* Constants */
|
||||||
const FLAKE = process.env.FLAKE;
|
const FLAKE = process.env.FLAKE;
|
||||||
|
|
||||||
export const updateFlakeInputs = () => {
|
export default () => {
|
||||||
console.log(styleText(['magenta'], '\nUpdating flake inputs:\n'));
|
console.log(styleText(['magenta'], '\nUpdating flake inputs:\n'));
|
||||||
|
|
||||||
const output = spawnSync(
|
const output = spawnSync(
|
||||||
|
|
39
apps/update-sources/src/nix-update.ts
Normal file
39
apps/update-sources/src/nix-update.ts
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import { styleText } from 'node:util';
|
||||||
|
|
||||||
|
|
||||||
|
/* Constants */
|
||||||
|
const FLAKE = process.env.FLAKE;
|
||||||
|
|
||||||
|
const getAttrVersion = (attr: string): string => spawnSync('nix',
|
||||||
|
['eval', '--raw', `${FLAKE}#${attr}.version`],
|
||||||
|
{ shell: true }).stdout.toString();
|
||||||
|
|
||||||
|
export default (
|
||||||
|
attr: string,
|
||||||
|
scope?: string,
|
||||||
|
scopeAttr?: string,
|
||||||
|
): {
|
||||||
|
changelog: string | null
|
||||||
|
stdout: string
|
||||||
|
stderr: string
|
||||||
|
} => {
|
||||||
|
const realAttr = scope ? `${attr}.x86_64-linux.${scope}.${scopeAttr}` : attr;
|
||||||
|
const cleanAttr = scope ? `${attr}.${scope}.${scopeAttr}` : attr;
|
||||||
|
|
||||||
|
console.log(styleText(['magenta'], `\nUpdating ${realAttr}:\n`));
|
||||||
|
|
||||||
|
const OLD_VERSION = getAttrVersion(realAttr);
|
||||||
|
|
||||||
|
const execution = spawnSync('nix-update', ['--flake', realAttr, '-u'], { cwd: FLAKE });
|
||||||
|
|
||||||
|
const NEW_VERSION = getAttrVersion(realAttr);
|
||||||
|
|
||||||
|
return {
|
||||||
|
changelog: OLD_VERSION !== NEW_VERSION ?
|
||||||
|
`${cleanAttr}: ${OLD_VERSION} -> ${NEW_VERSION}\n` :
|
||||||
|
null,
|
||||||
|
stdout: execution.stdout.toString(),
|
||||||
|
stderr: execution.stderr.toString(),
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,9 +1,9 @@
|
||||||
import { readPackageJSON, writePackageJSON } from 'pkg-types';
|
import { readPackageJSON, writePackageJSON } from 'pkg-types';
|
||||||
import { accessSync, constants, existsSync } from 'node:fs';
|
import { accessSync, constants, existsSync } from 'node:fs';
|
||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import { styleText } from 'node:util';
|
||||||
|
|
||||||
import { replaceInFile, npmRun } from './lib';
|
import { replaceInFile, npmRun } from './lib';
|
||||||
import { styleText } from 'node:util';
|
|
||||||
|
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
|
@ -11,7 +11,6 @@ const FLAKE = process.env.FLAKE as string;
|
||||||
|
|
||||||
const PINS = new Map([]);
|
const PINS = new Map([]);
|
||||||
|
|
||||||
|
|
||||||
const updatePackageJson = async(workspaceDir: string, updates: object) => {
|
const updatePackageJson = async(workspaceDir: string, updates: object) => {
|
||||||
const currentPackageJson = await readPackageJSON(`${workspaceDir}/package.json`);
|
const currentPackageJson = await readPackageJSON(`${workspaceDir}/package.json`);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { writeFileSync } from 'node:fs';
|
import { writeFileSync } from 'node:fs';
|
||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import { styleText } from 'node:util';
|
||||||
|
|
||||||
import { parseFetchurl } from './lib';
|
import { parseFetchurl } from './lib';
|
||||||
import { styleText } from 'node:util';
|
|
||||||
|
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
|
@ -20,7 +20,7 @@ const genVueText = (
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const updateVuetorrent = () => {
|
export default () => {
|
||||||
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`;
|
||||||
|
@ -42,37 +42,3 @@ export const updateVuetorrent = () => {
|
||||||
|
|
||||||
return OLD_VERSION !== VERSION ? `Vuetorrent: ${OLD_VERSION} -> ${VERSION}` : '';
|
return OLD_VERSION !== VERSION ? `Vuetorrent: ${OLD_VERSION} -> ${VERSION}` : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const getAttrVersion = (attr: string): string => spawnSync('nix',
|
|
||||||
['eval', '--raw', `${FLAKE}#${attr}.version`],
|
|
||||||
{ shell: true }).stdout.toString();
|
|
||||||
|
|
||||||
export const runNixUpdate = (
|
|
||||||
attr: string,
|
|
||||||
scope?: string,
|
|
||||||
scopeAttr?: string,
|
|
||||||
): {
|
|
||||||
changelog: string | null
|
|
||||||
stdout: string
|
|
||||||
stderr: string
|
|
||||||
} => {
|
|
||||||
const realAttr = scope ? `${attr}.x86_64-linux.${scope}.${scopeAttr}` : attr;
|
|
||||||
const cleanAttr = scope ? `${attr}.${scope}.${scopeAttr}` : attr;
|
|
||||||
|
|
||||||
console.log(styleText(['magenta'], `\nUpdating ${realAttr}:\n`));
|
|
||||||
|
|
||||||
const OLD_VERSION = getAttrVersion(realAttr);
|
|
||||||
|
|
||||||
const execution = spawnSync('nix-update', ['--flake', realAttr, '-u'], { cwd: FLAKE });
|
|
||||||
|
|
||||||
const NEW_VERSION = getAttrVersion(realAttr);
|
|
||||||
|
|
||||||
return {
|
|
||||||
changelog: OLD_VERSION !== NEW_VERSION ?
|
|
||||||
`${cleanAttr}: ${OLD_VERSION} -> ${NEW_VERSION}\n` :
|
|
||||||
null,
|
|
||||||
stdout: execution.stdout.toString(),
|
|
||||||
stderr: execution.stderr.toString(),
|
|
||||||
};
|
|
||||||
};
|
|
Loading…
Add table
Add a link
Reference in a new issue