qcobjects-cli 2.3.29 → 2.3.42

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/.gitlab-ci.yml ADDED
@@ -0,0 +1,15 @@
1
+ image: node:latest
2
+
3
+ stages:
4
+ - deploy
5
+
6
+ deploy:
7
+ stage: deploy
8
+ rules:
9
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_REF_NAME =~ /^v\d+\.\d+\.\d+.*$/
10
+ changes:
11
+ - package.json
12
+ script:
13
+ - echo "registry=https://registry.npmjs.org/:_authToken=${NPM_TOKEN}">.npmrc
14
+ - npm ci
15
+ - npm publish
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.29
1
+ 2.3.42
@@ -21,7 +21,7 @@
21
21
  *
22
22
  * Everyone is permitted to copy and distribute verbatim copies of this
23
23
  * license document, but changing it is not allowed.
24
- */
24
+ */
25
25
  /*eslint no-unused-vars: "off"*/
26
26
  /*eslint no-redeclare: "off"*/
27
27
  /*eslint no-empty: "off"*/
@@ -36,88 +36,136 @@ const absolutePath = path.resolve(__dirname, "./");
36
36
  const mime = require("mime");
37
37
 
38
38
  Package("com.qcobjects.backend.microservice.static", [
39
- Class("Microservice",BackendMicroservice,{
39
+ Class("Microservice", BackendMicroservice, {
40
40
  finishWithBody: function(stream) {},
41
- done: function () {
41
+ done: function() {
42
42
  // read and send file content in the stream
43
43
 
44
44
  let microservice = this;
45
45
  let stream = microservice.stream;
46
46
  let fileName = `${process.cwd()}/${microservice.fileName}`;
47
- try {
48
- logger.info(`Delivering static file... ${fileName}`);
49
- const fd = fs.openSync(fileName, "r");
50
- const stat = fs.fstatSync(fd);
51
- const headers = {
52
- "content-length": stat.size,
53
- "last-modified": stat.mtime.toUTCString(),
54
- "content-type": mime.getType(fileName)
55
- };
56
- console.log(fd);
57
- try {
58
- stream.respondWithFD(fd, headers);
59
- } catch (e){
60
- logger.debug("Something went wrong while sending headers...");
61
- }
62
- stream.on("close", () => {
63
- logger.info("closing file "+ fileName);
64
- fs.closeSync(fd);
65
- });
66
- stream.end();
67
47
 
68
- } catch (e){
69
- logger.debug("ERROR NOT FOUND");
70
- if (e.errno==-2){
71
- const headers = {
72
- ":status": 404,
73
- "content-type": "text/html"
48
+ const sendFileHTTP2 = function(stream, fileName) {
49
+ // read and send file content in the stream
50
+
51
+ try {
52
+ const fd = fs.openSync(fileName, "r");
53
+ const stat = fs.fstatSync(fd);
54
+ let headers = {
55
+ "content-length": stat.size,
56
+ "last-modified": stat.mtime.toUTCString(),
57
+ "content-type": mime.getType(fileName),
58
+ "cache-control": CONFIG.get("cacheControl", "max-age=31536000")
74
59
  };
75
- stream.write("<h1>404 - FILE NOT FOUND</h1>");
60
+ if (typeof microservice.route.responseHeaders !== "undefined") {
61
+ headers = Object.assign(headers, microservice.route.responseHeaders);
62
+ console.log(headers);
63
+ }
64
+
65
+ stream.respondWithFD(fd, headers);
76
66
  stream.on("close", () => {
77
- logger.debug("file not found "+ fileName);
78
- logger.info("closing file "+ fileName);
67
+ logger.debug("closing file " + fileName);
68
+ fs.closeSync(fd);
79
69
  });
80
70
  stream.end();
81
- } else {
82
- console.log(e);
83
- const headers = {
84
- ":status": 500,
85
- "content-type": "text/html"
71
+
72
+ } catch (e) {
73
+ logger.debug("[ERROR] something went wrong when trying to send the response as file " + fileName);
74
+ if (e.errno == -2) {
75
+ const headers = {
76
+ ":status": 404,
77
+ "content-type": mime.getType(fileName)
78
+ };
79
+ stream.respond(headers);
80
+ stream.write("<h1>404 - FILE NOT FOUND</h1>");
81
+ stream.on("close", () => {
82
+ logger.debug("closing file " + fileName);
83
+ });
84
+ stream.end();
85
+ }
86
+ }
87
+
88
+ };
89
+
90
+ const sendFileLegacyHTTP = function(stream, fileName) {
91
+ // read and send file content in the stream
92
+ let headers;
93
+ try {
94
+ console.log("trying to read "+ fileName);
95
+ const fd = fs.openSync(fileName, "r");
96
+ const stat = fs.fstatSync(fd);
97
+ headers = {
98
+ "Content-Length": stat.size,
99
+ "Last-Modified": stat.mtime.toUTCString(),
100
+ "Content-Type": mime.getType(fileName),
101
+ "Cache-Control": CONFIG.get("cacheControl", "max-age=31536000")
86
102
  };
87
- stream.write("<h1>500 - INTERNAL ERROR</h1>");
103
+ if (typeof microservice.route.responseHeaders !== "undefined") {
104
+ headers = Object.assign(headers, microservice.route.responseHeaders);
105
+ console.log(headers);
106
+ }
107
+
108
+ logger.debug("closing file " + fileName);
109
+ fs.closeSync(fd);
110
+
111
+ stream.writeHead(200, headers);
112
+
113
+ stream.write(fs.readFileSync(fileName));
88
114
  stream.on("close", () => {
89
- logger.debug("internal error "+ fileName);
90
- logger.info("closing file "+ fileName);
115
+ console.log("closing static file", fileName);
91
116
  });
117
+
118
+ } catch (e){
119
+ if (e.errno==-2){
120
+ headers = {
121
+ ":status": 404,
122
+ "Content-Type": "text/html"
123
+ };
124
+ stream.writeHead(404, headers);
125
+ stream.write("<h1>404 - FILE NOT FOUND</h1>");
126
+ stream.on("close", () => {
127
+ console.log("closing static file with error: ", fileName);
128
+ });
129
+ }
130
+ console.log(e);
92
131
  stream.end();
93
132
  }
133
+ stream.end();
134
+
135
+ };
136
+
137
+ if (typeof stream.respondWithFD !== "undefined") {
138
+ sendFileHTTP2(stream, fileName);
139
+ } else {
140
+ sendFileLegacyHTTP(stream, fileName);
94
141
  }
142
+
95
143
  },
96
- static: function (method,data){
144
+ static: function(method, data) {
97
145
  var microservice = this;
98
146
  var redirect_to = microservice.route.redirect_to;
99
- return new Promise (function (resolve,reject){
147
+ return new Promise(function(resolve, reject) {
100
148
  var supported_methods = microservice.route.supported_methods;
101
149
  var _method_allowed_ = false;
102
- if (typeof supported_methods !== "undefined"){
103
- if (supported_methods =="*" || (typeof method == "undefined") || [...supported_methods].map(m=>m.toLowerCase()).indexOf(method.toLowerCase())!== -1){
150
+ if (typeof supported_methods !== "undefined") {
151
+ if (supported_methods == "*" || (typeof method == "undefined") || [...supported_methods].map(m => m.toLowerCase()).indexOf(method.toLowerCase()) !== -1) {
104
152
  _method_allowed_ = true;
105
153
  }
106
154
  } else {
107
155
  _method_allowed_ = true;
108
156
  }
109
157
 
110
- logger.debug("Starting static delivery microservice call for method: "+method);
111
- if (_method_allowed_){
158
+ logger.debug("Starting static delivery microservice call for method: " + method);
159
+ if (_method_allowed_) {
112
160
  logger.info("I'm going to deliver a static path...");
113
- if (redirect_to){
161
+ if (redirect_to) {
114
162
  let request_path = microservice.request.path;
115
- let re = (new RegExp(microservice.route.path.replace( /{(.*?)}/g,"\(\?\<$1\>\.\*\)" ),"g"));
116
- microservice.fileName = request_path.replace(re,microservice.route.redirect_to);
163
+ let re = (new RegExp(microservice.route.path.replace(/{(.*?)}/g, "\(\?\<$1\>\.\*\)"), "g"));
164
+ microservice.fileName = request_path.replace(re, microservice.route.redirect_to);
117
165
  try {
118
166
  resolve();
119
- } catch (e){
120
- console.log("\u{1F926} Something went wrong \u{1F926} when trying to deliver a static path: "+microservice.fileName);
167
+ } catch (e) {
168
+ console.log("\u{1F926} Something went wrong \u{1F926} when trying to deliver a static path: " + microservice.fileName);
121
169
  reject();
122
170
  }
123
171
  } else {
@@ -125,7 +173,7 @@ Package("com.qcobjects.backend.microservice.static", [
125
173
  reject();
126
174
  }
127
175
  } else {
128
- logger.debug("Method: "+method+" will be skipped");
176
+ logger.debug("Method: " + method + " will be skipped");
129
177
  resolve();
130
178
  }
131
179
 
@@ -133,64 +181,64 @@ Package("com.qcobjects.backend.microservice.static", [
133
181
  },
134
182
  head: function(formData) {
135
183
  var microservice = this;
136
- microservice.static("head",formData).then(response=>{
137
- microservice.body=response;
184
+ microservice.static("head", formData).then(response => {
185
+ microservice.body = response;
138
186
  microservice.done();
139
187
  });
140
188
  },
141
- get: function(formData){
189
+ get: function(formData) {
142
190
  var microservice = this;
143
- microservice.static("get",formData).then(response=>{
144
- microservice.body=response;
191
+ microservice.static("get", formData).then(response => {
192
+ microservice.body = response;
145
193
  microservice.done();
146
194
  });
147
195
  },
148
- post:function (formData){
196
+ post: function(formData) {
149
197
  var microservice = this;
150
- microservice.static("post",formData).then(response=>{
151
- microservice.body=response;
198
+ microservice.static("post", formData).then(response => {
199
+ microservice.body = response;
152
200
  microservice.done();
153
201
  });
154
202
  },
155
203
  put: function(formData) {
156
204
  var microservice = this;
157
- microservice.static("put",formData).then(response=>{
158
- microservice.body=response;
205
+ microservice.static("put", formData).then(response => {
206
+ microservice.body = response;
159
207
  microservice.done();
160
208
  });
161
209
  },
162
210
  delete: function(formData) {
163
211
  var microservice = this;
164
- microservice.static("delete",formData).then(response=>{
165
- microservice.body=response;
212
+ microservice.static("delete", formData).then(response => {
213
+ microservice.body = response;
166
214
  microservice.done();
167
215
  });
168
216
  },
169
217
  connect: function(formData) {
170
218
  var microservice = this;
171
- microservice.static("connect",formData).then(response=>{
172
- microservice.body=response;
219
+ microservice.static("connect", formData).then(response => {
220
+ microservice.body = response;
173
221
  microservice.done();
174
222
  });
175
223
  },
176
224
  options: function(formData) {
177
225
  var microservice = this;
178
- microservice.static("options",formData).then(response=>{
179
- microservice.body=response;
226
+ microservice.static("options", formData).then(response => {
227
+ microservice.body = response;
180
228
  microservice.done();
181
229
  });
182
230
  },
183
231
  trace: function(formData) {
184
232
  var microservice = this;
185
- microservice.static("trace",formData).then(response=>{
186
- microservice.body=response;
233
+ microservice.static("trace", formData).then(response => {
234
+ microservice.body = response;
187
235
  microservice.done();
188
236
  });
189
237
  },
190
238
  patch: function(formData) {
191
239
  var microservice = this;
192
- microservice.static("patch",formData).then(response=>{
193
- microservice.body=response;
240
+ microservice.static("patch", formData).then(response => {
241
+ microservice.body = response;
194
242
  microservice.done();
195
243
  });
196
244
  }
@@ -0,0 +1,184 @@
1
+ /**
2
+ * QCObjects CLI 2.3.x
3
+ * ________________
4
+ *
5
+ * Author: Jean Machuca <correojean@gmail.com>
6
+ *
7
+ * Cross Browser Javascript Framework for MVC Patterns
8
+ * QuickCorp/QCObjects is licensed under the
9
+ * GNU Lesser General Public License v3.0
10
+ * [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
11
+ *
12
+ * Permissions of this copyleft license are conditioned on making available
13
+ * complete source code of licensed works and modifications under the same
14
+ * license or the GNU GPLv3. Copyright and license notices must be preserved.
15
+ * Contributors provide an express grant of patent rights. However, a larger
16
+ * work using the licensed work through interfaces provided by the licensed
17
+ * work may be distributed under different terms and without source code for
18
+ * the larger work.
19
+ *
20
+ * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
21
+ *
22
+ * Everyone is permitted to copy and distribute verbatim copies of this
23
+ * license document, but changing it is not allowed.
24
+ */
25
+ /*eslint no-unused-vars: "off"*/
26
+ /*eslint no-redeclare: "off"*/
27
+ /*eslint no-empty: "off"*/
28
+ /*eslint strict: "off"*/
29
+ /*eslint no-mixed-operators: "off"*/
30
+ /*eslint no-undef: "off"*/
31
+ "use strict";
32
+ const fs = require("fs");
33
+ const path = require("path");
34
+ const absolutePath = path.resolve( __dirname, "./" );
35
+ const templatePath = path.resolve( __dirname, "./templates/apps/" )+"/";
36
+ const templatePwaPath = path.resolve( __dirname, "./templates/pwa/" )+"/";
37
+ const package_config = require(absolutePath+"/package.json");
38
+ const { exec,execSync } = require("child_process");
39
+
40
+ Class ("QCObjectsEnterprise", {
41
+ install (switchCommander) {
42
+ let instance = this;
43
+ return instance.installEnterprise(license, email);
44
+ },
45
+ upgrade (switchCommander){
46
+ let instance = this;
47
+ const readline = require("readline");
48
+
49
+ const rl = readline.createInterface({
50
+ input: process.stdin,
51
+ output: process.stdout
52
+ });
53
+
54
+ var emailQuestion = function (){
55
+ rl.question(`
56
+ [NOTE: No information will be sent to a server until I got your consent]
57
+
58
+ Please tell me your e-Mail (\u{1F48C}):
59
+ `, (email) => {
60
+ const asterisk = "*";
61
+ if (email !== ""){
62
+ var phoneNumberQuestion = function (){
63
+ rl.question ("Please tell me your phone number (\u{1F919}): \n", (phonenumber) => {
64
+ if (phonenumber !== ""){
65
+ rl.question (`
66
+ Please select one of the following options (type a number):
67
+
68
+ 1.- \u{1F640} This is your first interaction \u{1F60D} with QCObjects Enterprise Edition \u{1F3E2},
69
+ you want to send your email and phone number to one of our executives to process your
70
+ inquiry, pay the license (when aplies) and receive a new fresh license number
71
+ that will free up to you the most advanced features for large companies
72
+
73
+ 2.- \u{2714} Your assigned executive \u{1F9D1} has given to you a new fresh QCObjects Enterprise Edition License Number
74
+ and you want to enter it to follow up with the next steps.
75
+
76
+ 3.- \u{1F3C3} You want to quit this form, as you got here accidentally
77
+ (You should think about it. It's not a coincidence, It's destiny \u{1F600}).
78
+
79
+ Please enter the number of the option and press [enter]: `, (interaction_option)=> {
80
+ logger.infoEnabled=true;
81
+
82
+ switch (interaction_option) {
83
+ case "1":
84
+ switchCommander.register(email,phonenumber).then(function (response){
85
+ logger.info(`\u{1F44F} Congrats! You have been successfully registered to the cloud! \u{1F44F}
86
+ One of our executives will be in touch with you as soon as possible to give you the next steps
87
+ to get a new License Number and start using QCObjects Entrprise Edition!
88
+
89
+ (In the meantime, you can continue using all the features of the QCObjects Community Edition)
90
+ `);
91
+ rl.close();
92
+ }).catch ((e)=>{
93
+ rl.close();
94
+ });
95
+ break;
96
+ case "2":
97
+ rl.stdoutMuted = true;
98
+ rl._writeToOutput = function _writeToOutput(stringToWrite) {
99
+ if (rl.stdoutMuted)
100
+ rl.output.write("*");
101
+ else
102
+ rl.output.write(stringToWrite);
103
+ };
104
+ rl.question("Please tell me the number of license that your executive has given to you: \n", (license) => {
105
+ rl.stdoutMuted = false;
106
+ instance.installEnterprise(license, email);
107
+
108
+ rl.close();
109
+ });
110
+
111
+ break;
112
+ default:
113
+ logger.info("\u{1F937} You can continue to use QCObjects Community Edition, see you! \u{1F64B} ");
114
+ rl.close();
115
+ break;
116
+ }
117
+
118
+ });
119
+
120
+ } else {
121
+ console.log(`You need to enter a Phone Number if you want to be contacted.
122
+ If you want to quit, press Ctrl-C.
123
+ `);
124
+ phoneNumberQuestion();
125
+ }
126
+ });
127
+ };
128
+ phoneNumberQuestion();
129
+
130
+ } else {
131
+ console.log(`You need to enter a real e-Mail adress if you want to be contacted.
132
+ If you want to quit, press Ctrl-C.
133
+ `);
134
+ emailQuestion();
135
+ }
136
+ });
137
+
138
+ };
139
+ emailQuestion();
140
+
141
+ },
142
+ installEnterprise (license, email) {
143
+ const asterisk = "*";
144
+ var license = CONFIG.get("enterprise-license", license);
145
+ var email = CONFIG.get("enterprise-email", email);
146
+
147
+ logger.info(`Your entered license number is ${asterisk.repeat(license.length)} and the email that you have entered is ${email}`);
148
+ logger.info("Now, I'm installing QCObjects Enterprise Edition in your computer...");
149
+ let cmdDownloadGit = `npm i --force -g git+https://license:${license}@software.qcobjects.io/qcobjects-enterprise/qcobjects-enterprise.git`;
150
+ exec(cmdDownloadGit,(err,stdout,stderr)=>{
151
+ if(!err){
152
+ exec("qcobjects --version",(err,stdout,stderr)=>{
153
+ if (stdout.lastIndexOf("Enterprise Edition")!==-1){
154
+ logger.info("\u{1F44F} Congrats! Now you have installed QCObjects Entrprise Edition! \u{1F44F}");
155
+ logger.info(`You can test it using:
156
+ > qcobjects --version
157
+
158
+ To find more help, type the command:
159
+
160
+ > qcobjects --help
161
+
162
+ Enjoy!
163
+ `);
164
+ } else {
165
+ console.log("\u{1F926} Something went wrong \u{1F926} when trying to update your license to QCObjects Enterprise Edition");
166
+ console.log("Ask your executive to help");
167
+ }
168
+ });
169
+
170
+ } else {
171
+ console.log("\u{1F926} Something went wrong \u{1F926} when trying to update your license to QCObjects Enterprise Edition");
172
+ if (stderr.lastIndexOf("Authentication failed")!==-1){
173
+ console.log("Please ask to your executive for the right license number");
174
+ } else {
175
+ console.log(stderr);
176
+ }
177
+ }
178
+ }).stdout.on("data", function(data) {
179
+ console.log(data);
180
+ });
181
+
182
+ }
183
+
184
+ })
@@ -41,6 +41,7 @@ logger.debugEnabled=false;
41
41
  CONFIG.set("node_modules_path","./node_modules/");
42
42
  CONFIG.set("qcobjectsnewapp_path",CONFIG.get("node_modules_path")+"/qcobjectsnewapp");
43
43
 
44
+ require(absolutePath+"/org.qcobjects.enterprise.commands");
44
45
  require(absolutePath+"/org.quickcorp.qcobjects.api.client_services");
45
46
  require(absolutePath+"/org.quickcorp.qcobjects.cli.commands");
46
47
 
@@ -179,11 +180,13 @@ Package("org.quickcorp.qcobjects.cli",[
179
180
  var _dirnames = function (pathname){
180
181
  fs.readdir(pathname,{withFileTypes:true},function (err,files){
181
182
  var _pathnames = [];
182
- files.filter((f)=>{return f.isDirectory();}).map((d)=>{
183
+ if (typeof files !== "undefined"){
184
+ files.filter((f)=>{return f.isDirectory();}).map((d)=>{
183
185
  _pathnames.push(pathname+"/"+d.name);
184
186
  callback(pathname+"/"+d.name);
185
187
  _dirnames(pathname+"/"+d.name);
186
188
  });
189
+ }
187
190
  _main_pathnames = _main_pathnames.concat(_pathnames);
188
191
  });
189
192
  return _main_pathnames;
@@ -243,119 +246,222 @@ Package("org.quickcorp.qcobjects.cli",[
243
246
  rl.close();
244
247
  let giturl = answer;
245
248
 
246
- let createAppCommandCustom = "echo \
247
- { \
248
- \"name\": \""+appName.toLowerCase()+"\", \
249
- \"repository\": { \
250
- \"type\": \"git\", \
251
- \"url\": \""+giturl+`" \
252
- }, \
253
- "description": "This is a custom NPM template app from ${options.createCustom} generated with QCObjects.", \
254
- "main": "js/init.js", \
255
- "license": "LGPL-3.0-or-later", \
256
- "dependencies": { \
257
- "${options.createCustom}": "latest", \
258
- "qcobjects": "latest" \
259
- } \
260
- } > package.json`;
261
-
262
-
263
- let createAppCommandPWA = "echo \
264
- { \
265
- \"name\": \""+appName.toLowerCase()+"\", \
266
- \"repository\": { \
267
- \"type\": \"git\", \
268
- \"url\": \""+giturl+"\" \
269
- }, \
270
- \"description\": \"Awesome PWA application that will help you achieve your dreams.\", \
271
- \"main\": \"js/init.js\", \
272
- \"license\": \"LGPL-3.0-or-later\", \
273
- \"dependencies\": { \
274
- \"qcobjectsnewapp\": \"latest\", \
275
- \"qcobjects\": \"latest\" \
276
- } \
277
- } > package.json";
278
-
279
- let createAppCommandAMP = "echo \
280
- { \
281
- \"name\": \""+appName.toLowerCase()+"\", \
282
- \"repository\": { \
283
- \"type\": \"git\", \
284
- \"url\": \""+giturl+"\" \
285
- }, \
286
- \"description\": \"Awesome AMP application that will help you achieve your dreams.\", \
287
- \"main\": \"js/init.js\", \
288
- \"license\": \"LGPL-3.0-or-later\", \
289
- \"dependencies\": { \
290
- \"qcobjects-ecommerce-amp\": \"latest\", \
291
- \"qcobjects\": \"latest\" \
292
- } \
293
- } > package.json";
294
-
295
- let createAppCommandPHP = `echo \
296
- { \
297
- "name": "${appName.toLowerCase()}", \
298
- "repository": {\
299
- "type": "git",\
300
- "url": "${giturl}"\
301
- },\
302
- "description": "Awesome PHP application that will help you achieve your dreams.",\
303
- "main": "js/init.js",\
304
- "license": "LGPL-3.0-or-later",\
305
- "devDependencies": {\
306
- "jasmine": "latest",\
307
- "qcobjects-cli": "latest"\
308
- },\
309
- "dependencies": {\
310
- "qcobjectsnewphp": "latest",\
311
- "qcobjects": "latest",\
312
- "qcobjects-sdk": "latest"\
313
- }\
314
- } > package.json`;
249
+ let createAppCommandCustom = `
250
+ {
251
+ "name": "${appName.toLowerCase()}",
252
+ "version": "0.0.1",
253
+ "repository": {
254
+ "type": "git",
255
+ "url": "${giturl}"
256
+ },
257
+ "description": "This is a custom NPM template app from ${options.createCustom} generated with QCObjects.",
258
+ "main": "js/init.js",
259
+ "license": "LGPL-3.0-or-later",
260
+ "scripts": {
261
+ "test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
262
+ "sync": "git add . && git commit -am ",
263
+ "preversion": "npm i --upgrade && npm test",
264
+ "postversion": "git push && git push --tags",
265
+ "coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
266
+ "start": "node app.js",
267
+ "build": "exit 0"
268
+ },
269
+ "dependencies": {
270
+ "${options.createCustom}": "latest",
271
+ "qcobjects": "latest",
272
+ "qcobjects-sdk": "latest"
273
+ },
274
+ "devDependencies":
275
+ "eslint": "^8.2.0",
276
+ "eslint-config-qcobjects": "latest",
277
+ "jasmine": "latest",
278
+ "qcobjects-cli": "latest",
279
+ "grunt": "^1.4.1",
280
+ "grunt-contrib-jasmine": "^2.0.2",
281
+ "nyc": "^15.1.0"
282
+ }
283
+ }`;
284
+
285
+ let createAppCommandPWA = `
286
+ {
287
+ "name": "${appName.toLowerCase()}",
288
+ "version": "0.0.1",
289
+ "repository": {
290
+ "type": "git",
291
+ "url": "${giturl}"
292
+ },
293
+ "description": "Awesome PWA application that will help you achieve your dreams.",
294
+ "main": "js/init.js",
295
+ "license": "LGPL-3.0-or-later",
296
+ "scripts": {
297
+ "test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
298
+ "sync": "git add . && git commit -am ",
299
+ "preversion": "npm i --upgrade && npm test",
300
+ "postversion": "git push && git push --tags",
301
+ "coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
302
+ "start": "node app.js",
303
+ "build": "exit 0"
304
+ },
305
+ "dependencies": {
306
+ "qcobjectsnewapp": "latest",
307
+ "qcobjects": "latest",
308
+ "qcobjects-sdk": "latest"
309
+ },
310
+ "devDependencies": {
311
+ "eslint": "^8.2.0",
312
+ "eslint-config-qcobjects": "latest",
313
+ "jasmine": "latest",
314
+ "qcobjects-cli": "latest",
315
+ "grunt": "^1.4.1",
316
+ "grunt-contrib-jasmine": "^2.0.2",
317
+ "nyc": "^15.1.0"
318
+ }
319
+ }`;
320
+
321
+ let createAppCommandAMP = `echo
322
+ {
323
+ "name": "${appName.toLowerCase()}",
324
+ "version": "0.0.1",
325
+ "repository": {
326
+ "type": "git",
327
+ "url": "${giturl}"
328
+ },
329
+ "description": "Awesome AMP application that will help you achieve your dreams.",
330
+ "main": "js/init.js",
331
+ "license": "LGPL-3.0-or-later",
332
+ "scripts": {
333
+ "test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
334
+ "sync": "git add . && git commit -am ",
335
+ "preversion": "npm i --upgrade && npm test",
336
+ "postversion": "git push && git push --tags",
337
+ "coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
338
+ "start": "node app.js",
339
+ "build": "exit 0"
340
+ },
341
+ "dependencies": {
342
+ "qcobjects-ecommerce-amp": "latest",
343
+ "qcobjects": "latest",
344
+ "qcobjects-sdk": "latest"
345
+ },
346
+ "devDependencies": {
347
+ "eslint": "^8.2.0",
348
+ "eslint-config-qcobjects": "latest",
349
+ "jasmine": "latest",
350
+ "qcobjects-cli": "latest",
351
+ "grunt": "^1.4.1",
352
+ "grunt-contrib-jasmine": "^2.0.2",
353
+ "nyc": "^15.1.0"
354
+ }
355
+ }`;
356
+
357
+ let createAppCommandPHP = `
358
+ {
359
+ "name": "${appName.toLowerCase()}",
360
+ "version": "0.0.1",
361
+ "repository": {
362
+ "type": "git",
363
+ "url": "${giturl}"
364
+ },
365
+ "description": "Awesome PHP application that will help you achieve your dreams.",
366
+ "main": "js/init.js",
367
+ "license": "LGPL-3.0-or-later",
368
+ "scripts": {
369
+ "test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
370
+ "sync": "git add . && git commit -am ",
371
+ "preversion": "npm i --upgrade && npm test",
372
+ "postversion": "git push && git push --tags",
373
+ "coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
374
+ "start": "node app.js",
375
+ "build": "exit 0"
376
+ },
377
+ "dependencies": {
378
+ "qcobjectsnewphp": "latest",
379
+ "qcobjects": "latest",
380
+ "qcobjects-sdk": "latest"
381
+ },
382
+ "devDependencies": {
383
+ "eslint": "^8.2.0",
384
+ "eslint-config-qcobjects": "latest",
385
+ "jasmine": "latest",
386
+ "qcobjects-cli": "latest",
387
+ "grunt": "^1.4.1",
388
+ "grunt-contrib-jasmine": "^2.0.2",
389
+ "nyc": "^15.1.0"
390
+ }
391
+ }`;
315
392
 
316
393
  let createAppCommand;
317
394
  let appTemplateName;
395
+ let _package_json_content;
318
396
 
319
397
  if (options.createAmp){
320
398
  appTemplateName = "qcobjects-ecommerce-amp";
321
- createAppCommand = createAppCommandAMP;
399
+ _package_json_content = createAppCommandAMP;
322
400
  } else if (options.createPwa){
323
401
  appTemplateName = "qcobjectsnewapp";
324
- createAppCommand = createAppCommandPWA;
402
+ _package_json_content = createAppCommandPWA;
325
403
  } else if (options.createPhp){
326
404
  appTemplateName = "qcobjectsnewphp";
327
- createAppCommand = createAppCommandPHP;
405
+ _package_json_content = createAppCommandPHP;
328
406
  } else if (options.createCustom){
329
407
  appTemplateName = options.createCustom;
330
- createAppCommand = createAppCommandCustom;
408
+ _package_json_content = createAppCommandCustom;
331
409
  } else {
332
410
  appTemplateName = "qcobjectsnewapp";
333
- createAppCommand = createAppCommandPWA;
411
+ _package_json_content = createAppCommandPWA;
334
412
  }
335
413
  CONFIG.set("qcobjectsnewapp_path",CONFIG.get("node_modules_path")+"/"+appTemplateName);
336
- if (!process.platform.toLowerCase().startsWith("win")){
337
- createAppCommand = createAppCommand.replace(/(")/g, String.fromCharCode(92)+"\"");
338
- }
414
+ /* if (!process.platform.toLowerCase().startsWith("win")){
415
+ _package_json_content = _package_json_content.replace(/(")/g, String.fromCharCode(92)+"\"");
416
+ }*/
417
+ createAppCommand = "npm init -y";
418
+ let _package_json_file = path.resolve(CONFIG.get("projectPath"),"./package.json");
419
+ logger.debug("_package_json_file: "+_package_json_file);
339
420
  logger.debug(createAppCommand);
421
+
340
422
  exec(createAppCommand, (err, stdout, stderr) => {
341
- exec("npm cache verify && npm i --save-dev ", (err, stdout, stderr) => {
342
- Promise.resolve(switchCommander.copyTemplate()).then(()=>{
343
- logger.info("Good! Your application is getting done. You can play with QCObjects now!");
344
- logger.info("In about five seconds your server will start...");
345
- exec("qcobjects-createcert",(err,stdout,stderr)=>{
346
- logger.info("Test certificates generated");
347
- exec("npm uninstall "+appTemplateName+" --save && npm cache verify",(err,stdout,stderr)=>{
348
- switchCommander.generateServiceWorker(appName);
423
+ if (err) {
424
+ logger.warn(err);
425
+ process.exit(1);
426
+ return;
427
+ }
428
+ fs.writeFile(_package_json_file, _package_json_content, err => {
429
+ if (err) {
430
+ logger.warn(err);
431
+ process.exit(1);
432
+ return;
433
+ }
434
+
435
+ exec("npm cache verify && npm i --save-dev ", (err, stdout, stderr) => {
436
+ if (err) {
437
+ logger.warn(err);
438
+ process.exit(1);
439
+ return;
440
+ }
441
+
442
+ Promise.resolve(switchCommander.copyTemplate())
443
+ .then(()=>{
444
+ logger.info("Good! Your application is getting done. You can play with QCObjects now!");
445
+ logger.info("In about five seconds your server will start...");
446
+ exec("qcobjects-createcert",(err,stdout,stderr)=>{
447
+ logger.info("Test certificates generated");
448
+
449
+ exec("npm uninstall "+appTemplateName+" --save && npm cache verify",(err,stdout,stderr)=>{
450
+ switchCommander.generateServiceWorker(appName);
451
+ });
452
+
453
+ }).stdout.on("data", function(data) {
454
+ console.log(data);
349
455
  });
350
- }).stdout.on("data", function(data) {
351
- console.log(data);
352
456
  });
457
+ }).stdout.on("data", function(data) {
458
+ console.log(data);
353
459
  });
354
- }).stdout.on("data", function(data) {
355
- console.log(data);
460
+
356
461
  });
462
+
357
463
  }).stdout.on("data", function(data) {
358
- console.log(data);
464
+ console.log("App generation started...");
359
465
  });
360
466
 
361
467
  });
@@ -364,135 +470,9 @@ Package("org.quickcorp.qcobjects.cli",[
364
470
  publish: function (_appName){
365
471
  logger.debug("publish is not yet implemented");
366
472
  },
367
- upgradeToEnterprise: function (){
473
+ upgradeToEnterprise (){
368
474
  let switchCommander = this;
369
- const readline = require("readline");
370
-
371
- const rl = readline.createInterface({
372
- input: process.stdin,
373
- output: process.stdout
374
- });
375
-
376
- var emailQuestion = function (){
377
- rl.question(`
378
- [NOTE: No information will be sent to a server until I got your consent]
379
-
380
- Please tell me your e-Mail (\u{1F48C}):
381
- `, (email) => {
382
- const asterisk = "*";
383
- if (email !== ""){
384
- var phoneNumberQuestion = function (){
385
- rl.question ("Please tell me your phone number (\u{1F919}): \n", (phonenumber) => {
386
- if (phonenumber !== ""){
387
- rl.question (`
388
- Please select one of the following options (type a number):
389
-
390
- 1.- \u{1F640} This is your first interaction \u{1F60D} with QCObjects Enterprise Edition \u{1F3E2},
391
- you want to send your email and phone number to one of our executives to process your
392
- inquiry, pay the license (when aplies) and receive a new fresh license number
393
- that will free up to you the most advanced features for large companies
394
-
395
- 2.- \u{2714} Your assigned executive \u{1F9D1} has given to you a new fresh QCObjects Enterprise Edition License Number
396
- and you want to enter it to follow up with the next steps.
397
-
398
- 3.- \u{1F3C3} You want to quit this form, as you got here accidentally
399
- (You should think about it. It's not a coincidence, It's destiny \u{1F600}).
400
-
401
- Please enter the number of the option and press [enter]: `, (interaction_option)=> {
402
- logger.infoEnabled=true;
403
-
404
- switch (interaction_option) {
405
- case "1":
406
- switchCommander.register(email,phonenumber).then(function (response){
407
- logger.info(`\u{1F44F} Congrats! You have been successfully registered to the cloud! \u{1F44F}
408
- One of our executives will be in touch with you as soon as possible to give you the next steps
409
- to get a new License Number and start using QCObjects Entrprise Edition!
410
-
411
- (In the meantime, you can continue using all the features of the QCObjects Community Edition)
412
- `);
413
- rl.close();
414
- }).catch ((e)=>{
415
- rl.close();
416
- });
417
- break;
418
- case "2":
419
- rl.stdoutMuted = true;
420
- rl._writeToOutput = function _writeToOutput(stringToWrite) {
421
- if (rl.stdoutMuted)
422
- rl.output.write("*");
423
- else
424
- rl.output.write(stringToWrite);
425
- };
426
- rl.question("Please tell me the number of license that your executive has given to you: \n", (license) => {
427
- rl.stdoutMuted = false;
428
- logger.info(`Your entered license number is ${asterisk.repeat(license.length)} and the email that you have entered is ${email}`);
429
- logger.info("Now, I'm installing QCObjects Enterprise Edition in your computer...");
430
- let cmdDownloadGit = `npm i --force -g git+https://license:${license}@software.qcobjects.io/qcobjects-enterprise/qcobjects-enterprise.git`;
431
- exec(cmdDownloadGit,(err,stdout,stderr)=>{
432
- if(!err){
433
- exec("qcobjects --version",(err,stdout,stderr)=>{
434
- if (stdout.lastIndexOf("Enterprise Edition")!==-1){
435
- logger.info("\u{1F44F} Congrats! Now you have installed QCObjects Entrprise Edition! \u{1F44F}");
436
- logger.info(`You can test it using:
437
- > qcobjects --version
438
-
439
- To find more help, type the command:
440
-
441
- > qcobjects --help
442
-
443
- Enjoy!
444
- `);
445
- } else {
446
- console.log("\u{1F926} Something went wrong \u{1F926} when trying to update your license to QCObjects Enterprise Edition");
447
- console.log("Ask your executive to help");
448
- }
449
- });
450
-
451
- } else {
452
- console.log("\u{1F926} Something went wrong \u{1F926} when trying to update your license to QCObjects Enterprise Edition");
453
- if (stderr.lastIndexOf("Authentication failed")!==-1){
454
- console.log("Please ask to your executive for the right license number");
455
- } else {
456
- console.log(stderr);
457
- }
458
- }
459
- }).stdout.on("data", function(data) {
460
- console.log(data);
461
- });
462
-
463
- rl.close();
464
- });
465
-
466
- break;
467
- default:
468
- logger.info("\u{1F937} You can continue to use QCObjects Community Edition, see you! \u{1F64B} ");
469
- rl.close();
470
- break;
471
- }
472
-
473
- });
474
-
475
- } else {
476
- console.log(`You need to enter a Phone Number if you want to be contacted.
477
- If you want to quit, press Ctrl-C.
478
- `);
479
- phoneNumberQuestion();
480
- }
481
- });
482
- };
483
- phoneNumberQuestion();
484
-
485
- } else {
486
- console.log(`You need to enter a real e-Mail adress if you want to be contacted.
487
- If you want to quit, press Ctrl-C.
488
- `);
489
- emailQuestion();
490
- }
491
- });
492
-
493
- };
494
- emailQuestion();
495
-
475
+ QCObjectsEnterprise.upgrade(switchCommander);
496
476
  }
497
477
  },
498
478
  initCommand: function (){
@@ -101,7 +101,7 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
101
101
  let server = microservice.server;
102
102
  let request = microservice.request;
103
103
  this.cors();
104
- server.on("data", (data) => {
104
+ microservice.req.on("data", (data) => {
105
105
  // data from POST, GET
106
106
  var requestMethod = request.method.toLowerCase();
107
107
  var supportedMethods = {"post":microservice.post,
@@ -146,8 +146,12 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
146
146
  done: function(){
147
147
  var microservice = this;
148
148
  var stream = microservice.stream;
149
- // stream.respond(microservice.headers);
150
- stream.writeHead(200, {"Content-Type": "text/plain"});
149
+ try {
150
+ stream.writeHead(200, microservice.headers);
151
+ } catch (e){
152
+ logger.debug("Something went wront while sending headers in http...");
153
+ logger.debug(e.toString());
154
+ }
151
155
  if (microservice.body != null){
152
156
  microservice.finishWithBody.call(microservice,stream);
153
157
  }
@@ -191,7 +195,7 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
191
195
  "content-type": mime.getType(fileName),
192
196
  "cache-control": CONFIG.get("cacheControl", "max-age=31536000")
193
197
  };
194
- console.log("closing file", fileName);
198
+ logger.debug("closing file " + fileName);
195
199
  fs.closeSync(fd);
196
200
  stream.setHeader("content-length", headers["content-length"]);
197
201
  stream.setHeader("last-modified", headers["last-modified"]);
@@ -318,7 +322,7 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
318
322
  _new_:function (){
319
323
  let oHTTPServer = this;
320
324
  const welcometo = "Welcome to \n";
321
- const instructions = "QCObjects GAE HTTPServer \n";
325
+ const instructions = "QCObjects Legacy HTTPServer \n";
322
326
  const logo = " .d88888b. .d8888b. .d88888b. 888 d8b 888 \r\nd88P\" \"Y88bd88P Y88bd88P\" \"Y88b888 Y8P 888 \r\n888 888888 888888 888888 888 \r\n888 888888 888 88888888b. 8888 .d88b. .d8888b888888.d8888b \r\n888 888888 888 888888 \"88b \"888d8P Y8bd88P\" 888 88K \r\n888 Y8b 888888 888888 888888 888 88888888888888 888 \"Y8888b. \r\nY88b.Y8b88PY88b d88PY88b. .d88P888 d88P 888Y8b. Y88b. Y88b. X88 \r\n \"Y888888\" \"Y8888P\" \"Y88888P\" 88888P\" 888 \"Y8888 \"Y8888P \"Y888 88888P' \r\n Y8b 888 \r\n d88P \r\n 888P\" ";
323
327
  console.log(welcometo);
324
328
  console.log(logo);
@@ -329,9 +333,11 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
329
333
 
330
334
  const http = require("http");
331
335
 
332
- this.server = http.createServer((req, res) => {});
336
+ oHTTPServer.server = http.createServer((req, res) => {
333
337
 
334
- var server = this.server;
338
+ });
339
+
340
+ var server = oHTTPServer.server;
335
341
 
336
342
  server.on("error", (err) => console.error(err));
337
343
 
@@ -398,6 +404,7 @@ Package("org.quickcorp.qcobjects.main.http.gae.server",[
398
404
  routeParams:selectedRouteParams,
399
405
  server:server,
400
406
  stream:res,
407
+ req:req,
401
408
  request:request
402
409
  });
403
410
  });
@@ -101,7 +101,7 @@ Package("org.quickcorp.qcobjects.main.http.server",[
101
101
  let server = microservice.server;
102
102
  let request = microservice.request;
103
103
  this.cors();
104
- server.on("data", (data) => {
104
+ microservice.req.on("data", (data) => {
105
105
  // data from POST, GET
106
106
  var requestMethod = request.method.toLowerCase();
107
107
  var supportedMethods = {"post":microservice.post,
@@ -146,8 +146,12 @@ Package("org.quickcorp.qcobjects.main.http.server",[
146
146
  done: function(){
147
147
  var microservice = this;
148
148
  var stream = microservice.stream;
149
- // stream.respond(microservice.headers);
150
- stream.writeHead(200, {"Content-Type": "text/plain"});
149
+ try {
150
+ stream.writeHead(200, microservice.headers);
151
+ } catch (e){
152
+ logger.debug("Something went wront while sending headers in http...");
153
+ logger.debug(e.toString());
154
+ }
151
155
  if (microservice.body != null){
152
156
  microservice.finishWithBody.call(microservice,stream);
153
157
  }
@@ -329,9 +333,11 @@ Package("org.quickcorp.qcobjects.main.http.server",[
329
333
 
330
334
  const http = require("http");
331
335
 
332
- this.server = http.createServer((req, res) => {});
336
+ oHTTPServer.server = http.createServer((req, res) => {
333
337
 
334
- var server = this.server;
338
+ });
339
+
340
+ var server = oHTTPServer.server;
335
341
 
336
342
  server.on("error", (err) => console.error(err));
337
343
 
@@ -398,6 +404,7 @@ Package("org.quickcorp.qcobjects.main.http.server",[
398
404
  routeParams:selectedRouteParams,
399
405
  server:server,
400
406
  stream:res,
407
+ req:req,
401
408
  request:request
402
409
  });
403
410
  });
package/package.json CHANGED
@@ -1,20 +1,27 @@
1
1
  {
2
2
  "name": "qcobjects-cli",
3
- "version": "2.3.29",
3
+ "version": "2.3.42",
4
4
  "description": "qcobjects cli command line tool",
5
5
  "main": "qcobjects-cli.js",
6
6
  "scripts": {
7
7
  "sync": "git add . && git commit -am ",
8
8
  "test": "npx eslint **/*.js --fix && $(npm bin)/jasmine",
9
9
  "preversion": "npm i --upgrade && npm test",
10
- "postversion": "git push && git push --tags && npm publish"
10
+ "postversion": "git push && git push --tags"
11
11
  },
12
12
  "dependencies": {
13
13
  "commander": "^2.20.3",
14
14
  "mime": "^2.4.7",
15
- "qcobjects": "latest",
15
+ "qcobjects": "^2.3.66-lts",
16
16
  "qcobjects-sdk": "latest",
17
- "yaml": "^1.8.0"
17
+ "yaml": "^1.10.2"
18
+ },
19
+ "devDependencies": {
20
+ "eslint": "^8.2.0",
21
+ "eslint-config-qcobjects": "^0.0.13",
22
+ "jasmine": "^3.7.0",
23
+ "qcobjects": "^2.3.66-lts",
24
+ "qcobjects-cli": "latest"
18
25
  },
19
26
  "repository": {
20
27
  "type": "file",
@@ -54,10 +61,5 @@
54
61
  "qcobjects-gae-server": "./qcobjects-gae-http-server.js",
55
62
  "qcobjects-http-server": "./qcobjects-http-server.js",
56
63
  "qcobjects-collab": "./qcobjects-collab.js"
57
- },
58
- "devDependencies": {
59
- "eslint": "^6.8.0",
60
- "eslint-config-qcobjects": "0.0.6",
61
- "jasmine": "^3.7.0"
62
64
  }
63
65
  }
@@ -32,7 +32,7 @@ caches.delete(cacheName); // force to reload cache for the first time the sw is
32
32
  self.addEventListener('install', e => {
33
33
  e.waitUntil(
34
34
  caches.open(cacheName).then(cache => {
35
- return cache.addAll([`${start_url}`,{{{filelist}}}])
35
+ return cache.addAll([`${start_url}`,{{filelist}}])
36
36
  .then(() => self.skipWaiting());
37
37
  })
38
38
  );