GithubHelp home page GithubHelp logo

google-cdn's Introduction

google-cdn Build Status Code Climate

Greenkeeper badge

Grunt task for replacing refs to resources on the Google CDN.

This module makes it easy to replace references to your bower resources in your app with links to the libraries on the Google CDN (and some other CDNs).

Getting started

Install: npm install --save google-cdn

Install CDN data module: npm install --save google-cdn-data (see list of more data modules below)

Example

bower.json:

{
  "name": "my-awesome-app",
  "dependencies": {
    "jquery": "~2.0.0"
  }
}
var googlecdn = require('google-cdn');

var bowerConfig = loadJSON('bower.json');
var markup = '<script src="bower_components/jquery/jquery.js"></script>';
googlecdn(markup, bowerConfig, {cdn: require('google-cdn-data')}, function (err, result) {
  if (err) {
    throw err;
  }

  assert.equal(result,
    '<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>');
});

API

googlecdn(content, bowerJson[, options], callback)

Replaces references to libraries supported by the Google CDN in content. The library versions are inferred from the bowerJson.

options is an optional object with these keys:

  • componentsPath: defaults to bower_components, the path you specify in your script tags to the components directory.
  • cdn: defaults to require('google-cdn-data'). CDN you want to use. Object of the following format:
{
  jquery: {
    versions: ['2.0.3', '2.0.2', '2.0.1', '2.0.0'],
    url: function (version) {
      return '//my.own.cdn/libs/jquery/' + version + '/jquery.min.js';
    }
  }
}

Used by

CDN data modules

Debugging

You can turn on debugging by setting the DEBUG environment variable to google-cdn. E.g.

env DEBUG='google-cdn' grunt cdnify

License

BSD

google-cdn's People

Contributors

darsee avatar david-mohr avatar greenkeeper[bot] avatar greenkeeperio-bot avatar lbabb avatar passy avatar peterdavehello avatar ruiaraujo avatar shahata avatar sindresorhus avatar stevemao avatar timabdulla avatar trask avatar urish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-cdn's Issues

Add support for "*" versions in cdn data

Now all component versions are hardcoded in index.js and it quickly becomes outdated. If google-cdn-data could specify versions: "*" (because Google CDN is usually up to date) - you could leave version updates task to Google. And we could always use latest versions of components in Bower from CDN.

An in-range update of proxyquire is breaking the build 🚨

The devDependency proxyquire was updated from 2.1.0 to 2.1.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

proxyquire is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 6 commits.

  • 5b88b07 2.1.1
  • 3905975 Update dependencies (#243)
  • 3ca62af funding: adding github funding spec
  • 12606d1 README.md: Fix typo (#241)
  • 3da0603 Add file path reference to readme (#237)
  • cb725be readme: fix simple-get example

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Multiple cdn data

It would be awesome to be able to specify more than one cnd-data and try to replace components in order. For example if I add: google-cdn-data and cndjs-data it will try to replace references that are hosted in google first, and if they can't be found in google then try cdnjs.

Support for CSS

This would really help me. Just have the task do the exact same thing, but for CSS... If I have time, I'll implement this myself and put a pull request on this issue.

Local fallbacks

Can this be extended to write a H5BP-style local fallback (like the following) in-case a CDN is down?

<script>window.jQuery || document.write('<script src="bower_components/jquery/jquery.js"></script>')</script>

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Ask bower for the `main` property

And get rid of hard-coded or badly guessed file names.

Should use async to spawn multiple bower processes in parallel and use bower info --json package#version. If there is no main attribute it should automatically shame the author on Twitter and fall back to packageName/packageName.js. The latter would suffice for a first version, though.

An in-range update of debug is breaking the build 🚨

Version 3.2.0 of debug was just published.

Branch Build failing 🚨
Dependency debug
Current Version 3.1.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

debug is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes 3.2.0

A long-awaited release to debug is available now: 3.2.0.

Due to the delay in release and the number of changes made (including bumping dependencies in order to mitigate vulnerabilities), it is highly recommended maintainers update to the latest package version and test thoroughly.


Minor Changes

Patches

Credits

Huge thanks to @DanielRuf, @EirikBirkeland, @KyleStay, @Qix-, @abenhamdine, @alexey-pelykh, @DiegoRBaquero, @febbraro, @kwolfy, and @TooTallNate for their help!

Commits

The new version differs by 25 commits.

There are 25 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of grunt is breaking the build 🚨

The devDependency grunt was updated from 1.0.3 to 1.0.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

grunt is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 5 commits.

  • 8fcbed1 v1.0.4 (#1668)
  • 0b13970 Update js-yaml to address https://npmjs.com/advisories/788 (#1667)
  • 7db6cf7 Use SOURCE_DATE_EPOCH to render dates in template. (#1596)
  • a2d6d80 Revert "Indicate in package.json that Node.js 4 or newer is required (#1643)" (#1644)
  • 773b7e7 Indicate in package.json that Node.js 4 or newer is required (#1643)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of bower is breaking the build 🚨

Version 1.8.1 of bower just got published.

Branch Build failing 🚨
Dependency bower
Current Version 1.8.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

bower is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Support .min.js references

References to .min.js files currently aren't supported, i.e. .js works:

 <script src="bower_components/jquery/jquery.js"></script>

… but not:

 <script src="bower_components/jquery/jquery.min.js"></script>

Add support for setting HTTPS

Most of the Google CDNs now have the ability to set the link using HTTPS. When the bower_components are converted, it would be nice to have an option to use HTTPS if supported, or to set it on the CDN as a flag.

Source

<script src="bower_components/angular/angular.js"></script>

becomes:

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>

However, Google supports

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>

Either test the URL to see if https is valid for the script, or add a flag to allow this. I know on my own urls, I could do this by returning the HTTPS, but it would be nice to use the default CDNs so as to not have to keep the versions up to date etc...

Too far out of date

Would be nice if you didn't have to keep updating all the versions. Was wondering if it would be possible to just use a pattern and https://github.com/mikeal/request to see if the version was available.

Simply ping the cdn to see if that version is available, then the only time you need to make updates is when a new library is added (not a new version).

I made changes for angular to get it to 1.2.5, but then I discovered to get that in I have to go the whole route of building the grunt-google-cdn plugin as well as changes here. Seems like there should be a better way.

An in-range update of semver is breaking the build 🚨

Version 5.5.0 of semver was just published.

Branch Build failing 🚨
Dependency semver
Current Version 5.4.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

semver is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 7 commits.

  • 44cbc84 v5.5.0
  • 1d37529 Cleaned up coerce behavior
  • e7092b4 Improved coerce regex and added coerce to README.
  • 68cef2d Added version coercion to the module and CLI.
  • ec6f97a range.bnf: Fix invalid bracket expression
  • 906b664 travis: don't cache node_modules
  • 7184ff4 range.bnf: Remove unnecessary empty entry

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Hoisting removed ?

Came back to JavaScript development after a while. Noticed that change 90a7e6d defeats the purpose of CDNify in some yeoman generated projects. Yeoman's gruntfile uses google-cdn to before usemin to change references to commonly used libraries (such as Angular in my case). After replacements, the entire scripts block is replaced, along with the references changed by google-cdn. As a result all references to libraries is lost.

Can the support for hoisting be retrofitted ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.