Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/commands/compute/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error) {
revision.AppVersion, cases.Title(textlang.English).String(language.Name),
)
metadataArgs := []string{
"metadata", "add", "bin/main.wasm", metadataProcessedBy,
"metadata", "add", binWasmPath, metadataProcessedBy,
}

metadataDisable, _ := strconv.ParseBool(c.Globals.Env.WasmMetadataDisable)
Expand Down Expand Up @@ -292,7 +292,7 @@ func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error) {

files := []string{
manifest.Filename,
"bin/main.wasm",
binWasmPath,
}
files, err = c.includeSourceCode(files, language.SourceDirectory)
if err != nil {
Expand Down Expand Up @@ -384,7 +384,7 @@ func (c *BuildCommand) ShowMetadata(wasmtools string, out io.Writer) {
// Disabling as the variables come from trusted sources.
// #nosec
// nosemgrep
command := exec.Command(wasmtools, "metadata", "show", "bin/main.wasm")
command := exec.Command(wasmtools, "metadata", "show", binWasmPath)
wasmtoolsOutput, err := command.Output()
if err != nil {
text.Error(out, "failed to execute wasm-tools metadata command: %s\n\n", err)
Expand Down Expand Up @@ -499,7 +499,7 @@ func ExecuteWasmTools(wasmtools string, args []string, d *global.Data) error {
// #nosec
err = os.WriteFile(binWasmPath, originalBin, 0o777)
if err != nil {
return fmt.Errorf("failed to restore bin/main.wasm: %w", err)
return fmt.Errorf("failed to restore %s: %w", binWasmPath, err)
}
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/commands/compute/language_assemblyscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package compute
import (
"encoding/json"
"errors"
"fmt"
"io"
"os"

Expand All @@ -19,7 +20,7 @@ import (
// NOTE: In the 5.x CLI releases we persisted the default to the fastly.toml
// We no longer do that. In 6.x we use the default and just inform the user.
// This makes the experience less confusing as users didn't expect file changes.
const AsDefaultBuildCommand = "npm exec -- asc assembly/index.ts --outFile bin/main.wasm --optimize --noAssert"
var AsDefaultBuildCommand = fmt.Sprintf("npm exec -- asc assembly/index.ts --outFile %s --optimize --noAssert", binWasmPath)

// AsDefaultBuildCommandForWebpack is a build command compiled into the CLI
// binary so it can be used as a fallback for customer's who have an existing
Expand All @@ -29,7 +30,7 @@ const AsDefaultBuildCommand = "npm exec -- asc assembly/index.ts --outFile bin/m
//
// NOTE: For this variation of the build script to be added to the user's
// fastly.toml will require a successful check for the webpack dependency.
const AsDefaultBuildCommandForWebpack = "npm exec webpack && npm exec -- asc assembly/index.ts --outFile bin/main.wasm --optimize --noAssert"
var AsDefaultBuildCommandForWebpack = fmt.Sprintf("npm exec webpack && npm exec -- asc assembly/index.ts --outFile %s --optimize --noAssert", binWasmPath)

// AsSourceDirectory represents the source code directory.
const AsSourceDirectory = "assembly"
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/compute/language_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
// NOTE: In the 5.x CLI releases we persisted the default to the fastly.toml
// We no longer do that. In 6.x we use the default and just inform the user.
// This makes the experience less confusing as users didn't expect file changes.
const TinyGoDefaultBuildCommand = "tinygo build -target=wasi -gc=conservative -o bin/main.wasm ./"
var TinyGoDefaultBuildCommand = fmt.Sprintf("tinygo build -target=wasi -gc=conservative -o %s ./", binWasmPath)

// GoSourceDirectory represents the source code directory.
const GoSourceDirectory = "."
Expand Down
5 changes: 3 additions & 2 deletions pkg/commands/compute/language_javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package compute
import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
"path/filepath"
Expand All @@ -20,7 +21,7 @@ import (
// NOTE: In the 5.x CLI releases we persisted the default to the fastly.toml
// We no longer do that. In 6.x we use the default and just inform the user.
// This makes the experience less confusing as users didn't expect file changes.
const JsDefaultBuildCommand = "npm exec js-compute-runtime ./src/index.js ./bin/main.wasm"
var JsDefaultBuildCommand = fmt.Sprintf("npm exec js-compute-runtime ./src/index.js %s", binWasmPath)

// JsDefaultBuildCommandForWebpack is a build command compiled into the CLI
// binary so it can be used as a fallback for customer's who have an existing
Expand All @@ -30,7 +31,7 @@ const JsDefaultBuildCommand = "npm exec js-compute-runtime ./src/index.js ./bin/
//
// NOTE: For this variation of the build script to be added to the user's
// fastly.toml will require a successful check for the webpack dependency.
const JsDefaultBuildCommandForWebpack = "npm exec webpack && npm exec js-compute-runtime ./bin/index.js ./bin/main.wasm"
var JsDefaultBuildCommandForWebpack = fmt.Sprintf("npm exec webpack && npm exec js-compute-runtime ./bin/index.js %s", binWasmPath)

// JsSourceDirectory represents the source code directory.
const JsSourceDirectory = "src"
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/compute/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func NewServeCommand(parent argparser.Registerer, g *global.Data, build *BuildCo
c.CmdClause.Flag("debug", "Run the server in Debug Adapter mode").Hidden().BoolVar(&c.debug)
c.CmdClause.Flag("dir", "Project directory to build (default: current directory)").Short('C').Action(c.dir.Set).StringVar(&c.dir.Value)
c.CmdClause.Flag("env", "The manifest environment config to use (e.g. 'stage' will attempt to read 'fastly.stage.toml')").Action(c.env.Set).StringVar(&c.env.Value)
c.CmdClause.Flag("file", "The Wasm file to run (causes validation checks for ./bin/main.wasm to be skipped)").Default("bin/main.wasm").StringVar(&c.file)
c.CmdClause.Flag("file", fmt.Sprintf("The Wasm file to run (causes validation checks for %s to be skipped)", binWasmPath)).Default(binWasmPath).StringVar(&c.file)
c.CmdClause.Flag("include-source", "Include source code in built package").Action(c.includeSrc.Set).BoolVar(&c.includeSrc.Value)
c.CmdClause.Flag("language", "Language type").Action(c.lang.Set).StringVar(&c.lang.Value)
c.CmdClause.Flag("metadata-disable", "Disable Wasm binary metadata annotations").Action(c.metadataDisable.Set).BoolVar(&c.metadataDisable.Value)
Expand Down