@dropi/ui 0.1.35 → 0.1.37

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 (2) hide show
  1. package/package.json +3 -2
  2. package/scripts/setup.js +67 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dropi/ui",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "Dropi Design System — Web Components for Angular, React and Vue",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -33,7 +33,8 @@
33
33
  "import": "./hydrate/index.mjs",
34
34
  "require": "./hydrate/index.js",
35
35
  "types": "./hydrate/index.d.ts"
36
- }
36
+ },
37
+ "./package.json": "./package.json"
37
38
  },
38
39
  "files": [
39
40
  "dist/",
package/scripts/setup.js CHANGED
@@ -74,7 +74,8 @@ async function run() {
74
74
  const p = path.join(projectRoot, f);
75
75
  if (!fs.existsSync(p)) return false;
76
76
  const c = fs.readFileSync(p, 'utf8');
77
- return c.includes('output') && c.includes('export');
77
+ // Detectar solo output: 'export' o output: "export" (no standalone ni otros)
78
+ return /output\s*:\s*["']export["']/.test(c);
78
79
  });
79
80
  const hasAppRouter = fs.existsSync(path.join(projectRoot, 'app')) || fs.existsSync(path.join(projectRoot, 'src', 'app'));
80
81
  const hasPagesRouter = fs.existsSync(path.join(projectRoot, 'pages')) || fs.existsSync(path.join(projectRoot, 'src', 'pages'));
@@ -368,60 +369,81 @@ dropi-icon:not(.hydrated) {
368
369
  // Resolver ruta real de @dropi/ui (compatible con npm, Yarn Berry, monorepos)
369
370
  let dropiUiRoot;
370
371
  try {
371
- // Intento 1: require.resolve desde projectRoot
372
- dropiUiRoot = path.dirname(require.resolve('@dropi/ui/package.json', { paths: [projectRoot] }));
373
- } catch (e1) {
374
- try {
375
- // Intento 2: ejecutar node en contexto del proyecto (útil en Yarn Berry PnP)
376
- const resolved = execSync(
377
- `node -e "console.log(require.resolve('@dropi/ui/package.json'))"`,
378
- { cwd: projectRoot, encoding: 'utf8' }
379
- ).trim();
380
- dropiUiRoot = path.dirname(resolved);
381
- } catch (e2) {
382
- // Intento 3: buscar en árbol de directorios (monorepos con hoisting)
383
- let dir = projectRoot;
384
- while (dir !== path.dirname(dir)) {
385
- const candidate = path.join(dir, 'node_modules', '@dropi', 'ui');
386
- if (fs.existsSync(path.join(candidate, 'package.json'))) {
387
- dropiUiRoot = candidate;
388
- break;
389
- }
390
- dir = path.dirname(dir);
372
+ // Intento 1: resolver desde la exportación principal y subir al root del paquete
373
+ // (evita ERR_PACKAGE_PATH_NOT_EXPORTED que ocurre al resolver './package.json')
374
+ const mainFile = require.resolve('@dropi/ui', { paths: [projectRoot] });
375
+ let dir = path.dirname(mainFile);
376
+ while (dir !== path.dirname(dir)) {
377
+ const pkgPath = path.join(dir, 'package.json');
378
+ if (fs.existsSync(pkgPath)) {
379
+ try {
380
+ if (JSON.parse(fs.readFileSync(pkgPath, 'utf8')).name === '@dropi/ui') {
381
+ dropiUiRoot = dir;
382
+ break;
383
+ }
384
+ } catch (_) {}
391
385
  }
392
- // Fallback convencional
393
- if (!dropiUiRoot) dropiUiRoot = path.join(projectRoot, 'node_modules', '@dropi', 'ui');
386
+ dir = path.dirname(dir);
387
+ }
388
+ } catch (e1) {}
389
+
390
+ if (!dropiUiRoot) {
391
+ // Intento 2: buscar en árbol de directorios (monorepos con hoisting)
392
+ let dir = projectRoot;
393
+ while (dir !== path.dirname(dir)) {
394
+ const candidate = path.join(dir, 'node_modules', '@dropi', 'ui');
395
+ if (fs.existsSync(path.join(candidate, 'package.json'))) {
396
+ dropiUiRoot = candidate;
397
+ break;
398
+ }
399
+ dir = path.dirname(dir);
394
400
  }
395
401
  }
396
402
 
403
+ // Fallback convencional
404
+ if (!dropiUiRoot) dropiUiRoot = path.join(projectRoot, 'node_modules', '@dropi', 'ui');
405
+
397
406
  const setupAsset = (srcRelativePath, destRelativePath) => {
398
407
  const src = path.join(dropiUiRoot, srcRelativePath);
399
408
  const dest = path.join(projectRoot, publicDir, destRelativePath);
400
409
  const destDir = path.dirname(dest);
401
410
 
402
- if (fs.existsSync(src)) {
403
- if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true });
404
- try {
405
- if (fs.existsSync(dest)) {
406
- if (fs.lstatSync(dest).isSymbolicLink() || fs.existsSync(dest)) fs.unlinkSync(dest);
407
- }
408
- fs.symlinkSync(src, dest, fs.lstatSync(src).isDirectory() ? 'dir' : 'file');
409
- log(`Assets configurados: ${destRelativePath} (Symlink ✅)`, 'ok');
410
- } catch (e) {
411
- // Fallback a copia recursiva
412
- try {
413
- if (fs.lstatSync(src).isDirectory()) {
414
- fs.cpSync ? fs.cpSync(src, dest, { recursive: true }) : execSync(`cp -R "${src}" "${dest}"`);
415
- } else {
416
- fs.copyFileSync(src, dest);
417
- }
418
- log(`Assets copiados: ${destRelativePath} (Copia ✅)`, 'ok');
419
- } catch (copyErr) {
420
- log(`Assets no encontrados: ${destRelativePath}. Cópialos manualmente desde node_modules/@dropi/ui/${srcRelativePath}`, 'warn');
421
- }
411
+ if (!fs.existsSync(src)) {
412
+ log(`Assets no encontrados: ${srcRelativePath}. Verifica que @dropi/ui esté instalado.`, 'warn');
413
+ return;
414
+ }
415
+
416
+ if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true });
417
+
418
+ // Limpiar dest con lstatSync — detecta symlinks rotos que existsSync ignora
419
+ try {
420
+ const stat = fs.lstatSync(dest);
421
+ if (stat.isDirectory() && !stat.isSymbolicLink()) {
422
+ fs.rmSync(dest, { recursive: true, force: true });
423
+ } else {
424
+ fs.unlinkSync(dest); // funciona para symlinks, broken symlinks y archivos
422
425
  }
423
- } else {
424
- log(`Assets no encontrados en node_modules: ${srcRelativePath}. Verifica que @dropi/ui esté instalado correctamente.`, 'warn');
426
+ } catch (_) {
427
+ // dest no existe, todo bien
428
+ }
429
+
430
+ // Intentar symlink primero
431
+ try {
432
+ fs.symlinkSync(src, dest, fs.lstatSync(src).isDirectory() ? 'dir' : 'file');
433
+ log(`Assets configurados: ${destRelativePath} (Symlink ✅)`, 'ok');
434
+ return;
435
+ } catch (_) {}
436
+
437
+ // Fallback: copia directa
438
+ try {
439
+ if (fs.lstatSync(src).isDirectory()) {
440
+ fs.cpSync ? fs.cpSync(src, dest, { recursive: true }) : execSync(`cp -R "${src}" "${dest}"`);
441
+ } else {
442
+ fs.copyFileSync(src, dest);
443
+ }
444
+ log(`Assets copiados: ${destRelativePath} (Copia ✅)`, 'ok');
445
+ } catch (copyErr) {
446
+ log(`Error al copiar ${destRelativePath}: ${copyErr.message}`, 'warn');
425
447
  }
426
448
  };
427
449