@nimbuslab/cli 0.15.0 → 0.16.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.
@@ -29,33 +29,34 @@ async function getLatestVersion(): Promise<string | null> {
29
29
  }
30
30
 
31
31
  // Detecta qual package manager tem o pacote instalado globalmente
32
+ // Prioriza npm (mais comum com fnm/nvm)
32
33
  function detectPackageManager(): PackageManager {
33
- // Tentar bun primeiro
34
+ // Tentar npm primeiro (prioridade)
34
35
  try {
35
- const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
36
+ const npmResult = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
36
37
  encoding: "utf-8",
37
38
  shell: true,
38
39
  timeout: 5000,
39
40
  })
40
- if (bunResult.stdout && bunResult.stdout.includes(PACKAGE_NAME)) {
41
- return "bun"
41
+ if (npmResult.stdout) {
42
+ const data = JSON.parse(npmResult.stdout)
43
+ if (data.dependencies?.[PACKAGE_NAME]) {
44
+ return "npm"
45
+ }
42
46
  }
43
47
  } catch {
44
48
  // ignore
45
49
  }
46
50
 
47
- // Tentar npm
51
+ // Fallback para bun
48
52
  try {
49
- const npmResult = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
53
+ const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
50
54
  encoding: "utf-8",
51
55
  shell: true,
52
56
  timeout: 5000,
53
57
  })
54
- if (npmResult.stdout) {
55
- const data = JSON.parse(npmResult.stdout)
56
- if (data.dependencies?.[PACKAGE_NAME]) {
57
- return "npm"
58
- }
58
+ if (bunResult.stdout && bunResult.stdout.includes(PACKAGE_NAME)) {
59
+ return "bun"
59
60
  }
60
61
  } catch {
61
62
  // ignore
@@ -65,35 +66,35 @@ function detectPackageManager(): PackageManager {
65
66
  }
66
67
 
67
68
  function getCurrentVersion(): string {
68
- // Tentar bun primeiro
69
+ // Tentar npm primeiro (prioridade)
69
70
  try {
70
- const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
71
+ const result = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
71
72
  encoding: "utf-8",
72
73
  shell: true,
73
74
  timeout: 5000,
74
75
  })
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]
76
+ if (result.stdout) {
77
+ const data = JSON.parse(result.stdout)
78
+ if (data.dependencies?.[PACKAGE_NAME]?.version) {
79
+ return data.dependencies[PACKAGE_NAME].version
80
80
  }
81
81
  }
82
82
  } catch {
83
83
  // ignore
84
84
  }
85
85
 
86
- // Fallback para npm
86
+ // Fallback para bun
87
87
  try {
88
- const result = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
88
+ const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
89
89
  encoding: "utf-8",
90
90
  shell: true,
91
91
  timeout: 5000,
92
92
  })
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
93
+ if (bunResult.stdout) {
94
+ // Formato: "@nimbuslab/cli@0.14.0"
95
+ const match = bunResult.stdout.match(new RegExp(`${PACKAGE_NAME.replace("/", "\\/")}@([\\d.]+)`))
96
+ if (match?.[1]) {
97
+ return match[1]
97
98
  }
98
99
  }
99
100
  } catch {
@@ -155,8 +156,8 @@ export async function update(args: string[]) {
155
156
  // Detectar package manager
156
157
  spinner.start("Detectando package manager...")
157
158
  const detectedPm = detectPackageManager()
158
- // Usar bun como padrao se nenhum detectado
159
- const pm = detectedPm === "unknown" ? "bun" : detectedPm
159
+ // Usar npm como padrao se nenhum detectado (compativel com fnm/nvm)
160
+ const pm = detectedPm === "unknown" ? "npm" : detectedPm
160
161
  spinner.stop(`Package manager: ${pm}${detectedPm === "unknown" ? " (padrao)" : ""}`)
161
162
 
162
163
  // Verificar versao atual