uglify-js-minify-css-allfiles 2.0.4 → 2.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.
- package/CHANGELOG.md +36 -24
- package/README.md +88 -45
- package/demo.js +6 -16
- package/dist/module.js +98 -81
- package/dist/modules/fileHandler.js +19 -19
- package/dist/modules/logger.js +177 -98
- package/dist/modules/minifier.js +9 -9
- package/logs/log-08-20-2024.log +65 -0
- package/minify.d.ts +41 -0
- package/package.json +2 -1
- package/test/lib/test.css +4 -4
- package/test/lib/test.js +1 -1
- package/test/test.css +4 -4
- package/test/test.js +80 -80
- package/logs/error.log +0 -6
- package/logs/summary.log +0 -112
package/dist/modules/logger.js
CHANGED
|
@@ -1,115 +1,194 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logger module for handling log operations.
|
|
3
|
-
* @module logger
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
1
|
import fs from 'fs/promises';
|
|
7
2
|
import path from 'path';
|
|
8
3
|
|
|
9
|
-
/**
|
|
10
|
-
* Get current formatted time string
|
|
11
|
-
* @returns {string} Formatted time string
|
|
12
|
-
*/
|
|
13
|
-
function getCurrentTime() {
|
|
14
|
-
const now = new Date();
|
|
15
|
-
return now.toLocaleString('en-US', {
|
|
16
|
-
year: 'numeric',
|
|
17
|
-
month: '2-digit',
|
|
18
|
-
day: '2-digit',
|
|
19
|
-
hour: '2-digit',
|
|
20
|
-
minute: '2-digit',
|
|
21
|
-
second: '2-digit',
|
|
22
|
-
hour12: false,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Logger class for handling log operations.
|
|
28
|
-
* @class
|
|
29
|
-
*/
|
|
30
4
|
class Logger {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
5
|
+
static LOG_LEVELS = {
|
|
6
|
+
error: 0,
|
|
7
|
+
warn: 1,
|
|
8
|
+
info: 2,
|
|
9
|
+
debug: 3,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
static DEFAULT_LOG_LEVEL = 'info';
|
|
13
|
+
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
const {
|
|
16
|
+
logDir = 'logs',
|
|
17
|
+
retentionDays = 30,
|
|
18
|
+
logLevel = Logger.DEFAULT_LOG_LEVEL,
|
|
19
|
+
dateFormat = 'YYYY-MM-DD',
|
|
20
|
+
timeZone = 'UTC',
|
|
21
|
+
logToConsole = true,
|
|
22
|
+
logToFile = true,
|
|
23
|
+
} = options;
|
|
24
|
+
|
|
25
|
+
this.logDir = logDir;
|
|
26
|
+
this.retentionDays = retentionDays;
|
|
27
|
+
this.dateFormat = dateFormat;
|
|
28
|
+
this.timeZone = timeZone;
|
|
29
|
+
this.logToConsole = logToConsole;
|
|
30
|
+
this.logToFile = logToFile;
|
|
31
|
+
|
|
32
|
+
this.errorCount = 0;
|
|
33
|
+
this.errorFiles = new Set();
|
|
34
|
+
this.processedFiles = new Set();
|
|
35
|
+
this.currentDate = this.getCurrentDate();
|
|
36
|
+
this.logFilePath = this.getLogFilePath();
|
|
37
|
+
|
|
38
|
+
this.setLogLevel(logLevel);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async initialize() {
|
|
42
|
+
if (this.logToFile) {
|
|
43
|
+
await this.createLogDirectory();
|
|
39
44
|
}
|
|
45
|
+
await this.cleanOldLogs();
|
|
46
|
+
}
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
async initialize() {
|
|
47
|
-
try {
|
|
48
|
-
await fs.mkdir(this.logDir, { recursive: true });
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error(`Failed to create log directory: ${error.message}`);
|
|
51
|
-
}
|
|
48
|
+
async createLogDirectory() {
|
|
49
|
+
try {
|
|
50
|
+
await fs.mkdir(this.logDir, { recursive: true });
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(`Failed to create log directory: ${error.message}`);
|
|
52
53
|
}
|
|
54
|
+
}
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
56
|
+
setLogLevel(level) {
|
|
57
|
+
const normalizedLevel = level.toLowerCase();
|
|
58
|
+
if (normalizedLevel in Logger.LOG_LEVELS) {
|
|
59
|
+
this.logLevel = Logger.LOG_LEVELS[normalizedLevel];
|
|
60
|
+
console.log(`Log level set to "${normalizedLevel}"`);
|
|
61
|
+
} else {
|
|
62
|
+
console.warn(
|
|
63
|
+
`Invalid log level "${level}". Using default level "${Logger.DEFAULT_LOG_LEVEL}".`,
|
|
64
|
+
);
|
|
65
|
+
this.logLevel = Logger.LOG_LEVELS[Logger.DEFAULT_LOG_LEVEL];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async log(level, message, metadata = {}) {
|
|
70
|
+
const logLevelValue = Logger.LOG_LEVELS[level.toLowerCase()] ?? Logger.LOG_LEVELS.info;
|
|
71
|
+
if (logLevelValue <= this.logLevel) {
|
|
72
|
+
const logMessage = this.formatLogMessage(level, message, metadata);
|
|
73
|
+
|
|
74
|
+
if (this.logToConsole) {
|
|
75
|
+
console[level.toLowerCase()](logMessage);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (this.logToFile) {
|
|
79
|
+
await this.appendLog(logMessage);
|
|
80
|
+
}
|
|
79
81
|
}
|
|
82
|
+
}
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
logInfo(message) {
|
|
86
|
-
console.info(`[${getCurrentTime()}] ${message}`);
|
|
84
|
+
async error(message, metadata = {}) {
|
|
85
|
+
this.errorCount++;
|
|
86
|
+
if (metadata.filePath) {
|
|
87
|
+
this.errorFiles.add(metadata.filePath);
|
|
87
88
|
}
|
|
89
|
+
await this.log('error', message, metadata);
|
|
90
|
+
}
|
|
88
91
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
92
|
+
async warn(message, metadata = {}) {
|
|
93
|
+
await this.log('warn', message, metadata);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async info(message, metadata = {}) {
|
|
97
|
+
await this.log('info', message, metadata);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async debug(message, metadata = {}) {
|
|
101
|
+
await this.log('debug', message, metadata);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
incrementProcessedFiles(filePath) {
|
|
105
|
+
this.processedFiles.add(filePath);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async summarize() {
|
|
109
|
+
const summary = this.formatSummary();
|
|
110
|
+
await this.log('info', 'Processing Summary', { summary });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async appendLog(content) {
|
|
114
|
+
if (this.logToFile) {
|
|
115
|
+
try {
|
|
116
|
+
await this.checkAndRotateLog();
|
|
117
|
+
await fs.appendFile(this.logFilePath, content + '\n');
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error(`Failed to write to log file: ${error.message}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async checkAndRotateLog() {
|
|
125
|
+
const currentDate = this.getCurrentDate();
|
|
126
|
+
if (currentDate !== this.currentDate) {
|
|
127
|
+
this.currentDate = currentDate;
|
|
128
|
+
this.logFilePath = this.getLogFilePath();
|
|
129
|
+
await this.cleanOldLogs();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getLogFilePath() {
|
|
134
|
+
return path.join(this.logDir, `log-${this.currentDate}.log`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
getCurrentDate() {
|
|
138
|
+
return new Date()
|
|
139
|
+
.toLocaleString('en-US', {
|
|
140
|
+
timeZone: this.timeZone,
|
|
141
|
+
year: 'numeric',
|
|
142
|
+
month: '2-digit',
|
|
143
|
+
day: '2-digit',
|
|
144
|
+
})
|
|
145
|
+
.split(',')[0]
|
|
146
|
+
.replace(/\//g, '-');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async cleanOldLogs() {
|
|
150
|
+
if (this.logToFile) {
|
|
151
|
+
try {
|
|
152
|
+
const files = await fs.readdir(this.logDir);
|
|
153
|
+
const now = new Date();
|
|
154
|
+
for (const file of files) {
|
|
155
|
+
const filePath = path.join(this.logDir, file);
|
|
156
|
+
const stats = await fs.stat(filePath);
|
|
157
|
+
const diffDays = (now - stats.mtime) / (1000 * 60 * 60 * 24);
|
|
158
|
+
if (diffDays > this.retentionDays) {
|
|
159
|
+
await fs.unlink(filePath);
|
|
160
|
+
}
|
|
111
161
|
}
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error(`Failed to clean old logs: ${error.message}`);
|
|
164
|
+
}
|
|
112
165
|
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
formatLogMessage(level, message, metadata) {
|
|
169
|
+
const timestamp = new Date().toLocaleString('en-US', {
|
|
170
|
+
timeZone: this.timeZone,
|
|
171
|
+
year: 'numeric',
|
|
172
|
+
month: '2-digit',
|
|
173
|
+
day: '2-digit',
|
|
174
|
+
hour: '2-digit',
|
|
175
|
+
minute: '2-digit',
|
|
176
|
+
second: '2-digit',
|
|
177
|
+
hour12: false,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
let metadataStr = Object.keys(metadata).length > 0 ? ` ${JSON.stringify(metadata)}` : '';
|
|
181
|
+
return `[${timestamp}] [${level.toUpperCase()}] ${message}${metadataStr}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
formatSummary() {
|
|
185
|
+
return {
|
|
186
|
+
totalFilesProcessed: this.processedFiles.size,
|
|
187
|
+
filesWithErrors: this.errorFiles.size,
|
|
188
|
+
errorCount: this.errorCount,
|
|
189
|
+
errorFiles: Array.from(this.errorFiles),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
113
192
|
}
|
|
114
193
|
|
|
115
194
|
export default Logger;
|
package/dist/modules/minifier.js
CHANGED
|
@@ -11,7 +11,7 @@ import CleanCSS from 'clean-css';
|
|
|
11
11
|
* @constant {Object}
|
|
12
12
|
*/
|
|
13
13
|
const CSS_OPTIONS = {
|
|
14
|
-
|
|
14
|
+
level: { 1: { all: false } },
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -21,11 +21,11 @@ const CSS_OPTIONS = {
|
|
|
21
21
|
* @returns {string} The minified JavaScript content.
|
|
22
22
|
*/
|
|
23
23
|
export function minifyJS(content) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return uglifyJS(content, {
|
|
25
|
+
compress: {
|
|
26
|
+
pure_funcs: ['console.log', 'console.error', 'console.warn', 'console.info'],
|
|
27
|
+
},
|
|
28
|
+
}).code;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -36,7 +36,7 @@ export function minifyJS(content) {
|
|
|
36
36
|
* @returns {Promise<Object>} A promise that resolves to the minification result.
|
|
37
37
|
*/
|
|
38
38
|
export function minifyCSS(content) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
new CleanCSS(CSS_OPTIONS).minify(content, (error, output) => resolve(output));
|
|
41
|
+
});
|
|
42
42
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[08/20/2024, 07:25:30] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
2
|
+
[08/20/2024, 07:25:30] [ERROR] Error processing file {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","error":"logger.logError is not a function"}
|
|
3
|
+
[08/20/2024, 07:25:30] [ERROR] Error processing file {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js","error":"logger.logError is not a function"}
|
|
4
|
+
[08/20/2024, 07:25:30] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
5
|
+
[08/20/2024, 07:27:25] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
6
|
+
[08/20/2024, 07:27:25] [ERROR] Error processing file {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","error":"logger.logError is not a function"}
|
|
7
|
+
[08/20/2024, 07:27:25] [ERROR] Error processing file {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js","error":"logger.logError is not a function"}
|
|
8
|
+
[08/20/2024, 07:27:25] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":2,"errorCount":2,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
9
|
+
[08/20/2024, 07:29:14] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
10
|
+
[08/20/2024, 07:29:14] [ERROR] Error processing file {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","error":"error is not defined"}
|
|
11
|
+
[08/20/2024, 07:29:14] [ERROR] Babel transformation failed {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js","error":"logger.logError is not a function"}
|
|
12
|
+
[08/20/2024, 07:29:14] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":2,"errorCount":2,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
13
|
+
[08/20/2024, 07:30:41] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
14
|
+
[08/20/2024, 07:30:41] [ERROR] Error processing file {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","error":"error is not defined"}
|
|
15
|
+
[08/20/2024, 07:30:41] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
16
|
+
[08/20/2024, 07:30:41] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":2,"errorCount":2,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
17
|
+
[08/20/2024, 07:34:34] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
18
|
+
[08/20/2024, 07:34:34] [WARN] CSS minification warnings {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","warnings":["Invalid character(s) '``1212`12' at 9:0. Ignoring.","Invalid property name '12\r\n wi2ddth' at 1:19. Ignoring.","Invalid property name '`122` height' at 3:1. Ignoring."]}
|
|
19
|
+
[08/20/2024, 07:34:34] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
20
|
+
[08/20/2024, 07:34:34] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
21
|
+
[08/20/2024, 07:34:34] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
22
|
+
[08/20/2024, 08:28:13] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
23
|
+
[08/20/2024, 08:28:13] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
24
|
+
[08/20/2024, 08:28:13] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
25
|
+
[08/20/2024, 08:28:13] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
26
|
+
[08/20/2024, 08:30:24] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
27
|
+
[08/20/2024, 08:30:24] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
28
|
+
[08/20/2024, 08:30:24] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
29
|
+
[08/20/2024, 08:30:24] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
30
|
+
[08/20/2024, 08:30:52] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
31
|
+
[08/20/2024, 08:30:52] [ERROR] CSS minification failed {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","warnings":["Invalid character(s) 'qw d' at 8:0. Ignoring.","Invalid property name 'widtqwd as w dh' at 2:2. Ignoring.","Invalid property name 'heig ht' at 3:2. Ignoring.","Invalid property name 'diw qqw ddqw dn' at 6:2. Ignoring."]}
|
|
32
|
+
[08/20/2024, 08:30:52] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
33
|
+
[08/20/2024, 08:30:52] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
34
|
+
[08/20/2024, 08:30:52] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":2,"errorCount":2,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
35
|
+
[08/20/2024, 08:31:39] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
36
|
+
[08/20/2024, 08:31:39] [WARN] CSS minification warnings {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","warnings":["Invalid character(s) 'qw d' at 8:0. Ignoring.","Invalid property name 'widtqwd as w dh' at 2:2. Ignoring.","Invalid property name 'heig ht' at 3:2. Ignoring.","Invalid property name 'diw qqw ddqw dn' at 6:2. Ignoring."]}
|
|
37
|
+
[08/20/2024, 08:31:39] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
38
|
+
[08/20/2024, 08:31:39] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
39
|
+
[08/20/2024, 08:31:39] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
40
|
+
[08/20/2024, 09:37:12] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":false}
|
|
41
|
+
[08/20/2024, 09:37:12] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
42
|
+
[08/20/2024, 09:37:12] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
43
|
+
[08/20/2024, 09:37:12] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
44
|
+
[08/20/2024, 09:41:53] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
45
|
+
[08/20/2024, 09:41:53] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
46
|
+
[08/20/2024, 09:41:54] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
47
|
+
[08/20/2024, 09:41:54] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
48
|
+
[08/20/2024, 09:42:26] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
49
|
+
[08/20/2024, 09:42:26] [WARN] CSS minification warnings {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","warnings":["Invalid character(s) '.f f asd123weqfqwe\r\n f asdedsf asdfsaday: block;\r\nfasdf fsad2dsf \r\nsdf' at 1:0. Ignoring."]}
|
|
50
|
+
[08/20/2024, 09:42:26] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css"}
|
|
51
|
+
[08/20/2024, 09:42:27] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
52
|
+
[08/20/2024, 09:42:27] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css"]}}
|
|
53
|
+
[08/20/2024, 09:45:28] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
54
|
+
[08/20/2024, 09:45:28] [WARN] CSS minification warnings {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","warnings":["Invalid character(s) '.f f asd123weqfqwe\r\n f asdedsf asdfsaday: block;\r\nfasdf fsad2dsf \r\nsdf' at 1:0. Ignoring."]}
|
|
55
|
+
[08/20/2024, 09:45:28] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css"}
|
|
56
|
+
[08/20/2024, 09:45:29] [ERROR] JavaScript minification failed {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js","error":"unknown: Identifier directly after number. (1:7)\n\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 1 |\u001b[39m \u001b[35m3123123\u001b[39mc312l312as123123s3123 \u001b[33mModernBa123123nk\u001b[39m {\n \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\n \u001b[90m 2 |\u001b[39m \u001b[35m31212312\u001b[39m\u001b[90m// Private fields\u001b[39m\n \u001b[90m 3 |\u001b[39m \u001b[33m#\u001b[39mbalance \u001b[33m=\u001b[39m \u001b[35m0\u001b[39m\u001b[33m;\u001b[39m\n \u001b[90m 4 |\u001b[39m \u001b[33m#\u001b[39mtransactionHistory \u001b[33m=\u001b[39m []\u001b[33m;\u001b[39m\u001b[0m"}
|
|
57
|
+
[08/20/2024, 09:45:29] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":2,"errorCount":2,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.css","C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
58
|
+
[08/20/2024, 10:12:02] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
59
|
+
[08/20/2024, 10:12:02] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
60
|
+
[08/20/2024, 10:12:03] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
61
|
+
[08/20/2024, 10:12:03] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
62
|
+
[08/20/2024, 10:23:04] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
63
|
+
[08/20/2024, 10:23:04] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
64
|
+
[08/20/2024, 10:23:05] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
65
|
+
[08/20/2024, 10:23:05] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
package/minify.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare module 'uglify-js-minify-css-allfiles' {
|
|
2
|
+
export interface BabelOptions {
|
|
3
|
+
targets?: string | string[] | { [key: string]: string };
|
|
4
|
+
modules?: 'amd' | 'umd' | 'systemjs' | 'commonjs' | 'cjs' | 'auto' | false;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
include?: string[];
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
useBuiltIns?: 'usage' | 'entry' | false;
|
|
9
|
+
corejs?: 2 | 3 | { version: 2 | 3; proposals: boolean };
|
|
10
|
+
forceAllTransforms?: boolean;
|
|
11
|
+
configPath?: string;
|
|
12
|
+
ignoreBrowserslistConfig?: boolean;
|
|
13
|
+
shippedProposals?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface LogOptions {
|
|
17
|
+
logDir?: string;
|
|
18
|
+
retentionDays?: number;
|
|
19
|
+
logLevel?: string;
|
|
20
|
+
dateFormat?: string;
|
|
21
|
+
timeZone?: string;
|
|
22
|
+
logToConsole?: boolean;
|
|
23
|
+
logToFile?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface MinifyOptions {
|
|
27
|
+
excludeFolder?: string;
|
|
28
|
+
useBabel?: boolean | BabelOptions;
|
|
29
|
+
useLog?: boolean | LogOptions;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Minifies all JavaScript and CSS files in the specified directory and its subdirectories.
|
|
34
|
+
*
|
|
35
|
+
* @param contentPath - The path to the directory containing the files to be minified.
|
|
36
|
+
* @param options - Options for minification and logging.
|
|
37
|
+
* @returns A promise that resolves when all files have been processed.
|
|
38
|
+
* @throws {Error} If there's an issue reading or writing files.
|
|
39
|
+
*/
|
|
40
|
+
export default function minifyAll(contentPath: string, options?: MinifyOptions): Promise<void>;
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uglify-js-minify-css-allfiles",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "you will be able to minify all files as same file names which is js or css",
|
|
5
5
|
"main": "minify.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"types": "minify.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": "./minify.js"
|
|
9
10
|
},
|
package/test/lib/test.css
CHANGED
package/test/lib/test.js
CHANGED
package/test/test.css
CHANGED