feat(update): start work on npm updating
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-30 03:44:34 -05:00
parent 9612c2a634
commit f52293ffe3
6 changed files with 53 additions and 3 deletions

View file

@ -9,7 +9,7 @@
jq, jq,
... ...
}: let }: let
inherit (lib) concatMapStringsSep getBin; inherit (lib) concatMapStringsSep;
inherit (builtins) fromJSON readFile; inherit (builtins) fromJSON readFile;
packageJSON = fromJSON (readFile "${src}/package.json"); packageJSON = fromJSON (readFile "${src}/package.json");
@ -31,7 +31,7 @@ in
postInstall = '' postInstall = ''
wrapProgram $out/bin/${pname} \ wrapProgram $out/bin/${pname} \
--prefix PATH : ${concatMapStringsSep ":" (p: getBin p) runtimeInputs} --prefix PATH : ${concatMapStringsSep ":" (p: p + "/bin") runtimeInputs}
''; '';
nodejs = nodejs_latest; nodejs = nodejs_latest;

View file

@ -1,13 +1,15 @@
{ {
buildApp, buildApp,
callPackage, callPackage,
nodejs_latest,
... ...
}: }:
buildApp { buildApp {
src = ./.; src = ./.;
npmDepsHash = "sha256-MF5z9QGOdxUKWDP7S4wdszgLrh6f5UyFb9tCn3QSH0k="; npmDepsHash = "sha256-XXc5wCGFGtr1e6URp2yXsWEKVrh5GrXQ/+Eud3W8ks4=";
runtimeInputs = [ runtimeInputs = [
nodejs_latest
(callPackage ../../nixosModules/docker/updateImage.nix {}) (callPackage ../../nixosModules/docker/updateImage.nix {})
]; ];
} }

Binary file not shown.

View file

@ -14,6 +14,7 @@
"eslint": "9.15.0", "eslint": "9.15.0",
"eslint-plugin-jsdoc": "50.5.0", "eslint-plugin-jsdoc": "50.5.0",
"jiti": "2.4.0", "jiti": "2.4.0",
"pkg-types": "1.2.1",
"typescript": "5.6.3", "typescript": "5.6.3",
"typescript-eslint": "8.15.0" "typescript-eslint": "8.15.0"
} }

View file

@ -7,6 +7,7 @@ import { updateDocker } from './docker';
import { updateFirefoxAddons } from '././firefox'; import { updateFirefoxAddons } from '././firefox';
import { updateFlakeInputs } from './flake'; import { updateFlakeInputs } from './flake';
import { updateCustomPackage, updateVuetorrent } from './misc'; import { updateCustomPackage, updateVuetorrent } from './misc';
import updateNodeModules from './node-modules';
/* Constants */ /* Constants */
@ -43,6 +44,10 @@ if (args['s'] || args['some-sass-language-server']) {
console.log(updateCustomPackage('some-sass-language-server')); console.log(updateCustomPackage('some-sass-language-server'));
} }
if (args['n'] || args['node_modules']) {
updateNodeModules();
}
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();

View file

@ -0,0 +1,42 @@
import { readPackageJSON } from 'pkg-types';
import { readdirSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
/* Constants */
const FLAKE = process.env.FLAKE as string;
export default () => {
readdirSync(FLAKE, { withFileTypes: true, recursive: true }).forEach(async(path) => {
if (path.name === 'package.json' && !path.parentPath.includes('node_modules')) {
const currentWorkspace = path.parentPath;
const currentPackageJson = await readPackageJSON(`${currentWorkspace}/package.json`);
const outdated = JSON.parse(spawnSync(
'npm',
['outdated', '--json'],
{ cwd: currentWorkspace },
).stdout.toString());
Object.keys(currentPackageJson.dependencies ?? {}).forEach((dep) => {
const versions = outdated[dep];
if (!versions?.current) {
return;
}
console.log(`${dep}: ${versions.current} -> ${versions.latest}`);
});
Object.keys(currentPackageJson.devDependencies ?? {}).forEach((dep) => {
const versions = outdated[dep];
if (!versions?.current) {
return;
}
console.log(`${dep}: ${versions.current} -> ${versions.latest}`);
});
}
});
};