@nimbuslab/cli 0.16.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 +20 -20
- package/package.json +1 -1
- package/src/commands/update.ts +27 -26
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.
|
|
153
|
+
version: "0.16.1",
|
|
154
154
|
description: "CLI para criar projetos nimbuslab",
|
|
155
155
|
type: "module",
|
|
156
156
|
bin: {
|
|
@@ -2383,16 +2383,6 @@ async function getLatestVersion() {
|
|
|
2383
2383
|
}
|
|
2384
2384
|
}
|
|
2385
2385
|
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
2386
|
try {
|
|
2397
2387
|
const npmResult = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
|
|
2398
2388
|
encoding: "utf-8",
|
|
@@ -2406,22 +2396,19 @@ function detectPackageManager2() {
|
|
|
2406
2396
|
}
|
|
2407
2397
|
}
|
|
2408
2398
|
} catch {}
|
|
2409
|
-
return "unknown";
|
|
2410
|
-
}
|
|
2411
|
-
function getCurrentVersion() {
|
|
2412
2399
|
try {
|
|
2413
2400
|
const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
|
|
2414
2401
|
encoding: "utf-8",
|
|
2415
2402
|
shell: true,
|
|
2416
2403
|
timeout: 5000
|
|
2417
2404
|
});
|
|
2418
|
-
if (bunResult.stdout) {
|
|
2419
|
-
|
|
2420
|
-
if (match?.[1]) {
|
|
2421
|
-
return match[1];
|
|
2422
|
-
}
|
|
2405
|
+
if (bunResult.stdout && bunResult.stdout.includes(PACKAGE_NAME)) {
|
|
2406
|
+
return "bun";
|
|
2423
2407
|
}
|
|
2424
2408
|
} catch {}
|
|
2409
|
+
return "unknown";
|
|
2410
|
+
}
|
|
2411
|
+
function getCurrentVersion() {
|
|
2425
2412
|
try {
|
|
2426
2413
|
const result = spawnSync("npm", ["ls", "-g", PACKAGE_NAME, "--json"], {
|
|
2427
2414
|
encoding: "utf-8",
|
|
@@ -2435,6 +2422,19 @@ function getCurrentVersion() {
|
|
|
2435
2422
|
}
|
|
2436
2423
|
}
|
|
2437
2424
|
} catch {}
|
|
2425
|
+
try {
|
|
2426
|
+
const bunResult = spawnSync("bun", ["pm", "ls", "-g"], {
|
|
2427
|
+
encoding: "utf-8",
|
|
2428
|
+
shell: true,
|
|
2429
|
+
timeout: 5000
|
|
2430
|
+
});
|
|
2431
|
+
if (bunResult.stdout) {
|
|
2432
|
+
const match = bunResult.stdout.match(new RegExp(`${PACKAGE_NAME.replace("/", "\\/")}@([\\d.]+)`));
|
|
2433
|
+
if (match?.[1]) {
|
|
2434
|
+
return match[1];
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
} catch {}
|
|
2438
2438
|
return "unknown";
|
|
2439
2439
|
}
|
|
2440
2440
|
async function update(args) {
|
|
@@ -2475,7 +2475,7 @@ async function update(args) {
|
|
|
2475
2475
|
const spinner = Y2();
|
|
2476
2476
|
spinner.start("Detectando package manager...");
|
|
2477
2477
|
const detectedPm = detectPackageManager2();
|
|
2478
|
-
const pm = detectedPm === "unknown" ? "
|
|
2478
|
+
const pm = detectedPm === "unknown" ? "npm" : detectedPm;
|
|
2479
2479
|
spinner.stop(`Package manager: ${pm}${detectedPm === "unknown" ? " (padrao)" : ""}`);
|
|
2480
2480
|
spinner.start("Verificando versao atual...");
|
|
2481
2481
|
const currentVersion = getCurrentVersion();
|
package/package.json
CHANGED
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
|