diff --git a/docs/_config.yml b/docs/_config.yml
index 9510d6b58..c113e1704 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -6,6 +6,7 @@ url: 'https://sinonjs.org'
github_username: sinonjs
sinon:
current_release: v13.0.0
+ current_major_version: 13
markdown: kramdown
kramdown:
input: GFM
diff --git a/docs/_includes/head.html b/docs/_includes/head.html
index 4fa8c6052..f0815bb88 100644
--- a/docs/_includes/head.html
+++ b/docs/_includes/head.html
@@ -12,7 +12,7 @@
{% comment %}
To make all documentation pages, regardless of version, lead search traffic to the latest version,
- we need to point all the pages under /releases/v*/ to their latest version
+ we need to point all the pages under /releases/v*/ to the latest version
{% endcomment %}
{% assign url_parts = page.url | split: "/" %}
@@ -20,11 +20,11 @@
{% if page.url contains "/releases/v" } %}
{% assign canonical_page_url = "/releases/latest/" | append: url_parts[3] %}
- {% if url_parts[2] != {site.sinon.current_release} %}
-
- {% endif %}
+
{% else %}
{% assign canonical_page_url = page.url | replace:'index.html','' %}
{% endif %}
diff --git a/docs/_includes/header.html b/docs/_includes/header.html
index b6e67f0ec..67430ca00 100644
--- a/docs/_includes/header.html
+++ b/docs/_includes/header.html
@@ -7,7 +7,7 @@
- - Documentation
+ - Documentation
- Releases
- Guides
- How To
diff --git a/docs/index.md b/docs/index.md
index c405e18d6..bdbc21fe8 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -4,6 +4,7 @@
---
{% assign current_release = site.sinon.current_release %}
+{% assign current_major = site.sinon.current_major_version %}
## Get Started
@@ -284,9 +285,9 @@ You've seen the most common tasks people tackle with Sinon.JS, yet we've only sc
Christian Johansen's book [Test-Driven JavaScript Development][tddjs] covers some of the design philosophy and initial sketches for Sinon.JS.
-[fakes]: /releases/{{current_release}}/fakes
-[fakexhr]: /releases/{{current_release}}/fake-xhr-and-server
-[fakeserver]: /releases/{{current_release}}/fake-xhr-and-server#fake-server
-[clock]: /releases/{{current_release}}/fake-timers
-[api-docs]: /releases/{{current_release}}
+[fakes]: /releases/v{{current_major}}/fakes
+[fakexhr]: /releases/v{{current_major}}/fake-xhr-and-server
+[fakeserver]: /releases/v{{current_major}}/fake-xhr-and-server#fake-server
+[clock]: /releases/v{{current_major}}/fake-timers
+[api-docs]: /releases/v{{current_major}}
[tddjs]: http://tddjs.com/
diff --git a/docs/release-source/release.md b/docs/release-source/release.md
index 6fd530eba..703a80d22 100644
--- a/docs/release-source/release.md
+++ b/docs/release-source/release.md
@@ -3,6 +3,7 @@ layout: page
title: API documentation - Sinon.JS
skip_ad: true
release_id: master
+sort_id: master
---
# {{page.title}} - `{{page.release_id}}`
diff --git a/docs/releases.html b/docs/releases.html
index 6e1240e3b..24d7da909 100644
--- a/docs/releases.html
+++ b/docs/releases.html
@@ -18,7 +18,7 @@ Releases
- {% assign sorted_releases = site.releases | sort | reverse %}
+ {% assign sorted_releases = site.releases | sort: "sort_id" | reverse %}
{% for release in sorted_releases %}
{% assign url_parts = release.url | split: "/" %}
@@ -65,3 +65,7 @@ Using NPM based CDNs
would download the latest browser bundle of Sinon 3.
+
+{% comment %}
+vim: ft=liquid
+{%endcomment %}
diff --git a/package-lock.json b/package-lock.json
index c1f727388..63e919b04 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -38,6 +38,7 @@
"proxyquireify": "^3.2.1",
"puppeteer": "^13.1.2",
"rimraf": "^3.0.2",
+ "semver": "^7.3.5",
"shelljs": "^0.8.4"
},
"funding": {
@@ -96,6 +97,15 @@
"url": "https://opencollective.com/babel"
}
},
+ "node_modules/@babel/core/node_modules/semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true,
+ "bin": {
+ "semver": "bin/semver.js"
+ }
+ },
"node_modules/@babel/generator": {
"version": "7.16.8",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.16.8.tgz",
@@ -128,6 +138,15 @@
"@babel/core": "^7.0.0"
}
},
+ "node_modules/@babel/helper-compilation-targets/node_modules/semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true,
+ "bin": {
+ "semver": "bin/semver.js"
+ }
+ },
"node_modules/@babel/helper-environment-visitor": {
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz",
@@ -2556,21 +2575,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/eslint-plugin-compat/node_modules/semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
- "dev": true,
- "dependencies": {
- "lru-cache": "^6.0.0"
- },
- "bin": {
- "semver": "bin/semver.js"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/eslint-plugin-jsdoc": {
"version": "37.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.7.0.tgz",
@@ -2605,21 +2609,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/eslint-plugin-jsdoc/node_modules/semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
- "dev": true,
- "dependencies": {
- "lru-cache": "^6.0.0"
- },
- "bin": {
- "semver": "bin/semver.js"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/eslint-plugin-mocha": {
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-mocha/-/eslint-plugin-mocha-10.0.3.tgz",
@@ -4162,6 +4151,15 @@
"node": ">=8"
}
},
+ "node_modules/istanbul-lib-instrument/node_modules/semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true,
+ "bin": {
+ "semver": "bin/semver.js"
+ }
+ },
"node_modules/istanbul-lib-processinfo": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz",
@@ -4751,6 +4749,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/make-dir/node_modules/semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true,
+ "bin": {
+ "semver": "bin/semver.js"
+ }
+ },
"node_modules/md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
@@ -5536,6 +5543,15 @@
"node": ">=8"
}
},
+ "node_modules/nyc/node_modules/semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true,
+ "bin": {
+ "semver": "bin/semver.js"
+ }
+ },
"node_modules/nyc/node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
@@ -6656,12 +6672,18 @@
}
},
"node_modules/semver": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
- "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "version": "7.3.5",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
+ "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
"dev": true,
+ "dependencies": {
+ "lru-cache": "^6.0.0"
+ },
"bin": {
"semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
}
},
"node_modules/serialize-javascript": {
@@ -8013,6 +8035,14 @@
"json5": "^2.1.2",
"semver": "^6.3.0",
"source-map": "^0.5.0"
+ },
+ "dependencies": {
+ "semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true
+ }
}
},
"@babel/generator": {
@@ -8036,6 +8066,14 @@
"@babel/helper-validator-option": "^7.16.7",
"browserslist": "^4.17.5",
"semver": "^6.3.0"
+ },
+ "dependencies": {
+ "semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true
+ }
}
},
"@babel/helper-environment-visitor": {
@@ -10107,15 +10145,6 @@
"requires": {
"p-limit": "^3.0.2"
}
- },
- "semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
- "dev": true,
- "requires": {
- "lru-cache": "^6.0.0"
- }
}
}
},
@@ -10140,15 +10169,6 @@
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true
- },
- "semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
- "dev": true,
- "requires": {
- "lru-cache": "^6.0.0"
- }
}
}
},
@@ -11187,6 +11207,14 @@
"@istanbuljs/schema": "^0.1.2",
"istanbul-lib-coverage": "^3.2.0",
"semver": "^6.3.0"
+ },
+ "dependencies": {
+ "semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true
+ }
}
},
"istanbul-lib-processinfo": {
@@ -11630,6 +11658,14 @@
"dev": true,
"requires": {
"semver": "^6.0.0"
+ },
+ "dependencies": {
+ "semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true
+ }
}
},
"md5.js": {
@@ -12246,6 +12282,12 @@
"aggregate-error": "^3.0.0"
}
},
+ "semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "dev": true
+ },
"wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
@@ -13120,10 +13162,13 @@
}
},
"semver": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
- "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
- "dev": true
+ "version": "7.3.5",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
+ "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
+ "dev": true,
+ "requires": {
+ "lru-cache": "^6.0.0"
+ }
},
"serialize-javascript": {
"version": "6.0.0",
diff --git a/package.json b/package.json
index e535a983a..815680150 100644
--- a/package.json
+++ b/package.json
@@ -101,6 +101,7 @@
"proxyquireify": "^3.2.1",
"puppeteer": "^13.1.2",
"rimraf": "^3.0.2",
+ "semver": "^7.3.5",
"shelljs": "^0.8.4"
},
"files": [
diff --git a/scripts/copy-documentation-for-new-release.sh b/scripts/copy-documentation-for-new-release.sh
index ca140704c..0327d9915 100755
--- a/scripts/copy-documentation-for-new-release.sh
+++ b/scripts/copy-documentation-for-new-release.sh
@@ -7,7 +7,8 @@ if [[ $# != 1 ]]; then
exit 1
fi
-RELEASE_VERSION="v$1"
+FULL_VERSION="v$1"
+MAJOR_VERSION=v$(node -p "require('semver').major('$1')")
SOURCE_PATH='docs/release-source/'
function copy_source_to(){
@@ -37,18 +38,19 @@ function copy_source_to(){
rm -r "$DIR/examples/node_modules"
rm "$DIR/examples/package-lock.json"
- # replace `release_id: master` with `release_id: $RELEASE_VERSION` in
+ # replace `release_id: master` with `release_id: $FULL_VERSION` in
# $FILE_PATH
- sed -i.bak "s/release_id: master/release_id: $RELEASE_VERSION/g" "$FILE_PATH"
+ sed -i.bak "s/release_id: master/release_id: $FULL_VERSION/g" "$FILE_PATH"
+ sed -i.bak "s/sort_id: master/sort_id: $MAJOR_VERSION/g" "$FILE_PATH"
rm "$FILE_PATH.bak"
git add "$DIR"
git add "$FILE_PATH"
}
-copy_source_to "$RELEASE_VERSION"
+copy_source_to "$MAJOR_VERSION"
rm -r "docs/_releases/latest" \
"docs/_releases/latest.md" 2>/dev/null
copy_source_to "latest"
-git commit -m "Add release documentation for $RELEASE_VERSION"
+git commit -m "Add release documentation for $MAJOR_VERSION"
diff --git a/scripts/set-release-id-in-config-yml.cjs b/scripts/set-release-id-in-config-yml.cjs
index 63e3c82e7..729764489 100644
--- a/scripts/set-release-id-in-config-yml.cjs
+++ b/scripts/set-release-id-in-config-yml.cjs
@@ -1,12 +1,14 @@
"use strict";
-var configYmlPath = "docs/_config.yml";
-var UTF8 = "utf8";
+const configYmlPath = "docs/_config.yml";
+const UTF8 = "utf8";
-var fs = require("fs");
-var yaml = require("js-yaml");
-var releaseId = `v${require("../package.json").version}`;
-var config = yaml.safeLoad(fs.readFileSync(configYmlPath, UTF8));
+const fs = require("fs");
+const yaml = require("js-yaml");
+const semver = require("semver");
+const releaseId = `v${require("../package.json").version}`;
+const config = yaml.safeLoad(fs.readFileSync(configYmlPath, UTF8));
config.sinon.current_release = releaseId; // eslint-disable-line camelcase
+config.sinon.current_major_version = semver.major(releaseId); // eslint-disable-line camelcase
fs.writeFileSync(configYmlPath, yaml.safeDump(config), UTF8);