{
  "version": 3,
  "sources": ["../../src/cli-commands-build-typescript.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 ts from \"typescript\";\nimport { Package, InheritClass, logger } from \"qcobjects\";\n\nexport class CommandHandler extends InheritClass {\n  choiceOption: {\n    [x: string]: any;\n    build_typescript: (configFile: string) => void;\n  };\n\n  constructor({\n    switchCommander\n  }: { switchCommander: any }) {\n    super({ switchCommander });\n    this.choiceOption = {\n      build_typescript(configFile) {\n        try {\n          logger.info(`[build:typescript] Building TypeScript with config file: ${configFile}...`);\n          \n          // Resolve the path to the tsconfig file\n          const configPath = path.resolve(process.cwd(), configFile);\n\n          // Parse the tsconfig file\n          const parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configPath, {}, {\n            ...ts.sys,\n            onUnRecoverableConfigFileDiagnostic: diagnostic => {\n              logger.warn(ts.formatDiagnostic(diagnostic, {\n                getCanonicalFileName: (fileName) => fileName,\n                getCurrentDirectory: ts.sys.getCurrentDirectory,\n                getNewLine: () => ts.sys.newLine,\n              }));\n              process.exit(1);\n            }\n          });\n\n          if (!parsedCommandLine) {\n            logger.warn('Failed to parse tsconfig file');\n            process.exit(1);\n          }\n\n          // Create a program with the parsed settings\n          const program = ts.createProgram({\n            rootNames: parsedCommandLine.fileNames,\n            options: parsedCommandLine.options,\n          });\n\n          // Emit the compiled files\n          const emitResult = program.emit();\n\n          // Report any diagnostics (errors or warnings)\n          const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);\n\n          allDiagnostics.forEach(diagnostic => {\n            if (diagnostic.file && diagnostic.start) {\n              const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n              const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n              logger.warn(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);\n            } else {\n              logger.warn(ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n'));\n            }\n          });\n\n          // Check if any files were emitted\n          const emittedFiles = emitResult.emittedFiles || [];\n          if (emittedFiles.length > 0) {\n            logger.info('Emitted files:');\n            emittedFiles.forEach(file => logger.info(file));\n          }\n\n          // Exit with an appropriate code\n          const exitCode = emitResult.emitSkipped ? 1 : 0;\n          logger.info(`Process completed with code '${exitCode}'.`);\n          if (exitCode !== 0) {\n            process.exit(exitCode);\n          }\n        } catch (e: any) {\n          logger.warn(`Something went wrong trying to build TypeScript: ${e.message}`);\n          process.exit(1);\n        }\n      }\n    };\n\n    const commandHandler = this;\n    logger.debug(\"Loading command build:typescript...\");\n\n    // Register both commands\n    const buildCommand = switchCommander.program.command(\"build:typescript <configFile>\")\n      .allowExcessArguments(false)\n      .description(\"Builds TypeScript files using the specified config file\")\n      .action(function (configFile: string) {\n        commandHandler.choiceOption.build_typescript.call(commandHandler, configFile);\n      });\n\n    // Add alias\n    switchCommander.program.command(\"build:ts <configFile>\")\n      .allowExcessArguments(false)\n      .description(\"Alias for build:typescript - Builds TypeScript files using the specified config file\")\n      .action(function (configFile: string) {\n        commandHandler.choiceOption.build_typescript.call(commandHandler, configFile);\n      });\n\n    logger.debug(\"Loading command build:typescript... DONE.\");\n  }\n}\n\nPackage(\"com.qcobjects.cli.commands.build.typescript\", [\n  CommandHandler\n]); "],
  "mappings": ";;AA+BA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,SAAS,cAAc,cAAc;AAEvC,MAAM,uBAAuB,aAAa;AAAA,EAnCjD,OAmCiD;AAAA;AAAA;AAAA,EAC/C;AAAA,EAKA,YAAY;AAAA,IACV;AAAA,EACF,GAA6B;AAC3B,UAAM,EAAE,gBAAgB,CAAC;AACzB,SAAK,eAAe;AAAA,MAClB,iBAAiB,YAAY;AAC3B,YAAI;AACF,iBAAO,KAAK,4DAA4D,UAAU,KAAK;AAGvF,gBAAM,aAAa,KAAK,QAAQ,QAAQ,IAAI,GAAG,UAAU;AAGzD,gBAAM,oBAAoB,GAAG,iCAAiC,YAAY,CAAC,GAAG;AAAA,YAC5E,GAAG,GAAG;AAAA,YACN,qCAAqC,uCAAc;AACjD,qBAAO,KAAK,GAAG,iBAAiB,YAAY;AAAA,gBAC1C,sBAAsB,wBAAC,aAAa,UAAd;AAAA,gBACtB,qBAAqB,GAAG,IAAI;AAAA,gBAC5B,YAAY,6BAAM,GAAG,IAAI,SAAb;AAAA,cACd,CAAC,CAAC;AACF,sBAAQ,KAAK,CAAC;AAAA,YAChB,GAPqC;AAAA,UAQvC,CAAC;AAED,cAAI,CAAC,mBAAmB;AACtB,mBAAO,KAAK,+BAA+B;AAC3C,oBAAQ,KAAK,CAAC;AAAA,UAChB;AAGA,gBAAM,UAAU,GAAG,cAAc;AAAA,YAC/B,WAAW,kBAAkB;AAAA,YAC7B,SAAS,kBAAkB;AAAA,UAC7B,CAAC;AAGD,gBAAM,aAAa,QAAQ,KAAK;AAGhC,gBAAM,iBAAiB,GAAG,sBAAsB,OAAO,EAAE,OAAO,WAAW,WAAW;AAEtF,yBAAe,QAAQ,gBAAc;A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