Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

latestMajorVersionForPackage fails if url has the form ~/Documents/somepath/Package #135

Open
jazzbox opened this issue Oct 7, 2017 · 9 comments

Comments

@jazzbox
Copy link

jazzbox commented Oct 7, 2017

Marathon currently does not support local packages with a tilde in the path:

import HTMLParser // marathon:~/Documents/somepath/HTMLParser

I am not quite sure where the patch should land, in Marathon itself:

class PackageManager {
    private func latestMajorVersionForPackage(at url: URL) throws -> Int {
        ....
        let releases = try perform(Releases.versions(for: url.expandPath).withoutPreReleases(),
                                   orThrow: Error.failedToResolveLatestVersion(url))
        ....
    }
}

or in the Releases package:

class Releases {    
    private static func string(from url: URL) throws -> String {
        ....
        let path = url.absoluteString.replacingOccurrences(of: "file://", with: "").expandPath
        ....
    }
}

I tried both patches, both work for me.

extension String {
    
    fileprivate var _expandPath: String? {
        guard hasPrefix("~/"), let home = ProcessInfo.processInfo.environment["HOME"] else { return nil }
        return self.replacingOccurrences(of: "~/", with: home + "/")
    }
    
    var expandPath: String {
        return _expandPath ?? self
    }
}

extension URL {
    
    var expandPath: URL {
        guard let expanded = absoluteString._expandPath, let url = URL(string: expanded) else { return self }
        return url
    }
}
@ghost
Copy link

ghost commented Aug 19, 2018

Hi @jazzbox this looks great.

I think it might need to be done with the Files API though, which is currently a dependency for marathon.

@lf-araujo
Copy link

@jazzbox , does it actually support local libraries without the tilde? In my tests it does not seem to work and I couldn't find documentation about it.

@jazzbox
Copy link
Author

jazzbox commented Sep 18, 2018

@lf-araujo yes, it works. You have to specify the full path like here

import HTMLParser // marathon:/Users/box/Documents/dev/myprojects/Marathon/HTMLParser

And you should test that your library can be imported in a small demo SwiftPM project. If you have made a mistake (for example you forgot to version tag your library) Marathon gives total misleading and unhelpful error messages.

That and the fact, that marathon is and will be always lagging behind SwiftPM, I think that it is not worth the effort. I am using Marathon for proof-of-concept and prototyping now, but when I'm finished, I'm moving to a SwiftPM project (and version control of course).

@ghost
Copy link

ghost commented Sep 18, 2018

@jazzbox not worth the effort? a little respect goes a long way. Not everyone deserves respect but I think John has earned it don’t you think?

Marathon might not be as reliable as main stream services but it’s free of charge.

you was using marathon in your release/production workflow? I don’t recommend using relatively unpopular and experimental open source ideas like this in production. Just use this for a bit of scripting here or there.

@lf-araujo
Copy link

lf-araujo commented Sep 18, 2018

That and the fact, that marathon is and will be always lagging behind SwiftPM, I think that it is not worth the effort. I am using Marathon for proof-of-concept and prototyping now, but when I'm finished, I'm moving to a SwiftPM project (and version control of course).

I mean, marathon makes small scripts very easy to test and run, that is what I use it for. Perhaps you are using it to a too large of a project, where SPM may perform better.

@rob-nash In Linux the directory address is not working is it perhaps related to the fact that marathon tries to use -C, which is now deprecated?

�[0;3mwarning: '--chdir/-C' option is deprecated; use '--package-path' instead

Thanks.

edit: I had to remove the library before using it through the local path, which means this works perfectly fine on Linux

@jazzbox
Copy link
Author

jazzbox commented Sep 18, 2018

@rob-nash Did we had a conversation? And who are you that you can tell me how I have to structure my work?

And wow "experimental idea", that is really disrespectful. Maybe you should not implying something that you are doing yourself!

@ghost
Copy link

ghost commented Sep 19, 2018

Hi @lf-araujo not entirely sure about linux 🙄 sorry

@jazzbox relax. you have done some good work here. if you want to use marathon in a production environment, then go ahead.

@orta
Copy link
Collaborator

orta commented Sep 19, 2018

@rob-nash - please take note that this repo has a code of conduct, and the sort of message ( which you rightly deleted ) to @jazzbox is definitely not welcome here. Please don't do it again.

@ghost
Copy link

ghost commented Sep 19, 2018

Get off your high horse @orta

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants