cli/pkg/devops/serve.go

110 lines
2.7 KiB
Go
Raw Normal View History

package devops
import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
"github.com/host-uk/core/pkg/io"
)
// ServeOptions configures the dev server.
type ServeOptions struct {
Port int // Port to serve on (default 8000)
Path string // Subdirectory to serve (default: current dir)
}
// Serve mounts the project and starts a dev server.
func (d *DevOps) Serve(ctx context.Context, projectDir string, opts ServeOptions) error {
running, err := d.IsRunning(ctx)
if err != nil {
return err
}
if !running {
return fmt.Errorf("dev environment not running (run 'core dev boot' first)")
}
if opts.Port == 0 {
opts.Port = 8000
}
servePath := projectDir
if opts.Path != "" {
servePath = filepath.Join(projectDir, opts.Path)
}
// Mount project directory via SSHFS
if err := d.mountProject(ctx, servePath); err != nil {
return fmt.Errorf("failed to mount project: %w", err)
}
// Detect and run serve command
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
serveCmd := DetectServeCommand(d.medium, servePath)
fmt.Printf("Starting server: %s\n", serveCmd)
fmt.Printf("Listening on http://localhost:%d\n", opts.Port)
// Run serve command via SSH
return d.sshShell(ctx, []string{"cd", "/app", "&&", serveCmd})
}
// mountProject mounts a directory into the VM via SSHFS.
func (d *DevOps) mountProject(ctx context.Context, path string) error {
absPath, err := filepath.Abs(path)
if err != nil {
return err
}
// Use reverse SSHFS mount
// The VM connects back to host to mount the directory
cmd := exec.CommandContext(ctx, "ssh",
Remove StrictHostKeyChecking=no from SSH commands (#315) * Remove StrictHostKeyChecking=no and implement proper host key verification This commit addresses security concerns from the OWASP audit by enforcing strict host key verification for all SSH and SCP commands. Key changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and pkg/devops. - Removed insecure host key verification from pkg/ansible SSH client. - Implemented a synchronous host key discovery mechanism during VM boot using ssh-keyscan to populate ~/.core/known_hosts. - Updated the devops Boot lifecycle to wait until the host key is verified. - Ensured pkg/ansible correctly handles missing known_hosts files. - Refactored hardcoded SSH port 2222 to a package constant DefaultSSHPort. - Added CORE_SKIP_SSH_SCAN environment variable for test environments. * Remove StrictHostKeyChecking=no and implement proper host key verification Addresses security concerns from OWASP audit by enforcing strict host key verification. Changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and devops. - Removed insecure host key verification from pkg/ansible. - Added synchronous host key discovery using ssh-keyscan during VM boot. - Updated Boot lifecycle to wait for host key verification. - Handled missing known_hosts file in pkg/ansible. - Refactored hardcoded SSH port to DefaultSSHPort constant. - Fixed formatting issues identified by QA check. * Secure SSH commands and fix auto-merge CI failure Addresses OWASP security audit by enforcing strict host key verification and fixes a CI failure in the auto-merge workflow. Key changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and pkg/devops. - Removed insecure host key verification from pkg/ansible. - Implemented synchronous host key discovery using ssh-keyscan during VM boot. - Handled missing known_hosts file in pkg/ansible. - Refactored hardcoded SSH port to DefaultSSHPort constant. - Added pkg/ansible/ssh_test.go to verify SSH client initialization. - Fixed formatting in pkg/io/local/client.go. - Fixed auto-merge.yml by inlining the script and providing repository context to 'gh' command, resolving the "not a git repository" error in CI. * Secure SSH, fix CI auto-merge, and resolve merge conflicts This commit addresses the OWASP security audit by enforcing strict host key verification and resolves persistent CI issues. Security Changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and devops. - Removed insecure host key verification from pkg/ansible. - Implemented synchronous host key discovery using ssh-keyscan during VM boot. - Updated Boot lifecycle to wait for host key verification. - Handled missing known_hosts file in pkg/ansible. - Refactored hardcoded SSH port to DefaultSSHPort constant. CI and Maintenance: - Fixed auto-merge.yml by inlining the script and adding repository context to 'gh' command, resolving the "not a git repository" error in CI. - Resolved merge conflicts in .github/workflows/auto-merge.yml with dev branch. - Added pkg/ansible/ssh_test.go for SSH client verification. - Fixed formatting in pkg/io/local/client.go to pass QA checks. * Secure SSH and TLS connections, and fix CI issues Addresses security concerns from OWASP audit and CodeQL by enforcing strict host key verification and TLS certificate verification. Security Changes: - Enforced strict SSH host key checking in pkg/container and devops. - Removed insecure SSH host key verification from pkg/ansible. - Added synchronous host key discovery during VM boot using ssh-keyscan. - Updated UniFi client to enforce TLS certificate verification by default. - Added --insecure flag and config option for UniFi to allow opt-in to skipping TLS verification for self-signed certificates. CI and Maintenance: - Fixed auto-merge workflow by providing repository context to 'gh' command. - Resolved merge conflicts in .github/workflows/auto-merge.yml. - Added unit tests for secured Ansible SSH client. - Fixed formatting issues identified by QA checks. * fix: gofmt alignment in cmd_config.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Secure connections, fix CI auto-merge, and resolve formatting Addresses OWASP security audit and CodeQL security alerts by enforcing secure defaults for SSH and TLS connections. Key changes: - Enforced strict SSH host key checking (StrictHostKeyChecking=yes). - Implemented synchronous host key verification during VM boot using ssh-keyscan. - Updated UniFi client to enforce TLS certificate verification by default. - Added --insecure flag and config option for UniFi to allow opt-in to skipping TLS verification. - Fixed auto-merge workflow by providing repository context to 'gh' command. - Resolved merge conflicts in .github/workflows/auto-merge.yml. - Fixed formatting in internal/cmd/unifi/cmd_config.go and pkg/io/local/client.go. - Added unit tests for secured Ansible SSH client. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Claude <developers@lethean.io>
2026-02-05 07:09:34 +00:00
"-o", "StrictHostKeyChecking=yes",
feat: infrastructure packages and lint cleanup (#281) * ci: consolidate duplicate workflows and merge CodeQL configs Remove 17 duplicate workflow files that were split copies of the combined originals. Each family (CI, CodeQL, Coverage, PR Build, Alpha Release) had the same job duplicated across separate push/pull_request/schedule/manual trigger files. Merge codeql.yml and codescan.yml into a single codeql.yml with a language matrix covering go, javascript-typescript, python, and actions — matching the previous default setup coverage. Remaining workflows (one per family): - ci.yml (push + PR + manual) - codeql.yml (push + PR + schedule, all languages) - coverage.yml (push + PR + manual) - alpha-release.yml (push + manual) - pr-build.yml (PR + manual) - release.yml (tag push) - agent-verify.yml, auto-label.yml, auto-project.yml Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add collect, config, crypt, plugin packages and fix all lint issues Add four new infrastructure packages with CLI commands: - pkg/config: layered configuration (defaults → file → env → flags) - pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums) - pkg/plugin: plugin system with GitHub-based install/update/remove - pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate) Fix all golangci-lint issues across the entire codebase (~100 errcheck, staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that `core go qa` passes with 0 issues. Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
"-o", "UserKnownHostsFile=~/.core/known_hosts",
"-o", "LogLevel=ERROR",
"-R", "10000:localhost:22", // Reverse tunnel for SSHFS
Remove StrictHostKeyChecking=no from SSH commands (#315) * Remove StrictHostKeyChecking=no and implement proper host key verification This commit addresses security concerns from the OWASP audit by enforcing strict host key verification for all SSH and SCP commands. Key changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and pkg/devops. - Removed insecure host key verification from pkg/ansible SSH client. - Implemented a synchronous host key discovery mechanism during VM boot using ssh-keyscan to populate ~/.core/known_hosts. - Updated the devops Boot lifecycle to wait until the host key is verified. - Ensured pkg/ansible correctly handles missing known_hosts files. - Refactored hardcoded SSH port 2222 to a package constant DefaultSSHPort. - Added CORE_SKIP_SSH_SCAN environment variable for test environments. * Remove StrictHostKeyChecking=no and implement proper host key verification Addresses security concerns from OWASP audit by enforcing strict host key verification. Changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and devops. - Removed insecure host key verification from pkg/ansible. - Added synchronous host key discovery using ssh-keyscan during VM boot. - Updated Boot lifecycle to wait for host key verification. - Handled missing known_hosts file in pkg/ansible. - Refactored hardcoded SSH port to DefaultSSHPort constant. - Fixed formatting issues identified by QA check. * Secure SSH commands and fix auto-merge CI failure Addresses OWASP security audit by enforcing strict host key verification and fixes a CI failure in the auto-merge workflow. Key changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and pkg/devops. - Removed insecure host key verification from pkg/ansible. - Implemented synchronous host key discovery using ssh-keyscan during VM boot. - Handled missing known_hosts file in pkg/ansible. - Refactored hardcoded SSH port to DefaultSSHPort constant. - Added pkg/ansible/ssh_test.go to verify SSH client initialization. - Fixed formatting in pkg/io/local/client.go. - Fixed auto-merge.yml by inlining the script and providing repository context to 'gh' command, resolving the "not a git repository" error in CI. * Secure SSH, fix CI auto-merge, and resolve merge conflicts This commit addresses the OWASP security audit by enforcing strict host key verification and resolves persistent CI issues. Security Changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and devops. - Removed insecure host key verification from pkg/ansible. - Implemented synchronous host key discovery using ssh-keyscan during VM boot. - Updated Boot lifecycle to wait for host key verification. - Handled missing known_hosts file in pkg/ansible. - Refactored hardcoded SSH port to DefaultSSHPort constant. CI and Maintenance: - Fixed auto-merge.yml by inlining the script and adding repository context to 'gh' command, resolving the "not a git repository" error in CI. - Resolved merge conflicts in .github/workflows/auto-merge.yml with dev branch. - Added pkg/ansible/ssh_test.go for SSH client verification. - Fixed formatting in pkg/io/local/client.go to pass QA checks. * Secure SSH and TLS connections, and fix CI issues Addresses security concerns from OWASP audit and CodeQL by enforcing strict host key verification and TLS certificate verification. Security Changes: - Enforced strict SSH host key checking in pkg/container and devops. - Removed insecure SSH host key verification from pkg/ansible. - Added synchronous host key discovery during VM boot using ssh-keyscan. - Updated UniFi client to enforce TLS certificate verification by default. - Added --insecure flag and config option for UniFi to allow opt-in to skipping TLS verification for self-signed certificates. CI and Maintenance: - Fixed auto-merge workflow by providing repository context to 'gh' command. - Resolved merge conflicts in .github/workflows/auto-merge.yml. - Added unit tests for secured Ansible SSH client. - Fixed formatting issues identified by QA checks. * fix: gofmt alignment in cmd_config.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Secure connections, fix CI auto-merge, and resolve formatting Addresses OWASP security audit and CodeQL security alerts by enforcing secure defaults for SSH and TLS connections. Key changes: - Enforced strict SSH host key checking (StrictHostKeyChecking=yes). - Implemented synchronous host key verification during VM boot using ssh-keyscan. - Updated UniFi client to enforce TLS certificate verification by default. - Added --insecure flag and config option for UniFi to allow opt-in to skipping TLS verification. - Fixed auto-merge workflow by providing repository context to 'gh' command. - Resolved merge conflicts in .github/workflows/auto-merge.yml. - Fixed formatting in internal/cmd/unifi/cmd_config.go and pkg/io/local/client.go. - Added unit tests for secured Ansible SSH client. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Claude <developers@lethean.io>
2026-02-05 07:09:34 +00:00
"-p", fmt.Sprintf("%d", DefaultSSHPort),
"root@localhost",
fmt.Sprintf("mkdir -p /app && sshfs -p 10000 %s@localhost:%s /app -o allow_other", os.Getenv("USER"), absPath),
)
return cmd.Run()
}
// DetectServeCommand auto-detects the serve command for a project.
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
func DetectServeCommand(m io.Medium, projectDir string) string {
// Laravel/Octane
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
if hasFile(m, projectDir, "artisan") {
return "php artisan octane:start --host=0.0.0.0 --port=8000"
}
// Node.js with dev script
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
if hasFile(m, projectDir, "package.json") {
if hasPackageScript(m, projectDir, "dev") {
return "npm run dev -- --host 0.0.0.0"
}
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
if hasPackageScript(m, projectDir, "start") {
return "npm start"
}
}
// PHP with composer
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
if hasFile(m, projectDir, "composer.json") {
return "frankenphp php-server -l :8000"
}
// Go
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
if hasFile(m, projectDir, "go.mod") {
if hasFile(m, projectDir, "main.go") {
return "go run ."
}
}
// Python Django
Migrate pkg/devops to Medium abstraction (#293) * chore(io): migrate pkg/devops to Medium abstraction This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package. Changes: - Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. This migration improves the testability and flexibility of the devops package by allowing for different storage backends. * chore(io): migrate pkg/devops to Medium abstraction This commit completes the migration of the pkg/devops package to the io.Medium abstraction. Changes: - Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations. - Updated New, NewImageManager, and LoadConfig to accept an io.Medium. - Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method. - Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium. - Updated all unit tests and CLI entry points to pass the appropriate io.Medium. - Fixed formatting issues in test files. This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
if hasFile(m, projectDir, "manage.py") {
return "python manage.py runserver 0.0.0.0:8000"
}
// Fallback: simple HTTP server
return "python3 -m http.server 8000"
}