Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add npm source #296

Merged
merged 3 commits into from
Aug 6, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion conda_forge_tick/update_upstream_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ def get_version(self, url):
return r.json()["info"]["version"].strip()


class NPM:
name = "npm"

def get_url(self, meta_yaml):
if "registry.npmjs.org" in meta_yaml["url"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be not in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack! good catch!

return None
# might be namespaced
pkg = meta_yaml["url"].split("/")[3:-2]
return "https://registry.npmjs.org/{}".format("/".join(pkg))

def get_version(self, url):
r = requests.get(url)
latest = r.json()["dist-tags"].get("latest", "").strip()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please check r.ok before trying to get the json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

# If it is a pre-release don't give back the pre-release version
if len(latest) and parse_version(latest).is_prerelease:
return False

return latest


class CRAN(LibrariesIO):
name = "cran"
url_contains = "cran.r-project.org/src/contrib/Archive"
Expand Down Expand Up @@ -204,7 +224,7 @@ def get_latest_version(meta_yaml, sources):
return False


def update_upstream_versions(gx, sources=(PyPI(), CRAN(), RawURL(), Github())):
def update_upstream_versions(gx, sources=(PyPI(), NPM(), CRAN(), RawURL(), Github())):
futures = {}
with ProcessPoolExecutor(max_workers=20) as pool:
for node, attrs in gx.node.items():
Expand Down