Skip to content

Commit ceb448d

Browse files
authored
fix: deprecate [project] (#4771)
1 parent ff204d0 commit ceb448d

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

crates/pixi_manifest/src/toml/manifest.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::{
3030
environment::TomlEnvironmentList, task::TomlTask,
3131
},
3232
utils::{PixiSpanned, package_map::UniquePackageMap},
33+
warning::Deprecation,
3334
};
3435

3536
/// Raw representation of a pixi manifest. This is the deserialized form of the
@@ -469,7 +470,12 @@ impl<'de> toml_span::Deserialize<'de> for TomlManifest {
469470
let workspace = if th.contains("workspace") {
470471
Some(th.required_s("workspace")?.into())
471472
} else {
472-
th.optional("project")
473+
let project: Option<Spanned<TomlWorkspace>> = th.optional("project");
474+
if let Some(project) = &project {
475+
warnings
476+
.push(Deprecation::renamed_field("project", "workspace", project.span).into());
477+
}
478+
project.map(From::from)
473479
};
474480
let package = th.optional("package");
475481

@@ -901,4 +907,28 @@ mod test {
901907
"#,
902908
));
903909
}
910+
911+
#[test]
912+
fn test_project_deprecation_warning() {
913+
assert_snapshot!(
914+
expect_parse_warnings(
915+
r#"
916+
[project]
917+
name = "foo"
918+
channels = []
919+
"#,
920+
),
921+
@r#"
922+
⚠ The `project` field is deprecated. Use `workspace` instead.
923+
╭─[pixi.toml:2:9]
924+
1 │
925+
2 │ ╭─▶ [project]
926+
3 │ │ name = "foo"
927+
4 │ ├─▶ channels = []
928+
· ╰──── replace this with 'workspace'
929+
5 │
930+
╰────
931+
"#
932+
);
933+
}
904934
}

0 commit comments

Comments
 (0)