refactor(updates): pass typed runtime policy to deskup
This commit is contained in:
1 parent
1ef8edc8bc
commit
d83f94afd5
13 files changed
+158
-102
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import 'package:deskup/deskup.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// Values are compiled from Dart defines; process environment does not redirect production.
|
||||
MacOSUpdateConfiguration macosUpdateConfiguration() =>
|
||||
const MacOSUpdateConfiguration(
|
||||
allowLocalHttp:
|
||||
appFlavor == 'development' &&
|
||||
bool.fromEnvironment('CUTDEX_UPDATE_TEST_HTTP'),
|
||||
);
|
||||
|
||||
WindowsUpdateConfiguration? windowsUpdateConfiguration({
|
||||
String? flavor,
|
||||
String developmentUrl = const String.fromEnvironment(
|
||||
'CUTDEX_WINDOWS_UPDATE_URL',
|
||||
),
|
||||
String developmentSource = const String.fromEnvironment(
|
||||
'CUTDEX_WINDOWS_UPDATE_SOURCE',
|
||||
defaultValue: 'gitea',
|
||||
),
|
||||
bool allowLocalHttp = const bool.fromEnvironment('CUTDEX_UPDATE_TEST_HTTP'),
|
||||
}) {
|
||||
final development = (flavor ?? appFlavor) == 'development';
|
||||
if (development && developmentUrl.isEmpty) return null;
|
||||
final WindowsUpdateSource source;
|
||||
if (!development) {
|
||||
source = GiteaUpdateSource(
|
||||
repositoryUrl: Uri.parse('https://git.orangraph.com/lingjhf/cutdex'),
|
||||
);
|
||||
} else if (developmentSource == 'gitea') {
|
||||
source = GiteaUpdateSource(
|
||||
repositoryUrl: Uri.parse(developmentUrl),
|
||||
allowLocalHttp: allowLocalHttp,
|
||||
);
|
||||
} else if (developmentSource == 'web') {
|
||||
source = WebUpdateSource(
|
||||
url: Uri.parse(developmentUrl),
|
||||
allowLocalHttp: allowLocalHttp,
|
||||
);
|
||||
} else {
|
||||
throw ArgumentError.value(developmentSource, 'developmentSource');
|
||||
}
|
||||
return WindowsUpdateConfiguration(
|
||||
source: source,
|
||||
expectedPackageId: development ? 'Cutdex.Dev' : 'Cutdex',
|
||||
preferenceNamespace: 'Cutdex',
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user