@sun-asterisk/sunlint 1.3.14 → 1.3.16
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/core/output-service.js +19 -1
- package/core/summary-report-service.js +21 -3
- package/core/upload-service.js +31 -9
- package/package.json +1 -1
package/core/output-service.js
CHANGED
|
@@ -14,6 +14,24 @@ class OutputService {
|
|
|
14
14
|
this.scoringService = new ScoringService();
|
|
15
15
|
this.summaryReportService = new SummaryReportService();
|
|
16
16
|
this.uploadService = new UploadService();
|
|
17
|
+
|
|
18
|
+
// Load version from package.json
|
|
19
|
+
this.version = this._loadVersion();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Load version from package.json
|
|
24
|
+
* @returns {string} Package version
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
_loadVersion() {
|
|
28
|
+
try {
|
|
29
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
30
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
31
|
+
return packageJson.version || '1.3.16';
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return '1.3.16'; // Fallback version
|
|
34
|
+
}
|
|
17
35
|
}
|
|
18
36
|
|
|
19
37
|
async outputResults(results, options, metadata = {}) {
|
|
@@ -111,7 +129,7 @@ class OutputService {
|
|
|
111
129
|
cwd: process.cwd(),
|
|
112
130
|
filesAnalyzed: totalFiles,
|
|
113
131
|
duration: metadata.duration,
|
|
114
|
-
version: metadata.version ||
|
|
132
|
+
version: metadata.version || this.version
|
|
115
133
|
}
|
|
116
134
|
);
|
|
117
135
|
|
|
@@ -9,7 +9,25 @@ const path = require('path');
|
|
|
9
9
|
const { execSync } = require('child_process');
|
|
10
10
|
|
|
11
11
|
class SummaryReportService {
|
|
12
|
-
constructor() {
|
|
12
|
+
constructor() {
|
|
13
|
+
// Load version from package.json
|
|
14
|
+
this.version = this._loadVersion();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Load version from package.json
|
|
19
|
+
* @returns {string} Package version
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
_loadVersion() {
|
|
23
|
+
try {
|
|
24
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
25
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
26
|
+
return packageJson.version || '1.3.16';
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return '1.3.16'; // Fallback version
|
|
29
|
+
}
|
|
30
|
+
}
|
|
13
31
|
|
|
14
32
|
/**
|
|
15
33
|
* Get Git repository information
|
|
@@ -214,7 +232,7 @@ class SummaryReportService {
|
|
|
214
232
|
info_count: 0, // Reserved for future use
|
|
215
233
|
lines_of_code: scoringSummary.metrics.linesOfCode,
|
|
216
234
|
files_analyzed: options.filesAnalyzed || 0,
|
|
217
|
-
sunlint_version: options.version ||
|
|
235
|
+
sunlint_version: options.version || this.version,
|
|
218
236
|
analysis_duration_ms: options.duration || 0,
|
|
219
237
|
violations: violationsSummary,
|
|
220
238
|
|
|
@@ -222,7 +240,7 @@ class SummaryReportService {
|
|
|
222
240
|
metadata: {
|
|
223
241
|
generated_at: new Date().toISOString(),
|
|
224
242
|
tool: 'SunLint',
|
|
225
|
-
version: options.version ||
|
|
243
|
+
version: options.version || this.version,
|
|
226
244
|
analysis_duration_ms: options.duration || 0
|
|
227
245
|
},
|
|
228
246
|
quality: {
|
package/core/upload-service.js
CHANGED
|
@@ -89,25 +89,45 @@ class UploadService {
|
|
|
89
89
|
const fileName = path.basename(filePath);
|
|
90
90
|
const timeout = options.timeout || 30; // 30 seconds default timeout
|
|
91
91
|
|
|
92
|
-
// Build curl command
|
|
92
|
+
// Build curl command with status code output
|
|
93
93
|
const curlCommand = this.buildCurlCommand(filePath, apiUrl, fileName, timeout);
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
|
-
// Execute curl command
|
|
96
|
+
// Execute curl command with write-out to get status code
|
|
97
97
|
const output = execSync(curlCommand, {
|
|
98
98
|
encoding: 'utf8',
|
|
99
99
|
maxBuffer: 1024 * 1024, // 1MB buffer
|
|
100
100
|
timeout: timeout * 1000 // Convert to milliseconds
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
// Parse response
|
|
104
|
-
|
|
103
|
+
// Parse response with headers included (-i flag)
|
|
104
|
+
// Output format: "HTTP/1.1 200 OK\nHeaders...\n\nResponse Body"
|
|
105
|
+
const lines = output.trim().split('\n');
|
|
106
|
+
|
|
107
|
+
// Find the status line (first line starting with HTTP)
|
|
105
108
|
let statusCode = null;
|
|
109
|
+
const statusLine = lines.find(line => line.startsWith('HTTP/'));
|
|
110
|
+
if (statusLine) {
|
|
111
|
+
const statusMatch = statusLine.match(/HTTP\/[\d.]+\s+(\d{3})/);
|
|
112
|
+
if (statusMatch) {
|
|
113
|
+
statusCode = parseInt(statusMatch[1]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Find response body (after empty line separating headers from body)
|
|
118
|
+
let response = '';
|
|
119
|
+
let foundEmptyLine = false;
|
|
120
|
+
for (const line of lines) {
|
|
121
|
+
if (foundEmptyLine) {
|
|
122
|
+
response += (response ? '\n' : '') + line;
|
|
123
|
+
} else if (line.trim() === '') {
|
|
124
|
+
foundEmptyLine = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
106
127
|
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
statusCode = parseInt(statusMatch[1]);
|
|
128
|
+
// If no empty line found, assume entire output is response
|
|
129
|
+
if (!foundEmptyLine) {
|
|
130
|
+
response = output.trim();
|
|
111
131
|
}
|
|
112
132
|
|
|
113
133
|
return {
|
|
@@ -144,7 +164,9 @@ class UploadService {
|
|
|
144
164
|
}
|
|
145
165
|
|
|
146
166
|
curlOptions.push(
|
|
147
|
-
`--data @"${filePath}"`,
|
|
167
|
+
`--data-binary @"${filePath}"`,
|
|
168
|
+
'-i', // Include response headers in output
|
|
169
|
+
'-s', // Silent mode (no progress meter)
|
|
148
170
|
`"${apiUrl}"`
|
|
149
171
|
);
|
|
150
172
|
|
package/package.json
CHANGED