update for windows support
This commit is contained in:
parent
06a3cdf6fa
commit
f8bc54fcc5
18 changed files with 163 additions and 122 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:dart_framework/core/application.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/cli/cli.dart';
|
||||
import 'package:oto_cli/cli/commands/command_scheduler.dart';
|
||||
|
|
@ -7,8 +8,13 @@ import 'package:oto_cli/cli/commands/command_exe.dart';
|
|||
// import 'package:oto_cli/cli/commands/command_start.dart';
|
||||
|
||||
void main(List<String> arguments) async {
|
||||
await initialize('oto', 'com.toki-labs.oto');
|
||||
Application('oto', 'com.toki-labs.oto', () {
|
||||
print(and);
|
||||
|
||||
CLI.initialize(
|
||||
'oto', arguments, [CommandTemplate(), CommandExe(), CommandScheduler()]);
|
||||
CLI.initialize('oto', arguments,
|
||||
[CommandTemplate(), CommandExe(), CommandScheduler()]);
|
||||
}, (error, stack) {
|
||||
print(error);
|
||||
print(stack);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,10 @@ class CommandExe extends CommandBase {
|
|||
return simpleFuture;
|
||||
}
|
||||
|
||||
Future executeScheduler(DataBuild build, bool logEnable, String logPath) async {
|
||||
_handler = IsolateManager.create(IsolateExe.scheduler(build, logEnable, logPath));
|
||||
Future executeScheduler(
|
||||
DataBuild build, bool logEnable, String logPath) async {
|
||||
_handler =
|
||||
IsolateManager.create(IsolateExe.scheduler(build, logEnable, logPath));
|
||||
await isComplete();
|
||||
_handler.exit();
|
||||
return simpleFuture;
|
||||
|
|
@ -99,20 +101,30 @@ class IsolateExe extends IsolateBase {
|
|||
String? _yamleContent = null;
|
||||
String? _logPath = null;
|
||||
|
||||
IsolateExe(this._buildType, {String? yamlContent, DataBuild? build, bool logEnable = true, String? logPath}) {
|
||||
IsolateExe(this._buildType,
|
||||
{String? yamlContent,
|
||||
DataBuild? build,
|
||||
bool logEnable = true,
|
||||
String? logPath}) {
|
||||
_yamleContent = yamlContent;
|
||||
_build = build;
|
||||
_logEnable = logEnable;
|
||||
_logPath = logPath;
|
||||
}
|
||||
|
||||
factory IsolateExe.scheduler(DataBuild build, bool logEnable, String logPath) {
|
||||
return IsolateExe(BuildType.scheduler, build: build, logEnable: logEnable, logPath: logPath);
|
||||
factory IsolateExe.scheduler(
|
||||
DataBuild build, bool logEnable, String logPath) {
|
||||
return IsolateExe(BuildType.scheduler,
|
||||
build: build, logEnable: logEnable, logPath: logPath);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady(Object? initData) async {
|
||||
await Application.instance.build(_buildType, yamlContent: _yamleContent, buildData: _build, logEnable: _logEnable, logPath: _logPath);
|
||||
await Application.instance.build(_buildType,
|
||||
yamlContent: _yamleContent,
|
||||
buildData: _build,
|
||||
logEnable: _logEnable,
|
||||
logPath: _logPath);
|
||||
send(IsoMessege('complete'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ import 'package:path/path.dart' as path;
|
|||
|
||||
class SchedulerManager {
|
||||
static String get _schedulerPath {
|
||||
var debugPath = isDebug ? '.debug' : '';
|
||||
return '$dataPath$debugPath/scheduler';
|
||||
return '$dataPath/scheduler';
|
||||
}
|
||||
|
||||
static String get _logsPath {
|
||||
|
|
|
|||
|
|
@ -1,26 +1,24 @@
|
|||
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
||||
class AwsCli extends Command {
|
||||
|
||||
@override
|
||||
Future execute(DataCommand command) async {
|
||||
DataAwsCli data = DataAwsCli.fromJson(getParam(command));
|
||||
String subCommand = data.subCommand;
|
||||
List<String> args = data.args;
|
||||
|
||||
|
||||
StringBuffer shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && aws $subCommand');
|
||||
shell.write(' $and aws $subCommand');
|
||||
for (String arg in args) {
|
||||
shell.write(' $arg');
|
||||
}
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ class BuildDart extends Command {
|
|||
var data = DataBuildDart.fromJson(getParam(command));
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && flutter clean');
|
||||
shell.write(' && flutter pub upgrade --major-versions');
|
||||
shell.write(' && flutter packages upgrade');
|
||||
shell.write(' && flutter pub get');
|
||||
shell.write(' $and flutter clean');
|
||||
shell.write(' $and flutter pub upgrade --major-versions');
|
||||
shell.write(' $and flutter packages upgrade');
|
||||
shell.write(' $and flutter pub get');
|
||||
if (data.executeBuildRunner == null ? true : data.executeBuildRunner!) {
|
||||
shell.write(
|
||||
' && flutter pub run build_runner build --delete-conflicting-outputs');
|
||||
' $and flutter pub run build_runner build --delete-conflicting-outputs');
|
||||
}
|
||||
|
||||
var process = await ProcessExecutor.start(await appendShell(shell, command),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/commands/build/build_dart.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
|
|
@ -40,7 +41,7 @@ class BuildDartCompile extends BuildDart {
|
|||
preBuildFile.deleteSync();
|
||||
}
|
||||
|
||||
shell.write(' && dart compile exe "$targetDartFile" -o "$buildPath"');
|
||||
shell.write(' $and dart compile exe "$targetDartFile" -o "$buildPath"');
|
||||
c.complete(shell);
|
||||
return c.future;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -13,10 +14,12 @@ class BuildDotNet extends Command {
|
|||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(
|
||||
' && MSBuild ${data.projectFile} /t:build /p:Configuration=Release;Platform=x86');
|
||||
' $and MSBuild ${data.projectFile} /t:build /p:Configuration=Release;Platform=x86');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace, printStderr: false, logHandler: Application.logWithType);
|
||||
workspace: workspace,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ class BuildFlutter extends BuildDart {
|
|||
data.platform.toString().replaceAll('BuildPlatform.', '').toLowerCase();
|
||||
var additional = data.additional == null ? '' : ' ${data.additional!}';
|
||||
if (data.macPassword != null) {
|
||||
shell.write(' && security unlock-keychain -p${data.macPassword}');
|
||||
shell.write(' $and security unlock-keychain -p${data.macPassword}');
|
||||
}
|
||||
shell.write(' && flutter build $platform$additional');
|
||||
shell.write(' $and flutter build $platform$additional');
|
||||
return dataFutrue(shell);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ class BuildiOS extends Command {
|
|||
shell.write(
|
||||
' && xcodebuild $project -scheme ${data.scheme} -destination $destination$configuration$derivedDataPath$settings clean build');
|
||||
|
||||
var process = await ProcessExecutor.start(shell, printStderr: false, logHandler: Application.logWithType);
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
printStderr: false, logHandler: Application.logWithType);
|
||||
var exitCode = await process.process.exitCode;
|
||||
var success = exitCode == 0;
|
||||
if (success) {
|
||||
|
|
@ -108,7 +109,9 @@ class CodeSign extends Command {
|
|||
' && codesign --deep --force --verify --verbose --timestamp --options runtime$entitlement --sign "${data.certificationName}" "${data.appPath}"');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace, printStderr: false, logHandler: Application.logWithType);
|
||||
workspace: workspace,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
@ -125,7 +128,9 @@ class CodeSignVerify extends Command {
|
|||
shell.write(' && spctl --assess --verbose "${data.appPath}"');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace, printStderr: false, logHandler: Application.logWithType);
|
||||
workspace: workspace,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
@ -150,7 +155,9 @@ class ProductBuild extends Command {
|
|||
' && productsign --sign "${data.installCertificationName}" "${data.unsignedResultPath}" "${data.signedResultPath}"');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace, printStderr: false, logHandler: Application.logWithType);
|
||||
workspace: workspace,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
@ -189,7 +196,9 @@ class Notarize extends Command {
|
|||
}
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace, printStderr: false, logHandler: Application.logWithType);
|
||||
workspace: workspace,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
@ -210,7 +219,9 @@ class ArchiveiOS extends Command {
|
|||
'xcodebuild -workspace $workspacePath -scheme ${data.scheme} -destination $destination -archivePath $archivePath archive');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace, printStderr: false, logHandler: Application.logWithType);
|
||||
workspace: workspace,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
@ -232,7 +243,9 @@ class ExportiOS extends Command {
|
|||
'xcodebuild -exportArchive -archivePath $archivePath -exportPath $exportPath -exportOptionsPlist $exportOptionPlistPath');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
workspace: workspace, printStderr: false, logHandler: Application.logWithType);
|
||||
workspace: workspace,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -22,10 +23,12 @@ class BuildMSBuild extends Command {
|
|||
'${data.projectFile} /p:Configuration=${data.config.name} /p:Platform=x64 /t:${data.type.name}';
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && msbuild $param');
|
||||
shell.write(' $and msbuild $param');
|
||||
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
decoder: SystemEncoding().decoder, printStderr: false, logHandler: Application.logWithType);
|
||||
decoder: SystemEncoding().decoder,
|
||||
printStderr: false,
|
||||
logHandler: Application.logWithType);
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ abstract class Command {
|
|||
String getCDPath(String path) {
|
||||
String drive = '';
|
||||
if (Platform.isWindows) {
|
||||
drive = '${path[0]}: && ';
|
||||
drive = '${path[0]}: $and ';
|
||||
}
|
||||
return '${drive}cd $path';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
||||
class Docker extends Command {
|
||||
|
||||
@override
|
||||
Future execute(DataCommand command) async {
|
||||
DataDocker data = DataDocker.fromJson(getParam(command));
|
||||
|
|
@ -13,14 +12,14 @@ class Docker extends Command {
|
|||
List<String> args = data.args;
|
||||
|
||||
StringBuffer shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && docker $dockerCommand');
|
||||
|
||||
shell.write(' $and docker $dockerCommand');
|
||||
|
||||
for (String arg in args) {
|
||||
shell.write(' $arg');
|
||||
}
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -12,10 +13,11 @@ class Git extends Command {
|
|||
var shell = StringBuffer(getCDPath(workspace));
|
||||
var commands = data.commands;
|
||||
for (var item in commands) {
|
||||
shell.write(' && git ${Command.getPathNormal(item)}');
|
||||
shell.write(' $and git ${Command.getPathNormal(item)}');
|
||||
}
|
||||
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
|
|
@ -30,13 +32,14 @@ class GitCommit extends Command {
|
|||
var addNewFile = data.addNewFile == null ? false : data.addNewFile!;
|
||||
var message = data.message;
|
||||
|
||||
if(addNewFile) {
|
||||
shell.write(' && git add -A && git commit -m "$message"');
|
||||
if (addNewFile) {
|
||||
shell.write(' $and git add -A $and git commit -m "$message"');
|
||||
} else {
|
||||
shell.write(' && git commit -am "$message"');
|
||||
shell.write(' $and git commit -am "$message"');
|
||||
}
|
||||
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
|
|
@ -49,12 +52,13 @@ class GitPush extends Command {
|
|||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
if (data.branch == null) {
|
||||
shell.write(' && git push');
|
||||
shell.write(' $and git push');
|
||||
} else {
|
||||
shell.write(' && git push origin ${data.branch!}');
|
||||
shell.write(' $and git push origin ${data.branch!}');
|
||||
}
|
||||
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
return await completeProcess(process, command,
|
||||
passExitCodes: [1 /*Everything up-to-date*/]);
|
||||
}
|
||||
|
|
@ -68,10 +72,11 @@ class GitCheckout extends Git {
|
|||
var branch = data.branch;
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && git checkout origin/$branch');
|
||||
shell.write(' && git checkout -b $branch');
|
||||
shell.write(' $and git checkout origin/$branch');
|
||||
shell.write(' $and git checkout -b $branch');
|
||||
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var exitCode = await process.process.exitCode;
|
||||
var ignores = [128 /*Already exists*/];
|
||||
if (ignores.contains(exitCode)) {
|
||||
|
|
@ -80,13 +85,14 @@ class GitCheckout extends Git {
|
|||
|
||||
if (exitCode == 0) {
|
||||
shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && git checkout $branch');
|
||||
shell.write(' $and git checkout $branch');
|
||||
|
||||
if (data.executePull == null ? true : data.executePull!) {
|
||||
shell.write(' && git pull origin $branch');
|
||||
shell.write(' $and git pull origin $branch');
|
||||
}
|
||||
|
||||
process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
process = await ProcessExecutor.start(shell,
|
||||
logHandler: Application.logWithType);
|
||||
exitCode = await process.process.exitCode;
|
||||
}
|
||||
|
||||
|
|
@ -101,8 +107,9 @@ class GitCount extends Command {
|
|||
var data = DataGitCount.fromJson(getParam(command));
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && git rev-list --all HEAD --all --count');
|
||||
var process = await ProcessExecutor.start(shell, printStderr: false, logHandler: Application.logWithType);
|
||||
shell.write(' $and git rev-list --all HEAD --all --count');
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
printStderr: false, logHandler: Application.logWithType);
|
||||
var number = int.parse(process.stdoutArr.last);
|
||||
await setProperty(data.setValue, number);
|
||||
|
||||
|
|
@ -118,9 +125,10 @@ class GitRev extends Command {
|
|||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
var target = data.branch ?? 'HEAD';
|
||||
shell.write(' && git fetch origin');
|
||||
shell.write(' && git rev-parse $target');
|
||||
var process = await ProcessExecutor.start(shell, printStderr: false, logHandler: Application.logWithType);
|
||||
shell.write(' $and git fetch origin');
|
||||
shell.write(' $and git rev-parse $target');
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
printStderr: false, logHandler: Application.logWithType);
|
||||
var hash = process.stdoutArr.last;
|
||||
await setProperty(data.setValue, hash);
|
||||
|
||||
|
|
@ -136,9 +144,10 @@ class GitReset extends Command {
|
|||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
var force = data.force! ? 'f' : '';
|
||||
shell.write(' && git reset --hard');
|
||||
shell.write(' && git clean -${force}d');
|
||||
var process = await ProcessExecutor.start(shell, printStderr: false, logHandler: Application.logWithType);
|
||||
shell.write(' $and git reset --hard');
|
||||
shell.write(' $and git clean -${force}d');
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
printStderr: false, logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
@ -155,7 +164,7 @@ class GitStashPush extends Command {
|
|||
? " -u"
|
||||
: (data.includeUntracked! ? " -u" : "");
|
||||
var message = data.message == null ? "" : " -m '${data.message}'";
|
||||
shell.write(' && git stash push$includeUntracked$message');
|
||||
shell.write(' $and git stash push$includeUntracked$message');
|
||||
var process = await ProcessExecutor.run(shell);
|
||||
if (data.setSuccess != null) {
|
||||
setProperty(
|
||||
|
|
@ -176,10 +185,11 @@ class GitStashApply extends Command {
|
|||
var apply =
|
||||
data.delete == null ? " pop" : (data.delete! ? " pop" : " apply");
|
||||
if (data.message == null) {
|
||||
shell.write(' && git stash$apply');
|
||||
process = await ProcessExecutor.start(shell, printStderr: false, logHandler: Application.logWithType);
|
||||
shell.write(' $and git stash$apply');
|
||||
process = await ProcessExecutor.start(shell,
|
||||
printStderr: false, logHandler: Application.logWithType);
|
||||
} else {
|
||||
shell.write(' && git stash list');
|
||||
shell.write(' $and git stash list');
|
||||
var result = await ProcessExecutor.run(shell);
|
||||
var exist = false;
|
||||
Application.log(result.stdout);
|
||||
|
|
@ -192,7 +202,7 @@ class GitStashApply extends Command {
|
|||
var id = lineArr[0];
|
||||
var content = lineArr[1];
|
||||
if (content.contains(data.message!)) {
|
||||
shell.write(' && git stash$apply $id');
|
||||
shell.write(' $and git stash$apply $id');
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -201,7 +211,8 @@ class GitStashApply extends Command {
|
|||
}
|
||||
|
||||
if (exist) {
|
||||
process = await ProcessExecutor.start(shell, printStderr: false, logHandler: Application.logWithType);
|
||||
process = await ProcessExecutor.start(shell,
|
||||
printStderr: false, logHandler: Application.logWithType);
|
||||
} else {
|
||||
return await complete(0, command);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -16,10 +17,11 @@ class GitHub extends Command {
|
|||
var shell = StringBuffer(getCDPath(workspace));
|
||||
var commands = data.commands;
|
||||
for (var item in commands) {
|
||||
shell.write(' && gh ${Command.getPathNormal(item)}');
|
||||
shell.write(' $and gh ${Command.getPathNormal(item)}');
|
||||
}
|
||||
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
|
@ -31,29 +33,26 @@ class GitHubPullRequestCreate extends Command {
|
|||
var data = DataGitHubPullRequestCreate.fromJson(getParam(command));
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && gh pr create --title "${data.title}" --body "${data.body}" -B ${data.branch}');
|
||||
shell.write(
|
||||
' $and gh pr create --title "${data.title}" --body "${data.body}" -B ${data.branch}');
|
||||
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var passExitCodes = [0, 1 /*already exists*/];
|
||||
var exitCode = await process.process.exitCode;
|
||||
if(passExitCodes.contains(exitCode))
|
||||
{
|
||||
if (passExitCodes.contains(exitCode)) {
|
||||
var resultMessage = '';
|
||||
if(exitCode == 1)
|
||||
{
|
||||
if (exitCode == 1) {
|
||||
resultMessage = process.stderr.toString().replaceAll('\n', '');
|
||||
var startIndex = resultMessage.indexOf(':') + 1;
|
||||
resultMessage = resultMessage.substring(startIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
resultMessage = process.stdout.toString().replaceAll('\n', '');
|
||||
}
|
||||
|
||||
String? url = null;
|
||||
String? number = null;
|
||||
if(!resultMessage.contains('GraphQL: No commits'))
|
||||
{
|
||||
if (!resultMessage.contains('GraphQL: No commits')) {
|
||||
var num = resultMessage.substring(resultMessage.lastIndexOf('/') + 1);
|
||||
url = resultMessage;
|
||||
number = num.toString();
|
||||
|
|
@ -62,7 +61,8 @@ class GitHubPullRequestCreate extends Command {
|
|||
await setProperty(data.setNumber, number);
|
||||
}
|
||||
|
||||
return await completeProcess(process, command, passExitCodes: passExitCodes);
|
||||
return await completeProcess(process, command,
|
||||
passExitCodes: passExitCodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,45 +71,37 @@ class GitHubPullRequestList extends Command {
|
|||
Future execute(DataCommand command) async {
|
||||
var data = DataGitHubPullRequestList.fromJson(getParam(command));
|
||||
|
||||
if(data.keys.isEmpty) throw Exception('keys not exist');
|
||||
if (data.keys.isEmpty) throw Exception('keys not exist');
|
||||
var keysString = data.keys.join(',');
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && gh pr list --json $keysString');
|
||||
shell.write(' $and gh pr list --json $keysString');
|
||||
|
||||
var decorder = Platform.isWindows ? SystemEncoding().decoder : utf8.decoder;
|
||||
var process = await ProcessExecutor.start(shell, decoder: decorder, logHandler: Application.logWithType);
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
decoder: decorder, logHandler: Application.logWithType);
|
||||
var exitCode = await process.process.exitCode;
|
||||
|
||||
if(exitCode == 0)
|
||||
{
|
||||
if (exitCode == 0) {
|
||||
Map<String, dynamic>? target = null;
|
||||
var jsonRaw = process.stdout.toString();
|
||||
jsonRaw = jsonRaw.substring(jsonRaw.indexOf('['));
|
||||
List<dynamic> list = jsonDecode(jsonRaw) as List<dynamic>;
|
||||
for(Map<String, dynamic> item in list)
|
||||
{
|
||||
if(item.containsKey(data.targetKey))
|
||||
{
|
||||
if(item[data.targetKey] == data.targetValue)
|
||||
{
|
||||
for (Map<String, dynamic> item in list) {
|
||||
if (item.containsKey(data.targetKey)) {
|
||||
if (item[data.targetKey] == data.targetValue) {
|
||||
target = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(target == null)
|
||||
{
|
||||
if (target == null) {
|
||||
await setProperty(data.setValue, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
await setProperty(data.setValue, jsonEncode(target));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
await setProperty(data.setValue, null);
|
||||
}
|
||||
return await completeProcess(process, command);
|
||||
|
|
@ -122,10 +114,11 @@ class GitHubPullRequestClose extends Command {
|
|||
var data = DataGitHubPullRequestClose.fromJson(getParam(command));
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && gh pr close ${data.number}');
|
||||
shell.write(' $and gh pr close ${data.number}');
|
||||
|
||||
var decorder = Platform.isWindows ? SystemEncoding().decoder : utf8.decoder;
|
||||
var process = await ProcessExecutor.start(shell, decoder: decorder, logHandler: Application.logWithType);
|
||||
var process = await ProcessExecutor.start(shell,
|
||||
decoder: decorder, logHandler: Application.logWithType);
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,24 @@
|
|||
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
||||
class Gradle extends Command {
|
||||
|
||||
@override
|
||||
Future execute(DataCommand command) async {
|
||||
DataGradle data = DataGradle.fromJson(getParam(command));
|
||||
List<String> args = data.args;
|
||||
|
||||
StringBuffer shell = StringBuffer(getCDPath(workspace));
|
||||
shell.write(' && gradle');
|
||||
|
||||
shell.write(' $and gradle');
|
||||
|
||||
for (String arg in args) {
|
||||
shell.write(' $arg');
|
||||
}
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -32,7 +33,7 @@ class ProcessRun extends Command {
|
|||
var dontKillme =
|
||||
Platform.isWindows ? 'SET BUILD_ID=dontKillMe' : 'BUILD_ID=dontKillMe';
|
||||
var param = data.param == null ? '' : ' ${data.param}';
|
||||
shell.writeln(' && $dontKillme && $exe$param');
|
||||
shell.writeln(' $and $dontKillme $and $exe$param');
|
||||
var file =
|
||||
File('${Directory.systemTemp.path}/${ProcessExecutor.tempFileName}');
|
||||
await file.writeAsString(shell.toString());
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -11,11 +12,12 @@ class Protobuf extends Command {
|
|||
var shell = StringBuffer(getCDPath(workspace));
|
||||
var commands = data.commands;
|
||||
for (var item in commands) {
|
||||
shell.write(' && protoc ${Command.getPathNormal(item)}');
|
||||
shell.write(' $and protoc ${Command.getPathNormal(item)}');
|
||||
}
|
||||
|
||||
var process = await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
var process =
|
||||
await ProcessExecutor.start(shell, logHandler: Application.logWithType);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:dart_framework/platform/process.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -12,7 +13,7 @@ class Shell extends Command {
|
|||
var shell = StringBuffer(getCDPath(workspace));
|
||||
var commands = data.commands;
|
||||
for (var item in commands) {
|
||||
shell.write(' && $item');
|
||||
shell.write(' $and $item');
|
||||
}
|
||||
|
||||
var process =
|
||||
|
|
|
|||
Loading…
Reference in a new issue