pipely-ai 1.2.0 → 1.3.1

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/index.js +19 -27
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  import { createInterface } from "node:readline/promises";
4
4
  import { createServer as createNetServer } from "node:net";
5
- import { randomBytes } from "node:crypto";
6
- import { execSync } from "node:child_process";
7
- import { writeFileSync, readFileSync, existsSync } from "node:fs";
5
+ import { randomBytes, randomUUID } from "node:crypto";
6
+ import { execSync, fork } from "node:child_process";
7
+ import { writeFileSync, readFileSync, existsSync, mkdirSync, unlinkSync, rmSync, createWriteStream } from "node:fs";
8
8
  import { join } from "node:path";
9
9
  import { platform, release, arch } from "node:os";
10
10
  import http from "node:http";
11
+ import https from "node:https";
11
12
 
12
13
  // ── ANSI Colors ──────────────────────────────────────
13
14
 
@@ -455,7 +456,6 @@ const BUNDLE_NAME = "pipely-local.tar.gz";
455
456
  async function getLatestReleaseUrl() {
456
457
  return new Promise((resolve) => {
457
458
  const url = `https://api.github.com/repos/${BUNDLE_REPO}/releases/latest`;
458
- const https = require("node:https");
459
459
  https.get(url, { headers: { "User-Agent": "pipely-cli" } }, (res) => {
460
460
  let body = "";
461
461
  res.on("data", (chunk) => (body += chunk));
@@ -474,9 +474,6 @@ async function getLatestReleaseUrl() {
474
474
 
475
475
  async function downloadFile(url, dest) {
476
476
  return new Promise((resolve, reject) => {
477
- const https = require("node:https");
478
- const fs = require("node:fs");
479
-
480
477
  function follow(url) {
481
478
  https.get(url, { headers: { "User-Agent": "pipely-cli" } }, (res) => {
482
479
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
@@ -487,7 +484,7 @@ async function downloadFile(url, dest) {
487
484
  reject(new Error(`HTTP ${res.statusCode}`));
488
485
  return;
489
486
  }
490
- const file = fs.createWriteStream(dest);
487
+ const file = createWriteStream(dest);
491
488
  res.pipe(file);
492
489
  file.on("finish", () => { file.close(); resolve(); });
493
490
  }).on("error", reject);
@@ -498,16 +495,8 @@ async function downloadFile(url, dest) {
498
495
  }
499
496
 
500
497
  function extractTarGz(file, dest) {
501
- const { mkdirSync } = require("node:fs");
502
498
  mkdirSync(dest, { recursive: true });
503
-
504
- const os = detectOS();
505
- if (os.platform === "win32") {
506
- // Windows: use tar (available since Windows 10)
507
- execSync(`tar -xzf "${file}" -C "${dest}"`, { stdio: "pipe" });
508
- } else {
509
- execSync(`tar -xzf "${file}" -C "${dest}"`, { stdio: "pipe" });
510
- }
499
+ execSync(`tar -xzf "${file}" -C "${dest}"`, { stdio: "pipe" });
511
500
  }
512
501
 
513
502
  function getLocalEnvPath() {
@@ -520,7 +509,7 @@ function isLocalInstalled() {
520
509
 
521
510
  function generateLocalEnv() {
522
511
  const jwtSecret = generateKey(64);
523
- const setupKey = require("node:crypto").randomUUID();
512
+ const setupKey = randomUUID();
524
513
 
525
514
  const env = `# Pipely AI — Local Mode
526
515
  DATABASE_URL=file:./data/pipely.db
@@ -564,8 +553,7 @@ async function installLocal() {
564
553
  console.log(`${c.green}✓${c.reset}`);
565
554
 
566
555
  const tmpFile = join(PIPELY_DIR, BUNDLE_NAME);
567
- const { mkdirSync: mk } = require("node:fs");
568
- mk(PIPELY_DIR, { recursive: true });
556
+ mkdirSync(PIPELY_DIR, { recursive: true });
569
557
 
570
558
  process.stdout.write(` Baixando bundle... `);
571
559
  try {
@@ -589,7 +577,7 @@ async function installLocal() {
589
577
  }
590
578
 
591
579
  // Clean up tar
592
- try { require("node:fs").unlinkSync(tmpFile); } catch {}
580
+ try { unlinkSync(tmpFile); } catch {}
593
581
 
594
582
  // Install deps
595
583
  console.log(`\n ${c.magenta}── Instalando dependencias ────────────────${c.reset}\n`);
@@ -611,7 +599,7 @@ async function installLocal() {
611
599
  console.log(` ${c.green}✓${c.reset} .env gerado`);
612
600
 
613
601
  // Create data directory
614
- mk(join(PIPELY_DIR, "data"), { recursive: true });
602
+ mkdirSync(join(PIPELY_DIR, "data"), { recursive: true });
615
603
 
616
604
  // Setup database
617
605
  process.stdout.write(` Criando banco de dados... `);
@@ -652,7 +640,6 @@ async function runLocal() {
652
640
 
653
641
  console.log(` ${c.magenta}── Iniciando Pipely AI ────────────────────${c.reset}\n`);
654
642
 
655
- const { fork } = require("node:child_process");
656
643
  const envPath = getLocalEnvPath();
657
644
  const envContent = existsSync(envPath) ? readFileSync(envPath, "utf-8") : "";
658
645
  const envVars = {};
@@ -963,6 +950,11 @@ async function install() {
963
950
  const os = detectOS();
964
951
  console.log(` Sistema: ${c.bold}${os.label}${c.reset} (${os.arch})\n`);
965
952
 
953
+ if (forceLocal) {
954
+ console.log(` Modo: ${c.cyan}Local (--local)${c.reset}\n`);
955
+ return installLocal();
956
+ }
957
+
966
958
  process.stdout.write(` Verificando Docker... `);
967
959
  const docker = checkDocker();
968
960
 
@@ -1186,8 +1178,9 @@ function isLocalMode() {
1186
1178
  // ══════════════════════════════════════════════════════
1187
1179
 
1188
1180
  const args = process.argv.slice(2);
1189
- const command = args[0];
1190
- const local = isLocalMode();
1181
+ const forceLocal = args.includes("--local");
1182
+ const command = args.filter((a) => a !== "--local")[0];
1183
+ const local = forceLocal || isLocalMode();
1191
1184
 
1192
1185
  switch (command) {
1193
1186
  case "status":
@@ -1214,8 +1207,7 @@ switch (command) {
1214
1207
  case "update":
1215
1208
  if (local) {
1216
1209
  // Delete and re-download bundle
1217
- const { rmSync: rm } = require("node:fs");
1218
- try { rm(PIPELY_DIR, { recursive: true }); } catch {}
1210
+ try { rmSync(PIPELY_DIR, { recursive: true }); } catch {}
1219
1211
  console.log(`\n ${c.dim}Reinstalando...${c.reset}\n`);
1220
1212
  installLocal().catch((err) => {
1221
1213
  console.error(`\n ${c.red}Erro: ${err.message}${c.reset}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pipely-ai",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Pipely AI — Instale, gerencie e atualize com um unico comando",
5
5
  "type": "module",
6
6
  "bin": {