tumemo 1.0.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/README.md +18 -0
- package/index.js +138 -0
- package/package.json +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Tumemo CLI 🚀
|
|
2
|
+
|
|
3
|
+
Um CLI robusto para automatizar o setup de projetos **React + TypeScript + Vite**, focado em produtividade e limpeza de boilerplate.
|
|
4
|
+
|
|
5
|
+
## 🛠️ O que ele faz?
|
|
6
|
+
|
|
7
|
+
- **Setup Instantâneo:** Cria a base com Vite + React + TS no diretório atual.
|
|
8
|
+
- **Limpeza Radical:** Remove automaticamente `assets/`, `App.css` e `index.css` do Vite.
|
|
9
|
+
- **Configuração de Estilos:** Cria uma pasta `src/shared/tailwind.css` (opcional).
|
|
10
|
+
- **Integração Shadcn UI:** Configura Aliases (`@/`) no Vite e TS, além de rodar o init do Shadcn.
|
|
11
|
+
- **Pronto para API:** Já instala o **Axios** por padrão.
|
|
12
|
+
- **Organização Sênior:** Cria pastas `components`, `pages`, `hooks` e `lib`.
|
|
13
|
+
|
|
14
|
+
## 🚀 Como usar
|
|
15
|
+
|
|
16
|
+
### Via NPX (Sem instalação)
|
|
17
|
+
```bash
|
|
18
|
+
npx tumemo-cli -s
|
package/index.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { execa } from 'execa';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
const log = {
|
|
10
|
+
info: (msg) => console.log(chalk.blue(`ℹ ${msg}`)),
|
|
11
|
+
success: (msg) => console.log(chalk.green.bold(`\n✅ ${msg}`)),
|
|
12
|
+
error: (msg) => console.log(chalk.red.bold(`\n❌ ${msg}`)),
|
|
13
|
+
step: (msg) => console.log(chalk.cyan(`🚀 ${msg}`))
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
async function runCommand(command, args, options = {}) {
|
|
17
|
+
try {
|
|
18
|
+
await execa(command, args, { stdio: 'inherit', ...options });
|
|
19
|
+
} catch (error) {
|
|
20
|
+
log.error(`Erro ao executar: ${command} ${args.join(' ')}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
program
|
|
26
|
+
.name('Tumemo')
|
|
27
|
+
.description('Setup automatizado React + TS + Axios')
|
|
28
|
+
.version('1.0.0')
|
|
29
|
+
.option('-t, --tailwind', 'Instalar Tailwind CSS')
|
|
30
|
+
.option('-s, --shadcn', 'Instalar Tailwind + Shadcn UI')
|
|
31
|
+
.action(async (options) => {
|
|
32
|
+
const root = process.cwd();
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
log.step(`Iniciando Setup Tumemo em: ${root}`);
|
|
36
|
+
|
|
37
|
+
// 1. Vite Base
|
|
38
|
+
await runCommand('npm', ['create', 'vite@latest', '.', '--', '--template', 'react-ts']);
|
|
39
|
+
|
|
40
|
+
// 2. Instalação
|
|
41
|
+
log.info('Baixando dependências...');
|
|
42
|
+
await runCommand('npm', ['install']);
|
|
43
|
+
await runCommand('npm', ['install', '-D', '@types/node']);
|
|
44
|
+
await runCommand('npm', ['install', 'axios', 'react-router-dom', 'tailwind-merge', 'clsx']);
|
|
45
|
+
|
|
46
|
+
// 3. Limpeza
|
|
47
|
+
log.info('Limpando arquivos desnecessários...');
|
|
48
|
+
const toDelete = ['src/assets', 'src/App.css', 'src/index.css'];
|
|
49
|
+
for (const item of toDelete) {
|
|
50
|
+
if (await fs.pathExists(path.join(root, item))) {
|
|
51
|
+
await fs.remove(path.join(root, item));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const useTailwind = options.tailwind || options.shadcn;
|
|
56
|
+
|
|
57
|
+
// 4. Estilos Customizados
|
|
58
|
+
if (useTailwind) {
|
|
59
|
+
log.info('Configurando estrutura Tailwind...');
|
|
60
|
+
await runCommand('npm', ['install', '-D', 'tailwindcss', 'postcss', 'autoprefixer']);
|
|
61
|
+
await runCommand('npx', ['tailwindcss', 'init', '-p']);
|
|
62
|
+
|
|
63
|
+
const tailwindContent = `@tailwind base;\n@tailwind components;\n@tailwind utilities;`;
|
|
64
|
+
await fs.ensureDir(path.join(root, 'src/shared'));
|
|
65
|
+
await fs.writeFile(path.join(root, 'src/shared/tailwind.css'), tailwindContent);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 5. Shadcn Integration
|
|
69
|
+
if (options.shadcn) {
|
|
70
|
+
log.info('Configurando Shadcn UI...');
|
|
71
|
+
await runCommand('npm', ['install', 'lucide-react', 'class-variance-authority']);
|
|
72
|
+
await runCommand('npx', ['shadcn-ui@latest', 'init', '-y']);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 6. Config de Paths (@/)
|
|
76
|
+
const viteConfig = `
|
|
77
|
+
import path from "path"
|
|
78
|
+
import react from "@vitejs/plugin-react"
|
|
79
|
+
import { defineConfig } from "vite"
|
|
80
|
+
|
|
81
|
+
export default defineConfig({
|
|
82
|
+
plugins: [react()],
|
|
83
|
+
resolve: {
|
|
84
|
+
alias: {
|
|
85
|
+
"@": path.resolve(__dirname, "./src"),
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
})`;
|
|
89
|
+
await fs.writeFile(path.join(root, 'vite.config.ts'), viteConfig.trim());
|
|
90
|
+
|
|
91
|
+
const tsConfigPath = path.join(root, 'tsconfig.app.json');
|
|
92
|
+
if (await fs.pathExists(tsConfigPath)) {
|
|
93
|
+
const tsConfig = await fs.readJson(tsConfigPath);
|
|
94
|
+
tsConfig.compilerOptions.baseUrl = ".";
|
|
95
|
+
tsConfig.compilerOptions.paths = { "@/*": ["./src/*"] };
|
|
96
|
+
await fs.writeJson(tsConfigPath, tsConfig, { spaces: 2 });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 7. main.tsx
|
|
100
|
+
const mainContent = `
|
|
101
|
+
import React from 'react'
|
|
102
|
+
import ReactDOM from 'react-dom/client'
|
|
103
|
+
import App from './App.tsx'
|
|
104
|
+
${useTailwind ? "import '@/shared/tailwind.css'" : ""}
|
|
105
|
+
|
|
106
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
107
|
+
<React.StrictMode>
|
|
108
|
+
<App />
|
|
109
|
+
</React.StrictMode>,
|
|
110
|
+
)`;
|
|
111
|
+
await fs.writeFile(path.join(root, 'src/main.tsx'), mainContent.trim());
|
|
112
|
+
|
|
113
|
+
// 8. App.tsx
|
|
114
|
+
const appContent = `
|
|
115
|
+
export default function App() {
|
|
116
|
+
return (
|
|
117
|
+
<div style={{ padding: '2rem', fontFamily: 'sans-serif' }}>
|
|
118
|
+
<h1>Setup Tumemo</h1>
|
|
119
|
+
<p>Desenvolvido com sucesso. React + TS + Axios prontos.</p>
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
124
|
+
await fs.writeFile(path.join(root, 'src/App.tsx'), appContent.trim());
|
|
125
|
+
|
|
126
|
+
// 9. Pastas Selecionadas
|
|
127
|
+
const dirs = ['src/components', 'src/pages'];
|
|
128
|
+
for (const dir of dirs) {
|
|
129
|
+
await fs.ensureDir(path.join(root, dir));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
log.success('Setup Tumemo finalizado! Tudo pronto para codar.');
|
|
133
|
+
} catch (err) {
|
|
134
|
+
log.error(`Erro: ${err.message}`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tumemo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI para automação de projetos React",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"Tumemo": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"axios": "^1.6.0",
|
|
12
|
+
"chalk": "^5.3.0",
|
|
13
|
+
"commander": "^11.1.0",
|
|
14
|
+
"execa": "^8.0.1",
|
|
15
|
+
"fs-extra": "^11.2.0"
|
|
16
|
+
}
|
|
17
|
+
}
|