innetjs 2.0.9 → 2.0.12

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.
package/bin/innet CHANGED
@@ -4,6 +4,7 @@
4
4
  var path$1 = require('path');
5
5
  var fs = require('fs-extra');
6
6
  var http = require('http');
7
+ var address = require('address');
7
8
  var https = require('https');
8
9
  var util = require('util');
9
10
  var axios = require('axios');
@@ -36,6 +37,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
36
37
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
37
38
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
38
39
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
40
+ var address__default = /*#__PURE__*/_interopDefaultLegacy(address);
39
41
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
40
42
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
41
43
  var logger__default = /*#__PURE__*/_interopDefaultLegacy(logger);
@@ -385,11 +387,11 @@ class InnetJS {
385
387
  options.output.format = 'cjs';
386
388
  options.external = Object.keys((pkg === null || pkg === void 0 ? void 0 : pkg.dependencies) || {});
387
389
  options.plugins.push(pluginNodeResolve.nodeResolve({
388
- moduleDirectories: [path__default["default"].resolve(this.srcFolder, 'node_modules')]
390
+ moduleDirectories: [path__default["default"].resolve(this.srcFolder, 'node_modules')],
389
391
  }), string({
390
392
  include: '**/*.*',
391
393
  exclude: stringExcludeNode,
392
- }), this.createServer(options.external));
394
+ }), this.createServer());
393
395
  }
394
396
  else {
395
397
  const key = path__default["default"].basename(this.sslKey) !== this.sslKey
@@ -570,13 +572,13 @@ class InnetJS {
570
572
  proxyReqPathResolver: req => req.originalUrl
571
573
  }));
572
574
  }
573
- app.use(/^[^.]+$/, (req, res) => {
575
+ app.use(/^([^.]*|.*\.[^.]{5,})$/, (req, res) => {
574
576
  res.sendFile(this.devBuildFolder + '/index.html');
575
577
  });
576
578
  const server = httpsUsing ? https__default["default"].createServer({ key, cert }, app) : http__default["default"].createServer(app);
577
579
  let port = this.port;
578
580
  const listener = () => {
579
- console.log(`${chalk__default["default"].green('➤')} Server started on http${httpsUsing ? 's' : ''}://localhost:${port}`);
581
+ console.log(`${chalk__default["default"].green('➤')} Started on http${httpsUsing ? 's' : ''}://localhost:${port} and http${httpsUsing ? 's' : ''}://${address__default["default"].ip()}:${port}`);
580
582
  };
581
583
  server.listen(port, listener);
582
584
  server.on('error', (e) => __awaiter(this, void 0, void 0, function* () {
@@ -600,23 +602,19 @@ class InnetJS {
600
602
  })
601
603
  };
602
604
  }
603
- createServer(external) {
605
+ createServer() {
604
606
  let app;
605
607
  return {
606
608
  writeBundle: () => __awaiter(this, void 0, void 0, function* () {
607
609
  app === null || app === void 0 ? void 0 : app.kill();
608
- const filePath = path__default["default"].resolve(this.buildFolder, 'index.js');
609
- let data = yield fs__default["default"].readFile(filePath, 'UTF-8');
610
- const regExp = new RegExp(`require\\('(${external.join('|')})'\\)`, 'g');
611
- data = data.replace(regExp, `require('${path__default["default"].resolve(this.projectFolder, 'node_modules', '$1')}')`);
612
- yield fs__default["default"].writeFile(filePath, data);
610
+ const filePath = path__default["default"].resolve(this.devBuildFolder, 'index.js');
613
611
  app = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
614
612
  })
615
613
  };
616
614
  }
617
615
  }
618
616
 
619
- var version = "2.0.9";
617
+ var version = "2.0.12";
620
618
 
621
619
  require('dotenv').config();
622
620
  const innetJS = new InnetJS();
package/index.d.ts CHANGED
@@ -48,7 +48,7 @@ export default class InnetJS {
48
48
  createClient(key: any, cert: any, pkg: any): {
49
49
  writeBundle: () => Promise<void>;
50
50
  };
51
- createServer(external: string[]): {
51
+ createServer(): {
52
52
  writeBundle: () => Promise<void>;
53
53
  };
54
54
  }
package/index.es6.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import path$1 from 'path';
2
2
  import fs, { promises } from 'fs-extra';
3
3
  import http from 'http';
4
+ import address from 'address';
4
5
  import https from 'https';
5
6
  import { promisify } from 'util';
6
7
  import axios from 'axios';
@@ -355,11 +356,11 @@ class InnetJS {
355
356
  options.output.format = 'cjs';
356
357
  options.external = Object.keys((pkg === null || pkg === void 0 ? void 0 : pkg.dependencies) || {});
357
358
  options.plugins.push(nodeResolve({
358
- moduleDirectories: [path$1.resolve(this.srcFolder, 'node_modules')]
359
+ moduleDirectories: [path$1.resolve(this.srcFolder, 'node_modules')],
359
360
  }), string({
360
361
  include: '**/*.*',
361
362
  exclude: stringExcludeNode,
362
- }), this.createServer(options.external));
363
+ }), this.createServer());
363
364
  }
364
365
  else {
365
366
  const key = path$1.basename(this.sslKey) !== this.sslKey
@@ -540,13 +541,13 @@ class InnetJS {
540
541
  proxyReqPathResolver: req => req.originalUrl
541
542
  }));
542
543
  }
543
- app.use(/^[^.]+$/, (req, res) => {
544
+ app.use(/^([^.]*|.*\.[^.]{5,})$/, (req, res) => {
544
545
  res.sendFile(this.devBuildFolder + '/index.html');
545
546
  });
546
547
  const server = httpsUsing ? https.createServer({ key, cert }, app) : http.createServer(app);
547
548
  let port = this.port;
548
549
  const listener = () => {
549
- console.log(`${chalk.green('➤')} Server started on http${httpsUsing ? 's' : ''}://localhost:${port}`);
550
+ console.log(`${chalk.green('➤')} Started on http${httpsUsing ? 's' : ''}://localhost:${port} and http${httpsUsing ? 's' : ''}://${address.ip()}:${port}`);
550
551
  };
551
552
  server.listen(port, listener);
552
553
  server.on('error', (e) => __awaiter(this, void 0, void 0, function* () {
@@ -570,16 +571,12 @@ class InnetJS {
570
571
  })
571
572
  };
572
573
  }
573
- createServer(external) {
574
+ createServer() {
574
575
  let app;
575
576
  return {
576
577
  writeBundle: () => __awaiter(this, void 0, void 0, function* () {
577
578
  app === null || app === void 0 ? void 0 : app.kill();
578
- const filePath = path$1.resolve(this.buildFolder, 'index.js');
579
- let data = yield fs.readFile(filePath, 'UTF-8');
580
- const regExp = new RegExp(`require\\('(${external.join('|')})'\\)`, 'g');
581
- data = data.replace(regExp, `require('${path$1.resolve(this.projectFolder, 'node_modules', '$1')}')`);
582
- yield fs.writeFile(filePath, data);
579
+ const filePath = path$1.resolve(this.devBuildFolder, 'index.js');
583
580
  app = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
584
581
  })
585
582
  };
package/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var path$1 = require('path');
4
4
  var fs = require('fs-extra');
5
5
  var http = require('http');
6
+ var address = require('address');
6
7
  var https = require('https');
7
8
  var util = require('util');
8
9
  var axios = require('axios');
@@ -34,6 +35,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
34
35
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
35
36
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
36
37
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
38
+ var address__default = /*#__PURE__*/_interopDefaultLegacy(address);
37
39
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
38
40
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
39
41
  var logger__default = /*#__PURE__*/_interopDefaultLegacy(logger);
@@ -383,11 +385,11 @@ class InnetJS {
383
385
  options.output.format = 'cjs';
384
386
  options.external = Object.keys((pkg === null || pkg === void 0 ? void 0 : pkg.dependencies) || {});
385
387
  options.plugins.push(pluginNodeResolve.nodeResolve({
386
- moduleDirectories: [path__default["default"].resolve(this.srcFolder, 'node_modules')]
388
+ moduleDirectories: [path__default["default"].resolve(this.srcFolder, 'node_modules')],
387
389
  }), string({
388
390
  include: '**/*.*',
389
391
  exclude: stringExcludeNode,
390
- }), this.createServer(options.external));
392
+ }), this.createServer());
391
393
  }
392
394
  else {
393
395
  const key = path__default["default"].basename(this.sslKey) !== this.sslKey
@@ -568,13 +570,13 @@ class InnetJS {
568
570
  proxyReqPathResolver: req => req.originalUrl
569
571
  }));
570
572
  }
571
- app.use(/^[^.]+$/, (req, res) => {
573
+ app.use(/^([^.]*|.*\.[^.]{5,})$/, (req, res) => {
572
574
  res.sendFile(this.devBuildFolder + '/index.html');
573
575
  });
574
576
  const server = httpsUsing ? https__default["default"].createServer({ key, cert }, app) : http__default["default"].createServer(app);
575
577
  let port = this.port;
576
578
  const listener = () => {
577
- console.log(`${chalk__default["default"].green('➤')} Server started on http${httpsUsing ? 's' : ''}://localhost:${port}`);
579
+ console.log(`${chalk__default["default"].green('➤')} Started on http${httpsUsing ? 's' : ''}://localhost:${port} and http${httpsUsing ? 's' : ''}://${address__default["default"].ip()}:${port}`);
578
580
  };
579
581
  server.listen(port, listener);
580
582
  server.on('error', (e) => __awaiter(this, void 0, void 0, function* () {
@@ -598,16 +600,12 @@ class InnetJS {
598
600
  })
599
601
  };
600
602
  }
601
- createServer(external) {
603
+ createServer() {
602
604
  let app;
603
605
  return {
604
606
  writeBundle: () => __awaiter(this, void 0, void 0, function* () {
605
607
  app === null || app === void 0 ? void 0 : app.kill();
606
- const filePath = path__default["default"].resolve(this.buildFolder, 'index.js');
607
- let data = yield fs__default["default"].readFile(filePath, 'UTF-8');
608
- const regExp = new RegExp(`require\\('(${external.join('|')})'\\)`, 'g');
609
- data = data.replace(regExp, `require('${path__default["default"].resolve(this.projectFolder, 'node_modules', '$1')}')`);
610
- yield fs__default["default"].writeFile(filePath, data);
608
+ const filePath = path__default["default"].resolve(this.devBuildFolder, 'index.js');
611
609
  app = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
612
610
  })
613
611
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innetjs",
3
- "version": "2.0.9",
3
+ "version": "2.0.12",
4
4
  "description": "CLI for innet boilerplate",
5
5
  "homepage": "https://github.com/d8corp/innetjs",
6
6
  "author": "Mikhail Lysikov <d8corp@mail.ru>",
@@ -37,6 +37,7 @@
37
37
  "@rollup/plugin-image": "^2.1.1",
38
38
  "@rollup/plugin-json": "^4.1.0",
39
39
  "@rollup/plugin-node-resolve": "^13.3.0",
40
+ "address": "^1.2.0",
40
41
  "autoprefixer": "^10.4.8",
41
42
  "axios": "^0.27.2",
42
43
  "chalk": "^4.1.2",