swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.68k stars 1.32k forks source link

`swift package add-dependency` automatically resolve a version #7759

Open MahdiBM opened 1 month ago

MahdiBM commented 1 month ago

Description

swift package add-dependency should automatically default to --from, with the latest stable version resolved. If no stable version, it should just default to the latest available version, possibly with only "upToNextMinor"?

cargo add jwt-authorizer has a similar behavior to what I described.

Expected behavior

swift package add-dependency https://github.com/DiscordBM/DiscordBM

Should result in:

.package(url: "https://github.com/DiscordBM/DiscordBM", from: "1.12.0"),

Notice from: "1.12.0" automatically figured out by the command.

Actual behavior

swift package add-dependency https://github.com/DiscordBM/DiscordBM

Results in:

error: must specify one of --exact, --branch, --revision, --from, or --up-to-next-minor-from

Steps to reproduce

Feature Request - No steps to reproduce.

Swift Package Manager version/commit hash

~ swift package --version
Swift Package Manager - Swift 6.0.0-dev

Swift & OS version (output of swift --version && uname -a)

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
Target: arm64-apple-macosx15.0
Darwin ---.local 24.0.0 Darwin Kernel Version 24.0.0: ---; root:xnu-11215.0.115.501.3~1/RELEASE_ARM64_T6000 arm64
rauhul commented 1 month ago

I think this would be a good improvement, imo the default should be from: "<latest-tag>" which iiuc means up to next major.