@igreen/design-system 1.0.3 → 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.
- package/package.json +6 -4
- package/postinstall.js +253 -0
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igreen/design-system",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "iGreen Design System - Complete Package",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "iGreen Design System - Complete Package with Auto-Setup",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"postinstall.js"
|
|
9
10
|
],
|
|
10
11
|
"scripts": {
|
|
11
12
|
"build": "tsc",
|
|
12
|
-
"dev": "tsc --watch"
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"postinstall": "node postinstall.js"
|
|
13
15
|
},
|
|
14
16
|
"dependencies": {
|
|
15
17
|
"@igreen/themes": "^1.2.0",
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* iGreen Design System - Postinstall Setup
|
|
5
|
+
*
|
|
6
|
+
* Configura automaticamente o projeto após npm install
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const readline = require('readline');
|
|
12
|
+
|
|
13
|
+
const rl = readline.createInterface({
|
|
14
|
+
input: process.stdin,
|
|
15
|
+
output: process.stdout
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Detectar se está sendo instalado em um projeto (não no próprio igreen)
|
|
19
|
+
const isInstallingInProject = () => {
|
|
20
|
+
const cwd = process.cwd();
|
|
21
|
+
|
|
22
|
+
// Se estamos dentro de node_modules/@igreen/design-system
|
|
23
|
+
if (cwd.includes(path.join('node_modules', '@igreen', 'design-system'))) {
|
|
24
|
+
const projectRoot = path.resolve(cwd, '..', '..', '..');
|
|
25
|
+
|
|
26
|
+
// Verificar se o projeto raiz NÃO é o igreen (verificando se tem packages/)
|
|
27
|
+
const hasPackagesDir = fs.existsSync(path.join(projectRoot, 'packages', 'design-system'));
|
|
28
|
+
|
|
29
|
+
// Se NÃO tem packages/design-system, é um projeto externo
|
|
30
|
+
return !hasPackagesDir;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return false;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getProjectRoot = () => {
|
|
37
|
+
const cwd = process.cwd();
|
|
38
|
+
// Voltar 3 níveis: node_modules/@igreen/design-system -> root
|
|
39
|
+
if (cwd.includes(path.join('node_modules', '@igreen', 'design-system'))) {
|
|
40
|
+
return path.resolve(cwd, '..', '..', '..');
|
|
41
|
+
}
|
|
42
|
+
return cwd;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const question = (query) => new Promise((resolve) => rl.question(query, resolve));
|
|
46
|
+
|
|
47
|
+
async function setupProject() {
|
|
48
|
+
console.log('\n🎨 iGreen Design System Setup\n');
|
|
49
|
+
|
|
50
|
+
// Verificar se está sendo instalado em um projeto
|
|
51
|
+
if (!isInstallingInProject()) {
|
|
52
|
+
console.log('ℹ️ Instalação detectada no próprio repositório iGreen, pulando setup automático.\n');
|
|
53
|
+
rl.close();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const projectRoot = getProjectRoot();
|
|
58
|
+
|
|
59
|
+
// Verificar se já foi configurado antes
|
|
60
|
+
const igreenConfigPath = path.join(projectRoot, '.igreen-configured');
|
|
61
|
+
if (fs.existsSync(igreenConfigPath)) {
|
|
62
|
+
console.log('✅ Projeto já configurado anteriormente.\n');
|
|
63
|
+
console.log('💡 Para reconfigurar, delete o arquivo .igreen-configured e reinstale.\n');
|
|
64
|
+
rl.close();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log('🚀 Vamos configurar seu projeto iGreen!\n');
|
|
69
|
+
|
|
70
|
+
// 1. Perguntar se quer configuração automática
|
|
71
|
+
const autoSetup = await question('Deseja configurar automaticamente? (S/n): ');
|
|
72
|
+
if (autoSetup.toLowerCase() === 'n') {
|
|
73
|
+
console.log('\n📚 Configuração manual: https://github.com/seu-repo/docs\n');
|
|
74
|
+
rl.close();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 2. Escolher tema
|
|
79
|
+
console.log('\n📦 Temas disponíveis:');
|
|
80
|
+
console.log(' 1. igreen (padrão verde)');
|
|
81
|
+
console.log(' 2. solarorange (laranja vibrante)\n');
|
|
82
|
+
|
|
83
|
+
const themeChoice = await question('Escolha o tema (1-2) [1]: ');
|
|
84
|
+
const theme = themeChoice === '2' ? 'solarorange' : 'igreen';
|
|
85
|
+
|
|
86
|
+
// 3. Criar estrutura de pastas
|
|
87
|
+
console.log('\n📁 Criando estrutura de pastas...');
|
|
88
|
+
|
|
89
|
+
const appDir = path.join(projectRoot, 'app');
|
|
90
|
+
const componentsDir = path.join(projectRoot, 'components');
|
|
91
|
+
const libDir = path.join(projectRoot, 'lib');
|
|
92
|
+
|
|
93
|
+
[appDir, componentsDir, libDir].forEach(dir => {
|
|
94
|
+
if (!fs.existsSync(dir)) {
|
|
95
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
96
|
+
console.log(` ✅ ${path.relative(projectRoot, dir)}/`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// 4. Criar globals.css
|
|
101
|
+
console.log('\n🎨 Configurando globals.css...');
|
|
102
|
+
const globalsCss = `@import 'tailwindcss';
|
|
103
|
+
|
|
104
|
+
/* iGreen Design System está configurado! */
|
|
105
|
+
/* O tema ${theme} será carregado automaticamente no layout */
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
fs.writeFileSync(path.join(appDir, 'globals.css'), globalsCss);
|
|
109
|
+
console.log(' ✅ app/globals.css');
|
|
110
|
+
|
|
111
|
+
// 5. Criar layout.tsx
|
|
112
|
+
console.log(' Configurando layout.tsx...');
|
|
113
|
+
const layoutContent = `import '@igreen/themes/${theme}'
|
|
114
|
+
import './globals.css'
|
|
115
|
+
import type { Metadata } from 'next'
|
|
116
|
+
|
|
117
|
+
export const metadata: Metadata = {
|
|
118
|
+
title: 'iGreen App',
|
|
119
|
+
description: 'Created with iGreen Design System',
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default function RootLayout({
|
|
123
|
+
children,
|
|
124
|
+
}: {
|
|
125
|
+
children: React.Node
|
|
126
|
+
}) {
|
|
127
|
+
return (
|
|
128
|
+
<html lang="pt-BR">
|
|
129
|
+
<body>{children}</body>
|
|
130
|
+
</html>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
fs.writeFileSync(path.join(appDir, 'layout.tsx'), layoutContent);
|
|
136
|
+
console.log(' ✅ app/layout.tsx');
|
|
137
|
+
|
|
138
|
+
// 6. Criar page.tsx exemplo
|
|
139
|
+
console.log(' Criando página de exemplo...');
|
|
140
|
+
const pageContent = `import { Button } from '@igreen/button'
|
|
141
|
+
import { Input } from '@igreen/input'
|
|
142
|
+
import { Label } from '@igreen/label'
|
|
143
|
+
|
|
144
|
+
export default function Home() {
|
|
145
|
+
return (
|
|
146
|
+
<main className="min-h-screen p-8">
|
|
147
|
+
<h1 className="text-3xl font-bold mb-8">
|
|
148
|
+
🎨 iGreen Design System
|
|
149
|
+
</h1>
|
|
150
|
+
|
|
151
|
+
<div className="space-y-6 max-w-md">
|
|
152
|
+
<div>
|
|
153
|
+
<Label>Nome</Label>
|
|
154
|
+
<Input placeholder="Digite seu nome" />
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<div>
|
|
158
|
+
<Label>Email</Label>
|
|
159
|
+
<Input type="email" placeholder="seu@email.com" />
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<Button>Enviar</Button>
|
|
163
|
+
</div>
|
|
164
|
+
</main>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
fs.writeFileSync(path.join(appDir, 'page.tsx'), pageContent);
|
|
170
|
+
console.log(' ✅ app/page.tsx');
|
|
171
|
+
|
|
172
|
+
// 7. Criar lib/utils.ts
|
|
173
|
+
console.log(' Configurando utilitários...');
|
|
174
|
+
const utilsContent = `export { cn } from '@igreen/utils'
|
|
175
|
+
`;
|
|
176
|
+
|
|
177
|
+
fs.writeFileSync(path.join(libDir, 'utils.ts'), utilsContent);
|
|
178
|
+
console.log(' ✅ lib/utils.ts');
|
|
179
|
+
|
|
180
|
+
// 8. Verificar/Criar postcss.config.mjs
|
|
181
|
+
console.log('\n⚙️ Configurando PostCSS...');
|
|
182
|
+
const postcssConfig = path.join(projectRoot, 'postcss.config.mjs');
|
|
183
|
+
if (!fs.existsSync(postcssConfig)) {
|
|
184
|
+
const postcssContent = `export default {
|
|
185
|
+
plugins: {
|
|
186
|
+
'@tailwindcss/postcss': {},
|
|
187
|
+
},
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
190
|
+
fs.writeFileSync(postcssConfig, postcssContent);
|
|
191
|
+
console.log(' ✅ postcss.config.mjs');
|
|
192
|
+
} else {
|
|
193
|
+
console.log(' ⏭️ postcss.config.mjs já existe');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 9. Atualizar package.json scripts (se possível)
|
|
197
|
+
console.log('\n📦 Verificando scripts...');
|
|
198
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
199
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
200
|
+
try {
|
|
201
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
202
|
+
|
|
203
|
+
if (!packageJson.scripts) {
|
|
204
|
+
packageJson.scripts = {};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (!packageJson.scripts.dev) {
|
|
208
|
+
packageJson.scripts.dev = 'next dev';
|
|
209
|
+
packageJson.scripts.build = 'next build';
|
|
210
|
+
packageJson.scripts.start = 'next start';
|
|
211
|
+
|
|
212
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
213
|
+
console.log(' ✅ Scripts adicionados ao package.json');
|
|
214
|
+
}
|
|
215
|
+
} catch (e) {
|
|
216
|
+
console.log(' ⚠️ Não foi possível atualizar package.json automaticamente');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 10. Marcar como configurado
|
|
221
|
+
fs.writeFileSync(igreenConfigPath, `Configured at: ${new Date().toISOString()}\nTheme: ${theme}\n`);
|
|
222
|
+
|
|
223
|
+
// 11. Mostrar próximos passos
|
|
224
|
+
console.log('\n' + '='.repeat(60));
|
|
225
|
+
console.log('🎉 Projeto configurado com sucesso!');
|
|
226
|
+
console.log('='.repeat(60));
|
|
227
|
+
console.log(`\n📦 Tema instalado: ${theme}`);
|
|
228
|
+
console.log('\n📝 Próximos passos:\n');
|
|
229
|
+
console.log(' 1. Instale as dependências do Next.js:');
|
|
230
|
+
console.log(' npm install next@latest react@latest react-dom@latest');
|
|
231
|
+
console.log('');
|
|
232
|
+
console.log(' 2. Instale o Tailwind CSS v4:');
|
|
233
|
+
console.log(' npm install tailwindcss@next @tailwindcss/postcss@next');
|
|
234
|
+
console.log('');
|
|
235
|
+
console.log(' 3. Inicie o servidor de desenvolvimento:');
|
|
236
|
+
console.log(' npm run dev');
|
|
237
|
+
console.log('');
|
|
238
|
+
console.log(' 4. Abra http://localhost:3000\n');
|
|
239
|
+
console.log('📚 Documentação: https://github.com/seu-repo/docs');
|
|
240
|
+
console.log('💚 Componentes disponíveis:');
|
|
241
|
+
console.log(' - Button, Input, Label, Checkbox, ExampleCard\n');
|
|
242
|
+
console.log('='.repeat(60) + '\n');
|
|
243
|
+
|
|
244
|
+
rl.close();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Executar setup
|
|
248
|
+
setupProject().catch(error => {
|
|
249
|
+
console.error('\n❌ Erro durante configuração:', error.message);
|
|
250
|
+
console.log('\n📚 Para configuração manual: https://github.com/seu-repo/docs\n');
|
|
251
|
+
rl.close();
|
|
252
|
+
process.exit(0); // Não falhar a instalação
|
|
253
|
+
});
|