{
  "version": 3,
  "sources": ["../../src/qcobjects-createcert.ts"],
  "sourcesContent": ["#!/usr/bin/env node\n/**\n * QCObjects CLI 2.4.x\n * ________________\n *\n * Author: Jean Machuca <correojean@gmail.com>\n *\n * Cross Browser Javascript Framework for MVC Patterns\n * QuickCorp/QCObjects is licensed under the\n * GNU Lesser General Public License v3.0\n * [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)\n *\n * Permissions of this copyleft license are conditioned on making available\n * complete source code of licensed works and modifications under the same\n * license or the GNU GPLv3. Copyright and license notices must be preserved.\n * Contributors provide an express grant of patent rights. However, a larger\n * work using the licensed work through interfaces provided by the licensed\n * work may be distributed under different terms and without source code for\n * the larger work.\n *\n * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>\n *\n * Everyone is permitted to copy and distribute verbatim copies of this\n * license document, but changing it is not allowed.\n*/\n/*eslint no-unused-vars: \"off\"*/\n/*eslint no-redeclare: \"off\"*/\n/*eslint no-empty: \"off\"*/\n/*eslint strict: \"off\"*/\n/*eslint no-mixed-operators: \"off\"*/\n/*eslint no-undef: \"off\"*/\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport \"./defaultsettings\";\nimport { InheritClass, CONFIG } from \"qcobjects\";\n\n(async () => {\n  \"use strict\";\n  const absolutePath = path.resolve(__dirname, \"./\");\n  const templatePath = path.resolve(__dirname, \"./templates/apps/\") + \"/\";\n  const isWindows = () => {\n    // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n    return os.platform().toLowerCase().startsWith(\"win\");\n  };\n  const isMac = () => {\n    // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n    return os.platform().toLowerCase().startsWith(\"darwin\");\n  };\n\n  const { execSync } = await import(\"node:child_process\");\n\n  class Main extends InheritClass {\n    constructor() {\n      super();\n      this.start();\n    }\n\n    start() {\n      const certificate_provider = CONFIG.get(\"certificate_provider\", \"self_signed\");\n      let stdout;\n      switch (certificate_provider) {\n        case \"self_signed\":\n          // stderr is sent to stderr of parent process\n          // you can set options.stdio if you want it to go elsewhere\n          if (isWindows()) {\n            stdout = execSync(\"openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj \\\"/CN=\" + CONFIG.get(\"domain\") + \"\\\"  -keyout \" + CONFIG.get(\"private-key-pem\") + \" -out \" + CONFIG.get(\"private-cert-pem\"));\n          } else {\n            stdout = execSync(\"openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=\" + CONFIG.get(\"domain\") + \"'  -keyout \" + CONFIG.get(\"private-key-pem\") + \" -out \" + CONFIG.get(\"private-cert-pem\"));\n          }\n          break;\n        case \"letsencrypt\":\n          if (isWindows()) {\n            throw Error(\"Letsencrypt certificate is not supported in Windows\");\n          } else {\n            var prehook_posthook = \"--pre-hook \\\"service qcobjects stop\\\" --post-hook=\\\"service qcobjects start\\\"\";\n            stdout = execSync(`certbot -n -d ${CONFIG.get(\"domain\")} certonly --standalone ${prehook_posthook}`);\n          }\n          break;\n        default:\n          break;\n      }\n\n    }\n  }\n\n  const __main__ = new Main();\n})().catch(e => console.error(e));"],
  "mappings": ";;;;;;;AA+BA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO;AACP,SAAS,cAAc,cAAc;AAlCrC;AAAA;AAoCA,KAAC,YAAY;AACX;AACA,YAAM,eAAe,KAAK,QAAQ,WAAW,IAAI;AACjD,YAAM,eAAe,KAAK,QAAQ,WAAW,mBAAmB,IAAI;AACpE,YAAM,YAAY,6BAAM;AAEtB,eAAO,GAAG,SAAS,EAAE,YAAY,EAAE,WAAW,KAAK;AAAA,MACrD,GAHkB;AAIlB,YAAM,QAAQ,6BAAM;AAElB,eAAO,GAAG,SAAS,EAAE,YAAY,EAAE,WAAW,QAAQ;AAAA,MACxD,GAHc;AAKd,YAAM,EAAE,SAAS,IAAI,MAAM,OAAO,oBAAoB;AAAA,MAEtD,MAAM,aAAa,aAAa;AAAA,QAnDlC,OAmDkC;AAAA;AAAA;AAAA,QAC9B,cAAc;AACZ,gB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