Refactor: Reorganize command structure and update related files

- Add command_registry.dart for centralized command registration
- Move util commands to appropriate directories (build, file, infra, notification)
- Update application.dart and all affected command files
This commit is contained in:
toki 2026-04-04 13:32:48 +09:00
parent 144f46bf65
commit 5066310567
41 changed files with 301 additions and 120 deletions

View file

@ -9,6 +9,7 @@ import 'package:dart_framework/utils/string_util.dart';
import 'package:dart_framework/utils/system_util.dart';
import 'package:oto_cli/cli/cli.dart';
import 'package:oto_cli/oto/commands/command.dart';
import 'package:oto_cli/oto/commands/command_registry.dart';
import 'package:oto_cli/oto/core/defined_data.dart';
import 'package:oto_cli/oto/pipeline/pipeline.dart';
import 'package:oto_cli/oto/data/command_data.dart';
@ -64,6 +65,7 @@ class Application {
_buildType = buildType;
_logEnable = logEnable;
setUTF8();
registerAllCommands();
DataBuild build;
DataComposer? composer;

View file

@ -22,3 +22,7 @@ class AwsCli extends Command {
return await completeProcess(process, command);
}
}
void registerAwsCliCommand() {
Command.register(CommandType.AwsCli, () => AwsCli());
}

View file

@ -20,3 +20,7 @@ class CreateAppData extends Command {
return complete(0, command);
}
}
void registerAppDataCreatorCommands() {
Command.register(CommandType.CreateAppData, () => CreateAppData());
}

View file

@ -34,3 +34,7 @@ class BuildDart extends Command {
return await completeProcess(process, command);
}
}
void registerBuildDartCommands() {
Command.register(CommandType.BuildDart, () => BuildDart());
}

View file

@ -2,6 +2,7 @@ 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/commands/command.dart';
import 'package:oto_cli/oto/data/command_data.dart';
// ignore: depend_on_referenced_packages
import 'package:path/path.dart' as path;
@ -54,3 +55,7 @@ class BuildDartCompile extends BuildDart {
}
}
}
void registerBuildDartCompileCommands() {
Command.register(CommandType.BuildDartCompile, () => BuildDartCompile());
}

View file

@ -24,3 +24,7 @@ class BuildDotNet extends Command {
return await completeProcess(process, command);
}
}
void registerBuildDotNetCommands() {
Command.register(CommandType.BuildDotNet, () => BuildDotNet());
}

View file

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:dart_framework/utils/system_util.dart';
import 'package:oto_cli/oto/commands/build/build_dart.dart';
import 'package:oto_cli/oto/commands/command.dart';
import 'package:oto_cli/oto/data/command_data.dart';
// ignore: constant_identifier_names
@ -22,3 +23,7 @@ class BuildFlutter extends BuildDart {
return dataFutrue(shell);
}
}
void registerBuildFlutterCommands() {
Command.register(CommandType.BuildFlutter, () => BuildFlutter());
}

View file

@ -569,3 +569,13 @@ class ExportiOS extends Command {
return await completeProcess(process, command);
}
}
void registerBuildIosCommands() {
Command.register(CommandType.BuildiOS, () => BuildiOS());
Command.register(CommandType.ArchiveiOS, () => ArchiveiOS());
Command.register(CommandType.ExportiOS, () => ExportiOS());
Command.register(CommandType.CodeSign, () => CodeSign());
Command.register(CommandType.CodeSignVerify, () => CodeSignVerify());
Command.register(CommandType.ProductBuild, () => ProductBuild());
Command.register(CommandType.Notarize, () => Notarize());
}

View file

@ -32,3 +32,7 @@ class BuildMSBuild extends Command {
return await completeProcess(process, command);
}
}
void registerBuildMsbuildCommands() {
Command.register(CommandType.BuildMSBuild, () => BuildMSBuild());
}

View file

@ -51,3 +51,7 @@ class PublishiOS extends Command {
return complete(0, command);
}
}
void registerPublishIosCommands() {
Command.register(CommandType.PublishiOS, () => PublishiOS());
}

View file

@ -107,3 +107,9 @@ class TestflightDistribute extends Command {
return await completeProcess(process, command, passExitCodes: [1]);
}
}
void registerTestflightCommands() {
Command.register(CommandType.TestflightUpload, () => TestflightUpload());
Command.register(CommandType.TestflightStatusCheck, () => TestflightStatusCheck());
Command.register(CommandType.TestflightDistribute, () => TestflightDistribute());
}

View file

@ -55,3 +55,7 @@ puts "✅ {ADD_FILE_PATH} 파일이 프로젝트에 추가되고, Copy Bundle Re
return await completeProcess(process, command);
}
}
void registerXcodeprojCommands() {
Command.register(CommandType.XcodeprojAddFile, () => XcodeprojAddFile());
}

View file

@ -6,46 +6,8 @@ import 'package:dart_framework/platform/process.dart';
import 'package:dart_framework/utils/path.dart';
import 'package:dart_framework/utils/system_util.dart';
import 'package:oto_cli/oto/application.dart';
import 'package:oto_cli/oto/commands/build/app_data_creator.dart';
import 'package:oto_cli/oto/commands/build/build_dart.dart';
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/build/build_msbuild.dart';
import 'package:oto_cli/oto/commands/build/testflight_ios.dart';
import 'package:oto_cli/oto/commands/build/xcodeproj.dart';
import 'package:oto_cli/oto/commands/file/directory.dart';
import 'package:oto_cli/oto/commands/file/file.dart';
import 'package:oto_cli/oto/commands/file/file_diff_check.dart';
import 'package:oto_cli/oto/commands/ftp/download.dart';
import 'package:oto_cli/oto/commands/git/git.dart';
import 'package:oto_cli/oto/commands/aws/awscli.dart';
import 'package:oto_cli/oto/commands/docker/docker.dart';
import 'package:oto_cli/oto/commands/git/git_hub.dart';
import 'package:oto_cli/oto/commands/gradle/gradle.dart';
import 'package:oto_cli/oto/commands/jenkins/jenkins.dart';
import 'package:oto_cli/oto/commands/jira/jira.dart';
import 'package:oto_cli/oto/commands/process/process.dart';
import 'package:oto_cli/oto/commands/proto/protobuf.dart';
import 'package:oto_cli/oto/commands/util/json.dart';
import 'package:oto_cli/oto/commands/notification/mattermost.dart';
import 'package:oto_cli/oto/commands/util/print.dart';
import 'package:oto_cli/oto/commands/util/set_value.dart';
import 'package:oto_cli/oto/commands/infra/smb_authorize.dart';
import 'package:oto_cli/oto/commands/util/string_util.dart';
import 'package:oto_cli/oto/commands/util/timer.dart';
import 'package:oto_cli/oto/commands/web/web.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';
import 'package:oto_cli/oto/commands/file/rename.dart';
import 'package:oto_cli/oto/commands/shell/shell.dart';
import 'package:oto_cli/oto/commands/file/copy.dart';
import 'package:oto_cli/oto/commands/build/publish_ios.dart';
import 'package:oto_cli/oto/commands/notification/slack.dart';
import 'package:oto_cli/oto/commands/file/zip.dart';
import 'package:oto_cli/oto/commands/ftp/upload.dart';
import 'package:oto_cli/oto/pipeline/pipeline_exe_handle.dart';
enum CommandType {
@ -128,87 +90,19 @@ enum CommandType {
}
abstract class Command {
static final Map<CommandType, Command Function()> _commandMap = {
CommandType.SimpleCommand: () => SimpleCommand(),
CommandType.Print: () => PrintCommand(),
CommandType.SetValue: () => SetValueCommand(),
CommandType.CreateAppData: () => CreateAppData(),
CommandType.BuildDart: () => BuildDart(),
CommandType.BuildFlutter: () => BuildFlutter(),
CommandType.BuildDartCompile: () => BuildDartCompile(),
CommandType.BuildDotNet: () => BuildDotNet(),
CommandType.BuildiOS: () => BuildiOS(),
CommandType.TestflightUpload: () => TestflightUpload(),
CommandType.TestflightStatusCheck: () => TestflightStatusCheck(),
CommandType.TestflightDistribute: () => TestflightDistribute(),
CommandType.XcodeprojAddFile: () => XcodeprojAddFile(),
CommandType.BuildMSBuild: () => BuildMSBuild(),
CommandType.CodeSign: () => CodeSign(),
CommandType.CodeSignVerify: () => CodeSignVerify(),
CommandType.ProductBuild: () => ProductBuild(),
CommandType.Notarize: () => Notarize(),
CommandType.ArchiveiOS: () => ArchiveiOS(),
CommandType.ExportiOS: () => ExportiOS(),
CommandType.PublishiOS: () => PublishiOS(),
CommandType.Upload: () => Upload(),
CommandType.Download: () => Download(),
CommandType.Copy: () => Copy(),
CommandType.Rename: () => Rename(),
CommandType.Delete: () => Delete(),
CommandType.FileDiffCheck: () => FileDiffCheck(),
CommandType.FileRead: () => FileRead(),
CommandType.FileWrite: () => FileWrite(),
CommandType.Files: () => Files(),
CommandType.FileInfo: () => FileInfo(),
CommandType.DirectoryCreate: () => DirectoryCreate(),
CommandType.Slack: () => Slack(),
CommandType.SlackFile: () => SlackFile(),
CommandType.SlackBuild: () => SlackBuild(),
CommandType.Mattermost: () => Mattermost(),
CommandType.MattermostBuild: () => MattermostBuild(),
CommandType.StringSub: () => StringSub(),
CommandType.StringReplace: () => StringReplace(),
CommandType.StringReplacePattern: () => StringReplacePattern(),
CommandType.StringIndex: () => StringIndex(),
CommandType.URLInfo: () => URLInfo(),
CommandType.Jira: () => Jira(),
CommandType.Zip: () => Zip(),
CommandType.Shell: () => Shell(),
CommandType.ShellFile: () => ShellFile(),
CommandType.Git: () => Git(),
CommandType.GitCommit: () => GitCommit(),
CommandType.GitPull: () => GitPull(),
CommandType.GitPush: () => GitPush(),
CommandType.GitCheckout: () => GitCheckout(),
CommandType.GitRev: () => GitRev(),
CommandType.GitCount: () => GitCount(),
CommandType.GitReset: () => GitReset(),
CommandType.GitStashPush: () => GitStashPush(),
CommandType.GitStashApply: () => GitStashApply(),
CommandType.GitBranch: () => GitBranch(),
CommandType.GitHub: () => GitHub(),
CommandType.GitHubPullRequestCreate: () => GitHubPullRequestCreate(),
CommandType.GitHubPullRequestList: () => GitHubPullRequestList(),
CommandType.GitHubPullRequestClose: () => GitHubPullRequestClose(),
CommandType.Protobuf: () => Protobuf(),
CommandType.JsonReader: () => JsonReader(),
CommandType.JsonReaderFile: () => JsonReaderFile(),
CommandType.JsonWriterFile: () => JsonWriterFile(),
CommandType.AwsCli: () => AwsCli(),
CommandType.Docker: () => Docker(),
CommandType.Gradle: () => Gradle(),
CommandType.WebRequest: () => WebRequest(),
CommandType.WebFile: () => WebFile(),
CommandType.ProcessPortUse: () => ProcessPortUse(),
CommandType.ProcessRun: () => ProcessRun(),
CommandType.ProcessKill: () => ProcessKill(),
CommandType.SMBAuth: () => SMBAuth(),
CommandType.Delay: () => Delay(),
CommandType.JenkinsParameterModify: () => JenkinsParameterModify(),
};
static final Map<CommandType, Command Function()> _commandMap = {};
static void register(CommandType type, Command Function() factory) {
_commandMap[type] = factory;
}
factory Command.byType(CommandType type) {
return _commandMap[type]!();
final factory = _commandMap[type];
if (factory == null) {
throw StateError(
'Command "$type" is not registered. Did you call registerAllCommands()?');
}
return factory();
}
Command();

View file

@ -0,0 +1,97 @@
import 'package:oto_cli/oto/commands/aws/awscli.dart';
import 'package:oto_cli/oto/commands/build/app_data_creator.dart';
import 'package:oto_cli/oto/commands/build/build_dart.dart';
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/build/build_msbuild.dart';
import 'package:oto_cli/oto/commands/build/publish_ios.dart';
import 'package:oto_cli/oto/commands/build/testflight_ios.dart';
import 'package:oto_cli/oto/commands/build/xcodeproj.dart';
import 'package:oto_cli/oto/commands/command.dart';
import 'package:oto_cli/oto/commands/docker/docker.dart';
import 'package:oto_cli/oto/commands/file/copy.dart';
import 'package:oto_cli/oto/commands/file/delete.dart';
import 'package:oto_cli/oto/commands/file/directory.dart';
import 'package:oto_cli/oto/commands/file/file.dart';
import 'package:oto_cli/oto/commands/file/file_diff_check.dart';
import 'package:oto_cli/oto/commands/file/rename.dart';
import 'package:oto_cli/oto/commands/file/zip.dart';
import 'package:oto_cli/oto/commands/ftp/download.dart';
import 'package:oto_cli/oto/commands/ftp/upload.dart';
import 'package:oto_cli/oto/commands/git/git.dart';
import 'package:oto_cli/oto/commands/git/git_hub.dart';
import 'package:oto_cli/oto/commands/gradle/gradle.dart';
import 'package:oto_cli/oto/commands/infra/smb_authorize.dart';
import 'package:oto_cli/oto/commands/jenkins/jenkins.dart';
import 'package:oto_cli/oto/commands/jira/jira.dart';
import 'package:oto_cli/oto/commands/notification/mattermost.dart';
import 'package:oto_cli/oto/commands/notification/slack.dart';
import 'package:oto_cli/oto/commands/process/process.dart';
import 'package:oto_cli/oto/commands/proto/protobuf.dart';
import 'package:oto_cli/oto/commands/shell/shell.dart';
import 'package:oto_cli/oto/commands/util/json.dart';
import 'package:oto_cli/oto/commands/util/print.dart';
import 'package:oto_cli/oto/commands/util/set_value.dart';
import 'package:oto_cli/oto/commands/util/string_util.dart';
import 'package:oto_cli/oto/commands/util/timer.dart';
import 'package:oto_cli/oto/commands/web/web.dart';
void registerAllCommands() {
Command.register(CommandType.SimpleCommand, () => SimpleCommand());
// build
registerBuildIosCommands();
registerTestflightCommands();
registerXcodeprojCommands();
registerAppDataCreatorCommands();
registerBuildDartCommands();
registerBuildDartCompileCommands();
registerBuildDotNetCommands();
registerBuildFlutterCommands();
registerBuildMsbuildCommands();
registerPublishIosCommands();
// git
registerGitCommands();
registerGitHubCommands();
// notification
registerSlackCommands();
registerMattermostCommands();
// file
registerCopyCommand();
registerDeleteCommand();
registerRenameCommand();
registerDirectoryCommand();
registerFileCommands();
registerFileDiffCheckCommand();
registerZipCommand();
// ftp
registerFtpUploadCommand();
registerFtpDownloadCommand();
// util
registerPrintCommand();
registerSetValueCommand();
registerStringUtilCommands();
registerJsonCommands();
registerTimerCommand();
// shell / process / infra
registerShellCommands();
registerProcessCommands();
registerInfraCommands();
// external services
registerJiraCommand();
registerProtobufCommand();
registerAwsCliCommand();
registerDockerCommand();
registerGradleCommand();
registerWebCommands();
registerJenkinsCommands();
}

View file

@ -23,3 +23,7 @@ class Docker extends Command {
return await completeProcess(process, command);
}
}
void registerDockerCommand() {
Command.register(CommandType.Docker, () => Docker());
}

View file

@ -76,3 +76,7 @@ class Copy extends Command {
return complete(0, command);
}
}
void registerCopyCommand() {
Command.register(CommandType.Copy, () => Copy());
}

View file

@ -59,3 +59,7 @@ class Delete extends Command {
return complete(0, command);
}
}
void registerDeleteCommand() {
Command.register(CommandType.Delete, () => Delete());
}

View file

@ -17,4 +17,7 @@ class DirectoryCreate extends Command {
}
return complete(0, command);
}
}
}
void registerDirectoryCommand() {
Command.register(CommandType.DirectoryCreate, () => DirectoryCreate());
}

View file

@ -106,3 +106,10 @@ class FileInfo extends Command {
}
}
}
void registerFileCommands() {
Command.register(CommandType.FileRead, () => FileRead());
Command.register(CommandType.FileWrite, () => FileWrite());
Command.register(CommandType.Files, () => Files());
Command.register(CommandType.FileInfo, () => FileInfo());
}

View file

@ -123,3 +123,7 @@ class FileDiffCheck extends Command {
return hex.encode(digest.bytes);
}
}
void registerFileDiffCheckCommand() {
Command.register(CommandType.FileDiffCheck, () => FileDiffCheck());
}

View file

@ -35,3 +35,7 @@ class Rename extends Command {
return complete(0, command);
}
}
void registerRenameCommand() {
Command.register(CommandType.Rename, () => Rename());
}

View file

@ -76,3 +76,7 @@ class Zip extends Command {
return complete(0, command);
}
}
void registerZipCommand() {
Command.register(CommandType.Zip, () => Zip());
}

View file

@ -43,3 +43,7 @@ class Download extends Command {
return complete(0, command);
}
}
void registerFtpDownloadCommand() {
Command.register(CommandType.Download, () => Download());
}

View file

@ -72,3 +72,7 @@ class Upload extends Command {
return complete(0, command);
}
}
void registerFtpUploadCommand() {
Command.register(CommandType.Upload, () => Upload());
}

View file

@ -292,3 +292,17 @@ class GitBranch extends Command {
return await completeProcess(process, command);
}
}
void registerGitCommands() {
Command.register(CommandType.Git, () => Git());
Command.register(CommandType.GitCommit, () => GitCommit());
Command.register(CommandType.GitPull, () => GitPull());
Command.register(CommandType.GitPush, () => GitPush());
Command.register(CommandType.GitCheckout, () => GitCheckout());
Command.register(CommandType.GitRev, () => GitRev());
Command.register(CommandType.GitCount, () => GitCount());
Command.register(CommandType.GitReset, () => GitReset());
Command.register(CommandType.GitStashPush, () => GitStashPush());
Command.register(CommandType.GitStashApply, () => GitStashApply());
Command.register(CommandType.GitBranch, () => GitBranch());
}

View file

@ -122,3 +122,10 @@ class GitHubPullRequestClose extends Command {
return await completeProcess(process, command);
}
}
void registerGitHubCommands() {
Command.register(CommandType.GitHub, () => GitHub());
Command.register(CommandType.GitHubPullRequestCreate, () => GitHubPullRequestCreate());
Command.register(CommandType.GitHubPullRequestList, () => GitHubPullRequestList());
Command.register(CommandType.GitHubPullRequestClose, () => GitHubPullRequestClose());
}

View file

@ -22,3 +22,7 @@ class Gradle extends Command {
return await completeProcess(process, command);
}
}
void registerGradleCommand() {
Command.register(CommandType.Gradle, () => Gradle());
}

View file

@ -23,3 +23,7 @@ class SMBAuth extends Command {
return complete(process.exitCode, command);
}
}
void registerInfraCommands() {
Command.register(CommandType.SMBAuth, () => SMBAuth());
}

View file

@ -63,3 +63,7 @@ class JenkinsParameterModify extends Command {
return await complete(0, command);
}
}
void registerJenkinsCommands() {
Command.register(CommandType.JenkinsParameterModify, () => JenkinsParameterModify());
}

View file

@ -121,4 +121,7 @@ class Jira extends Command {
return simpleFuture;
}
}
}
void registerJiraCommand() {
Command.register(CommandType.Jira, () => Jira());
}

View file

@ -95,3 +95,8 @@ class MattermostBuild extends Command {
return complete(0, command);
}
}
void registerMattermostCommands() {
Command.register(CommandType.Mattermost, () => Mattermost());
Command.register(CommandType.MattermostBuild, () => MattermostBuild());
}

View file

@ -77,3 +77,9 @@ class SlackBuild extends Command {
return complete(0, command);
}
}
void registerSlackCommands() {
Command.register(CommandType.Slack, () => Slack());
Command.register(CommandType.SlackFile, () => SlackFile());
Command.register(CommandType.SlackBuild, () => SlackBuild());
}

View file

@ -57,3 +57,9 @@ class ProcessKill extends Command {
return complete(0, command);
}
}
void registerProcessCommands() {
Command.register(CommandType.ProcessPortUse, () => ProcessPortUse());
Command.register(CommandType.ProcessRun, () => ProcessRun());
Command.register(CommandType.ProcessKill, () => ProcessKill());
}

View file

@ -21,3 +21,7 @@ class Protobuf extends Command {
return await completeProcess(process, command);
}
}
void registerProtobufCommand() {
Command.register(CommandType.Protobuf, () => Protobuf());
}

View file

@ -56,3 +56,8 @@ class ShellFile extends Command {
return success;
}
}
void registerShellCommands() {
Command.register(CommandType.Shell, () => Shell());
Command.register(CommandType.ShellFile, () => ShellFile());
}

View file

@ -134,3 +134,9 @@ class JsonWriterFile extends Command {
return complete(0, command);
}
}
void registerJsonCommands() {
Command.register(CommandType.JsonReader, () => JsonReader());
Command.register(CommandType.JsonReaderFile, () => JsonReaderFile());
Command.register(CommandType.JsonWriterFile, () => JsonWriterFile());
}

View file

@ -15,3 +15,7 @@ class PrintCommand extends Command {
return complete(0, command);
}
}
void registerPrintCommand() {
Command.register(CommandType.Print, () => PrintCommand());
}

View file

@ -85,3 +85,7 @@ class SetValueCommand extends Command {
return '<@property.$key>';
}
}
void registerSetValueCommand() {
Command.register(CommandType.SetValue, () => SetValueCommand());
}

View file

@ -113,3 +113,11 @@ class URLInfo extends Command {
}
}
void registerStringUtilCommands() {
Command.register(CommandType.StringSub, () => StringSub());
Command.register(CommandType.StringReplace, () => StringReplace());
Command.register(CommandType.StringReplacePattern, () => StringReplacePattern());
Command.register(CommandType.StringIndex, () => StringIndex());
Command.register(CommandType.URLInfo, () => URLInfo());
}

View file

@ -32,4 +32,7 @@ class Delay extends Command {
return await complete(0, command);
}
}
}
void registerTimerCommand() {
Command.register(CommandType.Delay, () => Delay());
}

View file

@ -80,3 +80,8 @@ class WebFile extends WebBase {
return await complete(await super.request(data, form), command);
}
}
void registerWebCommands() {
Command.register(CommandType.WebRequest, () => WebRequest());
Command.register(CommandType.WebFile, () => WebFile());
}