responsive-system 1.7.7 → 1.7.8

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": "responsive-system",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "Sistema de layout responsivo con auto-scaling para Tailwind CSS",
5
5
  "type": "module",
6
6
  "main": "./dist/responsive-system.cjs",
@@ -11,7 +11,7 @@
11
11
  * - Configura App.tsx con el layout seleccionado
12
12
  */
13
13
 
14
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs'
14
+ import * as fs from 'fs'
15
15
  import path from 'path'
16
16
  import { execSync } from 'child_process'
17
17
  import { fileURLToPath } from 'url'
@@ -57,14 +57,14 @@ console.log(` Directorio: ${projectRoot}`)
57
57
  console.log('')
58
58
 
59
59
  // Verificar si package.json existe
60
- if (!existsSync(packageJsonPath)) {
60
+ if (!fs.existsSync(packageJsonPath)) {
61
61
  console.log('⚠️ No se encontró package.json, saltando configuración')
62
62
  process.exit(0)
63
63
  }
64
64
 
65
65
  let packageJson
66
66
  try {
67
- packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
67
+ packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
68
68
  } catch (error) {
69
69
  console.error('❌ Error al leer package.json:', error.message)
70
70
  process.exit(1)
@@ -133,18 +133,18 @@ function copyFileFromPackage(relativePath, targetPath, isComponent = false) {
133
133
  const sourcePath = path.join(__dirname, '..', relativePath)
134
134
  const destPath = path.join(projectRoot, targetPath)
135
135
 
136
- if (!existsSync(sourcePath)) {
136
+ if (!fs.existsSync(sourcePath)) {
137
137
  console.error(` ❌ No se encontró: ${relativePath}`)
138
138
  return false
139
139
  }
140
140
 
141
141
  // Crear directorio destino si no existe
142
142
  const destDir = path.dirname(destPath)
143
- if (!existsSync(destDir)) {
144
- mkdirSync(destDir, { recursive: true })
143
+ if (!fs.existsSync(destDir)) {
144
+ fs.mkdirSync(destDir, { recursive: true })
145
145
  }
146
146
 
147
- let content = readFileSync(sourcePath, 'utf8')
147
+ let content = fs.readFileSync(sourcePath, 'utf8')
148
148
 
149
149
  // Si es un componente, reemplazar importaciones relativas por importaciones del paquete
150
150
  if (isComponent) {
@@ -165,7 +165,7 @@ function copyFileFromPackage(relativePath, targetPath, isComponent = false) {
165
165
  )
166
166
  }
167
167
 
168
- writeFileSync(destPath, content)
168
+ fs.writeFileSync(destPath, content)
169
169
  return true
170
170
  }
171
171
 
@@ -174,8 +174,8 @@ function generateLayoutComponents(selectedLayout) {
174
174
  const componentsDir = path.join(projectRoot, 'src', 'components', 'layout')
175
175
 
176
176
  // Crear directorio si no existe
177
- if (!existsSync(componentsDir)) {
178
- mkdirSync(componentsDir, { recursive: true })
177
+ if (!fs.existsSync(componentsDir)) {
178
+ fs.mkdirSync(componentsDir, { recursive: true })
179
179
  }
180
180
 
181
181
  const componentsToGenerate = {
@@ -231,7 +231,7 @@ const Navigation = () => {
231
231
 
232
232
  export default Navigation
233
233
  `
234
- writeFileSync(path.join(componentsDir, 'Navigation.tsx'), navigationContent)
234
+ fs.writeFileSync(path.join(componentsDir, 'Navigation.tsx'), navigationContent)
235
235
  console.log(' ✅ Navigation.tsx')
236
236
  }
237
237
 
@@ -253,7 +253,7 @@ export default Navigation
253
253
 
254
254
  export default Footer
255
255
  `
256
- writeFileSync(path.join(componentsDir, 'Footer.tsx'), footerContent)
256
+ fs.writeFileSync(path.join(componentsDir, 'Footer.tsx'), footerContent)
257
257
  console.log(' ✅ Footer.tsx')
258
258
  }
259
259
 
@@ -366,13 +366,13 @@ const Sidebar = ({ showLogo = true }: SidebarProps) => {
366
366
 
367
367
  export default Sidebar
368
368
  `
369
- writeFileSync(path.join(componentsDir, 'Sidebar.tsx'), sidebarContent)
369
+ fs.writeFileSync(path.join(componentsDir, 'Sidebar.tsx'), sidebarContent)
370
370
  console.log(' ✅ Sidebar.tsx')
371
371
  }
372
372
 
373
373
  // Crear index.ts para exportar los componentes
374
374
  const indexContent = components.map(c => `export { default as ${c} } from './${c}'`).join('\n')
375
- writeFileSync(path.join(componentsDir, 'index.ts'), indexContent)
375
+ fs.writeFileSync(path.join(componentsDir, 'index.ts'), indexContent)
376
376
  console.log(' ✅ index.ts')
377
377
  }
378
378
 
@@ -382,22 +382,22 @@ function copyUseResponsiveHook() {
382
382
 
383
383
  // Crear directorio hooks
384
384
  const hooksDir = path.join(projectRoot, 'src', 'hooks')
385
- if (!existsSync(hooksDir)) {
386
- mkdirSync(hooksDir, { recursive: true })
385
+ if (!fs.existsSync(hooksDir)) {
386
+ fs.mkdirSync(hooksDir, { recursive: true })
387
387
  }
388
388
 
389
389
  // Copiar tipos
390
390
  const typesDir = path.join(projectRoot, 'src', 'types')
391
- if (!existsSync(typesDir)) {
392
- mkdirSync(typesDir, { recursive: true })
391
+ if (!fs.existsSync(typesDir)) {
392
+ fs.mkdirSync(typesDir, { recursive: true })
393
393
  }
394
394
  copyFileFromPackage('src/types/responsive.ts', 'src/types/responsive.ts')
395
395
  console.log(' ✅ types/responsive.ts')
396
396
 
397
397
  // Copiar constantes
398
398
  const constantsDir = path.join(projectRoot, 'src', 'constants')
399
- if (!existsSync(constantsDir)) {
400
- mkdirSync(constantsDir, { recursive: true })
399
+ if (!fs.existsSync(constantsDir)) {
400
+ fs.mkdirSync(constantsDir, { recursive: true })
401
401
  }
402
402
  copyFileFromPackage('src/constants/breakpoints.ts', 'src/constants/breakpoints.ts')
403
403
  console.log(' ✅ constants/breakpoints.ts')
@@ -411,7 +411,7 @@ function copyUseResponsiveHook() {
411
411
  export type { ResponsiveState, Breakpoint, Orientation } from '../types/responsive'
412
412
  export { DEFAULT_BREAKPOINTS, getCurrentBreakpoint, getBreakpointIndex, getBreakpointValue } from '../constants/breakpoints'
413
413
  `
414
- writeFileSync(path.join(hooksDir, 'index.ts'), indexContent)
414
+ fs.writeFileSync(path.join(hooksDir, 'index.ts'), indexContent)
415
415
  console.log(' ✅ hooks/index.ts')
416
416
  }
417
417
 
@@ -476,7 +476,7 @@ if (!packageJson.type) {
476
476
  if (needsUpdate) {
477
477
  console.log('')
478
478
  console.log('📝 Actualizando package.json...')
479
- writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
479
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
480
480
  console.log('✅ package.json actualizado')
481
481
  console.log('')
482
482
  console.log('⚠️ Ejecuta "npm install" para instalar las dependencias')
@@ -487,7 +487,7 @@ if (needsUpdate) {
487
487
  // Verificar si el proyecto ya está configurado
488
488
  const mainTsxPath = path.join(projectRoot, 'src', 'main.tsx')
489
489
  const layoutsDir = path.join(projectRoot, 'src', 'layouts')
490
- const isAlreadyConfigured = existsSync(mainTsxPath) && existsSync(layoutsDir) && existsSync(path.join(projectRoot, 'vite.config.ts'))
490
+ const isAlreadyConfigured = fs.existsSync(mainTsxPath) && fs.existsSync(layoutsDir) && fs.existsSync(path.join(projectRoot, 'vite.config.ts'))
491
491
 
492
492
  // Función async para manejar la configuración del proyecto
493
493
  (async () => {
@@ -538,8 +538,8 @@ const isAlreadyConfigured = existsSync(mainTsxPath) && existsSync(layoutsDir) &&
538
538
  const dirs = ['src', 'src/components', 'src/components/layout', 'src/pages', 'src/hooks', 'src/types', 'src/constants', 'public']
539
539
  dirs.forEach(dir => {
540
540
  const dirPath = path.join(projectRoot, dir)
541
- if (!existsSync(dirPath)) {
542
- mkdirSync(dirPath, { recursive: true })
541
+ if (!fs.existsSync(dirPath)) {
542
+ fs.mkdirSync(dirPath, { recursive: true })
543
543
  }
544
544
  })
545
545
 
@@ -553,7 +553,7 @@ const isAlreadyConfigured = existsSync(mainTsxPath) && existsSync(layoutsDir) &&
553
553
 
554
554
  // Crear vite.config.ts
555
555
  const viteConfigPath = path.join(projectRoot, 'vite.config.ts')
556
- if (!existsSync(viteConfigPath)) {
556
+ if (!fs.existsSync(viteConfigPath)) {
557
557
  const viteConfig = `import { defineConfig } from 'vite'
558
558
  import react from '@vitejs/plugin-react'
559
559
 
@@ -561,13 +561,13 @@ export default defineConfig({
561
561
  plugins: [react()],
562
562
  })
563
563
  `
564
- writeFileSync(viteConfigPath, viteConfig)
564
+ fs.writeFileSync(viteConfigPath, viteConfig)
565
565
  console.log(' ✅ Creado: vite.config.ts')
566
566
  }
567
567
 
568
568
  // Crear tailwind.config.js
569
569
  const tailwindConfigPath = path.join(projectRoot, 'tailwind.config.js')
570
- if (!existsSync(tailwindConfigPath)) {
570
+ if (!fs.existsSync(tailwindConfigPath)) {
571
571
  const tailwindConfig = `import responsiveScalePlugin from 'responsive-system/plugin'
572
572
 
573
573
  export default {
@@ -603,13 +603,13 @@ export default {
603
603
  ],
604
604
  }
605
605
  `
606
- writeFileSync(tailwindConfigPath, tailwindConfig)
606
+ fs.writeFileSync(tailwindConfigPath, tailwindConfig)
607
607
  console.log(' ✅ Creado: tailwind.config.js')
608
608
  }
609
609
 
610
610
  // Crear postcss.config.js
611
611
  const postcssConfigPath = path.join(projectRoot, 'postcss.config.js')
612
- if (!existsSync(postcssConfigPath)) {
612
+ if (!fs.existsSync(postcssConfigPath)) {
613
613
  const postcssConfig = `export default {
614
614
  plugins: {
615
615
  '@tailwindcss/postcss': {},
@@ -617,13 +617,13 @@ export default {
617
617
  },
618
618
  }
619
619
  `
620
- writeFileSync(postcssConfigPath, postcssConfig)
620
+ fs.writeFileSync(postcssConfigPath, postcssConfig)
621
621
  console.log(' ✅ Creado: postcss.config.js')
622
622
  }
623
623
 
624
624
  // Crear tsconfig.json
625
625
  const tsconfigPath = path.join(projectRoot, 'tsconfig.json')
626
- if (!existsSync(tsconfigPath)) {
626
+ if (!fs.existsSync(tsconfigPath)) {
627
627
  const tsconfig = `{
628
628
  "compilerOptions": {
629
629
  "target": "ES2020",
@@ -646,13 +646,13 @@ export default {
646
646
  "references": [{ "path": "./tsconfig.node.json" }]
647
647
  }
648
648
  `
649
- writeFileSync(tsconfigPath, tsconfig)
649
+ fs.writeFileSync(tsconfigPath, tsconfig)
650
650
  console.log(' ✅ Creado: tsconfig.json')
651
651
  }
652
652
 
653
653
  // Crear tsconfig.node.json
654
654
  const tsconfigNodePath = path.join(projectRoot, 'tsconfig.node.json')
655
- if (!existsSync(tsconfigNodePath)) {
655
+ if (!fs.existsSync(tsconfigNodePath)) {
656
656
  const tsconfigNode = `{
657
657
  "compilerOptions": {
658
658
  "composite": true,
@@ -664,13 +664,13 @@ export default {
664
664
  "include": ["vite.config.ts"]
665
665
  }
666
666
  `
667
- writeFileSync(tsconfigNodePath, tsconfigNode)
667
+ fs.writeFileSync(tsconfigNodePath, tsconfigNode)
668
668
  console.log(' ✅ Creado: tsconfig.node.json')
669
669
  }
670
670
 
671
671
  // Crear index.html
672
672
  const indexHtmlPath = path.join(projectRoot, 'index.html')
673
- if (!existsSync(indexHtmlPath)) {
673
+ if (!fs.existsSync(indexHtmlPath)) {
674
674
  const indexHtml = `<!doctype html>
675
675
  <html lang="es">
676
676
  <head>
@@ -685,14 +685,14 @@ export default {
685
685
  </body>
686
686
  </html>
687
687
  `
688
- writeFileSync(indexHtmlPath, indexHtml)
688
+ fs.writeFileSync(indexHtmlPath, indexHtml)
689
689
  console.log(' ✅ Creado: index.html')
690
690
  }
691
691
 
692
692
  // Crear layout local según el seleccionado
693
693
  const layoutsDir = path.join(projectRoot, 'src', 'layouts')
694
- if (!existsSync(layoutsDir)) {
695
- mkdirSync(layoutsDir, { recursive: true })
694
+ if (!fs.existsSync(layoutsDir)) {
695
+ fs.mkdirSync(layoutsDir, { recursive: true })
696
696
  }
697
697
 
698
698
  // Generar layout local que use los componentes locales
@@ -807,12 +807,12 @@ export default MinimalLayout
807
807
  }
808
808
 
809
809
  const layoutPath = path.join(layoutsDir, `${selectedLayout.charAt(0).toUpperCase() + selectedLayout.slice(1)}Layout.tsx`)
810
- writeFileSync(layoutPath, layoutContent)
810
+ fs.writeFileSync(layoutPath, layoutContent)
811
811
  console.log(` ✅ Creado: src/layouts/${path.basename(layoutPath)}`)
812
812
 
813
813
  // Crear src/main.tsx que use el layout local
814
814
  const mainTsxPath = path.join(projectRoot, 'src', 'main.tsx')
815
- if (!existsSync(mainTsxPath)) {
815
+ if (!fs.existsSync(mainTsxPath)) {
816
816
  const layoutName = selectedLayout.charAt(0).toUpperCase() + selectedLayout.slice(1) + 'Layout'
817
817
  const mainTsx = `import React from 'react'
818
818
  import ReactDOM from 'react-dom/client'
@@ -831,22 +831,22 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
831
831
  </React.StrictMode>,
832
832
  )
833
833
  `
834
- writeFileSync(mainTsxPath, mainTsx)
834
+ fs.writeFileSync(mainTsxPath, mainTsx)
835
835
  console.log(' ✅ Creado: src/main.tsx')
836
836
  }
837
837
 
838
838
  // Crear src/index.css
839
839
  const indexCssPath = path.join(projectRoot, 'src', 'index.css')
840
- if (!existsSync(indexCssPath)) {
840
+ if (!fs.existsSync(indexCssPath)) {
841
841
  const indexCss = `@import "tailwindcss";
842
842
  `
843
- writeFileSync(indexCssPath, indexCss)
843
+ fs.writeFileSync(indexCssPath, indexCss)
844
844
  console.log(' ✅ Creado: src/index.css')
845
845
  }
846
846
 
847
847
  // Crear src/pages/HomePage.tsx con página de ejemplo simple
848
848
  const homePagePath = path.join(projectRoot, 'src', 'pages', 'HomePage.tsx')
849
- if (!existsSync(homePagePath)) {
849
+ if (!fs.existsSync(homePagePath)) {
850
850
  const homePage = `import { useResponsiveLayout } from 'responsive-system'
851
851
  import { useResponsive } from '../hooks'
852
852
 
@@ -926,13 +926,13 @@ function HomePage() {
926
926
 
927
927
  export default HomePage
928
928
  `
929
- writeFileSync(homePagePath, homePage)
929
+ fs.writeFileSync(homePagePath, homePage)
930
930
  console.log(' ✅ Creado: src/pages/HomePage.tsx (página de ejemplo simple)')
931
931
  }
932
932
 
933
933
  // Crear src/App.tsx que importa la página
934
934
  const appTsxPath = path.join(projectRoot, 'src', 'App.tsx')
935
- if (!existsSync(appTsxPath)) {
935
+ if (!fs.existsSync(appTsxPath)) {
936
936
  const appTsx = `import HomePage from './pages/HomePage'
937
937
 
938
938
  function App() {
@@ -941,7 +941,7 @@ function App() {
941
941
 
942
942
  export default App
943
943
  `
944
- writeFileSync(appTsxPath, appTsx)
944
+ fs.writeFileSync(appTsxPath, appTsx)
945
945
  console.log(' ✅ Creado: src/App.tsx')
946
946
  }
947
947
 
@@ -959,7 +959,7 @@ export default App
959
959
  packageJson.scripts.preview = 'vite preview'
960
960
  }
961
961
 
962
- writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
962
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
963
963
  console.log(' ✅ Actualizado: package.json con scripts')
964
964
 
965
965
  console.log('')