|
|
|
@ -1,4 +1,11 @@
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
|
import 'package:grinder/grinder.dart';
|
|
|
|
|
import 'package:yaml/yaml.dart';
|
|
|
|
|
import 'package:path/path.dart';
|
|
|
|
|
|
|
|
|
|
import 'config.dart';
|
|
|
|
|
|
|
|
|
|
main(args) => grind(args);
|
|
|
|
|
|
|
|
|
@ -16,30 +23,49 @@ clean() => defaultClean();
|
|
|
|
|
|
|
|
|
|
@Task()
|
|
|
|
|
buildApk() async {
|
|
|
|
|
await runAsync('flutter', arguments: [
|
|
|
|
|
await runAsync('fvm', arguments: [
|
|
|
|
|
'flutter',
|
|
|
|
|
'build',
|
|
|
|
|
'apk',
|
|
|
|
|
'--target-platform=android-arm64',
|
|
|
|
|
'--dart-define',
|
|
|
|
|
'ISPRODUCT=true'
|
|
|
|
|
]);
|
|
|
|
|
String date = DateUtil.formatDate(DateTime.now(), format: 'yy_MM_dd_HH_mm');
|
|
|
|
|
String version = await getVersion();
|
|
|
|
|
await runAsync('mv', arguments: [
|
|
|
|
|
Config.buildPath,
|
|
|
|
|
'${Config.buildDir}/${Config.packageName}_${version}_release_$date.apk'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Task()
|
|
|
|
|
buildApkDev() async {
|
|
|
|
|
await runAsync('flutter', arguments: [
|
|
|
|
|
await runAsync('fvm', arguments: [
|
|
|
|
|
'flutter',
|
|
|
|
|
'build',
|
|
|
|
|
'apk',
|
|
|
|
|
'--target-platform=android-arm64',
|
|
|
|
|
'--dart-define',
|
|
|
|
|
'ISPRODUCT=false'
|
|
|
|
|
]);
|
|
|
|
|
String date = DateUtil.formatDate(DateTime.now(), format: 'yy_MM_dd_HH_mm');
|
|
|
|
|
String version = await getVersion();
|
|
|
|
|
await runAsync('mv', arguments: [
|
|
|
|
|
Config.buildPath,
|
|
|
|
|
'${Config.buildDir}/${Config.packageName}_${version}_beta_$date.apk'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Task()
|
|
|
|
|
buildIos() async {
|
|
|
|
|
await runAsync('flutter',
|
|
|
|
|
arguments: ['build', 'ios', '--dart-define', 'BUILD_TYPE=PRODUCT']);
|
|
|
|
|
await runAsync('fvm', arguments: [
|
|
|
|
|
'flutter',
|
|
|
|
|
'build',
|
|
|
|
|
'ios',
|
|
|
|
|
'--dart-define',
|
|
|
|
|
'BUILD_TYPE=PRODUCT'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Task('import 排序')
|
|
|
|
@ -56,3 +82,13 @@ void format() {
|
|
|
|
|
void gen() async {
|
|
|
|
|
await Pub.run('build_runner', arguments: ['build']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Task()
|
|
|
|
|
Future<String> getVersion() async {
|
|
|
|
|
String projectPath = Directory('.').absolute.path;
|
|
|
|
|
String yamlPath = join(projectPath, 'pubspec.yaml');
|
|
|
|
|
String yamlContent = await File(yamlPath).readAsString();
|
|
|
|
|
dynamic content = loadYaml(yamlContent);
|
|
|
|
|
String version = content['version'];
|
|
|
|
|
return version;
|
|
|
|
|
}
|
|
|
|
|