parent
d17f6d9880
commit
dfc8337342
5 changed files with 122 additions and 61 deletions
apps/update-sources/src
32
apps/update-sources/src/netdaemon.ts
Normal file
32
apps/update-sources/src/netdaemon.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { styleText } from 'node:util';
|
||||
|
||||
|
||||
/* Constants */
|
||||
const FLAKE = process.env.FLAKE;
|
||||
|
||||
export default (): string | null => {
|
||||
console.log(styleText(['magenta'], '\nUpdating NetDaemon:\n'));
|
||||
|
||||
const FOLDER = `${FLAKE}/configurations/homie/modules/home-assistant/netdaemon`;
|
||||
|
||||
const OLD_VERSION = readFileSync(`${FOLDER}/.version`).toString().replace('\n', '');
|
||||
|
||||
const VERSION = JSON.parse(spawnSync('curl',
|
||||
['-s', 'https://api.github.com/repos/net-daemon/netdaemon/releases/latest'],
|
||||
{ shell: true }).stdout.toString()).tag_name.replace('v', '');
|
||||
|
||||
if (OLD_VERSION !== VERSION) {
|
||||
writeFileSync(`${FOLDER}/.version`, `${VERSION}\n`);
|
||||
|
||||
spawnSync('bumpNetdaemonDeps', [], {
|
||||
cwd: FOLDER,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
return `NetDaemon: ${OLD_VERSION} -> ${VERSION}\n`;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue