Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
fix package build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Jul 7, 2024
1 parent 578db61 commit 84023c4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
4 changes: 4 additions & 0 deletions cmd/sst/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import (
"sync"

"github.com/sst/ion/cmd/sst/cli"
"github.com/sst/ion/cmd/sst/mosaic"
"github.com/sst/ion/cmd/sst/ui"
"github.com/sst/ion/internal/util"
"github.com/sst/ion/pkg/project"
"github.com/sst/ion/pkg/server"
)

func CmdDev(cli *cli.Cli) error {
if _, ok := os.LookupEnv("SST_SERVER"); ok {
return mosaic.CmdMosaic(cli)
}
var args []string
for _, arg := range cli.Arguments() {
args = append(args, strings.Fields(arg)...)
Expand Down
8 changes: 7 additions & 1 deletion cmd/sst/mosaic/deploy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mosaic

import (
"os"

"github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
"github.com/sst/ion/cmd/sst/cli"
"github.com/sst/ion/cmd/sst/mosaic/aws"
Expand All @@ -10,7 +12,11 @@ import (
)

func CmdMosaicDeploy(c *cli.Cli) error {
evts, err := server.Stream(c.Context, "http://localhost:13557",
url := "http://localhost:13557"
if match, ok := os.LookupEnv("SST_SERVER"); ok {
url = match
}
evts, err := server.Stream(c.Context, url,
project.StackCommandEvent{},
project.ConcurrentUpdateEvent{},
project.StackCommandEvent{},
Expand Down
18 changes: 15 additions & 3 deletions cmd/sst/mosaic/mosaic.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func CmdMosaic(c *cli.Cli) error {
}
if len(args) > 0 {
url := "http://localhost:13557"
if match, ok := os.LookupEnv("SST_SERVER"); ok {
url = match
}
evts, err := server.Stream(c.Context, url, project.CompleteEvent{})
if err != nil {
return err
Expand Down Expand Up @@ -110,8 +113,9 @@ func CmdMosaic(c *cli.Cli) error {

currentExecutable, _ := os.Executable()
multi, err := multiplexer.New()
multi.AddPane("deploy", []string{currentExecutable, "mosaic-deploy"}, "Deploy", "", false)
multi.AddPane("shell", []string{currentExecutable, "shell"}, "Shell", "", true)
multiEnv := fmt.Sprintf("SST_SERVER=http://localhost:%v", server.Port)
multi.AddPane("deploy", []string{currentExecutable, "mosaic-deploy"}, "Deploy", "", false, multiEnv)
multi.AddPane("shell", []string{currentExecutable, "shell"}, "Shell", "", true, multiEnv)

wg.Go(func() error {
defer c.Cancel()
Expand All @@ -134,7 +138,15 @@ func CmdMosaic(c *cli.Cli) error {
}
dir := filepath.Join(cwd, d.Directory)
slog.Info("mosaic", "dev", d.Name, "directory", dir)
multi.AddPane(d.Name, append([]string{currentExecutable, "mosaic"}, strings.Split(d.Command, " ")...), d.Name, dir, true)
multi.AddPane(
d.Name,
append([]string{currentExecutable, "mosaic"},
strings.Split(d.Command, " ")...),
d.Name,
dir,
true,
multiEnv,
)
}
break
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/sst/mosaic/multiplexer/multiplexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package multiplexer

import (
"log/slog"
"os"
"os/exec"
"time"

Expand Down Expand Up @@ -40,6 +41,7 @@ type pane struct {
title string
cmd *exec.Cmd
killable bool
env []string
}

func (p *pane) start() error {
Expand All @@ -49,6 +51,7 @@ func (p *pane) start() error {
return nil
}
cmd := exec.Command(p.args[0], p.args[1:]...)
cmd.Env = append(p.env, os.Environ()...)
if p.cwd != "" {
cmd.Dir = p.cwd
}
Expand Down Expand Up @@ -250,7 +253,7 @@ func (m *Model) Start() error {
return nil
}

func (m *Model) AddPane(key string, args []string, title string, cwd string, killable bool) {
func (m *Model) AddPane(key string, args []string, title string, cwd string, killable bool, env ...string) {
term := tcellterm.New()
term.SetSurface(m.main)
term.Attach(m.handleEvent)
Expand All @@ -266,6 +269,7 @@ func (m *Model) AddPane(key string, args []string, title string, cwd string, kil
args: args,
title: title,
killable: killable,
env: env,
}
m.panes = append(m.panes, p)
p.start()
Expand Down
5 changes: 4 additions & 1 deletion pkg/js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ const __dirname = topLevelFileUrlToPath(new topLevelURL(".", import.meta.url))
Sourcefile: "eval.ts",
Loader: esbuild.LoaderTS,
},
Packages: esbuild.PackagesDefault,
NodePaths: []string{
filepath.Join(input.Dir, ".sst", ".platform", "node_modules"),
},
External: []string{
"@pulumi/*",
"@pulumiverse/*",
"@sst-provider/*",
"@aws-sdk/*",
"esbuild",
"archiver",
Expand Down

0 comments on commit 84023c4

Please sign in to comment.