mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
feat: use standard tables by default
This commit is contained in:
parent
b1a0cf6637
commit
f732451252
3 changed files with 26 additions and 24 deletions
|
@ -151,20 +151,20 @@ impl AddCommand {
|
||||||
.unwrap_or(url.path.to_string()),
|
.unwrap_or(url.path.to_string()),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let field = &mut manifest[dependency_key]
|
||||||
|
.or_insert(toml_edit::Item::Table(toml_edit::Table::new()))[&alias];
|
||||||
|
|
||||||
match specifier {
|
match specifier {
|
||||||
DependencySpecifiers::Pesde(spec) => {
|
DependencySpecifiers::Pesde(spec) => {
|
||||||
manifest[dependency_key][&alias]["name"] =
|
field["name"] = toml_edit::value(spec.name.clone().to_string());
|
||||||
toml_edit::value(spec.name.clone().to_string());
|
field["version"] = toml_edit::value(format!("^{}", version_id.version()));
|
||||||
manifest[dependency_key][&alias]["version"] =
|
|
||||||
toml_edit::value(format!("^{}", version_id.version()));
|
|
||||||
|
|
||||||
if *version_id.target() != project_target {
|
if *version_id.target() != project_target {
|
||||||
manifest[dependency_key][&alias]["target"] =
|
field["target"] = toml_edit::value(version_id.target().to_string());
|
||||||
toml_edit::value(version_id.target().to_string());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(index) = spec.index.filter(|i| i != DEFAULT_INDEX_NAME) {
|
if let Some(index) = spec.index.filter(|i| i != DEFAULT_INDEX_NAME) {
|
||||||
manifest[dependency_key][&alias]["index"] = toml_edit::value(index);
|
field["index"] = toml_edit::value(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
|
@ -177,13 +177,11 @@ impl AddCommand {
|
||||||
}
|
}
|
||||||
#[cfg(feature = "wally-compat")]
|
#[cfg(feature = "wally-compat")]
|
||||||
DependencySpecifiers::Wally(spec) => {
|
DependencySpecifiers::Wally(spec) => {
|
||||||
manifest[dependency_key][&alias]["wally"] =
|
field["wally"] = toml_edit::value(spec.name.clone().to_string());
|
||||||
toml_edit::value(spec.name.clone().to_string());
|
field["version"] = toml_edit::value(format!("^{}", version_id.version()));
|
||||||
manifest[dependency_key][&alias]["version"] =
|
|
||||||
toml_edit::value(format!("^{}", version_id.version()));
|
|
||||||
|
|
||||||
if let Some(index) = spec.index.filter(|i| i != DEFAULT_INDEX_NAME) {
|
if let Some(index) = spec.index.filter(|i| i != DEFAULT_INDEX_NAME) {
|
||||||
manifest[dependency_key][&alias]["index"] = toml_edit::value(index);
|
field["index"] = toml_edit::value(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
|
@ -194,9 +192,8 @@ impl AddCommand {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
DependencySpecifiers::Git(spec) => {
|
DependencySpecifiers::Git(spec) => {
|
||||||
manifest[dependency_key][&alias]["repo"] =
|
field["repo"] = toml_edit::value(spec.repo.to_bstring().to_string());
|
||||||
toml_edit::value(spec.repo.to_bstring().to_string());
|
field["rev"] = toml_edit::value(spec.rev.clone());
|
||||||
manifest[dependency_key][&alias]["rev"] = toml_edit::value(spec.rev.clone());
|
|
||||||
|
|
||||||
println!("added git {}#{} to {}", spec.repo, spec.rev, dependency_key);
|
println!("added git {}#{} to {}", spec.repo, spec.rev, dependency_key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,8 @@ impl InitCommand {
|
||||||
.prompt()
|
.prompt()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
manifest["target"]["environment"] = toml_edit::value(target_env);
|
manifest["target"].or_insert(toml_edit::Item::Table(toml_edit::Table::new()))
|
||||||
|
["environment"] = toml_edit::value(target_env);
|
||||||
|
|
||||||
if target_env == "roblox"
|
if target_env == "roblox"
|
||||||
|| inquire::Confirm::new(&format!(
|
|| inquire::Confirm::new(&format!(
|
||||||
|
@ -153,20 +154,23 @@ impl InitCommand {
|
||||||
)
|
)
|
||||||
.context("failed to write sourcemap generator script file")?;
|
.context("failed to write sourcemap generator script file")?;
|
||||||
|
|
||||||
manifest["scripts"][&ScriptName::RobloxSyncConfigGenerator.to_string()] =
|
let scripts =
|
||||||
|
manifest["scripts"].or_insert(toml_edit::Item::Table(toml_edit::Table::new()));
|
||||||
|
|
||||||
|
scripts[&ScriptName::RobloxSyncConfigGenerator.to_string()] =
|
||||||
toml_edit::value(format!(
|
toml_edit::value(format!(
|
||||||
concat!(".", env!("CARGO_PKG_NAME"), "/{}.luau"),
|
concat!(".", env!("CARGO_PKG_NAME"), "/{}.luau"),
|
||||||
ScriptName::RobloxSyncConfigGenerator
|
ScriptName::RobloxSyncConfigGenerator
|
||||||
));
|
));
|
||||||
|
|
||||||
manifest["scripts"][&ScriptName::SourcemapGenerator.to_string()] =
|
scripts[&ScriptName::SourcemapGenerator.to_string()] = toml_edit::value(format!(
|
||||||
toml_edit::value(format!(
|
|
||||||
concat!(".", env!("CARGO_PKG_NAME"), "/{}.luau"),
|
concat!(".", env!("CARGO_PKG_NAME"), "/{}.luau"),
|
||||||
ScriptName::SourcemapGenerator
|
ScriptName::SourcemapGenerator
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest["indices"][DEFAULT_INDEX_NAME] =
|
manifest["indices"].or_insert(toml_edit::Item::Table(toml_edit::Table::new()))
|
||||||
|
[DEFAULT_INDEX_NAME] =
|
||||||
toml_edit::value(read_config()?.default_index.to_bstring().to_string());
|
toml_edit::value(read_config()?.default_index.to_bstring().to_string());
|
||||||
|
|
||||||
project.write_manifest(manifest.to_string())?;
|
project.write_manifest(manifest.to_string())?;
|
||||||
|
|
|
@ -67,7 +67,8 @@ impl PatchCommitCommand {
|
||||||
|
|
||||||
std::fs::write(&patch_file, patch).context("failed to write patch file")?;
|
std::fs::write(&patch_file, patch).context("failed to write patch file")?;
|
||||||
|
|
||||||
manifest["patches"][&name.to_string()][&version_id.to_string()] =
|
manifest["patches"].or_insert(toml_edit::Item::Table(toml_edit::Table::new()))
|
||||||
|
[&name.to_string()][&version_id.to_string()] =
|
||||||
toml_edit::value(format!("patches/{patch_file_name}"));
|
toml_edit::value(format!("patches/{patch_file_name}"));
|
||||||
|
|
||||||
project
|
project
|
||||||
|
|
Loading…
Reference in a new issue