@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.
- package/dist/index.js +399 -195
- package/package.json +1 -1
- package/src/commands/lola.ts +476 -196
- package/src/commands/update.ts +27 -26
package/src/commands/update.ts
CHANGED
|
@@ -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
|
|
34
|
+
// Tentar npm primeiro (prioridade)
|
|
34
35
|
try {
|
|
35
|
-
const
|
|
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 (
|
|
41
|
-
|
|
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
|
-
//
|
|
51
|
+
// Fallback para bun
|
|
48
52
|
try {
|
|
49
|
-
const
|
|
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 (
|
|
55
|
-
|
|
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
|
|
69
|
+
// Tentar npm primeiro (prioridade)
|
|
69
70
|
try {
|
|
70
|
-
const
|
|
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 (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
86
|
+
// Fallback para bun
|
|
87
87
|
try {
|
|
88
|
-
const
|
|
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 (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
159
|
-
const pm = detectedPm === "unknown" ? "
|
|
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
|