clases 1.1.12 → 1.1.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clases",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -16,6 +16,7 @@
16
16
  },
17
17
  "scripts": {
18
18
  "build": "tsup src/index.ts --format cjs,esm --dts --clean",
19
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch"
19
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
20
+ "postinstall": "node scripts/init.js"
20
21
  }
21
22
  }
@@ -0,0 +1,28 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ // Intentamos encontrar el root del proyecto del usuario
5
+ const projectRoot = process.env.INIT_CWD || path.resolve('../../');
6
+ // Buscamos si existe la carpeta 'src' para ponerlo ahí (mejor para Tailwind/Vite)
7
+ const hasSrc = fs.existsSync(path.join(projectRoot, 'src'));
8
+ const targetDir = hasSrc ? path.join(projectRoot, 'src') : projectRoot;
9
+ const configPath = path.join(targetDir, 'clases.config.ts');
10
+
11
+ const template = `import { createCl } from 'clases';
12
+
13
+ // Instancia base agnóstica
14
+ export const cl = createCl({});
15
+ `;
16
+
17
+ try {
18
+ // Solo lo creamos si no existe para no borrar trabajo del usuario
19
+ if (!fs.existsSync(configPath)) {
20
+ fs.writeFileSync(configPath, template, 'utf8');
21
+ console.log(
22
+ '\x1b[36m%s\x1b[0m',
23
+ ' [clases] Configuración base creada en ' + (hasSrc ? 'src/' : './')
24
+ );
25
+ }
26
+ } catch (err) {
27
+ // Fallo silencioso para no romper la instalación si hay problemas de permisos
28
+ }