Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Add support for CommonJS repositories (Feature Request) #20

Open
jnewman opened this issue Jun 20, 2012 · 0 comments
Open

Add support for CommonJS repositories (Feature Request) #20

jnewman opened this issue Jun 20, 2012 · 0 comments
Labels
Milestone

Comments

@jnewman
Copy link
Contributor

jnewman commented Jun 20, 2012

Greetings,

I've started on support for CommonJS modules, but I'm brand new to Gradle, so I'd love some tips.

Basic idea is that any JS repo w/ a package.json should be resolvable with something like:

class GithubCommonJsDependency {
    String userName
    String name
    String repoName

    GithubCommonJsDependency(String packageJsonUrl, String version = "master") {
        // Example: https://github.com/vodori/dojo/blob/master/package.json
        // /vodori is the userName
        // /dojo is the repoName
        userName = packageJsonUrl.split("github.com/")[1].split("/")[0]
        name = repoName = packageJsonUrl.split("github.com/")[1].split("/")[1]
    }

    File getZip() {
        Object tag = getTagByName(version)
        return new File((tag.getAt("zipball_url") as String).toURL().getText())
    }

    Object getTagByName(String name) {
        // SEE: http://developer.github.com/v3/
        // TODO: This could be a whole lot nicer.
        String tagJson = "https://api.github.com/repos/${userName}/$repoName/tags".toURL().getText()
        ArrayList<Object> tags = new JsonSlurper().parseText(tagJson) as ArrayList<Object>

        for (Object tag in tags) {
            if (tag.name == name) {
                return tag
            }
        }

        return null
    }
}

Initial concept comes from VoloJS, which is a great concept, but requires Node and does more than just resolve packages.

Please let me know if you're interested. I'll probably be bothering you with pull requests fairly frequently with related and advice on what you're looking for would be great.

All the best,
Josh

@ghost ghost assigned eriwen Jun 20, 2012
@eriwen eriwen removed their assignment Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants