utils

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResourcesToProject added in v0.2.19

func AddResourcesToProject(cmd *cobra.Command, projectDir string, resources []api.ResourceItem, applicationID string) error

AddResourcesToProject adds selected resources to a project using pnpm exec major-client. It handles differential updates: removes resources that are no longer selected and adds new ones.

func CanUseSSH added in v0.2.27

func CanUseSSH() bool

CanUseSSH checks if SSH is available and configured for git

func CheckRepositoryAccess added in v0.2.27

func CheckRepositoryAccess(sshURL, httpsURL string) bool

CheckRepositoryAccess attempts to check if a repository is accessible via git ls-remote Returns true if accessible, false otherwise

func DetectFramework added in v0.2.40

func DetectFramework(projectDir string) string

DetectFramework detects the framework used in the project by checking package.json dependencies

func EnsureRepositoryAccess added in v0.2.27

func EnsureRepositoryAccess(cmd *cobra.Command, appID string, sshURL string, httpsURL string) error

EnsureRepositoryAccess ensures the user has access to the repository by inviting them as a collaborator This function prompts for GitHub username, sends an invite, and waits for access to be granted For backwards compatibility, use EnsureRepositoryAccessWithOptions for non-interactive mode

func EnsureRepositoryAccessWithOptions added in v0.2.34

func EnsureRepositoryAccessWithOptions(cmd *cobra.Command, appID string, sshURL string, httpsURL string, opts EnsureRepositoryAccessOptions) error

EnsureRepositoryAccessWithOptions ensures the user has access to the repository by inviting them as a collaborator Options allow for non-interactive mode with a provided or stored GitHub username

func ExtractGitHubURL added in v0.2.27

func ExtractGitHubURL(cloneURL string) (string, error)

ExtractGitHubURL extracts the GitHub repository URL from SSH or HTTPS clone URL Returns format: https://github.com/<owner>/<repo>

func GenerateMcpConfig deprecated added in v0.2.35

func GenerateMcpConfig(targetDir string, envVars map[string]string) (string, error)

GenerateMcpConfig generates a .mcp.json file for Claude Code in the specified directory. If targetDir is empty, it uses the current git repository root. It uses the env vars from the application env endpoint to construct the MCP server config pointing to the Go API's resource MCP endpoint.

Deprecated: The "major" Claude Code plugin now provides org-level MCP servers via headersHelper, which doesn't require per-project setup. This function is kept for backward compatibility with users who haven't installed the plugin yet.

func GenerateResourcesFile added in v0.2.4

func GenerateResourcesFile(targetDir string) (string, int, error)

GenerateResourcesFile generates a RESOURCES.md file for the application in the specified directory. If targetDir is empty, it uses the current git repository root. Returns the path to the generated file and the number of resources written.

func GetApplicationID added in v0.2.4

func GetApplicationID() (string, error)

GetApplicationID retrieves the application ID for the current git repository

func GetApplicationIDFromDir added in v0.2.4

func GetApplicationIDFromDir(dir string) (string, string, error)

GetApplicationIDFromDir retrieves the application ID and organization ID for a git repository in the specified directory. If dir is empty, it uses the current directory. Deprecated: Use GetApplicationInfo instead

func GetApplicationInfo added in v0.2.4

func GetApplicationInfo(dir string) (*api.GetApplicationByRepoResponse, error)

GetApplicationInfo retrieves full application information for a git repository in the specified directory. If dir is empty, it uses the current directory.

func NoArgs added in v0.1.11

func NoArgs(cmd *cobra.Command, args []string) error

NoArgs returns an error with suggestions if any args are included. This is like cobra.NoArgs but includes command suggestions for typos.

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens the specified URL in the default browser

func ResolveResourceItems added in v0.2.40

func ResolveResourceItems(ids []string, orgResources []api.ResourceItem) []api.ResourceItem

ResolveResourceItems maps a list of resource IDs to their full ResourceItem details from the org resource list. IDs not found in orgResources are skipped.

func SelectApplicationResources added in v0.2.4

func SelectApplicationResources(cmd *cobra.Command, apiClient *api.Client, orgID, appID string) ([]api.ResourceItem, error)

SelectApplicationResources prompts the user to select resources for the application Returns the selected resources with their full details

Types

type EnsureRepositoryAccessOptions added in v0.2.34

type EnsureRepositoryAccessOptions struct {
	// NonInteractive disables interactive prompts (uses stored/provided username)
	NonInteractive bool
	// GithubUsername is the GitHub username to use (overrides stored username)
	GithubUsername string
}

EnsureRepositoryAccessOptions configures how repository access is ensured

type InvitationPendingError added in v0.2.34

type InvitationPendingError struct {
	URL string
}

InvitationPendingError indicates the user needs to accept a GitHub invitation

func (*InvitationPendingError) Error added in v0.2.34

func (e *InvitationPendingError) Error() string

type LocalResource added in v0.2.4

type LocalResource struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Type          string `json:"type"`
	Description   string `json:"description"`
	ApplicationID string `json:"applicationId"`
}

LocalResource represents a resource stored in resources.json

func ReadLocalResources added in v0.2.4

func ReadLocalResources(projectDir string) ([]LocalResource, error)

ReadLocalResources reads the resources.json file from the project directory

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL