@lmjs/cli 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![LumenJS Reactive JavaScript Framework](https://lumen.bea.com.lb/lmjs.svg)
2
+
1
3
  # LumenJS Reactive JavaScript Framework
2
4
 
3
5
  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.
@@ -13,7 +15,7 @@ LumenJS comes along with MobiusCSS library which is a utility-first CSS framewor
13
15
  ## Installation
14
16
  Using npm:
15
17
  ```
16
- npm install -g @lumen.js/cli
18
+ npm install -g @lmjs/cli
17
19
  ```
18
20
 
19
21
   
@@ -21,55 +23,70 @@ npm install -g @lumen.js/cli
21
23
  ## USAGE
22
24
  Create A New Project
23
25
  ```
24
- lu create My Project Name
26
+ lm create My Project Name
25
27
  ```
28
+ You can use lu, lm, or lumen as a command.
26
29
 
27
30
   
28
31
 
29
32
  Run The Project
30
33
  ```
31
- lu serve
34
+ lm serve
32
35
  ```
33
36
 
34
37
   
35
38
 
36
39
  Create A View
37
40
  ```
38
- lu create -v myview
41
+ lm create -v myview
39
42
  ```
40
43
 
41
44
   
42
45
 
43
46
  Create A Sub View
44
47
  ```
45
- lu create -s mysubview
48
+ lm create -s mysubview
46
49
  ```
47
50
 
48
51
   
49
52
 
50
53
  Create A Component Template
51
54
  ```
52
- lu create -c mycomponent
55
+ lm create -c mycomponent
53
56
  ```
54
57
 
55
58
   
56
59
 
57
60
  Purge Offline Cache Files (For Offline Usage)
58
61
  ```
59
- lu purge
62
+ lm purge
60
63
  ```
61
64
 
62
65
   
63
66
 
64
67
  Build A Dist For Production Version + NodeJs Server
65
68
  ```
66
- lu build
69
+ lm build
70
+ ```
71
+
72
+  
73
+
74
+ Build A Dist For Production Version + NodeJs Server & Deploy It Directly
75
+ ```
76
+ lm build --deploy
67
77
  ```
68
78
 
69
79
   
70
80
 
71
81
  Build A Dist For Production Version without NodeJs Server
72
82
  ```
73
- lu build --no-server
83
+ lm build --serverless
84
+ ```
85
+
86
+  
87
+
88
+ Build A Dist For Production Version without NodeJs Server & Deploy It Directly
89
+ ```
90
+ lm build --serverless --deploy
74
91
  ```
75
92
 
package/index.js CHANGED
@@ -2,6 +2,9 @@ const nodemon = require('nodemon');
2
2
  const axios = require('axios').default;
3
3
  const path = require('path');
4
4
  const fs = require("fs");
5
+ const FtpDeploy = require("ftp-deploy");
6
+ const ftpDeploy = new FtpDeploy();
7
+
5
8
  // const { exec } = require("child_process");
6
9
  const fcs = require("./lib/fcs.js");
7
10
  var UglifyJS = require('uglify-js');
@@ -56,112 +59,176 @@ function processCommands(cmd) {
56
59
  var API = fcs.API;
57
60
 
58
61
  async function buildProject(cmds) {
59
- var projectPath = `${process.cwd()}`;
60
- var dest = projectPath + path.sep + 'dist';
61
62
 
62
- let _views = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `views` + path.sep);
63
- let _comps = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `comps` + path.sep);
64
- var config = fcs.getConfig();
63
+ import('ora').then(async ({ default: ora, oraPromise: oraPromise }) => {
64
+ const spinner = ora({
65
+ text: 'Started Building Project For Production..',
66
+ color: 'green'
67
+ });
65
68
 
66
- var indexCode = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "index.html", "utf8");
69
+ spinner.succeed('Started Building Project For Production').start('Gathering Required Resources..');
67
70
 
71
+ var projectPath = `${process.cwd()}`;
72
+ var dest = projectPath + path.sep + 'dist';
68
73
 
74
+ let _views = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `views` + path.sep);
75
+ let _comps = fcs.getAllFiles(`${process.cwd()}` + path.sep + `src` + path.sep + `comps` + path.sep);
76
+ var config = fcs.getConfig();
69
77
 
70
- var beaCSSCode = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "css" + path.sep + "bea.css", "utf8");
71
- var beaCode2 = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "index.js", "utf8");
78
+ var indexCode = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "index.html", "utf8");
72
79
 
73
- if (cmds.indexOf('--no-server') >= 0) {
74
- var beaCode = "";
75
80
 
76
- let r = await API.post("/beajs", {
77
- "data": JSON.stringify(config.apis)
78
- });
79
81
 
80
- let token_ = r.token;
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");
81
84
 
82
- if (token_ == "") {
83
- console.log("Error in making a unique token for your project!")
85
+ var kkk = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "js" + path.sep + "bea.js", "utf8");
86
+ spinner.succeed("Gathering Required Resources");
87
+ var beaCode = "";
88
+ if (cmds.indexOf('--serverless') >= 0) {
89
+ spinner.start('Getting Token From Server..');
84
90
 
85
- console.log("Error in making a build! Try again later.")
86
- return;
87
- } else {
88
- // make the build happen :)
89
- }
91
+ let r = await API.post("/beajs", {
92
+ "data": JSON.stringify(config.apis)
93
+ });
90
94
 
91
- beaCode += `
95
+ let token_ = r.token;
96
+
97
+ if (token_ == "") {
98
+ spinner.fail("Error getting a unique token for your project!");
99
+ spinner.fail("Build Failed! Try again later.");
100
+ return;
101
+ } else {
102
+ // make the build happen :)
103
+ }
104
+
105
+ beaCode += `
92
106
  let _beaTn = "` + token_ + `";
93
107
  `;
94
- let kkk = await axios.get(BEA_Libs.BEAJS + "/prod");
95
- beaCode += kkk.data;
96
- } else {
97
- var beaCode = fs.readFileSync(projectPath + path.sep + `src` + path.sep + "js" + path.sep + "bea.js", "utf8");
98
- }
108
+ // let kkk = await axios.get(BEA_Libs.BEAJS + "/prod");
109
+ // beaCode += kkk.data;
110
+ }
111
+ beaCode += kkk;
112
+ spinner.start('Packing & Cleaning...');
99
113
 
100
- beaCode += `
114
+ beaCode += `
101
115
  var _vcData = {
102
116
  "views": `+ JSON.stringify(_views) + `,
103
117
  "comps": `+ JSON.stringify(_comps) + `
104
118
  };
105
119
  `;
106
- beaCode += `
120
+ beaCode += `
107
121
  ` + beaCode2 + `
108
122
  `;
109
- var js2 = `
123
+ var js2 = `
110
124
  exports.config = `+ JSON.stringify(config) + `;
111
125
  `;
112
126
 
113
- let zode = UglifyJS.minify(beaCode, {
114
- mangle: {
115
- reserved: ['_vcdata']
116
- }
117
- });
118
- let zode2 = UglifyJS.minify(js2, {
119
- mangle: {
120
- reserved: ['_vcdata']
121
- },
122
- output: {
123
- beautify: true
124
- }
125
- });
126
-
127
- fcs.rd(dest);
128
-
129
- let buildPath = `build`;
130
- if (cmds.indexOf('--no-server') >= 0) {
131
-
132
- buildPath = `build_serverless`;
133
-
134
- fcs.copyDir(`${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + buildPath, dest);
135
- fcs.copyDir(projectPath + path.sep + "src", dest, "_beajsBuild");
136
- fcs.cd(dest + path.sep + "js");
137
- fcs.cd(dest + path.sep + "css");
138
- fcs.cd(dest + path.sep + "images");
127
+ let zode = UglifyJS.minify(beaCode, {
128
+ mangle: {
129
+ reserved: ['_vcdata']
130
+ }
131
+ });
132
+ let zode2 = UglifyJS.minify(js2, {
133
+ mangle: {
134
+ reserved: ['_vcdata']
135
+ },
136
+ output: {
137
+ beautify: true
138
+ }
139
+ });
139
140
 
140
- // fcs.copyDir(projectPath + path.sep + `src` + path.sep + `css`, dest + path.sep + "css");
141
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "js", dest + path.sep + "js", "_beajsBuild");
142
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "css", dest + path.sep + "css", "_beajsBuild");
143
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "images", dest + path.sep + "images", "_beajsBuild");
141
+ fcs.rd(dest);
142
+
143
+ spinner.succeed("Packing & Cleaning").start('Writing Files...');
144
+ let buildPath = `build`;
145
+ if (cmds.indexOf('--serverless') >= 0) {
146
+
147
+ buildPath = `build_serverless`;
148
+
149
+ fcs.copyDir(`${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + buildPath, dest);
150
+ fcs.copyDir(projectPath + path.sep + "src", dest, "_beajsBuild");
151
+ fcs.cd(dest + path.sep + "js");
152
+ fcs.cd(dest + path.sep + "css");
153
+ fcs.cd(dest + path.sep + "images");
154
+
155
+ // fcs.copyDir(projectPath + path.sep + `src` + path.sep + `css`, dest + path.sep + "css");
156
+ fcs.copyDir(projectPath + path.sep + "src" + path.sep + "js", dest + path.sep + "js", "_beajsBuild");
157
+ fcs.copyDir(projectPath + path.sep + "src" + path.sep + "css", dest + path.sep + "css", "_beajsBuild");
158
+ fcs.copyDir(projectPath + path.sep + "src" + path.sep + "images", dest + path.sep + "images", "_beajsBuild");
159
+
160
+ fs.writeFileSync(dest + path.sep + "js" + path.sep + "bea.js", String(zode.code));
161
+ fs.writeFileSync(dest + path.sep + "css" + path.sep + "bea.css", String(beaCSSCode));
162
+ fs.writeFileSync(dest + path.sep + "index.html", String(indexCode).split('<script src="/index.js" type="text/javascript"></script>').join(""));
163
+
164
+
165
+ if (cmds.indexOf('--deploy') >= 0) {
166
+ spinner.succeed('Writing Files').start('Uploading To Server..');
167
+ const _config = {
168
+ user: config.ftp.username,
169
+ // Password optional, prompted if none given
170
+ password: config.ftp.password,
171
+ host: config.ftp.host,
172
+ port: config.ftp.port,
173
+ localRoot: dest,
174
+ remoteRoot: config.ftp.remotePath,
175
+ include: ["*", "**/*", ".*"], // this would upload everything except dot files
176
+ // include: ["*.js", "dist/*", ".*"],
177
+ // e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
178
+ exclude: config.ftp.ignore,
179
+ // delete ALL existing files at destination before uploading, if true
180
+ deleteRemote: false,
181
+ // Passive mode is forced (EPSV command is not sent)
182
+ forcePasv: true,
183
+ // use sftp or ftp
184
+ sftp: false,
185
+ };
186
+ // console.log(_config);
187
+
188
+ ftpDeploy.deploy(_config, function (err, res) {
189
+ if (err) {
190
+ console.log(err);
191
+ } else {
192
+ spinner.succeed("Finished Uploading To Server");
193
+ spinner.succeed("Done");
194
+ }
195
+ });
196
+ ftpDeploy.on("uploading", function (data) {
197
+ spinner.start(((data.transferredFileCount) * 100 / data.totalFilesCount) + '% ' + 'Uploading ' + data.filename + ' ');
198
+ });
199
+ // ftpDeploy.on("uploaded", function (data) {
200
+ // console.log(data); // same data as uploading event
201
+ // });
202
+ // ftpDeploy.on("log", function (data) {
203
+ // console.log(data); // same data as uploading event
204
+ // });
205
+ // ftpDeploy.on("upload-error", function (data) {
206
+ // console.log(data.err); // data will also include filename, relativePath, and other goodies
207
+ // });
208
+
209
+ } else
210
+ spinner.succeed('Writing Files').succeed("Done");
211
+ } else {
212
+ fcs.copyDir(`${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + buildPath, dest);
213
+ fcs.copyDir(projectPath + path.sep + "src", dest + path.sep + "src", "_beajsBuild");
214
+ fcs.cd(dest + path.sep + "src" + path.sep + "js");
215
+ fcs.cd(dest + path.sep + "src" + path.sep + "css");
216
+ fcs.cd(dest + path.sep + "src" + path.sep + "images");
217
+
218
+ // fcs.copyDir(projectPath + path.sep + `src` + path.sep + `css`, dest + path.sep + "src" + path.sep + "css");
219
+ fcs.copyDir(projectPath + path.sep + "src" + path.sep + "js", dest + path.sep + "src" + path.sep + "js", "_beajsBuild");
220
+ fcs.copyDir(projectPath + path.sep + "src" + path.sep + "css", dest + path.sep + "src" + path.sep + "css", "_beajsBuild");
221
+ fcs.copyDir(projectPath + path.sep + "src" + path.sep + "images", dest + path.sep + "src" + path.sep + "images", "_beajsBuild");
222
+
223
+ fs.writeFileSync(dest + path.sep + "src" + path.sep + "js" + path.sep + "bea.js", String(zode.code));
224
+ fs.writeFileSync(dest + path.sep + "src" + path.sep + "css" + path.sep + "bea.css", String(beaCSSCode));
225
+ fs.writeFileSync(dest + path.sep + "src" + path.sep + "index.html", String(indexCode).split('<script src="/index.js" type="text/javascript"></script>').join(""));
226
+ fs.writeFileSync(dest + path.sep + "config.js", String(zode2.code));
227
+
228
+ spinner.succeed('Writing Files').succeed("Done");
229
+ }
144
230
 
145
- fs.writeFileSync(dest + path.sep + "js" + path.sep + "bea.js", String(zode.code));
146
- fs.writeFileSync(dest + path.sep + "css" + path.sep + "bea.css", String(beaCSSCode));
147
- fs.writeFileSync(dest + path.sep + "index.html", String(indexCode).split('<script src="/index.js" type="text/javascript"></script>').join(""));
148
- } else {
149
- fcs.copyDir(`${__dirname}` + path.sep + `lib` + path.sep + `files` + path.sep + buildPath, dest);
150
- fcs.copyDir(projectPath + path.sep + "src", dest + path.sep + "src", "_beajsBuild");
151
- fcs.cd(dest + path.sep + "src" + path.sep + "js");
152
- fcs.cd(dest + path.sep + "src" + path.sep + "css");
153
- fcs.cd(dest + path.sep + "src" + path.sep + "images");
154
-
155
- // fcs.copyDir(projectPath + path.sep + `src` + path.sep + `css`, dest + path.sep + "src" + path.sep + "css");
156
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "js", dest + path.sep + "src" + path.sep + "js", "_beajsBuild");
157
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "css", dest + path.sep + "src" + path.sep + "css", "_beajsBuild");
158
- fcs.copyDir(projectPath + path.sep + "src" + path.sep + "images", dest + path.sep + "src" + path.sep + "images", "_beajsBuild");
159
-
160
- fs.writeFileSync(dest + path.sep + "src" + path.sep + "js" + path.sep + "bea.js", String(zode.code));
161
- fs.writeFileSync(dest + path.sep + "src" + path.sep + "css" + path.sep + "bea.css", String(beaCSSCode));
162
- fs.writeFileSync(dest + path.sep + "src" + path.sep + "index.html", String(indexCode).split('<script src="/index.js" type="text/javascript"></script>').join(""));
163
- fs.writeFileSync(dest + path.sep + "config.js", String(zode2.code));
164
- }
231
+ });
165
232
 
166
233
  }
167
234
 
@@ -1,51 +1,70 @@
1
1
  {
2
- "version": "1.0.0.1",
3
- "server": {
4
- "host": "127.0.0.1",
5
- "port": "3000",
6
- "ssl": {
7
- "enabled": false,
8
- "key": "/key.pem",
9
- "cert": "/certificate.cer"
10
- }
11
- },
12
- "project_info": {
13
- "Title": "PROJECT_TITLE",
14
- "Description": "PROJECT_DESCRIPTION",
15
- "Keywords": "website,search,tags,goes,here",
16
- "WebsiteURL": "https://www.example.com/",
17
- "Favicon": "/images/favicon.ico",
18
- "SocialMedia": {
19
- "LI": "https://www.linkedin.com/",
20
- "IG": "https://www.instagram.com/",
21
- "FB": "https://www.facebook.com/"
22
- },
23
- "MetaTags": {
24
- "og:url": "https://www.example.com/",
25
- "og:title": "PROJECT_TITLE",
26
- "og:type": "business.business",
27
- "og:site_name": "PROJECT_TITLE",
28
- "fb:admins": "592515154",
29
- "fb:app_id": "138025696270006",
30
- "og:description": "PROJECT_TITLE",
31
- "og:image": "/images/example.png",
32
- "business:contact_data:street_address": "Street Address.",
33
- "business:contact_data:locality": "Tripoli",
34
- "business:contact_data:postal_code": "1300",
35
- "business:contact_data:country_name": "Lebanon",
36
- "business:contact_data:email": "info@example.com",
37
- "business:contact_data:phone_number": "+96171299411",
38
- "business:contact_data:fax_number": "+96171299411",
39
- "business:contact_data:website": "https://www.example.com/"
40
- }
41
- },
42
- "apis": [
43
- {
44
- "baseURL": "https://api.backendadmin.com/1",
45
- "headers": {
46
- "X-BEA-Application-ID": "YOUR_APPLICATION_ID",
47
- "X-BEA-Authorization": "YOUR_REST_API_KEY"
48
- }
49
- }
50
- ]
2
+ "version": "1.0.0.1",
3
+ "server": {
4
+ "host": "127.0.0.1",
5
+ "port": "3000",
6
+ "ssl": {
7
+ "enabled": false,
8
+ "key": "/key.pem",
9
+ "cert": "/certificate.cer"
10
+ }
11
+ },
12
+ "project_info": {
13
+ "Title": "PROJECT_TITLE",
14
+ "Description": "PROJECT_DESCRIPTION",
15
+ "Keywords": "website,search,tags,goes,here",
16
+ "WebsiteURL": "https://www.example.com/",
17
+ "Favicon": "/images/favicon.ico",
18
+ "SocialMedia": {
19
+ "LI": "https://www.linkedin.com/",
20
+ "IG": "https://www.instagram.com/",
21
+ "FB": "https://www.facebook.com/"
22
+ },
23
+ "MetaTags": {
24
+ "og:url": "https://www.example.com/",
25
+ "og:title": "PROJECT_TITLE",
26
+ "og:type": "business.business",
27
+ "og:site_name": "PROJECT_TITLE",
28
+ "fb:admins": "592515154",
29
+ "fb:app_id": "138025696270006",
30
+ "og:description": "PROJECT_TITLE",
31
+ "og:image": "/images/example.png",
32
+ "business:contact_data:street_address": "Street Address.",
33
+ "business:contact_data:locality": "Tripoli",
34
+ "business:contact_data:postal_code": "1300",
35
+ "business:contact_data:country_name": "Lebanon",
36
+ "business:contact_data:email": "info@example.com",
37
+ "business:contact_data:phone_number": "+96171299411",
38
+ "business:contact_data:fax_number": "+96171299411",
39
+ "business:contact_data:website": "https://www.example.com/"
40
+ }
41
+ },
42
+ "apis": [
43
+ {
44
+ "baseURL": "https://api.backendadmin.com/1",
45
+ "headers": {
46
+ "X-BEA-Application-ID": "YOUR_APPLICATION_ID",
47
+ "X-BEA-Authorization": "YOUR_REST_API_KEY"
48
+ }
49
+ }
50
+ ],
51
+ "ftp": {
52
+ "host": "ftp_host",
53
+ "username": "ftp_username",
54
+ "password": "ftp_password",
55
+ "remotePath": "/",
56
+ "concurrency": 4,
57
+ "protocol": "ftp",
58
+ "port": 21,
59
+ "ignore": [
60
+ "index.html"
61
+ ],
62
+ "syncOption": {
63
+ "delete": false,
64
+ "ignoreExisting": false,
65
+ "skipCreate": false,
66
+ "update": true
67
+ },
68
+ "connectTimeout": 30000
69
+ }
51
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmjs/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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": {
@@ -37,13 +37,15 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "axios": "^0.27.2",
40
+ "compression": "^1.7.4",
40
41
  "cookie-parser": "^1.4.6",
41
42
  "cssnano": "^5.1.11",
42
43
  "express": "^4.18.1",
43
44
  "express-session": "^1.17.3",
44
- "compression": "^1.7.4",
45
+ "ftp-deploy": "^2.4.3",
45
46
  "multer": "^1.4.5-lts.1",
46
47
  "nodemon": "^2.0.16",
48
+ "ora": "^6.1.2",
47
49
  "semver": "^7.3.7",
48
50
  "socket.io": "^4.5.1",
49
51
  "uglify-js": "^3.16.0"
@@ -60,5 +62,9 @@
60
62
  "name": "BEA Technology Company",
61
63
  "email": "info@bea.com.lb"
62
64
  },
63
- "license": "MIT"
65
+ "license": "MIT",
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/bea-company/lmjs-cli.git"
69
+ }
64
70
  }