@lmjs/cli 1.0.23 → 1.0.25

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.
Files changed (3) hide show
  1. package/README.md +10 -11
  2. package/index.js +259 -96
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ LumenJS is a tiny robust reactive javascript framework for building scalable and
8
8
 
9
9
 
10
10
  LumenJS comes along with MobiusCSS library which is a utility-first CSS framework packed with grid and table sectioning systems and classes like g, mt20, pv100, c and sq that can be composed to build any design, directly in your markup.
11
- <a href="https://mobius.lumenjs.com/" target="_blank">MobiusCSS Documentation</a>
11
+ <a href="https://www.lumenjs.com/mobius" target="_blank">MobiusCSS Documentation</a>
12
12
 
13
13
  &nbsp;
14
14
 
@@ -64,29 +64,28 @@ lm purge
64
64
 
65
65
  &nbsp;
66
66
 
67
- Build A Dist For Production Version + NodeJs Server
67
+ Build A Dist For Production Version without NodeJs Server
68
68
  ```
69
- lm build
69
+ lm build --serverless
70
70
  ```
71
71
 
72
72
  &nbsp;
73
73
 
74
- Build A Dist For Production Version + NodeJs Server & Deploy It Directly
74
+ Build A Dist For Production Version without NodeJs Server & Deploy It Directly
75
75
  ```
76
- lm build --deploy
76
+ lm build --serverless --deploy
77
77
  ```
78
78
 
79
79
  &nbsp;
80
80
 
81
- Build A Dist For Production Version without NodeJs Server
81
+ Build A Dist For Production Version + NodeJs Server
82
82
  ```
83
- lm build --serverless
83
+ lm build
84
84
  ```
85
85
 
86
86
  &nbsp;
87
87
 
88
- Build A Dist For Production Version without NodeJs Server & Deploy It Directly
89
- ```
90
- lm build --serverless --deploy
88
+ Build A Dist For Production Version + NodeJs Server & Deploy It Directly
91
89
  ```
92
-
90
+ lm build --deploy
91
+ ```
package/index.js CHANGED
@@ -1,20 +1,20 @@
1
- const nodemon = require('nodemon');
2
- const axios = require('axios').default;
3
- const path = require('path');
1
+ const nodemon = require("nodemon");
2
+ const axios = require("axios").default;
3
+ const path = require("path");
4
4
  const fs = require("fs");
5
5
  const FtpDeploy = require("ftp-deploy");
6
6
  const ftpDeploy = new FtpDeploy();
7
7
 
8
8
  // const { exec } = require("child_process");
9
9
  const fcs = require("./lib/fcs.js");
10
- var UglifyJS = require('uglify-js');
10
+ var UglifyJS = require("uglify-js");
11
11
 
12
12
  exports.processCommand = processCommands;
13
13
  exports.startServer = startServer;
14
14
 
15
15
  const BEA_Libs = {
16
- "BEACSS": "https://s.beacdn.com/beacss/latest",
17
- "BEAJS": "https://s.beacdn.com/beajs/latest"
16
+ BEACSS: "https://s.beacdn.com/beacss/latest",
17
+ BEAJS: "https://s.beacdn.com/beajs/latest",
18
18
  };
19
19
 
20
20
  function processCommands(cmd) {
@@ -25,27 +25,63 @@ function processCommands(cmd) {
25
25
  let c = process.argv.slice(3, process.argv.length);
26
26
  let t = fcs.lw(c[0]);
27
27
  fcs.create({
28
- "type": t[0] == "-" ? t.split("-").join("") : t,
29
- "name": t[0] == "-" ? c.slice(1, c.length) : c
28
+ type: t[0] == "-" ? t.split("-").join("") : t,
29
+ name: t[0] == "-" ? c.slice(1, c.length) : c,
30
30
  });
31
31
  } else if (command == "purge") {
32
- axios.get(BEA_Libs.BEAJS, {})
32
+ axios
33
+ .get(BEA_Libs.BEAJS, {})
33
34
  .then((beajs) => {
34
- axios.get(BEA_Libs.BEACSS, {})
35
- .then((beacss) => {
36
- var filePath = `${process.cwd()}` + path.sep;
37
- let stylesFile = filePath + path.sep + "src" + path.sep + "css" + path.sep + `bea.css`;
38
- var libsPath = `${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + `libs`;
39
- fcs.cd(libsPath);
40
- fs.writeFileSync(libsPath + path.sep + "bea.js", String(beajs.data));
41
- fs.writeFileSync(libsPath + path.sep + "bea.css", String(beacss.data));
42
- if (fs.existsSync(stylesFile)) {
43
- fs.writeFileSync(filePath + path.sep + "src" + path.sep + "js" + path.sep + "bea.js", String(beajs.data));
44
- fs.writeFileSync(filePath + path.sep + "src" + path.sep + "css" + path.sep + "bea.css", String(beacss.data));
45
- }
46
- console.log("Successfully Purged!");
47
- });
48
- }).catch(err => {
35
+ axios.get(BEA_Libs.BEACSS, {}).then((beacss) => {
36
+ var filePath = `${process.cwd()}` + path.sep;
37
+ let stylesFile =
38
+ filePath +
39
+ path.sep +
40
+ "src" +
41
+ path.sep +
42
+ "css" +
43
+ path.sep +
44
+ `bea.css`;
45
+ var libsPath =
46
+ `${__dirname}` +
47
+ path.sep +
48
+ `lib` +
49
+ path.sep +
50
+ `files` +
51
+ path.sep +
52
+ `libs`;
53
+ fcs.cd(libsPath);
54
+ fs.writeFileSync(libsPath + path.sep + "bea.js", String(beajs.data));
55
+ fs.writeFileSync(
56
+ libsPath + path.sep + "bea.css",
57
+ String(beacss.data)
58
+ );
59
+ if (fs.existsSync(stylesFile)) {
60
+ fs.writeFileSync(
61
+ filePath +
62
+ path.sep +
63
+ "src" +
64
+ path.sep +
65
+ "js" +
66
+ path.sep +
67
+ "bea.js",
68
+ String(beajs.data)
69
+ );
70
+ fs.writeFileSync(
71
+ filePath +
72
+ path.sep +
73
+ "src" +
74
+ path.sep +
75
+ "css" +
76
+ path.sep +
77
+ "bea.css",
78
+ String(beacss.data)
79
+ );
80
+ }
81
+ console.log("Successfully Purged!");
82
+ });
83
+ })
84
+ .catch((err) => {
49
85
  console.log("Purge Failed!");
50
86
  });
51
87
  } else if (command == "build") {
@@ -59,37 +95,52 @@ function processCommands(cmd) {
59
95
  var API = fcs.API;
60
96
 
61
97
  async function buildProject(cmds) {
62
-
63
- import('ora').then(async ({ default: ora, oraPromise: oraPromise }) => {
98
+ import("ora").then(async ({ default: ora, oraPromise: oraPromise }) => {
64
99
  const spinner = ora({
65
- text: 'Started Building Project For Production..',
66
- color: 'green'
100
+ text: "Started Building Project For Production..",
101
+ color: "green",
67
102
  });
68
103
 
69
- spinner.succeed('Started Building Project For Production').start('Gathering Required Resources..');
104
+ spinner
105
+ .succeed("Started Building Project For Production")
106
+ .start("Gathering Required Resources..");
70
107
 
71
108
  var projectPath = `${process.cwd()}`;
72
- var dest = projectPath + path.sep + 'dist';
73
-
74
- let _views = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `views` + path.sep);
75
- let _tpls = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `tpls` + path.sep);
109
+ var dest = projectPath + path.sep + "dist";
110
+
111
+ let _views = fcs.getAllFiles(
112
+ `${process.cwd()}` + path.sep + `src` + path.sep + `views` + path.sep
113
+ );
114
+ let _tpls = fcs.getAllFiles(
115
+ `${process.cwd()}` + path.sep + `src` + path.sep + `tpls` + path.sep
116
+ );
76
117
  var config = fcs.getConfig();
77
118
 
78
- var indexCode = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "index.html", "utf8");
79
-
80
-
81
-
82
- var beaCSSCode = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "css" + path.sep + "bea.css", "utf8");
83
- var beaCode2 = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "index.js", "utf8");
84
-
85
- var kkk = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "js" + path.sep + "bea.js", "utf8");
119
+ var indexCode = fs.readFileSync(
120
+ projectPath + path.sep + `src` + path.sep + "index.html",
121
+ "utf8"
122
+ );
123
+
124
+ var beaCSSCode = fs.readFileSync(
125
+ projectPath + path.sep + `src` + path.sep + "css" + path.sep + "bea.css",
126
+ "utf8"
127
+ );
128
+ var beaCode2 = fs.readFileSync(
129
+ projectPath + path.sep + `src` + path.sep + "index.js",
130
+ "utf8"
131
+ );
132
+
133
+ var kkk = fs.readFileSync(
134
+ projectPath + path.sep + `src` + path.sep + "js" + path.sep + "bea.js",
135
+ "utf8"
136
+ );
86
137
  spinner.succeed("Gathering Required Resources");
87
138
  var beaCode = "";
88
- if (cmds.indexOf('--serverless') >= 0) {
89
- spinner.start('Signing & Securing App..');
139
+ if (cmds.indexOf("--serverless") >= 0) {
140
+ spinner.start("Signing & Securing App..");
90
141
 
91
142
  let r = await API.post("https://www.beaapis.com/1/beajs", {
92
- "data": JSON.stringify(config.apis)
143
+ data: JSON.stringify(config.apis),
93
144
  });
94
145
 
95
146
  let token_ = r.token;
@@ -100,64 +151,128 @@ async function buildProject(cmds) {
100
151
  return;
101
152
  }
102
153
 
103
- beaCode += `
104
- var _beaTn = "` + token_ + `";
154
+ beaCode +=
155
+ `
156
+ var _beaTn = "` +
157
+ token_ +
158
+ `";
105
159
  `;
106
160
  }
107
161
  beaCode += kkk;
108
- spinner.succeed("Signing & Securing App").start('Packing & Cleaning...');
162
+ spinner.succeed("Signing & Securing App").start("Packing & Cleaning...");
109
163
 
110
- beaCode += `
164
+ beaCode +=
165
+ `
111
166
  var _vcData = {
112
- "views": `+ JSON.stringify(_views) + `,
113
- "tpls": `+ JSON.stringify(_tpls) + `
167
+ "views": ` +
168
+ JSON.stringify(_views) +
169
+ `,
170
+ "tpls": ` +
171
+ JSON.stringify(_tpls) +
172
+ `
114
173
  };
115
174
  `;
116
- beaCode += `
117
- ` + beaCode2 + `
175
+ beaCode +=
176
+ `
177
+ ` +
178
+ beaCode2 +
179
+ `
118
180
  `;
119
- var js2 = `
120
- exports.config = `+ JSON.stringify(config) + `;
181
+ var js2 =
182
+ `
183
+ exports.config = ` +
184
+ JSON.stringify(config) +
185
+ `;
121
186
  `;
122
187
 
123
188
  let zode = UglifyJS.minify(beaCode, {
124
189
  mangle: {
125
- reserved: ['_vcdata','_ws']
126
- }
190
+ reserved: ["_vcdata", "_ws"],
191
+ },
127
192
  });
128
193
  let zode2 = UglifyJS.minify(js2, {
129
194
  mangle: {
130
- reserved: ['_vcdata','_ws']
195
+ reserved: ["_vcdata", "_ws"],
131
196
  },
132
197
  output: {
133
- beautify: true
134
- }
198
+ beautify: true,
199
+ },
135
200
  });
136
201
 
137
202
  fcs.rd(dest);
138
203
 
139
- spinner.succeed("Packing & Cleaning").start('Writing Files...');
204
+ spinner.succeed("Packing & Cleaning").start("Writing Files...");
140
205
  let buildPath = `build`;
141
- if (cmds.indexOf('--serverless') >= 0) {
142
-
206
+ if (cmds.indexOf("--serverless") >= 0) {
143
207
  buildPath = `build_serverless`;
144
208
 
145
- fcs.copyDir(`${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + buildPath, dest);
209
+ fcs.copyDir(
210
+ `${__dirname}` +
211
+ path.sep +
212
+ `lib` +
213
+ path.sep +
214
+ `files` +
215
+ path.sep +
216
+ buildPath,
217
+ dest
218
+ );
146
219
  fcs.copyDir(projectPath + path.sep + "src", dest, "_beajsBuild");
147
220
  fcs.cd(dest + path.sep + "js");
148
221
  fcs.cd(dest + path.sep + "css");
149
222
  fcs.cd(dest + path.sep + "images");
150
223
 
151
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "js", dest + path.sep + "js", "_beajsBuild");
152
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "css", dest + path.sep + "css", "_beajsBuild");
153
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "images", dest + path.sep + "images", "_beajsBuild");
154
-
155
- fs.writeFileSync(dest + path.sep + "js" + path.sep + "bea.js", String(zode.code));
156
- fs.writeFileSync(dest + path.sep + "css" + path.sep + "bea.css", String(beaCSSCode));
157
- fs.writeFileSync(dest + path.sep + "index.html", String(indexCode).split('<script src="/index.js" type="text/javascript"></script>').join("").split('/js/bea.js').join("/js/bea.js?v" + new Date().getTime()).split('/css/styles.css').join("/css/styles.css?v" + new Date().getTime()).split('/css/bea.css').join("/css/bea.css?v" + new Date().getTime()));
224
+ fcs.copyDir(
225
+ projectPath + path.sep + "src" + path.sep + "js",
226
+ dest + path.sep + "js",
227
+ "_beajsBuild"
228
+ );
229
+ fcs.copyDir(
230
+ projectPath + path.sep + "src" + path.sep + "css",
231
+ dest + path.sep + "css",
232
+ "_beajsBuild"
233
+ );
234
+ fcs.copyDir(
235
+ projectPath + path.sep + "src" + path.sep + "images",
236
+ dest + path.sep + "images",
237
+ "_beajsBuild"
238
+ );
239
+
240
+ fs.writeFileSync(
241
+ dest + path.sep + "js" + path.sep + "bea.js",
242
+ String(zode.code)
243
+ );
244
+ fs.writeFileSync(
245
+ dest + path.sep + "css" + path.sep + "bea.css",
246
+ String(beaCSSCode)
247
+ );
248
+ fs.writeFileSync(
249
+ dest + path.sep + "index.html",
250
+ String(indexCode)
251
+ .split('<script src="/index.js" type="text/javascript"></script>')
252
+ .join("")
253
+ .split("/js/bea.js")
254
+ .join("/js/bea.js?v" + new Date().getTime())
255
+ .split("/css/styles.css")
256
+ .join("/css/styles.css?v" + new Date().getTime())
257
+ .split("/css/bea.css")
258
+ .join("/css/bea.css?v" + new Date().getTime())
259
+ );
158
260
  } else {
159
- fcs.copyDir(`${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + buildPath, dest);
160
- fcs.copyDir(projectPath + path.sep + "src", dest + path.sep + "src", "_beajsBuild");
261
+ fcs.copyDir(
262
+ `${__dirname}` +
263
+ path.sep +
264
+ `lib` +
265
+ path.sep +
266
+ `files` +
267
+ path.sep +
268
+ buildPath,
269
+ dest
270
+ );
271
+ fcs.copyDir(
272
+ projectPath + path.sep + "src",
273
+ dest + path.sep + "src",
274
+ "_beajsBuild"
275
+ );
161
276
  fcs.cd(dest + path.sep + "src" + path.sep + "js");
162
277
  fcs.cd(dest + path.sep + "src" + path.sep + "css");
163
278
  fcs.cd(dest + path.sep + "src" + path.sep + "images");
@@ -165,25 +280,61 @@ async function buildProject(cmds) {
165
280
  let appFile = projectPath + path.sep + `src` + path.sep + "app.js";
166
281
  if (fs.existsSync(appFile)) {
167
282
  var appCode = fs.readFileSync(appFile, "utf8");
168
- var serverJsCode = fs.readFileSync(`${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + buildPath + path.sep + "server.js", "utf8");
169
- fs.writeFileSync(dest + path.sep + "server.js", String(serverJsCode).split('//APP_HOLDER').join(appCode));
283
+ var serverJsCode = fs.readFileSync(
284
+ `${__dirname}` +
285
+ path.sep +
286
+ `lib` +
287
+ path.sep +
288
+ `files` +
289
+ path.sep +
290
+ buildPath +
291
+ path.sep +
292
+ "server.js",
293
+ "utf8"
294
+ );
295
+ fs.writeFileSync(
296
+ dest + path.sep + "server.js",
297
+ String(serverJsCode).split("//APP_HOLDER").join(appCode)
298
+ );
170
299
  fs.unlinkSync(dest + path.sep + "src" + path.sep + "app.js");
171
300
  }
172
301
 
173
302
  // fcs.copyDir(projectPath + path.sep + `src` + path.sep + `css`, dest + path.sep + "src" + path.sep + "css");
174
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "js", dest + path.sep + "src" + path.sep + "js", "_beajsBuild");
175
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "css", dest + path.sep + "src" + path.sep + "css", "_beajsBuild");
176
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "images", dest + path.sep + "src" + path.sep + "images", "_beajsBuild");
177
-
178
- fs.writeFileSync(dest + path.sep + "src" + path.sep + "js" + path.sep + "bea.js", String(zode.code));
179
- fs.writeFileSync(dest + path.sep + "src" + path.sep + "css" + path.sep + "bea.css", String(beaCSSCode));
180
- fs.writeFileSync(dest + path.sep + "src" + path.sep + "index.html", String(indexCode).split('<script src="/index.js" type="text/javascript"></script>').join(""));
303
+ fcs.copyDir(
304
+ projectPath + path.sep + "src" + path.sep + "js",
305
+ dest + path.sep + "src" + path.sep + "js",
306
+ "_beajsBuild"
307
+ );
308
+ fcs.copyDir(
309
+ projectPath + path.sep + "src" + path.sep + "css",
310
+ dest + path.sep + "src" + path.sep + "css",
311
+ "_beajsBuild"
312
+ );
313
+ fcs.copyDir(
314
+ projectPath + path.sep + "src" + path.sep + "images",
315
+ dest + path.sep + "src" + path.sep + "images",
316
+ "_beajsBuild"
317
+ );
318
+
319
+ fs.writeFileSync(
320
+ dest + path.sep + "src" + path.sep + "js" + path.sep + "bea.js",
321
+ String(zode.code)
322
+ );
323
+ fs.writeFileSync(
324
+ dest + path.sep + "src" + path.sep + "css" + path.sep + "bea.css",
325
+ String(beaCSSCode)
326
+ );
327
+ fs.writeFileSync(
328
+ dest + path.sep + "src" + path.sep + "index.html",
329
+ String(indexCode)
330
+ .split('<script src="/index.js" type="text/javascript"></script>')
331
+ .join("")
332
+ );
181
333
  fs.writeFileSync(dest + path.sep + "config.js", String(zode2.code));
182
-
183
334
  }
184
335
 
185
- if (cmds.indexOf('--deploy') >= 0) {
186
- spinner.succeed('Writing Files').start('Uploading To Server..');
336
+ if (cmds.indexOf("--deploy") >= 0) {
337
+ spinner.succeed("Writing Files").start("Uploading To Server..");
187
338
  const _config = {
188
339
  user: config.ftp.username,
189
340
  // Password optional, prompted if none given
@@ -192,7 +343,7 @@ async function buildProject(cmds) {
192
343
  port: config.ftp.port,
193
344
  localRoot: dest,
194
345
  remoteRoot: config.ftp.remotePath,
195
- include: ["*", "**/*", ".*"], // this would upload everything except dot files
346
+ include: ["*", "**/*", ".*"], // this would upload everything except dot files
196
347
  // include: ["*.js", "dist/*", ".*"],
197
348
  // e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
198
349
  exclude: config.ftp.ignore,
@@ -214,7 +365,17 @@ async function buildProject(cmds) {
214
365
  }
215
366
  });
216
367
  ftpDeploy.on("uploading", function (data) {
217
- spinner.start(parseFloat(((data.transferredFileCount) * 100 / data.totalFilesCount).toFixed(2)) + '% ' + 'Uploading ' + data.filename + ' ');
368
+ spinner.start(
369
+ parseFloat(
370
+ ((data.transferredFileCount * 100) / data.totalFilesCount).toFixed(
371
+ 2
372
+ )
373
+ ) +
374
+ "% " +
375
+ "Uploading " +
376
+ data.filename +
377
+ " "
378
+ );
218
379
  });
219
380
  // ftpDeploy.on("uploaded", function (data) {
220
381
  // console.log(data); // same data as uploading event
@@ -225,22 +386,24 @@ async function buildProject(cmds) {
225
386
  // ftpDeploy.on("upload-error", function (data) {
226
387
  // console.log(data.err); // data will also include filename, relativePath, and other goodies
227
388
  // });
228
-
229
- } else
230
- spinner.succeed('Writing Files').succeed("Done");
231
-
389
+ } else spinner.succeed("Writing Files").succeed("Done");
232
390
  });
391
+ }
233
392
 
393
+ function clear(isSoft) {
394
+ process.stdout.write(
395
+ isSoft ? '\x1B[H\x1B[2J' : '\x1B[2J\x1B[3J\x1B[H\x1Bc'
396
+ );
234
397
  }
235
398
 
236
399
  function startServer() {
400
+ clear();
237
401
  nodemon({
238
- script: path.join(__dirname.toString(), 'lib', 'app.js'), ext: "view,js,css,json,tpl,html", watch: [
239
- "src/",
240
- "config.json"
241
- ]
402
+ script: path.join(__dirname.toString(), "lib", "app.js"),
403
+ ext: "view,js,css,json,tpl,html",
404
+ watch: ["src/", "config.json"],
242
405
  });
243
- nodemon.on('restart', (files) => {
406
+ nodemon.on("restart", (files) => {
244
407
  console.log(files);
245
408
  });
246
- }
409
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmjs/cli",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "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
  "main": "./index.js",
6
6
  "bin": {