From 2453066da37df1977130617beb202f554e0d3348 Mon Sep 17 00:00:00 2001 From: doglightning Date: Thu, 10 Jul 2025 10:43:42 -0400 Subject: [PATCH 1/2] refactor: prep cli for migration --- .github/workflows/ci.yml | 36 ++- .github/workflows/release.yml | 1 + .vscode/launch.json | 47 ---- cmd/world/{cardinal => }/cardinal.go | 62 ++--- cmd/world/{cloud => }/cloud.go | 54 ++--- cmd/world/{evm => }/evm.go | 29 +-- cmd/world/main.go | 64 +++--- cmd/world/{organization => }/organization.go | 26 +-- cmd/world/{project => }/project.go | 36 +-- cmd/world/root.go | 60 +++++ cmd/world/root/root.go | 60 ----- cmd/world/{user => }/user.go | 30 +-- common/util/util.go | 18 -- gen/logs/v1/logs.pb.go | 201 ---------------- .../app/world-cli/.gitignore | 0 .../app/world-cli/.golangci.yaml | 0 .../app/world-cli/.goreleaser.yaml | 2 +- .../app/world-cli/.markdownlint.yaml | 0 .../app/world-cli/DEVELOPER.md | 0 LICENSE => internal/app/world-cli/LICENSE | 0 README.md => internal/app/world-cli/README.md | 0 .../app/world-cli/Taskfile.yml | 0 .../app/world-cli/buf.gen.yaml | 2 +- buf.yaml => internal/app/world-cli/buf.yaml | 0 .../clients/api/api_internal_test.go | 0 .../app/world-cli}/clients/api/client.go | 2 +- .../app/world-cli}/clients/api/cloud.go | 2 +- .../app/world-cli}/clients/api/login.go | 2 +- .../app/world-cli}/clients/api/mock.go | 2 +- .../world-cli}/clients/api/organization.go | 2 +- .../app/world-cli}/clients/api/project.go | 2 +- .../app/world-cli}/clients/api/types.go | 2 +- .../app/world-cli}/clients/api/user.go | 2 +- .../app/world-cli}/clients/browser/browser.go | 2 +- .../app/world-cli}/clients/browser/mock.go | 0 .../app/world-cli}/clients/browser/types.go | 0 .../app/world-cli}/clients/repo/mock.go | 0 .../app/world-cli}/clients/repo/repo.go | 0 .../clients/repo/repo_internal_test.go | 0 .../app/world-cli}/clients/repo/types.go | 0 .../app/world-cli/commands}/cardinal/build.go | 10 +- .../commands/cardinal/cardinal_test.go | 176 +++----------- .../app/world-cli/commands}/cardinal/dev.go | 16 +- .../app/world-cli/commands}/cardinal/mocks.go | 4 +- .../app/world-cli/commands}/cardinal/purge.go | 10 +- .../world-cli/commands}/cardinal/restart.go | 6 +- .../app/world-cli/commands}/cardinal/start.go | 29 ++- .../app/world-cli/commands}/cardinal/stop.go | 10 +- .../app/world-cli/commands}/cardinal/types.go | 2 +- .../commands}/cardinal/util_editor.go | 2 +- .../world-cli/commands/cloud/cloud_test.go | 216 ++++++++++++------ .../world-cli/commands}/cloud/deployment.go | 26 +-- .../app/world-cli/commands}/cloud/logs.go | 8 +- .../app/world-cli/commands}/cloud/mock.go | 4 +- .../app/world-cli/commands}/cloud/status.go | 4 +- .../app/world-cli/commands}/cloud/types.go | 16 +- .../app/world-cli/commands/evm/evm_test.go | 133 ++--------- .../app/world-cli/commands}/evm/mock.go | 4 +- .../app/world-cli/commands}/evm/start.go | 24 +- .../app/world-cli/commands}/evm/stop.go | 10 +- .../app/world-cli/commands}/evm/types.go | 2 +- .../commands}/organization/create.go | 10 +- .../commands}/organization/members_list.go | 4 +- .../world-cli/commands}/organization/mock.go | 4 +- .../organization/organization_test.go | 12 +- .../commands}/organization/switch.go | 4 +- .../world-cli/commands}/organization/types.go | 8 +- .../world-cli/commands}/organization/utils.go | 4 +- .../app/world-cli/commands}/project/create.go | 12 +- .../app/world-cli/commands}/project/delete.go | 4 +- .../app/world-cli/commands}/project/mock.go | 4 +- .../commands}/project/project_test.go | 12 +- .../commands}/project/region_selector.go | 10 +- .../app/world-cli/commands}/project/switch.go | 6 +- .../app/world-cli/commands}/project/types.go | 10 +- .../app/world-cli/commands}/project/update.go | 6 +- .../app/world-cli/commands}/project/utils.go | 10 +- .../app/world-cli/commands}/root/create.go | 14 +- .../world-cli/commands}/root/create_test.go | 10 +- .../app/world-cli/commands}/root/doctor.go | 10 +- .../app/world-cli/commands}/root/login.go | 10 +- .../app/world-cli/commands}/root/mock.go | 2 +- .../app/world-cli/commands}/root/root_test.go | 12 +- .../app/world-cli/commands}/root/types.go | 8 +- .../app/world-cli/commands}/root/version.go | 4 +- .../app/world-cli/commands}/user/invite.go | 6 +- .../app/world-cli/commands}/user/mock.go | 4 +- .../app/world-cli/commands}/user/role.go | 6 +- .../app/world-cli/commands}/user/types.go | 6 +- .../app/world-cli/commands}/user/update.go | 6 +- .../app/world-cli/commands}/user/user_test.go | 8 +- .../world-cli/common}/config/cli_config.go | 0 .../app/world-cli/common}/config/config.go | 2 +- .../common}/config/config_internal_test.go | 2 +- .../common}/dependency/dependency.go | 0 .../app/world-cli/common}/docker/client.go | 6 +- .../common}/docker/client_container.go | 12 +- .../world-cli/common}/docker/client_image.go | 12 +- .../common}/docker/client_internal_test.go | 8 +- .../common}/docker/client_network.go | 8 +- .../world-cli/common}/docker/client_util.go | 2 +- .../world-cli/common}/docker/client_volume.go | 8 +- .../docker/service/cardinal.Dockerfile | 0 .../common}/docker/service/cardinal.go | 2 +- .../common}/docker/service/celestia.go | 2 +- .../world-cli/common}/docker/service/evm.go | 2 +- .../common}/docker/service/jaeger.go | 2 +- .../common}/docker/service/nakama.go | 2 +- .../common}/docker/service/nakamadb.go | 4 +- .../common}/docker/service/prometheus.go | 2 +- .../world-cli/common}/docker/service/redis.go | 4 +- .../common}/docker/service/service.go | 4 +- .../app/world-cli/common}/editor/editor.go | 4 +- .../common}/editor/editor_internal_test.go | 0 .../app/world-cli/common}/env.go | 0 .../app/world-cli/common}/login/login.go | 0 .../world-cli/common}/login/login_darwin.go | 0 .../common}/login/login_internal_test.go | 0 .../world-cli/common}/login/login_linux.go | 0 .../world-cli/common}/login/login_windows.go | 0 .../app/world-cli/common}/port.go | 0 .../world-cli/common}/teacmd/dependencies.go | 4 +- .../app/world-cli/common}/teacmd/docker.go | 2 +- .../app/world-cli/common}/teacmd/git.go | 0 .../common}/teacmd/git_internal_test.go | 0 .../world-cli/common/telemetry}/posthog.go | 2 +- .../app/world-cli/common/telemetry}/sentry.go | 0 .../testdata}/starter-game-template/README.md | 0 .../cardinal/.run/Cardinal - Debug.run.xml | 0 .../starter-game-template/cardinal/Makefile | 0 .../cardinal/component/health.go | 0 .../cardinal/component/player.go | 0 .../starter-game-template/cardinal/go.mod | 0 .../starter-game-template/cardinal/go.sum | 0 .../cardinal/init_test.go | 0 .../starter-game-template/cardinal/main.go | 0 .../cardinal/msg/attack_player.go | 0 .../cardinal/msg/create_player.go | 0 .../cardinal/query/player_health.go | 0 .../cardinal/system/attack.go | 0 .../cardinal/system/default_spawner.go | 0 .../cardinal/system/player_spawner.go | 0 .../cardinal/system/regen.go | 0 .../cardinal/system/utils.go | 0 .../cardinal/system_test.go | 0 .../starter-game-template/world.toml | 0 .../common/testdata/toml/example-world.toml | 0 .../app/world-cli/common}/tomlutil/toml.go | 0 .../common}/tomlutil/toml_internal_test.go | 0 .../app/world-cli/common}/utils/slug/slug.go | 0 .../world-cli/common}/utils/slug/slug_test.go | 2 +- .../common}/utils/validate/cardinal_root.go | 0 .../world-cli/common}/utils/validate/email.go | 2 +- .../world-cli/common}/utils/validate/name.go | 2 +- .../world-cli/common}/utils/validate/url.go | 0 .../common}/utils/validate/validate_test.go | 2 +- .../controllers/cmd_setup/cmd_setup.go | 8 +- .../controllers/cmd_setup/cmd_setup_test.go | 18 +- .../world-cli}/controllers/cmd_setup/mock.go | 4 +- .../controllers/cmd_setup/organization.go | 6 +- .../controllers/cmd_setup/project.go | 6 +- .../world-cli}/controllers/cmd_setup/types.go | 10 +- .../logs/v1/logsv1connect/logs.connect.go | 2 +- .../app/world-cli}/interfaces/cardinal.go | 2 +- .../app/world-cli}/interfaces/cloud.go | 2 +- .../app/world-cli}/interfaces/cmd_setup.go | 2 +- .../app/world-cli}/interfaces/evm.go | 2 +- .../app/world-cli}/interfaces/organization.go | 2 +- .../app/world-cli}/interfaces/project.go | 2 +- .../app/world-cli}/interfaces/root.go | 0 .../app/world-cli}/interfaces/user.go | 2 +- .../app/world-cli}/models/cardinal.go | 0 .../app/world-cli}/models/cloud.go | 8 + .../app/world-cli}/models/cmd_setup.go | 0 .../app/world-cli}/models/evm.go | 0 .../app/world-cli}/models/organization.go | 0 .../app/world-cli}/models/project.go | 0 .../app/world-cli}/models/root.go | 0 .../app/world-cli}/models/user.go | 0 .../app/world-cli/proto}/logs/v1/logs.proto | 0 .../proto/logs/v1/world-cli.code-workspace | 11 + .../app/world-cli}/services/config/config.go | 6 +- .../services/config/config_internal_test.go | 4 +- .../app/world-cli}/services/config/mock.go | 0 .../app/world-cli}/services/config/types.go | 2 +- .../app/world-cli}/services/input/input.go | 2 +- .../services/input/input_internal_test.go | 0 .../app/world-cli}/services/input/mock.go | 0 .../app/world-cli}/services/input/types.go | 0 .../app/world-cli/taskfiles}/buf.yaml | 0 .../app/world-cli/taskfiles}/build.yaml | 0 .../app/world-cli/taskfiles}/lint.yaml | 0 .../app/world-cli/taskfiles}/test.yaml | 0 {common => internal/pkg}/logger/init.go | 10 +- {common => internal/pkg}/logger/logger.go | 0 {common => internal/pkg}/printer/printer.go | 0 {tea => internal/pkg/tea}/component/IBox.go | 0 .../tea}/component/multiselect/multiselect.go | 0 .../component/multispinner/multispinner.go | 2 +- .../pkg/tea}/component/program/program.go | 34 ++- .../pkg/tea}/component/spinner/spinner.go | 0 {tea => internal/pkg/tea}/component/status.go | 0 .../pkg/tea}/component/steps/cmd.go | 0 .../pkg/tea}/component/steps/entry.go | 0 .../pkg/tea}/component/steps/steps.go | 2 +- {tea => internal/pkg/tea}/style/container.go | 0 {tea => internal/pkg/tea}/style/icon.go | 0 {tea => internal/pkg/tea}/style/text.go | 0 {tea => internal/pkg/tea}/style/util.go | 7 +- 209 files changed, 800 insertions(+), 1144 deletions(-) delete mode 100644 .vscode/launch.json rename cmd/world/{cardinal => }/cardinal.go (67%) rename cmd/world/{cloud => }/cloud.go (69%) rename cmd/world/{evm => }/evm.go (64%) rename cmd/world/{organization => }/organization.go (71%) rename cmd/world/{project => }/project.go (73%) create mode 100644 cmd/world/root.go delete mode 100644 cmd/world/root/root.go rename cmd/world/{user => }/user.go (71%) delete mode 100644 common/util/util.go delete mode 100644 gen/logs/v1/logs.pb.go rename .gitignore => internal/app/world-cli/.gitignore (100%) rename .golangci.yaml => internal/app/world-cli/.golangci.yaml (100%) rename .goreleaser.yaml => internal/app/world-cli/.goreleaser.yaml (98%) rename .markdownlint.yaml => internal/app/world-cli/.markdownlint.yaml (100%) rename DEVELOPER.md => internal/app/world-cli/DEVELOPER.md (100%) rename LICENSE => internal/app/world-cli/LICENSE (100%) rename README.md => internal/app/world-cli/README.md (100%) rename Taskfile.yml => internal/app/world-cli/Taskfile.yml (100%) rename buf.gen.yaml => internal/app/world-cli/buf.gen.yaml (81%) rename buf.yaml => internal/app/world-cli/buf.yaml (100%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/api_internal_test.go (100%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/client.go (99%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/cloud.go (98%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/login.go (97%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/mock.go (99%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/organization.go (98%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/project.go (98%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/types.go (99%) rename {cmd/world/internal => internal/app/world-cli}/clients/api/user.go (94%) rename {cmd/world/internal => internal/app/world-cli}/clients/browser/browser.go (92%) rename {cmd/world/internal => internal/app/world-cli}/clients/browser/mock.go (100%) rename {cmd/world/internal => internal/app/world-cli}/clients/browser/types.go (100%) rename {cmd/world/internal => internal/app/world-cli}/clients/repo/mock.go (100%) rename {cmd/world/internal => internal/app/world-cli}/clients/repo/repo.go (100%) rename {cmd/world/internal => internal/app/world-cli}/clients/repo/repo_internal_test.go (100%) rename {cmd/world/internal => internal/app/world-cli}/clients/repo/types.go (100%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/build.go (92%) rename cmd/world/cardinal/cardinal_internal_test.go => internal/app/world-cli/commands/cardinal/cardinal_test.go (65%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/dev.go (93%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/mocks.go (89%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/purge.go (65%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/restart.go (72%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/start.go (82%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/stop.go (64%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/types.go (70%) rename {cmd/world => internal/app/world-cli/commands}/cardinal/util_editor.go (94%) rename cmd/world/cloud/cloud_internal_test.go => internal/app/world-cli/commands/cloud/cloud_test.go (75%) rename {cmd/world => internal/app/world-cli/commands}/cloud/deployment.go (95%) rename {cmd/world => internal/app/world-cli/commands}/cloud/logs.go (95%) rename {cmd/world => internal/app/world-cli/commands}/cloud/mock.go (86%) rename {cmd/world => internal/app/world-cli/commands}/cloud/status.go (91%) rename {cmd/world => internal/app/world-cli/commands}/cloud/types.go (72%) rename cmd/world/evm/evm_internal_test.go => internal/app/world-cli/commands/evm/evm_test.go (67%) rename {cmd/world => internal/app/world-cli/commands}/evm/mock.go (78%) rename {cmd/world => internal/app/world-cli/commands}/evm/start.go (84%) rename {cmd/world => internal/app/world-cli/commands}/evm/stop.go (61%) rename {cmd/world => internal/app/world-cli/commands}/evm/types.go (68%) rename {cmd/world => internal/app/world-cli/commands}/organization/create.go (89%) rename {cmd/world => internal/app/world-cli/commands}/organization/members_list.go (93%) rename {cmd/world => internal/app/world-cli/commands}/organization/mock.go (90%) rename {cmd/world => internal/app/world-cli/commands}/organization/organization_test.go (98%) rename {cmd/world => internal/app/world-cli/commands}/organization/switch.go (97%) rename {cmd/world => internal/app/world-cli/commands}/organization/types.go (71%) rename {cmd/world => internal/app/world-cli/commands}/organization/utils.go (91%) rename {cmd/world => internal/app/world-cli/commands}/project/create.go (96%) rename {cmd/world => internal/app/world-cli/commands}/project/delete.go (94%) rename {cmd/world => internal/app/world-cli/commands}/project/mock.go (92%) rename {cmd/world => internal/app/world-cli/commands}/project/project_test.go (99%) rename {cmd/world => internal/app/world-cli/commands}/project/region_selector.go (86%) rename {cmd/world => internal/app/world-cli/commands}/project/switch.go (96%) rename {cmd/world => internal/app/world-cli/commands}/project/types.go (84%) rename {cmd/world => internal/app/world-cli/commands}/project/update.go (91%) rename {cmd/world => internal/app/world-cli/commands}/project/utils.go (92%) rename {cmd/world => internal/app/world-cli/commands}/root/create.go (93%) rename {cmd/world => internal/app/world-cli/commands}/root/create_test.go (95%) rename {cmd/world => internal/app/world-cli/commands}/root/doctor.go (83%) rename {cmd/world => internal/app/world-cli/commands}/root/login.go (95%) rename {cmd/world => internal/app/world-cli/commands}/root/mock.go (91%) rename {cmd/world => internal/app/world-cli/commands}/root/root_test.go (96%) rename {cmd/world => internal/app/world-cli/commands}/root/types.go (73%) rename {cmd/world => internal/app/world-cli/commands}/root/version.go (96%) rename {cmd/world => internal/app/world-cli/commands}/user/invite.go (88%) rename {cmd/world => internal/app/world-cli/commands}/user/mock.go (86%) rename {cmd/world => internal/app/world-cli/commands}/user/role.go (91%) rename {cmd/world => internal/app/world-cli/commands}/user/types.go (66%) rename {cmd/world => internal/app/world-cli/commands}/user/update.go (86%) rename {cmd/world => internal/app/world-cli/commands}/user/user_test.go (98%) rename {common => internal/app/world-cli/common}/config/cli_config.go (100%) rename {common => internal/app/world-cli/common}/config/config.go (98%) rename {common => internal/app/world-cli/common}/config/config_internal_test.go (99%) rename {common => internal/app/world-cli/common}/dependency/dependency.go (100%) rename {common => internal/app/world-cli/common}/docker/client.go (97%) rename {common => internal/app/world-cli/common}/docker/client_container.go (95%) rename {common => internal/app/world-cli/common}/docker/client_image.go (98%) rename {common => internal/app/world-cli/common}/docker/client_internal_test.go (96%) rename {common => internal/app/world-cli/common}/docker/client_network.go (86%) rename {common => internal/app/world-cli/common}/docker/client_util.go (94%) rename {common => internal/app/world-cli/common}/docker/client_volume.go (89%) rename {common => internal/app/world-cli/common}/docker/service/cardinal.Dockerfile (100%) rename {common => internal/app/world-cli/common}/docker/service/cardinal.go (98%) rename {common => internal/app/world-cli/common}/docker/service/celestia.go (95%) rename {common => internal/app/world-cli/common}/docker/service/evm.go (98%) rename {common => internal/app/world-cli/common}/docker/service/jaeger.go (96%) rename {common => internal/app/world-cli/common}/docker/service/nakama.go (98%) rename {common => internal/app/world-cli/common}/docker/service/nakamadb.go (92%) rename {common => internal/app/world-cli/common}/docker/service/prometheus.go (95%) rename {common => internal/app/world-cli/common}/docker/service/redis.go (91%) rename {common => internal/app/world-cli/common}/docker/service/service.go (94%) rename {common => internal/app/world-cli/common}/editor/editor.go (98%) rename {common => internal/app/world-cli/common}/editor/editor_internal_test.go (100%) rename {common => internal/app/world-cli/common}/env.go (100%) rename {common => internal/app/world-cli/common}/login/login.go (100%) rename {common => internal/app/world-cli/common}/login/login_darwin.go (100%) rename {common => internal/app/world-cli/common}/login/login_internal_test.go (100%) rename {common => internal/app/world-cli/common}/login/login_linux.go (100%) rename {common => internal/app/world-cli/common}/login/login_windows.go (100%) rename {common => internal/app/world-cli/common}/port.go (100%) rename {common => internal/app/world-cli/common}/teacmd/dependencies.go (92%) rename {common => internal/app/world-cli/common}/teacmd/docker.go (98%) rename {common => internal/app/world-cli/common}/teacmd/git.go (100%) rename {common => internal/app/world-cli/common}/teacmd/git_internal_test.go (100%) rename {telemetry => internal/app/world-cli/common/telemetry}/posthog.go (97%) rename {telemetry => internal/app/world-cli/common/telemetry}/sentry.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/README.md (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/.run/Cardinal - Debug.run.xml (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/Makefile (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/component/health.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/component/player.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/go.mod (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/go.sum (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/init_test.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/main.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/msg/attack_player.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/msg/create_player.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/query/player_health.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/system/attack.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/system/default_spawner.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/system/player_spawner.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/system/regen.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/system/utils.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/cardinal/system_test.go (100%) rename {testdata => internal/app/world-cli/common/testdata}/starter-game-template/world.toml (100%) rename example-world.toml => internal/app/world-cli/common/testdata/toml/example-world.toml (100%) rename {common => internal/app/world-cli/common}/tomlutil/toml.go (100%) rename {common => internal/app/world-cli/common}/tomlutil/toml_internal_test.go (100%) rename {cmd/world/internal => internal/app/world-cli/common}/utils/slug/slug.go (100%) rename {cmd/world/internal => internal/app/world-cli/common}/utils/slug/slug_test.go (99%) rename {cmd/world/internal => internal/app/world-cli/common}/utils/validate/cardinal_root.go (100%) rename {cmd/world/internal => internal/app/world-cli/common}/utils/validate/email.go (97%) rename {cmd/world/internal => internal/app/world-cli/common}/utils/validate/name.go (94%) rename {cmd/world/internal => internal/app/world-cli/common}/utils/validate/url.go (100%) rename {cmd/world/internal => internal/app/world-cli/common}/utils/validate/validate_test.go (99%) rename {cmd/world/internal => internal/app/world-cli}/controllers/cmd_setup/cmd_setup.go (97%) rename {cmd/world/internal => internal/app/world-cli}/controllers/cmd_setup/cmd_setup_test.go (98%) rename {cmd/world/internal => internal/app/world-cli}/controllers/cmd_setup/mock.go (84%) rename {cmd/world/internal => internal/app/world-cli}/controllers/cmd_setup/organization.go (96%) rename {cmd/world/internal => internal/app/world-cli}/controllers/cmd_setup/project.go (97%) rename {cmd/world/internal => internal/app/world-cli}/controllers/cmd_setup/types.go (83%) rename {gen => internal/app/world-cli/gen}/logs/v1/logsv1connect/logs.connect.go (98%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/cardinal.go (88%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/cloud.go (91%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/cmd_setup.go (88%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/evm.go (77%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/organization.go (94%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/project.go (95%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/root.go (100%) rename {cmd/world/internal => internal/app/world-cli}/interfaces/user.go (92%) rename {cmd/world/internal => internal/app/world-cli}/models/cardinal.go (100%) rename {cmd/world/internal => internal/app/world-cli}/models/cloud.go (80%) rename {cmd/world/internal => internal/app/world-cli}/models/cmd_setup.go (100%) rename {cmd/world/internal => internal/app/world-cli}/models/evm.go (100%) rename {cmd/world/internal => internal/app/world-cli}/models/organization.go (100%) rename {cmd/world/internal => internal/app/world-cli}/models/project.go (100%) rename {cmd/world/internal => internal/app/world-cli}/models/root.go (100%) rename {cmd/world/internal => internal/app/world-cli}/models/user.go (100%) rename {proto => internal/app/world-cli/proto}/logs/v1/logs.proto (100%) create mode 100644 internal/app/world-cli/proto/logs/v1/world-cli.code-workspace rename {cmd/world/internal => internal/app/world-cli}/services/config/config.go (95%) rename {cmd/world/internal => internal/app/world-cli}/services/config/config_internal_test.go (97%) rename {cmd/world/internal => internal/app/world-cli}/services/config/mock.go (100%) rename {cmd/world/internal => internal/app/world-cli}/services/config/types.go (95%) rename {cmd/world/internal => internal/app/world-cli}/services/input/input.go (99%) rename {cmd/world/internal => internal/app/world-cli}/services/input/input_internal_test.go (100%) rename {cmd/world/internal => internal/app/world-cli}/services/input/mock.go (100%) rename {cmd/world/internal => internal/app/world-cli}/services/input/types.go (100%) rename {taskfiles => internal/app/world-cli/taskfiles}/buf.yaml (100%) rename {taskfiles => internal/app/world-cli/taskfiles}/build.yaml (100%) rename {taskfiles => internal/app/world-cli/taskfiles}/lint.yaml (100%) rename {taskfiles => internal/app/world-cli/taskfiles}/test.yaml (100%) rename {common => internal/pkg}/logger/init.go (85%) rename {common => internal/pkg}/logger/logger.go (100%) rename {common => internal/pkg}/printer/printer.go (100%) rename {tea => internal/pkg/tea}/component/IBox.go (100%) rename {tea => internal/pkg/tea}/component/multiselect/multiselect.go (100%) rename {tea => internal/pkg/tea}/component/multispinner/multispinner.go (98%) rename {tea => internal/pkg/tea}/component/program/program.go (82%) rename {tea => internal/pkg/tea}/component/spinner/spinner.go (100%) rename {tea => internal/pkg/tea}/component/status.go (100%) rename {tea => internal/pkg/tea}/component/steps/cmd.go (100%) rename {tea => internal/pkg/tea}/component/steps/entry.go (100%) rename {tea => internal/pkg/tea}/component/steps/steps.go (97%) rename {tea => internal/pkg/tea}/style/container.go (100%) rename {tea => internal/pkg/tea}/style/icon.go (100%) rename {tea => internal/pkg/tea}/style/text.go (100%) rename {tea => internal/pkg/tea}/style/util.go (69%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd120d85..ce4e24d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,25 +17,36 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup Golang uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} ## skip cache, use Namespace volume cache cache: false + - name: Init Dummy Git config for testing run: | git config --global user.email "github-action@mail.com" git config --global user.name "github-action" + - name: Setup Namespace cache uses: namespacelabs/nscloud-cache-action@v1 with: cache: go + - name: Install Task run: | go install github.com/go-task/task/v3/cmd/task@latest + + - name: Generate Protobuf files + working-directory: internal/app/world-cli + run: task buf:generate + - name: Run unit tests with coverage + working-directory: internal/app/world-cli run: task test:coverage + - name: Upload coverage to Codecov if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request' uses: codecov/codecov-action@v4 @@ -52,12 +63,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup Golang uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} ## skip cache, use Namespace volume cache cache: false + - name: Setup Namespace cache uses: namespacelabs/nscloud-cache-action@v1 with: @@ -66,17 +79,28 @@ jobs: /home/runner/go/pkg /home/runner/.cache/go-build /home/runner/.cache/golangci-lint + - name: Find go path - id: go-dir run: echo "path=$(go list -f '{{.Dir}}/...' -m | xargs)" >> $GITHUB_OUTPUT ## Equivalent to 'make lint' arguments + + - name: Install Task + run: | + go install github.com/go-task/task/v3/cmd/task@latest + + - name: Generate Protobuf files + working-directory: internal/app/world-cli + run: task buf:generate + - name: golangci-lint uses: golangci/golangci-lint-action@v7 with: + working-directory: internal/app/world-cli version: latest args: --timeout=10m -v ${{ steps.go-dir.outputs.path }} ## skip cache, use Namespace volume cache skip-cache: true + lint-md: name: Lint (markdown) @@ -89,7 +113,7 @@ jobs: - uses: xt0rted/markdownlint-problem-matcher@v3 - uses: articulate/actions-markdownlint@v1 with: - config: .markdownlint.yaml + config: internal/app/world-cli/.markdownlint.yaml ignore: vendor version: 0.39.0 @@ -99,12 +123,20 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Install Go uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} + - name: Install Task run: | go install github.com/go-task/task/v3/cmd/task@latest + + - name: Generate Protobuf files + working-directory: internal/app/world-cli + run: task buf:generate + - name: Build + working-directory: internal/app/world-cli run: task build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7b64a74..3923aba8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,7 @@ jobs: distribution: goreleaser version: ${{ env.GORELEASER_VERSION }} args: release --clean + working-directory: internal/app/world-cli env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SENTRY_DSN: ${{ secrets.SENTRY_DSN }} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index f507ee76..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Debug: DEV", - "type": "go", - "request": "launch", - "mode": "debug", - "program": "${workspaceFolder}/cmd/world/main.go", - "cwd": "${workspaceFolder}", - "args": ["login"], - "console": "integratedTerminal", - "env": { - "WORLD_CLI_ENV": "DEV" - } - }, - { - "name": "Debug: PROD", - "type": "go", - "request": "launch", - "mode": "debug", - "program": "${workspaceFolder}/cmd/world/main.go", - "cwd": "${workspaceFolder}", - "args": ["login"], - "console": "integratedTerminal", - "env": { - "WORLD_CLI_ENV": "PROD" - } - }, - { - "name": "Debug: LOCAL", - "type": "go", - "request": "launch", - "mode": "debug", - "program": "${workspaceFolder}/cmd/world/main.go", - "cwd": "${workspaceFolder}", - "args": ["login"], - "console": "integratedTerminal", - "env": { - "WORLD_CLI_ENV": "LOCAL" - } - } - ] -} \ No newline at end of file diff --git a/cmd/world/cardinal/cardinal.go b/cmd/world/cardinal.go similarity index 67% rename from cmd/world/cardinal/cardinal.go rename to cmd/world/cardinal.go index dc060bd7..c0db3bc1 100644 --- a/cmd/world/cardinal/cardinal.go +++ b/cmd/world/cardinal.go @@ -1,13 +1,11 @@ -package cardinal +package main import ( "context" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/dependency" - "pkg.world.dev/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/common/dependency" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) var CardinalCmdPlugin struct { @@ -20,12 +18,12 @@ type CardinalCmd struct { Context context.Context ` kong:"-"` Dependencies cmdsetup.Dependencies ` kong:"-"` - Start *StartCmd `cmd:"" group:"Cardinal Commands:" help:"Launch your Cardinal game environment"` - Stop *StopCmd `cmd:"" group:"Cardinal Commands:" help:"Gracefully shut down your Cardinal game environment"` - Restart *RestartCmd `cmd:"" group:"Cardinal Commands:" help:"Restart your Cardinal game environment"` - Dev *DevCmd `cmd:"" group:"Cardinal Commands:" help:"Run Cardinal in fast development mode with hot reloading"` - Purge *PurgeCmd `cmd:"" group:"Cardinal Commands:" help:"Reset your Cardinal game shard to a clean state by removing all data and containers"` - Build *BuildCmd `cmd:"" group:"Cardinal Commands:" help:"Build and package your Cardinal game into production-ready Docker images"` + Start *StartCardinalCmd `cmd:"" group:"Cardinal Commands:" help:"Launch your Cardinal game environment"` + Stop *StopCardinalCmd `cmd:"" group:"Cardinal Commands:" help:"Gracefully shut down your Cardinal game environment"` + Restart *RestartCardinalCmd `cmd:"" group:"Cardinal Commands:" help:"Restart your Cardinal game environment"` + Dev *DevCardinalCmd `cmd:"" group:"Cardinal Commands:" help:"Run Cardinal in fast development mode with hot reloading"` + Purge *PurgeCardinalCmd `cmd:"" group:"Cardinal Commands:" help:"Reset your Cardinal game shard to a clean state by removing all data and containers"` + Build *BuildCardinalCmd `cmd:"" group:"Cardinal Commands:" help:"Build and package your Cardinal game into production-ready Docker images"` } func (c *CardinalCmd) Run() error { @@ -38,7 +36,7 @@ func (c *CardinalCmd) Run() error { } //nolint:lll // needed to put all the help text in the same line -type StartCmd struct { +type StartCardinalCmd struct { Parent *CardinalCmd `kong:"-"` Detach bool ` flag:"" help:"Run in detached mode"` LogLevel string ` flag:"" help:"Set the log level for Cardinal"` @@ -48,7 +46,7 @@ type StartCmd struct { EditorPort string ` flag:"" help:"Port for Cardinal Editor" default:"auto"` } -func (c *StartCmd) Run() error { +func (c *StartCardinalCmd) Run() error { flags := models.StartCardinalFlags{ Config: c.Parent.Config, Detach: c.Detach, @@ -61,24 +59,24 @@ func (c *StartCmd) Run() error { return c.Parent.Dependencies.CardinalHandler.Start(c.Parent.Context, flags) } -type StopCmd struct { +type StopCardinalCmd struct { Parent *CardinalCmd `kong:"-"` } -func (c *StopCmd) Run() error { +func (c *StopCardinalCmd) Run() error { flags := models.StopCardinalFlags{ Config: c.Parent.Config, } return c.Parent.Dependencies.CardinalHandler.Stop(c.Parent.Context, flags) } -type RestartCmd struct { +type RestartCardinalCmd struct { Parent *CardinalCmd `kong:"-"` Detach bool ` flag:"" help:"Run in detached mode"` Debug bool ` flag:"" help:"Enable debugging"` } -func (c *RestartCmd) Run() error { +func (c *RestartCardinalCmd) Run() error { flags := models.RestartCardinalFlags{ Config: c.Parent.Config, Detach: c.Detach, @@ -87,13 +85,13 @@ func (c *RestartCmd) Run() error { return c.Parent.Dependencies.CardinalHandler.Restart(c.Parent.Context, flags) } -type DevCmd struct { +type DevCardinalCmd struct { Parent *CardinalCmd `kong:"-"` Editor bool ` flag:"" help:"Enable Cardinal Editor"` PrettyLog bool ` flag:"" help:"Run Cardinal with pretty logging" default:"true"` } -func (c *DevCmd) Run() error { +func (c *DevCardinalCmd) Run() error { flags := models.DevCardinalFlags{ Config: c.Parent.Config, Editor: c.Editor, @@ -102,18 +100,18 @@ func (c *DevCmd) Run() error { return c.Parent.Dependencies.CardinalHandler.Dev(c.Parent.Context, flags) } -type PurgeCmd struct { +type PurgeCardinalCmd struct { Parent *CardinalCmd `kong:"-"` } -func (c *PurgeCmd) Run() error { +func (c *PurgeCardinalCmd) Run() error { flags := models.PurgeCardinalFlags{ Config: c.Parent.Config, } return c.Parent.Dependencies.CardinalHandler.Purge(c.Parent.Context, flags) } -type BuildCmd struct { +type BuildCardinalCmd struct { Parent *CardinalCmd `kong:"-"` LogLevel string ` flag:"" help:"Set the log level for Cardinal"` Debug bool ` flag:"" help:"Enable debugging"` @@ -125,7 +123,7 @@ type BuildCmd struct { RegToken string ` flag:"" help:"Registry token for the given image repository" hidden:"true"` } -func (c *BuildCmd) Run() error { +func (c *BuildCardinalCmd) Run() error { flags := models.BuildCardinalFlags{ Config: c.Parent.Config, LogLevel: c.LogLevel, @@ -139,19 +137,3 @@ func (c *BuildCmd) Run() error { } return c.Parent.Dependencies.CardinalHandler.Build(c.Parent.Context, flags) } - -func getServices(cfg *config.Config) []service.Builder { - services := []service.Builder{service.NakamaDB, service.Redis, service.Cardinal, service.Nakama} - if cfg.Telemetry && cfg.DockerEnv["NAKAMA_TRACE_ENABLED"] == "true" { - services = append(services, service.Jaeger) - } - if cfg.Telemetry && cfg.DockerEnv["NAKAMA_METRICS_ENABLED"] == "true" { - services = append(services, service.Prometheus) - } - return services -} - -func getCardinalServices(_ *config.Config) []service.Builder { - services := []service.Builder{service.Cardinal} - return services -} diff --git a/cmd/world/cloud/cloud.go b/cmd/world/cloud.go similarity index 69% rename from cmd/world/cloud/cloud.go rename to cmd/world/cloud.go index 095db6f3..ffcca4c9 100644 --- a/cmd/world/cloud/cloud.go +++ b/cmd/world/cloud.go @@ -1,38 +1,38 @@ -package cloud +package main import ( "context" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) //nolint:lll // needed to put all the help text in the same line -var CmdPlugin struct { - Deploy *DeployCmd `cmd:"" group:"Cloud Management Commands:" help:"Deploy your World Forge project to a TEST environment in the cloud"` - Status *StatusCmd `cmd:"" group:"Cloud Management Commands:" help:"Check the status of your deployed World Forge project"` - Promote *PromoteCmd `cmd:"" group:"Cloud Management Commands:" help:"Deploy your game project to a LIVE environment in the cloud"` - Destroy *DestroyCmd `cmd:"" group:"Cloud Management Commands:" help:"Remove your game project's deployed infrastructure from the cloud"` - Reset *ResetCmd `cmd:"" group:"Cloud Management Commands:" help:"Restart your game project with a clean state"` - Logs *LogsCmd `cmd:"" group:"Cloud Management Commands:" help:"Tail logs for your game project"` +var CloudCmdPlugin struct { + Deploy *DeployCloudCmd `cmd:"" group:"Cloud Management Commands:" help:"Deploy your World Forge project to a TEST environment in the cloud"` + Status *StatusCloudCmd `cmd:"" group:"Cloud Management Commands:" help:"Check the status of your deployed World Forge project"` + Promote *PromoteCloudCmd `cmd:"" group:"Cloud Management Commands:" help:"Deploy your game project to a LIVE environment in the cloud"` + Destroy *DestroyCloudCmd `cmd:"" group:"Cloud Management Commands:" help:"Remove your game project's deployed infrastructure from the cloud"` + Reset *ResetCloudCmd `cmd:"" group:"Cloud Management Commands:" help:"Restart your game project with a clean state"` + Logs *LogsCloudCmd `cmd:"" group:"Cloud Management Commands:" help:"Tail logs for your game project"` } -type DeployCmd struct { +type DeployCloudCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Force bool ` flag:"" help:"Force the deployment"` } -func (c *DeployCmd) Run() error { +func (c *DeployCloudCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingIDOnly, ProjectRequired: models.NeedExistingData, } - deployType := DeploymentTypeDeploy + deployType := models.DeploymentTypeDeploy if c.Force { - deployType = DeploymentTypeForceDeploy + deployType = models.DeploymentTypeForceDeploy } return cmdsetup.WithSetup(c.Context, c.Dependencies, req, func(state models.CommandState) error { @@ -40,12 +40,12 @@ func (c *DeployCmd) Run() error { }) } -type StatusCmd struct { +type StatusCloudCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` } -func (c *StatusCmd) Run() error { +func (c *StatusCloudCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, @@ -57,12 +57,12 @@ func (c *StatusCmd) Run() error { }) } -type PromoteCmd struct { +type PromoteCloudCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` } -func (c *PromoteCmd) Run() error { +func (c *PromoteCloudCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingIDOnly, @@ -74,17 +74,17 @@ func (c *PromoteCmd) Run() error { c.Context, state.Organization.ID, *state.Project, - DeploymentTypePromote, + models.DeploymentTypePromote, ) }) } -type DestroyCmd struct { +type DestroyCloudCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` } -func (c *DestroyCmd) Run() error { +func (c *DestroyCloudCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingIDOnly, @@ -96,17 +96,17 @@ func (c *DestroyCmd) Run() error { c.Context, state.Organization.ID, *state.Project, - DeploymentTypeDestroy, + models.DeploymentTypeDestroy, ) }) } -type ResetCmd struct { +type ResetCloudCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` } -func (c *ResetCmd) Run() error { +func (c *ResetCloudCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingIDOnly, @@ -118,20 +118,20 @@ func (c *ResetCmd) Run() error { c.Context, state.Organization.ID, *state.Project, - DeploymentTypeReset, + models.DeploymentTypeReset, ) }) } //nolint:lll // needed to put all the help text in the same line -type LogsCmd struct { +type LogsCloudCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Region string ` arg:"" enum:"ap-southeast-1,eu-central-1,us-east-1,us-west-2" default:"us-west-2" optional:"" help:"The region to tail logs for"` Env string ` arg:"" enum:"test,live" default:"test" optional:"" help:"The environment to tail logs for"` } -func (c *LogsCmd) Run() error { +func (c *LogsCloudCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingIDOnly, diff --git a/cmd/world/evm/evm.go b/cmd/world/evm.go similarity index 64% rename from cmd/world/evm/evm.go rename to cmd/world/evm.go index 54440c14..a4fbaf19 100644 --- a/cmd/world/evm/evm.go +++ b/cmd/world/evm.go @@ -1,21 +1,10 @@ -package evm +package main import ( "context" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/teacmd" -) - -const ( - FlagUseDevDA = "dev" - FlagDAAuthToken = "da-auth-token" //nolint:gosec // false positive - EnvDAAuthToken = "DA_AUTH_TOKEN" //nolint:gosec // false positive - EnvDABaseURL = "DA_BASE_URL" - EnvDANamespaceID = "DA_NAMESPACE_ID" - - daService = teacmd.DockerServiceDA + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) var EvmCmdPlugin struct { @@ -26,12 +15,12 @@ var EvmCmdPlugin struct { type EvmCmd struct { Config string `flag:"" help:"A TOML config file"` - Start *StartCmd `cmd:"" group:"EVM Commands:" help:"Launch your EVM blockchain environment"` - Stop *StopCmd `cmd:"" group:"EVM Commands:" help:"Shut down your EVM blockchain environment"` + Start *StartEVMCmd `cmd:"" group:"EVM Commands:" help:"Launch your EVM blockchain environment"` + Stop *StopEVMCmd `cmd:"" group:"EVM Commands:" help:"Shut down your EVM blockchain environment"` } //nolint:lll // needed to put all the help text in the same line -type StartCmd struct { +type StartEVMCmd struct { Parent *EvmCmd `kong:"-"` Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` @@ -39,7 +28,7 @@ type StartCmd struct { UseDevDA bool ` flag:"" optional:"" help:"Use a locally running DA layer" name:"dev"` } -func (c *StartCmd) Run() error { +func (c *StartEVMCmd) Run() error { flags := models.StartEVMFlags{ Config: c.Parent.Config, DAAuthToken: c.DAAuthToken, @@ -48,13 +37,13 @@ func (c *StartCmd) Run() error { return c.Dependencies.EVMHandler.Start(c.Context, flags) } -type StopCmd struct { +type StopEVMCmd struct { Parent *EvmCmd `kong:"-"` Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` } -func (c *StopCmd) Run() error { +func (c *StopEVMCmd) Run() error { flags := models.StopEVMFlags{ Config: c.Parent.Config, } diff --git a/cmd/world/main.go b/cmd/world/main.go index 4f2e7e9d..46f683d7 100644 --- a/cmd/world/main.go +++ b/cmd/world/main.go @@ -12,23 +12,23 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/getsentry/sentry-go" "github.com/rs/zerolog/log" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/browser" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - cfgService "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/cardinal" - "pkg.world.dev/world-cli/cmd/world/cloud" - "pkg.world.dev/world-cli/cmd/world/evm" - "pkg.world.dev/world-cli/cmd/world/organization" - "pkg.world.dev/world-cli/cmd/world/project" - "pkg.world.dev/world-cli/cmd/world/root" - "pkg.world.dev/world-cli/cmd/world/user" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/logger" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/telemetry" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/browser" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/repo" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/cardinal" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/cloud" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/evm" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/organization" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/project" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/root" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/user" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/telemetry" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + cfgService "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" + "pkg.world.dev/world-cli/internal/pkg/logger" + "pkg.world.dev/world-cli/internal/pkg/printer" ) const ( @@ -112,17 +112,17 @@ func main() { } // Initialize packages - root.CLI.Plugins = kong.Plugins{ - &cardinal.CardinalCmdPlugin, - &cloud.CmdPlugin, - &evm.EvmCmdPlugin, - &project.CmdPlugin, - &organization.CmdPlugin, - &user.CmdPlugin, + CLI.Plugins = kong.Plugins{ + &CardinalCmdPlugin, + &CloudCmdPlugin, + &EvmCmdPlugin, + &ProjectCmdPlugin, + &OrganizationCmdPlugin, + &UserCmdPlugin, } ctx := kong.Parse( - &root.CLI, + &CLI, kong.Name("world"), kong.Description("World CLI: Your complete toolkit for World Engine development"), kong.UsageOnError(), @@ -132,13 +132,13 @@ func main() { }), ) realCtx := contextWithSigterm(context.Background()) - SetKongParentsAndContext(realCtx, dependencies, &root.CLI) - SetKongParentsAndContext(realCtx, dependencies, &cardinal.CardinalCmdPlugin) - SetKongParentsAndContext(realCtx, dependencies, &cloud.CmdPlugin) - SetKongParentsAndContext(realCtx, dependencies, &evm.EvmCmdPlugin) - SetKongParentsAndContext(realCtx, dependencies, &project.CmdPlugin) - SetKongParentsAndContext(realCtx, dependencies, &organization.CmdPlugin) - SetKongParentsAndContext(realCtx, dependencies, &user.CmdPlugin) + SetKongParentsAndContext(realCtx, dependencies, &CLI) + SetKongParentsAndContext(realCtx, dependencies, &CardinalCmdPlugin) + SetKongParentsAndContext(realCtx, dependencies, &CloudCmdPlugin) + SetKongParentsAndContext(realCtx, dependencies, &EvmCmdPlugin) + SetKongParentsAndContext(realCtx, dependencies, &ProjectCmdPlugin) + SetKongParentsAndContext(realCtx, dependencies, &OrganizationCmdPlugin) + SetKongParentsAndContext(realCtx, dependencies, &UserCmdPlugin) err = ctx.Run() if err != nil { sentry.CaptureException(err) diff --git a/cmd/world/organization/organization.go b/cmd/world/organization.go similarity index 71% rename from cmd/world/organization/organization.go rename to cmd/world/organization.go index b44d077e..84150b1b 100644 --- a/cmd/world/organization/organization.go +++ b/cmd/world/organization.go @@ -1,30 +1,30 @@ -package organization +package main import ( "context" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) -var CmdPlugin struct { - Organization *Cmd `cmd:"" aliases:"org" group:"Organization Commands:" help:"Manage your organizations"` +var OrganizationCmdPlugin struct { + Organization *OrganizationCmd `cmd:"" aliases:"org" group:"Organization Commands:" help:"Manage your organizations"` } -type Cmd struct { - Create *CreateCmd `cmd:"" group:"Organization Commands:" help:"Create a new organization"` - Switch *SwitchCmd `cmd:"" group:"Organization Commands:" help:"Switch to an organization"` - Members *MembersListCmd `cmd:"" group:"Organization Commands:" help:"List members of an organization"` +type OrganizationCmd struct { + Create *CreateOrganizationCmd `cmd:"" group:"Organization Commands:" help:"Create a new organization"` + Switch *SwitchOrganizationCmd `cmd:"" group:"Organization Commands:" help:"Switch to an organization"` + Members *MembersListCmd `cmd:"" group:"Organization Commands:" help:"List members of an organization"` } -type CreateCmd struct { +type CreateOrganizationCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Name string ` flag:"" help:"The name of the organization"` Slug string ` flag:"" help:"The slug of the organization"` } -func (c *CreateCmd) Run() error { +func (c *CreateOrganizationCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedRepoLookup, @@ -42,13 +42,13 @@ func (c *CreateCmd) Run() error { }) } -type SwitchCmd struct { +type SwitchOrganizationCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Slug string ` flag:"" help:"The slug of the organization to switch to"` } -func (c *SwitchCmd) Run() error { +func (c *SwitchOrganizationCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedRepoLookup, diff --git a/cmd/world/project/project.go b/cmd/world/project.go similarity index 73% rename from cmd/world/project/project.go rename to cmd/world/project.go index fe93fb21..0b805d94 100644 --- a/cmd/world/project/project.go +++ b/cmd/world/project.go @@ -1,31 +1,31 @@ -package project +package main import ( "context" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) -var CmdPlugin struct { - Project *Cmd `cmd:"" aliases:"proj" group:"Project Commands:" help:"Manage your projects"` +var ProjectCmdPlugin struct { + Project *ProjectCmd `cmd:"" aliases:"proj" group:"Project Commands:" help:"Manage your projects"` } -type Cmd struct { - Create *CreateCmd `cmd:"" group:"Project Commands:" help:"Create a new project"` - Switch *SwitchCmd `cmd:"" group:"Project Commands:" help:"Switch to a different project"` - Update *UpdateCmd `cmd:"" group:"Project Commands:" help:"Update your project"` - Delete *DeleteCmd `cmd:"" group:"Project Commands:" help:"Delete your project"` +type ProjectCmd struct { + Create *CreateProjectCmd `cmd:"" group:"Project Commands:" help:"Create a new project"` + Switch *SwitchProjectCmd `cmd:"" group:"Project Commands:" help:"Switch to a different project"` + Update *UpdateProjectCmd `cmd:"" group:"Project Commands:" help:"Update your project"` + Delete *DeleteProjectCmd `cmd:"" group:"Project Commands:" help:"Delete your project"` } -type CreateCmd struct { +type CreateProjectCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Name string ` flag:"" help:"The name of the project"` Slug string ` flag:"" help:"The slug of the project"` } -func (c *CreateCmd) Run() error { +func (c *CreateProjectCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, @@ -43,13 +43,13 @@ func (c *CreateCmd) Run() error { }) } -type SwitchCmd struct { +type SwitchProjectCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Slug string ` flag:"" help:"The slug of the project to switch to"` } -func (c *SwitchCmd) Run() error { +func (c *SwitchProjectCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, @@ -66,7 +66,7 @@ func (c *SwitchCmd) Run() error { }) } -type UpdateCmd struct { +type UpdateProjectCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Name string ` flag:"" help:"The new name of the project"` @@ -74,7 +74,7 @@ type UpdateCmd struct { AvatarURL string ` flag:"" help:"The new avatar URL of the project" type:"url"` } -func (c *UpdateCmd) Run() error { +func (c *UpdateProjectCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, @@ -91,12 +91,12 @@ func (c *UpdateCmd) Run() error { }) } -type DeleteCmd struct { +type DeleteProjectCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` } -func (c *DeleteCmd) Run() error { +func (c *DeleteProjectCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, diff --git a/cmd/world/root.go b/cmd/world/root.go new file mode 100644 index 00000000..2d5a332d --- /dev/null +++ b/cmd/world/root.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + + "github.com/alecthomas/kong" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" +) + +var CLI RootCmd + +//nolint:lll // must be on one line +type RootCmd struct { + Create *CreateWorldCmd `cmd:"" group:"Getting Started:" help:"Create a new World Engine project"` + Doctor *DoctorCmd `cmd:"" group:"Getting Started:" help:"Check your development environment"` + Login *LoginCmd `cmd:"" group:"Getting Started:" help:"Login to World Forge, creating a new account if necessary"` + kong.Plugins // put this here so tools will be in the right place + Version *VersionCmd `cmd:"" group:"Additional Commands:" help:"Show the version of the CLI"` + Verbose bool ` help:"Enable World CLI Debug logs" flag:"" short:"v"` +} + +//nolint:lll // must be on one line +type CreateWorldCmd struct { + Parent *RootCmd `kong:"-"` + Dependencies cmdsetup.Dependencies `kong:"-"` + Directory string ` arg:"" optional:"" type:"path" help:"The directory to create the project in"` +} + +func (c *CreateWorldCmd) Run() error { + return c.Dependencies.RootHandler.Create(c.Directory) +} + +type DoctorCmd struct { + Parent *RootCmd `kong:"-"` + Dependencies cmdsetup.Dependencies `kong:"-"` +} + +func (c *DoctorCmd) Run() error { + return c.Dependencies.RootHandler.Doctor() +} + +type VersionCmd struct { + Parent *RootCmd `kong:"-"` + Dependencies cmdsetup.Dependencies `kong:"-"` + Check bool ` help:"Check for the latest version of the CLI"` +} + +func (c *VersionCmd) Run() error { + return c.Dependencies.RootHandler.Version(c.Check) +} + +type LoginCmd struct { + Parent *RootCmd `kong:"-"` + Context context.Context `kong:"-"` + Dependencies cmdsetup.Dependencies `kong:"-"` +} + +func (c *LoginCmd) Run() error { + return c.Dependencies.RootHandler.Login(c.Context) +} diff --git a/cmd/world/root/root.go b/cmd/world/root/root.go deleted file mode 100644 index b14822d9..00000000 --- a/cmd/world/root/root.go +++ /dev/null @@ -1,60 +0,0 @@ -package root - -import ( - "context" - - "github.com/alecthomas/kong" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" -) - -var CLI Cmd - -//nolint:lll // must be on one line -type Cmd struct { - Create *CreateCmd `cmd:"" group:"Getting Started:" help:"Create a new World Engine project"` - Doctor *DoctorCmd `cmd:"" group:"Getting Started:" help:"Check your development environment"` - Login *LoginCmd `cmd:"" group:"Getting Started:" help:"Login to World Forge, creating a new account if necessary"` - kong.Plugins // put this here so tools will be in the right place - Version *VersionCmd `cmd:"" group:"Additional Commands:" help:"Show the version of the CLI"` - Verbose bool ` help:"Enable World CLI Debug logs" flag:"" short:"v"` -} - -//nolint:lll // must be on one line -type CreateCmd struct { - Parent *Cmd `kong:"-"` - Dependencies cmdsetup.Dependencies `kong:"-"` - Directory string ` arg:"" optional:"" type:"path" help:"The directory to create the project in"` -} - -func (c *CreateCmd) Run() error { - return c.Dependencies.RootHandler.Create(c.Directory) -} - -type DoctorCmd struct { - Parent *Cmd `kong:"-"` - Dependencies cmdsetup.Dependencies `kong:"-"` -} - -func (c *DoctorCmd) Run() error { - return c.Dependencies.RootHandler.Doctor() -} - -type VersionCmd struct { - Parent *Cmd `kong:"-"` - Dependencies cmdsetup.Dependencies `kong:"-"` - Check bool ` help:"Check for the latest version of the CLI"` -} - -func (c *VersionCmd) Run() error { - return c.Dependencies.RootHandler.Version(c.Check) -} - -type LoginCmd struct { - Parent *Cmd `kong:"-"` - Context context.Context `kong:"-"` - Dependencies cmdsetup.Dependencies `kong:"-"` -} - -func (c *LoginCmd) Run() error { - return c.Dependencies.RootHandler.Login(c.Context) -} diff --git a/cmd/world/user/user.go b/cmd/world/user.go similarity index 71% rename from cmd/world/user/user.go rename to cmd/world/user.go index 11ec990e..3e2d8383 100644 --- a/cmd/world/user/user.go +++ b/cmd/world/user.go @@ -1,31 +1,31 @@ -package user +package main import ( "context" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) -var CmdPlugin struct { - User *Cmd `cmd:""` +var UserCmdPlugin struct { + User *UserCmd `cmd:""` } //nolint:lll // needed to put all the help text in the same line -type Cmd struct { - Invite *InviteToOrganizationCmd `cmd:"" group:"User Commands:" optional:"" help:"Invite a user to an organization"` - Role *ChangeRoleInOrganizationCmd `cmd:"" group:"User Commands:" optional:"" help:"Change a user's role in an organization"` - Update *UpdateCmd `cmd:"" group:"User Commands:" optional:"" help:"Update a user"` +type UserCmd struct { + Invite *InviteUserToOrganizationCmd `cmd:"" group:"User Commands:" optional:"" help:"Invite a user to an organization"` + Role *ChangeUserRoleInOrganizationCmd `cmd:"" group:"User Commands:" optional:"" help:"Change a user's role in an organization"` + Update *UpdateUserCmd `cmd:"" group:"User Commands:" optional:"" help:"Update a user"` } -type InviteToOrganizationCmd struct { +type InviteUserToOrganizationCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Email string ` flag:"" help:"The email of the user to invite"` Role string ` flag:"" help:"The role of the user to invite"` } -func (c *InviteToOrganizationCmd) Run() error { +func (c *InviteUserToOrganizationCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, @@ -42,14 +42,14 @@ func (c *InviteToOrganizationCmd) Run() error { }) } -type ChangeRoleInOrganizationCmd struct { +type ChangeUserRoleInOrganizationCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Email string ` flag:"" help:"The email of the user to change the role of"` Role string ` flag:"" help:"The new role of the user"` } -func (c *ChangeRoleInOrganizationCmd) Run() error { +func (c *ChangeUserRoleInOrganizationCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, @@ -66,13 +66,13 @@ func (c *ChangeRoleInOrganizationCmd) Run() error { }) } -type UpdateCmd struct { +type UpdateUserCmd struct { Context context.Context `kong:"-"` Dependencies cmdsetup.Dependencies `kong:"-"` Name string ` flag:"" help:"The new name of the user"` } -func (c *UpdateCmd) Run() error { +func (c *UpdateUserCmd) Run() error { req := models.SetupRequest{ LoginRequired: models.NeedLogin, OrganizationRequired: models.NeedExistingData, diff --git a/common/util/util.go b/common/util/util.go deleted file mode 100644 index a76da2fe..00000000 --- a/common/util/util.go +++ /dev/null @@ -1,18 +0,0 @@ -package util - -import ( - "os" - - tea "github.com/charmbracelet/bubbletea" - "golang.org/x/term" -) - -// NewTeaProgram will create a BubbleTea program that automatically sets the no input option -// if you are not on a TTY, so you can run the debugger. Call it just as you would call tea.NewProgram(). -func NewTeaProgram(model tea.Model, opts ...tea.ProgramOption) *tea.Program { - if !term.IsTerminal(int(os.Stderr.Fd())) { - opts = append(opts, tea.WithInput(nil)) - // opts = append(opts, tea.WithoutRenderer()) - } - return tea.NewProgram(model, opts...) -} diff --git a/gen/logs/v1/logs.pb.go b/gen/logs/v1/logs.pb.go deleted file mode 100644 index 157ccd66..00000000 --- a/gen/logs/v1/logs.pb.go +++ /dev/null @@ -1,201 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc (unknown) -// source: logs/v1/logs.proto - -package logsv1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type GetLogsRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - OrganizationSlug string `protobuf:"bytes,1,opt,name=organization_slug,json=organizationSlug,proto3" json:"organization_slug,omitempty"` - ProjectSlug string `protobuf:"bytes,2,opt,name=project_slug,json=projectSlug,proto3" json:"project_slug,omitempty"` - Env string `protobuf:"bytes,3,opt,name=env,proto3" json:"env,omitempty"` - Region string `protobuf:"bytes,4,opt,name=region,proto3" json:"region,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetLogsRequest) Reset() { - *x = GetLogsRequest{} - mi := &file_logs_v1_logs_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetLogsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetLogsRequest) ProtoMessage() {} - -func (x *GetLogsRequest) ProtoReflect() protoreflect.Message { - mi := &file_logs_v1_logs_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetLogsRequest.ProtoReflect.Descriptor instead. -func (*GetLogsRequest) Descriptor() ([]byte, []int) { - return file_logs_v1_logs_proto_rawDescGZIP(), []int{0} -} - -func (x *GetLogsRequest) GetOrganizationSlug() string { - if x != nil { - return x.OrganizationSlug - } - return "" -} - -func (x *GetLogsRequest) GetProjectSlug() string { - if x != nil { - return x.ProjectSlug - } - return "" -} - -func (x *GetLogsRequest) GetEnv() string { - if x != nil { - return x.Env - } - return "" -} - -func (x *GetLogsRequest) GetRegion() string { - if x != nil { - return x.Region - } - return "" -} - -type GetLogsResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Log string `protobuf:"bytes,1,opt,name=log,proto3" json:"log,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetLogsResponse) Reset() { - *x = GetLogsResponse{} - mi := &file_logs_v1_logs_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetLogsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetLogsResponse) ProtoMessage() {} - -func (x *GetLogsResponse) ProtoReflect() protoreflect.Message { - mi := &file_logs_v1_logs_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetLogsResponse.ProtoReflect.Descriptor instead. -func (*GetLogsResponse) Descriptor() ([]byte, []int) { - return file_logs_v1_logs_proto_rawDescGZIP(), []int{1} -} - -func (x *GetLogsResponse) GetLog() string { - if x != nil { - return x.Log - } - return "" -} - -var File_logs_v1_logs_proto protoreflect.FileDescriptor - -const file_logs_v1_logs_proto_rawDesc = "" + - "\n" + - "\x12logs/v1/logs.proto\x12\alogs.v1\"\x8a\x01\n" + - "\x0eGetLogsRequest\x12+\n" + - "\x11organization_slug\x18\x01 \x01(\tR\x10organizationSlug\x12!\n" + - "\fproject_slug\x18\x02 \x01(\tR\vprojectSlug\x12\x10\n" + - "\x03env\x18\x03 \x01(\tR\x03env\x12\x16\n" + - "\x06region\x18\x04 \x01(\tR\x06region\"#\n" + - "\x0fGetLogsResponse\x12\x10\n" + - "\x03log\x18\x01 \x01(\tR\x03log2M\n" + - "\vLogsService\x12>\n" + - "\aGetLogs\x12\x17.logs.v1.GetLogsRequest\x1a\x18.logs.v1.GetLogsResponse0\x01B\x81\x01\n" + - "\vcom.logs.v1B\tLogsProtoP\x01Z*pkg.world.dev/world-cli/gen/logs/v1;logsv1\xa2\x02\x03LXX\xaa\x02\aLogs.V1\xca\x02\aLogs\\V1\xe2\x02\x13Logs\\V1\\GPBMetadata\xea\x02\bLogs::V1b\x06proto3" - -var ( - file_logs_v1_logs_proto_rawDescOnce sync.Once - file_logs_v1_logs_proto_rawDescData []byte -) - -func file_logs_v1_logs_proto_rawDescGZIP() []byte { - file_logs_v1_logs_proto_rawDescOnce.Do(func() { - file_logs_v1_logs_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_logs_v1_logs_proto_rawDesc), len(file_logs_v1_logs_proto_rawDesc))) - }) - return file_logs_v1_logs_proto_rawDescData -} - -var file_logs_v1_logs_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_logs_v1_logs_proto_goTypes = []any{ - (*GetLogsRequest)(nil), // 0: logs.v1.GetLogsRequest - (*GetLogsResponse)(nil), // 1: logs.v1.GetLogsResponse -} -var file_logs_v1_logs_proto_depIdxs = []int32{ - 0, // 0: logs.v1.LogsService.GetLogs:input_type -> logs.v1.GetLogsRequest - 1, // 1: logs.v1.LogsService.GetLogs:output_type -> logs.v1.GetLogsResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_logs_v1_logs_proto_init() } -func file_logs_v1_logs_proto_init() { - if File_logs_v1_logs_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_logs_v1_logs_proto_rawDesc), len(file_logs_v1_logs_proto_rawDesc)), - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_logs_v1_logs_proto_goTypes, - DependencyIndexes: file_logs_v1_logs_proto_depIdxs, - MessageInfos: file_logs_v1_logs_proto_msgTypes, - }.Build() - File_logs_v1_logs_proto = out.File - file_logs_v1_logs_proto_goTypes = nil - file_logs_v1_logs_proto_depIdxs = nil -} diff --git a/.gitignore b/internal/app/world-cli/.gitignore similarity index 100% rename from .gitignore rename to internal/app/world-cli/.gitignore diff --git a/.golangci.yaml b/internal/app/world-cli/.golangci.yaml similarity index 100% rename from .golangci.yaml rename to internal/app/world-cli/.golangci.yaml diff --git a/.goreleaser.yaml b/internal/app/world-cli/.goreleaser.yaml similarity index 98% rename from .goreleaser.yaml rename to internal/app/world-cli/.goreleaser.yaml index 00b410e0..ba7f78f4 100644 --- a/.goreleaser.yaml +++ b/internal/app/world-cli/.goreleaser.yaml @@ -11,7 +11,7 @@ before: - go generate ./... builds: - - main: ./cmd/world + - main: ./../../../cmd/world binary: world env: - CGO_ENABLED=0 diff --git a/.markdownlint.yaml b/internal/app/world-cli/.markdownlint.yaml similarity index 100% rename from .markdownlint.yaml rename to internal/app/world-cli/.markdownlint.yaml diff --git a/DEVELOPER.md b/internal/app/world-cli/DEVELOPER.md similarity index 100% rename from DEVELOPER.md rename to internal/app/world-cli/DEVELOPER.md diff --git a/LICENSE b/internal/app/world-cli/LICENSE similarity index 100% rename from LICENSE rename to internal/app/world-cli/LICENSE diff --git a/README.md b/internal/app/world-cli/README.md similarity index 100% rename from README.md rename to internal/app/world-cli/README.md diff --git a/Taskfile.yml b/internal/app/world-cli/Taskfile.yml similarity index 100% rename from Taskfile.yml rename to internal/app/world-cli/Taskfile.yml diff --git a/buf.gen.yaml b/internal/app/world-cli/buf.gen.yaml similarity index 81% rename from buf.gen.yaml rename to internal/app/world-cli/buf.gen.yaml index 98652f6d..0df91a2e 100644 --- a/buf.gen.yaml +++ b/internal/app/world-cli/buf.gen.yaml @@ -3,7 +3,7 @@ managed: enabled: true override: - file_option: go_package_prefix - value: pkg.world.dev/world-cli/gen + value: pkg.world.dev/world-cli/internal/app/world-cli/gen plugins: - remote: buf.build/protocolbuffers/go out: gen diff --git a/buf.yaml b/internal/app/world-cli/buf.yaml similarity index 100% rename from buf.yaml rename to internal/app/world-cli/buf.yaml diff --git a/cmd/world/internal/clients/api/api_internal_test.go b/internal/app/world-cli/clients/api/api_internal_test.go similarity index 100% rename from cmd/world/internal/clients/api/api_internal_test.go rename to internal/app/world-cli/clients/api/api_internal_test.go diff --git a/cmd/world/internal/clients/api/client.go b/internal/app/world-cli/clients/api/client.go similarity index 99% rename from cmd/world/internal/clients/api/client.go rename to internal/app/world-cli/clients/api/client.go index 736fb182..f3b68a47 100644 --- a/cmd/world/internal/clients/api/client.go +++ b/internal/app/world-cli/clients/api/client.go @@ -15,7 +15,7 @@ import ( "github.com/rotisserie/eris" "github.com/tidwall/gjson" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/pkg/printer" ) const ( diff --git a/cmd/world/internal/clients/api/cloud.go b/internal/app/world-cli/clients/api/cloud.go similarity index 98% rename from cmd/world/internal/clients/api/cloud.go rename to internal/app/world-cli/clients/api/cloud.go index 026cbf3a..dff55baf 100644 --- a/cmd/world/internal/clients/api/cloud.go +++ b/internal/app/world-cli/clients/api/cloud.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // ======================================== diff --git a/cmd/world/internal/clients/api/login.go b/internal/app/world-cli/clients/api/login.go similarity index 97% rename from cmd/world/internal/clients/api/login.go rename to internal/app/world-cli/clients/api/login.go index b2983e38..ff8f9ab7 100644 --- a/cmd/world/internal/clients/api/login.go +++ b/internal/app/world-cli/clients/api/login.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // ======================================== diff --git a/cmd/world/internal/clients/api/mock.go b/internal/app/world-cli/clients/api/mock.go similarity index 99% rename from cmd/world/internal/clients/api/mock.go rename to internal/app/world-cli/clients/api/mock.go index cdfe561c..50f3cd04 100644 --- a/cmd/world/internal/clients/api/mock.go +++ b/internal/app/world-cli/clients/api/mock.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // Ensure MockClient implements the interface. diff --git a/cmd/world/internal/clients/api/organization.go b/internal/app/world-cli/clients/api/organization.go similarity index 98% rename from cmd/world/internal/clients/api/organization.go rename to internal/app/world-cli/clients/api/organization.go index ef557d4d..467c6e92 100644 --- a/cmd/world/internal/clients/api/organization.go +++ b/internal/app/world-cli/clients/api/organization.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // ErrOrganizationSlugAlreadyExists is passed from forge to world-cli, Must always match. diff --git a/cmd/world/internal/clients/api/project.go b/internal/app/world-cli/clients/api/project.go similarity index 98% rename from cmd/world/internal/clients/api/project.go rename to internal/app/world-cli/clients/api/project.go index 1b16ee75..58a7d267 100644 --- a/cmd/world/internal/clients/api/project.go +++ b/internal/app/world-cli/clients/api/project.go @@ -7,7 +7,7 @@ import ( "sort" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // ErrProjectSlugAlreadyExists is passed from forge to world-cli, Must always match. diff --git a/cmd/world/internal/clients/api/types.go b/internal/app/world-cli/clients/api/types.go similarity index 99% rename from cmd/world/internal/clients/api/types.go rename to internal/app/world-cli/clients/api/types.go index ebbec643..b9ac9e64 100644 --- a/cmd/world/internal/clients/api/types.go +++ b/internal/app/world-cli/clients/api/types.go @@ -6,7 +6,7 @@ import ( "time" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) const ( diff --git a/cmd/world/internal/clients/api/user.go b/internal/app/world-cli/clients/api/user.go similarity index 94% rename from cmd/world/internal/clients/api/user.go rename to internal/app/world-cli/clients/api/user.go index a44e75fc..1a79362a 100644 --- a/cmd/world/internal/clients/api/user.go +++ b/internal/app/world-cli/clients/api/user.go @@ -4,7 +4,7 @@ import ( "context" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) var ( diff --git a/cmd/world/internal/clients/browser/browser.go b/internal/app/world-cli/clients/browser/browser.go similarity index 92% rename from cmd/world/internal/clients/browser/browser.go rename to internal/app/world-cli/clients/browser/browser.go index 208803ae..c1e06cfa 100644 --- a/cmd/world/internal/clients/browser/browser.go +++ b/internal/app/world-cli/clients/browser/browser.go @@ -4,7 +4,7 @@ import ( "os/exec" "runtime" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/pkg/printer" ) // OpenURL opens the given URL in the default browser. diff --git a/cmd/world/internal/clients/browser/mock.go b/internal/app/world-cli/clients/browser/mock.go similarity index 100% rename from cmd/world/internal/clients/browser/mock.go rename to internal/app/world-cli/clients/browser/mock.go diff --git a/cmd/world/internal/clients/browser/types.go b/internal/app/world-cli/clients/browser/types.go similarity index 100% rename from cmd/world/internal/clients/browser/types.go rename to internal/app/world-cli/clients/browser/types.go diff --git a/cmd/world/internal/clients/repo/mock.go b/internal/app/world-cli/clients/repo/mock.go similarity index 100% rename from cmd/world/internal/clients/repo/mock.go rename to internal/app/world-cli/clients/repo/mock.go diff --git a/cmd/world/internal/clients/repo/repo.go b/internal/app/world-cli/clients/repo/repo.go similarity index 100% rename from cmd/world/internal/clients/repo/repo.go rename to internal/app/world-cli/clients/repo/repo.go diff --git a/cmd/world/internal/clients/repo/repo_internal_test.go b/internal/app/world-cli/clients/repo/repo_internal_test.go similarity index 100% rename from cmd/world/internal/clients/repo/repo_internal_test.go rename to internal/app/world-cli/clients/repo/repo_internal_test.go diff --git a/cmd/world/internal/clients/repo/types.go b/internal/app/world-cli/clients/repo/types.go similarity index 100% rename from cmd/world/internal/clients/repo/types.go rename to internal/app/world-cli/clients/repo/types.go diff --git a/cmd/world/cardinal/build.go b/internal/app/world-cli/commands/cardinal/build.go similarity index 92% rename from cmd/world/cardinal/build.go rename to internal/app/world-cli/commands/cardinal/build.go index 2df5312a..0a788005 100644 --- a/cmd/world/cardinal/build.go +++ b/internal/app/world-cli/commands/cardinal/build.go @@ -9,11 +9,11 @@ import ( "github.com/rotisserie/eris" "github.com/rs/zerolog" "golang.org/x/sync/errgroup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) func (h *Handler) Build(ctx context.Context, f models.BuildCardinalFlags) error { diff --git a/cmd/world/cardinal/cardinal_internal_test.go b/internal/app/world-cli/commands/cardinal/cardinal_test.go similarity index 65% rename from cmd/world/cardinal/cardinal_internal_test.go rename to internal/app/world-cli/commands/cardinal/cardinal_test.go index d31a46a5..2851dc82 100644 --- a/cmd/world/cardinal/cardinal_internal_test.go +++ b/internal/app/world-cli/commands/cardinal/cardinal_test.go @@ -1,4 +1,4 @@ -package cardinal +package cardinal_test import ( "context" @@ -13,17 +13,8 @@ import ( "time" "gotest.tools/v3/assert" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/browser" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/cloud" - "pkg.world.dev/world-cli/cmd/world/organization" - "pkg.world.dev/world-cli/cmd/world/project" - "pkg.world.dev/world-cli/cmd/world/root" - "pkg.world.dev/world-cli/cmd/world/user" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/cardinal" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) var testCounter uint64 @@ -147,69 +138,6 @@ func copyDir(src, dst string) error { }) } -// createTestDependencies creates a minimal set of dependencies for testing. -func createTestDependencies() cmdsetup.Dependencies { - configService, _ := config.NewService("LOCAL") - inputService := input.NewService() - repoClient := repo.NewClient() - apiClient := api.NewClient("", "", "") - - projectHandler := project.NewHandler( - repoClient, - configService, - apiClient, - &inputService, - ) - - orgHandler := organization.NewHandler( - projectHandler, - &inputService, - apiClient, - configService, - ) - - userHandler := user.NewHandler( - apiClient, - &inputService, - ) - - cloudHandler := cloud.NewHandler( - apiClient, - configService, - projectHandler, - &inputService, - ) - - setupController := cmdsetup.NewController( - configService, - repoClient, - orgHandler, - projectHandler, - apiClient, - &inputService, - ) - - browserClient := browser.NewClient() - rootHandler := root.NewHandler("test-version", configService, apiClient, setupController, browserClient) - - // Create Cardinal handler - cardinalHandler := &Handler{} - - return cmdsetup.Dependencies{ - ConfigService: configService, - InputService: &inputService, - APIClient: apiClient, - RepoClient: repoClient, - OrganizationHandler: orgHandler, - ProjectHandler: projectHandler, - UserHandler: userHandler, - CloudHandler: cloudHandler, - SetupController: setupController, - RootHandler: rootHandler, - CardinalHandler: cardinalHandler, - } -} - func TestCardinalStartStopRestartPurge(t *testing.T) { t.Skip("Skipping cardinal start stop restart purge test") @@ -232,30 +160,20 @@ func TestCardinalStartStopRestartPurge(t *testing.T) { // Change to the template directory (auto-resets after test) t.Chdir(templateDir) - // Create dependencies and CLI commands - dependencies := createTestDependencies() - - // Start cardinal - startCmd := StartCmd{ // cardinal start --detach --editor=false - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, + cardinalHandler := &cardinal.Handler{} + startFlags := models.StartCardinalFlags{ Editor: false, Detach: true, } - err = startCmd.Run() + + // Start cardinal + err = cardinalHandler.Start(t.Context(), startFlags) assert.NilError(t, err) defer func() { // Purge cardinal - purgeCmd := PurgeCmd{ - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, - } - err = purgeCmd.Run() + purgeFlags := models.PurgeCardinalFlags{} + err = cardinalHandler.Purge(t.Context(), purgeFlags) assert.NilError(t, err) }() @@ -263,27 +181,18 @@ func TestCardinalStartStopRestartPurge(t *testing.T) { assert.Assert(t, cardinalIsUp(t), "Cardinal is not running") // Restart cardinal - restartCmd := RestartCmd{ // cardinal restart --detach - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, + restartFlags := models.RestartCardinalFlags{ Detach: true, } - err = restartCmd.Run() + err = cardinalHandler.Restart(t.Context(), restartFlags) assert.NilError(t, err) // Check and wait until cardinal is healthy assert.Assert(t, cardinalIsUp(t), "Cardinal is not running") // Stop cardinal - stopCmd := StopCmd{ - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, - } - err = stopCmd.Run() + stopFlags := models.StopCardinalFlags{} + err = cardinalHandler.Stop(t.Context(), stopFlags) assert.NilError(t, err) // Check and wait until cardinal shutdowns @@ -315,20 +224,14 @@ func TestCardinalDev(t *testing.T) { ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second) defer cancel() - // Create dependencies and CLI commands - dependencies := createTestDependencies() - - devCmd := DevCmd{ // cardinal dev --editor=false - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: ctx, - }, + cardinalHandler := &cardinal.Handler{} + devFlags := models.DevCardinalFlags{ Editor: false, } done := make(chan error, 1) go func() { - done <- devCmd.Run() + done <- cardinalHandler.Dev(ctx, devFlags) }() // Check and wait until cardinal is healthy @@ -368,14 +271,8 @@ func TestCardinalStart(t *testing.T) { // Change to the template directory (auto-resets after test) t.Chdir(templateDir) - // Create dependencies and CLI commands - dependencies := createTestDependencies() - - startCmd := StartCmd{ - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, + cardinalHandler := &cardinal.Handler{} + startFlags := models.StartCardinalFlags{ Editor: false, Detach: true, } @@ -383,20 +280,15 @@ func TestCardinalStart(t *testing.T) { // Start Cardinal in background done := make(chan error, 1) go func() { - done <- startCmd.Run() + done <- cardinalHandler.Start(t.Context(), startFlags) }() // Wait until Cardinal is up assert.Assert(t, cardinalIsUp(t), "Cardinal should be running") // Stop Cardinal - stopCmd := StopCmd{ - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, - } - err = stopCmd.Run() + stopFlags := models.StopCardinalFlags{} + err = cardinalHandler.Stop(t.Context(), stopFlags) assert.NilError(t, err) // Verify Cardinal is down @@ -428,28 +320,18 @@ func TestCardinalBuild(t *testing.T) { // Change to the template directory (auto-resets after test) t.Chdir(templateDir) - // Create dependencies and CLI commands - dependencies := createTestDependencies() - - // Build cardinal - buildCmd := BuildCmd{ - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, + cardinalHandler := &cardinal.Handler{} + buildFlags := models.BuildCardinalFlags{ LogLevel: "info", } - err = buildCmd.Run() + + // Build cardinal + err = cardinalHandler.Build(t.Context(), buildFlags) assert.NilError(t, err) // Cleanup - purge any containers that might have been created during build defer func() { - purgeCmd := PurgeCmd{ - Parent: &CardinalCmd{ - Dependencies: dependencies, - Context: t.Context(), - }, - } - _ = purgeCmd.Run() // Ignore errors in cleanup + purgeFlags := models.PurgeCardinalFlags{} + _ = cardinalHandler.Purge(t.Context(), purgeFlags) // Ignore errors in cleanup }() } diff --git a/cmd/world/cardinal/dev.go b/internal/app/world-cli/commands/cardinal/dev.go similarity index 93% rename from cmd/world/cardinal/dev.go rename to internal/app/world-cli/commands/cardinal/dev.go index b98d7505..78972660 100644 --- a/cmd/world/cardinal/dev.go +++ b/internal/app/world-cli/commands/cardinal/dev.go @@ -14,14 +14,14 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/rotisserie/eris" "golang.org/x/sync/errgroup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/logger" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/logger" + "pkg.world.dev/world-cli/internal/pkg/printer" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) const ( diff --git a/cmd/world/cardinal/mocks.go b/internal/app/world-cli/commands/cardinal/mocks.go similarity index 89% rename from cmd/world/cardinal/mocks.go rename to internal/app/world-cli/commands/cardinal/mocks.go index af108576..f73e59de 100644 --- a/cmd/world/cardinal/mocks.go +++ b/internal/app/world-cli/commands/cardinal/mocks.go @@ -4,8 +4,8 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) var _ interfaces.CardinalHandler = (*MockHandler)(nil) diff --git a/cmd/world/cardinal/purge.go b/internal/app/world-cli/commands/cardinal/purge.go similarity index 65% rename from cmd/world/cardinal/purge.go rename to internal/app/world-cli/commands/cardinal/purge.go index af71c3d4..c266e522 100644 --- a/cmd/world/cardinal/purge.go +++ b/internal/app/world-cli/commands/cardinal/purge.go @@ -3,11 +3,11 @@ package cardinal import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) Purge(ctx context.Context, f models.PurgeCardinalFlags) error { diff --git a/cmd/world/cardinal/restart.go b/internal/app/world-cli/commands/cardinal/restart.go similarity index 72% rename from cmd/world/cardinal/restart.go rename to internal/app/world-cli/commands/cardinal/restart.go index b0141936..0c59381a 100644 --- a/cmd/world/cardinal/restart.go +++ b/internal/app/world-cli/commands/cardinal/restart.go @@ -3,9 +3,9 @@ package cardinal import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) func (h *Handler) Restart(ctx context.Context, f models.RestartCardinalFlags) error { diff --git a/cmd/world/cardinal/start.go b/internal/app/world-cli/commands/cardinal/start.go similarity index 82% rename from cmd/world/cardinal/start.go rename to internal/app/world-cli/commands/cardinal/start.go index 21c99493..fb288e8c 100644 --- a/cmd/world/cardinal/start.go +++ b/internal/app/world-cli/commands/cardinal/start.go @@ -11,12 +11,13 @@ import ( "github.com/rotisserie/eris" "github.com/rs/zerolog" "golang.org/x/sync/errgroup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) const ( @@ -147,3 +148,19 @@ func validLogLevels() string { zerolog.Disabled.String(), }, ", ") } + +func getServices(cfg *config.Config) []service.Builder { + services := []service.Builder{service.NakamaDB, service.Redis, service.Cardinal, service.Nakama} + if cfg.Telemetry && cfg.DockerEnv["NAKAMA_TRACE_ENABLED"] == "true" { + services = append(services, service.Jaeger) + } + if cfg.Telemetry && cfg.DockerEnv["NAKAMA_METRICS_ENABLED"] == "true" { + services = append(services, service.Prometheus) + } + return services +} + +func getCardinalServices(_ *config.Config) []service.Builder { + services := []service.Builder{service.Cardinal} + return services +} diff --git a/cmd/world/cardinal/stop.go b/internal/app/world-cli/commands/cardinal/stop.go similarity index 64% rename from cmd/world/cardinal/stop.go rename to internal/app/world-cli/commands/cardinal/stop.go index 2bb939d9..0ab43449 100644 --- a/cmd/world/cardinal/stop.go +++ b/internal/app/world-cli/commands/cardinal/stop.go @@ -3,11 +3,11 @@ package cardinal import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) Stop(ctx context.Context, f models.StopCardinalFlags) error { diff --git a/cmd/world/cardinal/types.go b/internal/app/world-cli/commands/cardinal/types.go similarity index 70% rename from cmd/world/cardinal/types.go rename to internal/app/world-cli/commands/cardinal/types.go index 16f1deff..5b707a7e 100644 --- a/cmd/world/cardinal/types.go +++ b/internal/app/world-cli/commands/cardinal/types.go @@ -1,6 +1,6 @@ package cardinal -import "pkg.world.dev/world-cli/cmd/world/internal/interfaces" +import "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" var _ interfaces.CardinalHandler = &Handler{} diff --git a/cmd/world/cardinal/util_editor.go b/internal/app/world-cli/commands/cardinal/util_editor.go similarity index 94% rename from cmd/world/cardinal/util_editor.go rename to internal/app/world-cli/commands/cardinal/util_editor.go index ad414945..ffdc919e 100644 --- a/cmd/world/cardinal/util_editor.go +++ b/internal/app/world-cli/commands/cardinal/util_editor.go @@ -9,7 +9,7 @@ import ( "github.com/rotisserie/eris" "golang.org/x/sync/errgroup" - "pkg.world.dev/world-cli/common/editor" + "pkg.world.dev/world-cli/internal/app/world-cli/common/editor" ) const ceReadTimeout = 5 * time.Second diff --git a/cmd/world/cloud/cloud_internal_test.go b/internal/app/world-cli/commands/cloud/cloud_test.go similarity index 75% rename from cmd/world/cloud/cloud_internal_test.go rename to internal/app/world-cli/commands/cloud/cloud_test.go index 35cc1100..65a9fe73 100644 --- a/cmd/world/cloud/cloud_internal_test.go +++ b/internal/app/world-cli/commands/cloud/cloud_test.go @@ -7,12 +7,12 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/cloud" - "pkg.world.dev/world-cli/cmd/world/project" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/cloud" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/project" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) type CloudTestSuite struct { @@ -78,11 +78,11 @@ func (s *CloudTestSuite) TestHandler_DeploymentDeploy_Success() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeDeploy, + DeploymentType: models.DeploymentTypeDeploy, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypeDeploy). + mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeDeploy). Return(previewResponse, nil) // Mock confirmation @@ -90,7 +90,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentDeploy_Success() { Return(true, nil) // Mock deployment API calls - mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypeDeploy). + mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeDeploy). Return(nil) // Mock deployment status polling @@ -106,7 +106,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentDeploy_Success() { }`) mockAPI.On("GetDeploymentStatus", mock.Anything, "test-project-id").Return(statusResponse, nil) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeDeploy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDeploy) s.Require().NoError(err) mockAPI.AssertExpectations(s.T()) @@ -126,18 +126,18 @@ func (s *CloudTestSuite) TestHandler_DeploymentDeploy_UserCancels() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeDeploy, + DeploymentType: models.DeploymentTypeDeploy, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", cloud.DeploymentTypeDeploy). + mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", models.DeploymentTypeDeploy). Return(previewResponse, nil) // Mock user declining mockInput.On("Confirm", ctx, "Do you want to proceed with the Deploying? (Y/n)", "n"). Return(false, nil) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeDeploy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDeploy) s.Require().NoError(err) // Should not error when user cancels mockAPI.AssertExpectations(s.T()) @@ -163,11 +163,11 @@ func (s *CloudTestSuite) TestHandler_DeploymentDestroy_Success() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeDestroy, + DeploymentType: models.DeploymentTypeDestroy, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypeDestroy). + mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeDestroy). Return(previewResponse, nil) // Mock confirmation @@ -175,7 +175,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentDestroy_Success() { Return(true, nil) // Mock deployment API calls - mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypeDestroy). + mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeDestroy). Return(nil) // Mock deployment status polling with proper context handling @@ -191,7 +191,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentDestroy_Success() { }`) mockAPI.On("GetDeploymentStatus", mock.Anything, "test-project-id").Return(statusResponse, nil) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeDestroy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDestroy) s.Require().NoError(err) mockAPI.AssertExpectations(s.T()) @@ -218,11 +218,11 @@ func (s *CloudTestSuite) TestHandler_DeploymentReset_Success() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeReset, + DeploymentType: models.DeploymentTypeReset, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypeReset). + mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeReset). Return(previewResponse, nil) // Mock confirmation @@ -230,7 +230,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentReset_Success() { Return(true, nil) // Mock deployment API calls - mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypeReset). + mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeReset). Return(nil) // Mock deployment status polling @@ -246,7 +246,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentReset_Success() { }`) mockAPI.On("GetDeploymentStatus", mock.Anything, "test-project-id").Return(statusResponse, nil) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeReset) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeReset) s.Require().NoError(err) mockAPI.AssertExpectations(s.T()) @@ -273,11 +273,11 @@ func (s *CloudTestSuite) TestHandler_DeploymentPromote_Success() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypePromote, + DeploymentType: models.DeploymentTypePromote, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypePromote). + mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypePromote). Return(previewResponse, nil) // Mock confirmation @@ -285,7 +285,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentPromote_Success() { Return(true, nil) // Mock deployment API calls - mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypePromote). + mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypePromote). Return(nil) // Mock deployment status polling @@ -301,7 +301,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentPromote_Success() { }`) mockAPI.On("GetDeploymentStatus", mock.Anything, "test-project-id").Return(statusResponse, nil) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypePromote) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypePromote) s.Require().NoError(err) mockAPI.AssertExpectations(s.T()) @@ -328,11 +328,11 @@ func (s *CloudTestSuite) TestHandler_DeploymentForceDeploy_Success() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeForceDeploy, + DeploymentType: models.DeploymentTypeForceDeploy, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", cloud.DeploymentTypeForceDeploy). + mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeForceDeploy). Return(previewResponse, nil) // Mock confirmation @@ -369,7 +369,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentForceDeploy_Success() { }`) mockAPI.On("GetDeploymentStatus", mock.Anything, "test-project-id").Return(statusResponse2, nil) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeForceDeploy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeForceDeploy) s.Require().NoError(err) mockAPI.AssertExpectations(s.T()) @@ -383,7 +383,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentNoOrganization() { project := s.createTestProject() // Test with empty organization ID - err := handler.Deployment(ctx, "", project, cloud.DeploymentTypeDeploy) + err := handler.Deployment(ctx, "", project, models.DeploymentTypeDeploy) s.Require().NoError(err) // Should not error, just return early } @@ -424,11 +424,11 @@ func (s *CloudTestSuite) TestHandler_DeploymentCreateProject() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeDeploy, + DeploymentType: models.DeploymentTypeDeploy, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "new-project-id", cloud.DeploymentTypeDeploy). + mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "new-project-id", models.DeploymentTypeDeploy). Return(previewResponse, nil) // Mock user confirmation @@ -436,7 +436,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentCreateProject() { Return(true, nil) // Mock deploy project call with proper signature - mockAPI.On("DeployProject", mock.Anything, "test-org-id", "new-project-id", cloud.DeploymentTypeDeploy). + mockAPI.On("DeployProject", mock.Anything, "test-org-id", "new-project-id", models.DeploymentTypeDeploy). Return(nil) // Mock deployment status check @@ -452,7 +452,7 @@ func (s *CloudTestSuite) TestHandler_DeploymentCreateProject() { }`) mockAPI.On("GetDeploymentStatus", mock.Anything, "new-project-id").Return(statusResponse, nil) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeDeploy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDeploy) s.Require().NoError(err) mockAPI.AssertExpectations(s.T()) @@ -467,10 +467,10 @@ func (s *CloudTestSuite) TestHandler_DeploymentPreviewError() { project := s.createTestProject() // Mock preview deployment error - mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", cloud.DeploymentTypeDeploy). + mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", models.DeploymentTypeDeploy). Return(models.DeploymentPreview{}, errors.New("preview failed")) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeDeploy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDeploy) s.Require().Error(err) s.Contains(err.Error(), "Failed to preview deployment") @@ -489,18 +489,18 @@ func (s *CloudTestSuite) TestHandler_DeploymentInputError() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeDeploy, + DeploymentType: models.DeploymentTypeDeploy, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", cloud.DeploymentTypeDeploy). + mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", models.DeploymentTypeDeploy). Return(previewResponse, nil) // Mock input error mockInput.On("Confirm", ctx, "Do you want to proceed with the Deploying? (Y/n)", "n"). Return(false, errors.New("input failed")) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeDeploy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDeploy) s.Require().Error(err) s.Contains(err.Error(), "Failed to prompt user") @@ -520,11 +520,11 @@ func (s *CloudTestSuite) TestHandler_DeploymentAPIError() { ProjectName: "Test Project", ProjectSlug: "test-project", ExecutorName: "test-executor", - DeploymentType: cloud.DeploymentTypeDestroy, + DeploymentType: models.DeploymentTypeDestroy, TickRate: 20, Regions: []string{"us-west-2"}, } - mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", cloud.DeploymentTypeDestroy). + mockAPI.On("PreviewDeployment", ctx, "test-org-id", "test-project-id", models.DeploymentTypeDestroy). Return(previewResponse, nil) // Mock user confirmation @@ -532,10 +532,10 @@ func (s *CloudTestSuite) TestHandler_DeploymentAPIError() { Return(true, nil) // Mock API error - mockAPI.On("DeployProject", ctx, "test-org-id", "test-project-id", cloud.DeploymentTypeDestroy). + mockAPI.On("DeployProject", ctx, "test-org-id", "test-project-id", models.DeploymentTypeDestroy). Return(errors.New("API error")) - err := handler.Deployment(ctx, "test-org-id", project, cloud.DeploymentTypeDestroy) + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDestroy) s.Require().Error(err) s.Contains(err.Error(), "Failed to deploy project") @@ -658,38 +658,120 @@ func (s *CloudTestSuite) TestHandler_TailLogs_Success() { mockConfig.AssertExpectations(s.T()) } -// Test command Run methods. -func (s *CloudTestSuite) TestDeployCmd_Run() { - // Note: This would require mocking cmdsetup.WithSetup, which is complex - // For now, we test the Handler methods directly which is more important - cmd := &cloud.DeployCmd{ - Context: context.Background(), - Force: false, +// Test handler methods directly instead of command structs. +func (s *CloudTestSuite) TestHandler_Deploy() { + handler, mockAPI, mockConfig, mockInput, _ := s.createTestHandler() + ctx := context.Background() + project := s.createTestProject() + + // Mock config + testConfig := config.Config{ + OrganizationID: "test-org-id", + ProjectID: "test-project-id", } + mockConfig.On("GetConfig").Return(&testConfig).Maybe() + + // Mock preview deployment + previewResponse := models.DeploymentPreview{ + OrgName: "Test Org", + OrgSlug: "test-org", + ProjectName: "Test Project", + ProjectSlug: "test-project", + ExecutorName: "test-executor", + DeploymentType: models.DeploymentTypeDeploy, + TickRate: 20, + Regions: []string{"us-west-2"}, + } + mockAPI.On("PreviewDeployment", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeDeploy). + Return(previewResponse, nil) + + // Mock confirmation + mockInput.On("Confirm", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("string")). + Return(true, nil) - // Test that the command exists and has expected fields - s.NotNil(cmd) - s.False(cmd.Force) + // Mock deployment API calls + mockAPI.On("DeployProject", mock.Anything, "test-org-id", "test-project-id", models.DeploymentTypeDeploy). + Return(nil) + + // Mock deployment status polling + statusResponse := []byte(`{ + "data": { + "dev": { + "project_id": "test-project-id", + "created_by": "test-user", + "created_at": "2023-01-01T00:00:00Z", + "deployment_status": "created" + } + } + }`) + mockAPI.On("GetDeploymentStatus", mock.Anything, "test-project-id").Return(statusResponse, nil) + + err := handler.Deployment(ctx, "test-org-id", project, models.DeploymentTypeDeploy) + + s.Require().NoError(err) + mockAPI.AssertExpectations(s.T()) + mockConfig.AssertExpectations(s.T()) + mockInput.AssertExpectations(s.T()) } -func (s *CloudTestSuite) TestStatusCmd_Run() { - cmd := &cloud.StatusCmd{ - Context: context.Background(), - } +func (s *CloudTestSuite) TestHandler_Status() { + handler, mockAPI, _, _, _ := s.createTestHandler() + ctx := context.Background() + org := s.createTestOrganization() + project := s.createTestProject() - // Test that the command exists - s.NotNil(cmd) + // Mock deployment status + statusResponse := []byte(`{ + "data": { + "dev": { + "project_id": "test-project-id", + "created_by": "test-user", + "created_at": "2023-01-01T00:00:00Z", + "deployment_status": "created" + } + } + }`) + mockAPI.On("GetDeploymentStatus", mock.Anything, "test-project-id").Return(statusResponse, nil) + + err := handler.Status(ctx, org, project) + + s.Require().NoError(err) + mockAPI.AssertExpectations(s.T()) } -func (s *CloudTestSuite) TestLogsCmd_Run() { - cmd := &cloud.LogsCmd{ - Context: context.Background(), - Region: "us-west-2", - Env: "test", +func (s *CloudTestSuite) TestHandler_TailLogs() { + handler, mockAPI, mockConfig, mockInput, _ := s.createTestHandler() + ctx := context.Background() + + // Mock config + testConfig := config.Config{ + OrganizationID: "test-org-id", + ProjectID: "test-project-id", } + mockConfig.On("GetConfig").Return(&testConfig).Maybe() + + // Mock API calls + mockAPI.On("GetOrganizationByID", mock.Anything, "test-org-id"). + Return(s.createTestOrganization(), nil) + mockAPI.On("GetProjectByID", mock.Anything, "test-org-id", "test-project-id"). + Return(s.createTestProject(), nil) - // Test that the command exists and has expected fields - s.NotNil(cmd) - s.Equal("us-west-2", cmd.Region) - s.Equal("test", cmd.Env) + // Mock input prompts + mockInput.On("Prompt", mock.Anything, "Choose an environment", "1").Return("1", nil) + mockInput.On("Prompt", mock.Anything, "", "").Return("", nil) + + // Mock RPC base URL for logs client + mockAPI.On("GetRPCBaseURL").Return("https://api.example.com") + + // Create a context with cancellation to avoid hanging on the real network call + cancelCtx, cancel := context.WithCancel(ctx) + cancel() // Cancel immediately + + err := handler.TailLogs(cancelCtx, "us-west-2", "test") + + // Expect an error due to context cancellation, not network issues + s.Require().Error(err) + s.Contains(err.Error(), "context canceled") + mockAPI.AssertExpectations(s.T()) + mockConfig.AssertExpectations(s.T()) } diff --git a/cmd/world/cloud/deployment.go b/internal/app/world-cli/commands/cloud/deployment.go similarity index 95% rename from cmd/world/cloud/deployment.go rename to internal/app/world-cli/commands/cloud/deployment.go index 03e3b76e..38ad3088 100644 --- a/cmd/world/cloud/deployment.go +++ b/internal/app/world-cli/commands/cloud/deployment.go @@ -14,9 +14,9 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/rotisserie/eris" "github.com/rs/zerolog/log" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" - teaspinner "pkg.world.dev/world-cli/tea/component/spinner" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" + teaspinner "pkg.world.dev/world-cli/internal/pkg/tea/component/spinner" ) func (h *Handler) Deployment( @@ -53,11 +53,11 @@ func (h *Handler) Deployment( } processTitle := map[string]string{ - DeploymentTypeDeploy: "Deploying", - DeploymentTypeForceDeploy: "Force Deploying", - DeploymentTypeDestroy: "Destroying", - DeploymentTypeReset: "Resetting", - DeploymentTypePromote: "Promoting", + models.DeploymentTypeDeploy: "Deploying", + models.DeploymentTypeForceDeploy: "Force Deploying", + models.DeploymentTypeDestroy: "Destroying", + models.DeploymentTypeReset: "Resetting", + models.DeploymentTypePromote: "Promoting", } // prompt user to confirm deployment @@ -75,7 +75,7 @@ func (h *Handler) Deployment( return nil } - if deployType == DeploymentTypeForceDeploy { + if deployType == models.DeploymentTypeForceDeploy { deployType = "deploy?force=true" } @@ -85,7 +85,7 @@ func (h *Handler) Deployment( } env := DeployEnvPreview - if deployType == DeploymentTypePromote { + if deployType == models.DeploymentTypePromote { env = DeployEnvLive } @@ -454,11 +454,11 @@ func printDeploymentStatus(deployInfo DeployInfo) { func shouldShowHealth(deployInfo DeployInfo) bool { switch deployInfo.DeployType { - case DeploymentTypeDeploy: + case models.DeploymentTypeDeploy: return deployInfo.DeployStatus == DeployStatusCreated - case DeploymentTypeDestroy: + case models.DeploymentTypeDestroy: return deployInfo.DeployStatus == DeployStatusRemoved - case DeploymentTypeReset: + case models.DeploymentTypeReset: return true } return false diff --git a/cmd/world/cloud/logs.go b/internal/app/world-cli/commands/cloud/logs.go similarity index 95% rename from cmd/world/cloud/logs.go rename to internal/app/world-cli/commands/cloud/logs.go index 9395e58d..78d47485 100644 --- a/cmd/world/cloud/logs.go +++ b/internal/app/world-cli/commands/cloud/logs.go @@ -7,10 +7,10 @@ import ( "connectrpc.com/connect" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" - logsv1 "pkg.world.dev/world-cli/gen/logs/v1" - "pkg.world.dev/world-cli/gen/logs/v1/logsv1connect" + logsv1 "pkg.world.dev/world-cli/internal/app/world-cli/gen/logs/v1" + "pkg.world.dev/world-cli/internal/app/world-cli/gen/logs/v1/logsv1connect" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) TailLogs(ctx context.Context, region string, env string) error { diff --git a/cmd/world/cloud/mock.go b/internal/app/world-cli/commands/cloud/mock.go similarity index 86% rename from cmd/world/cloud/mock.go rename to internal/app/world-cli/commands/cloud/mock.go index c2fd6b9c..bcdc939d 100644 --- a/cmd/world/cloud/mock.go +++ b/internal/app/world-cli/commands/cloud/mock.go @@ -4,8 +4,8 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // Interface guard. diff --git a/cmd/world/cloud/status.go b/internal/app/world-cli/commands/cloud/status.go similarity index 91% rename from cmd/world/cloud/status.go rename to internal/app/world-cli/commands/cloud/status.go index f9b4da69..1669bbc0 100644 --- a/cmd/world/cloud/status.go +++ b/internal/app/world-cli/commands/cloud/status.go @@ -4,8 +4,8 @@ import ( "context" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) Status(ctx context.Context, organization models.Organization, project models.Project) error { diff --git a/cmd/world/cloud/types.go b/internal/app/world-cli/commands/cloud/types.go similarity index 72% rename from cmd/world/cloud/types.go rename to internal/app/world-cli/commands/cloud/types.go index 94bfbb5e..e236227f 100644 --- a/cmd/world/cloud/types.go +++ b/internal/app/world-cli/commands/cloud/types.go @@ -1,11 +1,11 @@ package cloud import ( - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) // Interface guard. @@ -19,12 +19,6 @@ type Handler struct { } const ( - DeploymentTypeDeploy = "deploy" - DeploymentTypeForceDeploy = "forceDeploy" - DeploymentTypeDestroy = "destroy" - DeploymentTypeReset = "reset" - DeploymentTypePromote = "promote" - DeployStatusFailed DeployStatus = "failed" DeployStatusCreated DeployStatus = "created" DeployStatusRemoved DeployStatus = "removed" diff --git a/cmd/world/evm/evm_internal_test.go b/internal/app/world-cli/commands/evm/evm_test.go similarity index 67% rename from cmd/world/evm/evm_internal_test.go rename to internal/app/world-cli/commands/evm/evm_test.go index 2855e842..8de6ddb5 100644 --- a/cmd/world/evm/evm_internal_test.go +++ b/internal/app/world-cli/commands/evm/evm_test.go @@ -1,4 +1,4 @@ -package evm +package evm_test import ( "context" @@ -13,17 +13,8 @@ import ( "time" "gotest.tools/v3/assert" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/browser" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/cloud" - "pkg.world.dev/world-cli/cmd/world/organization" - "pkg.world.dev/world-cli/cmd/world/project" - "pkg.world.dev/world-cli/cmd/world/root" - "pkg.world.dev/world-cli/cmd/world/user" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/evm" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) var testCounter uint64 @@ -146,69 +137,6 @@ func copyDir(src, dst string) error { }) } -// createTestDependencies creates a minimal set of dependencies for testing. -func createTestDependencies() cmdsetup.Dependencies { - configService, _ := config.NewService("LOCAL") - inputService := input.NewService() - repoClient := repo.NewClient() - apiClient := api.NewClient("", "", "") - - projectHandler := project.NewHandler( - repoClient, - configService, - apiClient, - &inputService, - ) - - orgHandler := organization.NewHandler( - projectHandler, - &inputService, - apiClient, - configService, - ) - - userHandler := user.NewHandler( - apiClient, - &inputService, - ) - - cloudHandler := cloud.NewHandler( - apiClient, - configService, - projectHandler, - &inputService, - ) - - setupController := cmdsetup.NewController( - configService, - repoClient, - orgHandler, - projectHandler, - apiClient, - &inputService, - ) - - browserClient := browser.NewClient() - rootHandler := root.NewHandler("test-version", configService, apiClient, setupController, browserClient) - - // Create EVM handler - evmHandler := &Handler{} - - return cmdsetup.Dependencies{ - ConfigService: configService, - InputService: &inputService, - APIClient: apiClient, - RepoClient: repoClient, - OrganizationHandler: orgHandler, - ProjectHandler: projectHandler, - UserHandler: userHandler, - CloudHandler: cloudHandler, - SetupController: setupController, - RootHandler: rootHandler, - EVMHandler: evmHandler, - } -} - func TestEVMStart(t *testing.T) { t.Skip("Skipping evm start test") @@ -235,19 +163,14 @@ func TestEVMStart(t *testing.T) { ctx, cancel := context.WithDeadline(t.Context(), time.Now().Add(20*time.Second)) defer cancel() - // Create dependencies and CLI commands - dependencies := createTestDependencies() - - startCmd := StartCmd{ - Parent: &EvmCmd{}, - UseDevDA: true, - Context: ctx, - Dependencies: dependencies, + evmHandler := &evm.Handler{} + flags := models.StartEVMFlags{ + UseDevDA: true, } done := make(chan error, 1) go func() { - done <- startCmd.Run() // evm start --dev + done <- evmHandler.Start(ctx, flags) }() // Check and wait until evm is up @@ -290,33 +213,22 @@ func TestEVMStop(t *testing.T) { ctx, startCancel := context.WithTimeout(t.Context(), 15*time.Second) defer startCancel() - // Create dependencies and CLI commands - dependencies := createTestDependencies() - - startCmd := StartCmd{ - Parent: &EvmCmd{}, - UseDevDA: true, - Context: ctx, - Dependencies: dependencies, + evmHandler := &evm.Handler{} + flags := models.StartEVMFlags{ + UseDevDA: true, } // Start EVM in background done := make(chan error, 1) go func() { - done <- startCmd.Run() + done <- evmHandler.Start(ctx, flags) }() // Wait until EVM is up assert.Assert(t, evmIsUp(t), "EVM should be running before we test stop") // Now test the Stop command - stopCmd := StopCmd{ - Parent: &EvmCmd{}, - Context: ctx, - Dependencies: dependencies, - } - - err = stopCmd.Run() + err = evmHandler.Stop(ctx, models.StopEVMFlags{}) assert.NilError(t, err) // Verify EVM is down @@ -353,33 +265,22 @@ func TestEVMStartAndStop(t *testing.T) { ctx, startCancel := context.WithTimeout(t.Context(), 15*time.Second) defer startCancel() - // Create dependencies and CLI commands - dependencies := createTestDependencies() - - startCmd := StartCmd{ - Parent: &EvmCmd{}, - UseDevDA: true, - Context: ctx, - Dependencies: dependencies, + evmHandler := &evm.Handler{} + flags := models.StartEVMFlags{ + UseDevDA: true, } // Start EVM in background done := make(chan error, 1) go func() { - done <- startCmd.Run() + done <- evmHandler.Start(ctx, flags) }() // Wait until EVM is up assert.Assert(t, evmIsUp(t), "EVM should be running") // Test Stop command - stopCmd := StopCmd{ - Parent: &EvmCmd{}, - Context: ctx, - Dependencies: dependencies, - } - - err = stopCmd.Run() + err = evmHandler.Stop(ctx, models.StopEVMFlags{}) assert.NilError(t, err) // Verify EVM is down diff --git a/cmd/world/evm/mock.go b/internal/app/world-cli/commands/evm/mock.go similarity index 78% rename from cmd/world/evm/mock.go rename to internal/app/world-cli/commands/evm/mock.go index beba165c..f068249a 100644 --- a/cmd/world/evm/mock.go +++ b/internal/app/world-cli/commands/evm/mock.go @@ -4,8 +4,8 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) var _ interfaces.EVMHandler = (*MockHandler)(nil) diff --git a/cmd/world/evm/start.go b/internal/app/world-cli/commands/evm/start.go similarity index 84% rename from cmd/world/evm/start.go rename to internal/app/world-cli/commands/evm/start.go index 347e9786..63902191 100644 --- a/cmd/world/evm/start.go +++ b/internal/app/world-cli/commands/evm/start.go @@ -6,13 +6,23 @@ import ( "net" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/logger" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/common/teacmd" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/common/teacmd" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/logger" + "pkg.world.dev/world-cli/internal/pkg/printer" +) + +const ( + FlagUseDevDA = "dev" + FlagDAAuthToken = "da-auth-token" //nolint:gosec // false positive + EnvDAAuthToken = "DA_AUTH_TOKEN" //nolint:gosec // false positive + EnvDABaseURL = "DA_BASE_URL" + EnvDANamespaceID = "DA_NAMESPACE_ID" + + daService = teacmd.DockerServiceDA ) func (h *Handler) Start(ctx context.Context, flags models.StartEVMFlags) error { diff --git a/cmd/world/evm/stop.go b/internal/app/world-cli/commands/evm/stop.go similarity index 61% rename from cmd/world/evm/stop.go rename to internal/app/world-cli/commands/evm/stop.go index dfe98a21..340f5b08 100644 --- a/cmd/world/evm/stop.go +++ b/internal/app/world-cli/commands/evm/stop.go @@ -3,11 +3,11 @@ package evm import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) Stop(ctx context.Context, flags models.StopEVMFlags) error { diff --git a/cmd/world/evm/types.go b/internal/app/world-cli/commands/evm/types.go similarity index 68% rename from cmd/world/evm/types.go rename to internal/app/world-cli/commands/evm/types.go index 277f42f8..0fca8203 100644 --- a/cmd/world/evm/types.go +++ b/internal/app/world-cli/commands/evm/types.go @@ -1,6 +1,6 @@ package evm -import "pkg.world.dev/world-cli/cmd/world/internal/interfaces" +import "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" var _ interfaces.EVMHandler = (*Handler)(nil) diff --git a/cmd/world/organization/create.go b/internal/app/world-cli/commands/organization/create.go similarity index 89% rename from cmd/world/organization/create.go rename to internal/app/world-cli/commands/organization/create.go index 630ba225..e5efafc1 100644 --- a/cmd/world/organization/create.go +++ b/internal/app/world-cli/commands/organization/create.go @@ -5,11 +5,11 @@ import ( "strings" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/utils/slug" - "pkg.world.dev/world-cli/cmd/world/internal/utils/validate" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/slug" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/validate" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) const MaxOrgNameLen = 50 diff --git a/cmd/world/organization/members_list.go b/internal/app/world-cli/commands/organization/members_list.go similarity index 93% rename from cmd/world/organization/members_list.go rename to internal/app/world-cli/commands/organization/members_list.go index c8ba37a1..ffc20477 100644 --- a/cmd/world/organization/members_list.go +++ b/internal/app/world-cli/commands/organization/members_list.go @@ -4,8 +4,8 @@ import ( "context" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) MembersList(ctx context.Context, org models.Organization, flags models.MembersListFlags) error { diff --git a/cmd/world/organization/mock.go b/internal/app/world-cli/commands/organization/mock.go similarity index 90% rename from cmd/world/organization/mock.go rename to internal/app/world-cli/commands/organization/mock.go index 77cd59f7..6eb08864 100644 --- a/cmd/world/organization/mock.go +++ b/internal/app/world-cli/commands/organization/mock.go @@ -4,8 +4,8 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // Interface guard. diff --git a/cmd/world/organization/organization_test.go b/internal/app/world-cli/commands/organization/organization_test.go similarity index 98% rename from cmd/world/organization/organization_test.go rename to internal/app/world-cli/commands/organization/organization_test.go index 5acf23a3..1de32061 100644 --- a/cmd/world/organization/organization_test.go +++ b/internal/app/world-cli/commands/organization/organization_test.go @@ -6,12 +6,12 @@ import ( "testing" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/organization" - "pkg.world.dev/world-cli/cmd/world/project" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/organization" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/project" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) // OrganizationTestSuite defines the test suite for organization package. diff --git a/cmd/world/organization/switch.go b/internal/app/world-cli/commands/organization/switch.go similarity index 97% rename from cmd/world/organization/switch.go rename to internal/app/world-cli/commands/organization/switch.go index ee7b87a5..621a7ffa 100644 --- a/cmd/world/organization/switch.go +++ b/internal/app/world-cli/commands/organization/switch.go @@ -5,8 +5,8 @@ import ( "strconv" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) var ( diff --git a/cmd/world/organization/types.go b/internal/app/world-cli/commands/organization/types.go similarity index 71% rename from cmd/world/organization/types.go rename to internal/app/world-cli/commands/organization/types.go index 4e0dde3c..6dfa9518 100644 --- a/cmd/world/organization/types.go +++ b/internal/app/world-cli/commands/organization/types.go @@ -1,10 +1,10 @@ package organization import ( - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) // Interface guard. diff --git a/cmd/world/organization/utils.go b/internal/app/world-cli/commands/organization/utils.go similarity index 91% rename from cmd/world/organization/utils.go rename to internal/app/world-cli/commands/organization/utils.go index a7b9c550..9d2b6474 100644 --- a/cmd/world/organization/utils.go +++ b/internal/app/world-cli/commands/organization/utils.go @@ -2,8 +2,8 @@ package organization import ( "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) saveOrganization(org models.Organization) error { diff --git a/cmd/world/project/create.go b/internal/app/world-cli/commands/project/create.go similarity index 96% rename from cmd/world/project/create.go rename to internal/app/world-cli/commands/project/create.go index 110ce329..4cb0a2f1 100644 --- a/cmd/world/project/create.go +++ b/internal/app/world-cli/commands/project/create.go @@ -8,12 +8,12 @@ import ( "strings" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/utils/slug" - "pkg.world.dev/world-cli/cmd/world/internal/utils/validate" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/common/tomlutil" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/common/tomlutil" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/slug" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/validate" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) const MaxProjectNameLen = 50 diff --git a/cmd/world/project/delete.go b/internal/app/world-cli/commands/project/delete.go similarity index 94% rename from cmd/world/project/delete.go rename to internal/app/world-cli/commands/project/delete.go index 4486ed61..565d0b1d 100644 --- a/cmd/world/project/delete.go +++ b/internal/app/world-cli/commands/project/delete.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) Delete( diff --git a/cmd/world/project/mock.go b/internal/app/world-cli/commands/project/mock.go similarity index 92% rename from cmd/world/project/mock.go rename to internal/app/world-cli/commands/project/mock.go index 51e4e4e6..91b299af 100644 --- a/cmd/world/project/mock.go +++ b/internal/app/world-cli/commands/project/mock.go @@ -4,8 +4,8 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // Interface guard. diff --git a/cmd/world/project/project_test.go b/internal/app/world-cli/commands/project/project_test.go similarity index 99% rename from cmd/world/project/project_test.go rename to internal/app/world-cli/commands/project/project_test.go index 0641a84c..3bf36e03 100644 --- a/cmd/world/project/project_test.go +++ b/internal/app/world-cli/commands/project/project_test.go @@ -9,12 +9,12 @@ import ( "testing" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/project" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/repo" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/project" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) // ProjectTestSuite defines the test suite for project package. diff --git a/cmd/world/project/region_selector.go b/internal/app/world-cli/commands/project/region_selector.go similarity index 86% rename from cmd/world/project/region_selector.go rename to internal/app/world-cli/commands/project/region_selector.go index 40b8a4ad..8994577b 100644 --- a/cmd/world/project/region_selector.go +++ b/internal/app/world-cli/commands/project/region_selector.go @@ -6,9 +6,9 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/common/util" - "pkg.world.dev/world-cli/tea/component/multiselect" + "pkg.world.dev/world-cli/internal/pkg/printer" + "pkg.world.dev/world-cli/internal/pkg/tea/component/multiselect" + "pkg.world.dev/world-cli/internal/pkg/tea/component/program" ) // TODO: This is a temporary implementation of the region selector. @@ -60,9 +60,9 @@ func (b *BubbleteeRegionSelector) runRegionSelector( selectedRegionsMap[i] = true } } - regionSelector = util.NewTeaProgram(multiselect.UpdateMultiselectModel(ctx, regions, selectedRegionsMap)) + regionSelector = program.NewTeaProgram(multiselect.UpdateMultiselectModel(ctx, regions, selectedRegionsMap)) } else { - regionSelector = util.NewTeaProgram(multiselect.InitialMultiselectModel(ctx, regions)) + regionSelector = program.NewTeaProgram(multiselect.InitialMultiselectModel(ctx, regions)) } m, err := regionSelector.Run() diff --git a/cmd/world/project/switch.go b/internal/app/world-cli/commands/project/switch.go similarity index 96% rename from cmd/world/project/switch.go rename to internal/app/world-cli/commands/project/switch.go index 5e5d000d..356a8ba3 100644 --- a/cmd/world/project/switch.go +++ b/internal/app/world-cli/commands/project/switch.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/rotisserie/eris" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) //nolint:gocognit,funlen // Belongs in a single function diff --git a/cmd/world/project/types.go b/internal/app/world-cli/commands/project/types.go similarity index 84% rename from cmd/world/project/types.go rename to internal/app/world-cli/commands/project/types.go index 224ed43a..a4c4d996 100644 --- a/cmd/world/project/types.go +++ b/internal/app/world-cli/commands/project/types.go @@ -3,11 +3,11 @@ package project import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/repo" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) const nilUUID = "00000000-0000-0000-0000-000000000000" diff --git a/cmd/world/project/update.go b/internal/app/world-cli/commands/project/update.go similarity index 91% rename from cmd/world/project/update.go rename to internal/app/world-cli/commands/project/update.go index 2119c8af..387b659c 100644 --- a/cmd/world/project/update.go +++ b/internal/app/world-cli/commands/project/update.go @@ -4,9 +4,9 @@ import ( "context" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func (h *Handler) Update( diff --git a/cmd/world/project/utils.go b/internal/app/world-cli/commands/project/utils.go similarity index 92% rename from cmd/world/project/utils.go rename to internal/app/world-cli/commands/project/utils.go index 3618e85e..4a70c0a6 100644 --- a/cmd/world/project/utils.go +++ b/internal/app/world-cli/commands/project/utils.go @@ -5,11 +5,11 @@ import ( "strings" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/utils/validate" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/repo" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/validate" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) // Show list of projects in selected organization. diff --git a/cmd/world/root/create.go b/internal/app/world-cli/commands/root/create.go similarity index 93% rename from cmd/world/root/create.go rename to internal/app/world-cli/commands/root/create.go index 1a2e028b..b5f1b432 100644 --- a/cmd/world/root/create.go +++ b/internal/app/world-cli/commands/root/create.go @@ -8,16 +8,16 @@ import ( "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" - "pkg.world.dev/world-cli/common/editor" - "pkg.world.dev/world-cli/common/teacmd" - "pkg.world.dev/world-cli/common/tomlutil" - "pkg.world.dev/world-cli/common/util" - "pkg.world.dev/world-cli/tea/component/steps" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common/editor" + "pkg.world.dev/world-cli/internal/app/world-cli/common/teacmd" + "pkg.world.dev/world-cli/internal/app/world-cli/common/tomlutil" + "pkg.world.dev/world-cli/internal/pkg/tea/component/program" + "pkg.world.dev/world-cli/internal/pkg/tea/component/steps" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) func (h *Handler) Create(directory string) error { - p := util.NewTeaProgram(NewWorldCreateModel(directory)) + p := program.NewTeaProgram(NewWorldCreateModel(directory)) if _, err := p.Run(); err != nil { return err } diff --git a/cmd/world/root/create_test.go b/internal/app/world-cli/commands/root/create_test.go similarity index 95% rename from cmd/world/root/create_test.go rename to internal/app/world-cli/commands/root/create_test.go index d064c3ec..4e28ebd0 100644 --- a/cmd/world/root/create_test.go +++ b/internal/app/world-cli/commands/root/create_test.go @@ -9,11 +9,11 @@ import ( "time" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/browser" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/root" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/browser" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/root" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" ) type CreateTestSuite struct { diff --git a/cmd/world/root/doctor.go b/internal/app/world-cli/commands/root/doctor.go similarity index 83% rename from cmd/world/root/doctor.go rename to internal/app/world-cli/commands/root/doctor.go index 2b5505ca..80258b73 100644 --- a/cmd/world/root/doctor.go +++ b/internal/app/world-cli/commands/root/doctor.go @@ -2,10 +2,10 @@ package root import ( tea "github.com/charmbracelet/bubbletea" - "pkg.world.dev/world-cli/common/dependency" - "pkg.world.dev/world-cli/common/teacmd" - "pkg.world.dev/world-cli/common/util" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common/dependency" + "pkg.world.dev/world-cli/internal/app/world-cli/common/teacmd" + "pkg.world.dev/world-cli/internal/pkg/tea/component/program" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) var DoctorDeps = []dependency.Dependency{ @@ -16,7 +16,7 @@ var DoctorDeps = []dependency.Dependency{ } func (h *Handler) Doctor() error { - p := util.NewTeaProgram(NewWorldDoctorModel()) + p := program.NewTeaProgram(NewWorldDoctorModel()) _, err := p.Run() if err != nil { return err diff --git a/cmd/world/root/login.go b/internal/app/world-cli/commands/root/login.go similarity index 95% rename from cmd/world/root/login.go rename to internal/app/world-cli/commands/root/login.go index 71b378cf..c3734fea 100644 --- a/cmd/world/root/login.go +++ b/internal/app/world-cli/commands/root/login.go @@ -15,11 +15,11 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/rotisserie/eris" "github.com/rs/zerolog/log" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/common/printer" - teaspinner "pkg.world.dev/world-cli/tea/component/spinner" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/pkg/printer" + teaspinner "pkg.world.dev/world-cli/internal/pkg/tea/component/spinner" ) var ( diff --git a/cmd/world/root/mock.go b/internal/app/world-cli/commands/root/mock.go similarity index 91% rename from cmd/world/root/mock.go rename to internal/app/world-cli/commands/root/mock.go index 4c782b54..687ba07c 100644 --- a/cmd/world/root/mock.go +++ b/internal/app/world-cli/commands/root/mock.go @@ -4,7 +4,7 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" ) // Interface guard. diff --git a/cmd/world/root/root_test.go b/internal/app/world-cli/commands/root/root_test.go similarity index 96% rename from cmd/world/root/root_test.go rename to internal/app/world-cli/commands/root/root_test.go index 11da9459..3c53898b 100644 --- a/cmd/world/root/root_test.go +++ b/internal/app/world-cli/commands/root/root_test.go @@ -8,12 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/browser" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/root" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/browser" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/root" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" ) type RootTestSuite struct { diff --git a/cmd/world/root/types.go b/internal/app/world-cli/commands/root/types.go similarity index 73% rename from cmd/world/root/types.go rename to internal/app/world-cli/commands/root/types.go index 2d74938a..057ece24 100644 --- a/cmd/world/root/types.go +++ b/internal/app/world-cli/commands/root/types.go @@ -1,10 +1,10 @@ package root import ( - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/browser" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/browser" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" ) // Interface guard. diff --git a/cmd/world/root/version.go b/internal/app/world-cli/commands/root/version.go similarity index 96% rename from cmd/world/root/version.go rename to internal/app/world-cli/commands/root/version.go index 2cf58a8d..1cad5603 100644 --- a/cmd/world/root/version.go +++ b/internal/app/world-cli/commands/root/version.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/go-version" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/logger" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/pkg/logger" + "pkg.world.dev/world-cli/internal/pkg/printer" ) const ( diff --git a/cmd/world/user/invite.go b/internal/app/world-cli/commands/user/invite.go similarity index 88% rename from cmd/world/user/invite.go rename to internal/app/world-cli/commands/user/invite.go index 3f6e54de..d5d370ef 100644 --- a/cmd/world/user/invite.go +++ b/internal/app/world-cli/commands/user/invite.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/utils/validate" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/validate" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) var ErrOrganizationInviteFailed = eris.New("Organization email invite failed, but invite is still created in CLI.") diff --git a/cmd/world/user/mock.go b/internal/app/world-cli/commands/user/mock.go similarity index 86% rename from cmd/world/user/mock.go rename to internal/app/world-cli/commands/user/mock.go index 804b7628..dda30372 100644 --- a/cmd/world/user/mock.go +++ b/internal/app/world-cli/commands/user/mock.go @@ -4,8 +4,8 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // Interface guard. diff --git a/cmd/world/user/role.go b/internal/app/world-cli/commands/user/role.go similarity index 91% rename from cmd/world/user/role.go rename to internal/app/world-cli/commands/user/role.go index c6f8d0a7..ba7a7d3b 100644 --- a/cmd/world/user/role.go +++ b/internal/app/world-cli/commands/user/role.go @@ -4,9 +4,9 @@ import ( "context" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/utils/validate" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/validate" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) var ( diff --git a/cmd/world/user/types.go b/internal/app/world-cli/commands/user/types.go similarity index 66% rename from cmd/world/user/types.go rename to internal/app/world-cli/commands/user/types.go index 5ada8103..a0fc53b1 100644 --- a/cmd/world/user/types.go +++ b/internal/app/world-cli/commands/user/types.go @@ -1,9 +1,9 @@ package user import ( - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) // Interface guard. diff --git a/cmd/world/user/update.go b/internal/app/world-cli/commands/user/update.go similarity index 86% rename from cmd/world/user/update.go rename to internal/app/world-cli/commands/user/update.go index 521e4cd2..09f5f2f8 100644 --- a/cmd/world/user/update.go +++ b/internal/app/world-cli/commands/user/update.go @@ -4,9 +4,9 @@ import ( "context" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/utils/validate" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/validate" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/pkg/printer" ) const ( diff --git a/cmd/world/user/user_test.go b/internal/app/world-cli/commands/user/user_test.go similarity index 98% rename from cmd/world/user/user_test.go rename to internal/app/world-cli/commands/user/user_test.go index 23801dc1..78d9c392 100644 --- a/cmd/world/user/user_test.go +++ b/internal/app/world-cli/commands/user/user_test.go @@ -6,10 +6,10 @@ import ( "testing" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/user" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/user" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) // UserTestSuite defines the test suite for user package. diff --git a/common/config/cli_config.go b/internal/app/world-cli/common/config/cli_config.go similarity index 100% rename from common/config/cli_config.go rename to internal/app/world-cli/common/config/cli_config.go diff --git a/common/config/config.go b/internal/app/world-cli/common/config/config.go similarity index 98% rename from common/config/config.go rename to internal/app/world-cli/common/config/config.go index 420795a5..67e8380d 100644 --- a/common/config/config.go +++ b/internal/app/world-cli/common/config/config.go @@ -8,7 +8,7 @@ import ( "github.com/pelletier/go-toml" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/logger" + "pkg.world.dev/world-cli/internal/pkg/logger" ) const ( diff --git a/common/config/config_internal_test.go b/internal/app/world-cli/common/config/config_internal_test.go similarity index 99% rename from common/config/config_internal_test.go rename to internal/app/world-cli/common/config/config_internal_test.go index 7a03f419..48be6789 100644 --- a/common/config/config_internal_test.go +++ b/internal/app/world-cli/common/config/config_internal_test.go @@ -256,7 +256,7 @@ DUPLICATE = 200 } func TestCanParseExampleConfig(t *testing.T) { - exampleConfig := "../../example-world.toml" + exampleConfig := "../testdata/toml/example-world.toml" cfg, err := GetConfig(&exampleConfig) assert.NilError(t, err) assert.Equal(t, "my-world-1", cfg.DockerEnv["CARDINAL_NAMESPACE"]) diff --git a/common/dependency/dependency.go b/internal/app/world-cli/common/dependency/dependency.go similarity index 100% rename from common/dependency/dependency.go rename to internal/app/world-cli/common/dependency/dependency.go diff --git a/common/docker/client.go b/internal/app/world-cli/common/docker/client.go similarity index 97% rename from common/docker/client.go rename to internal/app/world-cli/common/docker/client.go index afebf4e1..61b71169 100644 --- a/common/docker/client.go +++ b/internal/app/world-cli/common/docker/client.go @@ -9,9 +9,9 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/logger" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/pkg/logger" ) const ( diff --git a/common/docker/client_container.go b/internal/app/world-cli/common/docker/client_container.go similarity index 95% rename from common/docker/client_container.go rename to internal/app/world-cli/common/docker/client_container.go index 609f438a..b6a22c98 100644 --- a/common/docker/client_container.go +++ b/internal/app/world-cli/common/docker/client_container.go @@ -14,11 +14,11 @@ import ( cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/container" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/common/util" - "pkg.world.dev/world-cli/tea/component/multispinner" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/pkg/printer" + "pkg.world.dev/world-cli/internal/pkg/tea/component/multispinner" + "pkg.world.dev/world-cli/internal/pkg/tea/component/program" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) type processType int @@ -38,7 +38,7 @@ func (c *Client) processMultipleContainers(ctx context.Context, processType proc errChan := make(chan error, len(dockerServicesNames)) // Create tea program for multispinner - p := util.NewTeaProgram(multispinner.CreateSpinner(dockerServicesNames, cancel)) + p := program.NewTeaProgram(multispinner.CreateSpinner(dockerServicesNames, cancel)) // Process all containers for _, ds := range services { diff --git a/common/docker/client_image.go b/internal/app/world-cli/common/docker/client_image.go similarity index 98% rename from common/docker/client_image.go rename to internal/app/world-cli/common/docker/client_image.go index a1c10803..b92b3d01 100644 --- a/common/docker/client_image.go +++ b/internal/app/world-cli/common/docker/client_image.go @@ -21,11 +21,11 @@ import ( "github.com/rotisserie/eris" "github.com/vbauerster/mpb/v8" "github.com/vbauerster/mpb/v8/decor" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/printer" - "pkg.world.dev/world-cli/common/util" - "pkg.world.dev/world-cli/tea/component/multispinner" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/pkg/printer" + "pkg.world.dev/world-cli/internal/pkg/tea/component/multispinner" + "pkg.world.dev/world-cli/internal/pkg/tea/component/program" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) func (c *Client) buildImages(ctx context.Context, dockerServices ...service.Service) error { @@ -50,7 +50,7 @@ func (c *Client) buildImages(ctx context.Context, dockerServices ...service.Serv // Channel to collect errors from the goroutines errChan := make(chan error, len(imagesName)) - p := util.NewTeaProgram(multispinner.CreateSpinner(imagesName, cancel)) + p := program.NewTeaProgram(multispinner.CreateSpinner(imagesName, cancel)) for _, ds := range serviceToBuild { // Capture dockerService in the loop diff --git a/common/docker/client_internal_test.go b/internal/app/world-cli/common/docker/client_internal_test.go similarity index 96% rename from common/docker/client_internal_test.go rename to internal/app/world-cli/common/docker/client_internal_test.go index 076d22c6..e2cbab7d 100644 --- a/common/docker/client_internal_test.go +++ b/internal/app/world-cli/common/docker/client_internal_test.go @@ -12,10 +12,10 @@ import ( "time" "gotest.tools/v3/assert" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/docker/service" - "pkg.world.dev/world-cli/common/logger" - "pkg.world.dev/world-cli/common/teacmd" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/docker/service" + "pkg.world.dev/world-cli/internal/app/world-cli/common/teacmd" + "pkg.world.dev/world-cli/internal/pkg/logger" ) var ( diff --git a/common/docker/client_network.go b/internal/app/world-cli/common/docker/client_network.go similarity index 86% rename from common/docker/client_network.go rename to internal/app/world-cli/common/docker/client_network.go index 4b16cbf6..884a1873 100644 --- a/common/docker/client_network.go +++ b/internal/app/world-cli/common/docker/client_network.go @@ -5,15 +5,15 @@ import ( "github.com/docker/docker/api/types/network" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/util" - "pkg.world.dev/world-cli/tea/component/multispinner" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/pkg/tea/component/multispinner" + "pkg.world.dev/world-cli/internal/pkg/tea/component/program" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) func (c *Client) createNetworkIfNotExists(ctx context.Context, networkName string) error { // Create context with cancel ctx, cancel := context.WithCancel(ctx) - p := util.NewTeaProgram(multispinner.CreateSpinner([]string{networkName}, cancel)) + p := program.NewTeaProgram(multispinner.CreateSpinner([]string{networkName}, cancel)) errChan := make(chan error, 1) diff --git a/common/docker/client_util.go b/internal/app/world-cli/common/docker/client_util.go similarity index 94% rename from common/docker/client_util.go rename to internal/app/world-cli/common/docker/client_util.go index 24d12dd3..07074c04 100644 --- a/common/docker/client_util.go +++ b/internal/app/world-cli/common/docker/client_util.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/docker/docker/client" - "pkg.world.dev/world-cli/common/logger" + "pkg.world.dev/world-cli/internal/pkg/logger" ) func checkBuildkitSupport(cli *client.Client) bool { diff --git a/common/docker/client_volume.go b/internal/app/world-cli/common/docker/client_volume.go similarity index 89% rename from common/docker/client_volume.go rename to internal/app/world-cli/common/docker/client_volume.go index c23d6474..69bdb4e4 100644 --- a/common/docker/client_volume.go +++ b/internal/app/world-cli/common/docker/client_volume.go @@ -6,15 +6,15 @@ import ( "github.com/docker/docker/api/types/volume" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/util" - "pkg.world.dev/world-cli/tea/component/multispinner" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/pkg/tea/component/multispinner" + "pkg.world.dev/world-cli/internal/pkg/tea/component/program" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) func (c *Client) processVolume(ctx context.Context, processType processType, volumeName string) error { // Create context with cancel ctx, cancel := context.WithCancel(ctx) - p := util.NewTeaProgram(multispinner.CreateSpinner([]string{volumeName}, cancel)) + p := program.NewTeaProgram(multispinner.CreateSpinner([]string{volumeName}, cancel)) errChan := make(chan error, 1) diff --git a/common/docker/service/cardinal.Dockerfile b/internal/app/world-cli/common/docker/service/cardinal.Dockerfile similarity index 100% rename from common/docker/service/cardinal.Dockerfile rename to internal/app/world-cli/common/docker/service/cardinal.Dockerfile diff --git a/common/docker/service/cardinal.go b/internal/app/world-cli/common/docker/service/cardinal.go similarity index 98% rename from common/docker/service/cardinal.go rename to internal/app/world-cli/common/docker/service/cardinal.go index db4c84bc..772f4a8d 100644 --- a/common/docker/service/cardinal.go +++ b/internal/app/world-cli/common/docker/service/cardinal.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/go-connections/nat" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) const ( diff --git a/common/docker/service/celestia.go b/internal/app/world-cli/common/docker/service/celestia.go similarity index 95% rename from common/docker/service/celestia.go rename to internal/app/world-cli/common/docker/service/celestia.go index 4d3fc209..7dda978c 100644 --- a/common/docker/service/celestia.go +++ b/internal/app/world-cli/common/docker/service/celestia.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/go-connections/nat" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) func getCelestiaDevNetContainerName(cfg *config.Config) string { diff --git a/common/docker/service/evm.go b/internal/app/world-cli/common/docker/service/evm.go similarity index 98% rename from common/docker/service/evm.go rename to internal/app/world-cli/common/docker/service/evm.go index ec55612b..d3fda104 100644 --- a/common/docker/service/evm.go +++ b/internal/app/world-cli/common/docker/service/evm.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/api/types/container" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) func getEVMContainerName(cfg *config.Config) string { diff --git a/common/docker/service/jaeger.go b/internal/app/world-cli/common/docker/service/jaeger.go similarity index 96% rename from common/docker/service/jaeger.go rename to internal/app/world-cli/common/docker/service/jaeger.go index cb2d4bab..50cce634 100644 --- a/common/docker/service/jaeger.go +++ b/internal/app/world-cli/common/docker/service/jaeger.go @@ -5,7 +5,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) func getJaegerContainerName(cfg *config.Config) string { diff --git a/common/docker/service/nakama.go b/internal/app/world-cli/common/docker/service/nakama.go similarity index 98% rename from common/docker/service/nakama.go rename to internal/app/world-cli/common/docker/service/nakama.go index 8c24d977..00dbe928 100644 --- a/common/docker/service/nakama.go +++ b/internal/app/world-cli/common/docker/service/nakama.go @@ -8,7 +8,7 @@ import ( "github.com/docker/docker/api/types/container" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) func getNakamaContainerName(cfg *config.Config) string { diff --git a/common/docker/service/nakamadb.go b/internal/app/world-cli/common/docker/service/nakamadb.go similarity index 92% rename from common/docker/service/nakamadb.go rename to internal/app/world-cli/common/docker/service/nakamadb.go index 6a5cad7d..322a83d2 100644 --- a/common/docker/service/nakamadb.go +++ b/internal/app/world-cli/common/docker/service/nakamadb.go @@ -6,8 +6,8 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/logger" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/pkg/logger" ) func getNakamaDBContainerName(cfg *config.Config) string { diff --git a/common/docker/service/prometheus.go b/internal/app/world-cli/common/docker/service/prometheus.go similarity index 95% rename from common/docker/service/prometheus.go rename to internal/app/world-cli/common/docker/service/prometheus.go index d6d1ed67..a594352e 100644 --- a/common/docker/service/prometheus.go +++ b/internal/app/world-cli/common/docker/service/prometheus.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/docker/docker/api/types/container" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) // containerCmd is a static template used immutably within Prometheus(). diff --git a/common/docker/service/redis.go b/internal/app/world-cli/common/docker/service/redis.go similarity index 91% rename from common/docker/service/redis.go rename to internal/app/world-cli/common/docker/service/redis.go index 6ad42b06..26352439 100644 --- a/common/docker/service/redis.go +++ b/internal/app/world-cli/common/docker/service/redis.go @@ -6,8 +6,8 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/logger" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/pkg/logger" ) func getRedisContainerName(cfg *config.Config) string { diff --git a/common/docker/service/service.go b/internal/app/world-cli/common/docker/service/service.go similarity index 94% rename from common/docker/service/service.go rename to internal/app/world-cli/common/docker/service/service.go index 70543a15..8498d5cb 100644 --- a/common/docker/service/service.go +++ b/internal/app/world-cli/common/docker/service/service.go @@ -8,8 +8,8 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/go-connections/nat" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/logger" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/pkg/logger" ) var ( diff --git a/common/editor/editor.go b/internal/app/world-cli/common/editor/editor.go similarity index 98% rename from common/editor/editor.go rename to internal/app/world-cli/common/editor/editor.go index 8b9d3986..722318fa 100644 --- a/common/editor/editor.go +++ b/internal/app/world-cli/common/editor/editor.go @@ -15,8 +15,8 @@ import ( "github.com/google/uuid" "github.com/rotisserie/eris" "golang.org/x/mod/modfile" - "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/logger" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/pkg/logger" ) const ( diff --git a/common/editor/editor_internal_test.go b/internal/app/world-cli/common/editor/editor_internal_test.go similarity index 100% rename from common/editor/editor_internal_test.go rename to internal/app/world-cli/common/editor/editor_internal_test.go diff --git a/common/env.go b/internal/app/world-cli/common/env.go similarity index 100% rename from common/env.go rename to internal/app/world-cli/common/env.go diff --git a/common/login/login.go b/internal/app/world-cli/common/login/login.go similarity index 100% rename from common/login/login.go rename to internal/app/world-cli/common/login/login.go diff --git a/common/login/login_darwin.go b/internal/app/world-cli/common/login/login_darwin.go similarity index 100% rename from common/login/login_darwin.go rename to internal/app/world-cli/common/login/login_darwin.go diff --git a/common/login/login_internal_test.go b/internal/app/world-cli/common/login/login_internal_test.go similarity index 100% rename from common/login/login_internal_test.go rename to internal/app/world-cli/common/login/login_internal_test.go diff --git a/common/login/login_linux.go b/internal/app/world-cli/common/login/login_linux.go similarity index 100% rename from common/login/login_linux.go rename to internal/app/world-cli/common/login/login_linux.go diff --git a/common/login/login_windows.go b/internal/app/world-cli/common/login/login_windows.go similarity index 100% rename from common/login/login_windows.go rename to internal/app/world-cli/common/login/login_windows.go diff --git a/common/port.go b/internal/app/world-cli/common/port.go similarity index 100% rename from common/port.go rename to internal/app/world-cli/common/port.go diff --git a/common/teacmd/dependencies.go b/internal/app/world-cli/common/teacmd/dependencies.go similarity index 92% rename from common/teacmd/dependencies.go rename to internal/app/world-cli/common/teacmd/dependencies.go index eb50b5b0..1054f0f5 100644 --- a/common/teacmd/dependencies.go +++ b/internal/app/world-cli/common/teacmd/dependencies.go @@ -4,8 +4,8 @@ import ( "errors" tea "github.com/charmbracelet/bubbletea" - "pkg.world.dev/world-cli/common/dependency" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/app/world-cli/common/dependency" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) type DependencyStatus struct { diff --git a/common/teacmd/docker.go b/internal/app/world-cli/common/teacmd/docker.go similarity index 98% rename from common/teacmd/docker.go rename to internal/app/world-cli/common/teacmd/docker.go index c2d807fb..9a3b86a2 100644 --- a/common/teacmd/docker.go +++ b/internal/app/world-cli/common/teacmd/docker.go @@ -11,7 +11,7 @@ import ( "github.com/magefile/mage/sh" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) const ( diff --git a/common/teacmd/git.go b/internal/app/world-cli/common/teacmd/git.go similarity index 100% rename from common/teacmd/git.go rename to internal/app/world-cli/common/teacmd/git.go diff --git a/common/teacmd/git_internal_test.go b/internal/app/world-cli/common/teacmd/git_internal_test.go similarity index 100% rename from common/teacmd/git_internal_test.go rename to internal/app/world-cli/common/teacmd/git_internal_test.go diff --git a/telemetry/posthog.go b/internal/app/world-cli/common/telemetry/posthog.go similarity index 97% rename from telemetry/posthog.go rename to internal/app/world-cli/common/telemetry/posthog.go index 9c419275..3dc6251b 100644 --- a/telemetry/posthog.go +++ b/internal/app/world-cli/common/telemetry/posthog.go @@ -8,7 +8,7 @@ import ( "github.com/denisbrodbeck/machineid" "github.com/posthog/posthog-go" "github.com/rs/zerolog/log" - "pkg.world.dev/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/common/config" ) const ( diff --git a/telemetry/sentry.go b/internal/app/world-cli/common/telemetry/sentry.go similarity index 100% rename from telemetry/sentry.go rename to internal/app/world-cli/common/telemetry/sentry.go diff --git a/testdata/starter-game-template/README.md b/internal/app/world-cli/common/testdata/starter-game-template/README.md similarity index 100% rename from testdata/starter-game-template/README.md rename to internal/app/world-cli/common/testdata/starter-game-template/README.md diff --git a/testdata/starter-game-template/cardinal/.run/Cardinal - Debug.run.xml b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/.run/Cardinal - Debug.run.xml similarity index 100% rename from testdata/starter-game-template/cardinal/.run/Cardinal - Debug.run.xml rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/.run/Cardinal - Debug.run.xml diff --git a/testdata/starter-game-template/cardinal/Makefile b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/Makefile similarity index 100% rename from testdata/starter-game-template/cardinal/Makefile rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/Makefile diff --git a/testdata/starter-game-template/cardinal/component/health.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/component/health.go similarity index 100% rename from testdata/starter-game-template/cardinal/component/health.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/component/health.go diff --git a/testdata/starter-game-template/cardinal/component/player.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/component/player.go similarity index 100% rename from testdata/starter-game-template/cardinal/component/player.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/component/player.go diff --git a/testdata/starter-game-template/cardinal/go.mod b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/go.mod similarity index 100% rename from testdata/starter-game-template/cardinal/go.mod rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/go.mod diff --git a/testdata/starter-game-template/cardinal/go.sum b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/go.sum similarity index 100% rename from testdata/starter-game-template/cardinal/go.sum rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/go.sum diff --git a/testdata/starter-game-template/cardinal/init_test.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/init_test.go similarity index 100% rename from testdata/starter-game-template/cardinal/init_test.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/init_test.go diff --git a/testdata/starter-game-template/cardinal/main.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/main.go similarity index 100% rename from testdata/starter-game-template/cardinal/main.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/main.go diff --git a/testdata/starter-game-template/cardinal/msg/attack_player.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/msg/attack_player.go similarity index 100% rename from testdata/starter-game-template/cardinal/msg/attack_player.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/msg/attack_player.go diff --git a/testdata/starter-game-template/cardinal/msg/create_player.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/msg/create_player.go similarity index 100% rename from testdata/starter-game-template/cardinal/msg/create_player.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/msg/create_player.go diff --git a/testdata/starter-game-template/cardinal/query/player_health.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/query/player_health.go similarity index 100% rename from testdata/starter-game-template/cardinal/query/player_health.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/query/player_health.go diff --git a/testdata/starter-game-template/cardinal/system/attack.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/attack.go similarity index 100% rename from testdata/starter-game-template/cardinal/system/attack.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/attack.go diff --git a/testdata/starter-game-template/cardinal/system/default_spawner.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/default_spawner.go similarity index 100% rename from testdata/starter-game-template/cardinal/system/default_spawner.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/default_spawner.go diff --git a/testdata/starter-game-template/cardinal/system/player_spawner.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/player_spawner.go similarity index 100% rename from testdata/starter-game-template/cardinal/system/player_spawner.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/player_spawner.go diff --git a/testdata/starter-game-template/cardinal/system/regen.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/regen.go similarity index 100% rename from testdata/starter-game-template/cardinal/system/regen.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/regen.go diff --git a/testdata/starter-game-template/cardinal/system/utils.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/utils.go similarity index 100% rename from testdata/starter-game-template/cardinal/system/utils.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/system/utils.go diff --git a/testdata/starter-game-template/cardinal/system_test.go b/internal/app/world-cli/common/testdata/starter-game-template/cardinal/system_test.go similarity index 100% rename from testdata/starter-game-template/cardinal/system_test.go rename to internal/app/world-cli/common/testdata/starter-game-template/cardinal/system_test.go diff --git a/testdata/starter-game-template/world.toml b/internal/app/world-cli/common/testdata/starter-game-template/world.toml similarity index 100% rename from testdata/starter-game-template/world.toml rename to internal/app/world-cli/common/testdata/starter-game-template/world.toml diff --git a/example-world.toml b/internal/app/world-cli/common/testdata/toml/example-world.toml similarity index 100% rename from example-world.toml rename to internal/app/world-cli/common/testdata/toml/example-world.toml diff --git a/common/tomlutil/toml.go b/internal/app/world-cli/common/tomlutil/toml.go similarity index 100% rename from common/tomlutil/toml.go rename to internal/app/world-cli/common/tomlutil/toml.go diff --git a/common/tomlutil/toml_internal_test.go b/internal/app/world-cli/common/tomlutil/toml_internal_test.go similarity index 100% rename from common/tomlutil/toml_internal_test.go rename to internal/app/world-cli/common/tomlutil/toml_internal_test.go diff --git a/cmd/world/internal/utils/slug/slug.go b/internal/app/world-cli/common/utils/slug/slug.go similarity index 100% rename from cmd/world/internal/utils/slug/slug.go rename to internal/app/world-cli/common/utils/slug/slug.go diff --git a/cmd/world/internal/utils/slug/slug_test.go b/internal/app/world-cli/common/utils/slug/slug_test.go similarity index 99% rename from cmd/world/internal/utils/slug/slug_test.go rename to internal/app/world-cli/common/utils/slug/slug_test.go index fedc9b5b..c7f7f6d3 100644 --- a/cmd/world/internal/utils/slug/slug_test.go +++ b/internal/app/world-cli/common/utils/slug/slug_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/utils/slug" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/slug" ) type SlugTestSuite struct { diff --git a/cmd/world/internal/utils/validate/cardinal_root.go b/internal/app/world-cli/common/utils/validate/cardinal_root.go similarity index 100% rename from cmd/world/internal/utils/validate/cardinal_root.go rename to internal/app/world-cli/common/utils/validate/cardinal_root.go diff --git a/cmd/world/internal/utils/validate/email.go b/internal/app/world-cli/common/utils/validate/email.go similarity index 97% rename from cmd/world/internal/utils/validate/email.go rename to internal/app/world-cli/common/utils/validate/email.go index 07ae4bdf..c87ace9e 100644 --- a/cmd/world/internal/utils/validate/email.go +++ b/internal/app/world-cli/common/utils/validate/email.go @@ -6,7 +6,7 @@ import ( "github.com/rotisserie/eris" "golang.org/x/net/idna" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/pkg/printer" ) // Email checks if an email address is syntactically valid diff --git a/cmd/world/internal/utils/validate/name.go b/internal/app/world-cli/common/utils/validate/name.go similarity index 94% rename from cmd/world/internal/utils/validate/name.go rename to internal/app/world-cli/common/utils/validate/name.go index f59fedaf..dcb13491 100644 --- a/cmd/world/internal/utils/validate/name.go +++ b/internal/app/world-cli/common/utils/validate/name.go @@ -5,7 +5,7 @@ import ( "unicode" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/pkg/printer" ) func Name(name string, maxLength int) error { diff --git a/cmd/world/internal/utils/validate/url.go b/internal/app/world-cli/common/utils/validate/url.go similarity index 100% rename from cmd/world/internal/utils/validate/url.go rename to internal/app/world-cli/common/utils/validate/url.go diff --git a/cmd/world/internal/utils/validate/validate_test.go b/internal/app/world-cli/common/utils/validate/validate_test.go similarity index 99% rename from cmd/world/internal/utils/validate/validate_test.go rename to internal/app/world-cli/common/utils/validate/validate_test.go index bb96c2c9..014c7e90 100644 --- a/cmd/world/internal/utils/validate/validate_test.go +++ b/internal/app/world-cli/common/utils/validate/validate_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/utils/validate" + "pkg.world.dev/world-cli/internal/app/world-cli/common/utils/validate" ) type ValidationTestSuite struct { diff --git a/cmd/world/internal/controllers/cmd_setup/cmd_setup.go b/internal/app/world-cli/controllers/cmd_setup/cmd_setup.go similarity index 97% rename from cmd/world/internal/controllers/cmd_setup/cmd_setup.go rename to internal/app/world-cli/controllers/cmd_setup/cmd_setup.go index 4d4fe5d4..d90e8e77 100644 --- a/cmd/world/internal/controllers/cmd_setup/cmd_setup.go +++ b/internal/app/world-cli/controllers/cmd_setup/cmd_setup.go @@ -6,10 +6,10 @@ import ( "time" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/common/logger" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/pkg/logger" + "pkg.world.dev/world-cli/internal/pkg/printer" ) // WithSetup is a wrapper function that performs the setup flow and calls the handler with the established state. diff --git a/cmd/world/internal/controllers/cmd_setup/cmd_setup_test.go b/internal/app/world-cli/controllers/cmd_setup/cmd_setup_test.go similarity index 98% rename from cmd/world/internal/controllers/cmd_setup/cmd_setup_test.go rename to internal/app/world-cli/controllers/cmd_setup/cmd_setup_test.go index 32c61b40..e6d4a1e5 100644 --- a/cmd/world/internal/controllers/cmd_setup/cmd_setup_test.go +++ b/internal/app/world-cli/controllers/cmd_setup/cmd_setup_test.go @@ -7,15 +7,15 @@ import ( "github.com/rotisserie/eris" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - cmdsetup "pkg.world.dev/world-cli/cmd/world/internal/controllers/cmd_setup" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" - "pkg.world.dev/world-cli/cmd/world/organization" - "pkg.world.dev/world-cli/cmd/world/project" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/repo" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/organization" + "pkg.world.dev/world-cli/internal/app/world-cli/commands/project" + cmdsetup "pkg.world.dev/world-cli/internal/app/world-cli/controllers/cmd_setup" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) // SetupCommandSuite is a test suite for the SetupCommand controller. diff --git a/cmd/world/internal/controllers/cmd_setup/mock.go b/internal/app/world-cli/controllers/cmd_setup/mock.go similarity index 84% rename from cmd/world/internal/controllers/cmd_setup/mock.go rename to internal/app/world-cli/controllers/cmd_setup/mock.go index 7d173d8c..b690f44c 100644 --- a/cmd/world/internal/controllers/cmd_setup/mock.go +++ b/internal/app/world-cli/controllers/cmd_setup/mock.go @@ -4,8 +4,8 @@ import ( "context" "github.com/stretchr/testify/mock" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // Ensure MockController implements the interface. diff --git a/cmd/world/internal/controllers/cmd_setup/organization.go b/internal/app/world-cli/controllers/cmd_setup/organization.go similarity index 96% rename from cmd/world/internal/controllers/cmd_setup/organization.go rename to internal/app/world-cli/controllers/cmd_setup/organization.go index 032bf12c..8ca5c4ec 100644 --- a/cmd/world/internal/controllers/cmd_setup/organization.go +++ b/internal/app/world-cli/controllers/cmd_setup/organization.go @@ -4,9 +4,9 @@ import ( "context" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/pkg/printer" ) var ( diff --git a/cmd/world/internal/controllers/cmd_setup/project.go b/internal/app/world-cli/controllers/cmd_setup/project.go similarity index 97% rename from cmd/world/internal/controllers/cmd_setup/project.go rename to internal/app/world-cli/controllers/cmd_setup/project.go index d63372da..29f9b222 100644 --- a/cmd/world/internal/controllers/cmd_setup/project.go +++ b/internal/app/world-cli/controllers/cmd_setup/project.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/models" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/app/world-cli/models" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/pkg/printer" ) var ( diff --git a/cmd/world/internal/controllers/cmd_setup/types.go b/internal/app/world-cli/controllers/cmd_setup/types.go similarity index 83% rename from cmd/world/internal/controllers/cmd_setup/types.go rename to internal/app/world-cli/controllers/cmd_setup/types.go index d3b4b449..c9d8a7c3 100644 --- a/cmd/world/internal/controllers/cmd_setup/types.go +++ b/internal/app/world-cli/controllers/cmd_setup/types.go @@ -2,11 +2,11 @@ package cmdsetup import ( "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/cmd/world/internal/clients/api" - "pkg.world.dev/world-cli/cmd/world/internal/clients/repo" - "pkg.world.dev/world-cli/cmd/world/internal/interfaces" - "pkg.world.dev/world-cli/cmd/world/internal/services/config" - "pkg.world.dev/world-cli/cmd/world/internal/services/input" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/api" + "pkg.world.dev/world-cli/internal/app/world-cli/clients/repo" + "pkg.world.dev/world-cli/internal/app/world-cli/interfaces" + "pkg.world.dev/world-cli/internal/app/world-cli/services/config" + "pkg.world.dev/world-cli/internal/app/world-cli/services/input" ) var ( diff --git a/gen/logs/v1/logsv1connect/logs.connect.go b/internal/app/world-cli/gen/logs/v1/logsv1connect/logs.connect.go similarity index 98% rename from gen/logs/v1/logsv1connect/logs.connect.go rename to internal/app/world-cli/gen/logs/v1/logsv1connect/logs.connect.go index 0bd0485a..52238456 100644 --- a/gen/logs/v1/logsv1connect/logs.connect.go +++ b/internal/app/world-cli/gen/logs/v1/logsv1connect/logs.connect.go @@ -9,7 +9,7 @@ import ( context "context" errors "errors" http "net/http" - v1 "pkg.world.dev/world-cli/gen/logs/v1" + v1 "pkg.world.dev/world-cli/internal/app/world-cli/gen/logs/v1" strings "strings" ) diff --git a/cmd/world/internal/interfaces/cardinal.go b/internal/app/world-cli/interfaces/cardinal.go similarity index 88% rename from cmd/world/internal/interfaces/cardinal.go rename to internal/app/world-cli/interfaces/cardinal.go index ac636422..63f51562 100644 --- a/cmd/world/internal/interfaces/cardinal.go +++ b/internal/app/world-cli/interfaces/cardinal.go @@ -3,7 +3,7 @@ package interfaces import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) type CardinalHandler interface { diff --git a/cmd/world/internal/interfaces/cloud.go b/internal/app/world-cli/interfaces/cloud.go similarity index 91% rename from cmd/world/internal/interfaces/cloud.go rename to internal/app/world-cli/interfaces/cloud.go index eb9f7c12..8433b39c 100644 --- a/cmd/world/internal/interfaces/cloud.go +++ b/internal/app/world-cli/interfaces/cloud.go @@ -3,7 +3,7 @@ package interfaces import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // CloudHandler defines the interface for cloud deployment and management operations. diff --git a/cmd/world/internal/interfaces/cmd_setup.go b/internal/app/world-cli/interfaces/cmd_setup.go similarity index 88% rename from cmd/world/internal/interfaces/cmd_setup.go rename to internal/app/world-cli/interfaces/cmd_setup.go index 3a7ff577..07265611 100644 --- a/cmd/world/internal/interfaces/cmd_setup.go +++ b/internal/app/world-cli/interfaces/cmd_setup.go @@ -3,7 +3,7 @@ package interfaces import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // CommandSetupController defines the interface for command setup operations. diff --git a/cmd/world/internal/interfaces/evm.go b/internal/app/world-cli/interfaces/evm.go similarity index 77% rename from cmd/world/internal/interfaces/evm.go rename to internal/app/world-cli/interfaces/evm.go index ee036823..85a838df 100644 --- a/cmd/world/internal/interfaces/evm.go +++ b/internal/app/world-cli/interfaces/evm.go @@ -3,7 +3,7 @@ package interfaces import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) type EVMHandler interface { diff --git a/cmd/world/internal/interfaces/organization.go b/internal/app/world-cli/interfaces/organization.go similarity index 94% rename from cmd/world/internal/interfaces/organization.go rename to internal/app/world-cli/interfaces/organization.go index 04118dfe..638df70e 100644 --- a/cmd/world/internal/interfaces/organization.go +++ b/internal/app/world-cli/interfaces/organization.go @@ -3,7 +3,7 @@ package interfaces import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // OrganizationHandler defines the interface for organization-related operations. diff --git a/cmd/world/internal/interfaces/project.go b/internal/app/world-cli/interfaces/project.go similarity index 95% rename from cmd/world/internal/interfaces/project.go rename to internal/app/world-cli/interfaces/project.go index da516e16..171ebd04 100644 --- a/cmd/world/internal/interfaces/project.go +++ b/internal/app/world-cli/interfaces/project.go @@ -3,7 +3,7 @@ package interfaces import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // ProjectHandler defines the interface for project-related operations. diff --git a/cmd/world/internal/interfaces/root.go b/internal/app/world-cli/interfaces/root.go similarity index 100% rename from cmd/world/internal/interfaces/root.go rename to internal/app/world-cli/interfaces/root.go diff --git a/cmd/world/internal/interfaces/user.go b/internal/app/world-cli/interfaces/user.go similarity index 92% rename from cmd/world/internal/interfaces/user.go rename to internal/app/world-cli/interfaces/user.go index 94d34c94..d28feaac 100644 --- a/cmd/world/internal/interfaces/user.go +++ b/internal/app/world-cli/interfaces/user.go @@ -3,7 +3,7 @@ package interfaces import ( "context" - "pkg.world.dev/world-cli/cmd/world/internal/models" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) // UserHandler defines the interface for user-related operations. diff --git a/cmd/world/internal/models/cardinal.go b/internal/app/world-cli/models/cardinal.go similarity index 100% rename from cmd/world/internal/models/cardinal.go rename to internal/app/world-cli/models/cardinal.go diff --git a/cmd/world/internal/models/cloud.go b/internal/app/world-cli/models/cloud.go similarity index 80% rename from cmd/world/internal/models/cloud.go rename to internal/app/world-cli/models/cloud.go index b4082fee..f936b982 100644 --- a/cmd/world/internal/models/cloud.go +++ b/internal/app/world-cli/models/cloud.go @@ -24,3 +24,11 @@ type TemporaryCredential struct { Region string `json:"region"` RepoURI string `json:"repo_uri"` } + +const ( + DeploymentTypeDeploy = "deploy" + DeploymentTypeForceDeploy = "forceDeploy" + DeploymentTypeDestroy = "destroy" + DeploymentTypeReset = "reset" + DeploymentTypePromote = "promote" +) diff --git a/cmd/world/internal/models/cmd_setup.go b/internal/app/world-cli/models/cmd_setup.go similarity index 100% rename from cmd/world/internal/models/cmd_setup.go rename to internal/app/world-cli/models/cmd_setup.go diff --git a/cmd/world/internal/models/evm.go b/internal/app/world-cli/models/evm.go similarity index 100% rename from cmd/world/internal/models/evm.go rename to internal/app/world-cli/models/evm.go diff --git a/cmd/world/internal/models/organization.go b/internal/app/world-cli/models/organization.go similarity index 100% rename from cmd/world/internal/models/organization.go rename to internal/app/world-cli/models/organization.go diff --git a/cmd/world/internal/models/project.go b/internal/app/world-cli/models/project.go similarity index 100% rename from cmd/world/internal/models/project.go rename to internal/app/world-cli/models/project.go diff --git a/cmd/world/internal/models/root.go b/internal/app/world-cli/models/root.go similarity index 100% rename from cmd/world/internal/models/root.go rename to internal/app/world-cli/models/root.go diff --git a/cmd/world/internal/models/user.go b/internal/app/world-cli/models/user.go similarity index 100% rename from cmd/world/internal/models/user.go rename to internal/app/world-cli/models/user.go diff --git a/proto/logs/v1/logs.proto b/internal/app/world-cli/proto/logs/v1/logs.proto similarity index 100% rename from proto/logs/v1/logs.proto rename to internal/app/world-cli/proto/logs/v1/logs.proto diff --git a/internal/app/world-cli/proto/logs/v1/world-cli.code-workspace b/internal/app/world-cli/proto/logs/v1/world-cli.code-workspace new file mode 100644 index 00000000..d1158aa8 --- /dev/null +++ b/internal/app/world-cli/proto/logs/v1/world-cli.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "../../../../../.." + }, + { + "path": "../../../../../../../go-ecs" + } + ], + "settings": {} +} \ No newline at end of file diff --git a/cmd/world/internal/services/config/config.go b/internal/app/world-cli/services/config/config.go similarity index 95% rename from cmd/world/internal/services/config/config.go rename to internal/app/world-cli/services/config/config.go index 5d4851e8..5f3390bb 100644 --- a/cmd/world/internal/services/config/config.go +++ b/internal/app/world-cli/services/config/config.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/rotisserie/eris" - commonConfig "pkg.world.dev/world-cli/common/config" - "pkg.world.dev/world-cli/common/logger" - "pkg.world.dev/world-cli/common/printer" + commonConfig "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/pkg/logger" + "pkg.world.dev/world-cli/internal/pkg/printer" ) // TODO: break this config into credentials and known projects. Don't save org/project id in the config. diff --git a/cmd/world/internal/services/config/config_internal_test.go b/internal/app/world-cli/services/config/config_internal_test.go similarity index 97% rename from cmd/world/internal/services/config/config_internal_test.go rename to internal/app/world-cli/services/config/config_internal_test.go index ee366c70..9fa6428f 100644 --- a/cmd/world/internal/services/config/config_internal_test.go +++ b/internal/app/world-cli/services/config/config_internal_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/stretchr/testify/suite" - "pkg.world.dev/world-cli/cmd/world/internal/models" - commonConfig "pkg.world.dev/world-cli/common/config" + commonConfig "pkg.world.dev/world-cli/internal/app/world-cli/common/config" + "pkg.world.dev/world-cli/internal/app/world-cli/models" ) type ConfigTestSuite struct { diff --git a/cmd/world/internal/services/config/mock.go b/internal/app/world-cli/services/config/mock.go similarity index 100% rename from cmd/world/internal/services/config/mock.go rename to internal/app/world-cli/services/config/mock.go diff --git a/cmd/world/internal/services/config/types.go b/internal/app/world-cli/services/config/types.go similarity index 95% rename from cmd/world/internal/services/config/types.go rename to internal/app/world-cli/services/config/types.go index f155349e..53f5c0c5 100644 --- a/cmd/world/internal/services/config/types.go +++ b/internal/app/world-cli/services/config/types.go @@ -1,6 +1,6 @@ package config -import "pkg.world.dev/world-cli/cmd/world/internal/models" +import "pkg.world.dev/world-cli/internal/app/world-cli/models" type Config struct { OrganizationID string `json:"organization_id"` diff --git a/cmd/world/internal/services/input/input.go b/internal/app/world-cli/services/input/input.go similarity index 99% rename from cmd/world/internal/services/input/input.go rename to internal/app/world-cli/services/input/input.go index 61aef208..e821bfe9 100644 --- a/cmd/world/internal/services/input/input.go +++ b/internal/app/world-cli/services/input/input.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/rotisserie/eris" - "pkg.world.dev/world-cli/common/printer" + "pkg.world.dev/world-cli/internal/pkg/printer" ) var ( diff --git a/cmd/world/internal/services/input/input_internal_test.go b/internal/app/world-cli/services/input/input_internal_test.go similarity index 100% rename from cmd/world/internal/services/input/input_internal_test.go rename to internal/app/world-cli/services/input/input_internal_test.go diff --git a/cmd/world/internal/services/input/mock.go b/internal/app/world-cli/services/input/mock.go similarity index 100% rename from cmd/world/internal/services/input/mock.go rename to internal/app/world-cli/services/input/mock.go diff --git a/cmd/world/internal/services/input/types.go b/internal/app/world-cli/services/input/types.go similarity index 100% rename from cmd/world/internal/services/input/types.go rename to internal/app/world-cli/services/input/types.go diff --git a/taskfiles/buf.yaml b/internal/app/world-cli/taskfiles/buf.yaml similarity index 100% rename from taskfiles/buf.yaml rename to internal/app/world-cli/taskfiles/buf.yaml diff --git a/taskfiles/build.yaml b/internal/app/world-cli/taskfiles/build.yaml similarity index 100% rename from taskfiles/build.yaml rename to internal/app/world-cli/taskfiles/build.yaml diff --git a/taskfiles/lint.yaml b/internal/app/world-cli/taskfiles/lint.yaml similarity index 100% rename from taskfiles/lint.yaml rename to internal/app/world-cli/taskfiles/lint.yaml diff --git a/taskfiles/test.yaml b/internal/app/world-cli/taskfiles/test.yaml similarity index 100% rename from taskfiles/test.yaml rename to internal/app/world-cli/taskfiles/test.yaml diff --git a/common/logger/init.go b/internal/pkg/logger/init.go similarity index 85% rename from common/logger/init.go rename to internal/pkg/logger/init.go index ecebd1d7..6e3b73bf 100644 --- a/common/logger/init.go +++ b/internal/pkg/logger/init.go @@ -1,12 +1,12 @@ -//nolint:reassign // customizing zerolog globals is safe and intentional for this CLI +//nolint:reassign,forbidigo // customizing zerolog globals is safe and intentional for this CLI package logger import ( "bytes" + "fmt" "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "pkg.world.dev/world-cli/common/printer" ) const ( @@ -56,9 +56,9 @@ func PrintLogs() { // Extract the logs from the buffer and print them logs := logBuffer.String() if len(logs) > 0 { - printer.NewLine(1) - printer.Infoln("----- Log -----") - printer.Infoln(logs) + fmt.Println() + fmt.Println("----- Log -----") + fmt.Println(logs) } } } diff --git a/common/logger/logger.go b/internal/pkg/logger/logger.go similarity index 100% rename from common/logger/logger.go rename to internal/pkg/logger/logger.go diff --git a/common/printer/printer.go b/internal/pkg/printer/printer.go similarity index 100% rename from common/printer/printer.go rename to internal/pkg/printer/printer.go diff --git a/tea/component/IBox.go b/internal/pkg/tea/component/IBox.go similarity index 100% rename from tea/component/IBox.go rename to internal/pkg/tea/component/IBox.go diff --git a/tea/component/multiselect/multiselect.go b/internal/pkg/tea/component/multiselect/multiselect.go similarity index 100% rename from tea/component/multiselect/multiselect.go rename to internal/pkg/tea/component/multiselect/multiselect.go diff --git a/tea/component/multispinner/multispinner.go b/internal/pkg/tea/component/multispinner/multispinner.go similarity index 98% rename from tea/component/multispinner/multispinner.go rename to internal/pkg/tea/component/multispinner/multispinner.go index d3b5ca4b..49f3ff5e 100644 --- a/tea/component/multispinner/multispinner.go +++ b/internal/pkg/tea/component/multispinner/multispinner.go @@ -7,7 +7,7 @@ import ( "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) // Spinner is a component that displays a spinner while updating the logs. diff --git a/tea/component/program/program.go b/internal/pkg/tea/component/program/program.go similarity index 82% rename from tea/component/program/program.go rename to internal/pkg/tea/component/program/program.go index 4c162d7e..1136dcb2 100644 --- a/tea/component/program/program.go +++ b/internal/pkg/tea/component/program/program.go @@ -3,6 +3,7 @@ package program import ( "bytes" "context" + "fmt" "os" "strings" @@ -12,7 +13,6 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/muesli/reflow/wrap" "golang.org/x/term" - "pkg.world.dev/world-cli/common/printer" ) // An interface describing the parts of BubbleTea's Program that we actually use. @@ -49,14 +49,14 @@ type logModel struct { width int } -func NewProgram(model tea.Model, opts ...tea.ProgramOption) Program { - var p Program - if term.IsTerminal(int(os.Stdin.Fd())) { - p = tea.NewProgram(model, opts...) - } else { - p = newFakeProgram(model) +// NewTeaProgram will create a BubbleTea program that automatically sets the no input option +// if you are not on a TTY, so you can run the debugger. Call it just as you would call tea.NewProgram(). +func NewTeaProgram(model tea.Model, opts ...tea.ProgramOption) *tea.Program { + if !term.IsTerminal(int(os.Stderr.Fd())) { + opts = append(opts, tea.WithInput(nil)) + // opts = append(opts, tea.WithoutRenderer()) } - return p + return tea.NewProgram(model, opts...) } func newFakeProgram(model tea.Model) *fakeProgram { @@ -78,10 +78,12 @@ func (p *fakeProgram) Start() error { func (p *fakeProgram) Send(msg tea.Msg) { switch msg := msg.(type) { case StatusMsg: - printer.Infoln(string(msg)) + //nolint:forbidigo // This is a CLI utility function, cannot use printer as it's a reusable pkg + fmt.Println(string(msg)) case PsqlMsg: if msg != nil { - printer.Infoln(*msg) + //nolint:forbidigo // This is a CLI utility function, cannot use printer as it's a reusable pkg + fmt.Println(*msg) } } @@ -103,7 +105,7 @@ func (t StatusWriter) Write(p []byte) (int, error) { func RunProgram(ctx context.Context, f func(p Program, ctx context.Context) error) error { ctx, cancel := context.WithCancel(ctx) - p := NewProgram(logModel{ + p := newProgram(logModel{ cancel: cancel, spinner: spinner.New( spinner.WithSpinner(spinner.Dot), @@ -202,3 +204,13 @@ func (m logModel) View() string { return wrap.String(m.spinner.View()+m.status+progress+psqlOutputs, m.width) } + +func newProgram(model tea.Model, opts ...tea.ProgramOption) Program { + var p Program + if term.IsTerminal(int(os.Stdin.Fd())) { + p = tea.NewProgram(model, opts...) + } else { + p = newFakeProgram(model) + } + return p +} diff --git a/tea/component/spinner/spinner.go b/internal/pkg/tea/component/spinner/spinner.go similarity index 100% rename from tea/component/spinner/spinner.go rename to internal/pkg/tea/component/spinner/spinner.go diff --git a/tea/component/status.go b/internal/pkg/tea/component/status.go similarity index 100% rename from tea/component/status.go rename to internal/pkg/tea/component/status.go diff --git a/tea/component/steps/cmd.go b/internal/pkg/tea/component/steps/cmd.go similarity index 100% rename from tea/component/steps/cmd.go rename to internal/pkg/tea/component/steps/cmd.go diff --git a/tea/component/steps/entry.go b/internal/pkg/tea/component/steps/entry.go similarity index 100% rename from tea/component/steps/entry.go rename to internal/pkg/tea/component/steps/entry.go diff --git a/tea/component/steps/steps.go b/internal/pkg/tea/component/steps/steps.go similarity index 97% rename from tea/component/steps/steps.go rename to internal/pkg/tea/component/steps/steps.go index 19774a8b..26ba8ddf 100644 --- a/tea/component/steps/steps.go +++ b/internal/pkg/tea/component/steps/steps.go @@ -6,7 +6,7 @@ import ( "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "pkg.world.dev/world-cli/tea/style" + "pkg.world.dev/world-cli/internal/pkg/tea/style" ) const ( diff --git a/tea/style/container.go b/internal/pkg/tea/style/container.go similarity index 100% rename from tea/style/container.go rename to internal/pkg/tea/style/container.go diff --git a/tea/style/icon.go b/internal/pkg/tea/style/icon.go similarity index 100% rename from tea/style/icon.go rename to internal/pkg/tea/style/icon.go diff --git a/tea/style/text.go b/internal/pkg/tea/style/text.go similarity index 100% rename from tea/style/text.go rename to internal/pkg/tea/style/text.go diff --git a/tea/style/util.go b/internal/pkg/tea/style/util.go similarity index 69% rename from tea/style/util.go rename to internal/pkg/tea/style/util.go index 00589312..26841076 100644 --- a/tea/style/util.go +++ b/internal/pkg/tea/style/util.go @@ -1,16 +1,17 @@ package style import ( + "fmt" + "github.com/charmbracelet/lipgloss" - "pkg.world.dev/world-cli/common/printer" ) func ContextPrint(title, titleColor, subject, object string) { titleStr := ForegroundPrint(title, titleColor) arrowStr := ForegroundPrint("→", "241") subjectStr := ForegroundPrint(subject, "4") - - printer.Infof("%s %s %s %s ", titleStr, arrowStr, subjectStr, object) + //nolint:forbidigo // This is a CLI utility function, cannot use printer as it's a reusable pkg + fmt.Printf("%s %s %s %s ", titleStr, arrowStr, subjectStr, object) } func ForegroundPrint(text string, color string) string { From 404c99f3906a2e2437078ecf2d44950f7bcf0f03 Mon Sep 17 00:00:00 2001 From: Ed Zavada Date: Thu, 10 Jul 2025 20:00:48 -0400 Subject: [PATCH 2/2] Ignore the /dist/ and .idea/ --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..fd72d2e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +.idea/ +/dist/