qcobjects-cli 2.3.50 → 2.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  3. package/.github/ISSUE_TEMPLATE/custom.md +10 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. package/.github/ISSUE_TEMPLATE/issue-template.md +33 -0
  6. package/.github/workflows/codeql-analysis.yml +71 -0
  7. package/.github/workflows/npmpublish-beta.yml +38 -0
  8. package/.github/workflows/npmpublish-lts.yml +38 -0
  9. package/.github/workflows/npmpublish-main.yml +38 -0
  10. package/.gitlab-ci.yml +3 -2
  11. package/VERSION +1 -1
  12. package/backend/com.qcobjects.backend.microservice.static.js +40 -24
  13. package/backend/org.qcobjects.backend.php.js +149 -116
  14. package/{org.quickcorp.qcobjects.cli.commands.jira.client_services.js → com.qcobjects.cli.commands.jira.client_services.js} +29 -22
  15. package/{org.quickcorp.qcobjects.cli.commands.jira.js → com.qcobjects.cli.commands.jira.js} +77 -60
  16. package/{org.quickcorp.qcobjects.cli.commands.js → com.qcobjects.cli.commands.js} +3 -3
  17. package/com.qcobjects.cli.commands.version.js +285 -0
  18. package/org.qcobjects.common.pipelog.js +55 -0
  19. package/org.qcobjects.enterprise.commands.js +149 -139
  20. package/org.quickcorp.qcobjects.api.client_services.js +31 -20
  21. package/org.quickcorp.qcobjects.cli.js +288 -275
  22. package/org.quickcorp.qcobjects.collab.server.js +317 -308
  23. package/org.quickcorp.qcobjects.defaultsettings.js +1 -1
  24. package/org.quickcorp.qcobjects.main.file.js +100 -79
  25. package/org.quickcorp.qcobjects.main.http.gae.server.js +264 -232
  26. package/org.quickcorp.qcobjects.main.http.server.js +155 -145
  27. package/org.quickcorp.qcobjects.main.http2.server.js +198 -191
  28. package/package.json +18 -10
  29. package/qcobjects-cli.js +8 -11
  30. package/qcobjects-collab.js +8 -6
  31. package/qcobjects-createcert.js +28 -16
  32. package/qcobjects-gae-http-server.js +8 -5
  33. package/qcobjects-http-server.js +7 -5
  34. package/qcobjects-http2-server.js +8 -5
  35. package/qcobjects-shell.js +113 -107
  36. package/org.quickcorp.qcobjects.cli.commands.version.js +0 -267
@@ -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"*/
@@ -31,96 +31,141 @@
31
31
  "use strict";
32
32
  const fs = require("fs");
33
33
  const os = require("os");
34
- const { exec,execSync } = require("child_process");
34
+ const {
35
+ exec,
36
+ execSync
37
+ } = require("child_process");
35
38
  // MY_ENV_VAR="HELLO WORLD" php -f index.php
36
39
 
37
- let fixWinCmd = function (commandline){
38
- if (!process.platform.toLowerCase().startsWith("win")){
39
- commandline = commandline.replace(/(")/g, String.fromCharCode(92)+"\"");
40
+ let fixWinCmd = function (commandline) {
41
+ if (!process.platform.toLowerCase().startsWith("win")) {
42
+ commandline = commandline.replace(/(")/g, String.fromCharCode(92) + "\"");
40
43
  }
41
44
  return commandline;
42
45
  };
43
46
 
44
- Package("org.quickcorp.backend.php",[
45
- Class("PHPMicroservice",BackendMicroservice,{
46
- body:null,
47
- tempFileName: "",
48
- get_php_headers_list:function (){
47
+ Package("org.quickcorp.backend.php", [
48
+
49
+ class PHPMicroservice extends BackendMicroservice {
50
+ constructor() {
51
+ super(...arguments);
52
+ var o = this;
53
+
54
+ logger.debug("PHP Microservice executing");
55
+ let microservice = this;
56
+ let request = microservice.request;
57
+ let stream = o.stream;
58
+ microservice.stream = stream;
59
+ stream.on("data", (data) => {
60
+ // data from POST, GET
61
+ var requestMethod = request.method.toLowerCase();
62
+ var supportedMethods = {
63
+ "post": microservice.post,
64
+ };
65
+ if (supportedMethods.hasOwnProperty.call(supportedmethods, requestMethod)) {
66
+ supportedMethods[requestMethod].call(microservice, data);
67
+ }
68
+ });
69
+
70
+ // data from POST, GET
71
+ var requestMethod = request.method.toLowerCase();
72
+ var supportedMethods = {
73
+ "get": microservice.get,
74
+ "head": microservice.head,
75
+ "put": microservice.put,
76
+ "delete": microservice.delete,
77
+ "connect": microservice.connect,
78
+ "options": microservice.options,
79
+ "trace": microservice.trace,
80
+ "patch": microservice.patch
81
+ };
82
+ if (supportedMethods.hasOwnProperty.call(supportedMethods, requestMethod)) {
83
+ supportedMethods[requestMethod].call(microservice);
84
+ }
85
+
86
+ }
87
+
88
+ get_php_headers_list() {
49
89
  var phpheaders = {
50
- "QUERY_STRING":`${this.request.query}`,
51
- "REDIRECT_STATUS":"200",
52
- "REQUEST_METHOD":`${this.request.method}`,
53
- "SCRIPT_FILENAME":`${this.scriptFilePath}`,
54
- "SCRIPT_NAME":`${this.scriptFilePath.toString()}`,
55
- "PATH_INFO":`${this.request.path}`,
56
- "SERVER_NAME":`${this.domain}`,
57
- "SERVER_PROTOCOL":"HTTP/2",
58
- "REQUEST_URI":`${this.request.href}`,
59
- "HTTP_HOST":`${this.domain}`
90
+ "QUERY_STRING": `${this.request.query}`,
91
+ "REDIRECT_STATUS": "200",
92
+ "REQUEST_METHOD": `${this.request.method}`,
93
+ "SCRIPT_FILENAME": `${this.scriptFilePath}`,
94
+ "SCRIPT_NAME": `${this.scriptFilePath.toString()}`,
95
+ "PATH_INFO": `${this.request.path}`,
96
+ "SERVER_NAME": `${this.domain}`,
97
+ "SERVER_PROTOCOL": "HTTP/2",
98
+ "REQUEST_URI": `${this.request.href}`,
99
+ "HTTP_HOST": `${this.domain}`
60
100
  };
61
- function fixedEncodeURIComponent (str) {
101
+
102
+ function fixedEncodeURIComponent(str) {
62
103
  return encodeURIComponent(str).replace(/[!'()]/g, escape).replace(/\*/g, "%2A");
63
104
  }
64
- for (var headername in this.request.headers){
65
- if (!headername.startsWith(":")){
66
- var phpheadername = headername.toUpperCase().replace(new RegExp("-","g"),"_");
105
+ for (var headername in this.request.headers) {
106
+ if (!headername.startsWith(":")) {
107
+ var phpheadername = headername.toUpperCase().replace(new RegExp("-", "g"), "_");
67
108
  var headervalue = this.request.headers[headername];
68
- if (typeof headervalue != "string"){
109
+ if (typeof headervalue != "string") {
69
110
  headervalue = JSON.stringify(headervalue);
70
111
  }
71
- phpheaders["HTTP_"+phpheadername] = fixedEncodeURIComponent(headervalue);
112
+ phpheaders["HTTP_" + phpheadername] = fixedEncodeURIComponent(headervalue);
72
113
  }
73
114
  }
74
115
 
75
116
  return PipeLog.pipe(phpheaders);
76
- },
77
- saveTempData: function (data,done){
117
+ }
118
+
119
+ saveTempData(data, done) {
78
120
  var filename = os.tmpdir() + this.tempFileName;
79
121
  fs.writeFile(filename, data, (err) => {
80
122
  if (err) throw err;
81
123
  logger.debug("A temp data file has been saved!");
82
124
  done.call(this);
83
125
  });
84
- },
85
- generateTempFileName: function (){
126
+ }
127
+
128
+ generateTempFileName() {
86
129
  this.tempFileName = "temp" + Date.now().toString();
87
130
  return this.tempFileName;
88
- },
89
- trimSlash:function (pathname){
90
- if (pathname.startsWith("/")){
131
+ }
132
+
133
+ trimSlash(pathname) {
134
+ if (pathname.startsWith("/")) {
91
135
  pathname = pathname.slice(1);
92
136
  }
93
- if (pathname.endsWith("/")){
94
- pathname = pathname.slice(0,-1);
137
+ if (pathname.endsWith("/")) {
138
+ pathname = pathname.slice(0, -1);
95
139
  }
96
- return pathname.replace("//","/");
97
- },
98
- get:function (){
140
+ return pathname.replace("//", "/");
141
+ }
142
+
143
+ get() {
99
144
  var microservice = this;
100
145
  microservice.generateTempFileName();
101
146
 
102
- microservice.saveTempData(this.request.query,function (){
147
+ microservice.saveTempData(this.request.query, function () {
103
148
  try {
104
- process.chdir(CONFIG.get("documentRoot")+microservice.request.pathname.slice(1));
105
- } catch (e){}
149
+ process.chdir(CONFIG.get("documentRoot") + microservice.request.pathname.slice(1));
150
+ } catch (e) {}
106
151
 
107
- var scriptFileName = (microservice.route.hasOwnProperty.call(microservice.route,"redirect_to")
108
- && microservice.route.redirect_to !== "")?(microservice.route.redirect_to):(microservice.request.scriptname);
152
+ var scriptFileName = (microservice.route.hasOwnProperty.call(microservice.route, "redirect_to") &&
153
+ microservice.route.redirect_to !== "") ? (microservice.route.redirect_to) : (microservice.request.scriptname);
109
154
  var pathname = this.trimSlash(microservice.request.pathname);
110
- var documentRoot = CONFIG.get("documentRoot","");
111
- if (documentRoot == "./"){
155
+ var documentRoot = CONFIG.get("documentRoot", "");
156
+ if (documentRoot == "./") {
112
157
  documentRoot = "";
113
158
  }
114
159
 
115
160
  var scriptFilePath;
116
- if (documentRoot !== ""){
161
+ if (documentRoot !== "") {
117
162
  scriptFilePath = `${documentRoot}/${pathname}/${scriptFileName}`;
118
163
  } else {
119
164
  scriptFilePath = `${pathname}/${scriptFileName}`;
120
165
  }
121
166
 
122
- scriptFilePath = scriptFilePath.replace("//","/");
123
- if (scriptFilePath.startsWith("/") && !documentRoot.startsWith("/")){
167
+ scriptFilePath = scriptFilePath.replace("//", "/");
168
+ if (scriptFilePath.startsWith("/") && !documentRoot.startsWith("/")) {
124
169
  scriptFilePath = scriptFilePath.slice(1);
125
170
  }
126
171
 
@@ -129,7 +174,7 @@ Package("org.quickcorp.backend.php",[
129
174
 
130
175
  microservice.scriptFilePath = scriptFilePath;
131
176
 
132
- var commandline = `echo $(cat ${os.tmpdir()}${microservice.tempFileName}) |` + microservice.get_php_headers_list()+` php -d include_path="${PHPIncludePath}" -q <<- 'EOF'
177
+ var commandline = `echo $(cat ${os.tmpdir()}${microservice.tempFileName}) |` + microservice.get_php_headers_list() + ` php -d include_path="${PHPIncludePath}" -q <<- 'EOF'
133
178
  <?php
134
179
  $_payload = file_get_contents(sys_get_temp_dir().'${microservice.tempFileName}');
135
180
  foreach ($_SERVER as $_k => $_v) {
@@ -149,12 +194,12 @@ EOF`;
149
194
  commandline = fixWinCmd(commandline);
150
195
  logger.debug(commandline);
151
196
  try {
152
- let php = exec(commandline,(err,stdout,stderr)=>{
197
+ let php = exec(commandline, (err, stdout, stderr) => {
153
198
  microservice.body = stdout;
154
199
  console.log(stderr);
155
200
  microservice.done();
156
201
  });
157
- } catch (ex){
202
+ } catch (ex) {
158
203
  microservice.body = "500 - INTERNAL ERROR";
159
204
  logger.debug(ex.toString());
160
205
  console.log(ex);
@@ -163,35 +208,38 @@ EOF`;
163
208
 
164
209
  });
165
210
 
166
- },
167
- head:function (formData){this.done();},
168
- post:function (formData){
211
+ }
212
+
213
+ head(formData) {
214
+ this.done();
215
+ }
216
+ post(formData) {
169
217
  logger.debug("POST DATA");
170
218
  var microservice = this;
171
219
  microservice.generateTempFileName();
172
220
 
173
- microservice.saveTempData(formData,function (){
221
+ microservice.saveTempData(formData, function () {
174
222
  try {
175
- process.chdir(CONFIG.get("documentRoot")+microservice.request.pathname.slice(1));
176
- } catch (e){}
223
+ process.chdir(CONFIG.get("documentRoot") + microservice.request.pathname.slice(1));
224
+ } catch (e) {}
177
225
 
178
- var scriptFileName = (microservice.route.hasOwnProperty.call(microservice.route,"redirect_to")
179
- && microservice.route.redirect_to !== "")?(microservice.route.redirect_to):(microservice.request.scriptname);
226
+ var scriptFileName = (microservice.route.hasOwnProperty.call(microservice.route, "redirect_to") &&
227
+ microservice.route.redirect_to !== "") ? (microservice.route.redirect_to) : (microservice.request.scriptname);
180
228
  var pathname = this.trimSlash(microservice.request.pathname);
181
- var documentRoot = CONFIG.get("documentRoot","");
182
- if (documentRoot == "./"){
229
+ var documentRoot = CONFIG.get("documentRoot", "");
230
+ if (documentRoot == "./") {
183
231
  documentRoot = "";
184
232
  }
185
233
 
186
234
  var scriptFilePath;
187
- if (documentRoot !== ""){
235
+ if (documentRoot !== "") {
188
236
  scriptFilePath = `${documentRoot}/${pathname}/${scriptFileName}`;
189
237
  } else {
190
238
  scriptFilePath = `${pathname}/${scriptFileName}`;
191
239
  }
192
240
 
193
- scriptFilePath = scriptFilePath.replace("//","/");
194
- if (scriptFilePath.startsWith("/") && !documentRoot.startsWith("/")){
241
+ scriptFilePath = scriptFilePath.replace("//", "/");
242
+ if (scriptFilePath.startsWith("/") && !documentRoot.startsWith("/")) {
195
243
  scriptFilePath = scriptFilePath.slice(1);
196
244
  }
197
245
 
@@ -200,7 +248,7 @@ EOF`;
200
248
 
201
249
  microservice.scriptFilePath = scriptFilePath;
202
250
 
203
- var commandline = `echo $(cat ${os.tmpdir()}${microservice.tempFileName}) |` + microservice.get_php_headers_list()+` php -d include_path="${PHPIncludePath}" -q <<- 'EOF'
251
+ var commandline = `echo $(cat ${os.tmpdir()}${microservice.tempFileName}) |` + microservice.get_php_headers_list() + ` php -d include_path="${PHPIncludePath}" -q <<- 'EOF'
204
252
  <?php
205
253
  $_payload = file_get_contents(sys_get_temp_dir().'${microservice.tempFileName}');
206
254
  foreach ($_SERVER as $_k => $_v) {
@@ -218,11 +266,11 @@ unlink(sys_get_temp_dir().'${microservice.tempFileName}');
218
266
  ?>
219
267
  EOF`;
220
268
  commandline = fixWinCmd(commandline);
221
- // logger.debug(commandline);
269
+ // logger.debug(commandline);
222
270
 
223
271
  try {
224
272
  microservice.body = execSync(commandline).toString();
225
- } catch (ex){
273
+ } catch (ex) {
226
274
  microservice.body = "500 - INTERNAL ERROR";
227
275
  logger.debug(ex.toString());
228
276
  }
@@ -230,65 +278,50 @@ EOF`;
230
278
 
231
279
  });
232
280
 
233
- },
234
- put:function (formData){this.done();},
235
- delete:function (formData){this.done();},
236
- connect:function (formData){this.done();},
237
- options:function (formData){this.done();},
238
- trace:function (formData){this.done();},
239
- patch:function (formData){this.done();},
240
- done: function(){
281
+ }
282
+
283
+ put(formData) {
284
+ this.done();
285
+ }
286
+ delete(formData) {
287
+ this.done();
288
+ }
289
+ connect(formData) {
290
+ this.done();
291
+ }
292
+ options(formData) {
293
+ this.done();
294
+ }
295
+ trace(formData) {
296
+ this.done();
297
+ }
298
+ patch(formData) {
299
+ this.done();
300
+ }
301
+ done() {
241
302
  var microservice = this;
242
303
  var stream = microservice.stream;
243
304
  try {
244
305
  stream.respond(microservice.headers);
245
- } catch (e){
306
+ } catch (e) {
246
307
  //
247
308
  }
248
- if (microservice.body != null){
249
- microservice.finishWithBody.call(microservice,stream);
309
+ if (microservice.body != null) {
310
+ microservice.finishWithBody.call(microservice, stream);
250
311
  }
251
- },
252
- finishWithBody:function (stream){
312
+ }
313
+
314
+ finishWithBody(stream) {
253
315
  try {
254
316
  stream.write(this.body);
255
317
  stream.end();
256
- } catch (e){
257
- logger.debug("Something wrong writing the response for microservice"+e.toString());
318
+ } catch (e) {
319
+ logger.debug("Something wrong writing the response for microservice" + e.toString());
258
320
  }
259
- },
260
- _new_:function (o){
261
- logger.debug("PHP Microservice executing");
262
- let microservice = this;
263
- let request = microservice.request;
264
- let stream = o.stream;
265
- microservice.stream = stream;
266
- stream.on("data", (data) => {
267
- // data from POST, GET
268
- var requestMethod = request.method.toLowerCase();
269
- var supportedMethods = {"post":microservice.post,
270
- };
271
- if (supportedMethods.hasOwnProperty.call(supportedmethods,requestMethod)) {
272
- supportedMethods[requestMethod].call(microservice,data);
273
- }
274
- });
321
+ }
275
322
 
276
- // data from POST, GET
277
- var requestMethod = request.method.toLowerCase();
278
- var supportedMethods = {"get":microservice.get,
279
- "head":microservice.head,
280
- "put":microservice.put,
281
- "delete":microservice.delete,
282
- "connect":microservice.connect,
283
- "options":microservice.options,
284
- "trace":microservice.trace,
285
- "patch":microservice.patch
286
- };
287
- if (supportedMethods.hasOwnProperty.call(supportedMethods,requestMethod)) {
288
- supportedMethods[requestMethod].call(microservice);
289
- }
290
323
 
291
- }
292
- }),
293
- Class("Microservice",PHPMicroservice)
294
- ]);
324
+ },
325
+
326
+ Class("Microservice", PHPMicroservice)
327
+ ]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.3.x
2
+ * QCObjects CLI 2.4.x
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -29,35 +29,42 @@
29
29
  /*eslint no-mixed-operators: "off"*/
30
30
  /*eslint no-undef: "off"*/
31
31
  "use strict";
32
- Package("org.quickcorp.qcobjects.cli.commands.jira.client_services", [
33
- Class("JiraCloud", Service, {
34
- name: "jira_cloud",
35
- external: true,
36
- useHTTP2: true,
37
- cached: false,
38
- method: "POST",
39
- headers: {
40
- "accept":"application/json",
41
- "content-type":"application/json"
42
- },
43
- basePath: "",
44
- url: "",
45
- withCredentials: false,
46
- _new_: function(o) {
47
- // service instantiated
32
+ Package("com.qcobjects.cli.commands.jira.client_services", [
33
+ class JiraCloud extends Service {
34
+ constructor ({
35
+ name= "jira_cloud",
36
+ external= true,
37
+ useHTTP2= true,
38
+ cached= false,
39
+ method= "POST",
40
+ headers= {
41
+ "accept":"application/json",
42
+ "content-type":"application/json"
43
+ },
44
+ basePath= "",
45
+ url= "",
46
+ withCredentials= false
47
+ }){
48
+ super(...arguments);
49
+ var o = this;
48
50
  this.domain = `${o.domain}`;
49
51
  this.basePath = `https://${this.domain}/`;
50
52
  this.username_password = `${o.username}:${o.password}`;
51
53
  this.headers["authorization"] = `Basic ${Buffer.from(this.username_password).toString("base64")}`;
52
54
  this.url = this.basePath + o.apiMethod;
53
55
  this.data = o.data;
54
- },
55
- done: function(service,standardResponse) {
56
+
57
+ }
58
+
59
+ done(service,standardResponse) {
56
60
  // service loaded
57
61
  logger.debug(standardResponse);
58
- },
59
- fail: function (e){
62
+ }
63
+
64
+ fail (e){
60
65
  logger.debug(e);
61
66
  }
62
- })
67
+
68
+ }
69
+
63
70
  ]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.3.x
2
+ * QCObjects CLI 2.4.x
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -31,50 +31,101 @@
31
31
  "use strict";
32
32
  const fs = require("fs");
33
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
- require(absolutePath+"/org.quickcorp.qcobjects.cli.commands.jira.client_services");
41
-
42
- Package("org.quickcorp.qcobjects.cli.commands.jira",[
43
- Class("CommandHandler",{
44
- switchCommander:null,
45
- getIssueList: function (username, password, project){
46
- return new Promise(function (resolve, reject){
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 {
39
+ exec,
40
+ execSync
41
+ } = require("child_process");
42
+
43
+ require(absolutePath + "/com.qcobjects.cli.commands.jira.client_services");
44
+
45
+ Package("com.qcobjects.cli.commands.jira", [
46
+
47
+ class CommandHandler extends InheritClass {
48
+ constructor({
49
+ switchCommander
50
+ }) {
51
+ super(...arguments);
52
+ this.choiceOption = {
53
+ issues: function (options) {
54
+
55
+ this.getIssueList().then(function (response) {
56
+ console.log(_DataStringify(response));
57
+ }).catch(e => {
58
+ console.log(e);
59
+ process.exit(1);
60
+ });
61
+
62
+ }
63
+ };
64
+
65
+ let commandHandler = this;
66
+
67
+ switchCommander.program.command("jira <subcommand>")
68
+ .option("-u, --from-user [username]", "User name")
69
+ .option("-fp,--from-project <projectName>", "Project name")
70
+ .option("-p, --pwd <password>", "Password")
71
+ .option("-f, --format <format>", "Format (json, table)")
72
+ .description(`Jira Integration:
73
+ Sub-Commands can be:
74
+ issues: To get the issues list from JIRA
75
+ `)
76
+ .action(function (subcommand, options) {
77
+ if (commandHandler.choiceOption.hasOwnProperty.call(commandHandler.choiceOption, subcommand)) {
78
+ commandHandler.choiceOption[subcommand].call(commandHandler, subcommand, options);
79
+ } else {
80
+ console.error(`Sub-Command (jira ${subcommand}... ) is not available`);
81
+ process.exit(1);
82
+ }
83
+ });
84
+
85
+
86
+
87
+
88
+
89
+ }
90
+
91
+ getIssueList(username, password, project) {
92
+ return new Promise(function (resolve, reject) {
47
93
  logger.info("I'm going to get the issue list from the jira cloud...");
48
- let jira_config = CONFIG.get("jira",null);
49
- if (jira_config !== null){
94
+ let jira_config = CONFIG.get("jira", null);
95
+ if (jira_config !== null) {
50
96
  let jira_username = jira_config.username;
51
97
  let jira_password = jira_config.auth_token;
52
98
  let jira_project = jira_config.project;
53
99
  let jira_domain = jira_config.domain;
54
- let jira_issue_fields = ["id","key","summary","timetracking"];
100
+ let jira_issue_fields = ["id", "key", "summary", "timetracking"];
55
101
  let cloudClient = New(JiraCloud, {
56
- domain: `${jira_domain}`,
102
+ domain: `${jira_domain}`,
57
103
  username: `${jira_username}`,
58
104
  password: `${jira_password}`,
59
105
  apiMethod: "rest/api/latest/search",
60
- data:{"jql":`project = ${jira_project}`,"startAt":0,"maxResults":5000,"fields":jira_issue_fields}
106
+ data: {
107
+ "jql": `project = ${jira_project}`,
108
+ "startAt": 0,
109
+ "maxResults": 5000,
110
+ "fields": jira_issue_fields
111
+ }
61
112
  });
62
113
  try {
63
114
  let service = serviceLoader(cloudClient).then(successResponse => {
64
115
  let template = successResponse.service.template;
65
116
  let responseHeaders = successResponse.responseHeaders;
66
- if (responseHeaders[":status"] === 200 || !cloudClient.useHTTP2){
117
+ if (responseHeaders[":status"] === 200 || !cloudClient.useHTTP2) {
67
118
  let response = JSON.parse(template);
68
119
  resolve(response);
69
120
  } else {
70
- console.error("\u{1F926} Something went wrong \u{1F926} when trying to get jira issues from the cloud. The status was: "+responseHeaders[":status"]);
121
+ console.error("\u{1F926} Something went wrong \u{1F926} when trying to get jira issues from the cloud. The status was: " + responseHeaders[":status"]);
71
122
  reject(template);
72
123
  }
73
- }).catch ((e)=>{
124
+ }).catch((e) => {
74
125
  console.error("\u{1F926} Something went wrong \u{1F926} when trying to get jira issues from the cloud");
75
126
  reject(e);
76
127
  });
77
- } catch (e){
128
+ } catch (e) {
78
129
  console.error("\u{1F926} Something went wrong \u{1F926} when trying to get jira issues from the cloud");
79
130
  reject(e);
80
131
  }
@@ -85,43 +136,9 @@ Package("org.quickcorp.qcobjects.cli.commands.jira",[
85
136
  }
86
137
 
87
138
  });
88
- },
89
- choiceOption:{
90
- issues: function (options){
91
-
92
- this.getIssueList().then(function (response){
93
- console.log(_DataStringify(response));
94
- }).catch (e=>{
95
- console.log(e);
96
- process.exit(1);
97
- });
98
-
99
- }
100
- },
101
- _new_({switchCommander}){
102
- let commandHandler = this;
103
- this.switchCommander = switchCommander;
104
-
105
- switchCommander.program.command("jira <subcommand>")
106
- .option("-u, --from-user [username]", "User name")
107
- .option("-fp,--from-project <projectName>", "Project name")
108
- .option("-p, --pwd <password>", "Password")
109
- .option("-f, --format <format>", "Format (json, table)")
110
- .description(`Jira Integration:
111
- Sub-Commands can be:
112
- issues: To get the issues list from JIRA
113
- `)
114
- .action(function(subcommand, options){
115
- if (commandHandler.choiceOption.hasOwnProperty.call(commandHandler.choiceOption,subcommand)){
116
- commandHandler.choiceOption[subcommand].call(commandHandler,subcommand,options);
117
- } else {
118
- console.error(`Sub-Command (jira ${subcommand}... ) is not available`);
119
- process.exit(1);
120
- }
121
- });
139
+ }
122
140
 
123
141
 
142
+ }
124
143
 
125
- }
126
- })
127
- ]);
144
+ ]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.3.x
2
+ * QCObjects CLI 2.4.x
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -38,5 +38,5 @@ const package_config = require(absolutePath+"/package.json");
38
38
  const { exec,execSync } = require("child_process");
39
39
 
40
40
  // plugin commands here
41
- require(absolutePath+"/org.quickcorp.qcobjects.cli.commands.version");
42
- require(absolutePath+"/org.quickcorp.qcobjects.cli.commands.jira");
41
+ require(absolutePath+"/com.qcobjects.cli.commands.version");
42
+ require(absolutePath+"/com.qcobjects.cli.commands.jira");