pull/1/head
张萌 2 years ago
parent fd45bfda92
commit f7bf801c41

@ -17,8 +17,6 @@ main(args) => grind(args);
@Task('add minor version number') @Task('add minor version number')
void addVersion() async { void addVersion() async {
TaskArgs args = context.invocation.arguments;
bool force = args.getFlag('f');
String projectPath = Directory('.').absolute.path; String projectPath = Directory('.').absolute.path;
String yamlPath = join(projectPath, 'pubspec.yaml'); String yamlPath = join(projectPath, 'pubspec.yaml');
String yamlContent = await File(yamlPath).readAsString(); String yamlContent = await File(yamlPath).readAsString();
@ -31,13 +29,11 @@ void addVersion() async {
String result = yamlContent.replaceFirst(version, resultVersion.toString()); String result = yamlContent.replaceFirst(version, resultVersion.toString());
await File(yamlPath).writeAsString(result); await File(yamlPath).writeAsString(result);
stdout.write('version has been add 👍\n'); stdout.write('version has been add 👍\n');
await uploadVersion(force); await uploadVersion();
} }
@Task('add path version number') @Task('add path version number')
void addVersionPatch() async { void addVersionPatch() async {
TaskArgs args = context.invocation.arguments;
bool force = args.getFlag('f');
String projectPath = Directory('.').absolute.path; String projectPath = Directory('.').absolute.path;
String yamlPath = join(projectPath, 'pubspec.yaml'); String yamlPath = join(projectPath, 'pubspec.yaml');
String yamlContent = await File(yamlPath).readAsString(); String yamlContent = await File(yamlPath).readAsString();
@ -49,14 +45,12 @@ void addVersionPatch() async {
String result = yamlContent.replaceFirst(version, resultVersion.toString()); String result = yamlContent.replaceFirst(version, resultVersion.toString());
await File(yamlPath).writeAsString(result); await File(yamlPath).writeAsString(result);
stdout.write('version has been add 👍'); stdout.write('version has been add 👍\n');
await uploadVersion(force); await uploadVersion();
} }
@Task('add major version number') @Task('add major version number')
void addVersionMajor() async { void addVersionMajor() async {
TaskArgs args = context.invocation.arguments;
bool force = args.getFlag('f');
String projectPath = Directory('.').absolute.path; String projectPath = Directory('.').absolute.path;
String yamlPath = join(projectPath, 'pubspec.yaml'); String yamlPath = join(projectPath, 'pubspec.yaml');
String yamlContent = await File(yamlPath).readAsString(); String yamlContent = await File(yamlPath).readAsString();
@ -68,14 +62,12 @@ void addVersionMajor() async {
String result = yamlContent.replaceFirst(version, resultVersion.toString()); String result = yamlContent.replaceFirst(version, resultVersion.toString());
await File(yamlPath).writeAsString(result); await File(yamlPath).writeAsString(result);
stdout.write('version has been add 👍'); stdout.write('version has been add 👍\n');
await uploadVersion(force); await uploadVersion();
} }
@Task() @Task()
Future<String> getVersion() async { Future<String> getVersion() async {
TaskArgs args = context.invocation.arguments;
bool force = args.getFlag('f');
String projectPath = Directory('.').absolute.path; String projectPath = Directory('.').absolute.path;
String yamlPath = join(projectPath, 'pubspec.yaml'); String yamlPath = join(projectPath, 'pubspec.yaml');
String yamlContent = await File(yamlPath).readAsString(); String yamlContent = await File(yamlPath).readAsString();
@ -85,7 +77,9 @@ Future<String> getVersion() async {
} }
@Task() @Task()
Future uploadVersion(bool force) async { Future uploadVersion() async {
TaskArgs args = context.invocation.arguments;
bool force = args.getFlag('f');
var version = await getVersion(); var version = await getVersion();
List<String> spVersion = version.split('+'); List<String> spVersion = version.split('+');
stdout.write('版本号:' + spVersion[0] + '\n'); stdout.write('版本号:' + spVersion[0] + '\n');

Loading…
Cancel
Save