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

badge for required node.js version for npm #237

Closed
dougwilson opened this issue Aug 17, 2014 · 17 comments
Closed

badge for required node.js version for npm #237

dougwilson opened this issue Aug 17, 2014 · 17 comments

Comments

@dougwilson
Copy link
Contributor

hi! i semi-tried to add this, but since i use windows, it was not easy :) i would like to have a badge that would display the engine.node string as a badge. we talked about it a bit here: jshttp/jshttp.github.io#45 this information is available from the npm API, just like the version is. people can specify all kinds of things in there, so i would say echoing out the string should mostly work, but it would be neat if it was smart and had colors based on how many versions you are supporting.

@espadrine
Copy link
Member

That'd be lovely.

I found a way to get to the current node version through http://nodejs.org/dist/latest/SHASUMS.txt.
Color-wise, I'd say yellow if it doesn't support the current node version, and green if it does.

By the way, I like your care for color blindness.

@espadrine
Copy link
Member

So here's what I have:

  • URL: /node/v/gh-badges.svg
  • Color:
    • current node version supported: green
    • nightly node version supported: orange
    • outdated node version supported: yellow

What do you think?

@dougwilson
Copy link
Contributor Author

here is the colors i've been using the most recently:

  • minimum version 0.11, then orange. we could say, minimum version is greater than the latest version
  • minimum version is 0.10, then green. range includes the latest (0.10.31).
  • minimum version is 0.8, then brightgreen. only if the range includes the latest (see previous rule)

i like the outdated version idea so like if the version range does not include latest version (with the exception of if the range's minimum is above the latest (which would be orange)

@espadrine
Copy link
Member

This is a game changer.

A totally new product, fitting in a completely new product range.

We have been restless in our pursuit of detail.

@dougwilson
Copy link
Contributor Author

sweet, now i don't have to manage the badges manually :)

@dougwilson
Copy link
Contributor Author

thank you sooo much, @espadrine

@espadrine
Copy link
Member

And it's live! The website stayed live during the update! I feel like I outperformed an Apple engineer!

I'm harsh.

Anyway, here it is ☺

@dougwilson
Copy link
Contributor Author

Sweet. So @rlidwka pointed out the following badge should be giving orange:
koa

@espadrine
Copy link
Member

Why should it be orange? It specifies a version range which includes the current node version.

@dougwilson
Copy link
Contributor Author

The current node version is 0.10.31. The range there says >= 0.11.13. 0.10.31 falls below the given range in this case and 0.10.31 does not satisfy it.

@dougwilson
Copy link
Contributor Author

So from the code in 2dd89e6 it looks like every single badge is going to be green (technically, whatever color the first badge was that was fetched after that cache expired).

@dougwilson
Copy link
Contributor Author

i haven't actually run any code, but looking at how regularUpdate is written, it seems to me the call is supposed to be the following:

        regularUpdate('http://nodejs.org/dist/latest/SHASUMS.txt',
          (24 * 3600 * 1000),
          function(shasums) {
            var firstLine = shasums.slice(0, shasums.indexOf('\n'));
            var version = firstLine.split('  ')[1].split('-')[1];
            return version;
          }, function(err, version) {
            if (err != null) { sendBadge(format, badgeData); return; }
            if (semver.satisfies(version, versionRange)) {
              badgeData.colorscheme = 'brightgreen';
            } else if (semver.gtr(version, versionRange)) {
              badgeData.colorscheme = 'yellow';
            } else {
              badgeData.colorscheme = 'orange';
            }
            sendBadge(format, badgeData);
        });

@espadrine
Copy link
Member

Hum, that is very odd… I do get orange on localhost.

As for your suggested modification, it is irrelevant. Using constants avoids recomputing the semver information every time.

There is possibly a bug with the regularUpdate function, but it is way too late for me to figure it out.

@dougwilson
Copy link
Contributor Author

Here is one that clearly should be yellow, but is green:

@dougwilson
Copy link
Contributor Author

As for your suggested modification, it is irrelevant

ok? i mean, the function(shasums) { is only the cache for fetching the url http://nodejs.org/dist/latest/SHASUMS.txt as regularUpdate is written. so if the first badge is green, regularUpdate is storing AGE_CURRENT in the http://nodejs.org/dist/latest/SHASUMS.txt cache, though it seems like it's supposed to be storing 0.10.31 (the current version), rather than whatever the first badge's age happened to be.

Using constants avoids recomputing the semver information every time.

does't the top-level cache function call cache the badge?

espadrine added a commit that referenced this issue Sep 11, 2014
Modification authored by @dougwilson

Part of issue #237
@espadrine
Copy link
Member

so if the first badge is green, regularUpdate is storing AGE_CURRENT in the http://nodejs.org/dist/latest/SHASUMS.txt cache

Aaaah how strange that obvious things stop being obvious at 2am. Thanks and a thousand apologies!

@dougwilson
Copy link
Contributor Author

Thanks and a thousand apologies!

No problem. I can't thank you enough for taking the time to implement this in the first place :)

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

No branches or pull requests

2 participants