diff --git a/app/unisys/client-network.js b/app/unisys/client-network.js index 318820d98..79965bd75 100644 --- a/app/unisys/client-network.js +++ b/app/unisys/client-network.js @@ -85,7 +85,12 @@ NETWORK.Connect = function (datalink, opt) { // create websocket // uses values that were embedded in index.ejs on load - let wsURI = `ws://${NETSOCK.uaddr}:${NETSOCK.uport}`; + let wsURI; + if (window.location.protocol === 'https:') { + // use secure websocket if running on https, redirects port to /ws-port/ + // used with `netcreate-deploy-do` repo `nginx-ssl.conf.j2` on DigitalOcean droplets with SSL + wsURI = `wss://${window.location.host}/ws-port/${NETSOCK.uport}/`; + } else wsURI = `ws://${NETSOCK.uaddr}:${NETSOCK.uport}`; NETSOCK.ws = new WebSocket(wsURI); // create listeners diff --git a/brunch-config.js b/brunch-config.js index a41e7084e..d1cf1314a 100644 --- a/brunch-config.js +++ b/brunch-config.js @@ -188,10 +188,16 @@ module.exports = { }, hooks: { preCompile() { - // These files will eventually be copied over to public by brunch - // save json of database to public/data - UDB.WriteDbJSON(`${__dirname}/app-data/${NC_CONFIG.dataset}-db.json`); - UDB.WriteDbJSON(`${__dirname}/app-data/standalone-db.json`); + // As of 6/14/2025 the `WriteDbJSON` calls are commented out because + // 1. I don't believe we do anything with db json files anymore + // 2. If a loki file hasn't already been created, the WriteDbJSON call + // will fail silently and the rest of the compile process is skipped + // which means the `npm run package` will not work. + // + // // These files will eventually be copied over to public by brunch + // // save json of database to public/data + // UDB.WriteDbJSON(`${__dirname}/app-data/${NC_CONFIG.dataset}-db.json`); + // UDB.WriteDbJSON(`${__dirname}/app-data/standalone-db.json`); // // save json of template to public/data // UDB.WriteTemplateJSON(`${__dirname}/app-data/${NC_CONFIG.dataset}-template.json`); diff --git a/init-netcreate-config.js b/init-netcreate-config.js new file mode 100644 index 000000000..37a3f3474 --- /dev/null +++ b/init-netcreate-config.js @@ -0,0 +1,39 @@ +// Create a dummy netcreate-config.js file +// for first time setup. It needs to do two things: +// 1. Create app-config/netcreate-config.js file +// 2. Copy the _default.template.toml file to runtime directory + +const shell = require('shelljs'); +const fs = require('fs'); +const path = require('path'); + +const dataset = 'dummy'; +const port = '3000'; + +let script = ` +// this file generated by "init-netcreate-config.js" +const NC_CONFIG = { + dataset: "${dataset}", + port: "${port}" +}; +if (typeof process === "object") module.exports = NC_CONFIG; +if (typeof window === "object") window.NC_CONFIG = NC_CONFIG; +`; + +const nccPath = 'app-config'; +if (!fs.existsSync(nccPath)) fs.mkdirSync(nccPath, { recursive: true }); +shell.ShellString(script).to(`${nccPath}/netcreate-config.js`); + +// Copy template TOML file +const templateSrc = 'app-templates/_default.template.toml'; +const destDir = path.join('runtime'); +const destFile = path.join(destDir, `${dataset}.template.toml`); +if (!fs.existsSync(destDir)) shell.mkdir('-p', destDir); +shell.cp(templateSrc, destFile); + +console.log('init-netcreate-config.js'); +console.log('1. Created app-config/netcreate-config.js file'); +console.log(` with ${dataset} and ${port}`); +console.log(`2. Created a ${dataset}.template.toml file`); +console.log(' based on _default.template.toml'); +console.log('You can now run the server with "./nc.js" or nc-multiplex.');