fnva 0.0.47 → 0.0.48
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/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/platforms/linux-x64/fnva
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 从 Adoptium GitHub Releases 查询最新 Java 版本,
|
|
5
|
+
* 生成简化的 config/java_versions.toml(LTS + 最新非 LTS)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const https = require('https');
|
|
9
|
+
|
|
10
|
+
const REPOS = [
|
|
11
|
+
{ repo: 'temurin8-binaries', major: 8, lts: true },
|
|
12
|
+
{ repo: 'temurin11-binaries', major: 11, lts: true },
|
|
13
|
+
{ repo: 'temurin17-binaries', major: 17, lts: true },
|
|
14
|
+
{ repo: 'temurin21-binaries', major: 21, lts: true },
|
|
15
|
+
{ repo: 'temurin25-binaries', major: 25, lts: false },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const PLATFORMS = [
|
|
19
|
+
{ key: 'windows-x64', pattern: /jdk_x64_windows_hotspot/ },
|
|
20
|
+
{ key: 'linux-x64', pattern: /jdk_x64_linux_hotspot/ },
|
|
21
|
+
{ key: 'linux-aarch64', pattern: /jdk_aarch64_linux_hotspot/ },
|
|
22
|
+
{ key: 'macos-x64', pattern: /jdk_x64_mac_hotspot/ },
|
|
23
|
+
{ key: 'macos-aarch64', pattern: /jdk_aarch64_mac_hotspot/ },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
function fetchJSON(url) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
https.get(url, { headers: { 'User-Agent': 'fnva-ci' } }, (res) => {
|
|
29
|
+
let data = '';
|
|
30
|
+
res.on('data', (chunk) => data += chunk);
|
|
31
|
+
res.on('end', () => {
|
|
32
|
+
try { resolve(JSON.parse(data)); }
|
|
33
|
+
catch (e) { reject(new Error(`Parse error: ${e.message}`)); }
|
|
34
|
+
});
|
|
35
|
+
}).on('error', reject);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function parseVersion(tagName) {
|
|
40
|
+
// jdk-21.0.10+7 -> { version: "21.0.10", tag: "jdk-21.0.10+7" }
|
|
41
|
+
// jdk8u482-b08 -> { version: "8u482b08", tag: "jdk8u482-b08" }
|
|
42
|
+
const match = tagName.match(/^jdk-?([\d.]+u?\d*)(?:\+|b|-b?)(\d+)$/i);
|
|
43
|
+
if (!match) return null;
|
|
44
|
+
const base = match[1].replace(/\.0(?=\d)/g, '.');
|
|
45
|
+
const build = match[2];
|
|
46
|
+
if (tagName.includes('jdk8u')) {
|
|
47
|
+
return { version: `8u${base.replace(/^8u?/, '')}b${build.padStart(2, '0')}`, tag: tagName };
|
|
48
|
+
}
|
|
49
|
+
return { version: `${base}+${build}`, tag: tagName };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function getLatestVersion(repo, major) {
|
|
53
|
+
const url = `https://api.github.com/repos/adoptium/${repo}/releases?per_page=5`;
|
|
54
|
+
const releases = await fetchJSON(url);
|
|
55
|
+
|
|
56
|
+
for (const release of releases) {
|
|
57
|
+
if (release.prerelease) continue;
|
|
58
|
+
const parsed = parseVersion(release.tag_name);
|
|
59
|
+
if (!parsed) continue;
|
|
60
|
+
|
|
61
|
+
const assets = {};
|
|
62
|
+
for (const asset of release.assets) {
|
|
63
|
+
for (const p of PLATFORMS) {
|
|
64
|
+
if (p.pattern.test(asset.name) && (asset.name.endsWith('.zip') || asset.name.endsWith('.tar.gz'))) {
|
|
65
|
+
assets[p.key] = asset.name;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (Object.keys(assets).length >= 3) {
|
|
71
|
+
return { ...parsed, major, assets };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function toToml(entry) {
|
|
78
|
+
let lines = [
|
|
79
|
+
`[[versions]]`,
|
|
80
|
+
`version = "${entry.version}"`,
|
|
81
|
+
`major = ${entry.major}`,
|
|
82
|
+
`lts = ${entry.lts}`,
|
|
83
|
+
`tag_name = "${entry.tag}"`,
|
|
84
|
+
`[versions.assets]`,
|
|
85
|
+
];
|
|
86
|
+
for (const [key, name] of Object.entries(entry.assets)) {
|
|
87
|
+
lines.push(`${key} = "${name}"`);
|
|
88
|
+
}
|
|
89
|
+
return lines.join('\n');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function main() {
|
|
93
|
+
console.log('🔍 查询 Adoptium 最新版本...');
|
|
94
|
+
|
|
95
|
+
const entries = [];
|
|
96
|
+
for (const { repo, major, lts } of REPOS) {
|
|
97
|
+
console.log(` 检查 ${repo}...`);
|
|
98
|
+
try {
|
|
99
|
+
const entry = await getLatestVersion(repo, major);
|
|
100
|
+
if (entry) {
|
|
101
|
+
entries.push({ ...entry, lts });
|
|
102
|
+
console.log(` ✅ Java ${major}: ${entry.version}`);
|
|
103
|
+
} else {
|
|
104
|
+
console.log(` ⚠️ Java ${major}: 未找到可用版本`);
|
|
105
|
+
}
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.log(` ❌ Java ${major}: ${e.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
entries.sort((a, b) => b.major - a.major);
|
|
112
|
+
|
|
113
|
+
const toml = entries.map(toToml).join('\n\n') + '\n';
|
|
114
|
+
|
|
115
|
+
const fs = require('fs');
|
|
116
|
+
const path = require('path');
|
|
117
|
+
const targetPath = path.join(__dirname, '..', 'config', 'java_versions.toml');
|
|
118
|
+
|
|
119
|
+
const existing = fs.readFileSync(targetPath, 'utf-8');
|
|
120
|
+
if (existing.trim() === toml.trim()) {
|
|
121
|
+
console.log('\n📋 版本注册表无变化');
|
|
122
|
+
process.exit(0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
fs.writeFileSync(targetPath, toml, 'utf-8');
|
|
126
|
+
console.log(`\n✅ 已更新 ${targetPath}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
main().catch((e) => {
|
|
130
|
+
console.error(e);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
});
|