Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit cc8486f

Browse files
committed
chore(doc-gen, docs-app): generate "stable snapshot" for distTag=latest
The "stable snapshot" is the current state of the branch that has distTag=latest, i.e. a preview of the next patch version of the stable branch.
1 parent b990fa9 commit cc8486f

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

docs/app/src/versions.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ angular.module('versions', ['currentVersionData', 'allVersionsData'])
1212
/** @this VersionPickerController */
1313
function VersionPickerController($location, $window, CURRENT_NG_VERSION, ALL_NG_VERSIONS) {
1414

15-
var versionStr = CURRENT_NG_VERSION.isSnapshot ? 'snapshot' : CURRENT_NG_VERSION.version;
15+
var versionStr = CURRENT_NG_VERSION.version;
16+
17+
if (CURRENT_NG_VERSION.isSnapshot) {
18+
versionStr = CURRENT_NG_VERSION.distTag === 'latest' ? 'snapshot-stable' : 'snapshot';
19+
}
1620

1721
this.versions = ALL_NG_VERSIONS;
18-
this.selectedVersion = find(ALL_NG_VERSIONS, function(value) { return value.version.version === versionStr; });
22+
this.selectedVersion = find(ALL_NG_VERSIONS, function(value) {
23+
return value.version.version === versionStr;
24+
});
1925

2026
this.jumpToDocsVersion = function(value) {
2127
var currentPagePath = $location.path().replace(/\/$/, '');

docs/config/processors/versions-data.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ module.exports = function generateVersionDocProcessor(gitData) {
5555

5656
if (missesCurrentVersion) versions.push(currentVersion.version);
5757

58+
// Get the stable release with the highest version
59+
var highestStableRelease = versions.reverse().find(semverIsStable);
60+
5861
versions = versions
5962
.filter(function(versionStr) {
6063
return blacklist.indexOf(versionStr) === -1;
@@ -82,7 +85,21 @@ module.exports = function generateVersionDocProcessor(gitData) {
8285
var latest = sortObject(latestMap, reverse(semver.compare))
8386
.map(function(version) { return makeOption(version, 'Latest'); });
8487

85-
return [makeOption({version: 'snapshot'}, 'Latest', 'master')]
88+
// Generate master and stable snapshots
89+
var snapshots = [
90+
makeOption(
91+
{version: 'snapshot'},
92+
'Latest',
93+
'master-snapshot'
94+
),
95+
makeOption(
96+
{version: 'snapshot-stable'},
97+
'Latest',
98+
createSnapshotStableLabel(highestStableRelease)
99+
)
100+
];
101+
102+
return snapshots
86103
.concat(latest)
87104
.concat(versions);
88105
}
@@ -112,6 +129,18 @@ module.exports = function generateVersionDocProcessor(gitData) {
112129
function sortObject(obj, cmp) {
113130
return Object.keys(obj).map(function(key) { return obj[key]; }).sort(cmp);
114131
}
132+
133+
// https://github.com/kaelzhang/node-semver-stable/blob/34dd29842409295d49889d45871bec55a992b7f6/index.js#L25
134+
function semverIsStable(version) {
135+
var semverObj = semver.parse(version);
136+
return semverObj === null ? false : !semverObj.prerelease.length;
137+
}
138+
139+
function createSnapshotStableLabel(version) {
140+
var label = 'v' + version.replace(/.$/, 'x') + '-snapshot';
141+
142+
return label;
143+
}
115144
}
116145
};
117146
};

lib/versions/version-info.js

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ var getSnapshotVersion = function() {
210210
version.format();
211211
version.full = version.version + '+' + version.build;
212212
version.branch = 'master';
213+
version.distTag = currentPackage.distTag;
213214

214215
return version;
215216
};

0 commit comments

Comments
 (0)