mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-05-04 10:33:47 +01:00
feat: add engines when initing project
When initializing a project, the `engines` section will now be copied over from the scripts package.
This commit is contained in:
parent
a99420e05d
commit
e4f496ffab
2 changed files with 24 additions and 24 deletions
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Add dev only installs in #32 by @Stefanuk12
|
- Add dev only installs in #32 by @Stefanuk12
|
||||||
- Add `PESDE_HOME` variable (defaults to $HOME/.pesde) to override pesde's directory's location by @daimond113
|
- Add `PESDE_HOME` variable (defaults to $HOME/.pesde) to override pesde's directory's location by @daimond113
|
||||||
- Add `--target` argument to execute command by @daimond113
|
- Add `--target` argument to execute command by @daimond113
|
||||||
|
- Add `engines` when initializing a project based on the scripts package's by @daimond113
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Download engines in install step rather than lazily by @daimond113
|
- Download engines in install step rather than lazily by @daimond113
|
||||||
|
|
|
@ -215,23 +215,18 @@ impl InitCommand {
|
||||||
.pop_last()
|
.pop_last()
|
||||||
.context("scripts package not found")?;
|
.context("scripts package not found")?;
|
||||||
|
|
||||||
let id = Arc::new(PackageId::new(PackageNames::Pesde(scripts_pkg_name), v_id));
|
let mut file = source
|
||||||
|
.read_index_file(&scripts_pkg_name, &project)
|
||||||
|
.await
|
||||||
|
.context("failed to read scripts package index file")?
|
||||||
|
.context("scripts package not found in index")?;
|
||||||
|
|
||||||
let target = source
|
let entry = file
|
||||||
.get_target(
|
.entries
|
||||||
&pkg_ref,
|
.remove(&v_id)
|
||||||
&GetTargetOptions {
|
.context("failed to remove scripts package entry")?;
|
||||||
project: project.clone(),
|
|
||||||
// HACK: the pesde package source doesn't use the path, so we can just use an empty one
|
|
||||||
path: Path::new("").into(),
|
|
||||||
id: id.clone(),
|
|
||||||
// HACK: the pesde package source doesn't use the engines, so we can just use an empty map
|
|
||||||
engines: Default::default(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let Some(scripts) = target.scripts().filter(|s| !s.is_empty()) else {
|
let Some(scripts) = entry.target.scripts().filter(|s| !s.is_empty()) else {
|
||||||
anyhow::bail!("scripts package has no scripts.")
|
anyhow::bail!("scripts package has no scripts.")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,9 +243,9 @@ impl InitCommand {
|
||||||
.or_insert(toml_edit::Item::Table(toml_edit::Table::new()));
|
.or_insert(toml_edit::Item::Table(toml_edit::Table::new()));
|
||||||
|
|
||||||
let field = &mut dev_deps["scripts"];
|
let field = &mut dev_deps["scripts"];
|
||||||
field["name"] = toml_edit::value(id.name().to_string());
|
field["name"] = toml_edit::value(scripts_pkg_name.to_string());
|
||||||
field["version"] = toml_edit::value(format!("^{}", id.version_id().version()));
|
field["version"] = toml_edit::value(format!("^{}", v_id.version()));
|
||||||
field["target"] = toml_edit::value(id.version_id().target().to_string());
|
field["target"] = toml_edit::value(v_id.target().to_string());
|
||||||
|
|
||||||
for (alias, (spec, ty)) in pkg_ref.dependencies {
|
for (alias, (spec, ty)) in pkg_ref.dependencies {
|
||||||
if ty != DependencyType::Peer {
|
if ty != DependencyType::Peer {
|
||||||
|
@ -264,14 +259,18 @@ impl InitCommand {
|
||||||
let field = &mut dev_deps[alias.as_str()];
|
let field = &mut dev_deps[alias.as_str()];
|
||||||
field["name"] = toml_edit::value(spec.name.to_string());
|
field["name"] = toml_edit::value(spec.name.to_string());
|
||||||
field["version"] = toml_edit::value(spec.version.to_string());
|
field["version"] = toml_edit::value(spec.version.to_string());
|
||||||
field["target"] = toml_edit::value(
|
field["target"] =
|
||||||
spec.target
|
toml_edit::value(spec.target.unwrap_or_else(|| v_id.target()).to_string());
|
||||||
.unwrap_or_else(|| id.version_id().target())
|
|
||||||
.to_string(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add engines
|
if !entry.engines.is_empty() {
|
||||||
|
let engines = manifest["engines"]
|
||||||
|
.or_insert(toml_edit::Item::Table(toml_edit::Table::new()));
|
||||||
|
|
||||||
|
for (engine, req) in entry.engines {
|
||||||
|
engines[engine.to_string()] = toml_edit::value(req.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"{ERROR_PREFIX}: no scripts package configured, this can cause issues with Roblox compatibility"
|
"{ERROR_PREFIX}: no scripts package configured, this can cause issues with Roblox compatibility"
|
||||||
|
|
Loading…
Add table
Reference in a new issue