diff --git a/tasks/stats.js b/tasks/stats.js index 8310b515533..31cc04d46e1 100644 --- a/tasks/stats.js +++ b/tasks/stats.js @@ -6,7 +6,11 @@ var prettySize = require('prettysize'); var common = require('./util/common'); var constants = require('./util/constants'); -var pkg = require('../package.json'); +var pkgVersion = require('../package.json').version; +var majorVersion = pkgVersion.split('.')[0]; +var theLatest = 'latest' + ( + (majorVersion === '1') ? '' : ('-v' + majorVersion) +); var pathDistREADME = path.join(constants.pathToDist, 'README.md'); var cdnRoot = 'https://cdn.plot.ly/plotly-'; @@ -74,7 +78,7 @@ function getInfoContent() { 'Plotly.js defaults to US English (en-US) and includes British English (en) in the standard bundle.', 'Many other localizations are available - here is an example using Swiss-German (de-CH),', 'see the contents of this directory for the full list.', - 'They are also available on our CDN as ' + cdnRoot + 'locale-de-ch-latest.js OR ' + cdnRoot + 'locale-de-ch-' + pkg.version + '.js', + 'They are also available on our CDN as ' + cdnRoot + 'locale-de-ch-' + theLatest + '.js OR ' + cdnRoot + 'locale-de-ch-' + pkgVersion + '.js', 'Note that the file names are all lowercase, even though the region is uppercase when you apply a locale.', '', '*After* the plotly.js script tag, add:', @@ -109,12 +113,12 @@ function getMainBundleInfo() { '', 'It be can imported as minified javascript', '- using dist file `dist/plotly.min.js`', - '- using CDN URL ' + cdnRoot + 'latest' + MINJS + ' OR ' + cdnRoot + pkg.version + MINJS, + '- using CDN URL ' + cdnRoot + theLatest + MINJS + ' OR ' + cdnRoot + pkgVersion + MINJS, '', 'or as raw javascript:', '- using the `plotly.js-dist` npm package (starting in `v1.39.0`)', '- using dist file `dist/plotly.js`', - '- using CDN URL ' + cdnRoot + 'latest' + JS + ' OR ' + cdnRoot + pkg.version + JS, + '- using CDN URL ' + cdnRoot + theLatest + JS + ' OR ' + cdnRoot + pkgVersion + JS, '- using CommonJS with `require(\'plotly.js\')`', '', 'If you would like to have access to the attribute meta information ' + @@ -185,10 +189,10 @@ function makeBundleInfo(pathObj) { '', '| Flavor | URL |', '| ------ | --- |', - '| Latest | ' + cdnRoot + name + '-latest' + JS + ' |', - '| Latest minified | ' + cdnRoot + name + '-latest' + MINJS + ' |', - '| Tagged | ' + cdnRoot + name + '-' + pkg.version + JS + ' |', - '| Tagged minified | ' + cdnRoot + name + '-' + pkg.version + MINJS + ' |', + '| Latest | ' + cdnRoot + name + '-' + theLatest + JS + ' |', + '| Latest minified | ' + cdnRoot + name + '-' + theLatest + MINJS + ' |', + '| Tagged | ' + cdnRoot + name + '-' + pkgVersion + JS + ' |', + '| Tagged minified | ' + cdnRoot + name + '-' + pkgVersion + MINJS + ' |', '', '#### npm package (starting in `v1.39.0`)', '',