-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Clean dependency and WSL Distribution Fetch
- Loading branch information
Showing
11 changed files
with
393 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import 'package:arche/arche.dart'; | ||
|
||
class AppConfigs { | ||
final ConfigEntry<T> Function<T>(String configKey) _generator; | ||
final ConfigEntry<T> Function<T>(String key) _generator; | ||
AppConfigs(ArcheConfig config) | ||
: _generator = ConfigEntry.withConfig(config, generateMap: true); | ||
|
||
ConfigEntry<String> get locale => _generator("locale"); | ||
ConfigEntry<String> get font => _generator("font"); | ||
ConfigEntry<String> get distroInfoUrl => _generator("distro_info_url"); | ||
static const defaultDistroInfoUrl = | ||
"https://raw.githubusercontent.com/microsoft/WSL/master/distributions/DistributionInfo.json"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:arche/arche.dart'; | ||
import 'package:wslconfigurer/models/config.dart'; | ||
|
||
class LinuxDistribution { | ||
late final String name; | ||
late final String friendlyName; | ||
late final String storeAppId; | ||
late final bool amd64; | ||
late final bool arm64; | ||
late final String? amd64PackageUrl; | ||
late final String? arm64PackageUrl; | ||
late final String packageFamilyName; | ||
static Future<List<LinuxDistribution>> fetch() async { | ||
var url = ArcheBus() | ||
.of<AppConfigs>() | ||
.distroInfoUrl | ||
.getOr(AppConfigs.defaultDistroInfoUrl); | ||
var request = await HttpClient().getUrl(Uri.parse(url)); | ||
var response = await request.close(); | ||
Iterable json = jsonDecode( | ||
await response.transform(utf8.decoder).join())["Distributions"]; | ||
|
||
return json | ||
.map( | ||
(distro) => LinuxDistribution() | ||
..name = distro["Name"] | ||
..friendlyName = distro["FriendlyName"] | ||
..storeAppId = distro["StoreAppId"] | ||
..amd64 = distro["Amd64"] | ||
..arm64 = distro["Arm64"] | ||
..amd64PackageUrl = distro["Amd64PackageUrl"] | ||
..arm64PackageUrl = distro["Arm64PackageUrl"] | ||
..packageFamilyName = distro["PackageFamilyName"], | ||
) | ||
.toList(); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return "LinuxDistribution: $name"; | ||
} | ||
} |
Empty file.
Oops, something went wrong.