qcobjects-cli 2.5.103-beta → 2.5.105-beta

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 (89) hide show
  1. package/VERSION +1 -1
  2. package/build-esbuild.js +65 -12
  3. package/package.json +55 -21
  4. package/public/browser/com.qcobjects.cli.commands.jira.client_services.js +66 -55
  5. package/public/browser/com.qcobjects.cli.commands.jira.client_services.js.map +2 -2
  6. package/public/browser/com.qcobjects.cli.commands.jira.js +138 -93
  7. package/public/browser/com.qcobjects.cli.commands.jira.js.map +4 -4
  8. package/public/browser/com.qcobjects.cli.commands.js +371 -14
  9. package/public/browser/com.qcobjects.cli.commands.js.map +4 -4
  10. package/public/browser/com.qcobjects.cli.commands.version.js +220 -214
  11. package/public/browser/com.qcobjects.cli.commands.version.js.map +2 -2
  12. package/public/browser/index.js +4042 -13
  13. package/public/browser/index.js.map +4 -4
  14. package/public/browser/org.qcobjects.common.pipelog.js +37 -24
  15. package/public/browser/org.qcobjects.common.pipelog.js.map +2 -2
  16. package/public/browser/org.qcobjects.enterprise.commands.js +108 -117
  17. package/public/browser/org.qcobjects.enterprise.commands.js.map +3 -3
  18. package/public/browser/org.quickcorp.qcobjects.api.client_services.js +64 -55
  19. package/public/browser/org.quickcorp.qcobjects.api.client_services.js.map +2 -2
  20. package/public/browser/org.quickcorp.qcobjects.cli.js +1280 -379
  21. package/public/browser/org.quickcorp.qcobjects.cli.js.map +4 -4
  22. package/public/browser/org.quickcorp.qcobjects.defaultsettings.js +373 -359
  23. package/public/browser/org.quickcorp.qcobjects.defaultsettings.js.map +2 -2
  24. package/public/browser/qcobjects-cli.js +4042 -13
  25. package/public/browser/qcobjects-cli.js.map +4 -4
  26. package/public/browser/templates/apps/spa-local.html +28 -0
  27. package/public/browser/templates/apps/spa-local.js +65 -0
  28. package/public/browser/templates/pwa/sw.js +112 -0
  29. package/public/cjs/com.qcobjects.cli.commands.cjs +377 -6
  30. package/public/cjs/com.qcobjects.cli.commands.cjs.map +4 -4
  31. package/public/cjs/com.qcobjects.cli.commands.jira.cjs +82 -24
  32. package/public/cjs/com.qcobjects.cli.commands.jira.cjs.map +4 -4
  33. package/public/cjs/com.qcobjects.cli.commands.jira.client_services.cjs +25 -1
  34. package/public/cjs/com.qcobjects.cli.commands.jira.client_services.cjs.map +2 -2
  35. package/public/cjs/com.qcobjects.cli.commands.version.cjs +25 -6
  36. package/public/cjs/com.qcobjects.cli.commands.version.cjs.map +2 -2
  37. package/public/cjs/index.cjs +4042 -13
  38. package/public/cjs/index.cjs.map +4 -4
  39. package/public/cjs/org.qcobjects.common.pipelog.cjs +40 -14
  40. package/public/cjs/org.qcobjects.common.pipelog.cjs.map +2 -2
  41. package/public/cjs/org.qcobjects.enterprise.commands.cjs +38 -34
  42. package/public/cjs/org.qcobjects.enterprise.commands.cjs.map +3 -3
  43. package/public/cjs/org.quickcorp.qcobjects.api.client_services.cjs +24 -2
  44. package/public/cjs/org.quickcorp.qcobjects.api.client_services.cjs.map +2 -2
  45. package/public/cjs/org.quickcorp.qcobjects.cli.cjs +1032 -118
  46. package/public/cjs/org.quickcorp.qcobjects.cli.cjs.map +4 -4
  47. package/public/cjs/org.quickcorp.qcobjects.defaultsettings.cjs +362 -334
  48. package/public/cjs/org.quickcorp.qcobjects.defaultsettings.cjs.map +2 -2
  49. package/public/cjs/qcobjects-cli.cjs +4047 -13
  50. package/public/cjs/qcobjects-cli.cjs.map +4 -4
  51. package/public/cjs/templates/apps/spa-local.html +28 -0
  52. package/public/cjs/templates/apps/spa-local.js +65 -0
  53. package/public/cjs/templates/pwa/sw.js +112 -0
  54. package/public/esm/com.qcobjects.cli.commands.jira.client_services.mjs +50 -57
  55. package/public/esm/com.qcobjects.cli.commands.jira.client_services.mjs.map +2 -2
  56. package/public/esm/com.qcobjects.cli.commands.jira.mjs +119 -94
  57. package/public/esm/com.qcobjects.cli.commands.jira.mjs.map +4 -4
  58. package/public/esm/com.qcobjects.cli.commands.mjs +357 -16
  59. package/public/esm/com.qcobjects.cli.commands.mjs.map +4 -4
  60. package/public/esm/com.qcobjects.cli.commands.version.mjs +204 -216
  61. package/public/esm/com.qcobjects.cli.commands.version.mjs.map +2 -2
  62. package/public/esm/index.mjs +4043 -13
  63. package/public/esm/index.mjs.map +4 -4
  64. package/public/esm/org.qcobjects.common.pipelog.mjs +21 -26
  65. package/public/esm/org.qcobjects.common.pipelog.mjs.map +2 -2
  66. package/public/esm/org.qcobjects.enterprise.commands.mjs +92 -119
  67. package/public/esm/org.qcobjects.enterprise.commands.mjs.map +3 -3
  68. package/public/esm/org.quickcorp.qcobjects.api.client_services.mjs +48 -57
  69. package/public/esm/org.quickcorp.qcobjects.api.client_services.mjs.map +2 -2
  70. package/public/esm/org.quickcorp.qcobjects.cli.mjs +1266 -380
  71. package/public/esm/org.quickcorp.qcobjects.cli.mjs.map +4 -4
  72. package/public/esm/org.quickcorp.qcobjects.defaultsettings.mjs +357 -361
  73. package/public/esm/org.quickcorp.qcobjects.defaultsettings.mjs.map +2 -2
  74. package/public/esm/qcobjects-cli.mjs +4046 -14
  75. package/public/esm/qcobjects-cli.mjs.map +4 -4
  76. package/public/esm/templates/apps/spa-local.html +28 -0
  77. package/public/esm/templates/apps/spa-local.js +65 -0
  78. package/public/esm/templates/pwa/sw.js +112 -0
  79. package/public/index.d.ts +140 -10
  80. package/src/com.qcobjects.cli.commands.jira.client_services.ts +19 -21
  81. package/src/com.qcobjects.cli.commands.jira.ts +11 -34
  82. package/src/com.qcobjects.cli.commands.ts +3 -9
  83. package/src/com.qcobjects.cli.commands.version.ts +1 -9
  84. package/src/org.qcobjects.common.pipelog.ts +18 -15
  85. package/src/org.qcobjects.enterprise.commands.ts +29 -50
  86. package/src/org.quickcorp.qcobjects.api.client_services.ts +1 -4
  87. package/src/org.quickcorp.qcobjects.cli.ts +28 -57
  88. package/src/org.quickcorp.qcobjects.defaultsettings.ts +359 -355
  89. package/src/qcobjects-cli.ts +4 -5
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  var global = (() => {
3
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
9
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -12,6 +14,19 @@ var global = (() => {
12
14
  var __commonJS = (cb, mod) => function __require2() {
13
15
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
16
  };
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
30
 
16
31
  // node_modules/commander/lib/error.js
17
32
  var require_error = __commonJS({
@@ -939,8 +954,8 @@ var global = (() => {
939
954
  "use strict";
940
955
  var EventEmitter = __require("events").EventEmitter;
941
956
  var childProcess = __require("child_process");
942
- var path = __require("path");
943
- var fs = __require("fs");
957
+ var path4 = __require("path");
958
+ var fs3 = __require("fs");
944
959
  var process2 = __require("process");
945
960
  var { Argument, humanReadableArgName } = require_argument();
946
961
  var { CommanderError } = require_error();
@@ -1770,10 +1785,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1770
1785
  let launchWithNode = false;
1771
1786
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1772
1787
  function findFile(baseDir, baseName) {
1773
- const localBin = path.resolve(baseDir, baseName);
1774
- if (fs.existsSync(localBin)) return localBin;
1775
- if (sourceExt.includes(path.extname(baseName))) return void 0;
1776
- const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
1788
+ const localBin = path4.resolve(baseDir, baseName);
1789
+ if (fs3.existsSync(localBin)) return localBin;
1790
+ if (sourceExt.includes(path4.extname(baseName))) return void 0;
1791
+ const foundExt = sourceExt.find((ext) => fs3.existsSync(`${localBin}${ext}`));
1777
1792
  if (foundExt) return `${localBin}${foundExt}`;
1778
1793
  return void 0;
1779
1794
  }
@@ -1785,23 +1800,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1785
1800
  if (this._scriptPath) {
1786
1801
  let resolvedScriptPath;
1787
1802
  try {
1788
- resolvedScriptPath = fs.realpathSync(this._scriptPath);
1803
+ resolvedScriptPath = fs3.realpathSync(this._scriptPath);
1789
1804
  } catch (err) {
1790
1805
  resolvedScriptPath = this._scriptPath;
1791
1806
  }
1792
- executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
1807
+ executableDir = path4.resolve(path4.dirname(resolvedScriptPath), executableDir);
1793
1808
  }
1794
1809
  if (executableDir) {
1795
1810
  let localFile = findFile(executableDir, executableFile);
1796
1811
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1797
- const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
1812
+ const legacyName = path4.basename(this._scriptPath, path4.extname(this._scriptPath));
1798
1813
  if (legacyName !== this._name) {
1799
1814
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1800
1815
  }
1801
1816
  }
1802
1817
  executableFile = localFile || executableFile;
1803
1818
  }
1804
- launchWithNode = sourceExt.includes(path.extname(executableFile));
1819
+ launchWithNode = sourceExt.includes(path4.extname(executableFile));
1805
1820
  let proc;
1806
1821
  if (process2.platform !== "win32") {
1807
1822
  if (launchWithNode) {
@@ -2578,7 +2593,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2578
2593
  * @return {Command}
2579
2594
  */
2580
2595
  nameFromFilename(filename) {
2581
- this._name = path.basename(filename, path.extname(filename));
2596
+ this._name = path4.basename(filename, path4.extname(filename));
2582
2597
  return this;
2583
2598
  }
2584
2599
  /**
@@ -2592,9 +2607,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2592
2607
  * @param {string} [path]
2593
2608
  * @return {string|Command}
2594
2609
  */
2595
- executableDir(path2) {
2596
- if (path2 === void 0) return this._executableDir;
2597
- this._executableDir = path2;
2610
+ executableDir(path5) {
2611
+ if (path5 === void 0) return this._executableDir;
2612
+ this._executableDir = path5;
2598
2613
  return this;
2599
2614
  }
2600
2615
  /**
@@ -2794,392 +2809,1278 @@ Expecting one of '${allowedValues.join("', '")}'`);
2794
2809
  });
2795
2810
 
2796
2811
  // src/org.quickcorp.qcobjects.cli.ts
2797
- var require_org_quickcorp_qcobjects_cli = __commonJS({
2798
- "src/org.quickcorp.qcobjects.cli.ts"(exports) {
2799
- var fs = __require("fs");
2800
- var path = __require("path");
2801
- var absolutePath = path.resolve(__dirname, "./");
2802
- var templatePath = path.resolve(__dirname, "./templates/apps/") + "/";
2803
- var templatePwaPath = path.resolve(__dirname, "./templates/pwa/") + "/";
2804
- var package_config = __require(absolutePath + "/../package.json");
2805
- var { exec, execSync } = __require("child_process");
2806
- var { CONFIG, findPackageNodePath, Import, logger, Package, InheritClass, New, serviceLoader, global, Service, Component } = __require("qcobjects");
2807
- CONFIG.set("node_modules_path", "./node_modules/");
2808
- CONFIG.set("qcobjectsnewapp_path", CONFIG.get("node_modules_path") + "/qcobjectsnewapp");
2809
- var { QCObjectsEnterprise } = __require(absolutePath + "/org.qcobjects.enterprise.commands");
2810
- var { QuickCorpCloud } = __require(absolutePath + "/org.quickcorp.qcobjects.api.client_services");
2811
- __require(absolutePath + "/com.qcobjects.cli.commands");
2812
- var SwitchCommander = class extends InheritClass {
2813
- static {
2814
- __name(this, "SwitchCommander");
2815
- }
2816
- choiceOption = {
2817
- generateSw: /* @__PURE__ */ __name((_appName, options) => {
2818
- const dirPrefix = options.dir;
2819
- const switchCommander = this;
2820
- const appName = typeof _appName === "undefined" || _appName === true ? "MyAppName" : _appName;
2821
- switchCommander.generateServiceWorker(appName, dirPrefix).catch((e) => {
2822
- logger.warn(`An error ocurred while creating service worker: ${e}`);
2823
- });
2824
- }, "generateSw"),
2825
- create: /* @__PURE__ */ __name((_appName, options) => {
2826
- const version = global.__get_version__();
2827
- const switchCommander = this;
2828
- const appName = typeof _appName === "undefined" || _appName === true ? "MyAppName" : _appName;
2829
- const _package_json_content = `{
2830
- "name": "${appName}"
2831
- "version": "1.0.0",
2832
- "dependencies":{
2833
- "qcobjectsnewphp": "latest",
2834
- "qcobjects": "${version.qcobjects}",
2835
- "qcobjects-sdk": "^${version.sdk}"
2836
- }
2837
- }`;
2838
- let appTemplateName;
2839
- if (options.createAmp) {
2840
- appTemplateName = "qcobjects-ecommerce-amp";
2841
- } else if (options.createPwa) {
2842
- appTemplateName = "qcobjectsnewapp";
2843
- } else if (options.createPhp) {
2844
- appTemplateName = "qcobjectsnewphp";
2845
- } else if (options.createCustom) {
2846
- appTemplateName = options.createCustom;
2847
- } else {
2848
- appTemplateName = "qcobjectsnewapp";
2849
- }
2850
- CONFIG.set("qcobjectsnewapp_path", CONFIG.get("node_modules_path") + "/" + appTemplateName);
2851
- const _package_json_template_fname = path.resolve(CONFIG.get("qcobjectsnewapp_path", "qcobjectsnewapp"), "./package.json");
2852
- const createAppCommand = "npm init -y";
2853
- const _package_json_file = path.resolve(CONFIG.get("projectPath"), "./package.json");
2854
- logger.debug("_package_json_file: " + _package_json_file);
2855
- logger.debug(createAppCommand);
2856
- exec(createAppCommand, (err, stdout, stderr) => {
2857
- if (err) {
2858
- throw Error(err.message);
2859
- process.exit(1);
2860
- return;
2861
- }
2862
- exec(`npm i --save-dev ${appTemplateName}`, () => {
2863
- const _package_json_template_file = __require(_package_json_template_fname);
2864
- _package_json_template_file.name = appName;
2865
- _package_json_template_file.version = "1.0.0";
2866
- _package_json_template_file.repository = {};
2867
- fs.writeFileSync(_package_json_file, JSON.stringify(_package_json_template_file, null, 4));
2868
- logger.info("Good! App Templates was installed!");
2869
- console.log(`Starting to copy files from app template ${appTemplateName} to your project...`);
2870
- switchCommander.copyTemplate(path.resolve(findPackageNodePath(appTemplateName), appTemplateName), path.resolve(CONFIG.get("projectPath"), "./")).then(() => {
2871
- exec("npm uninstall " + appTemplateName + " --save && npm cache verify", (err2, stdout2, stderr2) => {
2872
- if (err2) {
2873
- throw Error(err2.message);
2874
- process.exit(1);
2875
- return;
2876
- }
2877
- execSync("npm install --save-dev qcobjects-cli ");
2878
- });
2879
- exec("npm cache verify && npm i ", (err2, stdout2, stderr2) => {
2880
- if (err2) {
2881
- throw Error(err2.message);
2882
- process.exit(1);
2883
- return;
2812
+ var org_quickcorp_qcobjects_cli_exports = {};
2813
+ __export(org_quickcorp_qcobjects_cli_exports, {
2814
+ EnterpriseCommands: () => org_qcobjects_enterprise_commands_exports,
2815
+ QuickCorpServices: () => org_quickcorp_qcobjects_api_client_services_exports,
2816
+ SwitchCommander: () => SwitchCommander,
2817
+ customCommands: () => com_qcobjects_cli_commands_exports,
2818
+ getPluginCommandsList: () => getPluginCommandsList
2819
+ });
2820
+
2821
+ // src/org.qcobjects.enterprise.commands.ts
2822
+ var org_qcobjects_enterprise_commands_exports = {};
2823
+ __export(org_qcobjects_enterprise_commands_exports, {
2824
+ QCObjectsEnterprise: () => QCObjectsEnterprise
2825
+ });
2826
+ var import_node_child_process = __require("node:child_process");
2827
+ var { Package, InheritClass, CONFIG, logger } = __require("qcobjects");
2828
+ var license = CONFIG.get("enterprise-license", "1234");
2829
+ var email = CONFIG.get("enterprise-email", "a@b.com");
2830
+ var QCObjectsEnterprise = class extends InheritClass {
2831
+ static {
2832
+ __name(this, "QCObjectsEnterprise");
2833
+ }
2834
+ install() {
2835
+ const instance = this;
2836
+ return instance.installEnterprise(license, email);
2837
+ }
2838
+ upgrade(switchCommander) {
2839
+ const instance = this;
2840
+ const readline = __require("readline");
2841
+ const rl = readline.createInterface({
2842
+ input: process.stdin,
2843
+ output: process.stdout
2844
+ });
2845
+ var emailQuestion = /* @__PURE__ */ __name(function() {
2846
+ rl.question(`
2847
+ [NOTE: No information will be sent to a server until I got your consent]
2848
+
2849
+ Please tell me your e-Mail (\u{1F48C}):
2850
+ `, (email2) => {
2851
+ if (email2 !== "") {
2852
+ var phoneNumberQuestion = /* @__PURE__ */ __name(function() {
2853
+ rl.question("Please tell me your phone number (\u{1F919}): \n", (phonenumber) => {
2854
+ if (phonenumber !== "") {
2855
+ rl.question(`
2856
+ Please select one of the following options (type a number):
2857
+
2858
+ 1.- \u{1F640} This is your first interaction \u{1F60D} with QCObjects Enterprise Edition \u{1F3E2},
2859
+ you want to send your email and phone number to one of our executives to process your
2860
+ inquiry, pay the license (when aplies) and receive a new fresh license number
2861
+ that will free up to you the most advanced features for large companies
2862
+
2863
+ 2.- \u2714 Your assigned executive \u{1F9D1} has given to you a new fresh QCObjects Enterprise Edition License Number
2864
+ and you want to enter it to follow up with the next steps.
2865
+
2866
+ 3.- \u{1F3C3} You want to quit this form, as you got here accidentally
2867
+ (You should think about it. It's not a coincidence, It's destiny \u{1F600}).
2868
+
2869
+ Please enter the number of the option and press [enter]: `, (interaction_option) => {
2870
+ logger.infoEnabled = true;
2871
+ switch (interaction_option) {
2872
+ case "1":
2873
+ switchCommander.register(email2, phonenumber).then(function() {
2874
+ logger.info(`\u{1F44F} Congrats! You have been successfully registered to the cloud! \u{1F44F}
2875
+ One of our executives will be in touch with you as soon as possible to give you the next steps
2876
+ to get a new License Number and start using QCObjects Entrprise Edition!
2877
+
2878
+ (In the meantime, you can continue using all the features of the QCObjects Community Edition)
2879
+ `);
2880
+ rl.close();
2881
+ }).catch(() => {
2882
+ rl.close();
2883
+ });
2884
+ break;
2885
+ case "2":
2886
+ rl.stdoutMuted = true;
2887
+ rl._writeToOutput = /* @__PURE__ */ __name(function _writeToOutput(stringToWrite) {
2888
+ if (rl.stdoutMuted)
2889
+ rl.output.write("*");
2890
+ else
2891
+ rl.output.write(stringToWrite);
2892
+ }, "_writeToOutput");
2893
+ rl.question("Please tell me the number of license that your executive has given to you: \n", (license2) => {
2894
+ rl.stdoutMuted = false;
2895
+ instance.installEnterprise(license2, email2);
2896
+ rl.close();
2897
+ });
2898
+ break;
2899
+ default:
2900
+ logger.info("\u{1F937} You can continue to use QCObjects Community Edition, see you! \u{1F64B} ");
2901
+ rl.close();
2902
+ break;
2884
2903
  }
2885
- logger.info("Good! Your application is done. You can play with QCObjects now!");
2886
- logger.info("I will create the SSL certificates now. It may take some time...");
2887
- exec("qcobjects-createcert", (err3, stdout3, stderr3) => {
2888
- logger.info("Test certificates generated");
2889
- const githubService = New(Service);
2890
- githubService.url = "https://raw.githubusercontent.com/QuickCorp/QCObjects/main/.gitignore";
2891
- githubService.headers = {
2892
- Accept: "application/vnd.github+json",
2893
- "X-GitHub-Api-Version": "2022-11-28",
2894
- "User-Agent": "qcobjects-cli"
2895
- };
2896
- githubService.done = () => {
2897
- };
2898
- serviceLoader(githubService).then(({ service }) => {
2899
- fs.writeFileSync(path.resolve(CONFIG.get("projectPath"), "./.gitignore"), service.template);
2900
- try {
2901
- execSync("git init");
2902
- logger.debug("Git initialized.");
2903
- } catch (e) {
2904
- logger.debug("Could not initialize git.");
2905
- }
2906
- });
2907
- }).stdout.on("data", function(data) {
2908
- console.log(data);
2909
- });
2910
- }).stdout.on("data", function(data) {
2911
- console.log(data);
2912
2904
  });
2913
- }).catch((e) => {
2914
- console.log(e);
2915
- });
2916
- }).stdout.on("data", function(data) {
2917
- console.log(data);
2905
+ } else {
2906
+ console.log(`You need to enter a Phone Number if you want to be contacted.
2907
+ If you want to quit, press Ctrl-C.
2908
+ `);
2909
+ phoneNumberQuestion();
2910
+ }
2918
2911
  });
2919
- }).stdout.on("data", function(data) {
2920
- console.log("App generation started...");
2921
- });
2922
- }, "create"),
2923
- publish(_appName, _options) {
2924
- logger.debug("publish is not yet implemented");
2925
- },
2926
- upgradeToEnterprise(_appName, _options) {
2927
- const switchCommander = this;
2928
- QCObjectsEnterprise.upgrade(switchCommander);
2912
+ }, "phoneNumberQuestion");
2913
+ phoneNumberQuestion();
2914
+ } else {
2915
+ console.log(`You need to enter a real e-Mail adress if you want to be contacted.
2916
+ If you want to quit, press Ctrl-C.
2917
+ `);
2918
+ emailQuestion();
2929
2919
  }
2930
- };
2931
- constructor() {
2932
- super();
2933
- this.program = require_commander();
2934
- }
2935
- shellCommands(_shell_commands) {
2936
- return new Promise(function(resolve_all, reject_all) {
2937
- var _promises_set = _shell_commands.map(
2938
- function(shell_command) {
2939
- return new Promise(
2940
- function(resolve, reject) {
2941
- logger.debug(shell_command);
2942
- exec(shell_command, (err, stdout, stderr) => {
2943
- if (!err) {
2944
- resolve(stdout);
2945
- } else {
2946
- logger.debug(`[FAILED]: ${shell_command}`);
2947
- logger.debug(`${stderr}`);
2948
- reject(stderr);
2949
- }
2950
- }).stdout.on("data", function(data) {
2951
- logger.info(data);
2952
- });
2953
- }
2954
- ).catch((e) => reject_all(e));
2920
+ });
2921
+ }, "emailQuestion");
2922
+ emailQuestion();
2923
+ }
2924
+ installEnterprise(license2, email2) {
2925
+ const asterisk = "*";
2926
+ logger.info(`Your entered license number is ${asterisk.repeat(license2.length)} and the email that you have entered is ${email2}`);
2927
+ logger.info("Now, I'm installing QCObjects Enterprise Edition in your computer...");
2928
+ const cmdDownloadGit = `npm i --force -g git+https://license:${license2}@software.qcobjects.io/qcobjects-enterprise/qcobjects-enterprise.git`;
2929
+ (0, import_node_child_process.execSync)(cmdDownloadGit);
2930
+ const stdout = (0, import_node_child_process.execSync)("qcobjects --version");
2931
+ if (stdout.lastIndexOf("Enterprise Edition") !== -1) {
2932
+ logger.info("\u{1F44F} Congrats! Now you have installed QCObjects Entrprise Edition! \u{1F44F}");
2933
+ logger.info(`You can test it using:
2934
+ > qcobjects --version
2935
+
2936
+ To find more help, type the command:
2937
+
2938
+ > qcobjects --help
2939
+
2940
+ Enjoy!
2941
+ `);
2942
+ } else {
2943
+ console.log("\u{1F926} Something went wrong \u{1F926} when trying to update your license to QCObjects Enterprise Edition");
2944
+ console.log("Ask your executive to help");
2945
+ }
2946
+ }
2947
+ };
2948
+ Package("org.qcobjects.enterprise.commands", [
2949
+ QCObjectsEnterprise
2950
+ ]);
2951
+
2952
+ // src/org.quickcorp.qcobjects.api.client_services.ts
2953
+ var org_quickcorp_qcobjects_api_client_services_exports = {};
2954
+ __export(org_quickcorp_qcobjects_api_client_services_exports, {
2955
+ QuickCorpCloud: () => QuickCorpCloud
2956
+ });
2957
+ var { Package: Package2, Service, logger: logger2 } = __require("qcobjects");
2958
+ var QuickCorpCloud = class extends Service {
2959
+ static {
2960
+ __name(this, "QuickCorpCloud");
2961
+ }
2962
+ constructor({
2963
+ name = "quickcorp_cloud",
2964
+ external = true,
2965
+ useHTTP2 = true,
2966
+ cached = false,
2967
+ method = "post",
2968
+ headers = {
2969
+ "origin": "localhost",
2970
+ "content-type": "application/json"
2971
+ },
2972
+ basePath = "https://cloud.quickcorp.org/",
2973
+ url = "",
2974
+ withCredentials = false
2975
+ }) {
2976
+ super({
2977
+ name,
2978
+ external,
2979
+ useHTTP2,
2980
+ cached,
2981
+ method,
2982
+ headers,
2983
+ basePath,
2984
+ url,
2985
+ withCredentials
2986
+ });
2987
+ }
2988
+ _new_(o) {
2989
+ this.headers["authorization"] = "Basic token";
2990
+ this.url = this.basePath + o.apiMethod;
2991
+ this.data = o.data;
2992
+ }
2993
+ done(service, standardResponse) {
2994
+ logger2.debug(standardResponse);
2995
+ }
2996
+ fail(e) {
2997
+ logger2.debug(e);
2998
+ }
2999
+ };
3000
+ Package2("org.quickcorp.qcobjects.api.client_services", [
3001
+ QuickCorpCloud
3002
+ ]);
3003
+
3004
+ // src/com.qcobjects.cli.commands.ts
3005
+ var com_qcobjects_cli_commands_exports = {};
3006
+ __export(com_qcobjects_cli_commands_exports, {
3007
+ jiraCommand: () => com_qcobjects_cli_commands_jira_exports,
3008
+ versionCommand: () => com_qcobjects_cli_commands_version_exports
3009
+ });
3010
+
3011
+ // src/com.qcobjects.cli.commands.version.ts
3012
+ var com_qcobjects_cli_commands_version_exports = {};
3013
+ __export(com_qcobjects_cli_commands_version_exports, {
3014
+ CommandHandler: () => CommandHandler
3015
+ });
3016
+ var fs = __require("fs");
3017
+ var path = __require("path");
3018
+ var { exec, execSync: execSync2 } = __require("child_process");
3019
+ var { Package: Package3, InheritClass: InheritClass2, logger: logger3 } = __require("qcobjects");
3020
+ var CommandHandler = class extends InheritClass2 {
3021
+ static {
3022
+ __name(this, "CommandHandler");
3023
+ }
3024
+ constructor({ switchCommander }) {
3025
+ super({ switchCommander });
3026
+ const commandHandler = this;
3027
+ this.choiceOption = {
3028
+ v_major(filename, options) {
3029
+ filename = typeof filename === "undefined" ? "VERSION" : filename;
3030
+ const versionString = this.getVersionStringFromFile(filename);
3031
+ const versionSuffix = this.parseVersionSuffix(versionString);
3032
+ const versionObject = this.parseVersionString(versionString);
3033
+ const major = parseInt(versionObject.major);
3034
+ const minor = parseInt(versionObject.minor);
3035
+ const patch = parseInt(versionObject.patch);
3036
+ const newVersion = this.buildNewVersionString({ major: major + 1, minor, patch }, versionSuffix);
3037
+ this.saveNewVersionFile(filename, newVersion);
3038
+ if (options.syncGit) {
3039
+ var commitMsg = options.commitMsg || `New Version v${newVersion}`;
3040
+ this.syncGit(newVersion, commitMsg, options.syncNpm);
3041
+ }
3042
+ },
3043
+ v_minor(filename, options) {
3044
+ filename = typeof filename === "undefined" ? "VERSION" : filename;
3045
+ const versionString = this.getVersionStringFromFile(filename);
3046
+ const versionSuffix = this.parseVersionSuffix(versionString);
3047
+ const versionObject = this.parseVersionString(versionString);
3048
+ const major = parseInt(versionObject.major);
3049
+ const minor = parseInt(versionObject.minor);
3050
+ const patch = parseInt(versionObject.patch);
3051
+ const newVersion = this.buildNewVersionString({ major, minor: minor + 1, patch }, versionSuffix);
3052
+ this.saveNewVersionFile(filename, newVersion);
3053
+ if (options.syncGit) {
3054
+ var commitMsg = options.commitMsg || `New Version v${newVersion}`;
3055
+ this.syncGit(newVersion, commitMsg, options.syncNpm);
3056
+ }
3057
+ },
3058
+ v_patch(filename, options) {
3059
+ filename = typeof filename === "undefined" ? "VERSION" : filename;
3060
+ const versionString = this.getVersionStringFromFile(filename);
3061
+ const versionSuffix = this.parseVersionSuffix(versionString);
3062
+ const versionObject = this.parseVersionString(versionString);
3063
+ const major = parseInt(versionObject.major);
3064
+ const minor = parseInt(versionObject.minor);
3065
+ const patch = parseInt(versionObject.patch);
3066
+ const newVersion = this.buildNewVersionString({ major, minor, patch: patch + 1 }, versionSuffix);
3067
+ this.saveNewVersionFile(filename, newVersion);
3068
+ if (options.syncGit) {
3069
+ var commitMsg = options.commitMsg || `New Version v${newVersion}`;
3070
+ this.syncGit(newVersion, commitMsg, options.syncNpm);
3071
+ }
3072
+ },
3073
+ v_sync(filename, options) {
3074
+ filename = typeof filename === "undefined" ? "VERSION" : filename;
3075
+ var commandHandler2 = this;
3076
+ commandHandler2.switchCommander.shellCommands([
3077
+ "echo $(git describe)"
3078
+ ]).then(function(response) {
3079
+ const versionString = response[0].split("-")[0].slice(1).replace("\n", "");
3080
+ console.log(versionString);
3081
+ const versionSuffix = commandHandler2.parseVersionSuffix(versionString);
3082
+ const versionObject = commandHandler2.parseVersionString(versionString);
3083
+ const major = parseInt(versionObject.major);
3084
+ const minor = parseInt(versionObject.minor);
3085
+ const patch = parseInt(versionObject.patch);
3086
+ const newVersion = commandHandler2.buildNewVersionString({ major, minor, patch }, versionSuffix);
3087
+ commandHandler2.saveNewVersionFile(filename, newVersion);
3088
+ var commitMsg = options.commitMsg || `Synced Version v${newVersion}`;
3089
+ commandHandler2.switchCommander.shellCommands(
3090
+ [
3091
+ "git fetch --tags -f",
3092
+ `git add . && git commit -am "${commitMsg}"`,
3093
+ "git fetch origin --tags",
3094
+ "git tag -ln",
3095
+ `npm version "${newVersion}" --allow-same-version -m "${commitMsg}"`,
3096
+ "git push && git push --tags"
3097
+ ]
3098
+ ).then(function(response2) {
3099
+ console.log(response2);
3100
+ });
3101
+ });
3102
+ },
3103
+ v_changelog() {
3104
+ const commandHandler2 = this;
3105
+ commandHandler2.switchCommander.shellCommands(
3106
+ [
3107
+ "git tag -ln"
3108
+ ]
3109
+ ).then(function(response) {
3110
+ var versionTags = response[0].split("\n").map((tag) => tag.split(" ").unique()).unique().map(
3111
+ (tag) => {
3112
+ return {
3113
+ "version": tag[0],
3114
+ "major": tag[0].split(".")[0],
3115
+ "minor": tag[0].split(".")[0] + "." + tag[0].split(".")[1],
3116
+ "description": tag.slice(1).join(" ").trim()
3117
+ };
2955
3118
  }
2956
3119
  );
2957
- var _promise_all = Promise.all(_promises_set).then(function(response) {
2958
- resolve_all(response);
2959
- }).catch(function(e) {
2960
- reject_all(e);
2961
- });
2962
- }).catch((e) => console.log(e));
2963
- }
2964
- fileListRecursive(dir) {
2965
- var instance = this;
2966
- return fs.statSync(dir).isDirectory() ? Array.prototype.concat(...fs.readdirSync(dir).map((f) => instance.fileListRecursive(path.join(dir, f)))).filter((f) => {
2967
- return !f.startsWith(".git") && f.lastIndexOf(".DS_Store") == -1;
2968
- }) : dir;
2969
- }
2970
- register(email, phonenumber) {
2971
- return new Promise(function(resolve, reject) {
2972
- logger.info("I'm going to register your profile on the cloud...");
2973
- const cloudClient = New(QuickCorpCloud, {
2974
- apiMethod: "register",
2975
- data: { email, phonenumber }
2976
- });
2977
- try {
2978
- const service = serviceLoader(cloudClient).then((successResonse) => {
2979
- const template = successResonse.service.template;
2980
- const response = JSON.parse(template);
2981
- resolve(response);
2982
- }).catch((e) => {
2983
- console.log("\u{1F926} Something went wrong \u{1F926} when trying to register you in the cloud");
2984
- reject(e);
2985
- });
2986
- } catch (e) {
2987
- console.log("\u{1F926} Something went wrong \u{1F926} when trying to register you in the cloud");
2988
- reject(e);
3120
+ var minorVersionTags = versionTags.filter((tag) => tag.version !== "").map((tag) => tag.version.split(".")[0] + "." + tag.version.split(".")[1]).unique();
3121
+ var history = minorVersionTags.map((minor) => {
3122
+ return {
3123
+ "major": minor.split(".")[0],
3124
+ "minor": minor,
3125
+ "history": "\n - " + versionTags.filter((tag) => tag.minor === minor).map(
3126
+ function(tag) {
3127
+ return tag.description;
3128
+ }
3129
+ ).filter((desc) => !desc.startsWith(minor.slice(1))).sort().unique().join("\n - ")
3130
+ };
3131
+ }).map((hist) => {
3132
+ return `## ${hist.major} -> ${hist.minor}
3133
+ ` + hist.history;
3134
+ }).join("\n");
3135
+ const subtitle = "This is an automatic Changelog history of versions generated using the command: **qcobjects v-changelog > CHANGELOG.md**";
3136
+ console.log("# Changelog \n\n" + subtitle + "\n\n" + history);
3137
+ });
3138
+ }
3139
+ };
3140
+ switchCommander.program.command("v-major [filename]").option("--git, --sync-git", "Sync with Git").option("--npm, --sync-npm", "Sync with NPM").option("-m, --commit-msg [message]", "Commit Message").description("Semantic Versioning: Upgrade to a new major version").action(function(args, options) {
3141
+ commandHandler.choiceOption.v_major.call(commandHandler, args, options);
3142
+ });
3143
+ switchCommander.program.command("v-minor [filename]").option("--git, --sync-git", "Sync with Git").option("--npm, --sync-npm", "Sync with NPM").option("-m, --commit-msg [message]", "Commit Message").description("Semantic Versioning: Upgrade to a new minor version").action(function(args, options) {
3144
+ commandHandler.choiceOption.v_minor.call(commandHandler, args, options);
3145
+ });
3146
+ switchCommander.program.command("v-patch [filename]").option("--git, --sync-git", "Sync with Git").option("--npm, --sync-npm", "Sync with NPM").option("-m, --commit-msg [message]", "Commit Message").description("Semantic Versioning: Upgrade to a new patch version").action(function(args, options) {
3147
+ commandHandler.choiceOption.v_patch.call(commandHandler, args, options);
3148
+ });
3149
+ switchCommander.program.command("v-sync [filename]").option("-m, --commit-msg [message]", "Commit Message").description("Semantic Versioning: Sync the version of NPM with version of GIT").action(function(args, options) {
3150
+ commandHandler.choiceOption.v_sync.call(commandHandler, args, options);
3151
+ });
3152
+ switchCommander.program.command("v-changelog").description("Semantic Versioning: Shows a changelog using Semantic Versioning").action(function(args, options) {
3153
+ commandHandler.choiceOption.v_changelog.call(commandHandler, args, options);
3154
+ });
3155
+ }
3156
+ syncGit(versionString, commitMsg, syncNpm = false) {
3157
+ let _commands_ = [];
3158
+ if (syncNpm) {
3159
+ _commands_ = _commands_.concat(
3160
+ [
3161
+ "git fetch --tags -f",
3162
+ `npm version "${versionString}" -m "${commitMsg}"`
3163
+ ]
3164
+ );
3165
+ }
3166
+ _commands_ = _commands_.concat(
3167
+ [
3168
+ `git add . && git commit -am "${commitMsg}"`,
3169
+ "git fetch origin --tags",
3170
+ "git tag -ln"
3171
+ ]
3172
+ );
3173
+ if (!syncNpm) {
3174
+ _commands_ = _commands_.concat(
3175
+ [
3176
+ `git tag -a "v${versionString}" -m "${commitMsg}"`
3177
+ ]
3178
+ );
3179
+ }
3180
+ _commands_ = _commands_.concat(
3181
+ [
3182
+ "git push && git push --tags"
3183
+ ]
3184
+ );
3185
+ this.switchCommander.shellCommands(_commands_).then(function(response) {
3186
+ logger3.info("Synced to Git");
3187
+ logger3.debug(response);
3188
+ }).catch(function(e) {
3189
+ logger3.info("Something went wrong trying to sync to git");
3190
+ logger3.debug(e);
3191
+ });
3192
+ }
3193
+ parseVersionString(versionString) {
3194
+ versionString = versionString.replace("\n", "");
3195
+ const regexpVer = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
3196
+ const versionObject = { ...versionString.match(regexpVer)?.groups };
3197
+ return versionObject;
3198
+ }
3199
+ getVersionStringFromFile(filename) {
3200
+ let versionString;
3201
+ try {
3202
+ versionString = fs.readFileSync(filename).toString().replace("\n", "");
3203
+ } catch (e) {
3204
+ versionString = "0.0.1";
3205
+ }
3206
+ return versionString;
3207
+ }
3208
+ buildNewSemVersionString({ major, minor, patch }) {
3209
+ return `${major}.${minor}.${patch}`;
3210
+ }
3211
+ parseVersionSuffix(versionString) {
3212
+ versionString = versionString.replace("\n", "");
3213
+ const versionObject = this.parseVersionString(versionString);
3214
+ const semVersionString = this.buildNewSemVersionString(versionObject);
3215
+ return versionString.replace(semVersionString, "");
3216
+ }
3217
+ buildNewVersionString({ major, minor, patch }, suffix) {
3218
+ const semVersionString = this.buildNewSemVersionString({ major, minor, patch });
3219
+ return `${semVersionString}${suffix}`;
3220
+ }
3221
+ saveNewVersionFile(filename, versionString) {
3222
+ fs.writeFileSync(filename, versionString);
3223
+ }
3224
+ };
3225
+ Package3("com.qcobjects.cli.commands.version", [
3226
+ CommandHandler
3227
+ ]);
3228
+
3229
+ // src/com.qcobjects.cli.commands.jira.ts
3230
+ var com_qcobjects_cli_commands_jira_exports = {};
3231
+ __export(com_qcobjects_cli_commands_jira_exports, {
3232
+ CommandHandler: () => CommandHandler2
3233
+ });
3234
+
3235
+ // src/com.qcobjects.cli.commands.jira.client_services.ts
3236
+ var { Package: Package4, Service: Service2, logger: logger4 } = __require("qcobjects");
3237
+ var JiraCloud = class extends Service2 {
3238
+ static {
3239
+ __name(this, "JiraCloud");
3240
+ }
3241
+ constructor({
3242
+ name = "jira_cloud",
3243
+ external = true,
3244
+ useHTTP2 = true,
3245
+ cached = false,
3246
+ method = "POST",
3247
+ headers = {
3248
+ "accept": "application/json",
3249
+ "content-type": "application/json"
3250
+ },
3251
+ basePath = "",
3252
+ url = "",
3253
+ withCredentials = false
3254
+ }) {
3255
+ super({
3256
+ name,
3257
+ external,
3258
+ useHTTP2,
3259
+ cached,
3260
+ method,
3261
+ headers,
3262
+ basePath,
3263
+ url,
3264
+ withCredentials
3265
+ });
3266
+ var o = this;
3267
+ this.domain = `${o.domain}`;
3268
+ this.basePath = `https://${this.domain}/`;
3269
+ this.username_password = `${o.username}:${o.password}`;
3270
+ this.headers["authorization"] = `Basic ${Buffer.from(this.username_password).toString("base64")}`;
3271
+ this.url = this.basePath + o.apiMethod;
3272
+ this.data = o.data;
3273
+ }
3274
+ done(service, standardResponse) {
3275
+ logger4.debug(standardResponse);
3276
+ }
3277
+ fail(e) {
3278
+ logger4.debug(e);
3279
+ }
3280
+ };
3281
+ Package4("com.qcobjects.cli.commands.jira.client_services", [
3282
+ JiraCloud
3283
+ ]);
3284
+
3285
+ // src/com.qcobjects.cli.commands.jira.ts
3286
+ var path2 = __require("path");
3287
+ var absolutePath = path2.resolve(__dirname, "./");
3288
+ var {
3289
+ exec: exec2,
3290
+ execSync: execSync3
3291
+ } = __require("child_process");
3292
+ var { Package: Package5, InheritClass: InheritClass3, _DataStringify, New, CONFIG: CONFIG2, logger: logger5, serviceLoader } = __require("qcobjects");
3293
+ var CommandHandler2 = class extends InheritClass3 {
3294
+ static {
3295
+ __name(this, "CommandHandler");
3296
+ }
3297
+ constructor({
3298
+ switchCommander
3299
+ }) {
3300
+ super({ switchCommander });
3301
+ this.choiceOption = {
3302
+ issues: /* @__PURE__ */ __name(function() {
3303
+ this.getIssueList().then(function(response) {
3304
+ console.log(_DataStringify(response));
3305
+ }).catch((e) => {
3306
+ console.log(e);
3307
+ process.exit(1);
3308
+ });
3309
+ }, "issues")
3310
+ };
3311
+ const commandHandler = this;
3312
+ switchCommander.program.command("jira <subcommand>").option("-u, --from-user [username]", "User name").option("-fp,--from-project <projectName>", "Project name").option("-p, --pwd <password>", "Password").option("-f, --format <format>", "Format (json, table)").description(`Jira Integration:
3313
+ Sub-Commands can be:
3314
+ issues: To get the issues list from JIRA
3315
+ `).action(function(subcommand, options) {
3316
+ if (commandHandler.choiceOption.hasOwnProperty.call(commandHandler.choiceOption, subcommand)) {
3317
+ commandHandler.choiceOption[subcommand].call(commandHandler, subcommand, options);
3318
+ } else {
3319
+ console.error(`Sub-Command (jira ${subcommand}... ) is not available`);
3320
+ process.exit(1);
3321
+ }
3322
+ });
3323
+ }
3324
+ getIssueList() {
3325
+ return new Promise(function(resolve, reject) {
3326
+ logger5.info("I'm going to get the issue list from the jira cloud...");
3327
+ const jira_config = CONFIG2.get("jira", null);
3328
+ if (jira_config !== null) {
3329
+ const jira_username = jira_config.username;
3330
+ const jira_password = jira_config.auth_token;
3331
+ const jira_project = jira_config.project;
3332
+ const jira_domain = jira_config.domain;
3333
+ const jira_issue_fields = ["id", "key", "summary", "timetracking"];
3334
+ const cloudClient = New(JiraCloud, {
3335
+ domain: `${jira_domain}`,
3336
+ username: `${jira_username}`,
3337
+ password: `${jira_password}`,
3338
+ apiMethod: "rest/api/latest/search",
3339
+ data: {
3340
+ "jql": `project = ${jira_project}`,
3341
+ "startAt": 0,
3342
+ "maxResults": 5e3,
3343
+ "fields": jira_issue_fields
2989
3344
  }
2990
3345
  });
3346
+ try {
3347
+ } catch (e) {
3348
+ console.error("\u{1F926} Something went wrong \u{1F926} when trying to get jira issues from the cloud");
3349
+ reject(e);
3350
+ }
3351
+ } else {
3352
+ console.error("\u{1F926} Something went wrong \u{1F926} You need to set the jira config settings");
3353
+ reject(new Error("\u{1F926} Something went wrong \u{1F926} You need to set the jira config settings"));
3354
+ }
3355
+ });
3356
+ }
3357
+ };
3358
+ Package5("com.qcobjects.cli.commands.jira", [
3359
+ CommandHandler2
3360
+ ]);
3361
+
3362
+ // src/org.quickcorp.qcobjects.defaultsettings.ts
3363
+ __require("qcobjects");
3364
+ var { CONFIG: CONFIG3, global, logger: logger6, _Crypt, findPackageNodePath, Export } = __require("qcobjects");
3365
+ var __get_version__ = /* @__PURE__ */ __name(() => {
3366
+ const path4 = __require("path");
3367
+ const absolutePath2 = path4.resolve(__dirname, "./");
3368
+ const package_config = __require(path4.resolve(process.cwd(), "package.json"));
3369
+ const qcobjects_pkg_config = __require("qcobjects/package.json");
3370
+ const qcobjects_sdk_pkg_config = __require("qcobjects-sdk/package.json");
3371
+ return {
3372
+ "qcobjects": qcobjects_pkg_config.version,
3373
+ "sdk": qcobjects_sdk_pkg_config.version,
3374
+ "cli": package_config.version
3375
+ };
3376
+ }, "__get_version__");
3377
+ var __get_version_string__ = /* @__PURE__ */ __name(() => {
3378
+ const version = __get_version__();
3379
+ return "QCObjects: v" + version.qcobjects + ", SDK: v" + version.sdk + ", CLI: v" + version.cli;
3380
+ }, "__get_version_string__");
3381
+ Export(__get_version__);
3382
+ Export(__get_version_string__);
3383
+ var __load_default_settings__ = /* @__PURE__ */ __name(() => {
3384
+ CONFIG3.set("documentRootFileIndex", "index.html");
3385
+ CONFIG3.set("projectPath", `${process.cwd()}/`);
3386
+ CONFIG3.set("useConfigService", false);
3387
+ CONFIG3.set("documentRoot", "./");
3388
+ CONFIG3.set("serverPortHTTP", 80);
3389
+ CONFIG3.set("serverPortHTTPS", 443);
3390
+ CONFIG3.set("private-key-pem", "localhost-privkey.pem");
3391
+ CONFIG3.set("private-cert-pem", "localhost-cert.pem");
3392
+ CONFIG3.set("allowHTTP1", true);
3393
+ CONFIG3.set("useTemplate", false);
3394
+ CONFIG3.set("domain", "localhost");
3395
+ const setDevMode = /* @__PURE__ */ __name((devmode) => {
3396
+ if (typeof devmode !== "undefined") {
3397
+ switch (true) {
3398
+ case devmode == "debug":
3399
+ logger6.debugEnabled = true;
3400
+ logger6.warnEnabled = true;
3401
+ logger6.infoEnabled = true;
3402
+ break;
3403
+ case devmode == "warn":
3404
+ logger6.debugEnabled = false;
3405
+ logger6.warnEnabled = true;
3406
+ logger6.infoEnabled = true;
3407
+ break;
3408
+ case devmode == "info":
3409
+ logger6.debugEnabled = false;
3410
+ logger6.warnEnabled = false;
3411
+ logger6.infoEnabled = true;
3412
+ break;
3413
+ default:
3414
+ logger6.debugEnabled = false;
3415
+ logger6.warnEnabled = false;
3416
+ logger6.infoEnabled = false;
3417
+ break;
3418
+ }
3419
+ } else {
3420
+ logger6.debugEnabled = false;
3421
+ logger6.warnEnabled = false;
3422
+ logger6.infoEnabled = false;
3423
+ }
3424
+ }, "setDevMode");
3425
+ try {
3426
+ var _config = __require(CONFIG3.get("projectPath") + "config.json");
3427
+ logger6.debug("Loading settings from your config.json");
3428
+ const _secretKey = Object.hasOwn(_config, "domain") ? _config["domain"] : "_secret_";
3429
+ if (Object.hasOwn(_config, "__encoded__")) {
3430
+ _config = JSON.parse(_Crypt.decrypt(_config.__encoded__, _secretKey));
3431
+ }
3432
+ for (var k in _config) {
3433
+ CONFIG3.set(k, _config[k]);
3434
+ }
3435
+ setDevMode(CONFIG3.get("devmode", ""));
3436
+ if (typeof CONFIG3.get("backend") !== "undefined") {
3437
+ global.set("backendAvailable", true);
3438
+ if (typeof CONFIG3.get("basePath") !== "undefined") {
3439
+ logger6.debug(`Changing the current directory: ${process.cwd()}`);
3440
+ try {
3441
+ process.chdir(CONFIG3.get("basePath"));
3442
+ logger6.debug(`New directory: ${process.cwd()}`);
3443
+ } catch (err) {
3444
+ logger6.warn(`It was impossible to change the current chdir: ${err}`);
3445
+ }
2991
3446
  }
2992
- generateServiceWorker(appName, dirPrefix = "./") {
2993
- const writeContent = /* @__PURE__ */ __name((component) => {
2994
- const parsedText = component.parseTemplate(component.template);
2995
- logger.debug("Starting to write the sw file...");
2996
- fs.writeFile(`${dirPrefix}/sw.js`, parsedText, (err) => {
2997
- if (err) {
2998
- throw Error(err);
3447
+ }
3448
+ } catch (e) {
3449
+ logger6.debug(e);
3450
+ logger6.debug("Something went wrong trying to load config.json file in your project");
3451
+ }
3452
+ (async function() {
3453
+ const path4 = __require("path");
3454
+ const projectPath = CONFIG3.get("projectPath", `${process.cwd()}/`);
3455
+ const loadDefaultRoutes = /* @__PURE__ */ __name(async () => {
3456
+ return await new Promise((resolve, reject) => {
3457
+ const sdkPath = path4.resolve(findPackageNodePath("qcobjects-sdk"), "qcobjects-sdk");
3458
+ const qcobjectsPath = path4.resolve(findPackageNodePath("qcobjects"), "qcobjects");
3459
+ let backend = CONFIG3.get("backend");
3460
+ if (typeof backend === "undefined") {
3461
+ backend = {};
3462
+ }
3463
+ if (typeof backend.routes === "undefined") {
3464
+ backend.routes = [];
3465
+ }
3466
+ backend.routes = backend.routes.concat([
3467
+ {
3468
+ "name": "QCObjects.js",
3469
+ "description": "Redirection of QCObjects.js",
3470
+ "path": "^/QCObjects.js$",
3471
+ "microservice": "com.qcobjects.backend.microservice.static",
3472
+ "redirect_to": path4.resolve(qcobjectsPath, "src", "QCObjects.js"),
3473
+ "responseHeaders": {},
3474
+ "cors": {
3475
+ "allow_origins": "*"
3476
+ }
3477
+ },
3478
+ {
3479
+ "name": "QCObjects-SDK.js",
3480
+ "description": "Redirection of QCObjects SDK",
3481
+ "path": "^/js/packages/QCObjects-SDK.js$",
3482
+ "microservice": "com.qcobjects.backend.microservice.static",
3483
+ "redirect_to": path4.resolve(sdkPath, "src/QCObjects-SDK.js"),
3484
+ "responseHeaders": {},
3485
+ "cors": {
3486
+ "allow_origins": "*"
3487
+ }
3488
+ },
3489
+ {
3490
+ "name": "QCObjects-SDK Components",
3491
+ "description": "Redirection of QCObjects SDK",
3492
+ "path": "^/qcobjects-sdk/(.*)$",
3493
+ "microservice": "com.qcobjects.backend.microservice.static",
3494
+ "redirect_to": path4.resolve(sdkPath, "$1"),
3495
+ "responseHeaders": {},
3496
+ "cors": {
3497
+ "allow_origins": "*"
2999
3498
  }
3000
- logger.info("Service Worker Generated");
3001
- console.log("");
3002
- console.log("Now simply put:");
3003
- console.log("CONFIG.set('serviceWorkerURI','/sw.js');");
3004
- console.log(" In your init.js file ");
3005
- console.log("");
3006
- console.log("To start your app in a local server ");
3007
- console.log("Execute the command: ");
3008
- console.log("> qcobjects launch <appname>");
3009
- console.log("");
3010
- });
3011
- }, "writeContent");
3012
- class ServiceWorkerComponent extends Component {
3013
- static {
3014
- __name(this, "ServiceWorkerComponent");
3015
- }
3016
- cached = false;
3017
- templateURI = "sw.js";
3018
- basePath = templatePwaPath;
3019
- name = "sw";
3020
- tplsource = "default";
3021
- template = "";
3022
- constructor({ name, data }) {
3023
- super({ name, data });
3024
3499
  }
3025
- done({ request, component }) {
3026
- super.done({ request, component });
3027
- writeContent(component);
3500
+ ]);
3501
+ CONFIG3.set("backend", backend);
3502
+ resolve();
3503
+ });
3504
+ }, "loadDefaultRoutes");
3505
+ await loadDefaultRoutes();
3506
+ })().then(() => logger6.info("Default routes loaded")).catch((e) => {
3507
+ logger6.warn(`An error ocurred loading default settings: ${e}`);
3508
+ });
3509
+ (function() {
3510
+ const path4 = __require("path");
3511
+ const fs3 = __require("fs");
3512
+ const projectPath = CONFIG3.get("projectPath", `${process.cwd()}/`);
3513
+ logger6.debug(`CONFIG.projectPath is set to ${projectPath}`);
3514
+ const findPath = /* @__PURE__ */ __name((p) => {
3515
+ const packagePath = path4.resolve(findPackageNodePath(p), p);
3516
+ return packagePath;
3517
+ }, "findPath");
3518
+ const getPackageJSON = /* @__PURE__ */ __name((p) => {
3519
+ let _json;
3520
+ try {
3521
+ const packagePath = findPath(p);
3522
+ if (typeof packagePath !== "undefined") {
3523
+ _json = JSON.parse(fs3.readFileSync(path4.resolve(`${packagePath}`, "./package.json")).toString());
3524
+ } else {
3525
+ _json = {};
3526
+ }
3527
+ } catch (e) {
3528
+ logger6.debug(`It was impossible to get the package.json from ${p}: ${e}`);
3529
+ _json = {};
3530
+ }
3531
+ return _json;
3532
+ }, "getPackageJSON");
3533
+ const hasKeyword = /* @__PURE__ */ (() => {
3534
+ let keywords = {};
3535
+ return (p, keyword) => {
3536
+ if (typeof keywords === "undefined") {
3537
+ keywords = {};
3538
+ }
3539
+ try {
3540
+ if (typeof keywords[p] === "undefined") {
3541
+ keywords[p] = getPackageJSON(p).keywords;
3028
3542
  }
3543
+ } catch (e) {
3544
+ throw Error(`Something went wrong when trying to get the keywords of ${p}`);
3029
3545
  }
3030
- return new Promise((resolve, reject) => {
3031
- var filelist = ["/"].concat(this.fileListRecursive(`${dirPrefix}`));
3032
- if (typeof dirPrefix !== "undefined" && dirPrefix !== "./" && dirPrefix !== ".") {
3033
- filelist = filelist.map((f) => f.replace(new RegExp(`${dirPrefix}/`), ""));
3034
- }
3035
- filelist = filelist.filter(function(fl) {
3036
- return fl !== "sw.js" && !fl.startsWith("node_modules/");
3037
- });
3038
- filelist = filelist.filter((fname) => !fname.endsWith(".pem"));
3039
- filelist = filelist.filter((fname) => !fname.endsWith(".sh"));
3040
- filelist = filelist.filter((fname) => !new RegExp("^package(.*).json$").test(fname));
3041
- filelist = filelist.filter((fname) => !fname.startsWith("."));
3042
- var fileListString = '\n "' + filelist.join('",\n "') + '"';
3043
- const component = new ServiceWorkerComponent({
3044
- name: "sw",
3045
- data: {
3046
- appName,
3047
- appVersion: "1.0.0",
3048
- filelist: fileListString
3049
- }
3050
- });
3051
- setTimeout(() => {
3052
- component.done({ request: null, component });
3053
- }, 1e3);
3054
- });
3055
- }
3056
- copyTemplate(source, dest) {
3057
- return new Promise((resolve, reject) => {
3058
- const copyDir = /* @__PURE__ */ __name((source2, dest2, exclude) => {
3059
- source2 = path.resolve(source2);
3060
- dest2 = path.resolve(dest2);
3061
- const dname = path.basename(source2);
3062
- const dirExcluded = exclude.includes(dname);
3063
- const isDir = /* @__PURE__ */ __name((d) => {
3064
- return fs.existsSync(d) && fs.statSync(d).isDirectory() ? true : false;
3065
- }, "isDir");
3066
- const isFile = /* @__PURE__ */ __name((d) => {
3067
- return fs.existsSync(d) && fs.statSync(d).isFile() ? true : false;
3068
- }, "isFile");
3069
- if (isDir(source2) && !dirExcluded) {
3070
- fs.mkdirSync(dest2, { recursive: true });
3071
- const paths = fs.readdirSync(source2, { withFileTypes: true });
3072
- const dirs = paths.filter((d) => d.isDirectory());
3073
- const files = paths.filter((f) => f.isFile());
3074
- ((paths2, dirs2, files2, exclude2) => {
3075
- files2.map((f) => {
3076
- const sourceFile = path.resolve(source2, f.name);
3077
- const destFile = path.resolve(dest2, f.name);
3078
- const fileExcluded = exclude2.includes(f.name);
3079
- if (isFile(sourceFile) && !fileExcluded) {
3080
- logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude2.join(",")}...`);
3081
- fs.copyFileSync(sourceFile, destFile);
3082
- logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude2.join(",")}...DONE!`);
3546
+ return typeof keywords[p] !== "undefined" && keywords[p].includes(keyword);
3547
+ };
3548
+ })();
3549
+ const setBackendValue = /* @__PURE__ */ __name((name, value) => {
3550
+ const backend = CONFIG3.get("backend", {});
3551
+ if (typeof value !== "undefined") {
3552
+ backend[name] = value;
3553
+ }
3554
+ CONFIG3.set("backend", backend);
3555
+ }, "setBackendValue");
3556
+ const dependencies = /* @__PURE__ */ (() => {
3557
+ let deps = [];
3558
+ return () => {
3559
+ if (typeof deps === "undefined") {
3560
+ deps = Object.keys(JSON.parse(fs3.readFileSync(path4.resolve(`${projectPath}`, "./package.json")).toString()).dependencies);
3561
+ setBackendValue("dependencies", deps);
3562
+ }
3563
+ return deps;
3564
+ };
3565
+ })();
3566
+ const devDependencies = /* @__PURE__ */ (() => {
3567
+ let deps = [];
3568
+ return () => {
3569
+ if (typeof deps === "undefined") {
3570
+ deps = Object.keys(JSON.parse(fs3.readFileSync(path4.resolve(`${projectPath}`, "./package.json")).toString()).devDependencies);
3571
+ setBackendValue("devDependencies", deps);
3572
+ }
3573
+ return deps;
3574
+ };
3575
+ })();
3576
+ const loadLibs = /* @__PURE__ */ __name(() => {
3577
+ let _ret_;
3578
+ if (CONFIG3.get("autodiscover", false) || CONFIG3.get("autodiscover_libs", false)) {
3579
+ const libs = dependencies().filter((p) => hasKeyword(p, "qcobjects-lib"));
3580
+ setBackendValue("libs", libs);
3581
+ if (libs.length > 0) {
3582
+ logger6.debug(`Plugin Libs found: ${libs.join(",")}`);
3583
+ _ret_ = Promise.all(libs.map((p) => {
3584
+ return __require(findPath(p));
3585
+ })).then(() => logger6.info("Libs loaded"));
3586
+ } else {
3587
+ logger6.debug("No Plugin Libs found.");
3588
+ _ret_ = Promise.resolve();
3589
+ }
3590
+ } else {
3591
+ logger6.debug("To load libs, set autodiscover_libs to true in your config.json");
3592
+ _ret_ = Promise.resolve();
3593
+ }
3594
+ return _ret_;
3595
+ }, "loadLibs");
3596
+ const loadHandlers = /* @__PURE__ */ __name(() => {
3597
+ let _ret_;
3598
+ if (CONFIG3.get("autodiscover", false) || CONFIG3.get("autodiscover_handlers", false)) {
3599
+ const handlers = dependencies().filter((p) => hasKeyword(p, "qcobjects-handler"));
3600
+ setBackendValue("handlers", handlers);
3601
+ if (handlers.length > 0) {
3602
+ logger6.debug(`Plugin Handlers found: ${handlers.join(",")}`);
3603
+ _ret_ = Promise.all(handlers.map((p) => {
3604
+ return __require(findPath(p));
3605
+ })).then(() => logger6.info("Handlers loaded"));
3606
+ } else {
3607
+ logger6.debug("No Plugin Handlers found.");
3608
+ _ret_ = Promise.resolve();
3609
+ }
3610
+ } else {
3611
+ logger6.debug("To load handlers, set autodiscover_handlers to true in your config.json");
3612
+ _ret_ = Promise.resolve();
3613
+ }
3614
+ return _ret_;
3615
+ }, "loadHandlers");
3616
+ const loadCommands = /* @__PURE__ */ __name(() => {
3617
+ let _ret_;
3618
+ logger6.debug(`Looking for custom commands as dependencies in: ${projectPath}/package.json`);
3619
+ if (CONFIG3.get("autodiscover", false) || CONFIG3.get("autodiscover_commands", false)) {
3620
+ const commands = dependencies().filter((p) => hasKeyword(p, "qcobjects-command"));
3621
+ setBackendValue("commands", commands);
3622
+ if (commands.length > 0) {
3623
+ logger6.debug(`Plugin Commands found: ${commands.join(",")}`);
3624
+ _ret_ = Promise.all(commands.map((p) => {
3625
+ return __require(findPath(p));
3626
+ })).then(() => logger6.info("Commands loaded"));
3627
+ } else {
3628
+ logger6.debug("No Plugin Commands found.");
3629
+ _ret_ = Promise.resolve();
3630
+ }
3631
+ } else {
3632
+ logger6.debug("To load commands, set autodiscover_commands to true in your config.json");
3633
+ _ret_ = Promise.resolve();
3634
+ }
3635
+ return _ret_;
3636
+ }, "loadCommands");
3637
+ const loadDevCommands = /* @__PURE__ */ __name(() => {
3638
+ let _ret_;
3639
+ logger6.debug(`Looking for custom commands as dev dependencies in: ${projectPath}/package.json`);
3640
+ if (CONFIG3.get("autodiscover", false) || CONFIG3.get("autodiscover_commands", false)) {
3641
+ const commands = devDependencies().filter((p) => hasKeyword(p, "qcobjects-command"));
3642
+ setBackendValue("devCommands", commands);
3643
+ if (commands.length > 0) {
3644
+ logger6.debug(`Dev Plugin Commands found: ${commands.join(",")}`);
3645
+ _ret_ = Promise.all(commands.map((p) => {
3646
+ return __require(findPath(p));
3647
+ })).then(() => logger6.info("Commands loaded"));
3648
+ } else {
3649
+ logger6.debug("No Plugin Commands found in dev dependencies.");
3650
+ _ret_ = Promise.resolve();
3651
+ }
3652
+ } else {
3653
+ logger6.debug("To load commands, set autodiscover_commands to true in your config.json");
3654
+ _ret_ = Promise.resolve();
3655
+ }
3656
+ return _ret_;
3657
+ }, "loadDevCommands");
3658
+ if (CONFIG3.get("autodiscover", false) || CONFIG3.get("autodiscover_libs", false) || CONFIG3.get("autodiscover_handlers", false) || CONFIG3.get("autodiscover_commands", false)) {
3659
+ logger6.info("Auto discover is enabled");
3660
+ } else if (!CONFIG3.get("autodiscover", false)) {
3661
+ logger6.info("Auto discover is disabled");
3662
+ logger6.debug("To load all dependencies, set autodiscover to true in your config.json");
3663
+ } else {
3664
+ logger6.info("Auto discover is disabled");
3665
+ }
3666
+ try {
3667
+ logger6.debug("Loading Libs...");
3668
+ loadLibs().catch((e) => {
3669
+ logger6.warn(`An error ocurred loading libs: ${e}`);
3670
+ });
3671
+ } catch (e) {
3672
+ throw Error(`Something went wrong trying to load libs: ${e.message}`);
3673
+ }
3674
+ try {
3675
+ logger6.debug("Loading Handlers...");
3676
+ loadHandlers().catch((e) => {
3677
+ logger6.warn(`An error ocurred loading handlers: ${e}`);
3678
+ });
3679
+ } catch (e) {
3680
+ throw Error(`Something went wrong trying to load handler: ${e.message}`);
3681
+ }
3682
+ try {
3683
+ logger6.debug("Loading Commands...");
3684
+ loadCommands().catch((e) => {
3685
+ logger6.warn(`An error ocurred loading commands: ${e}`);
3686
+ });
3687
+ } catch (e) {
3688
+ throw Error(`Something went wrong trying to load commands: ${e.message}`);
3689
+ }
3690
+ try {
3691
+ logger6.debug("Loading Dev Commands...");
3692
+ loadDevCommands().catch((e) => {
3693
+ logger6.warn(`An error ocurred loading dev commands: ${e}`);
3694
+ });
3695
+ } catch (e) {
3696
+ throw Error(`Something went wrong trying to load Dev commands: ${e.message}`);
3697
+ }
3698
+ try {
3699
+ const commands = CONFIG3.get("backend", { commands: [] }).commands || [];
3700
+ const devCommands = CONFIG3.get("backend", { devCommands: [] }).devCommands || [];
3701
+ setBackendValue("plugins", commands.concat(devCommands));
3702
+ } catch (e) {
3703
+ throw Error(`Something went wrong trying to load plugins list: ${e.message}`);
3704
+ }
3705
+ logger6.info("Dependencies loaded");
3706
+ process.once("SIGTERM", () => {
3707
+ console.log("\x1B[33m%s\x1B[0m", "Bye bye!");
3708
+ process.exit();
3709
+ });
3710
+ })();
3711
+ }, "__load_default_settings__");
3712
+ global.__load_default_settings__ = __load_default_settings__;
3713
+ global.__load_default_settings__();
3714
+ var cleanCache = /* @__PURE__ */ __name(() => {
3715
+ Object.keys(__require.cache).forEach((key) => {
3716
+ delete __require.cache[key];
3717
+ });
3718
+ }, "cleanCache");
3719
+ var __reset_settings__ = /* @__PURE__ */ __name(() => {
3720
+ cleanCache();
3721
+ global.__load_default_settings__();
3722
+ }, "__reset_settings__");
3723
+ global.__reset_settings__ = __reset_settings__;
3724
+
3725
+ // src/org.quickcorp.qcobjects.cli.ts
3726
+ var fs2 = __require("fs");
3727
+ var path3 = __require("path");
3728
+ var templatePwaPath = path3.resolve(__dirname, "./templates/pwa/") + "/";
3729
+ var { exec: exec3, execSync: execSync4 } = __require("child_process");
3730
+ __require("qcobjects");
3731
+ var { CONFIG: CONFIG4, findPackageNodePath: findPackageNodePath2, logger: logger7, Package: Package6, InheritClass: InheritClass4, New: New2, serviceLoader: serviceLoader2, global: global2, Service: Service3, Component } = __require("qcobjects");
3732
+ CONFIG4.set("node_modules_path", "./node_modules/");
3733
+ CONFIG4.set("qcobjectsnewapp_path", CONFIG4.get("node_modules_path") + "/qcobjectsnewapp");
3734
+ var getPluginCommandsList = /* @__PURE__ */ __name(() => {
3735
+ return global2.ClassesList.filter((c) => c.packageName.startsWith("com.qcobjects.cli.commands.")).filter((p) => p.classFactory.name.endsWith("CommandHandler"));
3736
+ }, "getPluginCommandsList");
3737
+ var SwitchCommander = class extends InheritClass4 {
3738
+ static {
3739
+ __name(this, "SwitchCommander");
3740
+ }
3741
+ choiceOption = {
3742
+ generateSw: /* @__PURE__ */ __name((_appName, options) => {
3743
+ const dirPrefix = options.dir;
3744
+ const switchCommander = this;
3745
+ const appName = typeof _appName === "undefined" || _appName === true ? "MyAppName" : _appName;
3746
+ switchCommander.generateServiceWorker(appName, dirPrefix).catch((e) => {
3747
+ logger7.warn(`An error ocurred while creating service worker: ${e}`);
3748
+ });
3749
+ }, "generateSw"),
3750
+ create: /* @__PURE__ */ __name((_appName, options) => {
3751
+ const version = __get_version__();
3752
+ const switchCommander = this;
3753
+ const appName = typeof _appName === "undefined" || _appName === true ? "MyAppName" : _appName;
3754
+ let appTemplateName;
3755
+ if (options.createAmp) {
3756
+ appTemplateName = "qcobjects-ecommerce-amp";
3757
+ } else if (options.createPwa) {
3758
+ appTemplateName = "qcobjectsnewapp";
3759
+ } else if (options.createPhp) {
3760
+ appTemplateName = "qcobjectsnewphp";
3761
+ } else if (options.createCustom) {
3762
+ appTemplateName = options.createCustom;
3763
+ } else {
3764
+ appTemplateName = "qcobjectsnewapp";
3765
+ }
3766
+ CONFIG4.set("qcobjectsnewapp_path", CONFIG4.get("node_modules_path") + "/" + appTemplateName);
3767
+ const _package_json_template_fname = path3.resolve(CONFIG4.get("qcobjectsnewapp_path", "qcobjectsnewapp"), "./package.json");
3768
+ const createAppCommand = "npm init -y";
3769
+ const _package_json_file = path3.resolve(CONFIG4.get("projectPath"), "./package.json");
3770
+ logger7.debug("_package_json_file: " + _package_json_file);
3771
+ logger7.debug(createAppCommand);
3772
+ exec3(createAppCommand, (err) => {
3773
+ if (err) {
3774
+ throw Error(err.message);
3775
+ process.exit(1);
3776
+ return;
3777
+ }
3778
+ exec3(`npm i --save-dev ${appTemplateName}`, () => {
3779
+ const _package_json_template_file = __require(_package_json_template_fname);
3780
+ _package_json_template_file.name = appName;
3781
+ _package_json_template_file.version = "1.0.0";
3782
+ _package_json_template_file.repository = {};
3783
+ fs2.writeFileSync(_package_json_file, JSON.stringify(_package_json_template_file, null, 4));
3784
+ logger7.info("Good! App Templates was installed!");
3785
+ console.log(`Starting to copy files from app template ${appTemplateName} to your project...`);
3786
+ switchCommander.copyTemplate(path3.resolve(findPackageNodePath2(appTemplateName), appTemplateName), path3.resolve(CONFIG4.get("projectPath"), "./")).then(() => {
3787
+ exec3("npm uninstall " + appTemplateName + " --save && npm cache verify", (err2) => {
3788
+ if (err2) {
3789
+ throw Error(err2.message);
3790
+ process.exit(1);
3791
+ return;
3792
+ }
3793
+ execSync4("npm install --save-dev qcobjects-cli ");
3794
+ });
3795
+ exec3("npm cache verify && npm i ", (err2) => {
3796
+ if (err2) {
3797
+ throw Error(err2.message);
3798
+ process.exit(1);
3799
+ return;
3800
+ }
3801
+ logger7.info("Good! Your application is done. You can play with QCObjects now!");
3802
+ logger7.info("I will create the SSL certificates now. It may take some time...");
3803
+ exec3("qcobjects-createcert", () => {
3804
+ logger7.info("Test certificates generated");
3805
+ const githubService = New2(Service3);
3806
+ githubService.url = "https://raw.githubusercontent.com/QuickCorp/QCObjects/main/.gitignore";
3807
+ githubService.headers = {
3808
+ Accept: "application/vnd.github+json",
3809
+ "X-GitHub-Api-Version": "2022-11-28",
3810
+ "User-Agent": "qcobjects-cli"
3811
+ };
3812
+ githubService.done = () => {
3813
+ };
3814
+ serviceLoader2(githubService).then(({ service }) => {
3815
+ fs2.writeFileSync(path3.resolve(CONFIG4.get("projectPath"), "./.gitignore"), service.template);
3816
+ try {
3817
+ execSync4("git init");
3818
+ logger7.debug("Git initialized.");
3819
+ } catch (e) {
3820
+ logger7.debug("Could not initialize git.");
3083
3821
  }
3084
3822
  });
3085
- dirs2.map((d) => {
3086
- const sourceDir = path.resolve(source2, d.name);
3087
- const destDir = path.resolve(dest2, d.name);
3088
- copyDir(sourceDir, destDir, exclude2);
3089
- });
3090
- })(paths, dirs, files, exclude);
3091
- }
3092
- }, "copyDir");
3093
- try {
3094
- const exclude = [
3095
- "package.json",
3096
- "node_modules",
3097
- ".DS_Store"
3098
- ];
3099
- logger.info(`[create] Copying files from ${source} to ${dest} excluding ${exclude.join(",")}...`);
3100
- copyDir(source, dest, typeof exclude !== "undefined" ? exclude : []);
3101
- resolve();
3102
- } catch (e) {
3103
- logger.warn(`Something went wrong trying to publish static files: ${e.message}`);
3104
- reject(e);
3105
- }
3106
- });
3107
- }
3108
- initCommand() {
3109
- const switchCommander = this;
3110
- if (process.argv.length > 1) {
3111
- logger.debug("Installing Commands...");
3112
- switchCommander.program.version(global.__get_version_string__());
3113
- switchCommander.program.command("create <appname>").description("Creates an app with <appname>").option("--pwa, --create-pwa", "Creates the progressive web app assets").option("--amp, --create-amp", "Creates the accelerated mobile pages assets").option("--php, --create-php", "Creates the PWA PHP assets").option("--custom, --create-custom <templateappname>", "Creates an App from any NPM package template").option("--tests, --create-tests", "Creates the test suite").action(function(args, options) {
3114
- switchCommander.choiceOption.create.call(switchCommander, args, options);
3115
- });
3116
- try {
3117
- logger.debug("Loading Plugin Commands...");
3118
- const importPluginCommands = /* @__PURE__ */ __name(function(switchCommander2) {
3119
- return global.ClassesList.filter((c) => c.packageName.startsWith("com.qcobjects.cli.commands.")).filter((p) => p.classFactory.name.endsWith("CommandHandler")).map((pluginCommand) => {
3120
- try {
3121
- logger.debug(`Loading plugin ${pluginCommand.packageName}`);
3122
- const classFactory = pluginCommand.classFactory;
3123
- pluginCommand.plugin = New(classFactory, { switchCommander: switchCommander2 });
3124
- } catch (e) {
3125
- throw Error(`Something went wrong loading ${pluginCommand.packageName}`);
3126
- }
3127
- return pluginCommand;
3128
- });
3129
- }, "importPluginCommands");
3130
- importPluginCommands(switchCommander);
3131
- } catch (e) {
3132
- throw Error(`Something went wrong loading plugins: ${e.message}`);
3133
- }
3134
- switchCommander.program.command("publish <appname>").description("Publishes an app with <appname>").option("--pwa, --create-pwa", "Publishes the progressive web app assets").option("--amp, --create-amp", "Publishes the accelerated mobile pages assets").option("--php, --create-php", "Creates the PWA PHP assets").option("--custom, --create-custom", "Creates an App from any NPM package template").option("--tests, --create-tests", "Publishes the test suite").action((args, options) => {
3135
- switchCommander.choiceOption.publish.bind(switchCommander)(args, options);
3136
- });
3137
- switchCommander.program.command("upgrade-to-enterprise").description("Upgrades to QCObjects Enterprise Edition").action(function(args, options) {
3138
- switchCommander.choiceOption.upgradeToEnterprise.call(switchCommander, args, options);
3139
- });
3140
- switchCommander.program.command("generate-sw <appname>").option("-d, --dir <dirPrefix> ", "creates the service worker in a specific dir <dirPrefix>").description("Generates the service worker <appname>").action(function(args, options) {
3141
- switchCommander.choiceOption.generateSw.call(switchCommander, args, options);
3142
- });
3143
- switchCommander.program.command("launch <appname>").description("Launches the application").action(function(args, options) {
3144
- logger.info("Launching...");
3145
- setTimeout(() => {
3146
- logger.info("Go to the browser and open https://localhost ");
3147
- logger.info("Press Ctrl-C to stop serving ");
3148
- exec("qcobjects-server", (err, stdout, stderr) => {
3149
3823
  }).stdout.on("data", function(data) {
3150
3824
  console.log(data);
3151
3825
  });
3152
- }, 5e3);
3153
- });
3154
- switchCommander.program.on("--help", function() {
3155
- console.log("");
3156
- console.log("Use:");
3157
- console.log(" $ qcobjects-cli [command] --help");
3158
- console.log(" For detailed information of a command ");
3159
- console.log("");
3160
- process.exit(0);
3161
- });
3162
- switchCommander.program.on("command:*", function() {
3163
- console.error("Invalid command: %s\nSee --help for a list of available commands.", switchCommander.program.args.join(" "));
3164
- process.exit(1);
3826
+ }).stdout.on("data", function(data) {
3827
+ console.log(data);
3828
+ });
3829
+ }).catch((e) => {
3830
+ console.log(e);
3165
3831
  });
3166
- switchCommander.program.parse(process.argv);
3167
- } else {
3168
- console.log("");
3169
- console.log("Use:");
3170
- console.log(" $ qcobjects-cli [command] --help");
3171
- console.log(" For detailed information of a command ");
3172
- console.log("");
3173
- process.exit(0);
3832
+ }).stdout.on("data", function(data) {
3833
+ console.log(data);
3834
+ });
3835
+ }).stdout.on("data", function() {
3836
+ console.log("App generation started...");
3837
+ });
3838
+ }, "create"),
3839
+ publish(_appName, _options) {
3840
+ logger7.debug("publish is not yet implemented");
3841
+ },
3842
+ upgradeToEnterprise(_appName, _options) {
3843
+ const switchCommander = this;
3844
+ QCObjectsEnterprise.upgrade(switchCommander);
3845
+ }
3846
+ };
3847
+ constructor() {
3848
+ super();
3849
+ this.program = require_commander();
3850
+ }
3851
+ shellCommands(_shell_commands) {
3852
+ return new Promise(function(resolve_all, reject_all) {
3853
+ var _promises_set = _shell_commands.map(
3854
+ function(shell_command) {
3855
+ return new Promise(
3856
+ function(resolve, reject) {
3857
+ logger7.debug(shell_command);
3858
+ exec3(shell_command, (err, stdout, stderr) => {
3859
+ if (!err) {
3860
+ resolve(stdout);
3861
+ } else {
3862
+ logger7.debug(`[FAILED]: ${shell_command}`);
3863
+ logger7.debug(`${stderr}`);
3864
+ reject(stderr);
3865
+ }
3866
+ }).stdout.on("data", function(data) {
3867
+ logger7.info(data);
3868
+ });
3869
+ }
3870
+ ).catch((e) => reject_all(e));
3174
3871
  }
3872
+ );
3873
+ }).catch((e) => console.log(e));
3874
+ }
3875
+ fileListRecursive(dir) {
3876
+ var instance = this;
3877
+ return fs2.statSync(dir).isDirectory() ? Array.prototype.concat(...fs2.readdirSync(dir).map((f) => instance.fileListRecursive(path3.join(dir, f)))).filter((f) => {
3878
+ return !f.startsWith(".git") && f.lastIndexOf(".DS_Store") == -1;
3879
+ }) : dir;
3880
+ }
3881
+ register(email2, phonenumber) {
3882
+ return new Promise(function(resolve, reject) {
3883
+ logger7.info("I'm going to register your profile on the cloud...");
3884
+ const cloudClient = New2(QuickCorpCloud, {
3885
+ apiMethod: "register",
3886
+ data: { email: email2, phonenumber }
3887
+ });
3888
+ try {
3889
+ } catch (e) {
3890
+ console.log("\u{1F926} Something went wrong \u{1F926} when trying to register you in the cloud");
3891
+ reject(e);
3175
3892
  }
3176
- };
3177
- Package("org.quickcorp.qcobjects.cli", [
3178
- SwitchCommander
3179
- ]);
3180
- exports = { SwitchCommander };
3893
+ });
3181
3894
  }
3182
- });
3183
- return require_org_quickcorp_qcobjects_cli();
3895
+ generateServiceWorker(appName, dirPrefix = "./") {
3896
+ const writeContent = /* @__PURE__ */ __name((component) => {
3897
+ const parsedText = component.parseTemplate(component.template);
3898
+ logger7.debug("Starting to write the sw file...");
3899
+ fs2.writeFile(`${dirPrefix}/sw.js`, parsedText, (err) => {
3900
+ if (err) {
3901
+ throw Error(err);
3902
+ }
3903
+ logger7.info("Service Worker Generated");
3904
+ console.log("");
3905
+ console.log("Now simply put:");
3906
+ console.log("CONFIG.set('serviceWorkerURI','/sw.js');");
3907
+ console.log(" In your init.js file ");
3908
+ console.log("");
3909
+ console.log("To start your app in a local server ");
3910
+ console.log("Execute the command: ");
3911
+ console.log("> qcobjects launch <appname>");
3912
+ console.log("");
3913
+ });
3914
+ }, "writeContent");
3915
+ class ServiceWorkerComponent extends Component {
3916
+ static {
3917
+ __name(this, "ServiceWorkerComponent");
3918
+ }
3919
+ cached = false;
3920
+ templateURI = "sw.js";
3921
+ basePath = templatePwaPath;
3922
+ name = "sw";
3923
+ tplsource = "default";
3924
+ template = "";
3925
+ constructor({ name, data }) {
3926
+ super({ name, data });
3927
+ }
3928
+ done({ request, component }) {
3929
+ super.done({ request, component });
3930
+ writeContent(component);
3931
+ }
3932
+ }
3933
+ return new Promise(() => {
3934
+ var filelist = ["/"].concat(this.fileListRecursive(`${dirPrefix}`));
3935
+ if (typeof dirPrefix !== "undefined" && dirPrefix !== "./" && dirPrefix !== ".") {
3936
+ filelist = filelist.map((f) => f.replace(new RegExp(`${dirPrefix}/`), ""));
3937
+ }
3938
+ filelist = filelist.filter(function(fl) {
3939
+ return fl !== "sw.js" && !fl.startsWith("node_modules/");
3940
+ });
3941
+ filelist = filelist.filter((fname) => !fname.endsWith(".pem"));
3942
+ filelist = filelist.filter((fname) => !fname.endsWith(".sh"));
3943
+ filelist = filelist.filter((fname) => !new RegExp("^package(.*).json$").test(fname));
3944
+ filelist = filelist.filter((fname) => !fname.startsWith("."));
3945
+ var fileListString = '\n "' + filelist.join('",\n "') + '"';
3946
+ const component = new ServiceWorkerComponent({
3947
+ name: "sw",
3948
+ data: {
3949
+ appName,
3950
+ appVersion: "1.0.0",
3951
+ filelist: fileListString
3952
+ }
3953
+ });
3954
+ setTimeout(() => {
3955
+ component.done({ request: null, component });
3956
+ }, 1e3);
3957
+ });
3958
+ }
3959
+ copyTemplate(source, dest) {
3960
+ return new Promise((resolve, reject) => {
3961
+ const copyDir = /* @__PURE__ */ __name((source2, dest2, exclude) => {
3962
+ source2 = path3.resolve(source2);
3963
+ dest2 = path3.resolve(dest2);
3964
+ const dname = path3.basename(source2);
3965
+ const dirExcluded = exclude.includes(dname);
3966
+ const isDir = /* @__PURE__ */ __name((d) => {
3967
+ return fs2.existsSync(d) && fs2.statSync(d).isDirectory() ? true : false;
3968
+ }, "isDir");
3969
+ const isFile = /* @__PURE__ */ __name((d) => {
3970
+ return fs2.existsSync(d) && fs2.statSync(d).isFile() ? true : false;
3971
+ }, "isFile");
3972
+ if (isDir(source2) && !dirExcluded) {
3973
+ fs2.mkdirSync(dest2, { recursive: true });
3974
+ const paths = fs2.readdirSync(source2, { withFileTypes: true });
3975
+ const dirs = paths.filter((d) => d.isDirectory());
3976
+ const files = paths.filter((f) => f.isFile());
3977
+ ((paths2, dirs2, files2, exclude2) => {
3978
+ files2.map((f) => {
3979
+ const sourceFile = path3.resolve(source2, f.name);
3980
+ const destFile = path3.resolve(dest2, f.name);
3981
+ const fileExcluded = exclude2.includes(f.name);
3982
+ if (isFile(sourceFile) && !fileExcluded) {
3983
+ logger7.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude2.join(",")}...`);
3984
+ fs2.copyFileSync(sourceFile, destFile);
3985
+ logger7.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude2.join(",")}...DONE!`);
3986
+ }
3987
+ });
3988
+ dirs2.map((d) => {
3989
+ const sourceDir = path3.resolve(source2, d.name);
3990
+ const destDir = path3.resolve(dest2, d.name);
3991
+ copyDir(sourceDir, destDir, exclude2);
3992
+ });
3993
+ })(paths, dirs, files, exclude);
3994
+ }
3995
+ }, "copyDir");
3996
+ try {
3997
+ const exclude = [
3998
+ "package.json",
3999
+ "node_modules",
4000
+ ".DS_Store"
4001
+ ];
4002
+ logger7.info(`[create] Copying files from ${source} to ${dest} excluding ${exclude.join(",")}...`);
4003
+ copyDir(source, dest, typeof exclude !== "undefined" ? exclude : []);
4004
+ resolve();
4005
+ } catch (e) {
4006
+ logger7.warn(`Something went wrong trying to publish static files: ${e.message}`);
4007
+ reject(e);
4008
+ }
4009
+ });
4010
+ }
4011
+ initCommand() {
4012
+ const switchCommander = this;
4013
+ if (process.argv.length > 1) {
4014
+ logger7.debug("Installing Commands...");
4015
+ switchCommander.program.version(__get_version_string__());
4016
+ switchCommander.program.command("create <appname>").description("Creates an app with <appname>").option("--pwa, --create-pwa", "Creates the progressive web app assets").option("--amp, --create-amp", "Creates the accelerated mobile pages assets").option("--php, --create-php", "Creates the PWA PHP assets").option("--custom, --create-custom <templateappname>", "Creates an App from any NPM package template").option("--tests, --create-tests", "Creates the test suite").action(function(args, options) {
4017
+ switchCommander.choiceOption.create.call(switchCommander, args, options);
4018
+ });
4019
+ try {
4020
+ logger7.debug("Loading Plugin Commands...");
4021
+ const importPluginCommands = /* @__PURE__ */ __name(function(switchCommander2) {
4022
+ return getPluginCommandsList().map((pluginCommand) => {
4023
+ try {
4024
+ logger7.debug(`Loading plugin ${pluginCommand.packageName}`);
4025
+ const classFactory = pluginCommand.classFactory;
4026
+ pluginCommand.plugin = new classFactory({ switchCommander: switchCommander2 });
4027
+ } catch (e) {
4028
+ throw Error(`Something went wrong loading ${pluginCommand.packageName}`);
4029
+ }
4030
+ return pluginCommand;
4031
+ });
4032
+ }, "importPluginCommands");
4033
+ importPluginCommands(switchCommander);
4034
+ } catch (e) {
4035
+ throw Error(`Something went wrong loading plugins: ${e.message}`);
4036
+ }
4037
+ switchCommander.program.command("publish <appname>").description("Publishes an app with <appname>").option("--pwa, --create-pwa", "Publishes the progressive web app assets").option("--amp, --create-amp", "Publishes the accelerated mobile pages assets").option("--php, --create-php", "Creates the PWA PHP assets").option("--custom, --create-custom", "Creates an App from any NPM package template").option("--tests, --create-tests", "Publishes the test suite").action((args, options) => {
4038
+ switchCommander.choiceOption.publish.bind(switchCommander)(args, options);
4039
+ });
4040
+ switchCommander.program.command("upgrade-to-enterprise").description("Upgrades to QCObjects Enterprise Edition").action(function(args, options) {
4041
+ switchCommander.choiceOption.upgradeToEnterprise.call(switchCommander, args, options);
4042
+ });
4043
+ switchCommander.program.command("generate-sw <appname>").option("-d, --dir <dirPrefix> ", "creates the service worker in a specific dir <dirPrefix>").description("Generates the service worker <appname>").action(function(args, options) {
4044
+ switchCommander.choiceOption.generateSw.call(switchCommander, args, options);
4045
+ });
4046
+ switchCommander.program.command("launch <appname>").description("Launches the application").action(function() {
4047
+ logger7.info("Launching...");
4048
+ setTimeout(() => {
4049
+ logger7.info("Go to the browser and open https://localhost ");
4050
+ logger7.info("Press Ctrl-C to stop serving ");
4051
+ exec3("qcobjects-server", () => {
4052
+ }).stdout.on("data", function(data) {
4053
+ console.log(data);
4054
+ });
4055
+ }, 5e3);
4056
+ });
4057
+ switchCommander.program.on("--help", function() {
4058
+ console.log("");
4059
+ console.log("Use:");
4060
+ console.log(" $ qcobjects-cli [command] --help");
4061
+ console.log(" For detailed information of a command ");
4062
+ console.log("");
4063
+ process.exit(0);
4064
+ });
4065
+ switchCommander.program.on("command:*", function() {
4066
+ console.error("Invalid command: %s\nSee --help for a list of available commands.", switchCommander.program.args.join(" "));
4067
+ process.exit(1);
4068
+ });
4069
+ switchCommander.program.parse(process.argv);
4070
+ } else {
4071
+ console.log("");
4072
+ console.log("Use:");
4073
+ console.log(" $ qcobjects-cli [command] --help");
4074
+ console.log(" For detailed information of a command ");
4075
+ console.log("");
4076
+ process.exit(0);
4077
+ }
4078
+ }
4079
+ };
4080
+ Package6("org.quickcorp.qcobjects.cli", [
4081
+ SwitchCommander
4082
+ ]);
4083
+ global2.SwitchCommander = SwitchCommander;
4084
+ return __toCommonJS(org_quickcorp_qcobjects_cli_exports);
3184
4085
  })();
3185
4086
  //# sourceMappingURL=org.quickcorp.qcobjects.cli.js.map