@swimmingliu/autovpn 1.6.3 → 1.6.4
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/dist/artifacts/list.js +37 -2
- package/dist/web/renderer/i18n.js +1 -1
- package/package.json +1 -1
package/dist/artifacts/list.js
CHANGED
|
@@ -8,6 +8,41 @@ function loadJson(filePath) {
|
|
|
8
8
|
}
|
|
9
9
|
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
10
10
|
}
|
|
11
|
+
function countNonEmptyLines(filePath) {
|
|
12
|
+
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return fs.readFileSync(filePath, 'utf8')
|
|
16
|
+
.split(/\r?\n/)
|
|
17
|
+
.map((line) => line.trim())
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.length;
|
|
20
|
+
}
|
|
21
|
+
function positiveNumber(value) {
|
|
22
|
+
const numeric = Number(value);
|
|
23
|
+
return Number.isFinite(numeric) && numeric > 0 ? numeric : 0;
|
|
24
|
+
}
|
|
25
|
+
function restoreArtifactCounts(artifactDir, counts = {}) {
|
|
26
|
+
const restored = { ...counts };
|
|
27
|
+
const fileCounts = [
|
|
28
|
+
['raw_links', 'vpn_node_raw.txt'],
|
|
29
|
+
['deduped_links', 'vpn_node_deduped.txt'],
|
|
30
|
+
['speedtest_links', 'vpn_node_speedtest.txt'],
|
|
31
|
+
['availability_links', 'vpn_node_availability.txt'],
|
|
32
|
+
['final_links', 'vpn_node_emoji.txt'],
|
|
33
|
+
['postprocess_links', 'vpn_node_emoji.txt']
|
|
34
|
+
];
|
|
35
|
+
for (const [countKey, fileName] of fileCounts) {
|
|
36
|
+
if (positiveNumber(restored[countKey]) > 0) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const fileCount = countNonEmptyLines(path.join(artifactDir, fileName));
|
|
40
|
+
if (fileCount && fileCount > 0) {
|
|
41
|
+
restored[countKey] = fileCount;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return restored;
|
|
45
|
+
}
|
|
11
46
|
function latestArtifactDir(artifactsRoot) {
|
|
12
47
|
if (!fs.existsSync(artifactsRoot)) {
|
|
13
48
|
return '';
|
|
@@ -37,7 +72,7 @@ export function artifactLatest(projectRoot, env = process.env) {
|
|
|
37
72
|
...payload,
|
|
38
73
|
run_status: report.run_status ?? '',
|
|
39
74
|
stage_status: report.stage_status ?? {},
|
|
40
|
-
counts: report.counts ?? {},
|
|
75
|
+
counts: restoreArtifactCounts(latest, (report.counts ?? {})),
|
|
41
76
|
source_counts: report.source_counts ?? {},
|
|
42
77
|
deployment: safeDeployment((report.deployment ?? {})),
|
|
43
78
|
error: redactText(String(report.error ?? ''))
|
|
@@ -88,7 +123,7 @@ export function artifactList(projectRoot, env = process.env) {
|
|
|
88
123
|
artifact_name: path.basename(artifactDir),
|
|
89
124
|
run_status: report.run_status ?? '',
|
|
90
125
|
stage_status: stageStatus,
|
|
91
|
-
counts: report.counts ?? {},
|
|
126
|
+
counts: restoreArtifactCounts(artifactDir, (report.counts ?? {})),
|
|
92
127
|
source_counts: report.source_counts ?? {},
|
|
93
128
|
retry_context: report.retry_context ?? {},
|
|
94
129
|
retryable_stages: retryableStages(artifactDir, stageStatus),
|