slicejs-cli 1.0.27 → 1.0.30

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.
@@ -0,0 +1,16 @@
1
+ export default function formatComponentCode(componentContent) {
2
+ // Eliminar espacios en blanco redundantes
3
+ componentContent = componentContent.replace(/\n\s*\n/g, '\n\n');
4
+
5
+ // Agregar espacios en blanco después de llaves y paréntesis
6
+ componentContent = componentContent.replace(/(\{|;|\(|\)|\})/g, '$1\n ');
7
+
8
+ // Eliminar espacios en blanco al final de las líneas
9
+ componentContent = componentContent.replace(/\s+$/gm, '');
10
+
11
+ // Reemplazar múltiples espacios con uno solo
12
+ componentContent = componentContent.replace(/ {2,}/g, ' ');
13
+
14
+ return componentContent.trim() + '\n';
15
+ }
16
+
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import Validations from '../Validations.js';
4
-
4
+ import formatComponentCode from '../format.js';
5
5
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
6
6
 
7
7
 
@@ -64,6 +64,7 @@ function modifyComponent(componentName, category, addProperties, removePropertie
64
64
  });
65
65
 
66
66
  componentContent = updateComponentProps(componentContent, existingProperties);
67
+ componentContent = formatComponentCode(componentContent);
67
68
  fs.writeFileSync(componentPath, componentContent);
68
69
  console.log(`Component '${componentName}' modified successfully.`);
69
70
  }
@@ -89,23 +90,22 @@ function addGetterSetterIfNeeded(componentContent, property) {
89
90
  }
90
91
 
91
92
  function removePropertyIfNeeded(componentContent, property) {
92
- let updatedComponentContent = componentContent;
93
-
94
93
  // Eliminar la propiedad de debuggerProps si está presente
95
- const debuggerPropsRegex = /this\.debuggerProps\s*=\s*\[(.*?)\];/s;
96
- updatedComponentContent = updatedComponentContent.replace(debuggerPropsRegex, (match, propsList) => {
97
- const props = propsList.split(',').map(prop => prop.trim().replace(/['"]/g, ''));
94
+ const propRegex = /this\.debuggerProps\s*=\s*\[(.*?)\];/s;
95
+ const match = componentContent.match(propRegex);
96
+ if (match && match[1]) {
97
+ let props = match[1].split(',').map(prop => prop.trim().replace(/['"]/g, ''));
98
98
  const propIndex = props.indexOf(property);
99
99
  if (propIndex !== -1) {
100
100
  props.splice(propIndex, 1);
101
+ componentContent = componentContent.replace(propRegex, `this.debuggerProps = [${props.map(prop => `'${prop}'`).join(', ')}];`);
101
102
  }
102
- return `this.debuggerProps = [${props.map(prop => `'${prop}'`).join(', ')}];`;
103
- });
103
+ }
104
104
 
105
105
  // Eliminar los getters y setters de la propiedad
106
- updatedComponentContent = removeGetterSetter(updatedComponentContent, property);
106
+ componentContent = removeGetterSetter(componentContent, property);
107
107
 
108
- return updatedComponentContent;
108
+ return componentContent;
109
109
  }
110
110
 
111
111
  function hasGetterSetterForProperty(componentContent, property) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "1.0.27",
3
+ "version": "1.0.30",
4
4
  "description": "Command client for developing web applications with Slice.js",
5
5
  "main": "client.js",
6
6
  "scripts": {