@andersbakken/fisk 4.0.31 → 4.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -500,19 +500,13 @@ function realValue(v) {
500
500
  return v;
501
501
  }
502
502
  class Engine {
503
- argv;
504
- prefix;
505
- additionalFiles;
506
- applicationPath;
507
- debug;
508
- options;
509
- configDirs;
510
503
  constructor(options, argv) {
504
+ var _a;
511
505
  this.argv = Object.assign({}, argv);
512
506
  this.prefix = options.prefix;
513
507
  this.additionalFiles = options.additionalFiles || [];
514
508
  this.applicationPath = options.noApplicationPath ? "" : appRootPath.toString();
515
- this.debug = options.debug ?? false;
509
+ this.debug = (_a = options.debug) !== null && _a !== void 0 ? _a : false;
516
510
  this.options = {};
517
511
  this.configDirs = this.argv["config-dir"] || options.configDirs || xdgBasedir.configDirs;
518
512
  this._read();
@@ -682,7 +676,8 @@ function options (optionsOptions, argv) {
682
676
  return defaultValue;
683
677
  }
684
678
  function string(name, defaultValue) {
685
- return engine.string(name) ?? defaultValue;
679
+ var _a;
680
+ return (_a = engine.string(name)) !== null && _a !== void 0 ? _a : defaultValue;
686
681
  }
687
682
  return Object.assign(value, {
688
683
  prefix: optionsOptions.prefix,
@@ -5303,19 +5303,13 @@ function realValue(v) {
5303
5303
  return v;
5304
5304
  }
5305
5305
  class Engine {
5306
- argv;
5307
- prefix;
5308
- additionalFiles;
5309
- applicationPath;
5310
- debug;
5311
- options;
5312
- configDirs;
5313
5306
  constructor(options, argv) {
5307
+ var _a;
5314
5308
  this.argv = Object.assign({}, argv);
5315
5309
  this.prefix = options.prefix;
5316
5310
  this.additionalFiles = options.additionalFiles || [];
5317
5311
  this.applicationPath = options.noApplicationPath ? "" : appRootPath.toString();
5318
- this.debug = options.debug ?? false;
5312
+ this.debug = (_a = options.debug) !== null && _a !== void 0 ? _a : false;
5319
5313
  this.options = {};
5320
5314
  this.configDirs = this.argv["config-dir"] || options.configDirs || xdgBasedir.configDirs;
5321
5315
  this._read();
@@ -5485,7 +5479,8 @@ function options (optionsOptions, argv) {
5485
5479
  return defaultValue;
5486
5480
  }
5487
5481
  function string(name, defaultValue) {
5488
- return engine.string(name) ?? defaultValue;
5482
+ var _a;
5483
+ return (_a = engine.string(name)) !== null && _a !== void 0 ? _a : defaultValue;
5489
5484
  }
5490
5485
  return Object.assign(value, {
5491
5486
  prefix: optionsOptions.prefix,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andersbakken/fisk",
3
- "version": "4.0.31",
3
+ "version": "4.0.33",
4
4
  "description": "Fisk, a distributed compile system",
5
5
  "scripts": {
6
6
  "lint": "eslint . --ext .ts",
@@ -30,7 +30,7 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@andersbakken/blessed": "^0.1.82",
33
- "@jhanssen/options": "^4.0.0",
33
+ "@jhanssen/options": "^5.0.0",
34
34
  "axios": "^0.21.1",
35
35
  "bufferutil": "^4.0.7",
36
36
  "bytes": "^3.0.0",
@@ -58,7 +58,7 @@
58
58
  "@types/fs-extra": "^9.0.13",
59
59
  "@types/humanize-duration": "^3.27.1",
60
60
  "@types/minimist": "^1.2.2",
61
- "@types/node": "^14.14.25",
61
+ "@types/node": "^14.18.63",
62
62
  "@types/posix": "^4.2.0",
63
63
  "@types/url-parse": "^1.4.8",
64
64
  "@types/ws": "^8.5.3",
@@ -52141,7 +52141,7 @@ class Server extends require$$0__default$2["default"] {
52141
52141
  return this.app;
52142
52142
  }
52143
52143
  listen() {
52144
- return new Promise((resolve) => {
52144
+ return new Promise((resolve, reject) => {
52145
52145
  this.app = express();
52146
52146
  this.app.use(bodyParser.urlencoded({ extended: true }));
52147
52147
  this.emit("listen", this.app);
@@ -52152,8 +52152,20 @@ class Server extends require$$0__default$2["default"] {
52152
52152
  });
52153
52153
  }
52154
52154
  this.server = require$$2__default["default"].createServer(this.app);
52155
- this.ws = new ws.Server({ noServer: true });
52156
- const port = this.option.int("port", 8097);
52155
+ const keyFile = this.option.string("key");
52156
+ const certFile = this.option.string("cert");
52157
+ let key;
52158
+ let cert;
52159
+ if (keyFile && certFile) {
52160
+ try {
52161
+ key = fs__default["default"].readFileSync(keyFile);
52162
+ cert = fs__default["default"].readFileSync(certFile);
52163
+ }
52164
+ catch (err) {
52165
+ reject(new Error(`Failed to read key (${keyFile}) or cert (${certFile}): ${err.message}`));
52166
+ return;
52167
+ }
52168
+ }
52157
52169
  let defaultBacklog = 128;
52158
52170
  try {
52159
52171
  defaultBacklog = parseInt(fs__default["default"].readFileSync("/proc/sys/net/core/somaxconn", "utf8")) || 128;
@@ -52162,6 +52174,9 @@ class Server extends require$$0__default$2["default"] {
52162
52174
  /* */
52163
52175
  }
52164
52176
  const backlog = this.option.int("backlog", defaultBacklog);
52177
+ this.ws = new ws.Server({ noServer: true });
52178
+ let waitingServers = 1;
52179
+ const port = this.option.int("port", 8097);
52165
52180
  this.server.listen({ port, backlog, host: "0.0.0.0" });
52166
52181
  this.server.on("upgrade", (req, socket, head) => {
52167
52182
  assert__default["default"](this.ws);
@@ -52169,15 +52184,6 @@ class Server extends require$$0__default$2["default"] {
52169
52184
  this._handleConnection(ws, req);
52170
52185
  });
52171
52186
  });
52172
- this.ws.on("headers", (headers, request) => {
52173
- const url = new urlParse(request.url, this.baseUrl);
52174
- headers.push("x-fisk-object-cache: " + (this.objectCache ? "true" : "false"));
52175
- if (url.pathname === "/monitor") {
52176
- const nonce = crypto__default["default"].randomBytes(256).toString("base64");
52177
- headers.push(`x-fisk-nonce: ${nonce}`);
52178
- this.nonces.set(request, nonce);
52179
- }
52180
- });
52181
52187
  this.server.on("error", (error) => {
52182
52188
  if (error.code === "EADDRINUSE") {
52183
52189
  console.log(`Port ${port} is in use...`);
@@ -52192,8 +52198,51 @@ class Server extends require$$0__default$2["default"] {
52192
52198
  }
52193
52199
  });
52194
52200
  this.server.once("listening", () => {
52195
- console.log("listening on", port);
52196
- resolve();
52201
+ console.log("http://listening on", port);
52202
+ if (!--waitingServers) {
52203
+ resolve();
52204
+ }
52205
+ });
52206
+ let securePort;
52207
+ if (key && cert) {
52208
+ securePort = this.option.int("securePort", 8098);
52209
+ this.secureServer = require$$1__default$1["default"].createServer({ key, cert }, this.app);
52210
+ this.secureServer.listen({ port: securePort, backlog, host: "0.0.0.0" });
52211
+ ++waitingServers;
52212
+ this.secureServer.on("error", (error) => {
52213
+ if (error.code === "EADDRINUSE") {
52214
+ console.log(`Port ${securePort} is in use...`);
52215
+ setTimeout(() => {
52216
+ assert__default["default"](this.secureServer);
52217
+ this.secureServer.listen({ port: securePort, backlog, host: "0.0.0.0" });
52218
+ }, 1000);
52219
+ }
52220
+ else {
52221
+ console.error("Got secure server error", error.message);
52222
+ this.emit("error", error);
52223
+ }
52224
+ });
52225
+ this.secureServer.on("upgrade", (req, socket, head) => {
52226
+ assert__default["default"](this.ws);
52227
+ this.ws.handleUpgrade(req, socket, head, (ws) => {
52228
+ this._handleConnection(ws, req);
52229
+ });
52230
+ });
52231
+ this.secureServer.once("listening", () => {
52232
+ console.log("https://listening on", securePort);
52233
+ if (!--waitingServers) {
52234
+ resolve();
52235
+ }
52236
+ });
52237
+ }
52238
+ this.ws.on("headers", (headers, request) => {
52239
+ const url = new urlParse(request.url, this.baseUrl);
52240
+ headers.push("x-fisk-object-cache: " + (this.objectCache ? "true" : "false"));
52241
+ if (url.pathname === "/monitor") {
52242
+ const nonce = crypto__default["default"].randomBytes(256).toString("base64");
52243
+ headers.push(`x-fisk-nonce: ${nonce}`);
52244
+ this.nonces.set(request, nonce);
52245
+ }
52197
52246
  });
52198
52247
  });
52199
52248
  }
@@ -53799,19 +53848,13 @@ function realValue(v) {
53799
53848
  return v;
53800
53849
  }
53801
53850
  class Engine {
53802
- argv;
53803
- prefix;
53804
- additionalFiles;
53805
- applicationPath;
53806
- debug;
53807
- options;
53808
- configDirs;
53809
53851
  constructor(options, argv) {
53852
+ var _a;
53810
53853
  this.argv = Object.assign({}, argv);
53811
53854
  this.prefix = options.prefix;
53812
53855
  this.additionalFiles = options.additionalFiles || [];
53813
53856
  this.applicationPath = options.noApplicationPath ? "" : appRootPath.toString();
53814
- this.debug = options.debug ?? false;
53857
+ this.debug = (_a = options.debug) !== null && _a !== void 0 ? _a : false;
53815
53858
  this.options = {};
53816
53859
  this.configDirs = this.argv["config-dir"] || options.configDirs || xdgBasedir.configDirs;
53817
53860
  this._read();
@@ -53981,7 +54024,8 @@ function options (optionsOptions, argv) {
53981
54024
  return defaultValue;
53982
54025
  }
53983
54026
  function string(name, defaultValue) {
53984
- return engine.string(name) ?? defaultValue;
54027
+ var _a;
54028
+ return (_a = engine.string(name)) !== null && _a !== void 0 ? _a : defaultValue;
53985
54029
  }
53986
54030
  return Object.assign(value, {
53987
54031
  prefix: optionsOptions.prefix,