Skip to content

Commit

Permalink
Merge pull request #935 from aziontech/dev
Browse files Browse the repository at this point in the history
Deploy to production - 2024/08/20
  • Loading branch information
PatrickMenoti authored Aug 21, 2024
2 parents cd203d2 + 77efbb9 commit 3a86f0b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
8 changes: 5 additions & 3 deletions pkg/cmd/build/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ func RunBuildCmdLine(cmd *BuildCmd, fields *contracts.BuildInfo, msgs *[]string)
return msg.ErrorBuilding
}

var vulcanParams string

if fields.Preset != "" {
vulcanParams = " --preset " + fields.Preset
conf.Preset = fields.Preset
}

if fields.Mode != "" {
vulcanParams += " --mode " + fields.Mode
conf.Mode = fields.Mode
}

var vulcanParams string

if fields.Entry != "" {
vulcanParams = " --entry " + fields.Entry
vulcanParams += " --entry " + fields.Entry
}

if fields.NodePolyfills != "" {
Expand Down
5 changes: 2 additions & 3 deletions pkg/cmd/build/vulcan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package build

import (
"fmt"
"strings"

msg "github.com/aziontech/azion-cli/messages/build"
"github.com/aziontech/azion-cli/pkg/contracts"
Expand All @@ -25,9 +24,9 @@ func vulcan(cmd *BuildCmd, conf *contracts.AzionApplicationOptions, vulcanParams
return err
}

command := vul.Command("", "build --preset %s --mode %s%s", cmd.f)
command := vul.Command("", "build%s", cmd.f)

err = runCommand(cmd, fmt.Sprintf(command, strings.ToLower(conf.Preset), strings.ToLower(conf.Mode), vulcanParams), msgs)
err = runCommand(cmd, fmt.Sprintf(command, vulcanParams), msgs)
if err != nil {
return fmt.Errorf(msg.ErrorVulcanExecute.Error(), err.Error())
}
Expand Down
16 changes: 13 additions & 3 deletions pkg/cmd/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/aziontech/azion-cli/pkg/cmd/deploy"
"github.com/aziontech/azion-cli/pkg/cmd/dev"
"github.com/aziontech/azion-cli/pkg/cmdutil"
"github.com/aziontech/azion-cli/pkg/config"
"github.com/aziontech/azion-cli/pkg/github"
"github.com/aziontech/azion-cli/pkg/iostreams"
"github.com/aziontech/azion-cli/pkg/logger"
Expand Down Expand Up @@ -202,8 +203,13 @@ func (cmd *initCmd) Run(c *cobra.Command, _ []string) error {
return err
}

// Create a temporary directory
tempDir, err := os.MkdirTemp("", "tempclonesamples")
dirPath, err := config.Dir()
if err != nil {
return err
}

// Create a temporary directory
tempDir, err := os.MkdirTemp(dirPath.Dir, "tempclonesamples")
if err != nil {
return err
}
Expand All @@ -223,9 +229,13 @@ func (cmd *initCmd) Run(c *cobra.Command, _ []string) error {
return err
}

oldPath := path.Join(tempDir, "templates", templateOptionsMap[answerTemplate].Path)
newPath := path.Join(pathWorkingDirHere, cmd.name)

//move contents from temporary directory into final destination
err = cmd.rename(path.Join(tempDir, "templates", templateOptionsMap[answerTemplate].Path), path.Join(pathWorkingDirHere, cmd.name))
err = cmd.rename(oldPath, newPath)
if err != nil {
logger.Debug("Error move contents directory", zap.Error(err))
return utils.ErrorMovingFiles
}

Expand Down
14 changes: 12 additions & 2 deletions pkg/cmd/link/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/aziontech/azion-cli/pkg/logger"
"github.com/aziontech/azion-cli/pkg/node"
"github.com/aziontech/azion-cli/pkg/output"
vulcanPkg "github.com/aziontech/azion-cli/pkg/vulcan"
"github.com/aziontech/azion-cli/utils"
thoth "github.com/aziontech/go-thoth"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -252,6 +253,17 @@ func (cmd *LinkCmd) run(c *cobra.Command, info *LinkInfo) error {

}

cmdVulcanInit := "init"
cmdVulcanInit = fmt.Sprintf("%s --preset '%s' --mode '%s' --scope '%s'", cmdVulcanInit, info.Preset, info.Mode, info.PathWorkingDir)

vul := vulcanPkg.NewVulcan()
command := vul.Command("", cmdVulcanInit, cmd.F)

_, err = cmd.CommandRunner(cmd.F, command, []string{})
if err != nil {
return err
}

initOut := output.SliceOutput{
GeneralOutput: output.GeneralOutput{
Out: cmd.F.IOStreams.Out,
Expand All @@ -269,7 +281,6 @@ func deps(c *cobra.Command, cmd *LinkCmd, info *LinkInfo, m string, msgs *[]stri
return nil
}


pathWorkDir, err := cmd.GetWorkDir()
if err != nil {
return err
Expand All @@ -281,7 +292,6 @@ func deps(c *cobra.Command, cmd *LinkCmd, info *LinkInfo, m string, msgs *[]stri
logger.FInfoFlags(cmd.Io.Out, msg.InstallDeps, cmd.F.Format, cmd.F.Out)
*msgs = append(*msgs, msg.InstallDeps)


if err := depsInstall(cmd, info.packageManager); err != nil {
logger.Debug("Error while installing project dependencies", zap.Error(err))
return msg.ErrorDeps
Expand Down
4 changes: 2 additions & 2 deletions pkg/vulcan/vulcan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
const (
currentMajor = 3
installEdgeFunctions = "npx --yes %s edge-functions%s %s"
firstTimeExecuting = "@v3.1.0"
firstTimeExecuting = "@v3.2.1"
)

var versionVulcan = "@3.1.0"
var versionVulcan = "@3.2.1"

type VulcanPkg struct {
Command func(flags, params string, f *cmdutil.Factory) string
Expand Down
10 changes: 5 additions & 5 deletions pkg/vulcan/vulcan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ func TestCheckVulcanMajor(t *testing.T) {
args: args{
currentVersion: "4.0.0",
},
lastVulcanVer: "3.1.0",
expectedVersion: "@v3.1.0",
lastVulcanVer: "3.2.1",
expectedVersion: "@v3.2.1",
wantErr: false,
},
{
name: "same major version",
args: args{
currentVersion: "3.1.0",
currentVersion: "3.2.1",
},
lastVulcanVer: "3.1.0",
expectedVersion: "@v3.1.0",
lastVulcanVer: "3.2.1",
expectedVersion: "@v3.2.1",
wantErr: false,
},
{
Expand Down

0 comments on commit 3a86f0b

Please sign in to comment.