@nimbuslab/cli 0.1.0
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/CLAUDE.md +106 -0
- package/LICENSE +11 -0
- package/README.md +80 -0
- package/bun.lock +38 -0
- package/dist/index.js +982 -0
- package/package.json +41 -0
- package/src/commands/create.ts +188 -0
- package/src/index.ts +62 -0
- package/tsconfig.json +29 -0
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nimbuslab/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI para criar projetos nimbuslab",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"nimbus": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "bun run src/index.ts",
|
|
11
|
+
"build": "bun build src/index.ts --outdir dist --target bun",
|
|
12
|
+
"typecheck": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"keywords": ["nimbuslab", "cli", "nextjs", "fast", "landing-page", "saas"],
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "nimbuslab",
|
|
17
|
+
"email": "contato@nimbuslab.com.br",
|
|
18
|
+
"url": "https://nimbuslab.com.br"
|
|
19
|
+
},
|
|
20
|
+
"license": "UNLICENSED",
|
|
21
|
+
"private": false,
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/nimbuslab/nimbus-cli.git"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://nimbuslab.com.br",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/nimbuslab/nimbus-cli/issues"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/bun": "latest",
|
|
35
|
+
"typescript": "^5"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@clack/prompts": "^0.11.0",
|
|
39
|
+
"picocolors": "^1.1.1"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as p from "@clack/prompts"
|
|
2
|
+
import pc from "picocolors"
|
|
3
|
+
import { $ } from "bun"
|
|
4
|
+
|
|
5
|
+
const TEMPLATE_REPO = "git@github.com:nimbuslab-templates/fast-by-nimbuslab.git"
|
|
6
|
+
|
|
7
|
+
interface ProjectConfig {
|
|
8
|
+
name: string
|
|
9
|
+
type: "fast" | "fast+"
|
|
10
|
+
git: boolean
|
|
11
|
+
install: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function create(args: string[]) {
|
|
15
|
+
const hasYes = args.includes("-y") || args.includes("--yes")
|
|
16
|
+
const projectName = args.find(a => !a.startsWith("-"))
|
|
17
|
+
|
|
18
|
+
p.intro(pc.bgCyan(pc.black(" Novo Projeto nimbuslab ")))
|
|
19
|
+
|
|
20
|
+
let config: ProjectConfig | symbol
|
|
21
|
+
|
|
22
|
+
if (hasYes && projectName) {
|
|
23
|
+
// Modo automatico com defaults
|
|
24
|
+
config = {
|
|
25
|
+
name: projectName,
|
|
26
|
+
type: "fast",
|
|
27
|
+
git: true,
|
|
28
|
+
install: true,
|
|
29
|
+
}
|
|
30
|
+
console.log(pc.dim(` Projeto: ${projectName}`))
|
|
31
|
+
console.log(pc.dim(` Tipo: fast`))
|
|
32
|
+
console.log(pc.dim(` Git: sim`))
|
|
33
|
+
console.log(pc.dim(` Instalar: sim`))
|
|
34
|
+
console.log()
|
|
35
|
+
} else {
|
|
36
|
+
config = await promptConfig(projectName)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (p.isCancel(config)) {
|
|
40
|
+
p.cancel("Operacao cancelada")
|
|
41
|
+
process.exit(0)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await createProject(config as ProjectConfig)
|
|
45
|
+
|
|
46
|
+
p.outro(pc.green("Projeto criado com sucesso!"))
|
|
47
|
+
|
|
48
|
+
showNextSteps(config as ProjectConfig)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function promptConfig(initialName?: string): Promise<ProjectConfig | symbol> {
|
|
52
|
+
const name = await p.text({
|
|
53
|
+
message: "Nome do projeto:",
|
|
54
|
+
placeholder: "meu-projeto",
|
|
55
|
+
initialValue: initialName,
|
|
56
|
+
validate: (value) => {
|
|
57
|
+
if (!value) return "Nome e obrigatorio"
|
|
58
|
+
if (!/^[a-z0-9-]+$/.test(value)) {
|
|
59
|
+
return "Use apenas letras minusculas, numeros e hifens"
|
|
60
|
+
}
|
|
61
|
+
return undefined
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
if (p.isCancel(name)) return name
|
|
66
|
+
|
|
67
|
+
const type = await p.select({
|
|
68
|
+
message: "Tipo de projeto:",
|
|
69
|
+
options: [
|
|
70
|
+
{
|
|
71
|
+
value: "fast",
|
|
72
|
+
label: "fast",
|
|
73
|
+
hint: "Landing page em 6 dias",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: "fast+",
|
|
77
|
+
label: "fast+",
|
|
78
|
+
hint: "SaaS completo com backend",
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
if (p.isCancel(type)) return type
|
|
84
|
+
|
|
85
|
+
const extras = await p.group({
|
|
86
|
+
git: () =>
|
|
87
|
+
p.confirm({
|
|
88
|
+
message: "Inicializar repositorio Git?",
|
|
89
|
+
initialValue: true,
|
|
90
|
+
}),
|
|
91
|
+
install: () =>
|
|
92
|
+
p.confirm({
|
|
93
|
+
message: "Instalar dependencias?",
|
|
94
|
+
initialValue: true,
|
|
95
|
+
}),
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
if (p.isCancel(extras)) return extras
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
name: name as string,
|
|
102
|
+
type: type as "fast" | "fast+",
|
|
103
|
+
git: extras.git as boolean,
|
|
104
|
+
install: extras.install as boolean,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function createProject(config: ProjectConfig) {
|
|
109
|
+
const s = p.spinner()
|
|
110
|
+
|
|
111
|
+
// Clone template
|
|
112
|
+
s.start("Clonando template...")
|
|
113
|
+
try {
|
|
114
|
+
await $`git clone --depth 1 ${TEMPLATE_REPO} ${config.name}`.quiet()
|
|
115
|
+
await $`rm -rf ${config.name}/.git`.quiet()
|
|
116
|
+
s.stop("Template clonado")
|
|
117
|
+
} catch (error) {
|
|
118
|
+
s.stop("Erro ao clonar template")
|
|
119
|
+
throw new Error("Falha ao clonar template. Verifique sua conexao.")
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Update package.json
|
|
123
|
+
s.start("Configurando projeto...")
|
|
124
|
+
try {
|
|
125
|
+
const pkgPath = `${config.name}/package.json`
|
|
126
|
+
const pkg = await Bun.file(pkgPath).json()
|
|
127
|
+
pkg.name = config.name
|
|
128
|
+
await Bun.write(pkgPath, JSON.stringify(pkg, null, 2))
|
|
129
|
+
s.stop("Projeto configurado")
|
|
130
|
+
} catch (error) {
|
|
131
|
+
s.stop("Erro ao configurar")
|
|
132
|
+
// Continue anyway
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Setup fast+ if selected
|
|
136
|
+
if (config.type === "fast+") {
|
|
137
|
+
s.start("Configurando fast+ (SaaS)...")
|
|
138
|
+
// O setup real será feito pelo bun setup do próprio template
|
|
139
|
+
s.stop("Configuracao fast+ preparada")
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Git init
|
|
143
|
+
if (config.git) {
|
|
144
|
+
s.start("Inicializando Git...")
|
|
145
|
+
try {
|
|
146
|
+
await $`cd ${config.name} && git init`.quiet()
|
|
147
|
+
await $`cd ${config.name} && git add -A`.quiet()
|
|
148
|
+
await $`cd ${config.name} && git commit -m "chore: setup inicial via nimbus create"`.quiet()
|
|
149
|
+
s.stop("Git inicializado")
|
|
150
|
+
} catch (error) {
|
|
151
|
+
s.stop("Erro ao inicializar Git")
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Install deps
|
|
156
|
+
if (config.install) {
|
|
157
|
+
s.start("Instalando dependencias (pode demorar)...")
|
|
158
|
+
try {
|
|
159
|
+
await $`cd ${config.name} && bun install`.quiet()
|
|
160
|
+
s.stop("Dependencias instaladas")
|
|
161
|
+
} catch (error) {
|
|
162
|
+
s.stop("Erro ao instalar dependencias")
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function showNextSteps(config: ProjectConfig) {
|
|
168
|
+
console.log()
|
|
169
|
+
console.log(pc.bold("Proximos passos:"))
|
|
170
|
+
console.log()
|
|
171
|
+
console.log(` ${pc.cyan("cd")} ${config.name}`)
|
|
172
|
+
|
|
173
|
+
if (!config.install) {
|
|
174
|
+
console.log(` ${pc.cyan("bun")} install`)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
console.log(` ${pc.cyan("bun")} setup`)
|
|
178
|
+
console.log(` ${pc.cyan("bun")} dev`)
|
|
179
|
+
console.log()
|
|
180
|
+
|
|
181
|
+
if (config.type === "fast+") {
|
|
182
|
+
console.log(pc.dim(" Dica: Execute 'bun setup' e escolha fast+ para configurar backend"))
|
|
183
|
+
console.log()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
console.log(pc.dim(" Documentacao: https://github.com/nimbuslab/fast-by-nimbuslab"))
|
|
187
|
+
console.log()
|
|
188
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import * as p from "@clack/prompts"
|
|
4
|
+
import pc from "picocolors"
|
|
5
|
+
import { create } from "./commands/create"
|
|
6
|
+
|
|
7
|
+
const LOGO = `
|
|
8
|
+
███╗ ██╗██╗███╗ ███╗██████╗ ██╗ ██╗███████╗
|
|
9
|
+
████╗ ██║██║████╗ ████║██╔══██╗██║ ██║██╔════╝
|
|
10
|
+
██╔██╗ ██║██║██╔████╔██║██████╔╝██║ ██║███████╗
|
|
11
|
+
██║╚██╗██║██║██║╚██╔╝██║██╔══██╗██║ ██║╚════██║
|
|
12
|
+
██║ ╚████║██║██║ ╚═╝ ██║██████╔╝╚██████╔╝███████║
|
|
13
|
+
╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚══════╝
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
const args = process.argv.slice(2)
|
|
18
|
+
const command = args[0]
|
|
19
|
+
|
|
20
|
+
console.log(pc.cyan(LOGO))
|
|
21
|
+
console.log(pc.dim(" CLI da nimbuslab - Crie projetos incríveis\n"))
|
|
22
|
+
|
|
23
|
+
if (!command || command === "create") {
|
|
24
|
+
await create(args.slice(1))
|
|
25
|
+
} else if (command === "help" || command === "--help" || command === "-h") {
|
|
26
|
+
showHelp()
|
|
27
|
+
} else if (command === "version" || command === "--version" || command === "-v") {
|
|
28
|
+
showVersion()
|
|
29
|
+
} else {
|
|
30
|
+
console.log(pc.red(`Comando desconhecido: ${command}`))
|
|
31
|
+
showHelp()
|
|
32
|
+
process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function showHelp() {
|
|
37
|
+
console.log(`
|
|
38
|
+
${pc.bold("Uso:")} nimbus [comando] [opcoes]
|
|
39
|
+
|
|
40
|
+
${pc.bold("Comandos:")}
|
|
41
|
+
create [nome] Criar novo projeto nimbuslab
|
|
42
|
+
help Mostrar esta ajuda
|
|
43
|
+
version Mostrar versao
|
|
44
|
+
|
|
45
|
+
${pc.bold("Opcoes:")}
|
|
46
|
+
-y, --yes Aceitar defaults (fast, git, install)
|
|
47
|
+
|
|
48
|
+
${pc.bold("Exemplos:")}
|
|
49
|
+
${pc.dim("$")} nimbus create meu-projeto
|
|
50
|
+
${pc.dim("$")} nimbus create meu-projeto -y
|
|
51
|
+
${pc.dim("$")} nimbus create
|
|
52
|
+
`)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function showVersion() {
|
|
56
|
+
console.log(`@nimbuslab/cli v0.1.0`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
main().catch((err) => {
|
|
60
|
+
console.error(pc.red("Erro:"), err.message)
|
|
61
|
+
process.exit(1)
|
|
62
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment setup & latest features
|
|
4
|
+
"lib": ["ESNext"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "Preserve",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
|
|
11
|
+
// Bundler mode
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
// Best practices
|
|
18
|
+
"strict": true,
|
|
19
|
+
"skipLibCheck": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedIndexedAccess": true,
|
|
22
|
+
"noImplicitOverride": true,
|
|
23
|
+
|
|
24
|
+
// Some stricter flags (disabled by default)
|
|
25
|
+
"noUnusedLocals": false,
|
|
26
|
+
"noUnusedParameters": false,
|
|
27
|
+
"noPropertyAccessFromIndexSignature": false
|
|
28
|
+
}
|
|
29
|
+
}
|