Skip to content

Commit b89f1ac

Browse files
authored
fix(android): update list of KSP versions (#1963)
1 parent be651b4 commit b89f1ac

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

android/dependencies.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ static String getKspVersion(String kotlinVersion) {
55
def availableVersions = [
66
// Run `scripts/update-ksp-versions.mjs` to update this list
77
// update-ksp-versions start
8-
"1.9.22-1.0.17",
8+
"1.9.23-1.0.20",
9+
"1.9.22-1.0.18",
910
"1.9.21-1.0.16",
1011
"1.9.20-1.0.14",
1112
"1.9.10-1.0.13",

scripts/update-ksp-versions.mjs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
// @ts-check
33

44
import * as fs from "node:fs";
5-
import * as https from "node:https";
65

76
const dependenciesGradle = "android/dependencies.gradle";
87
const groupId = "com.google.devtools.ksp";
98
const artifactId = "com.google.devtools.ksp.gradle.plugin";
109
const rows = 50;
1110
const searchUrl = `https://search.maven.org/solrsearch/select?q=g:%22${groupId}%22+AND+a:%22${artifactId}%22&core=gav&rows=${rows}&wt=json`;
11+
const userAgent =
12+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51";
1213

1314
/**
1415
* @param {{ docs?: { id: string; g: string; a: string; v: string; }[]; }} response
@@ -54,32 +55,13 @@ function update(output, versions) {
5455
}
5556

5657
function main() {
57-
const options = {
58-
headers: {
59-
"User-Agent":
60-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51",
61-
},
62-
};
63-
64-
https
65-
.get(searchUrl, options, (res) => {
66-
if (res.statusCode !== 200) {
67-
const { statusCode, statusMessage } = res;
68-
console.error(`${searchUrl} -> ${statusCode}: ${statusMessage}`);
69-
process.exitCode = 1;
70-
return;
71-
}
72-
73-
/** @type {Buffer[]} */
74-
const data = [];
75-
res.on("data", (chunk) => data.push(chunk));
76-
res.on("end", () => {
77-
const { response } = JSON.parse(Buffer.concat(data).toString());
78-
const versions = extractVersions(response);
79-
update(dependenciesGradle, versions);
80-
});
58+
fetch(searchUrl, { headers: { "User-Agent": userAgent } })
59+
.then((res) => res.json())
60+
.then(({ response }) => {
61+
const versions = extractVersions(response);
62+
update(dependenciesGradle, versions);
8163
})
82-
.on("error", (e) => {
64+
.catch((e) => {
8365
console.error(e);
8466
process.exitCode = 1;
8567
});

0 commit comments

Comments
 (0)