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

Add template code for multi-class discounts in rust #588

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions discounts/rust/discounts/default/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
16 changes: 16 additions & 0 deletions discounts/rust/discounts/default/Cargo.toml.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "{{handle | replace: " ", "-" | downcase}}"
version = "1.0.0"
edition = "2021"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "2025"?

rust-version = "1.62"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version is old. We currentl use 1.83, should we update it? 1.62 is the one used in the other targets (older templates in this repo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know for sure, but it seems sensible to start out with the latest Rust version that we're supporting in the CLI, rather than something older.


[dependencies]
serde = { version = "1.0.13", features = ["derive"] }
serde_json = "1.0"
shopify_function = "0.8.1"
graphql_client = "0.14.0"

[profile.release]
lto = true
opt-level = 'z'
strip = true
16 changes: 16 additions & 0 deletions discounts/rust/discounts/default/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Shopify Function development with Rust

## Dependencies

- [Install Rust](https://www.rust-lang.org/tools/install)
- On Windows, Rust requires the [Microsoft C++ Build Tools](https://docs.microsoft.com/en-us/windows/dev-environment/rust/setup). Be sure to select the _Desktop development with C++_ workload when installing them.

## Building the function

You can build this individual function using `cargo build`.

```shell
cargo build --target=wasm32-wasip1 --release
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this target added with the newer Rust version? Seems this could also be a reason to bump the Rust version.

Copy link
Contributor

@jonathanhamel4 jonathanhamel4 Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, however this target has been available before this release, it just became the new default with 1.84

```

The Shopify CLI `build` command will also execute this, based on the configuration in `shopify.extension.toml`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "{{name}}",
"description": "{{name}}"
}
Loading
Loading