-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupdateReadmeJava.ts
More file actions
19 lines (17 loc) · 932 Bytes
/
Copy pathupdateReadmeJava.ts
File metadata and controls
19 lines (17 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import axios from 'axios';
import * as fs from 'fs';
const RUNTIMES_CONFIG_NAME = 'java.configuration.runtimes';
const REDHAT_URL = 'https://raw.githubusercontent.com/redhat-developer/vscode-java/master/package.json';
const redhatJson = (await axios.get(REDHAT_URL)).data;
const configs = redhatJson.contributes?.configuration;
const config = configs.find(c => c.properties?.[RUNTIMES_CONFIG_NAME]);
const runtimeNames = config?.properties?.[RUNTIMES_CONFIG_NAME]?.items?.properties?.name?.enum ?? [];
const latestVer = runtimeNames.at(-1).replace(/^JavaSE-/, '');
console.log('RedHat support latest version:', latestVer);
const README_NAME = 'README.md';
const text = fs.readFileSync(README_NAME).toString();
const newText = text.replace(/(Java(?: |%20))\d+([ -]Ready)/ig, `$1${latestVer}$2`);
if (text !== newText) {
fs.writeFileSync(README_NAME, newText);
console.log('👉 Updated the latest Java version in README.md.');
}