Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compute/build): support locating language manifests outside project directory #765

Merged
merged 5 commits into from
Jan 17, 2023

Conversation

Integralist
Copy link
Collaborator

@Integralist Integralist commented Jan 17, 2023

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, then cd into the nested directory (because the CLI needs to execute where the fastly.toml file is) to validate I was able to build the projects successfully even though the language manifest files (e.g. Cargo.toml, go.mod, package.json where in a parent directory).

Examples

Go

.
├── README.md
├── go.mod
├── go.sum
└── nested
    ├── fastly.toml
    └── main.go

JavaScript

.
├── README.md
├── nested
│   ├── fastly.toml
│   ├── src
│   │   ├── index.js
│   │   └── welcome-to-compute@edge.html
│   └── webpack.config.js
├── npm-shrinkwrap.json
└── package.json

Rust

.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── nested
│   ├── fastly.toml
│   └── src
│       ├── main.rs
│       └── welcome-to-compute@edge.html
└── rust-toolchain.toml

NOTE: I needed the following change in the Cargo.toml so Cargo knew which binary crate it needs to reference:

[[bin]]
name = "fastly-compute-project"
path = "nested/src/main.rs"

@Integralist Integralist added the enhancement New feature or request label Jan 17, 2023
@Integralist Integralist merged commit 8b64f51 into main Jan 17, 2023
@Integralist Integralist deleted the integralist/lang-manifest-lookup branch January 17, 2023 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant