Initial commit

This commit is contained in:
Dorian Niemiec 2023-12-03 15:28:21 +01:00
commit 35226ae514
5 changed files with 79 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
svrjs
svrjs-temp

4
README.txt Normal file
View file

@ -0,0 +1,4 @@
How to build SVR.JS?
1. Clone SVR.JS git repository using "git clone -b stable https://git.svrjs.org/git/svrjs.git". You can also copy git repository contents into "svrjs" directory.
2. Run "bash build.sh"
3. You now have SVR.JS zip archive! You can install it using SVR.JS installer for GNU/Linux.

53
build.sh Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
GLOBIGNORE=".:.."
if ! [ -d svrjs ]; then
echo '"svrjs" directory is missing. You can obtain SVR.JS source ("svrjs" directory) using "git clone -b <branch> https://git.svrjs.org/git/svrjs.git" (where "<branch>" is a branch you want to clone).'
exit 1
fi
rm svr.js.*.zip
pushd $(dirname $0)
cp -a svrjs svrjs-temp
rm -rf svrjs-temp/.git
find svrjs-temp -name '.gitignore' -exec rm -f {} \;
mkdir svrjs-temp/node_modules_uncompressed
mv svrjs-temp/node_modules/.bin svrjs-temp/node_modules_uncompressed
for module in $(cat uncompressed_modules); do
mv svrjs-temp/node_modules/$module svrjs-temp/node_modules_uncompressed
done
cd svrjs-temp/node_modules
tar -czf ../modules.compressed *
tar -uzf ../modules.compressed .* 2>/dev/null
cd ..
rm -rf node_modules
mv node_modules_uncompressed node_modules
SVRJSVERSION=$(cat svr.js | grep -E '^[ \t]*(var|const|let) *version *= *(["'"'"'])' | grep -E -o '"([^"\\]|\\.)+"|'"'"'([^'"'"'\\]|\\.)+'"'"'' | head -n 1 | sed -E 's/^.|.$//g' | sed -E 's/\\(.)/\1/g')
if [ "$SVRJSVERSION" == "" ]; then
SVRJSVERSION=Unknown
fi
SVRJSFILENAME="svr.js.$(echo $SVRJSVERSION| tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z]+/./g').zip"
gzip svr.js
mv svr.js.gz svr.compressed
cp ../unpacker.js svr.js
echo $SVRJSFILENAME
zip -r ../$SVRJSFILENAME *
zip -r ../$SVRJSFILENAME .* 2>/dev/null
echo "SVR.JS $SVRJSVERSION" > zip -z ../$SVRJSFILENAME
cd ..
rm -rf svrjs-temp
popd
echo "You have packed SVR.JS $SVRJSVERSION to \"$SVRJSFILENAME\" file."

7
uncompressed_modules Normal file
View file

@ -0,0 +1,7 @@
chownr
fs-minipass
minipass
minizlib
mkdirp
tar
yallist

13
unpacker.js Normal file
View file

@ -0,0 +1,13 @@
var zlib = require("zlib");
var fs = require("fs");
var tar = require("tar");
console.log("Decompressing modules...");
tar.x({file: './modules.compressed', C: './node_modules', sync: true});
console.log("Deleting SVR.JS stub...");
fs.unlinkSync("svr.js");
fs.unlinkSync("modules.compressed");
console.log("Decompressing SVR.JS...");
var script = zlib.gunzipSync(fs.readFileSync("svr.compressed"));
fs.unlinkSync("svr.compressed");
fs.writeFileSync("svr.js",script);
console.log("Restart SVR.JS to get server interface.");