tumemo 1.0.0 → 1.0.5

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.
Files changed (3) hide show
  1. package/README.md +11 -11
  2. package/index.js +69 -89
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
- # Tumemo CLI 🚀
1
+ # 🚀 Tumemo CLI
2
2
 
3
- Um CLI robusto para automatizar o setup de projetos **React + TypeScript + Vite**, focado em produtividade e limpeza de boilerplate.
3
+ O jeito mais rápido de iniciar seus projetos React com TypeScript, Axios e as melhores ferramentas de estilo.
4
4
 
5
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:** instala o **Axios** por padrão.
12
- - **Organização Sênior:** Cria pastas `components`, `pages`, `hooks` e `lib`.
6
+ - Gera um projeto **Vite (React + TS)** limpo.
7
+ - Remove arquivos desnecessários (`App.css`, `index.css`, ativos de exemplo).
8
+ - Instala automaticamente: **Axios**, **React Router Dom**, **Tailwind Merge** e **Clsx**.
9
+ - Configura Aliases de caminho (`@/` aponta para `src/`).
10
+ - entrega as pastas `src/components`, `src/pages` e `src/shared` criadas.
11
+ - **Inicia o servidor automaticamente** após o setup.
13
12
 
14
13
  ## 🚀 Como usar
15
14
 
16
- ### Via NPX (Sem instalação)
15
+ Acesse a pasta onde deseja criar o projeto e rode:
16
+
17
17
  ```bash
18
- npx tumemo-cli -s
18
+ npx tumemo@latest
package/index.js CHANGED
@@ -6,132 +6,112 @@ import { execa } from 'execa';
6
6
  import fs from 'fs-extra';
7
7
  import path from 'path';
8
8
 
9
+ process.env.FORCE_COLOR = "1";
10
+
9
11
  const log = {
10
12
  info: (msg) => console.log(chalk.blue(`ℹ ${msg}`)),
11
13
  success: (msg) => console.log(chalk.green.bold(`\n✅ ${msg}`)),
12
14
  error: (msg) => console.log(chalk.red.bold(`\n❌ ${msg}`)),
13
- step: (msg) => console.log(chalk.cyan(`🚀 ${msg}`))
15
+ step: (msg) => console.log(chalk.cyan.bold(`\n🚀 ${msg}`))
14
16
  };
15
17
 
16
18
  async function runCommand(command, args, options = {}) {
17
19
  try {
18
- await execa(command, args, { stdio: 'inherit', ...options });
20
+ await execa(command, args, {
21
+ stdio: 'inherit',
22
+ shell: true,
23
+ env: { ...process.env, FORCE_COLOR: "1" },
24
+ ...options
25
+ });
19
26
  } catch (error) {
20
- log.error(`Erro ao executar: ${command} ${args.join(' ')}`);
27
+ log.error(`Erro: ${error.message}`);
21
28
  process.exit(1);
22
29
  }
23
30
  }
24
31
 
25
32
  program
26
33
  .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')
34
+ .description('O setup mais rápido para React + TS')
35
+ .version('1.1.1')
36
+ .option('-t, --tailwind', 'Instalar Tailwind v4')
37
+ .option('-s, --shadcn', 'Instalar Shadcn')
31
38
  .action(async (options) => {
32
39
  const root = process.cwd();
40
+ const projectName = path.basename(root);
33
41
 
34
42
  try {
35
43
  log.step(`Iniciando Setup Tumemo em: ${root}`);
36
44
 
37
- // 1. Vite Base
38
- await runCommand('npm', ['create', 'vite@latest', '.', '--', '--template', 'react-ts']);
45
+ log.info('Baixando template React + TS...');
46
+ await runCommand('npx', ['--yes', 'degit', 'vitejs/vite/packages/create-vite/template-react-ts', '.']);
47
+
48
+ const oldGit = path.join(root, '_gitignore');
49
+ if (fs.existsSync(oldGit)) fs.renameSync(oldGit, path.join(root, '.gitignore'));
50
+
51
+ const pkgPath = path.join(root, 'package.json');
52
+ const pkg = await fs.readJson(pkgPath);
53
+ pkg.name = projectName;
54
+ await fs.writeJson(pkgPath, pkg, { spaces: 2 });
39
55
 
40
- // 2. Instalação
41
- log.info('Baixando dependências...');
56
+ log.info('Instalando dependências base...');
42
57
  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
58
 
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
- }
59
+ log.info('Limpando boilerplate...');
60
+ ['src/assets', 'src/App.css', 'src/index.css', 'public/vite.svg'].forEach(item => {
61
+ const fullPath = path.resolve(root, item);
62
+ if (fs.existsSync(fullPath)) fs.removeSync(fullPath);
63
+ });
64
+
65
+ const htmlPath = path.join(root, 'index.html');
66
+ let htmlContent = fs.readFileSync(htmlPath, 'utf8');
67
+ htmlContent = htmlContent.replace('</head>', ' <style>body { margin: 0; padding: 0; box-sizing: border-box; }</style>\n </head>');
68
+ fs.writeFileSync(htmlPath, htmlContent);
69
+
70
+ await runCommand('npm', ['install', 'axios', 'react-router-dom', 'tailwind-merge', 'clsx']);
71
+ await runCommand('npm', ['install', '-D', '@types/node']);
54
72
 
55
73
  const useTailwind = options.tailwind || options.shadcn;
74
+ const useShadcn = options.shadcn;
56
75
 
57
- // 4. Estilos Customizados
58
76
  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);
77
+ log.info('Configurando Tailwind v4...');
78
+ await runCommand('npm', ['install', 'tailwindcss', '@tailwindcss/vite']);
79
+ fs.ensureDirSync(path.join(root, 'src/shared'));
80
+ fs.writeFileSync(path.join(root, 'src/shared/tailwind.css'), `@import "tailwindcss";`);
66
81
  }
67
82
 
68
- // 5. Shadcn Integration
69
- if (options.shadcn) {
83
+ if (useShadcn) {
70
84
  log.info('Configurando Shadcn UI...');
71
- await runCommand('npm', ['install', 'lucide-react', 'class-variance-authority']);
72
- await runCommand('npx', ['shadcn-ui@latest', 'init', '-y']);
85
+ await runCommand('npx', ['--yes', 'shadcn@latest', 'init', '-y']);
73
86
  }
74
87
 
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
- }
88
+ const viteConfig = `import path from "path"\nimport react from "@vitejs/plugin-react"\nimport { defineConfig } from "vite"\n${useTailwind ? 'import tailwindcss from "@tailwindcss/vite"' : ''}\n\nexport default defineConfig({\n plugins: [react(), ${useTailwind ? 'tailwindcss()' : ''}],\n resolve: { alias: { "@": path.resolve(__dirname, "./src") } },\n})`;
89
+ fs.writeFileSync(path.join(root, 'vite.config.ts'), viteConfig.trim());
98
90
 
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());
91
+ const tsAppPath = path.join(root, 'tsconfig.app.json');
92
+ const fallbackTs = { compilerOptions: { target: "ESNext", lib: ["DOM", "DOM.Iterable", "ESNext"], module: "ESNext", skipLibCheck: true, moduleResolution: "Node", resolveJsonModule: true, isolatedModules: true, noEmit: true, jsx: "react-jsx", strict: true, baseUrl: ".", paths: { "@/*": ["./src/*"] } } };
93
+ fs.writeJsonSync(tsAppPath, fallbackTs, { spaces: 2 });
125
94
 
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
- }
95
+ let techStack = "React + TS";
96
+ if (useShadcn) techStack += " + Shadcn UI";
97
+ else if (useTailwind) techStack += " + Tailwind v4";
98
+
99
+ const appContent = `export default function App() {\n return (\n <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', minHeight: '100vh', width: '100%', fontFamily: 'system-ui, sans-serif', backgroundColor: '#0f172a', color: '#f8fafc', margin: 0 }}>\n <h1 style={{ fontSize: '3.5rem', marginBottom: '0.5rem' }}>Tumemo CLI</h1>\n <p style={{ fontSize: '1.25rem', color: '#94a3b8' }}>Projeto: <strong style={{ color: '#38bdf8' }}>${projectName}</strong></p>\n <div style={{ marginTop: '2.5rem', padding: '1.5rem 3rem', borderRadius: '12px', backgroundColor: '#1e293b', border: '1px solid #334155' }}>\n <p>Stack: <strong>${techStack}</strong></p>\n </div>\n </div>\n )\n}`;
100
+ fs.writeFileSync(path.join(root, 'src/App.tsx'), appContent.trim());
101
+
102
+ const mainContent = `import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport App from './App.tsx'\n${useTailwind ? "import '@/shared/tailwind.css'\n" : ""}ReactDOM.createRoot(document.getElementById('root')!).render(<App />)`;
103
+ fs.writeFileSync(path.join(root, 'src/main.tsx'), mainContent);
104
+
105
+ ['src/components', 'src/pages'].forEach(dir => fs.ensureDirSync(path.join(root, dir)));
106
+
107
+ log.success(`\nTumemo v1.0.5 finalizado!`);
108
+ log.info('Iniciando servidor de desenvolvimento...\n');
109
+
110
+ // COMANDO PARA RODAR O SERVIDOR AUTOMATICAMENTE
111
+ await runCommand('npm', ['run', 'dev']);
131
112
 
132
- log.success('Setup Tumemo finalizado! Tudo pronto para codar.');
133
113
  } catch (err) {
134
- log.error(`Erro: ${err.message}`);
114
+ log.error(`Falha: ${err.message}`);
135
115
  }
136
116
  });
137
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tumemo",
3
- "version": "1.0.0",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "description": "CLI para automação de projetos React",
6
6
  "main": "index.js",