From 6faaddb1d44cfb9101e59f44588df5a6dacb71e4 Mon Sep 17 00:00:00 2001 From: Marcin Polak Date: Wed, 16 Sep 2020 20:06:54 +0200 Subject: [PATCH] Added Open Suse Leap and Open Suse Tumbleweed, memory for globals and more --- config/globals.js | 5 +-- lib/osys.js | 3 ++ nexss-language/lib/language.js | 5 ++- nexss-start/lib/writeableStdout.js | 4 +-- tests/Dockerfiles/OpenSuse.Dockerfile | 7 ----- tests/Dockerfiles/OpenSuseLeap.Dockerfile | 12 +++++++ .../Dockerfiles/OpenSuseTumbleweed.Dockerfile | 7 +++++ tests/Dockerfiles/_linuxDist.js | 5 +-- tests/Nexssfiles/test1.nexss | 2 +- tests/languages.nexss-test.js | 4 +-- tests/nexssStorage.json | 1 + tests/pipe.nexss-test.js | 31 +++++++++++++++++++ 12 files changed, 68 insertions(+), 18 deletions(-) delete mode 100644 tests/Dockerfiles/OpenSuse.Dockerfile create mode 100644 tests/Dockerfiles/OpenSuseLeap.Dockerfile create mode 100644 tests/Dockerfiles/OpenSuseTumbleweed.Dockerfile create mode 100644 tests/nexssStorage.json create mode 100644 tests/pipe.nexss-test.js diff --git a/config/globals.js b/config/globals.js index 52d1488..59826e3 100644 --- a/config/globals.js +++ b/config/globals.js @@ -3,9 +3,10 @@ Object.assign(global, require("../lib/ansi")); const dev_colors = require("../lib/core/dev-colors"); const functions = { - fs: require("fs"), - path: require("path"), + fs: require("fs"), // https://nodejs.org/api/fs.html + path: require("path"), // https://nodejs.org/api/path.html dev_colors, + mem: process.memoryUsage, // https://nodejs.org/api/process.html#process_process_memoryusage }; Object.assign(global, functions); diff --git a/lib/osys.js b/lib/osys.js index fbb4988..03acc91 100644 --- a/lib/osys.js +++ b/lib/osys.js @@ -88,6 +88,9 @@ module.exports.getInstallCommandByDist = (update) => { case "CentOS Linux": case "RHEL Linux": return `${sudo}yum ${operation} -y`; + case "openSUSE Leap": + case "openSUSE Tumbleweed": + return `${sudo}zypper -n ${operation}`; default: return `${sudo}apt-get ${operation} -y`; } diff --git a/nexss-language/lib/language.js b/nexss-language/lib/language.js index 6dc3ff1..4ba64bd 100644 --- a/nexss-language/lib/language.js +++ b/nexss-language/lib/language.js @@ -117,7 +117,10 @@ module.exports.getLang = (ext, recreateCache) => { config.osPackageManagers[Object.keys(config.osPackageManagers)[0]]; if (langRepositories[ext]) { ensureInstalled(osPM.keyOfItem, osPM.installation); - ensureInstalled("git", `${osPM.install} git`); + ensureInstalled( + "git", + `${osPM.install ? osPM.install : osPM.installCommand} git` + ); const repoName = require("path").basename(langRepositories[ext]); const repoPath = `${NEXSS_LANGUAGES_PATH}/${repoName}`; diff --git a/nexss-start/lib/writeableStdout.js b/nexss-start/lib/writeableStdout.js index 6e9b2ac..99102e0 100644 --- a/nexss-start/lib/writeableStdout.js +++ b/nexss-start/lib/writeableStdout.js @@ -40,9 +40,9 @@ module.exports.writeableStdout = () => timeElapsed(chunk.nxsTime); } catch (error) { if (process.argv.indexOf("--nxsModule") >= 0) { - console.log(JSON.stringify({ nxsOut: chunk })); + process.stdout.write(JSON.stringify({ nxsOut: chunk })); } else { - console.log( + process.stdout.write( typeof chunk === "object" ? JSON.stringify(chunk) : chunk ); } diff --git a/tests/Dockerfiles/OpenSuse.Dockerfile b/tests/Dockerfiles/OpenSuse.Dockerfile deleted file mode 100644 index 87727a9..0000000 --- a/tests/Dockerfiles/OpenSuse.Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM opensuse/leap - -RUN curl -sL https://deb.nodesource.com/setup | bash - -RUN apt-get update -RUN apt-get install git nodejs -y --force-yes - -CMD ["/bin/bash"] \ No newline at end of file diff --git a/tests/Dockerfiles/OpenSuseLeap.Dockerfile b/tests/Dockerfiles/OpenSuseLeap.Dockerfile new file mode 100644 index 0000000..4421cce --- /dev/null +++ b/tests/Dockerfiles/OpenSuseLeap.Dockerfile @@ -0,0 +1,12 @@ +FROM opensuse/leap + +# RUN zypper -n ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_Leap_42.1/ Devel:Languages:NodeJS +# RUN zypper -n --gpg-auto-import-keys ref Devel:Languages:NodeJS + +# RUN zypper -n in patterns-openSUSE-devel_C_C++ gcc-c++ + +# RUN zypper -n in npm + +RUN zypper -n install curl tar gzip +# export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" +CMD ["/bin/bash"] \ No newline at end of file diff --git a/tests/Dockerfiles/OpenSuseTumbleweed.Dockerfile b/tests/Dockerfiles/OpenSuseTumbleweed.Dockerfile new file mode 100644 index 0000000..d5d21de --- /dev/null +++ b/tests/Dockerfiles/OpenSuseTumbleweed.Dockerfile @@ -0,0 +1,7 @@ +FROM opensuse/tumbleweed + +RUN zypper -n install curl tar gzip +RUN zypper -n in nodejs npm + +# export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" +CMD ["/bin/bash"] \ No newline at end of file diff --git a/tests/Dockerfiles/_linuxDist.js b/tests/Dockerfiles/_linuxDist.js index aa5ac4b..d674d78 100644 --- a/tests/Dockerfiles/_linuxDist.js +++ b/tests/Dockerfiles/_linuxDist.js @@ -90,9 +90,10 @@ function pathToDocker(p) { const pathNexssCli = pathToDocker(path.resolve(process.cwd(), "../../")); const pathDotNexss = pathToDocker(path.join(require("os").homedir(), ".nexss")); // const command = `docker run -d -t ${imageName} bash -c "npm i @nexssp/cli -g && nexss && nexss test all --onlyErrors && /bin/bash`; -// const command = `docker run -i -d -v ${pathNexssCli}:/nexssCli -v ${pathDotNexss}:/root/.nexss -v /root/.nexss/cache -e DEBIAN_FRONTEND=noninteractive -t ${imageName} /bin/bash -c "cd nexssCli && chmod +x nexss.js && ln -s $(pwd)/nexss.js /usr/bin/nexss && mkdir /work && cd /work && /bin/bash" `; +const command = `docker run -i -d -v ${pathNexssCli}:/nexssCli -v ${pathDotNexss}:/root/.nexss -v /root/.nexss/cache -e DEBIAN_FRONTEND=noninteractive -t ${imageName} /bin/bash -c "cd nexssCli && chmod +x nexss.js && ln -s $(pwd)/nexss.js /usr/bin/nexss && mkdir /work && cd /work && /bin/bash" `; // const command = `docker run -d -it ${imageName} bash -c "npm i @nexssp/cli -g && nexss && /bin/bash`; -const command = `docker run -d -t ${imageName} bin/sh -c "git clone --depth=1 https://github.com/nexssp/cli.git && cd cli && chmod +x nexss.js && ln -s $(pwd)/nexss.js /usr/bin/nexss && nexss && nexss test errors"`; +// const command = `docker run -d -t ${imageName} bin/sh -c "git clone --depth=1 https://github.com/nexssp/cli.git && cd cli && chmod +x nexss.js && ln -s $(pwd)/nexss.js /usr/bin/nexss && nexss && nexss test errors"`; +// const command = `docker run -d -it ${imageName} bin/sh`; try { var res = execSync( // You can build packages inside the container, for dev whatever is needed. diff --git a/tests/Nexssfiles/test1.nexss b/tests/Nexssfiles/test1.nexss index 94de6c9..36ada50 100644 --- a/tests/Nexssfiles/test1.nexss +++ b/tests/Nexssfiles/test1.nexss @@ -30,6 +30,6 @@ Output/Log "This parameter" // Benchmarking // --nxsTime // Output/End --_if=${myvariable} "End of the script.." "${up('THis is a text which will be written up')}" - +Output/End --_memory="${mem().rss/(1024*1024)}" "${red(`${_memory}`)} MB." // Debug // Debug --nxsDebug OR Debug OR Id --nxsDebug \ No newline at end of file diff --git a/tests/languages.nexss-test.js b/tests/languages.nexss-test.js index a744726..abc3792 100644 --- a/tests/languages.nexss-test.js +++ b/tests/languages.nexss-test.js @@ -29,9 +29,7 @@ module.exports = { ".swift", // is not implemented on windows yet // OTHER ISSUES // ".html", - ".pd", // To check - ".ps1", - // ".d", // dome compiler proble, default.d not found + ".pd", // This language might be removed.. ".exs", ".ex", ".erl", // Compiler needs to be installed during adding a file (compile of lib is needed) diff --git a/tests/nexssStorage.json b/tests/nexssStorage.json new file mode 100644 index 0000000..f888f52 --- /dev/null +++ b/tests/nexssStorage.json @@ -0,0 +1 @@ +{"myvariable":"this is loooong value which is a second parameter.."} \ No newline at end of file diff --git a/tests/pipe.nexss-test.js b/tests/pipe.nexss-test.js new file mode 100644 index 0000000..f4311e4 --- /dev/null +++ b/tests/pipe.nexss-test.js @@ -0,0 +1,31 @@ +let values = ["Nexss"]; + +module.exports = { + values, + startFrom: "", + endsWith: "", + omit: [], + tests: [ + { + title: "NEXSS_ pipes", + onError: "stop", // global value, + notEval: true, // Means that parameters will not be evaluated (like below it ${..} will be passed) + tests: [ + { + title: "Simply Pipe", + params: [ + "nexss Id --nxsAs=MY1 | nexss Id --nxsAs=MY2", + /"MY1":".*".*"MY2":".*"/, + ], + }, + { + title: "Long Pipe", + params: [ + "nexss Id --nxsAs=MY1 | nexss Id --nxsAs=MY2 | nexss Id --nxsAs=MY3 | nexss Id --nxsAs=MY4 | nexss Id --nxsAs=MY5 | nexss Id --nxsAs=MY6", + /"MY1":".*".*"MY2":".*".*"MY3":".*".*"MY4":".*".*"MY5":".*".*"MY6":".*"/, + ], + }, + ], + }, + ], +};