Skip to content

Commit c8d2a48

Browse files
committed
feat: add android studio version completions
1 parent e85211d commit c8d2a48

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

completions-cron/src/__generated__/completions-index.ts

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/android/android-studios/android-studio.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class AndroidStudioResource extends Resource<AndroidStudioConfig> {
123123

124124
return {
125125
directory,
126-
version: installedVersion,
126+
...(installedVersion ? { version: installedVersion } : {}),
127127
};
128128
}
129129

@@ -250,12 +250,17 @@ export class AndroidStudioResource extends Resource<AndroidStudioConfig> {
250250
|| parameters.version === plist.CFBundleShortVersionString
251251
)
252252

253-
return matched.length > 0
254-
? {
255-
directory: path.dirname(matched[0].location),
256-
version: matched[0].webInfo?.version ?? matched[0].plist.CFBundleShortVersionString
257-
}
258-
: null;
253+
if (matched.length === 0) return null;
254+
255+
const best = matched[0];
256+
const version = best.webInfo?.version
257+
?? this.allAndroidStudioVersions?.find((v) => v.build === best.plist.CFBundleVersion)?.version
258+
?? best.plist.CFBundleShortVersionString;
259+
260+
return {
261+
directory: path.dirname(best.location),
262+
version,
263+
};
259264
}
260265

261266
private getVersionData(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { AndroidStudioVersionData } from '../types.js';
2+
3+
export default async function loadAndroidStudioVersions(): Promise<string[]> {
4+
const response = await fetch('https://jb.gg/android-studio-releases-list.json');
5+
6+
if (!response.ok) {
7+
throw new Error(`Failed to fetch Android Studio releases: ${response.status} ${await response.text()}`);
8+
}
9+
10+
const data = await response.json() as { content: { item: AndroidStudioVersionData[] } };
11+
12+
return data.content.item
13+
.filter((item) => item.channel === 'Release')
14+
.map((item) => item.version);
15+
}

0 commit comments

Comments
 (0)