index.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Command } from "@commander-js/extra-typings";
  2. import chalk from "chalk";
  3. import { processData } from "./process-data.ts";
  4. import { dumpFactorioData, dumpFactorioIcon } from "./helpers/command.helper.ts";
  5. import { extractLocale } from "./helpers/locale.helper.ts";
  6. import { step } from "../helpers/logger.ts";
  7. export const DEFAULT_OUTPUT_FOLDER = "./src/assets/data/2.0";
  8. const program = new Command()
  9. .name("factorio-dump")
  10. .option("--skip-dump", "Skip the dumping of icon and factorio data", false)
  11. .option("--skip-locale", "Skip the dumping of locale datas", false)
  12. .option("-o, --output <path>", "Path to put the extracted data", DEFAULT_OUTPUT_FOLDER)
  13. .description("Builds Factorio data assets for the web app from local factorio installation")
  14. .helpOption("-h, --help", "Display help")
  15. .addHelpText(
  16. "after",
  17. `
  18. Examples
  19. $ factorio-dump
  20. $ factorio-dump --skip-dump
  21. $ factorio-dump --skip-local
  22. `
  23. );
  24. async function run() {
  25. program.parse(process.argv);
  26. const options = program.opts();
  27. console.log(chalk.bold("\n🚀 Factorio Data Pipeline\n"));
  28. if (!options.skipDump) {
  29. await step("Dump factorio data", dumpFactorioData);
  30. await step("Dump factorio icons", dumpFactorioIcon);
  31. }
  32. await processData(options.output);
  33. //await step("Process factorio data and icons", processData, options.output);
  34. if (!options.skipLocale) await step("Dump factorio locale", extractLocale, options.output);
  35. console.log(chalk.green("\n✅ All steps completed successfully!"));
  36. }
  37. run().catch((err) => {
  38. console.error(chalk.red("\n❌ Something went wrong:"), err);
  39. process.exit(1);
  40. });