张萌 4 years ago
commit 22695f9412

@ -6,13 +6,12 @@
import 'package:device_info_plus_web/device_info_plus_web.dart';
import 'package:firebase_core_web/firebase_core_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:image_picker_for_web/image_picker_for_web.dart';
import 'package:package_info_plus_web/package_info_plus_web.dart';
import 'package:shared_preferences_web/shared_preferences_web.dart';
import 'package:url_launcher_web/url_launcher_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
// ignore: public_member_api_docs
void registerPlugins(Registrar registrar) {
DeviceInfoPlusPlugin.registerWith(registrar);

@ -838,7 +838,7 @@ packages:
source: hosted
version: "5.0.0"
pub_semver:
dependency: transitive
dependency: "direct dev"
description:
name: pub_semver
url: "https://pub.flutter-io.cn"
@ -1174,7 +1174,7 @@ packages:
source: hosted
version: "5.1.0"
yaml:
dependency: transitive
dependency: "direct dev"
description:
name: yaml
url: "https://pub.flutter-io.cn"

@ -2,10 +2,10 @@ name: aku_community
description: A new Flutter project.
publish_to: "none"
version: 1.1.21-dev+27
version: 1.2.0-dev+37
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
@ -77,6 +77,8 @@ dev_dependencies:
flutter_native_splash: ^1.1.8+4
json_serializable: ^4.1.1
build_runner: ^2.0.2
yaml: ^3.1.0
pub_semver: ^2.0.0
flutter:
uses-material-design: true

@ -0,0 +1,28 @@
part of './grind.dart';
@Task('打包Android项目')
buildApk() async {
await runAsync(
'flutter',
arguments: [
'build',
'apk',
'--target-platform=android-arm64',
'--dart-define',
'BUILD_TYPE=PRODUCT',
],
);
}
@Task('打包iOS项目')
buildIos() async {
await runAsync(
'flutter',
arguments: [
'build',
'ios',
'--dart-define',
'BUILD_TYPE=PRODUCT',
],
);
}

@ -0,0 +1,35 @@
part of 'grind.dart';
@Task('import 排序')
void sort() {
Pub.run('import_sorter:main');
}
@Task('格式化dart代码')
void format() {
DartFmt.format(libDir);
}
@Task('自动提交修改')
@Depends(sort, format, gitPush)
void git() {
log(' commit to git');
run(
'git',
arguments: [
'commit',
'-a',
'-m',
'[auto task] sort & format',
],
);
}
@Task('推送代码')
void gitPush() {
log(' push to git');
run(
'git',
arguments: ['push'],
);
}

@ -1,61 +1,28 @@
import 'dart:io';
import 'package:grinder/grinder.dart';
import 'package:path/path.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';
main(args) => grind(args);
import 'version_tool.dart';
@Task()
test() => new TestRunner().testAsync();
part '_build.dart';
part '_project_manage.dart';
@Task()
buildApk() async {
await runAsync(
'flutter',
arguments: [
'build',
'apk',
'--target-platform=android-arm64',
'--dart-define',
'BUILD_TYPE=PRODUCT',
],
);
}
@Task('build ios')
buildIos() async {
await runAsync(
'flutter',
arguments: [
'build',
'ios',
'--dart-define',
'BUILD_TYPE=PRODUCT',
],
);
}
@Task()
clean() => defaultClean();
main(args) => grind(args);
@Task()
void sort() {
Pub.run('import_sorter:main');
}
@Task('add version number')
void addVersion() 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'];
//rename version
@Task()
void format() {
DartFmt.format(libDir);
}
Version resultVersion = VersionTool.fromText(version).nextMinorTag('dev');
@Task('auto sort and format code')
@Depends(sort, format)
void git() {
log(' commit to git');
run(
'git',
arguments: [
'commit',
'-a',
'-m',
'[auto task] sort & format',
],
);
String result = yamlContent.replaceFirst(version, resultVersion.toString());
await File(yamlPath).writeAsString(result);
}

@ -0,0 +1,59 @@
import 'package:pub_semver/pub_semver.dart';
enum VersionNumber {
MAJOR,
MINOR,
PATCH,
}
class VersionTool {
Version version;
VersionTool(this.version);
VersionTool.fromText(String text) : version = Version.parse(text);
Version get nextMajor => _addBuildNumber(VersionNumber.MAJOR);
Version get nextMinor => _addBuildNumber(VersionNumber.MINOR);
Version get nextPatch => _addBuildNumber(VersionNumber.PATCH);
Version nextMajorTag(String tag) => _addBuildNumber(
VersionNumber.MAJOR,
tag: tag,
);
Version nextMinorTag(String tag) => _addBuildNumber(
VersionNumber.MINOR,
tag: tag,
);
Version nextPatchTag(String tag) => _addBuildNumber(
VersionNumber.PATCH,
tag: tag,
);
Version _addBuildNumber(VersionNumber type, {String? tag}) {
switch (type) {
case VersionNumber.MAJOR:
return Version(
version.major,
version.minor,
version.patch + 1,
pre: tag,
build: '${(version.build.first as int) + 1}',
);
case VersionNumber.MINOR:
return Version(
version.major,
version.minor + 1,
0,
pre: tag,
build: '${(version.build.first as int) + 1}',
);
case VersionNumber.PATCH:
return Version(
version.major + 1,
0,
0,
pre: tag,
build: '${(version.build.first as int) + 1}',
);
}
}
}
Loading…
Cancel
Save