This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Cdn check #14769
Closed
Closed
Cdn check #14769
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6ac3563
chore(Gruntfile): kill the build if the CDN version was not found
petebacondarwin c58a04c
chore(app.scenario): test docs app against production libraries
petebacondarwin 7057d26
chore(version-info): add offline-build support
petebacondarwin 18206f0
chore(version-info): add offline-build support
petebacondarwin d2b214f
chore(version-info): add offline-build support
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ var shell = require('shelljs'); | |
var semver = require('semver'); | ||
var _ = require('lodash'); | ||
|
||
var process = require('process'); | ||
// We are only interested in whether this environment variable exists, hence the !! | ||
var NO_REMOTE_REQUESTS = !!process.env['NG1_BUILD_NO_REMOTE_VERSION_REQUESTS']; | ||
|
||
var currentPackage, previousVersions, cdnVersion, gitRepoInfo; | ||
|
||
|
||
|
@@ -96,12 +100,12 @@ var getTaggedVersion = function() { | |
* @return {Array.<SemVer>} The collection of previous versions | ||
*/ | ||
var getPreviousVersions = function() { | ||
// always use the remote tags as the local clone might | ||
// If we are allowing remote requests then use the remote tags as the local clone might | ||
// not contain all commits when cloned with git clone --depth=... | ||
// Needed e.g. for Travis | ||
// Otherwise just use the tags in the local repository | ||
var repo_url = currentPackage.repository.url; | ||
var tagResults = shell.exec('git ls-remote --tags ' + repo_url, | ||
{silent: true}); | ||
var query = NO_REMOTE_REQUESTS ? 'git tag' : 'git ls-remote --tags ' + repo_url; | ||
var tagResults = shell.exec(query, {silent: true}); | ||
if (tagResults.code === 0) { | ||
return _(tagResults.output.match(/v[0-9].*[0-9]$/mg)) | ||
.map(function(tag) { | ||
|
@@ -138,15 +142,20 @@ var getCdnVersion = function() { | |
.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; | ||
if (NO_REMOTE_REQUESTS) { | ||
// We do not want to make any remote calls to the CDN so just use the most recent version | ||
cdnVersion = version; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we return here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, otherwise we are making one request There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK! |
||
} else { | ||
// 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; | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -204,3 +213,13 @@ exports.gitRepoInfo = gitRepoInfo = getGitRepoInfo(); | |
exports.previousVersions = previousVersions = getPreviousVersions(); | ||
exports.cdnVersion = cdnVersion = getCdnVersion(); | ||
exports.currentVersion = getTaggedVersion() || getSnapshotVersion(); | ||
|
||
if (NO_REMOTE_REQUESTS) { | ||
console.log('=============================================================================================='); | ||
console.log('Running with no remote requests for version data:'); | ||
console.log(' - this is due to the "NG1_BUILD_NO_REMOTE_VERSION_REQUESTS" environment variable being defined.'); | ||
console.log(' - be aware that the generated docs may not have valid or the most recent version information.'); | ||
console.log('=============================================================================================='); | ||
} | ||
console.log('CDN version:', cdnVersion.raw); | ||
console.log('Current version:', exports.currentVersion.raw); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, by using
-production
we are not testing against our local build, but only against the CDN version, right?This makes sense, since it is a separate app that just happens to live on the same repo and the app will use a CDN version (not our local build).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so there are other tests in this folder that hit the normal
index.html
.Also all the main e2e tests from the examples are run against local angular.