qcobjects-cli 2.3.31 → 2.3.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/.gitlab-ci.yml +15 -0
- package/VERSION +1 -1
- package/backend/com.qcobjects.backend.microservice.static.js +119 -75
- package/org.qcobjects.enterprise.commands.js +184 -0
- package/org.quickcorp.qcobjects.cli.js +201 -220
- package/org.quickcorp.qcobjects.defaultsettings.js +62 -1
- package/org.quickcorp.qcobjects.main.http.gae.server.js +14 -7
- package/org.quickcorp.qcobjects.main.http.server.js +12 -5
- package/package.json +11 -9
- package/qcobjects-shell.js +1 -1
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.
|
|
1
|
+
2.3.43
|
|
@@ -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,92 +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
|
-
let headers = {
|
|
52
|
-
"content-length": stat.size,
|
|
53
|
-
"last-modified": stat.mtime.toUTCString(),
|
|
54
|
-
"content-type": mime.getType(fileName),
|
|
55
|
-
"cache-control": CONFIG.get("cacheControl", "max-age=31536000")
|
|
56
|
-
};
|
|
57
|
-
if (typeof microservice.route.responseHeaders !== "undefined"){
|
|
58
|
-
headers = Object.assign(headers, microservice.route.responseHeaders);
|
|
59
|
-
}
|
|
60
47
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} catch (e){
|
|
64
|
-
logger.debug("Something went wrong while sending headers...");
|
|
65
|
-
}
|
|
66
|
-
stream.on("close", () => {
|
|
67
|
-
logger.info("closing file "+ fileName);
|
|
68
|
-
fs.closeSync(fd);
|
|
69
|
-
});
|
|
70
|
-
stream.end();
|
|
48
|
+
const sendFileHTTP2 = function(stream, fileName) {
|
|
49
|
+
// read and send file content in the stream
|
|
71
50
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
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")
|
|
78
59
|
};
|
|
79
|
-
|
|
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);
|
|
80
66
|
stream.on("close", () => {
|
|
81
|
-
logger.debug("file
|
|
82
|
-
|
|
67
|
+
logger.debug("closing file " + fileName);
|
|
68
|
+
fs.closeSync(fd);
|
|
83
69
|
});
|
|
84
70
|
stream.end();
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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")
|
|
90
102
|
};
|
|
91
|
-
|
|
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));
|
|
92
114
|
stream.on("close", () => {
|
|
93
|
-
|
|
94
|
-
logger.info("closing file "+ fileName);
|
|
115
|
+
console.log("closing static file", fileName);
|
|
95
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);
|
|
96
131
|
stream.end();
|
|
97
132
|
}
|
|
133
|
+
stream.end();
|
|
134
|
+
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
if (typeof stream.respondWithFD !== "undefined") {
|
|
138
|
+
sendFileHTTP2(stream, fileName);
|
|
139
|
+
} else {
|
|
140
|
+
sendFileLegacyHTTP(stream, fileName);
|
|
98
141
|
}
|
|
142
|
+
|
|
99
143
|
},
|
|
100
|
-
static: function
|
|
144
|
+
static: function(method, data) {
|
|
101
145
|
var microservice = this;
|
|
102
146
|
var redirect_to = microservice.route.redirect_to;
|
|
103
|
-
return new Promise
|
|
147
|
+
return new Promise(function(resolve, reject) {
|
|
104
148
|
var supported_methods = microservice.route.supported_methods;
|
|
105
149
|
var _method_allowed_ = false;
|
|
106
|
-
if (typeof supported_methods !== "undefined"){
|
|
107
|
-
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) {
|
|
108
152
|
_method_allowed_ = true;
|
|
109
153
|
}
|
|
110
154
|
} else {
|
|
111
155
|
_method_allowed_ = true;
|
|
112
156
|
}
|
|
113
157
|
|
|
114
|
-
logger.debug("Starting static delivery microservice call for method: "+method);
|
|
115
|
-
if (_method_allowed_){
|
|
158
|
+
logger.debug("Starting static delivery microservice call for method: " + method);
|
|
159
|
+
if (_method_allowed_) {
|
|
116
160
|
logger.info("I'm going to deliver a static path...");
|
|
117
|
-
if (redirect_to){
|
|
161
|
+
if (redirect_to) {
|
|
118
162
|
let request_path = microservice.request.path;
|
|
119
|
-
let re = (new RegExp(microservice.route.path.replace(
|
|
120
|
-
microservice.fileName
|
|
163
|
+
let re = (new RegExp(microservice.route.path.replace(/{(.*?)}/g, "\(\?\<$1\>\.\*\)"), "g"));
|
|
164
|
+
microservice.fileName = request_path.replace(re, microservice.route.redirect_to);
|
|
121
165
|
try {
|
|
122
166
|
resolve();
|
|
123
|
-
} catch (e){
|
|
124
|
-
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);
|
|
125
169
|
reject();
|
|
126
170
|
}
|
|
127
171
|
} else {
|
|
@@ -129,7 +173,7 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
129
173
|
reject();
|
|
130
174
|
}
|
|
131
175
|
} else {
|
|
132
|
-
logger.debug("Method: "+method+" will be skipped");
|
|
176
|
+
logger.debug("Method: " + method + " will be skipped");
|
|
133
177
|
resolve();
|
|
134
178
|
}
|
|
135
179
|
|
|
@@ -137,64 +181,64 @@ Package("com.qcobjects.backend.microservice.static", [
|
|
|
137
181
|
},
|
|
138
182
|
head: function(formData) {
|
|
139
183
|
var microservice = this;
|
|
140
|
-
microservice.static("head",formData).then(response=>{
|
|
141
|
-
microservice.body=response;
|
|
184
|
+
microservice.static("head", formData).then(response => {
|
|
185
|
+
microservice.body = response;
|
|
142
186
|
microservice.done();
|
|
143
187
|
});
|
|
144
188
|
},
|
|
145
|
-
get: function(formData){
|
|
189
|
+
get: function(formData) {
|
|
146
190
|
var microservice = this;
|
|
147
|
-
microservice.static("get",formData).then(response=>{
|
|
148
|
-
microservice.body=response;
|
|
191
|
+
microservice.static("get", formData).then(response => {
|
|
192
|
+
microservice.body = response;
|
|
149
193
|
microservice.done();
|
|
150
194
|
});
|
|
151
195
|
},
|
|
152
|
-
post:function
|
|
196
|
+
post: function(formData) {
|
|
153
197
|
var microservice = this;
|
|
154
|
-
microservice.static("post",formData).then(response=>{
|
|
155
|
-
microservice.body=response;
|
|
198
|
+
microservice.static("post", formData).then(response => {
|
|
199
|
+
microservice.body = response;
|
|
156
200
|
microservice.done();
|
|
157
201
|
});
|
|
158
202
|
},
|
|
159
203
|
put: function(formData) {
|
|
160
204
|
var microservice = this;
|
|
161
|
-
microservice.static("put",formData).then(response=>{
|
|
162
|
-
microservice.body=response;
|
|
205
|
+
microservice.static("put", formData).then(response => {
|
|
206
|
+
microservice.body = response;
|
|
163
207
|
microservice.done();
|
|
164
208
|
});
|
|
165
209
|
},
|
|
166
210
|
delete: function(formData) {
|
|
167
211
|
var microservice = this;
|
|
168
|
-
microservice.static("delete",formData).then(response=>{
|
|
169
|
-
microservice.body=response;
|
|
212
|
+
microservice.static("delete", formData).then(response => {
|
|
213
|
+
microservice.body = response;
|
|
170
214
|
microservice.done();
|
|
171
215
|
});
|
|
172
216
|
},
|
|
173
217
|
connect: function(formData) {
|
|
174
218
|
var microservice = this;
|
|
175
|
-
microservice.static("connect",formData).then(response=>{
|
|
176
|
-
microservice.body=response;
|
|
219
|
+
microservice.static("connect", formData).then(response => {
|
|
220
|
+
microservice.body = response;
|
|
177
221
|
microservice.done();
|
|
178
222
|
});
|
|
179
223
|
},
|
|
180
224
|
options: function(formData) {
|
|
181
225
|
var microservice = this;
|
|
182
|
-
microservice.static("options",formData).then(response=>{
|
|
183
|
-
microservice.body=response;
|
|
226
|
+
microservice.static("options", formData).then(response => {
|
|
227
|
+
microservice.body = response;
|
|
184
228
|
microservice.done();
|
|
185
229
|
});
|
|
186
230
|
},
|
|
187
231
|
trace: function(formData) {
|
|
188
232
|
var microservice = this;
|
|
189
|
-
microservice.static("trace",formData).then(response=>{
|
|
190
|
-
microservice.body=response;
|
|
233
|
+
microservice.static("trace", formData).then(response => {
|
|
234
|
+
microservice.body = response;
|
|
191
235
|
microservice.done();
|
|
192
236
|
});
|
|
193
237
|
},
|
|
194
238
|
patch: function(formData) {
|
|
195
239
|
var microservice = this;
|
|
196
|
-
microservice.static("patch",formData).then(response=>{
|
|
197
|
-
microservice.body=response;
|
|
240
|
+
microservice.static("patch", formData).then(response => {
|
|
241
|
+
microservice.body = response;
|
|
198
242
|
microservice.done();
|
|
199
243
|
});
|
|
200
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
|
-
|
|
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;
|
|
@@ -226,6 +229,7 @@ Package("org.quickcorp.qcobjects.cli",[
|
|
|
226
229
|
|
|
227
230
|
},
|
|
228
231
|
create:function (_appName, options){
|
|
232
|
+
const version = global.__get_version__();
|
|
229
233
|
let switchCommander = this;
|
|
230
234
|
let appName = (typeof _appName ==="undefined" || _appName === true)?("MyAppName"):(_appName);
|
|
231
235
|
|
|
@@ -243,119 +247,222 @@ Package("org.quickcorp.qcobjects.cli",[
|
|
|
243
247
|
rl.close();
|
|
244
248
|
let giturl = answer;
|
|
245
249
|
|
|
246
|
-
let createAppCommandCustom =
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
"
|
|
255
|
-
"
|
|
256
|
-
"
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
"
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
"
|
|
311
|
-
"qcobjects": "
|
|
312
|
-
"
|
|
313
|
-
|
|
314
|
-
|
|
250
|
+
let createAppCommandCustom = `
|
|
251
|
+
{
|
|
252
|
+
"name": "${appName.toLowerCase()}",
|
|
253
|
+
"version": "0.0.1",
|
|
254
|
+
"repository": {
|
|
255
|
+
"type": "git",
|
|
256
|
+
"url": "${giturl}"
|
|
257
|
+
},
|
|
258
|
+
"description": "This is a custom NPM template app from ${options.createCustom} generated with QCObjects.",
|
|
259
|
+
"main": "js/init.js",
|
|
260
|
+
"license": "LGPL-3.0-or-later",
|
|
261
|
+
"scripts": {
|
|
262
|
+
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
263
|
+
"sync": "git add . && git commit -am ",
|
|
264
|
+
"preversion": "npm i --upgrade && npm test",
|
|
265
|
+
"postversion": "git push && git push --tags",
|
|
266
|
+
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
267
|
+
"start": "node app.js",
|
|
268
|
+
"build": "exit 0"
|
|
269
|
+
},
|
|
270
|
+
"dependencies": {
|
|
271
|
+
"${options.createCustom}": "latest",
|
|
272
|
+
"qcobjects": "^${version.qcobjects}",
|
|
273
|
+
"qcobjects-sdk": "^${version.sdk}"
|
|
274
|
+
},
|
|
275
|
+
"devDependencies": {
|
|
276
|
+
"eslint": "^8.2.0",
|
|
277
|
+
"eslint-config-qcobjects": "latest",
|
|
278
|
+
"jasmine": "latest",
|
|
279
|
+
"qcobjects-cli": "^${version.cli}",
|
|
280
|
+
"grunt": "^1.4.1",
|
|
281
|
+
"grunt-contrib-jasmine": "^2.0.2",
|
|
282
|
+
"nyc": "^15.1.0"
|
|
283
|
+
}
|
|
284
|
+
}`;
|
|
285
|
+
|
|
286
|
+
let createAppCommandPWA = `
|
|
287
|
+
{
|
|
288
|
+
"name": "${appName.toLowerCase()}",
|
|
289
|
+
"version": "0.0.1",
|
|
290
|
+
"repository": {
|
|
291
|
+
"type": "git",
|
|
292
|
+
"url": "${giturl}"
|
|
293
|
+
},
|
|
294
|
+
"description": "Awesome PWA application that will help you achieve your dreams.",
|
|
295
|
+
"main": "js/init.js",
|
|
296
|
+
"license": "LGPL-3.0-or-later",
|
|
297
|
+
"scripts": {
|
|
298
|
+
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
299
|
+
"sync": "git add . && git commit -am ",
|
|
300
|
+
"preversion": "npm i --upgrade && npm test",
|
|
301
|
+
"postversion": "git push && git push --tags",
|
|
302
|
+
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
303
|
+
"start": "node app.js",
|
|
304
|
+
"build": "exit 0"
|
|
305
|
+
},
|
|
306
|
+
"dependencies": {
|
|
307
|
+
"qcobjectsnewapp": "latest",
|
|
308
|
+
"qcobjects": "^${version.qcobjects}",
|
|
309
|
+
"qcobjects-sdk": "^${version.sdk}"
|
|
310
|
+
},
|
|
311
|
+
"devDependencies": {
|
|
312
|
+
"eslint": "^8.2.0",
|
|
313
|
+
"eslint-config-qcobjects": "latest",
|
|
314
|
+
"jasmine": "latest",
|
|
315
|
+
"qcobjects-cli": "^${version.cli}",
|
|
316
|
+
"grunt": "^1.4.1",
|
|
317
|
+
"grunt-contrib-jasmine": "^2.0.2",
|
|
318
|
+
"nyc": "^15.1.0"
|
|
319
|
+
}
|
|
320
|
+
}`;
|
|
321
|
+
|
|
322
|
+
let createAppCommandAMP = `echo
|
|
323
|
+
{
|
|
324
|
+
"name": "${appName.toLowerCase()}",
|
|
325
|
+
"version": "0.0.1",
|
|
326
|
+
"repository": {
|
|
327
|
+
"type": "git",
|
|
328
|
+
"url": "${giturl}"
|
|
329
|
+
},
|
|
330
|
+
"description": "Awesome AMP application that will help you achieve your dreams.",
|
|
331
|
+
"main": "js/init.js",
|
|
332
|
+
"license": "LGPL-3.0-or-later",
|
|
333
|
+
"scripts": {
|
|
334
|
+
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
335
|
+
"sync": "git add . && git commit -am ",
|
|
336
|
+
"preversion": "npm i --upgrade && npm test",
|
|
337
|
+
"postversion": "git push && git push --tags",
|
|
338
|
+
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
339
|
+
"start": "node app.js",
|
|
340
|
+
"build": "exit 0"
|
|
341
|
+
},
|
|
342
|
+
"dependencies": {
|
|
343
|
+
"qcobjects-ecommerce-amp": "latest",
|
|
344
|
+
"qcobjects": "^${version.qcobjects}",
|
|
345
|
+
"qcobjects-sdk": "^${version.sdk}"
|
|
346
|
+
},
|
|
347
|
+
"devDependencies": {
|
|
348
|
+
"eslint": "^8.2.0",
|
|
349
|
+
"eslint-config-qcobjects": "latest",
|
|
350
|
+
"jasmine": "latest",
|
|
351
|
+
"qcobjects-cli": "^${version.cli}",
|
|
352
|
+
"grunt": "^1.4.1",
|
|
353
|
+
"grunt-contrib-jasmine": "^2.0.2",
|
|
354
|
+
"nyc": "^15.1.0"
|
|
355
|
+
}
|
|
356
|
+
}`;
|
|
357
|
+
|
|
358
|
+
let createAppCommandPHP = `
|
|
359
|
+
{
|
|
360
|
+
"name": "${appName.toLowerCase()}",
|
|
361
|
+
"version": "0.0.1",
|
|
362
|
+
"repository": {
|
|
363
|
+
"type": "git",
|
|
364
|
+
"url": "${giturl}"
|
|
365
|
+
},
|
|
366
|
+
"description": "Awesome PHP application that will help you achieve your dreams.",
|
|
367
|
+
"main": "js/init.js",
|
|
368
|
+
"license": "LGPL-3.0-or-later",
|
|
369
|
+
"scripts": {
|
|
370
|
+
"test": "(npx eslint *.js js/*.js js/packages/*.js --fix) && (npx jasmine)",
|
|
371
|
+
"sync": "git add . && git commit -am ",
|
|
372
|
+
"preversion": "npm i --upgrade && npm test",
|
|
373
|
+
"postversion": "git push && git push --tags",
|
|
374
|
+
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test",
|
|
375
|
+
"start": "node app.js",
|
|
376
|
+
"build": "exit 0"
|
|
377
|
+
},
|
|
378
|
+
"dependencies": {
|
|
379
|
+
"qcobjectsnewphp": "latest",
|
|
380
|
+
"qcobjects": "^${version.qcobjects}",
|
|
381
|
+
"qcobjects-sdk": "^${version.sdk}"
|
|
382
|
+
},
|
|
383
|
+
"devDependencies": {
|
|
384
|
+
"eslint": "^8.2.0",
|
|
385
|
+
"eslint-config-qcobjects": "latest",
|
|
386
|
+
"jasmine": "latest",
|
|
387
|
+
"qcobjects-cli": "^${version.cli}",
|
|
388
|
+
"grunt": "^1.4.1",
|
|
389
|
+
"grunt-contrib-jasmine": "^2.0.2",
|
|
390
|
+
"nyc": "^15.1.0"
|
|
391
|
+
}
|
|
392
|
+
}`;
|
|
315
393
|
|
|
316
394
|
let createAppCommand;
|
|
317
395
|
let appTemplateName;
|
|
396
|
+
let _package_json_content;
|
|
318
397
|
|
|
319
398
|
if (options.createAmp){
|
|
320
399
|
appTemplateName = "qcobjects-ecommerce-amp";
|
|
321
|
-
|
|
400
|
+
_package_json_content = createAppCommandAMP;
|
|
322
401
|
} else if (options.createPwa){
|
|
323
402
|
appTemplateName = "qcobjectsnewapp";
|
|
324
|
-
|
|
403
|
+
_package_json_content = createAppCommandPWA;
|
|
325
404
|
} else if (options.createPhp){
|
|
326
405
|
appTemplateName = "qcobjectsnewphp";
|
|
327
|
-
|
|
406
|
+
_package_json_content = createAppCommandPHP;
|
|
328
407
|
} else if (options.createCustom){
|
|
329
408
|
appTemplateName = options.createCustom;
|
|
330
|
-
|
|
409
|
+
_package_json_content = createAppCommandCustom;
|
|
331
410
|
} else {
|
|
332
411
|
appTemplateName = "qcobjectsnewapp";
|
|
333
|
-
|
|
412
|
+
_package_json_content = createAppCommandPWA;
|
|
334
413
|
}
|
|
335
414
|
CONFIG.set("qcobjectsnewapp_path",CONFIG.get("node_modules_path")+"/"+appTemplateName);
|
|
336
|
-
if (!process.platform.toLowerCase().startsWith("win")){
|
|
337
|
-
|
|
338
|
-
}
|
|
415
|
+
/* if (!process.platform.toLowerCase().startsWith("win")){
|
|
416
|
+
_package_json_content = _package_json_content.replace(/(")/g, String.fromCharCode(92)+"\"");
|
|
417
|
+
}*/
|
|
418
|
+
createAppCommand = "npm init -y";
|
|
419
|
+
let _package_json_file = path.resolve(CONFIG.get("projectPath"),"./package.json");
|
|
420
|
+
logger.debug("_package_json_file: "+_package_json_file);
|
|
339
421
|
logger.debug(createAppCommand);
|
|
422
|
+
|
|
340
423
|
exec(createAppCommand, (err, stdout, stderr) => {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
424
|
+
if (err) {
|
|
425
|
+
logger.warn(err);
|
|
426
|
+
process.exit(1);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
fs.writeFile(_package_json_file, _package_json_content, err => {
|
|
430
|
+
if (err) {
|
|
431
|
+
logger.warn(err);
|
|
432
|
+
process.exit(1);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
exec("npm cache verify && npm i --save-dev --legacy-peer-deps", (err, stdout, stderr) => {
|
|
437
|
+
if (err) {
|
|
438
|
+
logger.warn(err);
|
|
439
|
+
process.exit(1);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
Promise.resolve(switchCommander.copyTemplate())
|
|
444
|
+
.then(()=>{
|
|
445
|
+
logger.info("Good! Your application is getting done. You can play with QCObjects now!");
|
|
446
|
+
logger.info("In about five seconds your server will start...");
|
|
447
|
+
exec("qcobjects-createcert",(err,stdout,stderr)=>{
|
|
448
|
+
logger.info("Test certificates generated");
|
|
449
|
+
|
|
450
|
+
exec("npm uninstall "+appTemplateName+" --save && npm cache verify",(err,stdout,stderr)=>{
|
|
451
|
+
switchCommander.generateServiceWorker(appName);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
}).stdout.on("data", function(data) {
|
|
455
|
+
console.log(data);
|
|
349
456
|
});
|
|
350
|
-
}).stdout.on("data", function(data) {
|
|
351
|
-
console.log(data);
|
|
352
457
|
});
|
|
458
|
+
}).stdout.on("data", function(data) {
|
|
459
|
+
console.log(data);
|
|
353
460
|
});
|
|
354
|
-
|
|
355
|
-
console.log(data);
|
|
461
|
+
|
|
356
462
|
});
|
|
463
|
+
|
|
357
464
|
}).stdout.on("data", function(data) {
|
|
358
|
-
console.log(
|
|
465
|
+
console.log("App generation started...");
|
|
359
466
|
});
|
|
360
467
|
|
|
361
468
|
});
|
|
@@ -364,135 +471,9 @@ Package("org.quickcorp.qcobjects.cli",[
|
|
|
364
471
|
publish: function (_appName){
|
|
365
472
|
logger.debug("publish is not yet implemented");
|
|
366
473
|
},
|
|
367
|
-
upgradeToEnterprise
|
|
474
|
+
upgradeToEnterprise (){
|
|
368
475
|
let switchCommander = this;
|
|
369
|
-
|
|
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
|
-
|
|
476
|
+
QCObjectsEnterprise.upgrade(switchCommander);
|
|
496
477
|
}
|
|
497
478
|
},
|
|
498
479
|
initCommand: function (){
|
|
@@ -500,7 +481,7 @@ If you want to quit, press Ctrl-C.
|
|
|
500
481
|
if (process.argv.length>1){
|
|
501
482
|
|
|
502
483
|
switchCommander.program
|
|
503
|
-
.version(global.
|
|
484
|
+
.version(global.__get_version_string__());
|
|
504
485
|
switchCommander.program
|
|
505
486
|
.command("create <appname>")
|
|
506
487
|
.description("Creates an app with <appname>")
|
|
@@ -49,7 +49,16 @@ global.__get_version__ = function (){
|
|
|
49
49
|
const package_config = require(absolutePath+"/package.json");
|
|
50
50
|
const qcobjects_pkg_config = require("qcobjects/package.json");
|
|
51
51
|
const qcobjects_sdk_pkg_config = require("qcobjects-sdk/package.json");
|
|
52
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
"qcobjects":qcobjects_pkg_config.version,
|
|
54
|
+
"sdk":qcobjects_sdk_pkg_config.version,
|
|
55
|
+
"cli":package_config.version
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
global.__get_version_string__ = function (){
|
|
60
|
+
const version = global.__get_version__();
|
|
61
|
+
return "QCObjects: v"+version.qcobjects+", SDK: v"+version.sdk+", CLI: v"+version.cli;
|
|
53
62
|
};
|
|
54
63
|
|
|
55
64
|
|
|
@@ -118,3 +127,55 @@ try {
|
|
|
118
127
|
logger.debug(e);
|
|
119
128
|
logger.debug("Something went wrong trying to load config.json file in your project");
|
|
120
129
|
}
|
|
130
|
+
|
|
131
|
+
(async function (){
|
|
132
|
+
/* Auto Discover dependencies (lib, handlers, commands) */
|
|
133
|
+
const path = require("path");
|
|
134
|
+
const projectPath = CONFIG.get("projectPath", `${process.cwd()}/`);
|
|
135
|
+
const loadLibs = async () => {
|
|
136
|
+
let _ret_;
|
|
137
|
+
if (CONFIG.get("autodiscover", false) || CONFIG.get("autodiscover_libs",false)){
|
|
138
|
+
_ret_ = Promise.all(Object.keys(require(`${projectPath}/package.json`).dependencies).filter((p)=>require(`${findPackageNodePath(p)}/${p}/package.json`).keywords.includes("qcobjects-lib")).map((p)=>Import(p))).then(()=>logger.info("Libs loaded"));
|
|
139
|
+
} else {
|
|
140
|
+
_ret_ = Promise.resolve();
|
|
141
|
+
logger.debug("To load libs, set autodiscover_libs to true in your config.json");
|
|
142
|
+
}
|
|
143
|
+
return _ret_;
|
|
144
|
+
};
|
|
145
|
+
const loadHandlers = async () => {
|
|
146
|
+
let _ret_;
|
|
147
|
+
if (CONFIG.get("autodiscover", false) || CONFIG.get("autodiscover_handlers",false)){
|
|
148
|
+
_ret_ = Promise.all(Object.keys(require(`${projectPath}/package.json`).dependencies).filter((p)=>require(`${findPackageNodePath(p)}/${p}/package.json`).keywords.includes("qcobjects-handler")).map((p)=>Import(p))).then(()=>logger.info("Handlers loaded"));
|
|
149
|
+
} else {
|
|
150
|
+
_ret_ = Promise.resolve();
|
|
151
|
+
logger.debug("To load handlers, set autodiscover_handlers to true in your config.json");
|
|
152
|
+
}
|
|
153
|
+
return _ret_;
|
|
154
|
+
};
|
|
155
|
+
const loadCommands = async () => {
|
|
156
|
+
let _ret_;
|
|
157
|
+
if (CONFIG.get("autodiscover", false) || CONFIG.get("autodiscover_commands",false)){
|
|
158
|
+
_ret_ = Promise.all(Object.keys(require(`${projectPath}/package.json`).dependencies).filter((p)=>require(`${findPackageNodePath(p)}/${p}/package.json`).keywords.includes("qcobjects-command")).map((p)=>Import(p))).then(()=>logger.info("Commands loaded"));
|
|
159
|
+
} else {
|
|
160
|
+
_ret_ = Promise.resolve();
|
|
161
|
+
logger.debug("To load commands, set autodiscover_commands to true in your config.json");
|
|
162
|
+
}
|
|
163
|
+
return _ret_;
|
|
164
|
+
};
|
|
165
|
+
if (CONFIG.get("autodiscover", false)
|
|
166
|
+
|| CONFIG.get("autodiscover_libs",false)
|
|
167
|
+
|| CONFIG.get("autodiscover_handlers",false)
|
|
168
|
+
|| CONFIG.get("autodiscover_commands",false)
|
|
169
|
+
){
|
|
170
|
+
logger.info("Auto discover is enabled");
|
|
171
|
+
} else if (!CONFIG.get("autodiscover", false)) {
|
|
172
|
+
logger.info("Auto discover is disabled");
|
|
173
|
+
logger.debug("To load all dependencies, set autodiscover to true in your config.json");
|
|
174
|
+
} else {
|
|
175
|
+
logger.info("Auto discover is disabled");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
await loadLibs();
|
|
179
|
+
await loadHandlers();
|
|
180
|
+
await loadCommands();
|
|
181
|
+
})().then (()=>logger.info("Dependencies loaded"));
|
|
@@ -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
|
-
|
|
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
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
336
|
+
oHTTPServer.server = http.createServer((req, res) => {
|
|
333
337
|
|
|
334
|
-
|
|
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
|
-
|
|
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
|
-
|
|
150
|
-
|
|
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
|
-
|
|
336
|
+
oHTTPServer.server = http.createServer((req, res) => {
|
|
333
337
|
|
|
334
|
-
|
|
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.
|
|
3
|
+
"version": "2.3.43",
|
|
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
|
|
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": "
|
|
15
|
+
"qcobjects": "^2.3.66-lts",
|
|
16
16
|
"qcobjects-sdk": "latest",
|
|
17
|
-
"yaml": "^1.
|
|
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
|
}
|
package/qcobjects-shell.js
CHANGED
|
@@ -85,7 +85,7 @@ readline.emitKeypressEvents(process.stdin);
|
|
|
85
85
|
if (process.stdin.isTTY)
|
|
86
86
|
process.stdin.setRawMode(true);
|
|
87
87
|
|
|
88
|
-
let qcobjects_version = global.
|
|
88
|
+
let qcobjects_version = global.__get_version_string__();
|
|
89
89
|
|
|
90
90
|
const rl = readline.createInterface({
|
|
91
91
|
input: process.stdin,
|