cli
cli copied to clipboard
Fix language validation
Problem: looking up the language manifest file (e.g. Cargo.toml, go.mod, package.json) would cause the CLI to fail if it wasn't in the same directory as the directory the CLI was being run in (which typically is the project directory where the fastly.toml exists).
Solution: We lean into specific language toolchain commands to help identify the language's manifest file, rather than just expecting to find it in the current directory.
Notes: I tested this PR by creating a project for Go, Rust and JavaScript where I run compute init and then manually moved the source code files/fastly.toml into a nested directory to validate I was able to build the projects successfully.
Examples
Rust
.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── nested
│ ├── fastly.toml
│ └── src
│ ├── main.rs
│ └── [email protected]
└── rust-toolchain.toml
NOTE: I needed the following change in the
Cargo.tomlso Cargo knew which binary crate it needs to reference:
[[bin]]
name = "fastly-compute-project"
path = "nested/src/main.rs"
Go
.
├── README.md
├── go.mod
├── go.sum
└── nested
├── fastly.toml
└── main.go
JavaScript
.
├── README.md
├── nested
│ ├── fastly.toml
│ ├── src
│ │ ├── index.js
│ │ └── [email protected]
│ └── webpack.config.js
├── npm-shrinkwrap.json
└── package.json
Fixes: https://github.com/fastly/cli/issues/598