update static method
Implementation
static Future<void> update(
[bool isGit = false, bool forceUpdate = false]) async {
isGit = GetCli.arguments.contains('--git');
forceUpdate = GetCli.arguments.contains('-f');
if (!isGit && !forceUpdate) {
var versionInPubDev =
await PubDevApi.getLatestVersionFromPackage('sunac_flutter_cli');
var versionInstalled = await PubspecLock.getVersionCli(disableLog: true);
if (versionInstalled == versionInPubDev) {
return LogService.info(
Translation(LocaleKeys.info_cli_last_version_already_installed.tr)
.toString());
}
}
LogService.info('Upgrading sunac_flutter_cli …');
try {
if (Platform.script.path.contains('flutter')) {
if (isGit) {
await run(
'flutter pub global activate -sgit https://github.com/nEdAy/sunac_flutter_cli/',
verbose: true);
} else {
await run('flutter pub global activate sunac_flutter_cli',
verbose: true);
}
} else {
if (isGit) {
await run(
'flutter pub global activate -sgit https://github.com/nEdAy/sunac_flutter_cli/',
verbose: true);
} else {
await run('flutter pub global activate sunac_flutter_cli',
verbose: true);
}
}
return LogService.success(LocaleKeys.success_update_cli.tr);
} on Exception catch (err) {
LogService.info(err.toString());
return LogService.error(LocaleKeys.error_update_cli.tr);
}
}