tumemo 1.0.0 → 1.0.1
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/index.js +29 -17
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -6,16 +6,24 @@ import { execa } from 'execa';
|
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
|
|
9
|
+
// Força o Chalk a usar cores mesmo em sub-processos
|
|
10
|
+
process.env.FORCE_COLOR = "1";
|
|
11
|
+
|
|
9
12
|
const log = {
|
|
10
13
|
info: (msg) => console.log(chalk.blue(`ℹ ${msg}`)),
|
|
11
14
|
success: (msg) => console.log(chalk.green.bold(`\n✅ ${msg}`)),
|
|
12
15
|
error: (msg) => console.log(chalk.red.bold(`\n❌ ${msg}`)),
|
|
13
|
-
step: (msg) => console.log(chalk.cyan(
|
|
16
|
+
step: (msg) => console.log(chalk.cyan.bold(`\n🚀 ${msg}`))
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
async function runCommand(command, args, options = {}) {
|
|
17
20
|
try {
|
|
18
|
-
|
|
21
|
+
// Adicionado env para forçar cores nos comandos do NPM/Vite
|
|
22
|
+
await execa(command, args, {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
env: { ...process.env, FORCE_COLOR: "1" },
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
19
27
|
} catch (error) {
|
|
20
28
|
log.error(`Erro ao executar: ${command} ${args.join(' ')}`);
|
|
21
29
|
process.exit(1);
|
|
@@ -25,7 +33,7 @@ async function runCommand(command, args, options = {}) {
|
|
|
25
33
|
program
|
|
26
34
|
.name('Tumemo')
|
|
27
35
|
.description('Setup automatizado React + TS + Axios')
|
|
28
|
-
.version('1.0.
|
|
36
|
+
.version('1.0.2')
|
|
29
37
|
.option('-t, --tailwind', 'Instalar Tailwind CSS')
|
|
30
38
|
.option('-s, --shadcn', 'Instalar Tailwind + Shadcn UI')
|
|
31
39
|
.action(async (options) => {
|
|
@@ -34,27 +42,31 @@ program
|
|
|
34
42
|
try {
|
|
35
43
|
log.step(`Iniciando Setup Tumemo em: ${root}`);
|
|
36
44
|
|
|
37
|
-
// 1. Vite Base
|
|
38
|
-
|
|
45
|
+
// 1. Vite Base (Adicionado --yes para evitar menus interativos)
|
|
46
|
+
log.info('Criando base Vite...');
|
|
47
|
+
await runCommand('npm', ['create', 'vite@latest', '.', '--yes', '--', '--template', 'react-ts']);
|
|
39
48
|
|
|
40
|
-
// 2. Instalação
|
|
41
|
-
log.info('Baixando dependências...');
|
|
49
|
+
// 2. Instalação (npm install puro primeiro)
|
|
50
|
+
log.info('Baixando dependências base...');
|
|
42
51
|
await runCommand('npm', ['install']);
|
|
43
|
-
|
|
52
|
+
|
|
53
|
+
log.info('Instalando bibliotecas auxiliares (Axios, Router, etc)...');
|
|
44
54
|
await runCommand('npm', ['install', 'axios', 'react-router-dom', 'tailwind-merge', 'clsx']);
|
|
55
|
+
await runCommand('npm', ['install', '-D', '@types/node']);
|
|
45
56
|
|
|
46
|
-
// 3. Limpeza
|
|
47
|
-
log.info('Limpando
|
|
57
|
+
// 3. Limpeza Radical
|
|
58
|
+
log.info('Limpando boilerplate...');
|
|
48
59
|
const toDelete = ['src/assets', 'src/App.css', 'src/index.css'];
|
|
49
60
|
for (const item of toDelete) {
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
const fullPath = path.join(root, item);
|
|
62
|
+
if (await fs.pathExists(fullPath)) {
|
|
63
|
+
await fs.remove(fullPath);
|
|
52
64
|
}
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
const useTailwind = options.tailwind || options.shadcn;
|
|
56
68
|
|
|
57
|
-
// 4.
|
|
69
|
+
// 4. Configuração Tailwind
|
|
58
70
|
if (useTailwind) {
|
|
59
71
|
log.info('Configurando estrutura Tailwind...');
|
|
60
72
|
await runCommand('npm', ['install', '-D', 'tailwindcss', 'postcss', 'autoprefixer']);
|
|
@@ -96,7 +108,7 @@ export default defineConfig({
|
|
|
96
108
|
await fs.writeJson(tsConfigPath, tsConfig, { spaces: 2 });
|
|
97
109
|
}
|
|
98
110
|
|
|
99
|
-
// 7. main.tsx
|
|
111
|
+
// 7. main.tsx (Ajustado para importar o CSS apenas se usar Tailwind)
|
|
100
112
|
const mainContent = `
|
|
101
113
|
import React from 'react'
|
|
102
114
|
import ReactDOM from 'react-dom/client'
|
|
@@ -116,7 +128,7 @@ export default function App() {
|
|
|
116
128
|
return (
|
|
117
129
|
<div style={{ padding: '2rem', fontFamily: 'sans-serif' }}>
|
|
118
130
|
<h1>Setup Tumemo</h1>
|
|
119
|
-
<p>
|
|
131
|
+
<p>Projeto pronto. React + TS + Axios configurados.</p>
|
|
120
132
|
</div>
|
|
121
133
|
)
|
|
122
134
|
}
|
|
@@ -129,9 +141,9 @@ export default function App() {
|
|
|
129
141
|
await fs.ensureDir(path.join(root, dir));
|
|
130
142
|
}
|
|
131
143
|
|
|
132
|
-
log.success('Setup Tumemo finalizado!
|
|
144
|
+
log.success('Setup Tumemo finalizado! Bom trabalho.');
|
|
133
145
|
} catch (err) {
|
|
134
|
-
log.error(`Erro: ${err.message}`);
|
|
146
|
+
log.error(`Erro crítico: ${err.message}`);
|
|
135
147
|
}
|
|
136
148
|
});
|
|
137
149
|
|