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

Commit

Permalink
components directory
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Nov 22, 2023
1 parent 6099b4a commit 102ea02
Show file tree
Hide file tree
Showing 15 changed files with 968 additions and 188 deletions.
4 changes: 0 additions & 4 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,6 @@ func initProject() (*project.Project, error) {
return nil, err
}

if err := p.GenerateTypes(); err != nil {
return nil, err
}

if !p.CheckDeps() {
err = p.InstallDeps()
if err != nil {
Expand Down
12 changes: 4 additions & 8 deletions examples/test/sst.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="./.sst/types/global.d.ts" />
/// <reference path="./.sst/src/global.d.ts" />

export default {
config() {
Expand All @@ -9,14 +9,10 @@ export default {
};
},
async run() {
const a = new aws.s3.Bucket("my-bucket", {
tags: {
foo: "1123",
},
});

const bucket = new aws.s3.Bucket("my-bucket");
new sst.FunctionCodeUpdater("updator");
return {
url: util.interpolate`https://${a.bucketDomainName}`,
url: util.interpolate`https://${bucket.bucketDomainName}`,
};
},
};
Empty file added examples/test/test.ts
Empty file.
56 changes: 56 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package components

import (
"embed"
"io"
"os"
"path/filepath"
)

//go:embed src/* package.json
var files embed.FS

func CopyTo(srcDir, destDir string) error {
// Create the destination directory if it doesn't exist
if err := os.MkdirAll(destDir, 0755); err != nil {
return err
}

// List all files and directories in the embedded FS
entries, err := files.ReadDir(srcDir)
if err != nil {
return err
}

// Loop through each entry (file or directory)
for _, entry := range entries {
srcPath := filepath.Join(srcDir, entry.Name())
destPath := filepath.Join(destDir, entry.Name())

if entry.IsDir() {
// If it's a directory, recursively copy its contents
if err := CopyTo(srcPath, destPath); err != nil {
return err
}
} else {
// If it's a file, copy it to the destination directory
srcFile, err := files.Open(srcPath)
if err != nil {
return err
}
defer srcFile.Close()

destFile, err := os.Create(destPath)
if err != nil {
return err
}
defer destFile.Close()

if _, err := io.Copy(destFile, srcFile); err != nil {
return err
}
}
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/package.json",
"name": "sst",
"dependencies": {
"@aws-sdk/client-sts": "^3.454.0",
"@pulumi/aws": "5.43.0",
"@pulumi/pulumi": "3.94.2"
}
Expand Down
Loading

0 comments on commit 102ea02

Please sign in to comment.