diff --git a/di/di.go b/di/di.go deleted file mode 100644 index 5b333a0b..00000000 --- a/di/di.go +++ /dev/null @@ -1,46 +0,0 @@ -//+build wireinject - -// Package di provides dependency injection. -package di - -import ( - "github.com/google/wire" - "github.com/int128/ghcp/adaptors/cmd" - "github.com/int128/ghcp/adaptors/env" - "github.com/int128/ghcp/adaptors/fs" - githubAdaptor "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/infrastructure/github" - "github.com/int128/ghcp/usecases/commit" - "github.com/int128/ghcp/usecases/forkcommit" - "github.com/int128/ghcp/usecases/gitobject" - "github.com/int128/ghcp/usecases/pullrequest" - "github.com/int128/ghcp/usecases/release" -) - -func NewCmd() cmd.Interface { - wire.Build( - cmd.Set, - logger.Set, - github.Set, - env.Set, - - wire.Value(cmd.NewInternalRunnerFunc(NewCmdInternalRunner)), - ) - return nil -} - -func NewCmdInternalRunner(logger.Interface, github.Interface) *cmd.InternalRunner { - wire.Build( - cmd.Set, - fs.Set, - githubAdaptor.Set, - - gitobject.Set, - commit.Set, - forkcommit.Set, - pullrequest.Set, - release.Set, - ) - return nil -} diff --git a/main.go b/main.go index 7e2c39ca..d7f98838 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/int128/ghcp/di" + "github.com/int128/ghcp/pkg/di" ) var version = "HEAD" diff --git a/adaptors/cmd/cmd.go b/pkg/cmd/cmd.go similarity index 89% rename from adaptors/cmd/cmd.go rename to pkg/cmd/cmd.go index abbc762b..ed6ed5cb 100644 --- a/adaptors/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -6,13 +6,13 @@ import ( "fmt" "github.com/google/wire" - "github.com/int128/ghcp/adaptors/env" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/infrastructure/github" - "github.com/int128/ghcp/usecases/commit" - "github.com/int128/ghcp/usecases/forkcommit" - "github.com/int128/ghcp/usecases/pullrequest" - "github.com/int128/ghcp/usecases/release" + "github.com/int128/ghcp/pkg/env" + "github.com/int128/ghcp/pkg/github/client" + "github.com/int128/ghcp/pkg/logger" + "github.com/int128/ghcp/pkg/usecases/commit" + "github.com/int128/ghcp/pkg/usecases/forkcommit" + "github.com/int128/ghcp/pkg/usecases/pullrequest" + "github.com/int128/ghcp/pkg/usecases/release" "github.com/spf13/cobra" "github.com/spf13/pflag" "golang.org/x/xerrors" @@ -47,7 +47,7 @@ type Interface interface { type Runner struct { Env env.Interface NewLogger logger.NewFunc - NewGitHub github.NewFunc + NewGitHub client.NewFunc NewInternalRunner NewInternalRunnerFunc } @@ -100,7 +100,7 @@ func (r *Runner) newRootCmd(o *globalOptions) *cobra.Command { return c } -type NewInternalRunnerFunc func(logger.Interface, github.Interface) *InternalRunner +type NewInternalRunnerFunc func(logger.Interface, client.Interface) *InternalRunner // InternalRunner has the set of use-cases. type InternalRunner struct { @@ -134,7 +134,7 @@ func (r *Runner) newInternalRunner(o *globalOptions) (*InternalRunner, error) { log.Debugf("Using GitHub Enterprise URL from environment variable $%s", envGitHubAPI) } } - gh, err := r.NewGitHub(github.Option{ + gh, err := r.NewGitHub(client.Option{ Token: o.GitHubToken, URLv3: o.GitHubAPI, }) diff --git a/adaptors/cmd/cmd_test.go b/pkg/cmd/cmd_test.go similarity index 90% rename from adaptors/cmd/cmd_test.go rename to pkg/cmd/cmd_test.go index f1ec8a5c..b8085c4c 100644 --- a/adaptors/cmd/cmd_test.go +++ b/pkg/cmd/cmd_test.go @@ -7,20 +7,20 @@ import ( "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" - "github.com/int128/ghcp/adaptors/env/mock_env" - "github.com/int128/ghcp/adaptors/logger" - testingLogger "github.com/int128/ghcp/adaptors/logger/testing" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/infrastructure/github" - "github.com/int128/ghcp/usecases/commit" - "github.com/int128/ghcp/usecases/commit/mock_commit" - "github.com/int128/ghcp/usecases/forkcommit" - "github.com/int128/ghcp/usecases/forkcommit/mock_forkcommit" - "github.com/int128/ghcp/usecases/pullrequest" - "github.com/int128/ghcp/usecases/pullrequest/mock_pullrequest" - "github.com/int128/ghcp/usecases/release" - "github.com/int128/ghcp/usecases/release/mock_release" + "github.com/int128/ghcp/pkg/env/mock_env" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/github/client" + "github.com/int128/ghcp/pkg/logger" + testingLogger "github.com/int128/ghcp/pkg/logger/testing" + "github.com/int128/ghcp/pkg/usecases/commit" + "github.com/int128/ghcp/pkg/usecases/commit/mock_commit" + "github.com/int128/ghcp/pkg/usecases/forkcommit" + "github.com/int128/ghcp/pkg/usecases/forkcommit/mock_forkcommit" + "github.com/int128/ghcp/pkg/usecases/pullrequest" + "github.com/int128/ghcp/pkg/usecases/pullrequest/mock_pullrequest" + "github.com/int128/ghcp/pkg/usecases/release" + "github.com/int128/ghcp/pkg/usecases/release/mock_release" ) func TestCmd_Run(t *testing.T) { @@ -43,7 +43,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -78,7 +78,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -114,7 +114,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -151,7 +151,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -178,7 +178,7 @@ func TestCmd_Run(t *testing.T) { defer ctrl.Finish() r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, nil), NewInternalRunner: newInternalRunner(InternalRunner{}), } @@ -206,7 +206,7 @@ func TestCmd_Run(t *testing.T) { defer ctrl.Finish() r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, nil), NewInternalRunner: newInternalRunner(InternalRunner{}), } @@ -231,7 +231,7 @@ func TestCmd_Run(t *testing.T) { defer ctrl.Finish() r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, nil), NewInternalRunner: newInternalRunner(InternalRunner{}), } @@ -266,7 +266,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -302,7 +302,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -338,7 +338,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -372,7 +372,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{ForkCommitUseCase: commitUseCase}), } @@ -407,7 +407,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{ForkCommitUseCase: commitUseCase}), } @@ -444,7 +444,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{PullRequestUseCase: useCase}), } @@ -477,7 +477,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{PullRequestUseCase: useCase}), } @@ -515,7 +515,7 @@ func TestCmd_Run(t *testing.T) { }) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{ReleaseUseCase: releaseUseCase}), } @@ -554,7 +554,7 @@ func TestCmd_Run(t *testing.T) { Do(ctx, input) r := Runner{ NewLogger: newLogger(t, logger.Option{Debug: true}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -586,7 +586,7 @@ func TestCmd_Run(t *testing.T) { Chdir("dir") r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: mockEnv, NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -615,7 +615,7 @@ func TestCmd_Run(t *testing.T) { Do(ctx, input) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN"}), Env: newEnv(ctrl, map[string]string{envGitHubToken: "YOUR_TOKEN", envGitHubAPI: ""}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -639,7 +639,7 @@ func TestCmd_Run(t *testing.T) { defer ctrl.Finish() r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{}), + NewGitHub: newGitHub(t, client.Option{}), Env: newEnv(ctrl, map[string]string{envGitHubToken: ""}), NewInternalRunner: newInternalRunner(InternalRunner{}), } @@ -666,7 +666,7 @@ func TestCmd_Run(t *testing.T) { Do(ctx, input) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN", URLv3: "https://github.example.com/api/v3/"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN", URLv3: "https://github.example.com/api/v3/"}), Env: newEnv(ctrl, nil), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -695,7 +695,7 @@ func TestCmd_Run(t *testing.T) { Do(ctx, input) r := Runner{ NewLogger: newLogger(t, logger.Option{}), - NewGitHub: newGitHub(t, github.Option{Token: "YOUR_TOKEN", URLv3: "https://github.example.com/api/v3/"}), + NewGitHub: newGitHub(t, client.Option{Token: "YOUR_TOKEN", URLv3: "https://github.example.com/api/v3/"}), Env: newEnv(ctrl, map[string]string{envGitHubAPI: "https://github.example.com/api/v3/"}), NewInternalRunner: newInternalRunner(InternalRunner{CommitUseCase: commitUseCase}), } @@ -726,8 +726,8 @@ func newLogger(t *testing.T, want logger.Option) logger.NewFunc { } } -func newGitHub(t *testing.T, want github.Option) github.NewFunc { - return func(got github.Option) (github.Interface, error) { +func newGitHub(t *testing.T, want client.Option) client.NewFunc { + return func(got client.Option) (client.Interface, error) { if diff := cmp.Diff(want, got); diff != "" { t.Errorf("mismatch (-want +got):\n%s", diff) } @@ -744,7 +744,7 @@ func newEnv(ctrl *gomock.Controller, getenv map[string]string) *mock_env.MockInt } func newInternalRunner(base InternalRunner) NewInternalRunnerFunc { - return func(l logger.Interface, g github.Interface) *InternalRunner { + return func(l logger.Interface, g client.Interface) *InternalRunner { base.Logger = l return &base } diff --git a/adaptors/cmd/commit.go b/pkg/cmd/commit.go similarity index 96% rename from adaptors/cmd/commit.go rename to pkg/cmd/commit.go index 9e4ca173..4514bb25 100644 --- a/adaptors/cmd/commit.go +++ b/pkg/cmd/commit.go @@ -8,9 +8,9 @@ import ( "github.com/spf13/pflag" "golang.org/x/xerrors" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/usecases/commit" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/usecases/commit" ) const commitCmdExample = ` To commit files to the default branch: diff --git a/adaptors/cmd/commit_attribute_options.go b/pkg/cmd/commit_attribute_options.go similarity index 97% rename from adaptors/cmd/commit_attribute_options.go rename to pkg/cmd/commit_attribute_options.go index b78f4b90..759bf87d 100644 --- a/adaptors/cmd/commit_attribute_options.go +++ b/pkg/cmd/commit_attribute_options.go @@ -4,7 +4,7 @@ import ( "github.com/spf13/pflag" "golang.org/x/xerrors" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" ) type commitAttributeOptions struct { diff --git a/adaptors/cmd/empty_commit.go b/pkg/cmd/empty_commit.go similarity index 96% rename from adaptors/cmd/empty_commit.go rename to pkg/cmd/empty_commit.go index 38c32db1..e4085e02 100644 --- a/adaptors/cmd/empty_commit.go +++ b/pkg/cmd/empty_commit.go @@ -8,9 +8,9 @@ import ( "github.com/spf13/pflag" "golang.org/x/xerrors" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/usecases/commit" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/usecases/commit" ) const emptyCommitCmdExample = ` To create an empty commit to the default branch: diff --git a/adaptors/cmd/forkcommit.go b/pkg/cmd/forkcommit.go similarity index 95% rename from adaptors/cmd/forkcommit.go rename to pkg/cmd/forkcommit.go index b2230027..1ea54387 100644 --- a/adaptors/cmd/forkcommit.go +++ b/pkg/cmd/forkcommit.go @@ -8,9 +8,9 @@ import ( "github.com/spf13/pflag" "golang.org/x/xerrors" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/usecases/forkcommit" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/usecases/forkcommit" ) func (r *Runner) newForkCommitCmd(ctx context.Context, gOpts *globalOptions) *cobra.Command { diff --git a/adaptors/cmd/pull_request.go b/pkg/cmd/pull_request.go similarity index 97% rename from adaptors/cmd/pull_request.go rename to pkg/cmd/pull_request.go index 405482ae..3c084b22 100644 --- a/adaptors/cmd/pull_request.go +++ b/pkg/cmd/pull_request.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/usecases/pullrequest" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/usecases/pullrequest" "github.com/spf13/cobra" "github.com/spf13/pflag" "golang.org/x/xerrors" diff --git a/adaptors/cmd/release.go b/pkg/cmd/release.go similarity index 96% rename from adaptors/cmd/release.go rename to pkg/cmd/release.go index ade96cb2..6d341ee6 100644 --- a/adaptors/cmd/release.go +++ b/pkg/cmd/release.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/usecases/release" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/usecases/release" "github.com/spf13/cobra" "github.com/spf13/pflag" "golang.org/x/xerrors" diff --git a/pkg/di/di.go b/pkg/di/di.go new file mode 100644 index 00000000..0f566092 --- /dev/null +++ b/pkg/di/di.go @@ -0,0 +1,46 @@ +//+build wireinject + +// Package di provides dependency injection. +package di + +import ( + "github.com/google/wire" + "github.com/int128/ghcp/pkg/cmd" + "github.com/int128/ghcp/pkg/env" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/github/client" + "github.com/int128/ghcp/pkg/logger" + "github.com/int128/ghcp/pkg/usecases/commit" + "github.com/int128/ghcp/pkg/usecases/forkcommit" + "github.com/int128/ghcp/pkg/usecases/gitobject" + "github.com/int128/ghcp/pkg/usecases/pullrequest" + "github.com/int128/ghcp/pkg/usecases/release" +) + +func NewCmd() cmd.Interface { + wire.Build( + cmd.Set, + logger.Set, + client.Set, + env.Set, + + wire.Value(cmd.NewInternalRunnerFunc(NewCmdInternalRunner)), + ) + return nil +} + +func NewCmdInternalRunner(logger.Interface, client.Interface) *cmd.InternalRunner { + wire.Build( + cmd.Set, + fs.Set, + github.Set, + + gitobject.Set, + commit.Set, + forkcommit.Set, + pullrequest.Set, + release.Set, + ) + return nil +} diff --git a/di/wire_gen.go b/pkg/di/wire_gen.go similarity index 65% rename from di/wire_gen.go rename to pkg/di/wire_gen.go index 012fa862..9bf36a6e 100644 --- a/di/wire_gen.go +++ b/pkg/di/wire_gen.go @@ -6,17 +6,17 @@ package di import ( - "github.com/int128/ghcp/adaptors/cmd" - "github.com/int128/ghcp/adaptors/env" - "github.com/int128/ghcp/adaptors/fs" - github2 "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/infrastructure/github" - "github.com/int128/ghcp/usecases/commit" - "github.com/int128/ghcp/usecases/forkcommit" - "github.com/int128/ghcp/usecases/gitobject" - "github.com/int128/ghcp/usecases/pullrequest" - "github.com/int128/ghcp/usecases/release" + "github.com/int128/ghcp/pkg/cmd" + "github.com/int128/ghcp/pkg/env" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/github/client" + "github.com/int128/ghcp/pkg/logger" + "github.com/int128/ghcp/pkg/usecases/commit" + "github.com/int128/ghcp/pkg/usecases/forkcommit" + "github.com/int128/ghcp/pkg/usecases/gitobject" + "github.com/int128/ghcp/pkg/usecases/pullrequest" + "github.com/int128/ghcp/pkg/usecases/release" ) // Injectors from di.go: @@ -24,12 +24,12 @@ import ( func NewCmd() cmd.Interface { envEnv := &env.Env{} newFunc := _wireNewFuncValue - githubNewFunc := _wireGithubNewFuncValue + clientNewFunc := _wireClientNewFuncValue newInternalRunnerFunc := _wireNewInternalRunnerFuncValue runner := &cmd.Runner{ Env: envEnv, NewLogger: newFunc, - NewGitHub: githubNewFunc, + NewGitHub: clientNewFunc, NewInternalRunner: newInternalRunnerFunc, } return runner @@ -37,14 +37,14 @@ func NewCmd() cmd.Interface { var ( _wireNewFuncValue = logger.NewFunc(logger.New) - _wireGithubNewFuncValue = github.NewFunc(github.New) + _wireClientNewFuncValue = client.NewFunc(client.New) _wireNewInternalRunnerFuncValue = cmd.NewInternalRunnerFunc(NewCmdInternalRunner) ) -func NewCmdInternalRunner(loggerInterface logger.Interface, githubInterface github.Interface) *cmd.InternalRunner { +func NewCmdInternalRunner(loggerInterface logger.Interface, clientInterface client.Interface) *cmd.InternalRunner { fileSystem := &fs.FileSystem{} - gitHub := &github2.GitHub{ - Client: githubInterface, + gitHub := &github.GitHub{ + Client: clientInterface, Logger: loggerInterface, } createGitObject := &gitobject.CreateGitObject{ diff --git a/adaptors/env/env.go b/pkg/env/env.go similarity index 93% rename from adaptors/env/env.go rename to pkg/env/env.go index 0bdbedfc..9cf7ac04 100644 --- a/adaptors/env/env.go +++ b/pkg/env/env.go @@ -11,7 +11,7 @@ var Set = wire.NewSet( wire.Bind(new(Interface), new(*Env)), ) -//go:generate mockgen -destination mock_env/mock_env.go github.com/int128/ghcp/adaptors/env Interface +//go:generate mockgen -destination mock_env/mock_env.go github.com/int128/ghcp/pkg/env Interface type Interface interface { Getenv(key string) string diff --git a/adaptors/env/mock_env/mock_env.go b/pkg/env/mock_env/mock_env.go similarity index 96% rename from adaptors/env/mock_env/mock_env.go rename to pkg/env/mock_env/mock_env.go index 8058cd35..90d5d98c 100644 --- a/adaptors/env/mock_env/mock_env.go +++ b/pkg/env/mock_env/mock_env.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/adaptors/env (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/env (interfaces: Interface) // Package mock_env is a generated GoMock package. package mock_env diff --git a/adaptors/fs/fs.go b/pkg/fs/fs.go similarity index 98% rename from adaptors/fs/fs.go rename to pkg/fs/fs.go index 4ba5afa8..35d3e327 100644 --- a/adaptors/fs/fs.go +++ b/pkg/fs/fs.go @@ -16,7 +16,7 @@ var Set = wire.NewSet( wire.Bind(new(Interface), new(*FileSystem)), ) -//go:generate mockgen -destination mock_fs/mock_fs.go github.com/int128/ghcp/adaptors/fs Interface +//go:generate mockgen -destination mock_fs/mock_fs.go github.com/int128/ghcp/pkg/fs Interface type Interface interface { FindFiles(paths []string, filter FindFilesFilter) ([]File, error) diff --git a/adaptors/fs/fs_test.go b/pkg/fs/fs_test.go similarity index 100% rename from adaptors/fs/fs_test.go rename to pkg/fs/fs_test.go diff --git a/adaptors/fs/mock_fs/mock_fs.go b/pkg/fs/mock_fs/mock_fs.go similarity index 94% rename from adaptors/fs/mock_fs/mock_fs.go rename to pkg/fs/mock_fs/mock_fs.go index ad8f031f..51b9afa8 100644 --- a/adaptors/fs/mock_fs/mock_fs.go +++ b/pkg/fs/mock_fs/mock_fs.go @@ -1,12 +1,12 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/adaptors/fs (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/fs (interfaces: Interface) // Package mock_fs is a generated GoMock package. package mock_fs import ( gomock "github.com/golang/mock/gomock" - fs "github.com/int128/ghcp/adaptors/fs" + fs "github.com/int128/ghcp/pkg/fs" reflect "reflect" ) diff --git a/domain/git/commitstrategy/commit_strategy.go b/pkg/git/commitstrategy/commit_strategy.go similarity index 97% rename from domain/git/commitstrategy/commit_strategy.go rename to pkg/git/commitstrategy/commit_strategy.go index 66d6ad5c..778c2b4c 100644 --- a/domain/git/commitstrategy/commit_strategy.go +++ b/pkg/git/commitstrategy/commit_strategy.go @@ -3,7 +3,7 @@ package commitstrategy import ( "fmt" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" ) // CommitStrategy represents a method to create a commit object. diff --git a/domain/git/commitstrategy/commit_strategy_test.go b/pkg/git/commitstrategy/commit_strategy_test.go similarity index 100% rename from domain/git/commitstrategy/commit_strategy_test.go rename to pkg/git/commitstrategy/commit_strategy_test.go diff --git a/domain/git/git.go b/pkg/git/git.go similarity index 100% rename from domain/git/git.go rename to pkg/git/git.go diff --git a/domain/git/git_test.go b/pkg/git/git_test.go similarity index 100% rename from domain/git/git_test.go rename to pkg/git/git_test.go diff --git a/domain/git/gitobject.go b/pkg/git/gitobject.go similarity index 100% rename from domain/git/gitobject.go rename to pkg/git/gitobject.go diff --git a/domain/git/release.go b/pkg/git/release.go similarity index 100% rename from domain/git/release.go rename to pkg/git/release.go diff --git a/infrastructure/github/github.go b/pkg/github/client/github.go similarity index 96% rename from infrastructure/github/github.go rename to pkg/github/client/github.go index 60342a5c..60aa1deb 100644 --- a/infrastructure/github/github.go +++ b/pkg/github/client/github.go @@ -1,4 +1,4 @@ -package github +package client import ( "context" @@ -19,7 +19,7 @@ var Set = wire.NewSet( type NewFunc func(Option) (Interface, error) -//go:generate mockgen -destination mock_github/mock_github.go github.com/int128/ghcp/infrastructure/github Interface +//go:generate mockgen -destination mock_client/mock_client.go github.com/int128/ghcp/pkg/github/client Interface type Interface interface { QueryService diff --git a/infrastructure/github/github_test.go b/pkg/github/client/github_test.go similarity index 99% rename from infrastructure/github/github_test.go rename to pkg/github/client/github_test.go index 1893a074..7153ea4b 100644 --- a/infrastructure/github/github_test.go +++ b/pkg/github/client/github_test.go @@ -1,4 +1,4 @@ -package github +package client import ( "context" diff --git a/infrastructure/github/mock_github/mock_github.go b/pkg/github/client/mock_client/mock_client.go similarity index 97% rename from infrastructure/github/mock_github/mock_github.go rename to pkg/github/client/mock_client/mock_client.go index e36554f6..bb401b48 100644 --- a/infrastructure/github/mock_github/mock_github.go +++ b/pkg/github/client/mock_client/mock_client.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/infrastructure/github (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/github/client (interfaces: Interface) -// Package mock_github is a generated GoMock package. -package mock_github +// Package mock_client is a generated GoMock package. +package mock_client import ( context "context" diff --git a/adaptors/github/commit.go b/pkg/github/commit.go similarity index 97% rename from adaptors/github/commit.go rename to pkg/github/commit.go index 7758a04e..75115e86 100644 --- a/adaptors/github/commit.go +++ b/pkg/github/commit.go @@ -5,16 +5,16 @@ import ( "github.com/cenkalti/backoff" "github.com/google/go-github/v33/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/domain/git" - githubInfrastructure "github.com/int128/ghcp/infrastructure/github" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github/client" + "github.com/int128/ghcp/pkg/logger" "github.com/shurcooL/githubv4" "golang.org/x/xerrors" ) // GitHub provides GitHub API access. type GitHub struct { - Client githubInfrastructure.Interface + Client client.Interface Logger logger.Interface } diff --git a/adaptors/github/github.go b/pkg/github/github.go similarity index 97% rename from adaptors/github/github.go rename to pkg/github/github.go index b9b389a9..1fd1d5f9 100644 --- a/adaptors/github/github.go +++ b/pkg/github/github.go @@ -4,7 +4,7 @@ import ( "context" "github.com/google/wire" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" "github.com/shurcooL/githubv4" "golang.org/x/xerrors" ) @@ -14,7 +14,7 @@ var Set = wire.NewSet( wire.Bind(new(Interface), new(*GitHub)), ) -//go:generate mockgen -destination mock_github/mock_github.go github.com/int128/ghcp/adaptors/github Interface +//go:generate mockgen -destination mock_github/mock_github.go github.com/int128/ghcp/pkg/github Interface type Interface interface { CreateFork(ctx context.Context, id git.RepositoryID) (*git.RepositoryID, error) diff --git a/adaptors/github/github_test.go b/pkg/github/github_test.go similarity index 90% rename from adaptors/github/github_test.go rename to pkg/github/github_test.go index 06a204ca..2e1ea6dd 100644 --- a/adaptors/github/github_test.go +++ b/pkg/github/github_test.go @@ -8,9 +8,9 @@ import ( "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" "github.com/google/go-github/v33/github" - testingLogger "github.com/int128/ghcp/adaptors/logger/testing" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/infrastructure/github/mock_github" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github/client/mock_client" + testingLogger "github.com/int128/ghcp/pkg/logger/testing" "golang.org/x/xerrors" ) @@ -22,7 +22,7 @@ func TestGitHub_CreateCommit(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - gitHubClient := mock_github.NewMockInterface(ctrl) + gitHubClient := mock_client.NewMockInterface(ctrl) gitHubClient.EXPECT(). CreateCommit(ctx, "owner", "repo", &github.Commit{ Message: github.String("message"), @@ -54,7 +54,7 @@ func TestGitHub_CreateCommit(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - gitHubClient := mock_github.NewMockInterface(ctrl) + gitHubClient := mock_client.NewMockInterface(ctrl) gitHubClient.EXPECT(). CreateCommit(ctx, "owner", "repo", &github.Commit{ Message: github.String("message"), @@ -90,7 +90,7 @@ func TestGitHub_GetReleaseByTagOrNil(t *testing.T) { defer ctrl.Finish() var resp github.Response resp.Response = &http.Response{StatusCode: 200} - gitHubClient := mock_github.NewMockInterface(ctrl) + gitHubClient := mock_client.NewMockInterface(ctrl) gitHubClient.EXPECT(). GetReleaseByTag(ctx, "owner", "repo", "v1.0.0"). Return(&github.RepositoryRelease{ @@ -123,7 +123,7 @@ func TestGitHub_GetReleaseByTagOrNil(t *testing.T) { defer ctrl.Finish() var resp github.Response resp.Response = &http.Response{StatusCode: 404} - gitHubClient := mock_github.NewMockInterface(ctrl) + gitHubClient := mock_client.NewMockInterface(ctrl) gitHubClient.EXPECT(). GetReleaseByTag(ctx, "owner", "repo", "v1.0.0"). Return(nil, &resp, xerrors.New("not found")) diff --git a/adaptors/github/gitobject.go b/pkg/github/gitobject.go similarity index 98% rename from adaptors/github/gitobject.go rename to pkg/github/gitobject.go index ac40e0e5..96e9730d 100644 --- a/adaptors/github/gitobject.go +++ b/pkg/github/gitobject.go @@ -6,7 +6,7 @@ import ( "github.com/google/go-github/v33/github" "golang.org/x/xerrors" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" ) // CreateCommit creates a commit and returns SHA of it. diff --git a/adaptors/github/mock_github/mock_github.go b/pkg/github/mock_github/mock_github.go similarity index 98% rename from adaptors/github/mock_github/mock_github.go rename to pkg/github/mock_github/mock_github.go index 7eaaf668..2e5f76a5 100644 --- a/adaptors/github/mock_github/mock_github.go +++ b/pkg/github/mock_github/mock_github.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/adaptors/github (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/github (interfaces: Interface) // Package mock_github is a generated GoMock package. package mock_github @@ -7,8 +7,8 @@ package mock_github import ( context "context" gomock "github.com/golang/mock/gomock" - github "github.com/int128/ghcp/adaptors/github" - git "github.com/int128/ghcp/domain/git" + git "github.com/int128/ghcp/pkg/git" + github "github.com/int128/ghcp/pkg/github" reflect "reflect" ) diff --git a/adaptors/github/pull_request.go b/pkg/github/pull_request.go similarity index 99% rename from adaptors/github/pull_request.go rename to pkg/github/pull_request.go index 537a5923..4b546ded 100644 --- a/adaptors/github/pull_request.go +++ b/pkg/github/pull_request.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" "github.com/shurcooL/githubv4" "golang.org/x/xerrors" ) diff --git a/adaptors/github/release.go b/pkg/github/release.go similarity index 98% rename from adaptors/github/release.go rename to pkg/github/release.go index d847f9b8..5d70fe9b 100644 --- a/adaptors/github/release.go +++ b/pkg/github/release.go @@ -6,7 +6,7 @@ import ( "os" "github.com/google/go-github/v33/github" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" "golang.org/x/xerrors" ) diff --git a/adaptors/logger/logger.go b/pkg/logger/logger.go similarity index 95% rename from adaptors/logger/logger.go rename to pkg/logger/logger.go index 8636d91f..dea8c24c 100644 --- a/adaptors/logger/logger.go +++ b/pkg/logger/logger.go @@ -13,7 +13,7 @@ var Set = wire.NewSet( type NewFunc func(Option) Interface -//go:generate mockgen -destination mock_logger/mock_logger.go github.com/int128/ghcp/adaptors/logger Interface +//go:generate mockgen -destination mock_logger/mock_logger.go github.com/int128/ghcp/pkg/logger Interface type Interface interface { Errorf(format string, v ...interface{}) diff --git a/adaptors/logger/mock_logger/mock_logger.go b/pkg/logger/mock_logger/mock_logger.go similarity index 97% rename from adaptors/logger/mock_logger/mock_logger.go rename to pkg/logger/mock_logger/mock_logger.go index 073e6a91..4475a656 100644 --- a/adaptors/logger/mock_logger/mock_logger.go +++ b/pkg/logger/mock_logger/mock_logger.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/adaptors/logger (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/logger (interfaces: Interface) // Package mock_logger is a generated GoMock package. package mock_logger diff --git a/adaptors/logger/testing/logger.go b/pkg/logger/testing/logger.go similarity index 92% rename from adaptors/logger/testing/logger.go rename to pkg/logger/testing/logger.go index 4fdf4f62..797bee8e 100644 --- a/adaptors/logger/testing/logger.go +++ b/pkg/logger/testing/logger.go @@ -3,7 +3,7 @@ package testing import ( "testing" - "github.com/int128/ghcp/adaptors/logger" + "github.com/int128/ghcp/pkg/logger" ) func New(t *testing.T) logger.Interface { diff --git a/usecases/commit/commit.go b/pkg/usecases/commit/commit.go similarity index 96% rename from usecases/commit/commit.go rename to pkg/usecases/commit/commit.go index 080e3841..cf9842fb 100644 --- a/usecases/commit/commit.go +++ b/pkg/usecases/commit/commit.go @@ -8,12 +8,12 @@ import ( "github.com/google/wire" "golang.org/x/xerrors" - "github.com/int128/ghcp/adaptors/fs" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/usecases/gitobject" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/logger" + "github.com/int128/ghcp/pkg/usecases/gitobject" ) var Set = wire.NewSet( @@ -21,7 +21,7 @@ var Set = wire.NewSet( wire.Bind(new(Interface), new(*Commit)), ) -//go:generate mockgen -destination mock_commit/mock_commit.go github.com/int128/ghcp/usecases/commit Interface +//go:generate mockgen -destination mock_commit/mock_commit.go github.com/int128/ghcp/pkg/usecases/commit Interface type Interface interface { Do(ctx context.Context, in Input) error diff --git a/usecases/commit/commit_test.go b/pkg/usecases/commit/commit_test.go similarity index 96% rename from usecases/commit/commit_test.go rename to pkg/usecases/commit/commit_test.go index 28e233cc..95283959 100644 --- a/usecases/commit/commit_test.go +++ b/pkg/usecases/commit/commit_test.go @@ -5,15 +5,15 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/int128/ghcp/adaptors/fs" - "github.com/int128/ghcp/adaptors/fs/mock_fs" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/github/mock_github" - testingLogger "github.com/int128/ghcp/adaptors/logger/testing" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/usecases/gitobject" - "github.com/int128/ghcp/usecases/gitobject/mock_gitobject" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/fs/mock_fs" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/github/mock_github" + testingLogger "github.com/int128/ghcp/pkg/logger/testing" + "github.com/int128/ghcp/pkg/usecases/gitobject" + "github.com/int128/ghcp/pkg/usecases/gitobject/mock_gitobject" ) var parentRepositoryID = git.RepositoryID{Owner: "upstream", Name: "repo"} diff --git a/usecases/commit/mock_commit/mock_commit.go b/pkg/usecases/commit/mock_commit/mock_commit.go similarity index 91% rename from usecases/commit/mock_commit/mock_commit.go rename to pkg/usecases/commit/mock_commit/mock_commit.go index 8aeb2b4d..8c6f6bf6 100644 --- a/usecases/commit/mock_commit/mock_commit.go +++ b/pkg/usecases/commit/mock_commit/mock_commit.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/usecases/commit (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/usecases/commit (interfaces: Interface) // Package mock_commit is a generated GoMock package. package mock_commit @@ -7,7 +7,7 @@ package mock_commit import ( context "context" gomock "github.com/golang/mock/gomock" - commit "github.com/int128/ghcp/usecases/commit" + commit "github.com/int128/ghcp/pkg/usecases/commit" reflect "reflect" ) diff --git a/usecases/forkcommit/forkcommit.go b/pkg/usecases/forkcommit/forkcommit.go similarity index 87% rename from usecases/forkcommit/forkcommit.go rename to pkg/usecases/forkcommit/forkcommit.go index 4814be0f..923741f5 100644 --- a/usecases/forkcommit/forkcommit.go +++ b/pkg/usecases/forkcommit/forkcommit.go @@ -6,11 +6,11 @@ import ( "github.com/google/wire" "golang.org/x/xerrors" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/usecases/commit" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/logger" + "github.com/int128/ghcp/pkg/usecases/commit" ) var Set = wire.NewSet( @@ -18,7 +18,7 @@ var Set = wire.NewSet( wire.Bind(new(Interface), new(*ForkCommit)), ) -//go:generate mockgen -destination mock_forkcommit/mock_forkcommit.go github.com/int128/ghcp/usecases/forkcommit Interface +//go:generate mockgen -destination mock_forkcommit/mock_forkcommit.go github.com/int128/ghcp/pkg/usecases/forkcommit Interface type Interface interface { Do(ctx context.Context, in Input) error diff --git a/usecases/forkcommit/forkcommit_test.go b/pkg/usecases/forkcommit/forkcommit_test.go similarity index 88% rename from usecases/forkcommit/forkcommit_test.go rename to pkg/usecases/forkcommit/forkcommit_test.go index 7017fb70..e3bafe55 100644 --- a/usecases/forkcommit/forkcommit_test.go +++ b/pkg/usecases/forkcommit/forkcommit_test.go @@ -5,12 +5,12 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/int128/ghcp/adaptors/github/mock_github" - testingLogger "github.com/int128/ghcp/adaptors/logger/testing" - "github.com/int128/ghcp/domain/git" - "github.com/int128/ghcp/domain/git/commitstrategy" - "github.com/int128/ghcp/usecases/commit" - "github.com/int128/ghcp/usecases/commit/mock_commit" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/git/commitstrategy" + "github.com/int128/ghcp/pkg/github/mock_github" + testingLogger "github.com/int128/ghcp/pkg/logger/testing" + "github.com/int128/ghcp/pkg/usecases/commit" + "github.com/int128/ghcp/pkg/usecases/commit/mock_commit" ) func TestForkCommit_Do(t *testing.T) { diff --git a/usecases/forkcommit/mock_forkcommit/mock_forkcommit.go b/pkg/usecases/forkcommit/mock_forkcommit/mock_forkcommit.go similarity index 90% rename from usecases/forkcommit/mock_forkcommit/mock_forkcommit.go rename to pkg/usecases/forkcommit/mock_forkcommit/mock_forkcommit.go index 25621ea4..064b2c0b 100644 --- a/usecases/forkcommit/mock_forkcommit/mock_forkcommit.go +++ b/pkg/usecases/forkcommit/mock_forkcommit/mock_forkcommit.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/usecases/forkcommit (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/usecases/forkcommit (interfaces: Interface) // Package mock_forkcommit is a generated GoMock package. package mock_forkcommit @@ -7,7 +7,7 @@ package mock_forkcommit import ( context "context" gomock "github.com/golang/mock/gomock" - forkcommit "github.com/int128/ghcp/usecases/forkcommit" + forkcommit "github.com/int128/ghcp/pkg/usecases/forkcommit" reflect "reflect" ) diff --git a/usecases/gitobject/create.go b/pkg/usecases/gitobject/create.go similarity index 93% rename from usecases/gitobject/create.go rename to pkg/usecases/gitobject/create.go index 8dbc420e..4f519a2c 100644 --- a/usecases/gitobject/create.go +++ b/pkg/usecases/gitobject/create.go @@ -7,10 +7,10 @@ import ( "github.com/google/wire" "golang.org/x/xerrors" - "github.com/int128/ghcp/adaptors/fs" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/logger" ) var Set = wire.NewSet( @@ -18,7 +18,7 @@ var Set = wire.NewSet( wire.Bind(new(Interface), new(*CreateGitObject)), ) -//go:generate mockgen -destination mock_gitobject/mock_gitobject.go github.com/int128/ghcp/usecases/gitobject Interface +//go:generate mockgen -destination mock_gitobject/mock_gitobject.go github.com/int128/ghcp/pkg/usecases/gitobject Interface type Interface interface { Do(ctx context.Context, in Input) (*Output, error) diff --git a/usecases/gitobject/create_test.go b/pkg/usecases/gitobject/create_test.go similarity index 96% rename from usecases/gitobject/create_test.go rename to pkg/usecases/gitobject/create_test.go index 6251b794..b890f9a9 100644 --- a/usecases/gitobject/create_test.go +++ b/pkg/usecases/gitobject/create_test.go @@ -7,12 +7,12 @@ import ( "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" - "github.com/int128/ghcp/adaptors/fs" - "github.com/int128/ghcp/adaptors/fs/mock_fs" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/github/mock_github" - testingLogger "github.com/int128/ghcp/adaptors/logger/testing" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/fs/mock_fs" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/github/mock_github" + testingLogger "github.com/int128/ghcp/pkg/logger/testing" ) func TestCreateBlobTreeCommit_Do(t *testing.T) { diff --git a/usecases/gitobject/mock_gitobject/mock_gitobject.go b/pkg/usecases/gitobject/mock_gitobject/mock_gitobject.go similarity index 90% rename from usecases/gitobject/mock_gitobject/mock_gitobject.go rename to pkg/usecases/gitobject/mock_gitobject/mock_gitobject.go index 7c4a670f..cf55004a 100644 --- a/usecases/gitobject/mock_gitobject/mock_gitobject.go +++ b/pkg/usecases/gitobject/mock_gitobject/mock_gitobject.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/usecases/gitobject (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/usecases/gitobject (interfaces: Interface) // Package mock_gitobject is a generated GoMock package. package mock_gitobject @@ -7,7 +7,7 @@ package mock_gitobject import ( context "context" gomock "github.com/golang/mock/gomock" - gitobject "github.com/int128/ghcp/usecases/gitobject" + gitobject "github.com/int128/ghcp/pkg/usecases/gitobject" reflect "reflect" ) diff --git a/usecases/pullrequest/mock_pullrequest/mock_pullrequest.go b/pkg/usecases/pullrequest/mock_pullrequest/mock_pullrequest.go similarity index 90% rename from usecases/pullrequest/mock_pullrequest/mock_pullrequest.go rename to pkg/usecases/pullrequest/mock_pullrequest/mock_pullrequest.go index 645aee53..a956ade2 100644 --- a/usecases/pullrequest/mock_pullrequest/mock_pullrequest.go +++ b/pkg/usecases/pullrequest/mock_pullrequest/mock_pullrequest.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/usecases/pullrequest (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/usecases/pullrequest (interfaces: Interface) // Package mock_pullrequest is a generated GoMock package. package mock_pullrequest @@ -7,7 +7,7 @@ package mock_pullrequest import ( context "context" gomock "github.com/golang/mock/gomock" - pullrequest "github.com/int128/ghcp/usecases/pullrequest" + pullrequest "github.com/int128/ghcp/pkg/usecases/pullrequest" reflect "reflect" ) diff --git a/usecases/pullrequest/pull_request.go b/pkg/usecases/pullrequest/pull_request.go similarity index 93% rename from usecases/pullrequest/pull_request.go rename to pkg/usecases/pullrequest/pull_request.go index 2c6199d7..0917126e 100644 --- a/usecases/pullrequest/pull_request.go +++ b/pkg/usecases/pullrequest/pull_request.go @@ -4,9 +4,9 @@ import ( "context" "github.com/google/wire" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/logger" "golang.org/x/xerrors" ) @@ -15,7 +15,7 @@ var Set = wire.NewSet( wire.Struct(new(PullRequest), "*"), ) -//go:generate mockgen -destination mock_pullrequest/mock_pullrequest.go github.com/int128/ghcp/usecases/pullrequest Interface +//go:generate mockgen -destination mock_pullrequest/mock_pullrequest.go github.com/int128/ghcp/pkg/usecases/pullrequest Interface type Interface interface { Do(ctx context.Context, in Input) error diff --git a/usecases/pullrequest/pull_request_test.go b/pkg/usecases/pullrequest/pull_request_test.go similarity index 96% rename from usecases/pullrequest/pull_request_test.go rename to pkg/usecases/pullrequest/pull_request_test.go index 0f19e3df..7a67dcc2 100644 --- a/usecases/pullrequest/pull_request_test.go +++ b/pkg/usecases/pullrequest/pull_request_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/github/mock_github" - testingLogger "github.com/int128/ghcp/adaptors/logger/testing" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/github/mock_github" + testingLogger "github.com/int128/ghcp/pkg/logger/testing" ) func TestPullRequest_Do(t *testing.T) { diff --git a/usecases/release/mock_release/mock_release.go b/pkg/usecases/release/mock_release/mock_release.go similarity index 90% rename from usecases/release/mock_release/mock_release.go rename to pkg/usecases/release/mock_release/mock_release.go index ff6158e2..eb4533fb 100644 --- a/usecases/release/mock_release/mock_release.go +++ b/pkg/usecases/release/mock_release/mock_release.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/ghcp/usecases/release (interfaces: Interface) +// Source: github.com/int128/ghcp/pkg/usecases/release (interfaces: Interface) // Package mock_release is a generated GoMock package. package mock_release @@ -7,7 +7,7 @@ package mock_release import ( context "context" gomock "github.com/golang/mock/gomock" - release "github.com/int128/ghcp/usecases/release" + release "github.com/int128/ghcp/pkg/usecases/release" reflect "reflect" ) diff --git a/usecases/release/release.go b/pkg/usecases/release/release.go similarity index 92% rename from usecases/release/release.go rename to pkg/usecases/release/release.go index e295a523..57f70d07 100644 --- a/usecases/release/release.go +++ b/pkg/usecases/release/release.go @@ -5,10 +5,10 @@ import ( "path/filepath" "github.com/google/wire" - "github.com/int128/ghcp/adaptors/fs" - "github.com/int128/ghcp/adaptors/github" - "github.com/int128/ghcp/adaptors/logger" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github" + "github.com/int128/ghcp/pkg/logger" "golang.org/x/xerrors" ) @@ -17,7 +17,7 @@ var Set = wire.NewSet( wire.Bind(new(Interface), new(*Release)), ) -//go:generate mockgen -destination mock_release/mock_release.go github.com/int128/ghcp/usecases/release Interface +//go:generate mockgen -destination mock_release/mock_release.go github.com/int128/ghcp/pkg/usecases/release Interface type Interface interface { Do(ctx context.Context, in Input) error diff --git a/usecases/release/release_test.go b/pkg/usecases/release/release_test.go similarity index 93% rename from usecases/release/release_test.go rename to pkg/usecases/release/release_test.go index ba1080bf..70c53e52 100644 --- a/usecases/release/release_test.go +++ b/pkg/usecases/release/release_test.go @@ -5,11 +5,11 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/int128/ghcp/adaptors/fs" - "github.com/int128/ghcp/adaptors/fs/mock_fs" - "github.com/int128/ghcp/adaptors/github/mock_github" - testingLogger "github.com/int128/ghcp/adaptors/logger/testing" - "github.com/int128/ghcp/domain/git" + "github.com/int128/ghcp/pkg/fs" + "github.com/int128/ghcp/pkg/fs/mock_fs" + "github.com/int128/ghcp/pkg/git" + "github.com/int128/ghcp/pkg/github/mock_github" + testingLogger "github.com/int128/ghcp/pkg/logger/testing" ) func TestRelease_Do(t *testing.T) {