update static method
Implementation
static Future<void> update(
[bool isGit = false, bool forceUpdate = false]) async {
isGit = GenCli.arguments.contains('--git');
forceUpdate = GenCli.arguments.contains('-f');
if (!isGit && !forceUpdate) {
var versionInPubDev =
await PubDevApi.getLatestVersionFromPackage('gen_cli');
var versionInstalled = await PubspecLock.getVersionCli(disableLog: true);
if (versionInstalled == versionInPubDev) {
return LogService.info('您已安装 gen_cli 最新版本');
}
}
LogService.info('Upgrading gen_cli …');
try {
if (Platform.script.path.contains('flutter')) {
if (isGit) {
await run(
'flutter pub global activate -sgit https://github.com/jonataslaw/gen_cli/',
verbose: true);
} else {
await run('flutter pub global activate gen_cli', verbose: true);
}
} else {
if (isGit) {
await run(
'flutter pub global activate -sgit https://github.com/jonataslaw/gen_cli/',
verbose: true);
} else {
await run('flutter pub global activate gen_cli', verbose: true);
}
}
return LogService.success('升级完成');
} on Exception catch (err) {
LogService.info(err.toString());
return LogService.error('升级 gen_cli 错误');
}
}