@nimbuslab/cli 0.1.0 → 0.1.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/README.md +12 -2
- package/dist/index.js +28 -5
- package/package.json +1 -1
- package/src/commands/create.ts +33 -6
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,30 @@ 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
|
+
import { rm } from "fs/promises";
|
|
786
|
+
import { join } from "path";
|
|
785
787
|
var TEMPLATE_REPO = "git@github.com:nimbuslab-templates/fast-by-nimbuslab.git";
|
|
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
|
+
if (!hasBun) {
|
|
793
|
+
console.log(import_picocolors3.default.red("Erro: Bun nao encontrado."));
|
|
794
|
+
console.log(import_picocolors3.default.dim("Instale em: https://bun.sh"));
|
|
795
|
+
console.log();
|
|
796
|
+
if (process.platform === "win32") {
|
|
797
|
+
console.log(import_picocolors3.default.cyan('powershell -c "irm bun.sh/install.ps1 | iex"'));
|
|
798
|
+
} else {
|
|
799
|
+
console.log(import_picocolors3.default.cyan("curl -fsSL https://bun.sh/install | bash"));
|
|
800
|
+
}
|
|
801
|
+
console.log();
|
|
802
|
+
process.exit(1);
|
|
803
|
+
}
|
|
804
|
+
if (!hasGit) {
|
|
805
|
+
console.log(import_picocolors3.default.red("Erro: Git nao encontrado."));
|
|
806
|
+
console.log(import_picocolors3.default.dim("Instale git para continuar."));
|
|
807
|
+
process.exit(1);
|
|
808
|
+
}
|
|
787
809
|
const hasYes = args.includes("-y") || args.includes("--yes");
|
|
788
810
|
const projectName = args.find((a) => !a.startsWith("-"));
|
|
789
811
|
Ie(import_picocolors3.default.bgCyan(import_picocolors3.default.black(" Novo Projeto nimbuslab ")));
|
|
@@ -868,7 +890,7 @@ async function createProject(config) {
|
|
|
868
890
|
s.start("Clonando template...");
|
|
869
891
|
try {
|
|
870
892
|
await $2`git clone --depth 1 ${TEMPLATE_REPO} ${config.name}`.quiet();
|
|
871
|
-
await
|
|
893
|
+
await rm(join(config.name, ".git"), { recursive: true, force: true });
|
|
872
894
|
s.stop("Template clonado");
|
|
873
895
|
} catch (error) {
|
|
874
896
|
s.stop("Erro ao clonar template");
|
|
@@ -891,9 +913,10 @@ async function createProject(config) {
|
|
|
891
913
|
if (config.git) {
|
|
892
914
|
s.start("Inicializando Git...");
|
|
893
915
|
try {
|
|
894
|
-
|
|
895
|
-
await $2`
|
|
896
|
-
await $2`
|
|
916
|
+
const cwd = config.name;
|
|
917
|
+
await $2`git init`.cwd(cwd).quiet();
|
|
918
|
+
await $2`git add -A`.cwd(cwd).quiet();
|
|
919
|
+
await $2`git commit -m "chore: setup inicial via nimbus create"`.cwd(cwd).quiet();
|
|
897
920
|
s.stop("Git inicializado");
|
|
898
921
|
} catch (error) {
|
|
899
922
|
s.stop("Erro ao inicializar Git");
|
|
@@ -902,7 +925,7 @@ async function createProject(config) {
|
|
|
902
925
|
if (config.install) {
|
|
903
926
|
s.start("Instalando dependencias (pode demorar)...");
|
|
904
927
|
try {
|
|
905
|
-
await $2`
|
|
928
|
+
await $2`bun install`.cwd(config.name).quiet();
|
|
906
929
|
s.stop("Dependencias instaladas");
|
|
907
930
|
} catch (error) {
|
|
908
931
|
s.stop("Erro ao instalar dependencias");
|
package/package.json
CHANGED
package/src/commands/create.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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
7
|
const TEMPLATE_REPO = "git@github.com:nimbuslab-templates/fast-by-nimbuslab.git"
|
|
6
8
|
|
|
@@ -12,6 +14,30 @@ 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
|
+
|
|
22
|
+
if (!hasBun) {
|
|
23
|
+
console.log(pc.red("Erro: Bun nao encontrado."))
|
|
24
|
+
console.log(pc.dim("Instale em: https://bun.sh"))
|
|
25
|
+
console.log()
|
|
26
|
+
if (process.platform === "win32") {
|
|
27
|
+
console.log(pc.cyan('powershell -c "irm bun.sh/install.ps1 | iex"'))
|
|
28
|
+
} else {
|
|
29
|
+
console.log(pc.cyan("curl -fsSL https://bun.sh/install | bash"))
|
|
30
|
+
}
|
|
31
|
+
console.log()
|
|
32
|
+
process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!hasGit) {
|
|
36
|
+
console.log(pc.red("Erro: Git nao encontrado."))
|
|
37
|
+
console.log(pc.dim("Instale git para continuar."))
|
|
38
|
+
process.exit(1)
|
|
39
|
+
}
|
|
40
|
+
|
|
15
41
|
const hasYes = args.includes("-y") || args.includes("--yes")
|
|
16
42
|
const projectName = args.find(a => !a.startsWith("-"))
|
|
17
43
|
|
|
@@ -112,7 +138,7 @@ async function createProject(config: ProjectConfig) {
|
|
|
112
138
|
s.start("Clonando template...")
|
|
113
139
|
try {
|
|
114
140
|
await $`git clone --depth 1 ${TEMPLATE_REPO} ${config.name}`.quiet()
|
|
115
|
-
await
|
|
141
|
+
await rm(join(config.name, ".git"), { recursive: true, force: true })
|
|
116
142
|
s.stop("Template clonado")
|
|
117
143
|
} catch (error) {
|
|
118
144
|
s.stop("Erro ao clonar template")
|
|
@@ -143,9 +169,10 @@ async function createProject(config: ProjectConfig) {
|
|
|
143
169
|
if (config.git) {
|
|
144
170
|
s.start("Inicializando Git...")
|
|
145
171
|
try {
|
|
146
|
-
|
|
147
|
-
await $`
|
|
148
|
-
await $`
|
|
172
|
+
const cwd = config.name
|
|
173
|
+
await $`git init`.cwd(cwd).quiet()
|
|
174
|
+
await $`git add -A`.cwd(cwd).quiet()
|
|
175
|
+
await $`git commit -m "chore: setup inicial via nimbus create"`.cwd(cwd).quiet()
|
|
149
176
|
s.stop("Git inicializado")
|
|
150
177
|
} catch (error) {
|
|
151
178
|
s.stop("Erro ao inicializar Git")
|
|
@@ -156,7 +183,7 @@ async function createProject(config: ProjectConfig) {
|
|
|
156
183
|
if (config.install) {
|
|
157
184
|
s.start("Instalando dependencias (pode demorar)...")
|
|
158
185
|
try {
|
|
159
|
-
await $`
|
|
186
|
+
await $`bun install`.cwd(config.name).quiet()
|
|
160
187
|
s.stop("Dependencias instaladas")
|
|
161
188
|
} catch (error) {
|
|
162
189
|
s.stop("Erro ao instalar dependencias")
|