@nimbuslab/cli 0.1.0 → 0.1.3
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/README.md +12 -2
- package/dist/index.js +54 -12
- package/package.json +1 -1
- package/src/commands/create.ts +59 -10
- package/src/index.ts +4 -3
package/README.md
CHANGED
|
@@ -47,9 +47,19 @@ nimbus help
|
|
|
47
47
|
|
|
48
48
|
## Requisitos
|
|
49
49
|
|
|
50
|
+
- **Bun** - Runtime e package manager (https://bun.sh)
|
|
51
|
+
- **Git** - Controle de versao
|
|
50
52
|
- Acesso SSH ao repositorio de templates nimbuslab
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
|
|
54
|
+
### Instalando Bun
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Linux/Mac
|
|
58
|
+
curl -fsSL https://bun.sh/install | bash
|
|
59
|
+
|
|
60
|
+
# Windows (PowerShell)
|
|
61
|
+
powershell -c "irm bun.sh/install.ps1 | iex"
|
|
62
|
+
```
|
|
53
63
|
|
|
54
64
|
## Desenvolvimento
|
|
55
65
|
|
package/dist/index.js
CHANGED
|
@@ -782,8 +782,49 @@ var Ce = async (t, n) => {
|
|
|
782
782
|
// src/commands/create.ts
|
|
783
783
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
784
784
|
var {$: $2 } = globalThis.Bun;
|
|
785
|
-
|
|
785
|
+
import { rm } from "fs/promises";
|
|
786
|
+
import { join } from "path";
|
|
787
|
+
var TEMPLATE_REPO = "nimbuslab-templates/fast-by-nimbuslab";
|
|
786
788
|
async function create(args) {
|
|
789
|
+
const checkCmd = process.platform === "win32" ? "where" : "which";
|
|
790
|
+
const hasBun = await $2`${checkCmd} bun`.quiet().then(() => true).catch(() => false);
|
|
791
|
+
const hasGit = await $2`${checkCmd} git`.quiet().then(() => true).catch(() => false);
|
|
792
|
+
const hasGh = await $2`${checkCmd} gh`.quiet().then(() => true).catch(() => false);
|
|
793
|
+
if (!hasBun) {
|
|
794
|
+
console.log(import_picocolors3.default.red("Erro: Bun nao encontrado."));
|
|
795
|
+
console.log(import_picocolors3.default.dim("Instale em: https://bun.sh"));
|
|
796
|
+
console.log();
|
|
797
|
+
if (process.platform === "win32") {
|
|
798
|
+
console.log(import_picocolors3.default.cyan('powershell -c "irm bun.sh/install.ps1 | iex"'));
|
|
799
|
+
} else {
|
|
800
|
+
console.log(import_picocolors3.default.cyan("curl -fsSL https://bun.sh/install | bash"));
|
|
801
|
+
}
|
|
802
|
+
console.log();
|
|
803
|
+
process.exit(1);
|
|
804
|
+
}
|
|
805
|
+
if (!hasGit) {
|
|
806
|
+
console.log(import_picocolors3.default.red("Erro: Git nao encontrado."));
|
|
807
|
+
console.log(import_picocolors3.default.dim("Instale git para continuar."));
|
|
808
|
+
process.exit(1);
|
|
809
|
+
}
|
|
810
|
+
if (!hasGh) {
|
|
811
|
+
console.log(import_picocolors3.default.red("Erro: GitHub CLI (gh) nao encontrado."));
|
|
812
|
+
console.log(import_picocolors3.default.dim("Instale em: https://cli.github.com"));
|
|
813
|
+
console.log();
|
|
814
|
+
if (process.platform === "win32") {
|
|
815
|
+
console.log(import_picocolors3.default.cyan("winget install GitHub.cli"));
|
|
816
|
+
} else {
|
|
817
|
+
console.log(import_picocolors3.default.cyan("sudo apt install gh # ou brew install gh"));
|
|
818
|
+
}
|
|
819
|
+
console.log();
|
|
820
|
+
process.exit(1);
|
|
821
|
+
}
|
|
822
|
+
const ghAuth = await $2`gh auth status`.quiet().then(() => true).catch(() => false);
|
|
823
|
+
if (!ghAuth) {
|
|
824
|
+
console.log(import_picocolors3.default.red("Erro: GitHub CLI nao autenticado."));
|
|
825
|
+
console.log(import_picocolors3.default.dim("Execute: gh auth login"));
|
|
826
|
+
process.exit(1);
|
|
827
|
+
}
|
|
787
828
|
const hasYes = args.includes("-y") || args.includes("--yes");
|
|
788
829
|
const projectName = args.find((a) => !a.startsWith("-"));
|
|
789
830
|
Ie(import_picocolors3.default.bgCyan(import_picocolors3.default.black(" Novo Projeto nimbuslab ")));
|
|
@@ -867,12 +908,12 @@ async function createProject(config) {
|
|
|
867
908
|
const s = Y2();
|
|
868
909
|
s.start("Clonando template...");
|
|
869
910
|
try {
|
|
870
|
-
await $2`
|
|
871
|
-
await
|
|
911
|
+
await $2`gh repo clone ${TEMPLATE_REPO} ${config.name} -- --depth 1`.quiet();
|
|
912
|
+
await rm(join(config.name, ".git"), { recursive: true, force: true });
|
|
872
913
|
s.stop("Template clonado");
|
|
873
914
|
} catch (error) {
|
|
874
915
|
s.stop("Erro ao clonar template");
|
|
875
|
-
throw new Error("Falha ao clonar template. Verifique
|
|
916
|
+
throw new Error("Falha ao clonar template. Verifique se tem acesso ao repositorio.");
|
|
876
917
|
}
|
|
877
918
|
s.start("Configurando projeto...");
|
|
878
919
|
try {
|
|
@@ -891,9 +932,10 @@ async function createProject(config) {
|
|
|
891
932
|
if (config.git) {
|
|
892
933
|
s.start("Inicializando Git...");
|
|
893
934
|
try {
|
|
894
|
-
|
|
895
|
-
await $2`
|
|
896
|
-
await $2`
|
|
935
|
+
const cwd = config.name;
|
|
936
|
+
await $2`git init`.cwd(cwd).quiet();
|
|
937
|
+
await $2`git add -A`.cwd(cwd).quiet();
|
|
938
|
+
await $2`git commit -m "chore: setup inicial via nimbus create"`.cwd(cwd).quiet();
|
|
897
939
|
s.stop("Git inicializado");
|
|
898
940
|
} catch (error) {
|
|
899
941
|
s.stop("Erro ao inicializar Git");
|
|
@@ -902,7 +944,7 @@ async function createProject(config) {
|
|
|
902
944
|
if (config.install) {
|
|
903
945
|
s.start("Instalando dependencias (pode demorar)...");
|
|
904
946
|
try {
|
|
905
|
-
await $2`
|
|
947
|
+
await $2`bun install`.cwd(config.name).quiet();
|
|
906
948
|
s.stop("Dependencias instaladas");
|
|
907
949
|
} catch (error) {
|
|
908
950
|
s.stop("Erro ao instalar dependencias");
|
|
@@ -935,14 +977,14 @@ var LOGO = `
|
|
|
935
977
|
\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
936
978
|
\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
|
|
937
979
|
\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
|
|
938
|
-
\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
|
|
939
|
-
`;
|
|
980
|
+
\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`;
|
|
940
981
|
async function main() {
|
|
941
982
|
const args = process.argv.slice(2);
|
|
942
983
|
const command = args[0];
|
|
943
984
|
console.log(import_picocolors4.default.cyan(LOGO));
|
|
944
|
-
console.log(import_picocolors4.default.
|
|
945
|
-
|
|
985
|
+
console.log(import_picocolors4.default.white(" CLI da nimbuslab"));
|
|
986
|
+
console.log(import_picocolors4.default.dim(" Crie projetos incriveis"));
|
|
987
|
+
console.log();
|
|
946
988
|
if (!command || command === "create") {
|
|
947
989
|
await create(args.slice(1));
|
|
948
990
|
} else if (command === "help" || command === "--help" || command === "-h") {
|
package/package.json
CHANGED
package/src/commands/create.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as p from "@clack/prompts"
|
|
2
2
|
import pc from "picocolors"
|
|
3
|
-
import { $
|
|
3
|
+
import { $} from "bun"
|
|
4
|
+
import { rm } from "node:fs/promises"
|
|
5
|
+
import { join } from "node:path"
|
|
4
6
|
|
|
5
|
-
const TEMPLATE_REPO = "
|
|
7
|
+
const TEMPLATE_REPO = "nimbuslab-templates/fast-by-nimbuslab"
|
|
6
8
|
|
|
7
9
|
interface ProjectConfig {
|
|
8
10
|
name: string
|
|
@@ -12,6 +14,52 @@ interface ProjectConfig {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export async function create(args: string[]) {
|
|
17
|
+
// Verifica dependencias (cross-platform)
|
|
18
|
+
const checkCmd = process.platform === "win32" ? "where" : "which"
|
|
19
|
+
const hasBun = await $`${checkCmd} bun`.quiet().then(() => true).catch(() => false)
|
|
20
|
+
const hasGit = await $`${checkCmd} git`.quiet().then(() => true).catch(() => false)
|
|
21
|
+
const hasGh = await $`${checkCmd} gh`.quiet().then(() => true).catch(() => false)
|
|
22
|
+
|
|
23
|
+
if (!hasBun) {
|
|
24
|
+
console.log(pc.red("Erro: Bun nao encontrado."))
|
|
25
|
+
console.log(pc.dim("Instale em: https://bun.sh"))
|
|
26
|
+
console.log()
|
|
27
|
+
if (process.platform === "win32") {
|
|
28
|
+
console.log(pc.cyan('powershell -c "irm bun.sh/install.ps1 | iex"'))
|
|
29
|
+
} else {
|
|
30
|
+
console.log(pc.cyan("curl -fsSL https://bun.sh/install | bash"))
|
|
31
|
+
}
|
|
32
|
+
console.log()
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!hasGit) {
|
|
37
|
+
console.log(pc.red("Erro: Git nao encontrado."))
|
|
38
|
+
console.log(pc.dim("Instale git para continuar."))
|
|
39
|
+
process.exit(1)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!hasGh) {
|
|
43
|
+
console.log(pc.red("Erro: GitHub CLI (gh) nao encontrado."))
|
|
44
|
+
console.log(pc.dim("Instale em: https://cli.github.com"))
|
|
45
|
+
console.log()
|
|
46
|
+
if (process.platform === "win32") {
|
|
47
|
+
console.log(pc.cyan("winget install GitHub.cli"))
|
|
48
|
+
} else {
|
|
49
|
+
console.log(pc.cyan("sudo apt install gh # ou brew install gh"))
|
|
50
|
+
}
|
|
51
|
+
console.log()
|
|
52
|
+
process.exit(1)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Verifica se gh esta autenticado
|
|
56
|
+
const ghAuth = await $`gh auth status`.quiet().then(() => true).catch(() => false)
|
|
57
|
+
if (!ghAuth) {
|
|
58
|
+
console.log(pc.red("Erro: GitHub CLI nao autenticado."))
|
|
59
|
+
console.log(pc.dim("Execute: gh auth login"))
|
|
60
|
+
process.exit(1)
|
|
61
|
+
}
|
|
62
|
+
|
|
15
63
|
const hasYes = args.includes("-y") || args.includes("--yes")
|
|
16
64
|
const projectName = args.find(a => !a.startsWith("-"))
|
|
17
65
|
|
|
@@ -108,15 +156,15 @@ async function promptConfig(initialName?: string): Promise<ProjectConfig | symbo
|
|
|
108
156
|
async function createProject(config: ProjectConfig) {
|
|
109
157
|
const s = p.spinner()
|
|
110
158
|
|
|
111
|
-
// Clone template
|
|
159
|
+
// Clone template usando gh (funciona com token OAuth)
|
|
112
160
|
s.start("Clonando template...")
|
|
113
161
|
try {
|
|
114
|
-
await $`
|
|
115
|
-
await
|
|
162
|
+
await $`gh repo clone ${TEMPLATE_REPO} ${config.name} -- --depth 1`.quiet()
|
|
163
|
+
await rm(join(config.name, ".git"), { recursive: true, force: true })
|
|
116
164
|
s.stop("Template clonado")
|
|
117
165
|
} catch (error) {
|
|
118
166
|
s.stop("Erro ao clonar template")
|
|
119
|
-
throw new Error("Falha ao clonar template. Verifique
|
|
167
|
+
throw new Error("Falha ao clonar template. Verifique se tem acesso ao repositorio.")
|
|
120
168
|
}
|
|
121
169
|
|
|
122
170
|
// Update package.json
|
|
@@ -143,9 +191,10 @@ async function createProject(config: ProjectConfig) {
|
|
|
143
191
|
if (config.git) {
|
|
144
192
|
s.start("Inicializando Git...")
|
|
145
193
|
try {
|
|
146
|
-
|
|
147
|
-
await $`
|
|
148
|
-
await $`
|
|
194
|
+
const cwd = config.name
|
|
195
|
+
await $`git init`.cwd(cwd).quiet()
|
|
196
|
+
await $`git add -A`.cwd(cwd).quiet()
|
|
197
|
+
await $`git commit -m "chore: setup inicial via nimbus create"`.cwd(cwd).quiet()
|
|
149
198
|
s.stop("Git inicializado")
|
|
150
199
|
} catch (error) {
|
|
151
200
|
s.stop("Erro ao inicializar Git")
|
|
@@ -156,7 +205,7 @@ async function createProject(config: ProjectConfig) {
|
|
|
156
205
|
if (config.install) {
|
|
157
206
|
s.start("Instalando dependencias (pode demorar)...")
|
|
158
207
|
try {
|
|
159
|
-
await $`
|
|
208
|
+
await $`bun install`.cwd(config.name).quiet()
|
|
160
209
|
s.stop("Dependencias instaladas")
|
|
161
210
|
} catch (error) {
|
|
162
211
|
s.stop("Erro ao instalar dependencias")
|
package/src/index.ts
CHANGED
|
@@ -10,15 +10,16 @@ const LOGO = `
|
|
|
10
10
|
██╔██╗ ██║██║██╔████╔██║██████╔╝██║ ██║███████╗
|
|
11
11
|
██║╚██╗██║██║██║╚██╔╝██║██╔══██╗██║ ██║╚════██║
|
|
12
12
|
██║ ╚████║██║██║ ╚═╝ ██║██████╔╝╚██████╔╝███████║
|
|
13
|
-
╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝
|
|
14
|
-
`
|
|
13
|
+
╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚══════╝`
|
|
15
14
|
|
|
16
15
|
async function main() {
|
|
17
16
|
const args = process.argv.slice(2)
|
|
18
17
|
const command = args[0]
|
|
19
18
|
|
|
20
19
|
console.log(pc.cyan(LOGO))
|
|
21
|
-
console.log(pc.
|
|
20
|
+
console.log(pc.white(" CLI da nimbuslab"))
|
|
21
|
+
console.log(pc.dim(" Crie projetos incriveis"))
|
|
22
|
+
console.log()
|
|
22
23
|
|
|
23
24
|
if (!command || command === "create") {
|
|
24
25
|
await create(args.slice(1))
|