Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"async": "^1.4.2",
"coveralls": "^2.11.2",
"create-error-class": "^3.0.2",
"david": "^9.0.0",
"dox": "0.8.1",
"extend": "^3.0.0",
"glob": "^5.0.9",
"globby": "^3.0.1",
"is": "^3.1.0",
"istanbul": "^0.3.5",
"jscs": "^2.1.1",
"jshint": "^2.9.1",
Expand All @@ -18,6 +20,7 @@
"mitm": "^1.1.0",
"mkdirp": "^0.5.1",
"mocha": "^2.5.3",
"package-json": "^2.4.0",
"propprop": "^0.3.1",
"proxyquire": "^1.7.10",
"request": "^2.70.0",
Expand All @@ -28,6 +31,7 @@
},
"scripts": {
"postinstall": "node ./scripts/install.js",
"update-deps": "node ./scripts/update-deps.js",
"docs": "node ./scripts/docs/packages.js",
"bundle": "node ./scripts/docs/bundle.js",
"lint": "jshint scripts/ packages/ system-test/ test/ && jscs packages/ system-test/ test/",
Expand Down
2 changes: 1 addition & 1 deletion packages/compute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"@google-cloud/common": "^0.5.0",
"arrify": "^1.0.0",
"async": "^1.4.2",
"async": "^1.5.2",
"create-error-class": "^2.0.1",
"extend": "^3.0.0",
"gce-images": "^0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/dns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"@google-cloud/common": "^0.5.0",
"arrify": "^1.0.0",
"dns-zonefile": "0.1.18",
"dns-zonefile": "^0.1.18",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"extend": "^3.0.0",
"is": "^3.0.1",
"methmeth": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"@google-cloud/common": "^0.5.0",
"arrify": "^1.0.0",
"async": "^1.4.2",
"async": "^1.5.2",
"concat-stream": "^1.5.0",
"create-error-class": "^2.0.1",
"duplexify": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/vision/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@google-cloud/common": "^0.5.0",
"arguejs": "^0.2.3",
"arrify": "^1.0.0",
"async": "^1.4.2",
"async": "^1.5.2",
"extend": "^3.0.0",
"google-gax": "^0.6.0",
"google-proto-files": "^0.7.0",
Expand Down
115 changes: 115 additions & 0 deletions scripts/update-deps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*!
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var async = require('async');
var david = require('david');

This comment was marked as spam.

This comment was marked as spam.

var glob = require('globby');
var is = require('is');
var packageJson = require('package-json');
var path = require('path');
var prop = require('propprop');
var semver = require('semver');

require('shelljs/global');

var MIN_SUPPORTED_NODE_VERSION =
require('../package.json').engines.node.replace(/^\D*/, '');

function updatePackage(pkg, callback) {
console.log(pkg.depsToUpdate)

if (!is.empty(pkg.depsToUpdate)) {
exec('npm install --save ' + pkg.depsToUpdate.map(prop('name')).join(' '), {
cwd: pkg.cwd
});
}

callback();
}

function shouldUpdateDependency(dependency, callback) {
packageJson(dependency.name, dependency.stable).then(function(json) {
var minCompatibleNodeVersion = json.engines && json.engines.node;

if (!minCompatibleNodeVersion) {
callback(true);
return;
}

var isCompatible = semver.satisfies(
MIN_SUPPORTED_NODE_VERSION,
minCompatibleNodeVersion
);

callback(isCompatible);
});
}

function populateDepsToUpdate(pkg, callback) {
david.getUpdatedDependencies(pkg.json, function(err, updatedDeps) {
if (err) {
callback(err);
return;
}

if (is.empty(updatedDeps)) {
callback();
return;
}

for (var updatedDep in updatedDeps) {
updatedDeps[updatedDep].name = updatedDep;
}

async.filter(updatedDeps, shouldUpdateDependency, function(deps) {
if (err) {
callback(err);
return;
}

pkg.depsToUpdate = deps;

callback();
});
});
}

var pkgs = glob.sync('packages/*/package.json')
.map(function(packageJsonPath) {
return {
cwd: path.dirname(packageJsonPath),
json: require(path.join('..', packageJsonPath)),
depsToUpdate: []
};
});

async.eachLimit(pkgs, 5, populateDepsToUpdate, function(err) {
if (err) {
console.error('Could not update dependencies', err);
return;
}

async.eachLimit(pkgs, 5, updatePackage, function(err) {
if (err) {
console.error('Could not update dependencies', err);
return;
}

console.log('Dependencies updated!');
});
});