yonaskolb / Mint

A package manager that installs and runs executable Swift packages
MIT License
2.27k stars 122 forks source link

[discussion] Re-design Mintfile #165

Open hiragram opened 4 years ago

hiragram commented 4 years ago

Hello.

I propose a new design of Mintfile, and want to hear opinions from other developers.

Overview

Currently supported Mintfile looks like:

yonaskolb/mint
yonaskolb/mint@1.0.0
https://github.com/yonaskolb/mint
git@github.com:yonaskolb/Mint.git

And new Mintfile that I propose looks like:

github yonaskolb/mint
github yonaskolb/mint version:1.0.0
git https://github.com/yonaskolb/mint
git git@github.com:yonaskolb/Mint.git

Pros/Cons

Pros

Cons

Conclusion

I don't believe that my idea is the best way. If you have better one, please tell me and let's discuss.

Refs

background: https://github.com/yonaskolb/Mint/pull/150#issuecomment-600802465

yonaskolb commented 4 years ago

Would be good to see a proposal for how this carries over into the command line arguments as well

hiragram commented 4 years ago

@yonaskolb Do you mean something like $ mint install xcodegen version:1.0.0 ?

vknabel commented 4 years ago

I generally agree that it will be much easier to maintain the new Mintfile approach. I just wanted to throw in some ideas.

Ruby

The current approach by @hiragram looks like Ruby actual Ruby-Code. Which makes sense as both, CocoaPods and Carthage, rely on Ruby for their syntax.

Pros: No parsing, consistent Cons: whole new ecosystem (ruby dependency, bundler, ...) to depend on

Swift

As alternative approach to using Ruby, we could use actual Swift code: e.g. Mintfile.swift.

Pros: Uses the main language for the task Cons: More complex to execute, flickery without IDE support

Edit: we could also use PackageConfig#custom-configuration-types for this task. Though its docs are a bit confusing.

PackageConfig

We could use PackageConfig to store our CLI-dependencies into a Package.swift file.

#if canImport(PackageConfig)
    import PackageConfig

    let config = PackageConfiguration([
        "mint": [
            // the actual format might differ
            "target": [
                "github": "yonaskolb/mint",
                "version": "1.0.0"
            ]
        ],
    ]).write()
#endif

Pros: No parsing, can be combined with other approaches (Dictionaries are JSON encodable), consistent with Rocket and Komondor Cons: External dependency, wouldn't make sense with custom-parsing Mintfile-format

YAML

We could just use YAML as format for the Mintfile:

target:
  git: https://github.com/yonaskolb/mint
  version: 1.0.0

Pros: works great with PackageConfig (using YAMLDecoder and some JSONDecoder) Cons: yikes, three dependencies?

hiragram commented 4 years ago

Hi @vknabel , thank you. Yes, my concept is strongly inspired by Carthage. YAML seems nice, and @yonaskolb has much experience Swift+YAML in XcodeGen project.

Now I think that adding support for YAML-style definition is better than modifying structure of existing Mintfile. If @yonaskolb thinks it's good, I start implementing YAML support.

AF-cgi commented 4 years ago

Hi @yonaskolb, do you plan any solution to update the Mintfile automatically including versioning? From my point Podfile and Package has good approaches to do this. Also other dependency managers has this option.

toshi0383 commented 4 years ago

I'm big thumb-up for the YAML support. 🙆‍♂️ Maybe better to have a new issue for YAML support, as we don't intend to "re-design Mintfile" any more, right?

hiragram commented 4 years ago

Actually, YAML support implementation is almost completed. I'm going to send a PR in several days.

Tulleb commented 1 year ago

Why is this ticket still open? It's been more than 2 years now and latest message was talking about an ongoing PR?

hakkurishian commented 8 months ago

one year later, would really love to be able to depend on branches ! Anything that can be done to help this move forward?

yonaskolb commented 7 months ago

I'd be happy with a YAML Mintfile. @hiragram do you have WIP you'd like to share?

would really love to be able to depend on branches !

@hakkurishian you can currently depend on branches using the same syntax org/package@my_branch.