Skip to content

Commit aa249ae

Browse files
committed
chore(release): calculate the cdnVersion on every build
The CDN version of angular is now calculated on every build, by looking at the tags in angular/angular.js, sorting them by semver and checking against ajax.googleapis.com which one is available.
1 parent d6d7fe4 commit aa249ae

File tree

5 files changed

+27
-34
lines changed

5 files changed

+27
-34
lines changed

Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function(grunt) {
1010
grunt.loadTasks('lib/grunt');
1111

1212
var NG_VERSION = versionInfo.currentVersion;
13-
NG_VERSION.cdn = versionInfo.currentPackage.cdnVersion;
13+
NG_VERSION.cdn = versionInfo.cdnVersion;
1414
var dist = 'angular-'+ NG_VERSION.full;
1515

1616
//global beforeEach

docs/docs.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var basePackage = require('./config');
66

77
module.exports = function(config) {
88

9-
var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + versionInfo.currentPackage.cdnVersion;
9+
var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + versionInfo.cdnVersion;
1010

1111
var getVersion = function(component, sourceFolder, packageFile) {
1212
sourceFolder = sourceFolder || '../bower_components';

lib/versions/version-info.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var shell = require('shelljs');
44
var semver = require('semver');
55
var _ = require('lodash');
66

7-
var currentPackage, previousVersions;
7+
var currentPackage, previousVersions, cdnVersion;
88

99

1010
/**
@@ -131,6 +131,29 @@ var getPreviousVersions = function() {
131131
}
132132
};
133133

134+
var getCdnVersion = function() {
135+
return _(previousVersions)
136+
.filter(function(tag) {
137+
return semver.satisfies(tag, currentPackage.branchVersion);
138+
})
139+
.reverse()
140+
.reduce(function(cdnVersion, version) {
141+
if (!cdnVersion) {
142+
// Note: need to use shell.exec and curl here
143+
// as version-infos returns its result synchronously...
144+
var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/'+version+'/angular.min.js '+
145+
'--head --write-out "%{http_code}" -o /dev/null -silent',
146+
{silent: true});
147+
if ( cdnResult.code === 0 ) {
148+
var statusCode = cdnResult.output.trim();
149+
if (statusCode === '200') {
150+
cdnVersion = version;
151+
}
152+
}
153+
}
154+
return cdnVersion;
155+
}, null);
156+
}
134157

135158
/**
136159
* Get the unstable snapshot version
@@ -179,4 +202,5 @@ var getSnapshotVersion = function() {
179202
exports.currentPackage = currentPackage = getPackage();
180203
exports.gitRepoInfo = gitRepoInfo = getGitRepoInfo();
181204
exports.previousVersions = previousVersions = getPreviousVersions();
205+
exports.cdnVersion = cdnVersion = getCdnVersion();
182206
exports.currentVersion = getTaggedVersion() || getSnapshotVersion();

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "angularjs",
33
"branchVersion": "1.3.*",
4-
"cdnVersion": "1.3.0-beta.3",
54
"repository": {
65
"type": "git",
76
"url": "https://github.com/angular/angular.js.git"

scripts/angular.js/publish-cdn-version.sh

-30
This file was deleted.

0 commit comments

Comments
 (0)