From 519e68465a9284267f550737ea39ecc7f3bba991 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sat, 24 Aug 2024 17:13:59 +0200 Subject: [PATCH] Add SVR.JS name and documentation URL to svrjs.json file. --- esbuild.config.js | 18 ++++++++++++------ src/index.js | 2 +- src/middleware/core.js | 1 - src/utils/generateServerString.js | 7 ++++--- svrjs.json | 4 +++- templates/index.ejs | 6 +++--- templates/licenseElement.ejs | 4 ++-- templates/licenses.ejs | 6 +++--- templates/tests.ejs | 2 +- 9 files changed, 29 insertions(+), 21 deletions(-) diff --git a/esbuild.config.js b/esbuild.config.js index 1b82481..c41252c 100644 --- a/esbuild.config.js +++ b/esbuild.config.js @@ -6,7 +6,8 @@ const archiver = require("archiver"); const dependencies = JSON.parse(fs.readFileSync(__dirname + "/package.json")).dependencies || {}; const requiredDependencyList = Object.keys(dependencies); let dependencyList = Object.keys(dependencies); -const version = JSON.parse(fs.readFileSync(__dirname + "/svrjs.json")).version; +const svrjsInfo = JSON.parse(fs.readFileSync(__dirname + "/svrjs.json")); +const {name, version, documentationURL} = svrjsInfo; // Function to find and add all dependencies into the dependencyList array. function findAllDependencies(curList) { @@ -53,7 +54,8 @@ let licenseElements = ""; dependencyList.forEach((dependency) => { const packageJSON = JSON.parse(fs.readFileSync(__dirname + "/node_modules/" + dependency.replace(/\/\.\./g,"") + "/package.json").toString()); licenseElements += licenseElementTemplate({ - name: packageJSON.name, + moduleName: packageJSON.name, + name: name, license: packageJSON.license, description: packageJSON.description || "No description", author: packageJSON.author ? packageJSON.author.name : packageJSON.author, @@ -63,24 +65,28 @@ dependencyList.forEach((dependency) => { // Generate pages const licensesPage = layoutTemplate({ - title: "SVR.JS " + version + " Licenses", + title: name + " " + version + " Licenses", content: licensesTemplate({ + name: name, version: version, licenses: licenseElements }) }); const testsPage = layoutTemplate({ - title: "SVR.JS " + version + " Tests", + title: name + " " + version + " Tests", content: testsTemplate({ + name: name, version: version }) }); const indexPage = layoutTemplate({ - title: "SVR.JS " + version, + title: name + " " + version, content: indexTemplate({ - version: version + name: name, + version: version, + documentationURL: documentationURL }) }); diff --git a/src/index.js b/src/index.js index 08404b7..d66d091 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,7 @@ const fs = require("fs"); //const getOS = require("./utils/getOS.js"); const generateServerString = require("./utils/generateServerString.js") const svrjsInfo = require("../svrjs.json"); -const version = svrjsInfo.version; +const {version} = svrjsInfo; //const parseURL = require("./utils/urlParser.js"); //const fixNodeMojibakeURL = require("./utils/urlMojibakeFixer.js"); diff --git a/src/middleware/core.js b/src/middleware/core.js index dd22894..9957929 100644 --- a/src/middleware/core.js +++ b/src/middleware/core.js @@ -5,7 +5,6 @@ const generateErrorStack = require("../utils/generateErrorStack.js"); const generateServerString = require("../utils/generateServerString.js"); const serverHTTPErrorDescs = require("../res/httpErrorDescriptions.js"); const fixNodeMojibakeURL = require("../utils/urlMojibakeFixer.js"); -//const getOS = require("../utils/getOS.js"); const ipMatch = require("../utils/ipMatch.js"); const svrjsInfo = require("../../svrjs.json"); const version = svrjsInfo.version; diff --git a/src/utils/generateServerString.js b/src/utils/generateServerString.js index 5087791..7e0e7bb 100644 --- a/src/utils/generateServerString.js +++ b/src/utils/generateServerString.js @@ -1,10 +1,11 @@ const svrjsInfo = require("../../svrjs.json"); -const version = svrjsInfo.version; +const {version, name} = svrjsInfo; const getOS = require("./getOS.js"); function generateServerString(exposeServerVersion) { return exposeServerVersion - ? "SVR.JS/" + + ? name + + "/" + version + " (" + getOS() + @@ -13,7 +14,7 @@ function generateServerString(exposeServerVersion) { ? "Bun/v" + process.versions.bun + "; like Node.JS/" + process.version : "Node.JS/" + process.version) + ")" - : "SVR.JS"; + : name; } module.exports = generateServerString; \ No newline at end of file diff --git a/svrjs.json b/svrjs.json index 199a5a5..25dd11d 100644 --- a/svrjs.json +++ b/svrjs.json @@ -1,3 +1,5 @@ { - "version": "Nightly-GitNext" + "version": "Nightly-GitNext", + "name": "SVR.JS", + "documentationURL": "https://svrjs.org/docs" } diff --git a/templates/index.ejs b/templates/index.ejs index fcf531a..cc0d977 100644 --- a/templates/index.ejs +++ b/templates/index.ejs @@ -1,4 +1,4 @@ -

Welcome to SVR.JS <%= version %>

+

Welcome to <%= name %> <%= version %>

<% if (version.indexOf("Nightly-") == 0) { %>
WARNING!
@@ -82,8 +82,8 @@

Tests
Licenses
- SVR.JS status page
- SVR.JS documentation + <%= name %> status page
+ <%= name %> documentation

diff --git a/templates/licenseElement.ejs b/templates/licenseElement.ejs index 986fbfb..0c285aa 100644 --- a/templates/licenseElement.ejs +++ b/templates/licenseElement.ejs @@ -1,10 +1,10 @@
License: <%= license %>
- <%= name %><% if (author) { %> (by <%= author %>)<% } %> + <%= moduleName %><% if (author) { %> (by <%= author %>)<% } %>
<%= description %><% if (required) { %>
- Required by SVR.JS.<% } %> + Required by <%= name %>.<% } %>
diff --git a/templates/licenses.ejs b/templates/licenses.ejs index a6c2cd9..d82befb 100644 --- a/templates/licenses.ejs +++ b/templates/licenses.ejs @@ -1,5 +1,5 @@ -

SVR.JS <%= version %> Licenses

-

SVR.JS <%= version %>

+

<%= name %> <%= version %> Licenses

+

<%= name %> <%= version %>

MIT License

@@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-

Packages used by SVR.JS <%= version %>

+

Packages used by <%= name %> <%= version %>

<%- licenses %>
diff --git a/templates/tests.ejs b/templates/tests.ejs index 6570e82..304c825 100644 --- a/templates/tests.ejs +++ b/templates/tests.ejs @@ -1,4 +1,4 @@ -

SVR.JS <%= version %> Tests

+

<%= name %> <%= version %> Tests

Directory (without trailing slash)

Directory (with query)