diff --git a/lib/oto/commands/build/build_dart.dart b/lib/oto/commands/build/build_dart.dart index 0e558e6..988e377 100644 --- a/lib/oto/commands/build/build_dart.dart +++ b/lib/oto/commands/build/build_dart.dart @@ -19,12 +19,11 @@ class BuildDart extends Command { var data = DataBuildDart.fromJson(command.param); var workspace = getWorkspace(data.workspace); - var shell = StringBuffer(); - shell.write('cd $workspace'); - shell.write(' && flutter clean'); - shell.write(' && flutter pub upgrade --major-versions'); - shell.write(' && flutter packages upgrade'); - shell.write(' && flutter pub get'); + var shell = StringBuffer('cd $workspace'); + shell.write('&& flutter clean'); + shell.write('&& flutter pub upgrade --major-versions'); + shell.write('&& flutter packages upgrade'); + shell.write('&& flutter pub get'); if (data.executeBuildRunner == null ? true : data.executeBuildRunner!) { shell.write( ' && flutter pub run build_runner build --delete-conflicting-outputs'); diff --git a/lib/oto/commands/command.dart b/lib/oto/commands/command.dart index 9d36147..0438fbe 100644 --- a/lib/oto/commands/command.dart +++ b/lib/oto/commands/command.dart @@ -10,6 +10,7 @@ import 'package:oto_cli/oto/commands/build/build_dart_compile.dart'; import 'package:oto_cli/oto/commands/build/build_dot_net.dart'; import 'package:oto_cli/oto/commands/build/build_flutter.dart'; import 'package:oto_cli/oto/commands/build/build_ios.dart'; +import 'package:oto_cli/oto/commands/git/git.dart'; import 'package:oto_cli/oto/data/command_data.dart'; import 'package:oto_cli/oto/data/jenkins_data.dart'; import 'package:oto_cli/oto/commands/file/delete.dart'; @@ -41,7 +42,8 @@ enum CommandType { Slack, SlackBuild, Zip, - Shell + Shell, + Git } abstract class Command { @@ -64,7 +66,8 @@ abstract class Command { CommandType.Slack: Slack(), CommandType.SlackBuild: SlackBuild(), CommandType.Zip: Zip(), - CommandType.Shell: Shell() + CommandType.Shell: Shell(), + CommandType.Git: Git() }; factory Command.byType(CommandType type) { @@ -165,8 +168,6 @@ abstract class Command { class SimpleCommand extends Command { @override Future execute(DataCommand command) async { - var property = Application.instance.property; - var jenkins = Application.instance.jenkinsData; print(command.param); return simpleFuture; } diff --git a/lib/oto/commands/git/git.dart b/lib/oto/commands/git/git.dart index 50f7336..85596b3 100644 --- a/lib/oto/commands/git/git.dart +++ b/lib/oto/commands/git/git.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:oto_cli/oto/application.dart'; import 'package:oto_cli/oto/commands/command.dart'; import 'package:oto_cli/oto/data/command_data.dart'; import 'package:dart_framework/platform/process.dart'; @@ -8,15 +7,19 @@ import 'package:dart_framework/platform/process.dart'; class Git extends Command { @override Future execute(DataCommand command) async { - var data = DataExecuteApp.fromJson(command.param); + var data = DataGit.fromJson(command.param); + var workspace = getWorkspace(data.workspace); - var exe = replaceTag(data.executable); - var desktop = replaceTag(data.desktopServicePath); - print('Process Start: $exe'); - var content = 'start "" "$exe" & exit'; + var shell = StringBuffer('cd $workspace'); + var commands = data.commands; + for (var item in commands) { + shell.write('&& git ${getPathNormal(item)}'); + } - var buffer = StringBuffer(content); - var processData = await ProcessExecutor.run(buffer, workspace: desktop); - return complete(processData.exitCode, command); + var process = await ProcessExecutor.start(shell, + workspace: workspace, printStderr: false); + + return complete(await process.process.exitCode, command, + errorMessage: process.stderr.toString()); } } diff --git a/lib/oto/data/command_data.g.dart b/lib/oto/data/command_data.g.dart index f06dae0..678e280 100644 --- a/lib/oto/data/command_data.g.dart +++ b/lib/oto/data/command_data.g.dart @@ -53,6 +53,7 @@ const _$CommandTypeEnumMap = { CommandType.SlackBuild: 'SlackBuild', CommandType.Zip: 'Zip', CommandType.Shell: 'Shell', + CommandType.Git: 'Git', }; DataParam _$DataParamFromJson(Map json) =>