agroplan-ai-cli 1.0.4 → 1.0.5

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 (2) hide show
  1. package/dist/index.js +47 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -610,7 +610,7 @@ function openCommand() {
610
610
  import { existsSync as existsSync6, cpSync, rmSync } from "fs";
611
611
  import { join as join3, dirname as dirname2 } from "path";
612
612
  var __dirname = "C:\\Users\\Defal\\Documents\\Projetos\\AgroPlan\\tools\\agroplan-cli\\src\\commands";
613
- async function setupCommand(force = false) {
613
+ async function setupCommand(force = false, pythonPath) {
614
614
  console.log(`\uD83D\uDEE0\uFE0F Configurando AgroPlan AI - API Local
615
615
  `);
616
616
  const homeDir = getHomeAgroplanDir();
@@ -629,15 +629,38 @@ async function setupCommand(force = false) {
629
629
  }
630
630
  console.log(`
631
631
  \uD83D\uDC0D Verificando Python...`);
632
- const python = checkPython();
632
+ let python;
633
+ if (pythonPath) {
634
+ console.log(` \uD83C\uDFAF Usando Python espec\xEDfico: ${pythonPath}`);
635
+ if (!existsSync6(pythonPath)) {
636
+ console.log("\u274C Python especificado n\xE3o encontrado");
637
+ console.log(` Caminho: ${pythonPath}`);
638
+ return;
639
+ }
640
+ const versionResult = Bun.spawnSync([pythonPath, "--version"], {});
641
+ if (!versionResult.success) {
642
+ console.log("\u274C Falha ao verificar vers\xE3o do Python especificado");
643
+ return;
644
+ }
645
+ const versionOutput = new TextDecoder().decode(versionResult.stdout);
646
+ python = {
647
+ available: true,
648
+ path: pythonPath,
649
+ version: versionOutput.trim()
650
+ };
651
+ } else {
652
+ python = checkPython();
653
+ }
633
654
  if (!python.available) {
634
655
  console.log("\u274C Python n\xE3o encontrado");
635
656
  console.log(" Instale Python 3.8+ em https://python.org/downloads");
657
+ console.log(" Ou use: agroplan setup --python=<caminho>");
636
658
  return;
637
659
  }
638
660
  console.log(` \u2705 ${python.version}`);
639
661
  if (python.version && python.version.includes("3.13")) {
640
662
  console.log(" \u26A0\uFE0F Python 3.13 detectado. Se a instala\xE7\xE3o for lenta, use Python 3.11 ou 3.12.");
663
+ console.log(' \uD83D\uDCA1 Exemplo: agroplan setup --python="C:\\Python311\\python.exe"');
641
664
  }
642
665
  console.log(`
643
666
  \uD83D\uDCC2 Criando estrutura de diret\xF3rios...`);
@@ -720,10 +743,11 @@ async function setupCommand(force = false) {
720
743
  console.log(" \u2705 Servidor web configurado");
721
744
  const packageJson = __require(join3(dirname2(dirname2(dirname2(__dirname))), "package.json"));
722
745
  saveSetupState({
723
- version: packageJson.version || "1.0.4",
746
+ version: packageJson.version || "1.0.5",
724
747
  installedAt: new Date().toISOString(),
725
748
  backendPath: backendDir,
726
749
  python: python.version || "unknown",
750
+ pythonPath: python.path || "",
727
751
  dependenciesInstalled: true
728
752
  });
729
753
  console.log(`
@@ -741,6 +765,7 @@ async function setupCommand(force = false) {
741
765
  var COMMANDS = {
742
766
  setup: "Configura a API local no seu computador",
743
767
  "setup --force": "Reinstala a API local (remove instala\xE7\xE3o anterior)",
768
+ "setup --python=<path>": "Usa Python espec\xEDfico para instala\xE7\xE3o",
744
769
  doctor: "Verifica se o sistema est\xE1 configurado corretamente",
745
770
  "serve on": "Inicia a API local em http://localhost:8000",
746
771
  "serve off": "Para a API local",
@@ -749,12 +774,12 @@ var COMMANDS = {
749
774
  open: "Abre o AgroPlan AI no navegador"
750
775
  };
751
776
  function showHelp() {
752
- console.log("\uD83C\uDF31 AgroPlan AI - CLI Local v1.0.4");
777
+ console.log("\uD83C\uDF31 AgroPlan AI - CLI Local v1.0.5");
753
778
  console.log(` Launcher para modo local acelerado
754
779
  `);
755
780
  console.log("\uD83D\uDCCB Comandos dispon\xEDveis:");
756
781
  Object.entries(COMMANDS).forEach(([cmd, desc]) => {
757
- console.log(` agroplan ${cmd.padEnd(15)} # ${desc}`);
782
+ console.log(` agroplan ${cmd.padEnd(20)} # ${desc}`);
758
783
  });
759
784
  console.log(`
760
785
  \uD83C\uDFAF Fluxo recomendado:`);
@@ -763,6 +788,9 @@ function showHelp() {
763
788
  console.log(" 3. agroplan open # Abrir no navegador");
764
789
  console.log(" 4. agroplan serve off # Parar quando terminar");
765
790
  console.log(`
791
+ \uD83D\uDC0D Para Python 3.13 (Windows):`);
792
+ console.log(' agroplan setup --python="C:\\Python311\\python.exe"');
793
+ console.log(`
766
794
  \uD83D\uDCA1 Modo h\xEDbrido:`);
767
795
  console.log(" \u2022 API Local: R\xE1pida, n\xE3o dorme, ideal para uso di\xE1rio");
768
796
  console.log(" \u2022 API Render: Fallback universal, funciona em qualquer PC");
@@ -774,14 +802,23 @@ async function main() {
774
802
  showHelp();
775
803
  return;
776
804
  }
777
- const command = args.join(" ");
805
+ let command = "";
806
+ let pythonPath;
807
+ let force = false;
808
+ for (let i = 0;i < args.length; i++) {
809
+ const arg = args[i];
810
+ if (arg.startsWith("--python=")) {
811
+ pythonPath = arg.split("=")[1];
812
+ } else if (arg === "--force") {
813
+ force = true;
814
+ } else {
815
+ command += (command ? " " : "") + arg;
816
+ }
817
+ }
778
818
  try {
779
819
  switch (command) {
780
820
  case "setup":
781
- await setupCommand(false);
782
- break;
783
- case "setup --force":
784
- await setupCommand(true);
821
+ await setupCommand(force, pythonPath);
785
822
  break;
786
823
  case "doctor":
787
824
  await doctorCommand();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agroplan-ai-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "CLI global para AgroPlan AI - modo local acelerado",
5
5
  "type": "module",
6
6
  "bin": {