ingeniuscliq-core 0.4.2 → 0.4.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.
@@ -16,6 +16,13 @@ function sanitizeTemplateName(input) {
16
16
  .replace(/-+/g, '-'); // colapsar guiones
17
17
  }
18
18
 
19
+ function toPascalCase(str) {
20
+ return str
21
+ .split('-')
22
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
23
+ .join('');
24
+ }
25
+
19
26
  function ensureDir(dirPath) {
20
27
  fs.mkdirSync(dirPath, { recursive: true });
21
28
  }
@@ -46,12 +53,79 @@ function createTemplate(templateNameRaw) {
46
53
  console.log(chalk.green(`✓ Creado directorio: ${chalk.bold(`src/components/templates/${templateName}`)}`));
47
54
 
48
55
  // Subcarpetas requeridas
49
- const subdirs = ['components', 'pages', 'styles'];
56
+ const subdirs = ['components', 'pages', 'styles', 'assets', 'helpers', 'hooks', 'types', 'locale'];
50
57
  subdirs.forEach((dir) => {
51
58
  ensureDir(joinPaths(baseDir, dir));
52
59
  console.log(chalk.green(`✓ Creado directorio: ${chalk.bold(`src/components/templates/${templateName}/${dir}`)}`));
53
60
  });
54
61
 
62
+ // Subcarpetas dentro de components
63
+ const componentsSubdirs = ['common', 'skeletons', 'layout'];
64
+ componentsSubdirs.forEach((dir) => {
65
+ ensureDir(joinPaths(baseDir, 'components', dir));
66
+ console.log(chalk.green(`✓ Creado directorio: ${chalk.bold(`src/components/templates/${templateName}/components/${dir}`)}`));
67
+ });
68
+
69
+ // Subcarpetas dentro de pages con archivos index.tsx
70
+ const pagesSubdirs = ['store', 'preview'];
71
+ const pageTemplates = {
72
+ store: `const StorePage = () => {\n return (\n <></>\n )\n}\n\nexport default StorePage\n`,
73
+ preview: `const PreviewPage = () => {\n return (\n <></>\n )\n}\n\nexport default PreviewPage\n`
74
+ };
75
+
76
+ pagesSubdirs.forEach((dir) => {
77
+ const pageDirPath = joinPaths(baseDir, 'pages', dir);
78
+ ensureDir(pageDirPath);
79
+ console.log(chalk.green(`✓ Creado directorio: ${chalk.bold(`src/components/templates/${templateName}/pages/${dir}`)}`));
80
+
81
+ // Crear archivo index.tsx
82
+ const indexPath = joinPaths(pageDirPath, 'index.tsx');
83
+ fs.writeFileSync(indexPath, pageTemplates[dir]);
84
+ console.log(chalk.green(`✓ Creado archivo: ${chalk.bold(`src/components/templates/${templateName}/pages/${dir}/index.tsx`)}`));
85
+ });
86
+
87
+ // Archivos dentro de components/layout
88
+ const pascalCaseName = toPascalCase(templateName);
89
+ const layoutDir = joinPaths(baseDir, 'components', 'layout');
90
+
91
+ // index.tsx en layout
92
+ const layoutIndexContent = `const ${pascalCaseName}Layout = ({ children }: { children: React.ReactNode }) => {\n return (\n <></>\n )\n}\n\nexport default ${pascalCaseName}Layout\n`;
93
+ const layoutIndexPath = joinPaths(layoutDir, 'index.tsx');
94
+ fs.writeFileSync(layoutIndexPath, layoutIndexContent);
95
+ console.log(chalk.green(`✓ Creado archivo: ${chalk.bold(`src/components/templates/${templateName}/components/layout/index.tsx`)}`));
96
+
97
+ // preview.tsx en layout
98
+ const layoutPreviewContent = `interface ${pascalCaseName}PreviewLayoutProps extends React.PropsWithChildren {\n template?: string | null\n}\n\nconst ${pascalCaseName}PreviewLayout = ({ template = null, children }: ${pascalCaseName}PreviewLayoutProps) => {\n return (\n <></>\n )\n}\n\nexport default ${pascalCaseName}PreviewLayout\n`;
99
+ const layoutPreviewPath = joinPaths(layoutDir, 'preview.tsx');
100
+ fs.writeFileSync(layoutPreviewPath, layoutPreviewContent);
101
+ console.log(chalk.green(`✓ Creado archivo: ${chalk.bold(`src/components/templates/${templateName}/components/layout/preview.tsx`)}`));
102
+
103
+ // Estructura de locale
104
+ const localeDir = joinPaths(baseDir, 'locale');
105
+ const localeSubdirs = ['fields', 'messages'];
106
+ const localeFiles = ['en.json', 'es.json'];
107
+ const emptyJsonContent = '{}\n';
108
+
109
+ // Archivos en locale raíz
110
+ localeFiles.forEach((file) => {
111
+ const filePath = joinPaths(localeDir, file);
112
+ fs.writeFileSync(filePath, emptyJsonContent);
113
+ console.log(chalk.green(`✓ Creado archivo: ${chalk.bold(`src/components/templates/${templateName}/locale/${file}`)}`));
114
+ });
115
+
116
+ // Subcarpetas y archivos en locale
117
+ localeSubdirs.forEach((subdir) => {
118
+ const subdirPath = joinPaths(localeDir, subdir);
119
+ ensureDir(subdirPath);
120
+ console.log(chalk.green(`✓ Creado directorio: ${chalk.bold(`src/components/templates/${templateName}/locale/${subdir}`)}`));
121
+
122
+ localeFiles.forEach((file) => {
123
+ const filePath = joinPaths(subdirPath, file);
124
+ fs.writeFileSync(filePath, emptyJsonContent);
125
+ console.log(chalk.green(`✓ Creado archivo: ${chalk.bold(`src/components/templates/${templateName}/locale/${subdir}/${file}`)}`));
126
+ });
127
+ });
128
+
55
129
  console.log(chalk.green.bold(`\n✨ Plantilla '${templateName}' creada correctamente.`));
56
130
  } catch (error) {
57
131
  console.error(chalk.red.bold(`❌ Error creando la plantilla: ${error.message}`));
@@ -10,6 +10,6 @@ export const createBaseDir = (moduleName, pathPrefix = []) => {
10
10
  return path.join(...fullPath)
11
11
  }
12
12
 
13
- export const joinPaths = (baseDir, dirToAdd) => {
14
- return path.join(baseDir, dirToAdd)
13
+ export const joinPaths = (...paths) => {
14
+ return path.join(...paths)
15
15
  }