@nimbuslab/cli 0.16.0 → 0.16.2

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 CHANGED
@@ -150,7 +150,7 @@ var require_src = __commonJS((exports, module) => {
150
150
  var require_package = __commonJS((exports, module) => {
151
151
  module.exports = {
152
152
  name: "@nimbuslab/cli",
153
- version: "0.16.0",
153
+ version: "0.16.2",
154
154
  description: "CLI para criar projetos nimbuslab",
155
155
  type: "module",
156
156
  bin: {
@@ -2360,6 +2360,11 @@ function printUpgradePlan(name, plan) {
2360
2360
  var import_picocolors6 = __toESM(require_picocolors(), 1);
2361
2361
  import { execSync, spawnSync } from "child_process";
2362
2362
  var PACKAGE_NAME = "@nimbuslab/cli";
2363
+ function isUsingFnm() {
2364
+ const fnmDir = process.env.FNM_DIR || process.env.FNM_MULTISHELL_PATH;
2365
+ const whichNode = spawnSync("which", ["node"], { encoding: "utf-8", shell: true });
2366
+ return !!(fnmDir || whichNode.stdout && whichNode.stdout.includes("fnm"));
2367
+ }
2363
2368
  async function getAvailableVersions() {
2364
2369
  try {
2365
2370
  const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`);
@@ -2383,16 +2388,6 @@ async function getLatestVersion() {
2383
2388
  }
2384
2389
  }
2385
2390
  function detectPackageManager2() {
2386
- try {
2387
- const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
2388
- encoding: "utf-8",
2389
- shell: true,
2390
- timeout: 5000
2391
- });
2392
- if (bunResult.stdout && bunResult.stdout.includes(PACKAGE_NAME)) {
2393
- return "bun";
2394
- }
2395
- } catch {}
2396
2391
  try {
2397
2392
  const npmResult = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
2398
2393
  encoding: "utf-8",
@@ -2406,22 +2401,19 @@ function detectPackageManager2() {
2406
2401
  }
2407
2402
  }
2408
2403
  } catch {}
2409
- return "unknown";
2410
- }
2411
- function getCurrentVersion() {
2412
2404
  try {
2413
2405
  const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
2414
2406
  encoding: "utf-8",
2415
2407
  shell: true,
2416
2408
  timeout: 5000
2417
2409
  });
2418
- if (bunResult.stdout) {
2419
- const match = bunResult.stdout.match(new RegExp(`${PACKAGE_NAME.replace("/", "\\/")}@([\\d.]+)`));
2420
- if (match?.[1]) {
2421
- return match[1];
2422
- }
2410
+ if (bunResult.stdout && bunResult.stdout.includes(PACKAGE_NAME)) {
2411
+ return "bun";
2423
2412
  }
2424
2413
  } catch {}
2414
+ return "unknown";
2415
+ }
2416
+ function getCurrentVersion() {
2425
2417
  try {
2426
2418
  const result = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
2427
2419
  encoding: "utf-8",
@@ -2435,6 +2427,19 @@ function getCurrentVersion() {
2435
2427
  }
2436
2428
  }
2437
2429
  } catch {}
2430
+ try {
2431
+ const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
2432
+ encoding: "utf-8",
2433
+ shell: true,
2434
+ timeout: 5000
2435
+ });
2436
+ if (bunResult.stdout) {
2437
+ const match = bunResult.stdout.match(new RegExp(`${PACKAGE_NAME.replace("/", "\\/")}@([\\d.]+)`));
2438
+ if (match?.[1]) {
2439
+ return match[1];
2440
+ }
2441
+ }
2442
+ } catch {}
2438
2443
  return "unknown";
2439
2444
  }
2440
2445
  async function update(args) {
@@ -2475,7 +2480,7 @@ async function update(args) {
2475
2480
  const spinner = Y2();
2476
2481
  spinner.start("Detectando package manager...");
2477
2482
  const detectedPm = detectPackageManager2();
2478
- const pm = detectedPm === "unknown" ? "bun" : detectedPm;
2483
+ const pm = detectedPm === "unknown" ? "npm" : detectedPm;
2479
2484
  spinner.stop(`Package manager: ${pm}${detectedPm === "unknown" ? " (padrao)" : ""}`);
2480
2485
  spinner.start("Verificando versao atual...");
2481
2486
  const currentVersion = getCurrentVersion();
@@ -2522,6 +2527,12 @@ async function update(args) {
2522
2527
  } else {
2523
2528
  M2.success(`${PACKAGE_NAME} atualizado: ${currentVersion} -> ${newVersion}`);
2524
2529
  }
2530
+ if (isUsingFnm()) {
2531
+ console.log();
2532
+ console.log(import_picocolors6.default.yellow(" fnm detectado - execute para aplicar:"));
2533
+ console.log(import_picocolors6.default.cyan(" hash -r"));
2534
+ console.log(import_picocolors6.default.dim(" Ou abra um novo terminal."));
2535
+ }
2525
2536
  Se(import_picocolors6.default.green("Pronto!"));
2526
2537
  } catch (error) {
2527
2538
  spinner.stop("Erro na atualizacao");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimbuslab/cli",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "CLI para criar projetos nimbuslab",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,6 +6,13 @@ const PACKAGE_NAME = "@nimbuslab/cli"
6
6
 
7
7
  type PackageManager = "bun" | "npm" | "unknown"
8
8
 
9
+ // Detecta se está usando fnm (Fast Node Manager)
10
+ function isUsingFnm(): boolean {
11
+ const fnmDir = process.env.FNM_DIR || process.env.FNM_MULTISHELL_PATH
12
+ const whichNode = spawnSync("which", ["node"], { encoding: "utf-8", shell: true })
13
+ return !!(fnmDir || (whichNode.stdout && whichNode.stdout.includes("fnm")))
14
+ }
15
+
9
16
  async function getAvailableVersions(): Promise<string[]> {
10
17
  try {
11
18
  const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`)
@@ -29,33 +36,34 @@ async function getLatestVersion(): Promise<string | null> {
29
36
  }
30
37
 
31
38
  // Detecta qual package manager tem o pacote instalado globalmente
39
+ // Prioriza npm (mais comum com fnm/nvm)
32
40
  function detectPackageManager(): PackageManager {
33
- // Tentar bun primeiro
41
+ // Tentar npm primeiro (prioridade)
34
42
  try {
35
- const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
43
+ const npmResult = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
36
44
  encoding: "utf-8",
37
45
  shell: true,
38
46
  timeout: 5000,
39
47
  })
40
- if (bunResult.stdout && bunResult.stdout.includes(PACKAGE_NAME)) {
41
- return "bun"
48
+ if (npmResult.stdout) {
49
+ const data = JSON.parse(npmResult.stdout)
50
+ if (data.dependencies?.[PACKAGE_NAME]) {
51
+ return "npm"
52
+ }
42
53
  }
43
54
  } catch {
44
55
  // ignore
45
56
  }
46
57
 
47
- // Tentar npm
58
+ // Fallback para bun
48
59
  try {
49
- const npmResult = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
60
+ const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
50
61
  encoding: "utf-8",
51
62
  shell: true,
52
63
  timeout: 5000,
53
64
  })
54
- if (npmResult.stdout) {
55
- const data = JSON.parse(npmResult.stdout)
56
- if (data.dependencies?.[PACKAGE_NAME]) {
57
- return "npm"
58
- }
65
+ if (bunResult.stdout && bunResult.stdout.includes(PACKAGE_NAME)) {
66
+ return "bun"
59
67
  }
60
68
  } catch {
61
69
  // ignore
@@ -65,35 +73,35 @@ function detectPackageManager(): PackageManager {
65
73
  }
66
74
 
67
75
  function getCurrentVersion(): string {
68
- // Tentar bun primeiro
76
+ // Tentar npm primeiro (prioridade)
69
77
  try {
70
- const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
78
+ const result = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
71
79
  encoding: "utf-8",
72
80
  shell: true,
73
81
  timeout: 5000,
74
82
  })
75
- if (bunResult.stdout) {
76
- // Formato: "@nimbuslab/cli@0.14.0"
77
- const match = bunResult.stdout.match(new RegExp(`${PACKAGE_NAME.replace("/", "\\/")}@([\\d.]+)`))
78
- if (match?.[1]) {
79
- return match[1]
83
+ if (result.stdout) {
84
+ const data = JSON.parse(result.stdout)
85
+ if (data.dependencies?.[PACKAGE_NAME]?.version) {
86
+ return data.dependencies[PACKAGE_NAME].version
80
87
  }
81
88
  }
82
89
  } catch {
83
90
  // ignore
84
91
  }
85
92
 
86
- // Fallback para npm
93
+ // Fallback para bun
87
94
  try {
88
- const result = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
95
+ const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
89
96
  encoding: "utf-8",
90
97
  shell: true,
91
98
  timeout: 5000,
92
99
  })
93
- if (result.stdout) {
94
- const data = JSON.parse(result.stdout)
95
- if (data.dependencies?.[PACKAGE_NAME]?.version) {
96
- return data.dependencies[PACKAGE_NAME].version
100
+ if (bunResult.stdout) {
101
+ // Formato: "@nimbuslab/cli@0.14.0"
102
+ const match = bunResult.stdout.match(new RegExp(`${PACKAGE_NAME.replace("/", "\\/")}@([\\d.]+)`))
103
+ if (match?.[1]) {
104
+ return match[1]
97
105
  }
98
106
  }
99
107
  } catch {
@@ -155,8 +163,8 @@ export async function update(args: string[]) {
155
163
  // Detectar package manager
156
164
  spinner.start("Detectando package manager...")
157
165
  const detectedPm = detectPackageManager()
158
- // Usar bun como padrao se nenhum detectado
159
- const pm = detectedPm === "unknown" ? "bun" : detectedPm
166
+ // Usar npm como padrao se nenhum detectado (compativel com fnm/nvm)
167
+ const pm = detectedPm === "unknown" ? "npm" : detectedPm
160
168
  spinner.stop(`Package manager: ${pm}${detectedPm === "unknown" ? " (padrao)" : ""}`)
161
169
 
162
170
  // Verificar versao atual
@@ -228,6 +236,15 @@ export async function update(args: string[]) {
228
236
  } else {
229
237
  p.log.success(`${PACKAGE_NAME} atualizado: ${currentVersion} -> ${newVersion}`)
230
238
  }
239
+
240
+ // Se usa fnm, avisar sobre hash
241
+ if (isUsingFnm()) {
242
+ console.log()
243
+ console.log(pc.yellow(" fnm detectado - execute para aplicar:"))
244
+ console.log(pc.cyan(" hash -r"))
245
+ console.log(pc.dim(" Ou abra um novo terminal."))
246
+ }
247
+
231
248
  p.outro(pc.green("Pronto!"))
232
249
  } catch (error) {
233
250
  spinner.stop("Erro na atualizacao")