summary refs log tree commit diff
path: root/bundle/scripts/depcheck.js
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-06 22:28:15 +0200
committerGitHub <noreply@github.com>2022-08-06 22:28:15 +0200
commit8fbcd35a87ac572c8e14b24b33fcb3d2e9223703 (patch)
treec9afc6ff4f708fb4c3ebbfb6a4a754375cc50d4e /bundle/scripts/depcheck.js
parentMerge pull request #815 from fosscord/translation (diff)
parentMake build script use parts, defined in utils.js (diff)
downloadserver-8fbcd35a87ac572c8e14b24b33fcb3d2e9223703.tar.xz
Merge pull request #817 from fosscord/dev/new-scripts
Add utility scripts
Diffstat (limited to 'bundle/scripts/depcheck.js')
-rw-r--r--bundle/scripts/depcheck.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/bundle/scripts/depcheck.js b/bundle/scripts/depcheck.js
new file mode 100644

index 00000000..1957f794 --- /dev/null +++ b/bundle/scripts/depcheck.js
@@ -0,0 +1,56 @@ +const path = require("path"); +const fs = require("fs"); +const { env } = require("process"); +const { execSync } = require("child_process"); +const { argv, stdout, exit } = require("process"); + +const { execIn, getLines, parts } = require("./utils"); + +let npmi_extra_flags = ""; + +const resolveminor = argv.includes("resolveminor"); +if(argv.includes("nobuild")) npmi_extra_flags += "--ignore-scripts "; + +parts.forEach((part) => { + let partDir = path.join(__dirname, "..", "..", part); + let distDir = path.join(partDir, "dist"); + console.log(`Checking updates for ${part} (${partDir})`); + if(part == "bundle") { + execIn(`npm run syncdeps`, partDir) + } + if(resolveminor) { + fs.rmSync(path.join(partDir, "node_modules"), { + recursive: true, + force: true, + }); + execIn(`npm i --save --no-fund --no-audit --no-package-lock ${npmi_extra_flags}`, partDir) + } + let x = [ + [ + "pkg", + { + current: "1.0", + wanted: "2.0", + latest: "2.0", + dependent: "cdn", + location: "/usr/src/fosscord/bundle/node_packages/pkg", + }, + ], + ]; + x = Object.entries( + JSON.parse(execIn("npm outdated --json", partDir)) + ); + x.forEach((a) => { + let pkgname = a[0]; + let pkginfo = a[1]; + if(!pkginfo.current) + console.log(`MISSING ${pkgname}: ${pkginfo.current} -> ${pkginfo.wanted} (latest: ${pkginfo.latest})`); + else if(pkginfo.latest != pkginfo.wanted){ + if(pkginfo.current != pkginfo.wanted) + console.log(`MINOR ${pkgname}: ${pkginfo.current} -> ${pkginfo.wanted}`); + console.log(`MAJOR ${pkgname}: ${pkginfo.current} -> ${pkginfo.latest}`); + } + else + console.log(`MINOR ${pkgname}: ${pkginfo.current} -> ${pkginfo.wanted}`); + }); +});