vtex-css-sanitizer-cli 1.0.8 → 1.1.0

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.
@@ -41,6 +41,7 @@ jobs:
41
41
 
42
42
  - name: Sync version from tag
43
43
  working-directory: gui
44
+ shell: bash
44
45
  run: npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version
45
46
 
46
47
  - name: Build & Package
@@ -35,8 +35,16 @@ async function fixCommand(projectPath) {
35
35
  const totalFiles = cssFiles.length;
36
36
  for (let fileIndex = 0; fileIndex < totalFiles; fileIndex++) {
37
37
  const filePath = cssFiles[fileIndex];
38
- const originalContent = await promises_1.default.readFile(filePath, 'utf-8');
39
- const root = postcss_1.default.parse(originalContent);
38
+ let originalContent;
39
+ let root;
40
+ try {
41
+ originalContent = await promises_1.default.readFile(filePath, 'utf-8');
42
+ root = postcss_1.default.parse(originalContent);
43
+ }
44
+ catch (error) {
45
+ console.error(`❌ Error leyendo/parseando ${path_1.default.relative(projectPath, filePath)}: ${error}`);
46
+ continue;
47
+ }
40
48
  const candidates = (0, css_processor_1.identifyRulesForDeletion)(root, unusedSuffixes);
41
49
  if (candidates.length === 0) {
42
50
  continue;
@@ -50,7 +58,7 @@ async function fixCommand(projectPath) {
50
58
  const rule = candidates[i];
51
59
  const relativePath = path_1.default.relative(projectPath, filePath);
52
60
  const ruleAsString = rule.toString();
53
- console.clear();
61
+ console.log('\n==================================================================');
54
62
  console.log(`[ Progreso: Archivo ${fileIndex + 1} de ${totalFiles} ]`);
55
63
  console.log(`------------------------------------------------------------------`);
56
64
  console.log(`Revisando Archivo: ${relativePath}`);
@@ -98,7 +106,7 @@ async function fixCommand(projectPath) {
98
106
  deletedRules.push(...fileDeletedRules);
99
107
  keptRules.push(...fileKeptRules);
100
108
  }
101
- console.clear();
109
+ console.log('\n==================================================================');
102
110
  if (totalRulesRemoved > 0) {
103
111
  console.log(`\n✅ Proceso completado. Se eliminaron un total de ${totalRulesRemoved} reglas CSS.`);
104
112
  }
@@ -13,13 +13,15 @@ async function ensureReportDirectory(projectPath) {
13
13
  await promises_1.default.mkdir(reportDir, { recursive: true }); // recursive: true evita errores si el dir ya existe
14
14
  return reportDir;
15
15
  }
16
- // --- Helper para obtener la fecha en formato YYYY-MM-DD ---
16
+ // --- Helper para obtener la fecha en formato YYYY-MM-DD_HHmm ---
17
17
  function getFormattedDate() {
18
18
  const date = new Date();
19
19
  const year = date.getFullYear();
20
20
  const month = (date.getMonth() + 1).toString().padStart(2, '0');
21
21
  const day = date.getDate().toString().padStart(2, '0');
22
- return `${year}-${month}-${day}`;
22
+ const hours = date.getHours().toString().padStart(2, '0');
23
+ const minutes = date.getMinutes().toString().padStart(2, '0');
24
+ return `${year}-${month}-${day}_${hours}${minutes}`;
23
25
  }
24
26
  // --- Generador para el informe de 'analyze' ---
25
27
  async function generateAnalysisReport(projectPath, unusedCss, unusedBlockClasses, usedCssSuffixesMap, declaredBlockClassesMap) {
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "vtex-css-sanitizer-cli",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "Herramienta CLI para eliminar CSS y blockClass no utilizados en proyectos VTEX IO.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "vtex-css-sanitizer": "dist/index.js"
8
8
  },
9
9
  "scripts": {
10
- "build": "npx tsc",
10
+ "build": "tsc",
11
11
  "start": "ts-node src/index.ts",
12
- "dev": "npm run build && node dist/index.js"
12
+ "dev": "npm run build && node dist/index.js",
13
+ "prepublishOnly": "npm run build"
13
14
  },
14
15
  "keywords": [
15
16
  "vtex",
@@ -20,7 +21,6 @@
20
21
  "author": "Elias Daniel Emanuele",
21
22
  "license": "ISC",
22
23
  "dependencies": {
23
- "@types/glob": "^8.1.0",
24
24
  "commander": "^11.0.0",
25
25
  "glob": "^8.1.0",
26
26
  "jsonc-parser": "^3.2.0",
@@ -28,6 +28,7 @@
28
28
  "prompts": "^2.4.2"
29
29
  },
30
30
  "devDependencies": {
31
+ "@types/glob": "^8.1.0",
31
32
  "@types/node": "^20.5.7",
32
33
  "@types/prompts": "^2.4.9",
33
34
  "ts-node": "^10.9.1",