Skip to content

Commit 98a41cd

Browse files
authored
Merge pull request #404 from netcreateorg/dev-bl/deploy-test
Feature: Deploy & SSL
2 parents 99e4897 + b83ce6c commit 98a41cd

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

app/unisys/client-network.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ NETWORK.Connect = function (datalink, opt) {
8585

8686
// create websocket
8787
// uses values that were embedded in index.ejs on load
88-
let wsURI = `ws://${NETSOCK.uaddr}:${NETSOCK.uport}`;
88+
let wsURI;
89+
if (window.location.protocol === 'https:') {
90+
// use secure websocket if running on https, redirects port to /ws-port/
91+
// used with `netcreate-deploy-do` repo `nginx-ssl.conf.j2` on DigitalOcean droplets with SSL
92+
wsURI = `wss://${window.location.host}/ws-port/${NETSOCK.uport}/`;
93+
} else wsURI = `ws://${NETSOCK.uaddr}:${NETSOCK.uport}`;
8994
NETSOCK.ws = new WebSocket(wsURI);
9095

9196
// create listeners

brunch-config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,16 @@ module.exports = {
188188
},
189189
hooks: {
190190
preCompile() {
191-
// These files will eventually be copied over to public by brunch
192-
// save json of database to public/data
193-
UDB.WriteDbJSON(`${__dirname}/app-data/${NC_CONFIG.dataset}-db.json`);
194-
UDB.WriteDbJSON(`${__dirname}/app-data/standalone-db.json`);
191+
// As of 6/14/2025 the `WriteDbJSON` calls are commented out because
192+
// 1. I don't believe we do anything with db json files anymore
193+
// 2. If a loki file hasn't already been created, the WriteDbJSON call
194+
// will fail silently and the rest of the compile process is skipped
195+
// which means the `npm run package` will not work.
196+
//
197+
// // These files will eventually be copied over to public by brunch
198+
// // save json of database to public/data
199+
// UDB.WriteDbJSON(`${__dirname}/app-data/${NC_CONFIG.dataset}-db.json`);
200+
// UDB.WriteDbJSON(`${__dirname}/app-data/standalone-db.json`);
195201

196202
// // save json of template to public/data
197203
// UDB.WriteTemplateJSON(`${__dirname}/app-data/${NC_CONFIG.dataset}-template.json`);

init-netcreate-config.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Create a dummy netcreate-config.js file
2+
// for first time setup. It needs to do two things:
3+
// 1. Create app-config/netcreate-config.js file
4+
// 2. Copy the _default.template.toml file to runtime directory
5+
6+
const shell = require('shelljs');
7+
const fs = require('fs');
8+
const path = require('path');
9+
10+
const dataset = 'dummy';
11+
const port = '3000';
12+
13+
let script = `
14+
// this file generated by "init-netcreate-config.js"
15+
const NC_CONFIG = {
16+
dataset: "${dataset}",
17+
port: "${port}"
18+
};
19+
if (typeof process === "object") module.exports = NC_CONFIG;
20+
if (typeof window === "object") window.NC_CONFIG = NC_CONFIG;
21+
`;
22+
23+
const nccPath = 'app-config';
24+
if (!fs.existsSync(nccPath)) fs.mkdirSync(nccPath, { recursive: true });
25+
shell.ShellString(script).to(`${nccPath}/netcreate-config.js`);
26+
27+
// Copy template TOML file
28+
const templateSrc = 'app-templates/_default.template.toml';
29+
const destDir = path.join('runtime');
30+
const destFile = path.join(destDir, `${dataset}.template.toml`);
31+
if (!fs.existsSync(destDir)) shell.mkdir('-p', destDir);
32+
shell.cp(templateSrc, destFile);
33+
34+
console.log('init-netcreate-config.js');
35+
console.log('1. Created app-config/netcreate-config.js file');
36+
console.log(` with ${dataset} and ${port}`);
37+
console.log(`2. Created a ${dataset}.template.toml file`);
38+
console.log(' based on _default.template.toml');
39+
console.log('You can now run the server with "./nc.js" or nc-multiplex.');

0 commit comments

Comments
 (0)