mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-29 05:15:38 +08:00
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.
This commit is contained in:
@@ -10,7 +10,7 @@ module.exports = function(grunt) {
|
|||||||
grunt.loadTasks('lib/grunt');
|
grunt.loadTasks('lib/grunt');
|
||||||
|
|
||||||
var NG_VERSION = versionInfo.currentVersion;
|
var NG_VERSION = versionInfo.currentVersion;
|
||||||
NG_VERSION.cdn = versionInfo.currentPackage.cdnVersion;
|
NG_VERSION.cdn = versionInfo.cdnVersion;
|
||||||
var dist = 'angular-'+ NG_VERSION.full;
|
var dist = 'angular-'+ NG_VERSION.full;
|
||||||
|
|
||||||
//global beforeEach
|
//global beforeEach
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var basePackage = require('./config');
|
|||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
|
|
||||||
var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + versionInfo.currentPackage.cdnVersion;
|
var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + versionInfo.cdnVersion;
|
||||||
|
|
||||||
var getVersion = function(component, sourceFolder, packageFile) {
|
var getVersion = function(component, sourceFolder, packageFile) {
|
||||||
sourceFolder = sourceFolder || '../bower_components';
|
sourceFolder = sourceFolder || '../bower_components';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ var shell = require('shelljs');
|
|||||||
var semver = require('semver');
|
var semver = require('semver');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
|
||||||
var currentPackage, previousVersions;
|
var currentPackage, previousVersions, cdnVersion;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,6 +131,29 @@ var getPreviousVersions = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var getCdnVersion = function() {
|
||||||
|
return _(previousVersions)
|
||||||
|
.filter(function(tag) {
|
||||||
|
return semver.satisfies(tag, currentPackage.branchVersion);
|
||||||
|
})
|
||||||
|
.reverse()
|
||||||
|
.reduce(function(cdnVersion, version) {
|
||||||
|
if (!cdnVersion) {
|
||||||
|
// Note: need to use shell.exec and curl here
|
||||||
|
// as version-infos returns its result synchronously...
|
||||||
|
var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/'+version+'/angular.min.js '+
|
||||||
|
'--head --write-out "%{http_code}" -o /dev/null -silent',
|
||||||
|
{silent: true});
|
||||||
|
if ( cdnResult.code === 0 ) {
|
||||||
|
var statusCode = cdnResult.output.trim();
|
||||||
|
if (statusCode === '200') {
|
||||||
|
cdnVersion = version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cdnVersion;
|
||||||
|
}, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the unstable snapshot version
|
* Get the unstable snapshot version
|
||||||
@@ -179,4 +202,5 @@ var getSnapshotVersion = function() {
|
|||||||
exports.currentPackage = currentPackage = getPackage();
|
exports.currentPackage = currentPackage = getPackage();
|
||||||
exports.gitRepoInfo = gitRepoInfo = getGitRepoInfo();
|
exports.gitRepoInfo = gitRepoInfo = getGitRepoInfo();
|
||||||
exports.previousVersions = previousVersions = getPreviousVersions();
|
exports.previousVersions = previousVersions = getPreviousVersions();
|
||||||
|
exports.cdnVersion = cdnVersion = getCdnVersion();
|
||||||
exports.currentVersion = getTaggedVersion() || getSnapshotVersion();
|
exports.currentVersion = getTaggedVersion() || getSnapshotVersion();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "angularjs",
|
"name": "angularjs",
|
||||||
"branchVersion": "1.2.*",
|
"branchVersion": "1.2.*",
|
||||||
"cdnVersion": "1.2.15",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/angular/angular.js.git"
|
"url": "https://github.com/angular/angular.js.git"
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Script for updating cdnVersion of angular.js
|
|
||||||
|
|
||||||
echo "###################################"
|
|
||||||
echo "## Update angular.js cdnVersion ###"
|
|
||||||
echo "###################################"
|
|
||||||
|
|
||||||
ARG_DEFS=(
|
|
||||||
"--cdn-version=(.*)"
|
|
||||||
"--action=(prepare|publish)"
|
|
||||||
)
|
|
||||||
|
|
||||||
function init {
|
|
||||||
cd ../..
|
|
||||||
}
|
|
||||||
|
|
||||||
function prepare {
|
|
||||||
replaceJsonProp "package.json" "cdnVersion" "(.*)" "$CDN_VERSION"
|
|
||||||
git add package.json
|
|
||||||
git commit -m "chore(release): update cdn version"
|
|
||||||
}
|
|
||||||
|
|
||||||
function publish {
|
|
||||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
||||||
# push the commits to github
|
|
||||||
git push origin $BRANCH
|
|
||||||
}
|
|
||||||
|
|
||||||
source $(dirname $0)/../utils.inc
|
|
||||||
Reference in New Issue
Block a user