From 2b5dc020d5f2b53b1d7e57937b56b5760038a67d Mon Sep 17 00:00:00 2001 From: Shivansh Vij Date: Mon, 9 Oct 2023 11:50:41 +0200 Subject: [PATCH 1/2] Fix: TypeScript Build Bugs (#115) * Fixing the last few typescript generator bugs Signed-off-by: Shivansh Vij * Fixing lint timeout issue Signed-off-by: Shivansh Vij --------- Signed-off-by: Shivansh Vij --- .github/workflows/lint.yml | 3 +- build/golang.go | 2 + build/rust.go | 20 +++--- build/typescript.go | 2 + compile/rust/templates/lib.rs.templ | 8 ++- compile/typescript/manifest.go | 2 +- go.mod | 12 ++-- go.sum | 25 +++---- signature/generator/generator.go | 102 +++++++++++++++++++++++++--- storage/signature.go | 34 ++++++++++ 10 files changed, 166 insertions(+), 44 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 95069ba6..6f84e1f6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -50,4 +50,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: latest \ No newline at end of file + version: latest + args: --timeout=5m \ No newline at end of file diff --git a/build/golang.go b/build/golang.go index 304fe499..82f421ed 100644 --- a/build/golang.go +++ b/build/golang.go @@ -187,6 +187,7 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) { cmd.Dir = compilePath cmd.Stdout = options.Output cmd.Stderr = options.Output + cmd.Env = os.Environ() err = cmd.Run() if err != nil { return nil, fmt.Errorf("unable to compile scale function: %w", err) @@ -212,6 +213,7 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) { cmd.Dir = compilePath cmd.Stdout = options.Output cmd.Stderr = options.Output + cmd.Env = os.Environ() err = cmd.Run() if err != nil { return nil, fmt.Errorf("unable to compile scale function: %w", err) diff --git a/build/rust.go b/build/rust.go index 7dafba91..d3779bf5 100644 --- a/build/rust.go +++ b/build/rust.go @@ -160,15 +160,6 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) { return nil, fmt.Errorf("unable to create lib.rs file: %w", err) } - cmd := exec.Command(options.CargoBin, "check") - cmd.Dir = compilePath - cmd.Stdout = options.Output - cmd.Stderr = options.Output - err = cmd.Run() - if err != nil { - return nil, fmt.Errorf("unable to compile scale function: %w", err) - } - var target string switch options.Target { case WASITarget: @@ -179,6 +170,16 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) { return nil, fmt.Errorf("unknown build target %d", options.Target) } + cmd := exec.Command(options.CargoBin, "check", "--target", target) + cmd.Dir = compilePath + cmd.Stdout = options.Output + cmd.Stderr = options.Output + cmd.Env = os.Environ() + err = cmd.Run() + if err != nil { + return nil, fmt.Errorf("unable to compile scale function: %w", err) + } + buildArgs := append([]string{"build"}, options.Args...) if options.Release { buildArgs = append(buildArgs, "--release") @@ -189,6 +190,7 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) { cmd.Dir = compilePath cmd.Stdout = options.Output cmd.Stderr = options.Output + cmd.Env = os.Environ() err = cmd.Run() if err != nil { return nil, fmt.Errorf("unable to compile scale function: %w", err) diff --git a/build/typescript.go b/build/typescript.go index 0fe1a37c..bb387777 100644 --- a/build/typescript.go +++ b/build/typescript.go @@ -233,6 +233,7 @@ func LocalTypescript(options *LocalTypescriptOptions) (*scalefunc.Schema, error) cmd.Dir = compilePath cmd.Stderr = options.Output cmd.Stdout = options.Output + cmd.Env = os.Environ() err = cmd.Run() if err != nil { return nil, fmt.Errorf("unable to compile scale function and update npm: %w", err) @@ -266,6 +267,7 @@ func LocalTypescript(options *LocalTypescriptOptions) (*scalefunc.Schema, error) cmd.Stdin = strings.NewReader(string(result.OutputFiles[0].Contents)) cmd.Stderr = options.Output cmd.Stdout = options.Output + cmd.Env = os.Environ() err = cmd.Run() if err != nil { return nil, fmt.Errorf("unable to compile scale function using js_builder: %w", err) diff --git a/compile/rust/templates/lib.rs.templ b/compile/rust/templates/lib.rs.templ index 9a7920ef..70c896ca 100644 --- a/compile/rust/templates/lib.rs.templ +++ b/compile/rust/templates/lib.rs.templ @@ -8,10 +8,14 @@ pub unsafe extern "C" fn initialize() -> u64 { {{ if .package_schema.Initialize }} return match {{ .package_schema.Name }}::{{ .package_schema.Initialize }}() { Ok(_) => { 0 }, - Err(err) => { packUint32(signature.Error(err)) } + Err(err) => { + let (ptr, len) = signature::error(err); + pack_uint32(ptr, len) + } }; - {{ end }} + {{ else }} 0 + {{ end }} } #[cfg_attr(target_arch = "wasm32", export_name = "run")] diff --git a/compile/typescript/manifest.go b/compile/typescript/manifest.go index 2a992678..973f8fda 100644 --- a/compile/typescript/manifest.go +++ b/compile/typescript/manifest.go @@ -162,5 +162,5 @@ func (m *Manifest) Write() ([]byte, error) { m.packageJSON.internal["devDependencies"] = m.packageJSON.DevDependencies } - return json.Marshal(m.packageJSON.internal) + return json.MarshalIndent(m.packageJSON.internal, "", "\t") } diff --git a/go.mod b/go.mod index 919c6588..6e5acfcb 100644 --- a/go.mod +++ b/go.mod @@ -4,29 +4,27 @@ go 1.20 require ( github.com/BurntSushi/toml v1.3.2 - github.com/evanw/esbuild v0.19.3 + github.com/evanw/esbuild v0.19.4 github.com/google/uuid v1.3.1 - github.com/hashicorp/hcl/v2 v2.18.0 + github.com/hashicorp/hcl/v2 v2.18.1 github.com/loopholelabs/polyglot v1.1.3 github.com/loopholelabs/scale-signature-interfaces v0.1.7 github.com/stretchr/testify v1.8.4 github.com/tetratelabs/wazero v1.5.0 - golang.org/x/mod v0.12.0 + golang.org/x/mod v0.13.0 golang.org/x/text v0.13.0 ) require ( github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 // indirect + github.com/zclconf/go-cty v1.14.1 // indirect + golang.org/x/sys v0.13.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 5924c588..f7fa8f82 100644 --- a/go.sum +++ b/go.sum @@ -2,15 +2,13 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8 github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/evanw/esbuild v0.19.3 h1:foPr0xwQM3lBWKBtscauTN9FrmJzRDVI2+EGOs82H/I= -github.com/evanw/esbuild v0.19.3/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk= +github.com/evanw/esbuild v0.19.4 h1:Etk+6ZCjtNxZZLEgMKSqpO0/oM0k1WYKJabaPMJ39iQ= +github.com/evanw/esbuild v0.19.4/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -18,8 +16,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= -github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo= +github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -44,17 +42,16 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tetratelabs/wazero v1.5.0 h1:Yz3fZHivfDiZFUXnWMPUoiW7s8tC1sjdBtlJn08qYa0= github.com/tetratelabs/wazero v1.5.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= -github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= -github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= +github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= +golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 h1:0wxTF6pSjIIhNt7mo9GvjDfzyCOiWhmICgtO/Ah948s= -golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= diff --git a/signature/generator/generator.go b/signature/generator/generator.go index 720b7e7d..052ed975 100644 --- a/signature/generator/generator.go +++ b/signature/generator/generator.go @@ -46,9 +46,10 @@ type GuestRegistryPackage struct { } type GuestLocalPackage struct { - GolangFiles []File - RustFiles []File - TypescriptFiles []File + GolangFiles []File + RustFiles []File + TypescriptFiles []File + TypescriptPackage *bytes.Buffer } type HostRegistryPackage struct { @@ -59,8 +60,9 @@ type HostRegistryPackage struct { } type HostLocalPackage struct { - GolangFiles []File - TypescriptFiles []File + GolangFiles []File + TypescriptFiles []File + TypescriptPackage *bytes.Buffer } type Options struct { @@ -324,10 +326,50 @@ func GenerateGuestLocal(options *Options) (*GuestLocalPackage, error) { NewFile("package.json", "package.json", packageJSON), } + typescriptBuffer := new(bytes.Buffer) + gzipTypescriptWriter := gzip.NewWriter(typescriptBuffer) + tarTypescriptWriter := tar.NewWriter(gzipTypescriptWriter) + + var header *tar.Header + for _, file := range typescriptFiles { + header, err = tar.FileInfoHeader(file, file.Name()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to create tar header for %s: %w", file.Name(), err) + } + + header.Name = path.Join("package", header.Name) + + err = tarTypescriptWriter.WriteHeader(header) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar header for %s: %w", file.Name(), err) + } + _, err = tarTypescriptWriter.Write(file.Data()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar data for %s: %w", file.Name(), err) + } + } + + err = tarTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close tar writer: %w", err) + } + + err = gzipTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close gzip writer: %w", err) + } + return &GuestLocalPackage{ - GolangFiles: golangFiles, - RustFiles: rustFiles, - TypescriptFiles: typescriptFiles, + GolangFiles: golangFiles, + RustFiles: rustFiles, + TypescriptFiles: typescriptFiles, + TypescriptPackage: typescriptBuffer, }, nil } @@ -508,8 +550,48 @@ func GenerateHostLocal(options *Options) (*HostLocalPackage, error) { NewFile("package.json", "package.json", packageJSON), } + typescriptBuffer := new(bytes.Buffer) + gzipTypescriptWriter := gzip.NewWriter(typescriptBuffer) + tarTypescriptWriter := tar.NewWriter(gzipTypescriptWriter) + + var header *tar.Header + for _, file := range typescriptFiles { + header, err = tar.FileInfoHeader(file, file.Name()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to create tar header for %s: %w", file.Name(), err) + } + + header.Name = path.Join("package", header.Name) + + err = tarTypescriptWriter.WriteHeader(header) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar header for %s: %w", file.Name(), err) + } + _, err = tarTypescriptWriter.Write(file.Data()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar data for %s: %w", file.Name(), err) + } + } + + err = tarTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close tar writer: %w", err) + } + + err = gzipTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close gzip writer: %w", err) + } + return &HostLocalPackage{ - GolangFiles: golangFiles, - TypescriptFiles: typescriptFiles, + GolangFiles: golangFiles, + TypescriptFiles: typescriptFiles, + TypescriptPackage: typescriptBuffer, }, nil } diff --git a/storage/signature.go b/storage/signature.go index 1e11023f..d9f20293 100644 --- a/storage/signature.go +++ b/storage/signature.go @@ -303,11 +303,21 @@ func GenerateSignature(sig *signature.Schema, name string, tag string, org strin return err } + err = os.MkdirAll(path.Join(directory, "typescript", "guest"), 0755) + if err != nil { + return err + } + err = os.MkdirAll(path.Join(directory, "golang", "host"), 0755) if err != nil { return err } + err = os.MkdirAll(path.Join(directory, "typescript", "host"), 0755) + if err != nil { + return err + } + guestPackage, err := generator.GenerateGuestLocal(&generator.Options{ Signature: sig, @@ -338,6 +348,18 @@ func GenerateSignature(sig *signature.Schema, name string, tag string, org strin } } + for _, file := range guestPackage.TypescriptFiles { + err = os.WriteFile(path.Join(directory, "typescript", "guest", file.Path()), file.Data(), 0644) + if err != nil { + return err + } + } + + err = os.WriteFile(path.Join(directory, "typescript", "guest.tar.gz"), guestPackage.TypescriptPackage.Bytes(), 0644) + if err != nil { + return err + } + hostPackage, err := generator.GenerateHostLocal(&generator.Options{ Signature: sig, @@ -358,5 +380,17 @@ func GenerateSignature(sig *signature.Schema, name string, tag string, org strin } } + for _, file := range hostPackage.TypescriptFiles { + err = os.WriteFile(path.Join(directory, "typescript", "host", file.Path()), file.Data(), 0644) + if err != nil { + return err + } + } + + err = os.WriteFile(path.Join(directory, "typescript", "host.tar.gz"), hostPackage.TypescriptPackage.Bytes(), 0644) + if err != nil { + return err + } + return nil } From 233e230b2f06df686dc90e815f002efaa1ab40e2 Mon Sep 17 00:00:00 2001 From: Shivansh Vij Date: Mon, 9 Oct 2023 11:54:54 +0200 Subject: [PATCH 2/2] Bumping versions, updating changelog Signed-off-by: Shivansh Vij --- CHANGELOG.md | 25 ++++++++++++++++--- Cargo.toml | 2 +- .../golang_tests/generated/generated.go | 2 +- .../golang_tests/host_signature/host.go | 2 +- .../golang_tests/host_signature/types.go | 2 +- integration/golang_tests/signature/guest.go | 2 +- integration/golang_tests/signature/types.go | 2 +- integration/rust_tests/generated/generated.rs | 2 +- integration/rust_tests/signature/guest.rs | 2 +- integration/rust_tests/signature/types.rs | 2 +- .../typescript_tests/generated/generated.d.ts | 2 +- .../typescript_tests/generated/generated.js | 2 +- .../generated/generated.js.map | 2 +- .../typescript_tests/host_signature/index.ts | 2 +- .../typescript_tests/host_signature/types.ts | 2 +- .../typescript_tests/signature/index.ts | 2 +- .../typescript_tests/signature/types.ts | 2 +- package.json | 2 +- .../converter/converter_tests/generated.go | 2 +- signature/generator/golang/generated.txt | 2 +- signature/generator/rust/generated.txt | 2 +- signature/generator/typescript/generated.txt | 2 +- version/current_version | 2 +- 23 files changed, 44 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c06f6e5e..37a6dd68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,25 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -## [v0.4.4] - 2023-08-05 +## [v0.4.5] - 2023-10-09 + +### Features + +- Environment Variables set during the scale function build command now get passed properly to the downstream commands +- The build system now allows for wasi and wasm targets depending on the user's choice + +### Fixes + +- Using init function for Rust plugins now properly builds and does not cause builds to break +- The Rust build step now properly verifies the build target with Cargo +- The storage manager now properly generates TypeScript signatures for both the guest and the host + +### Changes + +- The TypeScript manifest generator for builds and signatures now returns a pretty-printed package.json +- The signature builder now returns the tar.gz format for TypeScript signatures as well as the raw files + +## [v0.4.4] - 2023-10-05 ### Features @@ -17,7 +35,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Fixed a bug where the signature generation would not generate typescript signatures -## [v0.4.3] - 2023-08-04 +## [v0.4.3] - 2023-10-04 ### Changes @@ -281,7 +299,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Initial release of the Scale Runtime library. -[unreleased]: https://github.com/loopholelabs/scale/compare/v0.4.4...HEAD +[unreleased]: https://github.com/loopholelabs/scale/compare/v0.4.5...HEAD +[v0.4.5]: https://github.com/loopholelabs/scale/compare/v0.4.5 [v0.4.4]: https://github.com/loopholelabs/scale/compare/v0.4.4 [v0.4.3]: https://github.com/loopholelabs/scale/compare/v0.4.3 [v0.4.2]: https://github.com/loopholelabs/scale/compare/v0.4.2 diff --git a/Cargo.toml b/Cargo.toml index ba3e9650..98379a92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scale_rs" -version = "0.4.4" +version = "0.4.5" edition = "2021" description = "Scale is a framework for building high-performance plugin systems into any application, all powered by WebAssembly." homepage = "https://scale.sh" diff --git a/integration/golang_tests/generated/generated.go b/integration/golang_tests/generated/generated.go index 9f4bf6b8..ea77888b 100644 --- a/integration/golang_tests/generated/generated.go +++ b/integration/golang_tests/generated/generated.go @@ -1,4 +1,4 @@ -// Code generated by scale-signature v0.4.4, DO NOT EDIT. +// Code generated by scale-signature v0.4.5, DO NOT EDIT. // output: generated package generated diff --git a/integration/golang_tests/host_signature/host.go b/integration/golang_tests/host_signature/host.go index e925c063..1e56f80d 100644 --- a/integration/golang_tests/host_signature/host.go +++ b/integration/golang_tests/host_signature/host.go @@ -1,4 +1,4 @@ -// Code generated by scale-signature v0.4.4, DO NOT EDIT. +// Code generated by scale-signature v0.4.5, DO NOT EDIT. // output: signature package signature diff --git a/integration/golang_tests/host_signature/types.go b/integration/golang_tests/host_signature/types.go index 59dc60d4..d501e529 100644 --- a/integration/golang_tests/host_signature/types.go +++ b/integration/golang_tests/host_signature/types.go @@ -1,4 +1,4 @@ -// Code generated by scale-signature v0.4.4, DO NOT EDIT. +// Code generated by scale-signature v0.4.5, DO NOT EDIT. // output: signature package signature diff --git a/integration/golang_tests/signature/guest.go b/integration/golang_tests/signature/guest.go index 469fb3f5..0f3f8524 100644 --- a/integration/golang_tests/signature/guest.go +++ b/integration/golang_tests/signature/guest.go @@ -1,4 +1,4 @@ -// Code generated by scale-signature v0.4.4, DO NOT EDIT. +// Code generated by scale-signature v0.4.5, DO NOT EDIT. // output: signature package signature diff --git a/integration/golang_tests/signature/types.go b/integration/golang_tests/signature/types.go index e4e9ba22..c8a7fefc 100644 --- a/integration/golang_tests/signature/types.go +++ b/integration/golang_tests/signature/types.go @@ -1,4 +1,4 @@ -// Code generated by scale-signature v0.4.4, DO NOT EDIT. +// Code generated by scale-signature v0.4.5, DO NOT EDIT. // output: signature package signature diff --git a/integration/rust_tests/generated/generated.rs b/integration/rust_tests/generated/generated.rs index 0dd384b0..356ac058 100644 --- a/integration/rust_tests/generated/generated.rs +++ b/integration/rust_tests/generated/generated.rs @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: generated #![allow(dead_code)] diff --git a/integration/rust_tests/signature/guest.rs b/integration/rust_tests/signature/guest.rs index 1fde0765..d8c2c841 100644 --- a/integration/rust_tests/signature/guest.rs +++ b/integration/rust_tests/signature/guest.rs @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: local_example_latest_guest pub mod types; diff --git a/integration/rust_tests/signature/types.rs b/integration/rust_tests/signature/types.rs index a60df82d..d3ddf6a3 100644 --- a/integration/rust_tests/signature/types.rs +++ b/integration/rust_tests/signature/types.rs @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: local_example_latest_guest #![allow(dead_code)] diff --git a/integration/typescript_tests/generated/generated.d.ts b/integration/typescript_tests/generated/generated.d.ts index a9ff3afc..05656d2d 100644 --- a/integration/typescript_tests/generated/generated.d.ts +++ b/integration/typescript_tests/generated/generated.d.ts @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: generated import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" diff --git a/integration/typescript_tests/generated/generated.js b/integration/typescript_tests/generated/generated.js index 2d4fcdfc..4924df5a 100644 --- a/integration/typescript_tests/generated/generated.js +++ b/integration/typescript_tests/generated/generated.js @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: generated "use strict"; diff --git a/integration/typescript_tests/generated/generated.js.map b/integration/typescript_tests/generated/generated.js.map index 74853834..bce4da50 100644 --- a/integration/typescript_tests/generated/generated.js.map +++ b/integration/typescript_tests/generated/generated.js.map @@ -2,7 +2,7 @@ "version": 3, "sources": [""], "sourceRoot": "generated.js", - "sourcesContent": ["// Code generated by scale-signature 0.4.4, DO NOT EDIT.\n// output: generated\n\nimport { Encoder, Decoder, Kind } from \"@loopholelabs/polyglot\"\n\nexport class Context {\n a: number;\n b: number;\n c: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.a = decoder.int32();\n this.b = decoder.int32();\n this.c = decoder.int32();\n } else {\n this.a = 0;\n this.b = 0;\n this.c = 0;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.int32(this.a);\n encoder.int32(this.b);\n encoder.int32(this.c);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): Context | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new Context(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n"], + "sourcesContent": ["// Code generated by scale-signature 0.4.5, DO NOT EDIT.\n// output: generated\n\nimport { Encoder, Decoder, Kind } from \"@loopholelabs/polyglot\"\n\nexport class Context {\n a: number;\n b: number;\n c: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.a = decoder.int32();\n this.b = decoder.int32();\n this.c = decoder.int32();\n } else {\n this.a = 0;\n this.b = 0;\n this.c = 0;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.int32(this.a);\n encoder.int32(this.b);\n encoder.int32(this.c);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): Context | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new Context(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n"], "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,EAQnB,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,IAAI,QAAQ,MAAM;AACvB,WAAK,IAAI,QAAQ,MAAM;AACvB,WAAK,IAAI,QAAQ,MAAM;AAAA,IACzB,OAAO;AACL,WAAK,IAAI;AACT,WAAK,IAAI;AACT,WAAK,IAAI;AAAA,IACX;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,MAAM,KAAK,CAAC;AACpB,YAAQ,MAAM,KAAK,CAAC;AACpB,YAAQ,MAAM,KAAK,CAAC;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuC;AACpD,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,QAAQ,OAAO;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;", "names": [] } diff --git a/integration/typescript_tests/host_signature/index.ts b/integration/typescript_tests/host_signature/index.ts index 2e9bf756..23926011 100644 --- a/integration/typescript_tests/host_signature/index.ts +++ b/integration/typescript_tests/host_signature/index.ts @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: local-example-latest-host /* eslint no-bitwise: off */ diff --git a/integration/typescript_tests/host_signature/types.ts b/integration/typescript_tests/host_signature/types.ts index dbd46d23..37c22941 100644 --- a/integration/typescript_tests/host_signature/types.ts +++ b/integration/typescript_tests/host_signature/types.ts @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: local-example-latest-host import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" diff --git a/integration/typescript_tests/signature/index.ts b/integration/typescript_tests/signature/index.ts index 61ad18b9..2d6b7bfb 100644 --- a/integration/typescript_tests/signature/index.ts +++ b/integration/typescript_tests/signature/index.ts @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: local-example-latest-guest /* eslint no-bitwise: off */ diff --git a/integration/typescript_tests/signature/types.ts b/integration/typescript_tests/signature/types.ts index e81bcd77..e7320551 100644 --- a/integration/typescript_tests/signature/types.ts +++ b/integration/typescript_tests/signature/types.ts @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: local-example-latest-guest import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" diff --git a/package.json b/package.json index 55b429df..7782b718 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@loopholelabs/scale", - "version": "0.4.4", + "version": "0.4.5", "description": "Scale is a framework for building high-performance plugin systems into any application, all powered by WebAssembly.", "source": "index.ts", "types": "types.d.ts", diff --git a/signature/converter/converter_tests/generated.go b/signature/converter/converter_tests/generated.go index beb753eb..b1ea2880 100644 --- a/signature/converter/converter_tests/generated.go +++ b/signature/converter/converter_tests/generated.go @@ -1,4 +1,4 @@ -// Code generated by scale-signature v0.4.4, DO NOT EDIT. +// Code generated by scale-signature v0.4.5, DO NOT EDIT. // output: generated package generated diff --git a/signature/generator/golang/generated.txt b/signature/generator/golang/generated.txt index 670213f6..ae072bdb 100644 --- a/signature/generator/golang/generated.txt +++ b/signature/generator/golang/generated.txt @@ -1,4 +1,4 @@ -// Code generated by scale-signature v0.4.4, DO NOT EDIT. +// Code generated by scale-signature v0.4.5, DO NOT EDIT. // output: types package types diff --git a/signature/generator/rust/generated.txt b/signature/generator/rust/generated.txt index f23b3790..69440910 100755 --- a/signature/generator/rust/generated.txt +++ b/signature/generator/rust/generated.txt @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: types #![allow(dead_code)] diff --git a/signature/generator/typescript/generated.txt b/signature/generator/typescript/generated.txt index e43dd975..ed8194fd 100755 --- a/signature/generator/typescript/generated.txt +++ b/signature/generator/typescript/generated.txt @@ -1,4 +1,4 @@ -// Code generated by scale-signature 0.4.4, DO NOT EDIT. +// Code generated by scale-signature 0.4.5, DO NOT EDIT. // output: types import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" diff --git a/version/current_version b/version/current_version index 5ab76976..04a04894 100644 --- a/version/current_version +++ b/version/current_version @@ -1 +1 @@ -v0.4.4 \ No newline at end of file +v0.4.5 \ No newline at end of file