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

Commit

Permalink
Merge branch 'dev' of github.com:sst/ion into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Mar 20, 2024
2 parents 4ddcd21 + 797be57 commit 0c08d8b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Ion is a new engine for deploying SST apps. It uses Pulumi and Terraform, as opp
- No CDK or npm package conflicts
- Native support for **non-AWS** providers

_Note: Ion is currently in alpha. We’ll be sharing more details on how to migrate your existing SST apps soon._
_Note: Ion is generally available and recommended for new SST users. We are working on a migration path for SST v2 users._

## Installation

Expand Down
43 changes: 32 additions & 11 deletions cmd/sst/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"log/slog"
"os"
"os/exec"
"time"
"path/filepath"
"strings"
"time"

"github.com/briandowns/spinner"
"github.com/fatih/color"
Expand Down Expand Up @@ -68,8 +68,8 @@ func CmdInit(cli *Cli) error {
color.New(color.FgBlue, color.Bold).Print(">")
fmt.Println(" Astro detected. This will...")
fmt.Println(" - create an sst.config.ts")
fmt.Println(" - set up the astro-sst adapter in astro.config.mjs")
fmt.Println(" - add the sst sdk and astro-sst adapter to package.json")
fmt.Println(" - modify the astro.config.mjs")
fmt.Println(" - add the sst sdk to package.json")
fmt.Println()
template = "astro"
} else if filepath.HasPrefix(filepath.Base(path), "remix.config") || (filepath.HasPrefix(filepath.Base(path), "vite.config") && fileContains(path, "@remix-run/dev")) {
Expand All @@ -85,7 +85,7 @@ func CmdInit(cli *Cli) error {
return fmt.Errorf("file found")
}

return nil;
return nil
})

if template == "" {
Expand Down Expand Up @@ -140,6 +140,33 @@ func CmdInit(cli *Cli) error {
}
var cmd *exec.Cmd

spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond)
spin.Suffix = " Installing providers..."
spin.Start()

cfgPath, err := project.Discover()
if err != nil {
return err
}
proj, err := project.New(&project.ProjectConfig{
Config: cfgPath,
Stage: "sst",
Version: version,
})
if err != nil {
return err
}
if err := proj.CopyPlatform(version); err != nil {
return err
}

if err := proj.Install(); err != nil {
return err
}

if _, err := os.Stat("package-lock.json"); err == nil {
cmd = exec.Command("npm", "install")
}
if _, err := os.Stat("yarn.lock"); err == nil {
cmd = exec.Command("yarn", "install")
}
Expand All @@ -150,19 +177,13 @@ func CmdInit(cli *Cli) error {
cmd = exec.Command("bun", "install")
}
if cmd != nil {
spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond)
spin.Suffix = " Installing dependencies..."
spin.Start()
slog.Info("installing deps", "args", cmd.Args)
cmd.Run()
spin.Stop()
}

slog.Info("initializing project", "template", template)
_, err = initProject(cli)
if err != nil {
return err
}
color.New(color.FgGreen, color.Bold).Print("✓ ")
color.New(color.FgWhite).Println(" Success 🎉")
fmt.Println()
Expand All @@ -188,4 +209,4 @@ func fileContains(filePath string, str string) bool {
}

return false
}
}
16 changes: 8 additions & 8 deletions cmd/sst/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,17 @@ func (u *UI) Trigger(evt *project.StackEvent) {
if len(evt.CompleteEvent.Errors) == 0 && evt.CompleteEvent.Finished {
color.New(color.FgGreen, color.Bold).Print(IconCheck)
if !u.hasProgress {
color.New(color.FgWhite, color.Bold).Println(" No changes")
if u.mode == ProgressModeRemove {
color.New(color.FgWhite, color.Bold).Println(" Stage already removed")
} else {
color.New(color.FgWhite, color.Bold).Println(" No changes")
}
}
if u.hasProgress {
if u.mode == ProgressModeRemove {
color.New(color.FgWhite, color.Bold).Println(" Removed")
}
if u.mode == ProgressModeDeploy {
color.New(color.FgWhite, color.Bold).Println(" Complete")
}
if u.mode == ProgressModeDev {
if u.mode == ProgressModeDeploy || u.mode == ProgressModeDev {
color.New(color.FgWhite, color.Bold).Println(" Complete")
}
if u.mode == ProgressModeRefresh {
Expand Down Expand Up @@ -512,12 +513,11 @@ func (u *UI) formatURN(urn string) string {
name := child.Name()
typeName := child.Type().DisplayName()
splits := strings.SplitN(child.Name(), ".", 2)
fmt.Println(splits)
if len(splits) > 1 {
name = splits[0]
typeName = strings.ReplaceAll(splits[1], ".", ":")
}
result := name + " [" + typeName + "]"
result := name + " " + typeName

for {
parent := resource.URN(u.parents[string(child)])
Expand All @@ -530,7 +530,7 @@ func (u *UI) formatURN(urn string) string {
child = parent
}
if string(child) != urn {
result = child.Name() + " [" + child.Type().DisplayName() + "]" + " → " + result
result = child.Name() + " " + child.Type().DisplayName() + " → " + result
}
return result
}
Expand Down
1 change: 1 addition & 0 deletions www/src/components/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const slug = Astro.props.entry.slug;
text-transform: uppercase;
font-family: var(--sl-font-mono);
font-weight: 500;
letter-spacing: 0.5px;
}
.actions a:hover {
text-decoration: underline;
Expand Down
2 changes: 1 addition & 1 deletion www/src/content/docs/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components';
Ion is a new engine for deploying [SST](https://sst.dev) apps. It uses [Pulumi](https://www.pulumi.com) and [Terraform](https://www.terraform.io), as opposed to CDK and CloudFormation.

:::tip
Ion is **currently in alpha**. We'll be sharing more details on how to migrate your existing SST apps soon.
Ion is **generally available** and recommended for new SST users. We are working on a migration path for SST v2 users.
:::

Once Ion is stable, it’ll be released as SST v3. [Read the full announcement](https://sst.dev/blog/moving-away-from-cdk.html).
Expand Down
2 changes: 1 addition & 1 deletion www/src/content/docs/docs/linking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Resource linking is a feature of SST that allows you to link resources together
```
</TabItem>
<TabItem label="Remix">
```js title="app/root.tsx"
```js title="app/routes/_index.tsx"
import { Resource } from "sst";
console.log(Resource.MyBucket.name);
Expand Down

0 comments on commit 0c08d8b

Please sign in to comment.