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