template adjusment

This commit is contained in:
luke-hagar-sp
2023-06-26 14:19:42 -05:00
parent ad8b3ba84f
commit c14762459a
6 changed files with 19 additions and 18 deletions

View File

@@ -3,7 +3,6 @@ package sdk
import ( import (
"embed" "embed"
"os"
"github.com/sailpoint-oss/sailpoint-cli/internal/initialize" "github.com/sailpoint-oss/sailpoint-cli/internal/initialize"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@@ -30,10 +29,7 @@ func newGolangCmd() *cobra.Command {
if len(args) > 0 { if len(args) > 0 {
projName = args[0] projName = args[0]
} else { } else {
projName, err = os.Getwd() projName = "go-template"
if err != nil {
return err
}
} }
err = initialize.InitializeProject(goTemplateContents, goTemplateDirName, projName) err = initialize.InitializeProject(goTemplateContents, goTemplateDirName, projName)

View File

@@ -3,7 +3,6 @@ package sdk
import ( import (
"embed" "embed"
"os"
"github.com/sailpoint-oss/sailpoint-cli/internal/initialize" "github.com/sailpoint-oss/sailpoint-cli/internal/initialize"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@@ -30,10 +29,7 @@ func newPowerShellCmd() *cobra.Command {
if len(args) > 0 { if len(args) > 0 {
projName = args[0] projName = args[0]
} else { } else {
projName, err = os.Getwd() projName = "powershell-template"
if err != nil {
return err
}
} }
err = initialize.InitializeProject(pwshTemplateContents, pwshTemplateDirName, projName) err = initialize.InitializeProject(pwshTemplateContents, pwshTemplateDirName, projName)

View File

@@ -3,7 +3,6 @@ package sdk
import ( import (
"embed" "embed"
"os"
"github.com/sailpoint-oss/sailpoint-cli/internal/initialize" "github.com/sailpoint-oss/sailpoint-cli/internal/initialize"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@@ -30,10 +29,7 @@ func newTypescriptCmd() *cobra.Command {
if len(args) > 0 { if len(args) > 0 {
projName = args[0] projName = args[0]
} else { } else {
projName, err = os.Getwd() projName = "typescript-template"
if err != nil {
return err
}
} }
err = initialize.InitializeProject(tsTemplateContents, tsTemplateDirName, projName) err = initialize.InitializeProject(tsTemplateContents, tsTemplateDirName, projName)

View File

@@ -45,7 +45,12 @@ func newCollectCmd(term terminal.Terminal) *cobra.Command {
mpb.WithWaitGroup(&wg)) mpb.WithWaitGroup(&wg))
for i, endpoint := range args { for i, endpoint := range args {
password := credentials[i] var password string
if len(credentials) >= i-1 {
password = credentials[i]
}
if password == "" { if password == "" {
password, err = term.PromptPassword("Please enter the password for " + endpoint) password, err = term.PromptPassword("Please enter the password for " + endpoint)
if err != nil { if err != nil {

View File

@@ -11,14 +11,18 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"text/template" "text/template"
"github.com/charmbracelet/log"
) )
const packageJsonName = "package.json" const (
packageJsonName = "package.json"
)
func InitializeProject(templateContents embed.FS, templateDirName string, projName string) error { func InitializeProject(templateContents embed.FS, templateDirName string, projName string) error {
if projName == "" { if projName == "" {
return errors.New("connector name cannot be empty") return errors.New("project name cannot be empty")
} }
@@ -53,6 +57,10 @@ func InitializeProject(templateContents embed.FS, templateDirName string, projNa
return err return err
} }
log.Debug("creating file", "fileName", fileName)
fileName = strings.TrimSuffix(fileName, ".file")
if err := createFile(fileName, data); err != nil { if err := createFile(fileName, data); err != nil {
return err return err
} }