clases-tailwind 1.0.2 → 1.0.3
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 +4 -1
- package/src/scripts/init.js +22 -13
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clases-tailwind",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"clases-init": "./scripts/init.js"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"types": "./dist/index.d.ts",
|
package/src/scripts/init.js
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
const fs = require('fs');
|
|
2
3
|
const path = require('path');
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
// Intentamos INIT_CWD (npm/pnpm), si no, el directorio actual
|
|
6
|
+
const projectRoot = process.env.INIT_CWD || process.cwd();
|
|
5
7
|
const hasSrc = fs.existsSync(path.join(projectRoot, 'src'));
|
|
6
8
|
const targetDir = hasSrc ? path.join(projectRoot, 'src') : projectRoot;
|
|
7
9
|
const configPath = path.join(targetDir, 'clases.config.ts');
|
|
8
10
|
|
|
9
|
-
const
|
|
11
|
+
const template = `import { createCl } from 'clases';
|
|
10
12
|
import { tailwindRegistry } from 'clases-tailwind';
|
|
11
13
|
|
|
12
|
-
// Instancia configurada para Tailwind CSS
|
|
13
14
|
export const tw = createCl(tailwindRegistry);
|
|
14
15
|
`;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
17
|
+
function init() {
|
|
18
|
+
if (fs.existsSync(configPath)) {
|
|
19
|
+
// Si el usuario lo corre manualmente con npx, avisamos.
|
|
20
|
+
// Si es postinstall, mejor callar.
|
|
21
|
+
if (!process.env.INIT_CWD) {
|
|
22
|
+
console.log('⚠️ El archivo clases.config.ts ya existe.');
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
fs.writeFileSync(configPath, template, 'utf8');
|
|
29
|
+
console.log('\x1b[32m%s\x1b[0m', '✅ clases.config.ts generado con éxito.');
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error('❌ Error al crear la configuración:', e.message);
|
|
32
|
+
}
|
|
26
33
|
}
|
|
34
|
+
|
|
35
|
+
init();
|