{
  "version": 3,
  "sources": ["../../src/cli-commands-publish-static.ts"],
  "sourcesContent": ["/**\n * QCObjects CLI 2.5\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\"*/\n\"use strict\";\nimport path from \"node:path\";\nimport fs from \"node:fs\";\n\nimport { Package, InheritClass, _DataStringify, New, CONFIG, logger } from \"qcobjects\";\nconst absolutePath = path.resolve(__dirname, \"./\");\n\nexport class CommandHandler extends InheritClass {\n  choiceOption: {\n    [x: string]: any; publish_static: (source:string, dest:string, options:any) => void;\n  };\n\n  constructor({\n    switchCommander\n  }: { switchCommander: any }) {\n    super({ switchCommander });\n    this.choiceOption = {\n      publish_static(source, dest, options) {\n\n        const copyDir = (source:string, dest:string, exclude:string) => {\n          source = path.resolve(source);\n          dest = path.resolve(dest);\n          const dname = path.basename(source);\n          const dirExcluded = (exclude.includes(dname));\n  \n          const isDir = (d:string) => {\n            return (fs.existsSync(d) && fs.statSync(d).isDirectory())?(true):(false);\n          };\n  \n          const isFile = (d:string) => {\n            return (fs.existsSync(d) && fs.statSync(d).isFile())?(true):(false);\n          };\n  \n          if (isDir(source) && !dirExcluded){\n            fs.mkdirSync(dest, {recursive:true});\n            const paths = fs.readdirSync(source, {withFileTypes:true});\n            const dirs = paths.filter(d=>d.isDirectory());\n            const files = paths.filter(f=>f.isFile());\n            void ((paths, dirs, files, exclude) => {\n              files.forEach((f) => {\n                const sourceFile = path.resolve(source, f.name);\n                const destFile = path.resolve(dest, f.name);\n                const fileExcluded = exclude.includes(f.name);\n                if (isFile(sourceFile) && !fileExcluded) {\n                  logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...`);\n                  fs.copyFileSync(sourceFile, destFile);\n                  logger.debug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...DONE!`);\n                }\n              });\n              dirs.forEach((d) => {\n                const sourceDir = path.resolve(source, d.name);\n                const destDir = path.resolve(dest, d.name);\n                copyDir(sourceDir, destDir, exclude);\n              });\n            })(paths, dirs, files, exclude);\n          }\n  \n        };\n  \n        try {\n          logger.info(`[publish:static] Copying files from ${source} to ${dest} excluding ${options.exclude}...`);\n          copyDir(source, dest, (typeof options.exclude !== \"undefined\") ? (options.exclude) : ([]));\n        } catch (e:any) {\n          logger.warn(`Something went wrong trying to publish static files: ${e.message}`);\n          process.exit(1);\n        }\n      }\n  \n    };\n\n    const commandHandler = this;\n    logger.debug(\"Loading command publish-static...\");\n\n    switchCommander.program.command(\"publish:static <source> <dest>\")\n      .allowExcessArguments(false)\n      .option(\"-e, --exclude <excludePaths...>\", \"Exclude some paths or files\")\n      .description(\"Publishes (copy) all files and directories from source to dest\")\n      .action(function (source:string, dest:string, options:any) {\n        commandHandler.choiceOption.publish_static.call(commandHandler, source, dest, options);\n      });\n\n    logger.debug(\"Loading command publish-static... DONE.\");\n  }\n\n\n}\n\n\nPackage(\"com.qcobjects.cli.commands.jira\", [\n  CommandHandler\n]);\n"],
  "mappings": ";;AA+BA,OAAO,UAAU;AACjB,OAAO,QAAQ;AAEf,SAAS,SAAS,cAA2C,cAAc;AAC3E,MAAM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