meshcentral: rewrite with buildNpmPackage (#493026)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,144 +0,0 @@
|
||||
{
|
||||
"name": "meshcentral",
|
||||
"version": "1.1.56",
|
||||
"keywords": [
|
||||
"Remote Device Management",
|
||||
"Remote Device Monitoring",
|
||||
"Remote Desktop",
|
||||
"Remote Terminal",
|
||||
"Remote File Access",
|
||||
"KVM",
|
||||
"2FA",
|
||||
"Two-Factor Authentication",
|
||||
"Intel Active Management Technology",
|
||||
"Intel AMT"
|
||||
],
|
||||
"homepage": "https://meshcentral.com",
|
||||
"description": "Web based remote computer management server",
|
||||
"author": "Ylian Saint-Hilaire <ylianst@gmail.com>",
|
||||
"main": "meshcentral.js",
|
||||
"bin": {
|
||||
"meshcentral": "bin/meshcentral"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
"*.js",
|
||||
"amt",
|
||||
"bin",
|
||||
"rdp",
|
||||
"views",
|
||||
"emails",
|
||||
"agents",
|
||||
"public",
|
||||
"translate",
|
||||
"readme.txt",
|
||||
"license.txt",
|
||||
"sample-config.json",
|
||||
"sample-config-advanced.json"
|
||||
],
|
||||
"dependencies": {
|
||||
"@seald-io/nedb": "4.1.2",
|
||||
"archiver": "7.0.1",
|
||||
"body-parser": "1.20.4",
|
||||
"cbor": "5.2.0",
|
||||
"compression": "1.8.1",
|
||||
"cookie-session": "2.1.1",
|
||||
"express": "4.22.1",
|
||||
"express-handlebars": "7.1.3",
|
||||
"express-ws": "5.0.2",
|
||||
"ipcheck": "0.1.0",
|
||||
"minimist": "1.2.8",
|
||||
"multiparty": "4.2.3",
|
||||
"node-forge": "1.3.2",
|
||||
"otplib": "12.0.1",
|
||||
"ua-client-hints-js": "0.1.2",
|
||||
"ua-parser-js": "1.0.40",
|
||||
"ws": "8.18.3",
|
||||
"yauzl": "2.10.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Ylianst/MeshCentral.git"
|
||||
},
|
||||
"readme": "readme.md",
|
||||
"optionalDependencies": {
|
||||
"passport": "0.7.0",
|
||||
"connect-flash": "0.1.1",
|
||||
"passport-twitter": "1.0.4",
|
||||
"passport-google-oauth20": "2.0.0",
|
||||
"passport-github2": "0.1.12",
|
||||
"passport-azure-oauth2": "0.1.0",
|
||||
"jwt-simple": "0.5.6",
|
||||
"openid-client": "5.7.1",
|
||||
"passport-saml": "*",
|
||||
"@duosecurity/duo_universal": "2.1.0",
|
||||
"archiver": "7.0.1",
|
||||
"body-parser": "1.20.4",
|
||||
"cbor": "5.2.0",
|
||||
"compression": "1.8.1",
|
||||
"cookie-session": "2.1.1",
|
||||
"express": "4.22.1",
|
||||
"express-handlebars": "7.1.3",
|
||||
"express-ws": "5.0.2",
|
||||
"ipcheck": "0.1.0",
|
||||
"minimist": "1.2.8",
|
||||
"multiparty": "4.2.3",
|
||||
"@seald-io/nedb": "4.1.2",
|
||||
"node-forge": "1.3.2",
|
||||
"ua-parser-js": "1.0.40",
|
||||
"ua-client-hints-js": "0.1.2",
|
||||
"ws": "8.18.3",
|
||||
"yauzl": "2.10.0",
|
||||
"node-windows": "0.1.14",
|
||||
"loadavg-windows": "1.1.1",
|
||||
"node-sspi": "0.2.10",
|
||||
"ldapauth-fork": "5.0.5",
|
||||
"ssh2": "1.17.0",
|
||||
"svg-captcha": "1.4.0",
|
||||
"image-size": "2.0.2",
|
||||
"acme-client": "4.2.5",
|
||||
"aedes": "0.51.3",
|
||||
"mysql2": "3.15.1",
|
||||
"@mysql/xdevapi": "8.0.33",
|
||||
"mongodb": "4.17.2",
|
||||
"@mongodb-js/saslprep": "1.3.1",
|
||||
"pg": "8.16.3",
|
||||
"mariadb": "3.4.5",
|
||||
"acebase": "1.29.5",
|
||||
"sqlite3": "5.1.7",
|
||||
"node-vault": "0.10.5",
|
||||
"https-proxy-agent": "7.0.6",
|
||||
"mongojs": "3.1.0",
|
||||
"nodemailer": "6.10.1",
|
||||
"@sendgrid/mail": "8.1.6",
|
||||
"jsdom": "22.1.0",
|
||||
"esprima": "4.0.1",
|
||||
"html-minifier-terser": "7.2.0",
|
||||
"@crowdsec/express-bouncer": "0.1.0",
|
||||
"prom-client": "15.1.3",
|
||||
"archiver-zip-encrypted": "2.0.0",
|
||||
"googleapis": "128.0.0",
|
||||
"webdav": "5.8.0",
|
||||
"minio": "8.0.6",
|
||||
"wildleek": "2.0.0",
|
||||
"yub": "0.11.1",
|
||||
"otplib": "12.0.1",
|
||||
"twilio": "4.23.0",
|
||||
"plivo": "4.75.1",
|
||||
"telnyx": "1.25.5",
|
||||
"telegram": "2.26.22",
|
||||
"input": "1.0.1",
|
||||
"discord.js": "14.6.0",
|
||||
"@xmpp/client": "0.13.6",
|
||||
"node-pushover": "1.0.0",
|
||||
"zulip": "0.1.0",
|
||||
"web-push": "3.6.7",
|
||||
"firebase-admin": "12.7.0",
|
||||
"modern-syslog": "1.2.0",
|
||||
"syslog": "0.1.1-1",
|
||||
"heapdump": "0.3.15"
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,47 @@
|
||||
{
|
||||
lib,
|
||||
fetchzip,
|
||||
fetchYarnDeps,
|
||||
yarn2nix-moretea,
|
||||
nodejs-slim_20,
|
||||
dos2unix,
|
||||
buildNpmPackage,
|
||||
fetchFromGitHub,
|
||||
nodejs_22,
|
||||
}:
|
||||
|
||||
yarn2nix-moretea.mkYarnPackage {
|
||||
version = "1.1.56";
|
||||
buildNpmPackage (finalAttrs: {
|
||||
pname = "meshcentral";
|
||||
version = "1.1.57";
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://registry.npmjs.org/meshcentral/-/meshcentral-1.1.56.tgz";
|
||||
sha256 = "1n6kzbgmsn083sdwgwnn6cwch1ay20n1218bgzyv604hyvzrm0i2";
|
||||
src = fetchFromGitHub {
|
||||
owner = "Ylianst";
|
||||
repo = "MeshCentral";
|
||||
tag = finalAttrs.version;
|
||||
hash = "sha256-tXv4AWFLBoaHraSTYbEuNjdxnB3tYyAYq5xPe4jRcmw=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-vWCd+7SnQCf6iBhQboqMKL7TQRPxvt4DOe9+XJ8XJ1Y=";
|
||||
# Using the npmDeps with a newer nodejs causes `npm ci` errors, also upstream
|
||||
# states they stick to the LTS version of nodejs:
|
||||
# https://meshcentral.com/docs/MeshCentral2InstallGuide.pdf
|
||||
nodejs = nodejs_22;
|
||||
|
||||
patches = [
|
||||
./fix-js-include-paths.patch
|
||||
# from some reason the way the package is installed causes the `require`
|
||||
# line in `$out/lib/node_modules/meshcentral/bin/meshcentral` to import the
|
||||
# main file as a module, and thus nothing happens when it runs. We remove
|
||||
# this conditional since we never use this as a module.
|
||||
./run.patch
|
||||
# Add `optionalDependencies` that are used during runtime, to
|
||||
# `package{,-lock}.json`. During a video meeting with upstream, they sort
|
||||
# of agreed to track these optionalDependencies from now on, but they are
|
||||
# still not sure about a few details regarding this. See:
|
||||
#
|
||||
# https://github.com/Ylianst/MeshCentral/pull/7672
|
||||
#
|
||||
# The above doesn't apply cleanly on 1.1.57, but hopefully it shouldn't be
|
||||
# too hard to regenerate it for the next version.
|
||||
./optionalDependencies.patch
|
||||
];
|
||||
|
||||
packageJSON = ./package.json;
|
||||
yarnLock = ./yarn.lock;
|
||||
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnLock = ./yarn.lock;
|
||||
hash = "sha256-M5TZhY995VFFbY3cjM3jiEceiVm54N6CKxQRVACOL9w=";
|
||||
};
|
||||
|
||||
# Tarball has CRLF line endings. This makes patching difficult, so let's convert them.
|
||||
nativeBuildInputs = [ dos2unix ];
|
||||
prePatch = ''
|
||||
find . -name '*.js' -exec dos2unix {} +
|
||||
ln -snf meshcentral.js bin/meshcentral
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
mkdir -p $out/bin
|
||||
chmod a+x $out/libexec/meshcentral/deps/meshcentral/meshcentral.js
|
||||
sed -i '1i#!${lib.getExe nodejs-slim_20}' $out/libexec/meshcentral/deps/meshcentral/meshcentral.js
|
||||
ln -s $out/libexec/meshcentral/deps/meshcentral/meshcentral.js $out/bin/meshcentral
|
||||
'';
|
||||
|
||||
doDist = false;
|
||||
|
||||
publishBinsFor = [ ];
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
dontNpmBuild = true;
|
||||
|
||||
meta = {
|
||||
description = "Computer management web app";
|
||||
@@ -54,4 +50,4 @@ yarn2nix-moretea.mkYarnPackage {
|
||||
license = lib.licenses.asl20;
|
||||
mainProgram = "meshcentral";
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git c/meshcentral.js w/meshcentral.js
|
||||
index ea784b4c..62dfd645 100644
|
||||
--- c/meshcentral.js
|
||||
+++ w/meshcentral.js
|
||||
@@ -4461,8 +4461,4 @@ function mainStart() {
|
||||
});
|
||||
}
|
||||
|
||||
-if (require.main === module) {
|
||||
- mainStart(); // Called directly, launch normally.
|
||||
-} else {
|
||||
- module.exports.mainStart = mainStart; // Required as a module, useful for winservice.js
|
||||
-}
|
||||
+mainStart(); // Called directly, launch normally.
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p nodejs yarn prefetch-yarn-deps jq rsync common-updater-scripts moreutils
|
||||
|
||||
set -exuo pipefail
|
||||
|
||||
expr_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
tmp=$(mktemp -dt update-meshcentral.XXXXXX)
|
||||
|
||||
npm show --json meshcentral > "$tmp/npm.json"
|
||||
version=$(<"$tmp/npm.json" jq -r .version)
|
||||
tarball=$(<"$tmp/npm.json" jq -r .dist.tarball)
|
||||
|
||||
prefetch=$(nix-prefetch-url --unpack --print-path "$tarball" | tr '\n' ' ')
|
||||
read -r hash storePath <<<"$prefetch"
|
||||
cd "$tmp"
|
||||
rsync -r --chmod=u=rwX "$storePath/" package/
|
||||
cd package
|
||||
|
||||
# Very crude way of discovering optional dependencies. These are
|
||||
# fetched at runtime by stock upstream, but we don't allow that kind
|
||||
# of thing in nix :)
|
||||
awk <meshcentral.js "
|
||||
BEGIN { RS=\"[\n;]\" }
|
||||
match(\$0, /(modules|passport) = (\[.*\])$/, a) { print a[2] }
|
||||
match(\$0, /(modules|passport).push\(('[^)]+')\)/, a) { print \"[\" a[2] \"]\" }
|
||||
" |
|
||||
tr \' \" |
|
||||
jq --slurp '[if type == "array" then .[] else . end] | flatten' |
|
||||
# And an equally crude way of adding them to package.json. We
|
||||
# can't use yarn add here, because that will blow up on
|
||||
# dependencies which don't support the current platform. Even with
|
||||
# --optional.
|
||||
jq --slurpfile package package.json \
|
||||
'(. | map(. | capture("(?<name>@?[^@]+)(@(?<version>.+))?") | { key: .name, value: (.version // "*")}) | from_entries) as $optionalDependencies | $package | .[] | .optionalDependencies |= . + $optionalDependencies' |
|
||||
sponge package.json
|
||||
|
||||
# Fetch all the optional dependencies, so we have them available in
|
||||
# yarn.lock/yarn.nix
|
||||
yarn install --ignore-scripts
|
||||
|
||||
cp package.json "$expr_dir"
|
||||
cp yarn.lock "$expr_dir/yarn.lock"
|
||||
|
||||
cd "$expr_dir/../../../.."
|
||||
update-source-version meshcentral "$version" "$hash" "$tarball"
|
||||
|
||||
new_yarn_hash=$(prefetch-yarn-deps "$expr_dir/yarn.lock")
|
||||
new_yarn_hash=$(nix-hash --type sha256 --to-sri "$new_yarn_hash")
|
||||
old_yarn_hash=$(nix-instantiate --eval -A meshcentral.offlineCache.outputHash | tr -d '"')
|
||||
sed -i "$expr_dir/default.nix" -e "s|\"$old_yarn_hash\"|\"$new_yarn_hash\"|"
|
||||
|
||||
# Only clean up if everything worked
|
||||
cd /
|
||||
rm -rf "$tmp"
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user