Skip to content

Commit 101bc69

Browse files
committed
[WIP, BROKEN] start making "dist init" use v1 config
1 parent cdfcfa3 commit 101bc69

File tree

1 file changed

+16
-75
lines changed

1 file changed

+16
-75
lines changed

cargo-dist/src/init.rs

+16-75
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{
99
config::{
1010
self, CiStyle, Config, DistMetadata, HostingStyle, InstallPathStrategy, InstallerStyle,
1111
MacPkgConfig, PublishStyle,
12+
v1::TomlLayer,
1213
},
1314
do_generate,
1415
errors::{DistError, DistResult},
@@ -506,87 +507,27 @@ fn get_new_dist_metadata(
506507
cfg: &Config,
507508
args: &InitArgs,
508509
workspaces: &WorkspaceGraph,
509-
) -> DistResult<DistMetadata> {
510+
) -> DistResult<TomlLayer> {
510511
use dialoguer::{Confirm, Input, MultiSelect};
511512
let root_workspace = workspaces.root_workspace();
512513
let has_config = has_metadata_table(root_workspace);
513514

514515
let mut meta = if has_config {
515-
config::parse_metadata_table_or_manifest(
516-
&root_workspace.manifest_path,
517-
root_workspace.dist_manifest_path.as_deref(),
518-
root_workspace.cargo_metadata_table.as_ref(),
519-
)?
516+
config::load_config(&root_workspace.manifest_path)?.dist
520517
} else {
521-
DistMetadata {
518+
TomlLayer {
522519
// If they init with this version we're gonna try to stick to it!
523-
cargo_dist_version: Some(std::env!("CARGO_PKG_VERSION").parse().unwrap()),
524-
cargo_dist_url_override: None,
525-
// deprecated, default to not emitting it
526-
rust_toolchain_version: None,
527-
ci: None,
528-
installers: None,
529-
install_success_msg: None,
530-
tap: None,
531-
formula: None,
532-
system_dependencies: None,
533-
targets: None,
520+
dist_version: Some(std::env!("CARGO_PKG_VERSION").parse().unwrap()),
521+
dist_url_override: None,
534522
dist: None,
535-
include: None,
536-
auto_includes: None,
537-
windows_archive: None,
538-
unix_archive: None,
539-
npm_scope: None,
540-
npm_package: None,
541-
checksum: None,
542-
precise_builds: None,
543-
merge_tasks: None,
544-
fail_fast: None,
545-
cache_builds: None,
546-
build_local_artifacts: None,
547-
dispatch_releases: None,
548-
release_branch: None,
549-
install_path: None,
550-
features: None,
551-
default_features: None,
552-
all_features: None,
553-
plan_jobs: None,
554-
local_artifacts_jobs: None,
555-
global_artifacts_jobs: None,
556-
source_tarball: None,
557-
host_jobs: None,
558-
publish_jobs: None,
559-
post_announce_jobs: None,
560-
publish_prereleases: None,
561-
force_latest: None,
562-
create_release: None,
563-
github_releases_repo: None,
564-
github_releases_submodule_path: None,
565-
github_release: None,
566-
pr_run_mode: None,
567523
allow_dirty: None,
568-
ssldotcom_windows_sign: None,
569-
macos_sign: None,
570-
github_attestations: None,
571-
msvc_crt_static: None,
572-
hosting: None,
573-
extra_artifacts: None,
574-
github_custom_runners: None,
575-
github_custom_job_permissions: None,
576-
bin_aliases: None,
577-
tag_namespace: None,
578-
install_updater: None,
579-
always_use_latest_updater: None,
580-
display: None,
581-
display_name: None,
582-
package_libraries: None,
583-
install_libraries: None,
584-
github_build_setup: None,
585-
mac_pkg_config: None,
586-
min_glibc_version: None,
587-
cargo_auditable: None,
588-
cargo_cyclonedx: None,
589-
omnibor: None,
524+
targets: None,
525+
artifacts: None,
526+
builds: None,
527+
ci: None,
528+
hosts: None,
529+
installers: None,
530+
publishers: None,
590531
}
591532
};
592533

@@ -607,7 +548,7 @@ fn get_new_dist_metadata(
607548

608549
// Set cargo-dist-version
609550
let current_version: Version = std::env!("CARGO_PKG_VERSION").parse().unwrap();
610-
if let Some(desired_version) = &meta.cargo_dist_version {
551+
if let Some(desired_version) = &meta.dist_version {
611552
if desired_version != &current_version && !desired_version.pre.starts_with("github-") {
612553
let default = true;
613554
let prompt = format!(
@@ -627,7 +568,7 @@ fn get_new_dist_metadata(
627568
};
628569

629570
if response {
630-
meta.cargo_dist_version = Some(current_version);
571+
meta.dist_version = Some(current_version);
631572
} else {
632573
Err(DistError::NoUpdateVersion {
633574
project_version: desired_version.clone(),
@@ -637,7 +578,7 @@ fn get_new_dist_metadata(
637578
}
638579
} else {
639580
// Really not allowed, so just force them onto the current version
640-
meta.cargo_dist_version = Some(current_version);
581+
meta.dist_version = Some(current_version);
641582
}
642583

643584
{

0 commit comments

Comments
 (0)