Skip to content

Commit 3950a91

Browse files
authored
Remove template stuff that is no longer relevant (#85)
1 parent 548f052 commit 3950a91

File tree

5 files changed

+1
-148
lines changed

5 files changed

+1
-148
lines changed

clients/api/client.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,6 @@ func (c *Client) GetVersionStatus(applicationID, organizationID, versionID strin
287287
return &resp, nil
288288
}
289289

290-
// --- Template endpoints ---
291-
292-
// GetTemplates retrieves all available templates
293-
func (c *Client) GetTemplates() (*GetTemplatesResponse, error) {
294-
var resp GetTemplatesResponse
295-
err := c.doRequest("GET", "/templates", nil, &resp)
296-
if err != nil {
297-
return nil, err
298-
}
299-
return &resp, nil
300-
}
301-
302290
// --- Resource endpoints ---
303291

304292
// GetResources retrieves all resources for an organization
@@ -331,20 +319,6 @@ func (c *Client) SaveApplicationResources(organizationID, applicationID string,
331319
return &resp, nil
332320
}
333321

334-
// SetApplicationTemplate associates a template with an application
335-
func (c *Client) SetApplicationTemplate(applicationID, templateID string) (*SetApplicationTemplateResponse, error) {
336-
req := SetApplicationTemplateRequest{
337-
ApplicationID: applicationID,
338-
TemplateID: templateID,
339-
}
340-
341-
var resp SetApplicationTemplateResponse
342-
err := c.doRequest("POST", "/applications/template", req, &resp)
343-
if err != nil {
344-
return nil, err
345-
}
346-
return &resp, nil
347-
}
348322

349323
// --- Version Check endpoints ---
350324

@@ -440,19 +414,3 @@ func (c *Client) GetApplicationForLink(applicationID string) (*GetApplicationFor
440414
return &resp, nil
441415
}
442416

443-
// PushTemplate pushes template files to the application repository using backend GitHub App credentials
444-
// This bypasses the need for user's SSH access, allowing template push even when
445-
// the user hasn't accepted the GitHub invitation yet.
446-
func (c *Client) PushTemplate(applicationID, templateID string) (*PushTemplateResponse, error) {
447-
req := PushTemplateRequest{
448-
ApplicationID: applicationID,
449-
TemplateID: templateID,
450-
}
451-
452-
var resp PushTemplateResponse
453-
err := c.doRequest("POST", "/applications/push-template", req, &resp)
454-
if err != nil {
455-
return nil, err
456-
}
457-
return &resp, nil
458-
}

clients/api/structs.go

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package api
22

3-
import "github.com/major-technology/cli/constants"
43

54
// LoginStartResponse represents the response from POST /login/start
65
type LoginStartResponse struct {
@@ -78,7 +77,7 @@ type GetApplicationByRepoResponse struct {
7877
ApplicationID string `json:"applicationId,omitempty"`
7978
OrganizationID string `json:"organizationId,omitempty"`
8079
TemplateID *string `json:"templateId,omitempty"`
81-
TemplateName *constants.TemplateName `json:"templateName,omitempty"`
80+
TemplateName *string `json:"templateName,omitempty"`
8281
URLSlug *string `json:"urlSlug,omitempty"`
8382
}
8483

@@ -168,21 +167,6 @@ type GetVersionStatusResponse struct {
168167
AppURL string `json:"app_url,omitempty"`
169168
}
170169

171-
// --- Template structs ---
172-
173-
// TemplateItem represents a single template
174-
type TemplateItem struct {
175-
ID string `json:"id"`
176-
Name constants.TemplateName `json:"name"`
177-
TemplateURL string `json:"templateUrl"`
178-
}
179-
180-
// GetTemplatesResponse represents the response from GET /templates
181-
type GetTemplatesResponse struct {
182-
Error *AppErrorDetail `json:"error,omitempty"`
183-
Templates []*TemplateItem `json:"templates,omitempty"`
184-
}
185-
186170
// --- Resource structs ---
187171

188172
// GetResourcesRequest represents the request body for POST /resources
@@ -209,19 +193,6 @@ type SaveApplicationResourcesResponse struct {
209193
Success bool `json:"success,omitempty"`
210194
}
211195

212-
// SetApplicationTemplateRequest represents the request body for POST /applications/template
213-
type SetApplicationTemplateRequest struct {
214-
ApplicationID string `json:"applicationId"`
215-
TemplateID string `json:"templateId"`
216-
}
217-
218-
// SetApplicationTemplateResponse represents the response from POST /applications/template
219-
type SetApplicationTemplateResponse struct {
220-
Error *AppErrorDetail `json:"error,omitempty"`
221-
Success bool `json:"success,omitempty"`
222-
Message string `json:"message,omitempty"`
223-
}
224-
225196
// --- Version Check structs ---
226197

227198
// CheckVersionResponse represents the response from GET /version/check
@@ -303,19 +274,3 @@ type GetApplicationForLinkResponse struct {
303274
CloneURLHTTPS string `json:"cloneUrlHttps,omitempty"`
304275
}
305276

306-
// --- Push Template structs ---
307-
308-
// PushTemplateRequest represents the request body for POST /applications/push-template
309-
type PushTemplateRequest struct {
310-
ApplicationID string `json:"applicationId"`
311-
TemplateID string `json:"templateId"`
312-
}
313-
314-
// PushTemplateResponse represents the response from POST /applications/push-template
315-
type PushTemplateResponse struct {
316-
Error *AppErrorDetail `json:"error,omitempty"`
317-
Success bool `json:"success"`
318-
CommitSha string `json:"commitSha,omitempty"`
319-
FilesCount int `json:"filesCount,omitempty"`
320-
ErrorMsg string `json:"errorMessage,omitempty"`
321-
}

cmd/app/create.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import (
66

77
"github.com/charmbracelet/huh"
88
"github.com/charmbracelet/lipgloss"
9-
"github.com/major-technology/cli/clients/api"
109
mjrToken "github.com/major-technology/cli/clients/token"
11-
"github.com/major-technology/cli/constants"
1210
"github.com/major-technology/cli/errors"
1311
"github.com/major-technology/cli/middleware"
1412
"github.com/major-technology/cli/singletons"
@@ -117,15 +115,8 @@ func runCreate(cobraCmd *cobra.Command) error {
117115
// Get the API client
118116
apiClient := singletons.GetAPIClient()
119117

120-
// Fetch and select template
121-
_, _, templateID, err := selectTemplate(cobraCmd, apiClient)
122-
if err != nil {
123-
return errors.WrapError("failed to select template", err)
124-
}
125-
126118
cobraCmd.Printf("\nCreating application '%s'...\n", appName)
127119

128-
// Call POST /applications (token will be fetched automatically)
129120
createResp, err := apiClient.CreateApplication(appName, appDescription, orgID)
130121
if err != nil {
131122
return err
@@ -134,25 +125,6 @@ func runCreate(cobraCmd *cobra.Command) error {
134125
cobraCmd.Printf("✓ Application created with ID: %s\n", createResp.ApplicationID)
135126
cobraCmd.Printf("✓ Repository: %s\n", createResp.RepositoryName)
136127

137-
_, err = apiClient.SetApplicationTemplate(createResp.ApplicationID, templateID)
138-
if err != nil {
139-
return err
140-
}
141-
142-
// Push template files to repository using backend (GitHub App credentials)
143-
// This bypasses user's SSH access, so template is pushed even if invitation is pending
144-
cobraCmd.Println("Pushing template to repository...")
145-
pushResp, err := apiClient.PushTemplate(createResp.ApplicationID, templateID)
146-
if err != nil {
147-
return errors.WrapError("failed to push template to repository", err)
148-
}
149-
150-
if !pushResp.Success {
151-
return errors.WrapError("failed to push template to repository", fmt.Errorf("%s", pushResp.ErrorMsg))
152-
}
153-
154-
cobraCmd.Printf("✓ Template pushed (%d files)\n", pushResp.FilesCount)
155-
156128
// Ensure repository access before cloning
157129
// Use non-interactive mode if all required flags were provided
158130
isNonInteractive := flagAppName != "" && flagAppDescription != ""
@@ -296,22 +268,3 @@ func printSuccessMessage(cobraCmd *cobra.Command, appName string) {
296268
cobraCmd.Println(box)
297269
}
298270

299-
// selectTemplate fetches the NextJS template from the API.
300-
// Returns the template URL, name, and ID.
301-
func selectTemplate(cobraCmd *cobra.Command, apiClient *api.Client) (string, constants.TemplateName, string, error) {
302-
// Fetch available templates
303-
templatesResp, err := apiClient.GetTemplates()
304-
if err != nil {
305-
return "", "", "", err
306-
}
307-
308-
// Find the NextJS template
309-
for _, template := range templatesResp.Templates {
310-
if template.Name == constants.NextJSTemplate {
311-
cobraCmd.Printf("Using template: %s\n", template.Name)
312-
return template.TemplateURL, template.Name, template.ID, nil
313-
}
314-
}
315-
316-
return "", "", "", errors.ErrorNoTemplatesAvailable
317-
}

constants/constants.go

Lines changed: 0 additions & 7 deletions
This file was deleted.

errors/errors.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,6 @@ var ErrorApplicationDescriptionRequired = &CLIError{
363363
Err: errors.New("application description required"),
364364
}
365365

366-
var ErrorNoTemplatesAvailable = &CLIError{
367-
Title: "No templates available",
368-
Suggestion: "No templates are available. Please contact support.",
369-
Err: errors.New("no templates available"),
370-
}
371-
372366
var ErrorNoValidCloneMethodAvailable = &CLIError{
373367
Title: "No valid clone method available",
374368
Suggestion: "Please check your SSH keys are configured correctly. Run 'ssh -T git@github.com' to test your GitHub SSH connection.",

0 commit comments

Comments
 (0)