Skip to content

Commit

Permalink
Merge pull request #874 from AmbientRun/fix-api-version
Browse files Browse the repository at this point in the history
Fix new package api version. Fixes #873
  • Loading branch information
FredrikNoren authored Sep 15, 2023
2 parents b43d252 + 3472d15 commit a20eb5b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
35 changes: 17 additions & 18 deletions app/src/cli/new_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ pub(crate) fn handle(
// Write the files to disk.
let ambient_toml = include_str!("new_package_template/ambient.toml")
.replace("{{id}}", id.as_str())
.replace("{{name}}", name);
.replace("{{name}}", name)
.replace(
"{{ambient_version}}",
&format!("{}", ambient_native_std::ambient_version().version),
);

let cargo_toml = {
// Special-case creating an example in guest/rust/examples so that it "Just Works".
Expand All @@ -70,23 +74,18 @@ pub(crate) fn handle(
None => {
let version = ambient_version();
(
#[cfg(feature = "production")]
format!("ambient_api = \"{}\"", version.version),
#[cfg(not(feature = "production"))]
{
if let Some(api_path) = api_path {
log::info!("Ambient path: {}", api_path);
format!("ambient_api = {{ path = {:?} }}", api_path)
} else if let Some(tag) = version.tag() {
log::info!("Ambient tag: {}", tag);
format!("ambient_api = {{ git = \"https://github.com/AmbientRun/Ambient.git\", tag = \"{}\" }}", tag)
} else if !version.revision.is_empty() {
log::info!("Ambient revision: {}", version.revision);
format!("ambient_api = {{ git = \"https://github.com/AmbientRun/Ambient.git\", rev = \"{}\" }}", version.revision)
} else {
log::info!("Ambient version: {}", version.version);
format!("ambient_api = \"{}\"", version.version)
}
if let Some(api_path) = api_path {
log::info!("Ambient path: {}", api_path);
format!("ambient_api = {{ path = {:?} }}", api_path)
} else if let Some(tag) = version.tag() {
log::info!("Ambient tag: {}", tag);
format!("ambient_api = {{ git = \"https://github.com/AmbientRun/Ambient.git\", tag = \"{}\" }}", tag)
} else if !version.revision.is_empty() {
log::info!("Ambient revision: {}", version.revision);
format!("ambient_api = {{ git = \"https://github.com/AmbientRun/Ambient.git\", rev = \"{}\" }}", version.revision)
} else {
log::info!("Ambient version: {}", version.version);
format!("ambient_api = \"{}\"", version.version)
},
false,
)
Expand Down
1 change: 1 addition & 0 deletions app/src/cli/new_package_template/ambient.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ id = "{{id}}"
name = "{{name}}"
version = "0.0.1"
content = { type = "Playable" }
ambient_version = "{{ambient_version}}"

0 comments on commit a20eb5b

Please sign in to comment.