From 2b37a64327ed493dd31215e51774b889e16407d0 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Sat, 19 Dec 2020 21:56:21 -0500 Subject: [PATCH 1/4] Replace build bash scripts with node.js scripts. --- build_scripts/cleanDist.js | 6 +++++ build_scripts/copyStatic.js | 12 ++++++++++ build_scripts/createVersion.js | 31 +++++++++++++++++++++++++ createVersion.sh | 20 ---------------- package-lock.json | 42 +++++++++++++++++++++++++++++++--- package.json | 13 ++++++----- 6 files changed, 95 insertions(+), 29 deletions(-) create mode 100644 build_scripts/cleanDist.js create mode 100644 build_scripts/copyStatic.js create mode 100644 build_scripts/createVersion.js delete mode 100755 createVersion.sh diff --git a/build_scripts/cleanDist.js b/build_scripts/cleanDist.js new file mode 100644 index 00000000..53833db8 --- /dev/null +++ b/build_scripts/cleanDist.js @@ -0,0 +1,6 @@ +const fs = require('fs').promises; + +const directory = './dist'; + +fs.rmdir(directory, { recursive: true }) + .then(() => console.log('Dist folder cleared!')); \ No newline at end of file diff --git a/build_scripts/copyStatic.js b/build_scripts/copyStatic.js new file mode 100644 index 00000000..0709baf5 --- /dev/null +++ b/build_scripts/copyStatic.js @@ -0,0 +1,12 @@ +const fse = require('fs-extra'); + +const srcDir = `./src/static`; +const destDir = `./dist`; + +fse.copySync(srcDir, destDir, { overwrite: true }, function (err) { + if (err) { + console.error(err); + } else { + console.log("Successfully copied src/static to dist!"); + } +}); \ No newline at end of file diff --git a/build_scripts/createVersion.js b/build_scripts/createVersion.js new file mode 100644 index 00000000..9ea6e4af --- /dev/null +++ b/build_scripts/createVersion.js @@ -0,0 +1,31 @@ +const fse = require('fs-extra'); + +var gitVer = require('child_process').execSync('git rev-parse --short HEAD').toString(); +var gitVerFull = require('child_process').execSync('git rev-parse HEAD').toString(); +var packageVersion = process.env.npm_package_version; +const filePath = './dist/VERSION.json'; + +console.log('Found package version', packageVersion); +console.log('Found Git commit short hash', gitVer); +console.log('Found Git commit long hash', gitVerFull); + +function yyyymmdd() { + var x = new Date(); + var y = x.getFullYear().toString(); + var m = (x.getMonth() + 1).toString(); + var d = x.getDate().toString(); + (d.length == 1) && (d = '0' + d); + (m.length == 1) && (m = '0' + m); + var yyyymmdd = y + m + d; + return yyyymmdd; +} + +var jsonToWrite = { + "npm-package-version": packageVersion, + "git-commit": gitVerFull, + "version-tag": packageVersion + "-" + yyyymmdd() + "-" + gitVer +} + +jsonToWrite = JSON.stringify(jsonToWrite); + +var attemptFileWrite = fse.outputFileSync(filePath, jsonToWrite); diff --git a/createVersion.sh b/createVersion.sh deleted file mode 100755 index ab899e40..00000000 --- a/createVersion.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/bash -# Create a version number in a file in the distribution directory. -# The output is a JSON file with various version things in it. - -VERSIONFILE="dist/VERSION.json" -mkdir -p $(dirname ${VERSIONFILE}) - -PACKAGEVER="$npm_package_version" -DATE=$(date "+%Y%m%d") -GITVER=$(git rev-parse --short HEAD) -GITVERFULL=$(git rev-parse HEAD) - - -# Note: be sure to add the end of line commas to all but the last JSON entry - -echo "{ " > "${VERSIONFILE}" -echo " \"npm-package-version\": \"${PACKAGEVER}\"," >> "${VERSIONFILE}" -echo " \"git-commit\": \"${GITVERFULL}\"," >> "${VERSIONFILE}" -echo " \"version-tag\": \"${PACKAGEVER}-${DATE}-${GITVER}\"" >> "${VERSIONFILE}" -echo "} " >> "${VERSIONFILE}" diff --git a/package-lock.json b/package-lock.json index 5b9a2522..8cf00c41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "iamus-metaverse-server", - "version": "2.3.5", + "version": "2.3.6", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -235,6 +235,11 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==" }, + "at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -688,6 +693,17 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, + "fs-extra": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz", + "integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==", + "requires": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^1.0.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -715,8 +731,7 @@ "graceful-fs": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" }, "has": { "version": "1.0.3", @@ -857,6 +872,22 @@ "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", "dev": true }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + }, + "dependencies": { + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + } + } + }, "kuler": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", @@ -1535,6 +1566,11 @@ "resolved": "https://registry.npmjs.org/unique-names-generator/-/unique-names-generator-4.3.1.tgz", "integrity": "sha512-oxkKrDXbwx6I5M963SdfmMH2t8n1OIfYyzoJ25BmDeETlyWAZjTbMXwIEMiQDex4lkD2pqe+9gxDJQAB2IOfDg==" }, + "universalify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", + "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==" + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index 9f3b8dcf..1fb9fc53 100755 --- a/package.json +++ b/package.json @@ -6,12 +6,12 @@ "author": "Robert Adams ", "repository": { "type": "git", - "url": "https://github.com/Misterblue/Iamus" + "url": "https://github.com/vircadia/Iamus" }, "bugs": { - "url": "https://github.com/Misterblue/Iamus/issues" + "url": "https://github.com/vircadia/Iamus/issues" }, - "homepage": "https://github.com/Misterblue/Iamus", + "homepage": "https://github.com/vircadia/Iamus", "keywords": [ "Vircadia", "ActivityPub", @@ -33,9 +33,9 @@ "build:iamus": "tsc", "prestart": "npm run build", "start": "node dist/index.js", - "clean-dist": "rm -rf dist/*", - "create-version": "./createVersion.sh", - "copy-static": "cp -r src/static dist", + "clean-dist": "node build_scripts/cleanDist.js", + "create-version": "node build_scripts/createVersion.js", + "copy-static": "node build_scripts/copyStatic.js", "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { @@ -43,6 +43,7 @@ "debug": "~2.6.9", "deepmerge": "^4.2.2", "express": "~4.16.1", + "fs-extra": "^9.0.1", "glob": "^7.1.6", "http-errors": "~1.6.3", "loglevel": "^1.7.1", From ca0b1aea75b1c7f6f88997b5060201dbe6c035f8 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Sat, 19 Dec 2020 21:58:32 -0500 Subject: [PATCH 2/4] Add EOF lines. --- build_scripts/cleanDist.js | 3 ++- build_scripts/copyStatic.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build_scripts/cleanDist.js b/build_scripts/cleanDist.js index 53833db8..7a514060 100644 --- a/build_scripts/cleanDist.js +++ b/build_scripts/cleanDist.js @@ -3,4 +3,5 @@ const fs = require('fs').promises; const directory = './dist'; fs.rmdir(directory, { recursive: true }) - .then(() => console.log('Dist folder cleared!')); \ No newline at end of file + .then(() => console.log('Dist folder cleared!')); + \ No newline at end of file diff --git a/build_scripts/copyStatic.js b/build_scripts/copyStatic.js index 0709baf5..bad490e5 100644 --- a/build_scripts/copyStatic.js +++ b/build_scripts/copyStatic.js @@ -9,4 +9,4 @@ fse.copySync(srcDir, destDir, { overwrite: true }, function (err) { } else { console.log("Successfully copied src/static to dist!"); } -}); \ No newline at end of file +}); From 68a9e586d1eb4527fe96724083054c8ef05c8d9b Mon Sep 17 00:00:00 2001 From: Kalila L Date: Sun, 20 Dec 2020 23:38:08 -0500 Subject: [PATCH 3/4] Initially modify the redirect URL for user profiles. --- src/routes/users/username.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/users/username.ts b/src/routes/users/username.ts index 40addaf1..2de3efc7 100755 --- a/src/routes/users/username.ts +++ b/src/routes/users/username.ts @@ -27,7 +27,7 @@ const procGetUserProfile: RequestHandler = async (req: Request, resp: Response, const dashboardURL = Config.metaverse["dashboard-url"]; const metaverseURL = encodeURIComponent(Config.metaverse["metaverse-server-url"]); const username = encodeURIComponent(req.vUsername); - const redirectionURL = `${dashboardURL}?metaverse=${metaverseURL}&page=user/profile&user=${username}`; + const redirectionURL = `${dashboardURL}?metaverse=${metaverseURL}&page=profile/${username}`; resp.statusCode = HTTPStatusCode.Found; resp.setHeader('Location', redirectionURL), resp.setHeader('content-type', 'text/html'); From 56dcb52b6ce8efd3b06ec9c4b4c732bcc9086729 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Mon, 21 Dec 2020 00:13:09 -0500 Subject: [PATCH 4/4] Work in progress updating of documentation. --- docs/Building.md | 61 ++++++++++++++++++++++++++++++++++++++++------- docs/Design.md | 8 +++---- docs/TestSetup.md | 2 +- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/docs/Building.md b/docs/Building.md index de0390dc..9c2cac5a 100755 --- a/docs/Building.md +++ b/docs/Building.md @@ -6,6 +6,13 @@ and running the server. For development or other running configurations, refer to [Notes On Development] and [Running Docker Image]. +## Prerequisites + +You will need the following installed on your system/server: + +* Git +* NodeJS + ## Build Instructions The application is a [NodeJS]/[ExpressJS]/[TypeScript] application so the @@ -18,7 +25,7 @@ npm run build ## Running -For testing and simple opertion, you can run Iamus in the build directory. +For testing and simple operation, you can run Iamus in the build directory. Say you want to build and run Iamus in the directory IBASE. The steps are: ```sh @@ -40,7 +47,7 @@ Refer to [Running Docker Image] for instructions. For connecting domain-servers to the Iamus metaverse-server, you must point any domain-servers (Vircadia) at this -metaverse server. This is accomplished by setting the `HIFI_METAVERSE_URL`: +metaverse server. This is accomplished by setting the `HIFI_METAVERSE_URL` environment variable: ```sh export HIFI_METAVERSE_URL=http://HOSTADDRESS:9400 @@ -71,7 +78,7 @@ current package and build version. The format of the file is: } ``` -`version-tag` combines the NPM package version, the date of build, and +`version-tag` combines the NPM package version, the date of the build, and the GIT commit version and is used to tag the Docker image. The version information is also read and added to the configuration @@ -81,7 +88,7 @@ data structure (for use by the application) and added to the ## Configuration The server parameters are all specified in `config.ts`. These default -values are overlayed with environment variables and then overlayed with +values are overlaid with environment variables and then overlaid with the contents of a configuration file. The environment variables are: @@ -89,7 +96,7 @@ The environment variables are: - IAMUS_LOGLEVEL: logging level. One of 'error', 'info', 'warn', 'debug'. Default 'info'. - IAMUS_LISTEN_HOST: host to listen for requests on. Default '0.0.0.0'. - IAMUS_LISTEN_PORT: port to listen for requests on. Default 9400. -- IAMUS_EXTERNAL_HOSTNAME: hostname to report as referencing back to this server. This is mostly used by ActivityPub for links to users. Default 'localhost'. This value MUST be set for proper metavserse-server operation. +- IAMUS_EXTERNAL_HOSTNAME: hostname to report as referencing back to this server. This is mostly used by ActivityPub for links to users. Default 'localhost'. This value MUST be set for proper metaverse-server operation. - IAMUS_CONFIG_FILE: filename or URL of a JSON formatted configuration file that over-rides the values. Default "./iamus.json". The configuration file, if it exists, is read and its values overlay @@ -139,6 +146,8 @@ All the configuration parameter default values are defined in `src/config.ts`. ## Setup MongoDB +### Install on Linux + Install MongoDb following the instructions at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ : ```sh @@ -165,8 +174,8 @@ use admin db.createUser({user:"cadiauser", pwd: "LONGPASSWORD3", roles: [{ role: "readWrite", db: "domainstore" }]}) ``` -Where, if course, "LONGPASSWORD*" is a collection of random letter and numbers. -This creates account "adminer" for DB administration, "backuper" for doing backups +Where, of course, "LONGPASSWORD*" is a collection of random letter and numbers to use as a password. +This creates an account "adminer" for DB administration, "backuper" for doing backups and "cadiauser" to be the database user for the domain-server. The database is "domainstore". @@ -179,6 +188,42 @@ security: then do `sudo systemctl restart mongod`. +### Install on Windows + +Install MongoDb following the instructions at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/ : + +```sh +"C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe" +db.disableFreeMonitoring() +``` + +Turn on authentication and create some users for our instance: + +```sh +"C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe" +use admin +db.createUser({user:"adminer", pwd: "LONGPASSWORD1", roles: [ "root" ]}) +use admin +db.createUser({user:"backuper", pwd: "LONGPASSWORD2", roles: [ "backup" ]}) +use admin +db.createUser({user:"cadiauser", pwd: "LONGPASSWORD3", roles: [{ role: "readWrite", db: "domainstore" }]}) +``` + +Where, of course, "LONGPASSWORD*" is a collection of random letter and numbers to use as a password. +This creates an account "adminer" for DB administration, "backuper" for doing backups +and "cadiauser" to be the database user for the domain-server. +The database is "domainstore". + +After doing the above creation steps, edit `\bin\mongod.cfg` and add: + +``` +security: + authorization: enabled +``` + +In Windows PowerShell, restart the service by running +`Restart-Service MongoDB -force`. + ## Logging My default, Iamus logs to a file named `iamus.log` in the directory `./logs`. @@ -194,7 +239,7 @@ These parameters can be changed with the config file. | debug.log-max-size-megabytes | 100 | the maximum size of the individual log files | | debug.log-max-files | 10 | number of old log files to keep | | debug.log-compress | false | if to compress old versions of the log files | -| debug.log-to-console | false | whether to additionlly log to the console | +| debug.log-to-console | false | whether to additionally log to the console | When running with Docker, one often changes the logging directory to point into a mounted volume for easy reference. diff --git a/docs/Design.md b/docs/Design.md index 1904d4f0..719ec825 100755 --- a/docs/Design.md +++ b/docs/Design.md @@ -72,11 +72,11 @@ the database. This two step process is done with: This sample takes the authorization of the requestor, the account being changed, the external name of the field being set, and the value being set. The extra parameters passing the AccountEntity that goes with the authorization token (this is -optional but saves a database lookup if supplied) and a VKeyedCollection that has the +optional but saves a database lookup if supplied) and a VKeyedCollection that has the database information that needs to be updated for this set operation. -Ths update information is then passed +This update information is then passed . -This system of field getting and setting is implmented with field definitions +This system of field getting and setting is implemented with field definitions that are attached to the entity definition. Each field in an Entity has a `FieldDefn` definition that gives its internal and external name and the routines to use to validate and update the field. @@ -108,7 +108,7 @@ The functions `getter` and `setter` are the operations that get and set the fiel Of course, the setter presumes the set value has passed the validation. These function definitions accept and return type "any" so the callers need to know what they want/expect. -## Other Implimentation Nodes +## Other Implementation Nodes BEWARE! All "entity" classes are really just Objects that are read out of the database. Even though they are defined as classes, when read from the diff --git a/docs/TestSetup.md b/docs/TestSetup.md index 69cf245a..6ea6f57b 100755 --- a/docs/TestSetup.md +++ b/docs/TestSetup.md @@ -1,4 +1,4 @@ -# Iamus Test Setup +# Iamus Test Setup (outdated) **TL:DR version**: a test metaverse using the latest Iamus and Vircadia