@lmjs/cli 1.0.41 → 1.0.43

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/lib/app.js CHANGED
@@ -1,7 +1,5 @@
1
1
  var fs = require('fs');
2
- const axios = require('axios').default;
3
2
  const path = require("path");
4
-
5
3
  const express = require('express');
6
4
  var compression = require('compression');
7
5
  const app = express();
@@ -65,18 +63,17 @@ wss.on('connection', (ws) => {
65
63
  let pata = data.payload;
66
64
  let __data = pata['data'];
67
65
  let _body = pata['body'];
68
- let res = await axios({
69
- method: _body['method'].toString().toLowerCase(),
70
- url: fcs.validURL(_body['path']) ? _body['path'] : (config.apis[_body['api'] ?? 0].baseURL + _body['path']),
71
- data: __data ?? {},
72
- headers: _body['headers'] ?? config.apis[_body['api'] ?? 0].headers
73
- });
66
+ var resa = await API.req(_body['path'], __data, _body['headers'], _body['method'], _body['api'], true);
67
+ let res = await resa.text();
68
+ try {
69
+ res = JSON.parse(res);
70
+ } catch (e) {
71
+ }
74
72
  _data.payload = (_body['full']) ? {
75
- "headers": res.headers,
76
- "data": res.data
77
- } : res.data;
73
+ "headers": resa.headers,
74
+ "data": res
75
+ } : res;
78
76
  ws.send(JSON.stringify(_data));
79
-
80
77
  } catch (e) {
81
78
  _data.payload = { "code": 108, "error": e.message, "type": "RequestError" };
82
79
  ws.send(JSON.stringify(_data));
@@ -91,10 +88,11 @@ wss.on('connection', (ws) => {
91
88
 
92
89
  }
93
90
  });
94
- });
91
+ }).on('error', (e) => { });
95
92
 
96
93
  global.app = app;
97
- global.axios = axios;
94
+ var fetch = fcs.fetch;
95
+ global.fetch = fetch;
98
96
  global.wss = wss;
99
97
  global.fs = fs;
100
98
  global.path = path;
@@ -120,8 +118,14 @@ app.post('*', function (req, res) {
120
118
  return;
121
119
  });
122
120
 
123
- server.listen(config.server.port, function () {
124
- console.log(`LumenJS server running at http://${config.server.host}:${config.server.port}/`);
121
+ server.listen(config.server.port > 0 ? config.server.port : 0, function (err) {
122
+ cl(`LumenJS server running at http://${config.server.host}:${config.server.port > 0 && server.address().port == config.server.port ? config.server.port : server.address().port}/`);
125
123
  _views = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `views` + path.sep);
126
124
  _tpls = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `tpls` + path.sep);
125
+ }).on('error', (e) => {
126
+ if (e.code === 'EADDRINUSE') {
127
+ cl('Port ' + config.server.port + ' is already in use..');
128
+ server.close();
129
+ server.listen(0);
130
+ }
127
131
  });
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  const semver = require('semver');
3
- const axios = require('axios').default;
4
3
  const path = require('path');
5
4
  const fs = require("fs");
6
5
  const fcs = require("./fcs.js");
@@ -13,9 +12,9 @@ if (!semver.satisfies(m[0].toString(), '>=12')) {
13
12
  console.log("Node version should be minimum 12.0.0");
14
13
  process.exit(1);
15
14
  } else {
16
- axios.get(BEA_Libs.BEAJS, {})
15
+ fcs.API.get(BEA_Libs.BEAJS, {})
17
16
  .then((beajs) => {
18
- axios.get(BEA_Libs.BEACSS, {})
17
+ fcs.API.get(BEA_Libs.BEACSS, {})
19
18
  .then((beacss) => {
20
19
  var libsPath = `${__dirname}` + path.sep + `files` + path.sep + `libs`;
21
20
  fcs.cd(libsPath);
package/lib/fcs.js CHANGED
@@ -1,4 +1,4 @@
1
- const axios = require("axios").default;
1
+ const fetch = require('node-fetch');
2
2
  const path = require("path");
3
3
  const fs = require("fs");
4
4
  const nodemon = require("nodemon");
@@ -16,6 +16,7 @@ const BEA_Libs = {
16
16
  exports.getAllFiles = getAllFiles;
17
17
  exports.ucwords = ucwords;
18
18
 
19
+ exports.fetch = fetch;
19
20
  exports.getConfig = getConfig;
20
21
  function getConfig() {
21
22
  config = {
@@ -100,10 +101,10 @@ function create(conf) {
100
101
  if (!fs.existsSync(libsPath + path.sep + "bea.js")) getLibs = true;
101
102
  }
102
103
  if (getLibs) {
103
- axios
104
+ API
104
105
  .get(BEA_Libs.BEAJS, {})
105
106
  .then((beajs) => {
106
- axios.get(BEA_Libs.BEACSS, {}).then((beacss) => {
107
+ API.get(BEA_Libs.BEACSS, {}).then((beacss) => {
107
108
  var libsPath =
108
109
  `${__dirname}` + path.sep + `files` + path.sep + `libs`;
109
110
  cd(libsPath);
@@ -379,16 +380,24 @@ var API = {
379
380
  patch: async function (u, d, h, a) {
380
381
  return await this.req(u, d, h, "PATCH", a);
381
382
  },
382
- req: async function (u, d, h, m, a) {
383
- let res = await axios({
383
+ req: async function (u, d, h, m, a, f) {
384
+ var urled = validURL(u) ? u : config.apis[a ?? 0].baseURL + u;
385
+ if (m.toString().toLowerCase() == 'get') {
386
+ if (urled.indexOf('?') > -1) urled = urled + "&" + new URLSearchParams(d ?? {});
387
+ else urled = urled + "?" + new URLSearchParams(d ?? {});
388
+ }
389
+ let resa = await fetch(urled, {
384
390
  method: m.toString().toLowerCase(),
385
- url: validURL(u) ? u : config.apis[a ?? 0].baseURL + u,
386
- data: d ?? {},
391
+ body: m.toString().toLowerCase() == 'get' ? null : JSON.stringify(d ?? {}),
387
392
  headers: h ?? config.apis[a ?? 0].headers,
388
- maxContentLength: 100000000,
389
- maxBodyLength: 1000000000,
390
393
  });
391
- return res.data;
394
+ if (f) return resa;
395
+ let res = await resa.text();
396
+ try {
397
+ return JSON.parse(res);
398
+ } catch (e) {
399
+ return res;
400
+ }
392
401
  },
393
402
  };
394
403
  exports.API = API;
@@ -455,6 +464,8 @@ function processCommands(cmd) {
455
464
  } else if (command == "build") {
456
465
  let cmds = process.argv;
457
466
  _bp(cmds);
467
+ } else if (command == "-v" || command == "-version") {
468
+ console.log("LumenJS version " + require('../package.json').version);
458
469
  } else {
459
470
  console.log("LumenJS CLI's command not found!");
460
471
  }
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 26.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 401.2 400" style="enable-background:new 0 0 401.2 400;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{fill:url(#SVGID_1_);}
7
+ .st1{fill:url(#SVGID_00000121980058407996782030000001428573370188884122_);}
8
+ .st2{fill:url(#SVGID_00000152943445312239820940000001348209735848371111_);}
9
+ .st3{fill:url(#SVGID_00000182506215407219878010000004978831317569463227_);}
10
+ </style>
11
+ <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="428.0083" y1="569.0914" x2="305.5179" y2="631.5034" gradientTransform="matrix(1 0 0 1 0 -440)">
12
+ <stop offset="0" style="stop-color:#F6A11A"/>
13
+ <stop offset="0.2488" style="stop-color:#F6A31A"/>
14
+ <stop offset="0.41" style="stop-color:#F7AA19"/>
15
+ <stop offset="0.5463" style="stop-color:#F9B517"/>
16
+ <stop offset="0.6688" style="stop-color:#FBC413"/>
17
+ <stop offset="0.781" style="stop-color:#FED609"/>
18
+ <stop offset="0.8073" style="stop-color:#FFDB06"/>
19
+ <stop offset="1" style="stop-color:#F4E600"/>
20
+ </linearGradient>
21
+ <path class="st0" d="M312.1,188.4c-1,15.8,4,26.6,12.7,37.5c12.1,15.2,46.2,34.6,65.6,43.4v-166c0.1-12.5-2.1-21.7-4.2-27.8
22
+ c-3.3-9.8-7.2-15.1-8.3-25.5c-0.8-7.2,0.2-13.3,1.1-17.1c-18.6,38.5-37.3,77.1-56,115.6C316.9,161.2,313,174.7,312.1,188.4z"/>
23
+ <linearGradient id="SVGID_00000006699273835235655250000012902414653514590898_" gradientUnits="userSpaceOnUse" x1="28.6056" y1="708.1651" x2="222.6818" y2="677.278" gradientTransform="matrix(1 0 0 1 0 -440)">
24
+ <stop offset="0" style="stop-color:#F6A11A"/>
25
+ <stop offset="0.1626" style="stop-color:#F7A61A"/>
26
+ <stop offset="0.3697" style="stop-color:#F8B21A"/>
27
+ <stop offset="0.601" style="stop-color:#FAC41A"/>
28
+ <stop offset="0.848" style="stop-color:#FCDB1A"/>
29
+ <stop offset="1" style="stop-color:#FEEB17"/>
30
+ <stop offset="1" style="stop-color:#F6A11A"/>
31
+ </linearGradient>
32
+ <path style="fill:url(#SVGID_00000006699273835235655250000012902414653514590898_);" d="M222.6,256.9c-1.1-45.5-47.6-62-57.9-69.9
33
+ S33.4,127.6,33.4,127.6l-7.3-3.1v118.2c0,66.8,54.4,126.9,120.9,132c5.3,0.4,10.2,0.4,15.6,0.1c3.4-0.2,4.4,1.4,2.6,4.4
34
+ c-2.6,4.3-4.4,11.1-5.1,12c2.3-3.1,13.3-19.6,15.6-22.8C175.8,368.4,223.7,302.4,222.6,256.9z"/>
35
+ <linearGradient id="SVGID_00000023973866845629556700000008098464440569412238_" gradientUnits="userSpaceOnUse" x1="218.3323" y1="168.8993" x2="174.0283" y2="10.906">
36
+ <stop offset="0" style="stop-color:#FEEB17"/>
37
+ <stop offset="0.1117" style="stop-color:#FCDA1A"/>
38
+ <stop offset="0.2557" style="stop-color:#FAC71A"/>
39
+ <stop offset="0.4088" style="stop-color:#F9B71B"/>
40
+ <stop offset="0.5733" style="stop-color:#F7AB1A"/>
41
+ <stop offset="0.7572" style="stop-color:#F6A41A"/>
42
+ <stop offset="1" style="stop-color:#F6A11A"/>
43
+ </linearGradient>
44
+ <path style="fill:url(#SVGID_00000023973866845629556700000008098464440569412238_);" d="M287.2,151.4c12.8-15.9,18.4-22.5,37.5-56
45
+ c9.1-15.9,23.7-41.5,42.7-74c-2.3,3.9-6.3,9-12,9.9c-9.9,1.5-35.9-22.4-91.1-22.4H26v91.3c0,1.9-1.6,3.4-3.6,3.3
46
+ c-6.7-0.7-14-4.1-14-4.1S231.1,221.2,287.2,151.4z"/>
47
+ <linearGradient id="SVGID_00000031196562025411060430000008544292392537440944_" gradientUnits="userSpaceOnUse" x1="279.2118" y1="708.8517" x2="301.8741" y2="815.4693" gradientTransform="matrix(1 0 0 1 0 -440)">
48
+ <stop offset="0" style="stop-color:#F4E600"/>
49
+ <stop offset="5.336942e-02" style="stop-color:#F5DF00"/>
50
+ <stop offset="0.2273" style="stop-color:#F7CA02"/>
51
+ <stop offset="0.3891" style="stop-color:#F8B910"/>
52
+ <stop offset="0.5328" style="stop-color:#F8AE15"/>
53
+ <stop offset="0.6434" style="stop-color:#F8AA16"/>
54
+ <stop offset="1" style="stop-color:#F6A11A"/>
55
+ </linearGradient>
56
+ <path style="fill:url(#SVGID_00000031196562025411060430000008544292392537440944_);" d="M238.5,297.8c-9.8,9.8-33.3,53.4-44.9,75.5
57
+ h108.9c48.6,0,88-39.4,88-88l0,0C284.4,238.6,251.6,284.7,238.5,297.8z"/>
58
+ </svg>
@@ -1,13 +1,36 @@
1
- <div>
2
- Home View
1
+ <div class="hv100">
2
+ <div class="ph50">
3
+ <div class="pv10 r" style="height: 50px;">
4
+ <grid_nm gap10>
5
+ <div class="vm">
6
+ <a href="https://www.npmjs.com/package/@lmjs/cli">
7
+ <div class="mdi mdi-npm fs40 cw"></div>
8
+ </a>
9
+ </div>
10
+ <div class="vm">
11
+ <a href="https://github.com/bea-technology/lmjs-cli">
12
+ <div class="mdi mdi-github fs34 cw"></div>
13
+ </a>
14
+ </div>
15
+ </grid_nm>
16
+ </div>
17
+ </div>
18
+ <div class="cc sq cov" style="background-image: url('/images/lumen_icon_yellow.svg'); height: 250px;"></div>
3
19
  </div>
4
- <script>
5
- </script>
20
+
21
+
22
+
23
+ <style>
24
+ body {
25
+ color: rgba(255, 255, 255, .87);
26
+ background-color: #242424;
27
+ }
28
+ </style>
6
29
 
7
30
  <settings>
8
31
  {
9
- hasFooter: true,
10
- hasHeader: true,
11
- hasNav: true
32
+ hasFooter: false,
33
+ hasHeader: false,
34
+ hasNav: false
12
35
  }
13
36
  </settings>
@@ -1,13 +0,0 @@
1
- <style>
2
- a.active {
3
- font-weight: 900;
4
- color: black;
5
- }
6
- </style>
7
- <div class="oh pv40 upper cb70">
8
- <grid_nm gap40>
9
- <div><a href="/" n0="home">Home</a></div>
10
- <div><a href="/about" n0="about">About Us</a></div>
11
- <div><a href="/contact" n0="contact">Contact Us</a></div>
12
- </grid_nm>
13
- </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmjs/cli",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "Command line interface for super fast LumenJS development. LumenJS is a tiny robust reactive javascript framework for building scalable and high-performant web applications and web user interfaces, be it simple or complex, with standard HTML, CSS and JavaScript",
5
5
  "bin": {
6
6
  "lm": "./bin/commands.js",
@@ -35,7 +35,7 @@
35
35
  "lumen bea"
36
36
  ],
37
37
  "dependencies": {
38
- "@lmjs/core": "^1.0.6"
38
+ "@lmjs/core": "^1.0.7"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=12.0.0"
@@ -1,14 +0,0 @@
1
- <div>
2
- About View
3
- </div>
4
- <script>
5
-
6
- </script>
7
-
8
- <settings>
9
- {
10
- hasFooter: true,
11
- hasHeader: true,
12
- hasNav: true
13
- }
14
- </settings>
@@ -1,14 +0,0 @@
1
- <div>
2
- Contact View
3
- </div>
4
- <script>
5
-
6
- </script>
7
-
8
- <settings>
9
- {
10
- hasFooter: true,
11
- hasHeader: true,
12
- hasNav: true
13
- }
14
- </settings>