Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/unisys/client-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions brunch-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
39 changes: 39 additions & 0 deletions init-netcreate-config.js
Original file line number Diff line number Diff line change
@@ -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.');