@nimbuslab/cli 0.4.1 → 0.4.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 +41 -1
- package/package.json +1 -1
- package/src/index.ts +52 -1
package/dist/index.js
CHANGED
|
@@ -1471,6 +1471,8 @@ function showNextSteps(config) {
|
|
|
1471
1471
|
}
|
|
1472
1472
|
|
|
1473
1473
|
// src/index.ts
|
|
1474
|
+
var PACKAGE_NAME = "@nimbuslab/cli";
|
|
1475
|
+
var CURRENT_VERSION = "0.4.2";
|
|
1474
1476
|
var LOGO = `
|
|
1475
1477
|
\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
1476
1478
|
\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
|
|
@@ -1478,6 +1480,40 @@ var LOGO = `
|
|
|
1478
1480
|
\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551
|
|
1479
1481
|
\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
|
|
1480
1482
|
\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D`;
|
|
1483
|
+
async function checkForUpdates() {
|
|
1484
|
+
try {
|
|
1485
|
+
const controller = new AbortController;
|
|
1486
|
+
const timeout = setTimeout(() => controller.abort(), 3000);
|
|
1487
|
+
const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
|
|
1488
|
+
signal: controller.signal
|
|
1489
|
+
});
|
|
1490
|
+
clearTimeout(timeout);
|
|
1491
|
+
if (!res.ok)
|
|
1492
|
+
return null;
|
|
1493
|
+
const data = await res.json();
|
|
1494
|
+
const latestVersion = data.version;
|
|
1495
|
+
if (latestVersion && latestVersion !== CURRENT_VERSION) {
|
|
1496
|
+
return latestVersion;
|
|
1497
|
+
}
|
|
1498
|
+
return null;
|
|
1499
|
+
} catch {
|
|
1500
|
+
return null;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
function showUpdateNotice(latestVersion) {
|
|
1504
|
+
const current = CURRENT_VERSION;
|
|
1505
|
+
const latest = latestVersion;
|
|
1506
|
+
const command = `bun add -g ${PACKAGE_NAME}`;
|
|
1507
|
+
const line1 = ` Nova versao disponivel: ${current} \u2192 ${latest}`;
|
|
1508
|
+
const line2 = ` Atualize com: ${command}`;
|
|
1509
|
+
const maxLen = Math.max(line1.length, line2.length);
|
|
1510
|
+
const border = "\u2500".repeat(maxLen + 2);
|
|
1511
|
+
console.log(import_picocolors4.default.yellow(` \u250C${border}\u2510`));
|
|
1512
|
+
console.log(import_picocolors4.default.yellow(` \u2502`) + import_picocolors4.default.white(line1.padEnd(maxLen + 1)) + import_picocolors4.default.yellow(`\u2502`));
|
|
1513
|
+
console.log(import_picocolors4.default.yellow(` \u2502`) + import_picocolors4.default.cyan(line2.padEnd(maxLen + 1)) + import_picocolors4.default.yellow(`\u2502`));
|
|
1514
|
+
console.log(import_picocolors4.default.yellow(` \u2514${border}\u2518`));
|
|
1515
|
+
console.log();
|
|
1516
|
+
}
|
|
1481
1517
|
async function main() {
|
|
1482
1518
|
const args = process.argv.slice(2);
|
|
1483
1519
|
const command = args[0];
|
|
@@ -1485,6 +1521,10 @@ async function main() {
|
|
|
1485
1521
|
console.log(import_picocolors4.default.white(" CLI da nimbuslab"));
|
|
1486
1522
|
console.log(import_picocolors4.default.dim(" Crie projetos incriveis"));
|
|
1487
1523
|
console.log();
|
|
1524
|
+
const latestVersion = await checkForUpdates();
|
|
1525
|
+
if (latestVersion) {
|
|
1526
|
+
showUpdateNotice(latestVersion);
|
|
1527
|
+
}
|
|
1488
1528
|
if (!command || command === "create") {
|
|
1489
1529
|
await create(args.slice(1));
|
|
1490
1530
|
} else if (command === "help" || command === "--help" || command === "-h") {
|
|
@@ -1528,7 +1568,7 @@ ${import_picocolors4.default.bold("Exemplos:")}
|
|
|
1528
1568
|
`);
|
|
1529
1569
|
}
|
|
1530
1570
|
function showVersion() {
|
|
1531
|
-
console.log(
|
|
1571
|
+
console.log(`${PACKAGE_NAME} v${CURRENT_VERSION}`);
|
|
1532
1572
|
}
|
|
1533
1573
|
main().catch((err) => {
|
|
1534
1574
|
console.error(import_picocolors4.default.red("Erro:"), err.message);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,6 +4,9 @@ import * as p from "@clack/prompts"
|
|
|
4
4
|
import pc from "picocolors"
|
|
5
5
|
import { create } from "./commands/create"
|
|
6
6
|
|
|
7
|
+
const PACKAGE_NAME = "@nimbuslab/cli"
|
|
8
|
+
const CURRENT_VERSION = "0.4.2"
|
|
9
|
+
|
|
7
10
|
const LOGO = `
|
|
8
11
|
███╗ ██╗██╗███╗ ███╗██████╗ ██╗ ██╗███████╗
|
|
9
12
|
████╗ ██║██║████╗ ████║██╔══██╗██║ ██║██╔════╝
|
|
@@ -12,6 +15,48 @@ const LOGO = `
|
|
|
12
15
|
██║ ╚████║██║██║ ╚═╝ ██║██████╔╝╚██████╔╝███████║
|
|
13
16
|
╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚══════╝`
|
|
14
17
|
|
|
18
|
+
async function checkForUpdates(): Promise<string | null> {
|
|
19
|
+
try {
|
|
20
|
+
const controller = new AbortController()
|
|
21
|
+
const timeout = setTimeout(() => controller.abort(), 3000)
|
|
22
|
+
|
|
23
|
+
const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
|
|
24
|
+
signal: controller.signal,
|
|
25
|
+
})
|
|
26
|
+
clearTimeout(timeout)
|
|
27
|
+
|
|
28
|
+
if (!res.ok) return null
|
|
29
|
+
|
|
30
|
+
const data = await res.json() as { version?: string }
|
|
31
|
+
const latestVersion = data.version
|
|
32
|
+
|
|
33
|
+
if (latestVersion && latestVersion !== CURRENT_VERSION) {
|
|
34
|
+
return latestVersion
|
|
35
|
+
}
|
|
36
|
+
return null
|
|
37
|
+
} catch {
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function showUpdateNotice(latestVersion: string) {
|
|
43
|
+
const current = CURRENT_VERSION
|
|
44
|
+
const latest = latestVersion
|
|
45
|
+
const command = `bun add -g ${PACKAGE_NAME}`
|
|
46
|
+
|
|
47
|
+
const line1 = ` Nova versao disponivel: ${current} → ${latest}`
|
|
48
|
+
const line2 = ` Atualize com: ${command}`
|
|
49
|
+
|
|
50
|
+
const maxLen = Math.max(line1.length, line2.length)
|
|
51
|
+
const border = "─".repeat(maxLen + 2)
|
|
52
|
+
|
|
53
|
+
console.log(pc.yellow(` ┌${border}┐`))
|
|
54
|
+
console.log(pc.yellow(` │`) + pc.white(line1.padEnd(maxLen + 1)) + pc.yellow(`│`))
|
|
55
|
+
console.log(pc.yellow(` │`) + pc.cyan(line2.padEnd(maxLen + 1)) + pc.yellow(`│`))
|
|
56
|
+
console.log(pc.yellow(` └${border}┘`))
|
|
57
|
+
console.log()
|
|
58
|
+
}
|
|
59
|
+
|
|
15
60
|
async function main() {
|
|
16
61
|
const args = process.argv.slice(2)
|
|
17
62
|
const command = args[0]
|
|
@@ -21,6 +66,12 @@ async function main() {
|
|
|
21
66
|
console.log(pc.dim(" Crie projetos incriveis"))
|
|
22
67
|
console.log()
|
|
23
68
|
|
|
69
|
+
// Check for updates (non-blocking)
|
|
70
|
+
const latestVersion = await checkForUpdates()
|
|
71
|
+
if (latestVersion) {
|
|
72
|
+
showUpdateNotice(latestVersion)
|
|
73
|
+
}
|
|
74
|
+
|
|
24
75
|
if (!command || command === "create") {
|
|
25
76
|
await create(args.slice(1))
|
|
26
77
|
} else if (command === "help" || command === "--help" || command === "-h") {
|
|
@@ -66,7 +117,7 @@ ${pc.bold("Exemplos:")}
|
|
|
66
117
|
}
|
|
67
118
|
|
|
68
119
|
function showVersion() {
|
|
69
|
-
console.log(
|
|
120
|
+
console.log(`${PACKAGE_NAME} v${CURRENT_VERSION}`)
|
|
70
121
|
}
|
|
71
122
|
|
|
72
123
|
main().catch((err) => {
|