diff --git a/package.json b/package.json index 37de270949..696e616fce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openlayers", - "version": "5.0.0-beta.12", + "version": "5.0.0-beta.14", "description": "Build tools and sources for developing OpenLayers based mapping applications", "keywords": [ "map", @@ -16,8 +16,10 @@ "serve-examples": "mkdir -p build/examples && webpack --config examples/webpack/config.js --mode development --watch & serve build/examples", "build-examples": "webpack --config examples/webpack/config.js --mode production", "build-index": "node tasks/generate-index", - "prebuild": "npm run build-index", - "build": "rollup --config config/rollup.js", + "set-version": "node tasks/set-version", + "prebuild": "npm run set-version && npm run build-index", + "prepare": "npm run set-version", + "build": "rollup --config config/rollup.js && cleancss --source-map src/ol/ol.css -o build/ol.css", "presrc-closure": "npm run prebuild", "src-closure": "node tasks/transform-types", "pretypecheck": "npm run src-closure", diff --git a/src/ol/AssertionError.js b/src/ol/AssertionError.js index ba70e8a492..1510800b98 100644 --- a/src/ol/AssertionError.js +++ b/src/ol/AssertionError.js @@ -13,7 +13,7 @@ import {VERSION, inherits} from './index.js'; */ const AssertionError = function(code) { - const path = VERSION ? VERSION.split('-')[0] : 'latest'; + const path = VERSION.split('-')[0]; /** * @type {string} diff --git a/src/ol/index.js b/src/ol/index.js index 0e289d3923..330e73fdf5 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -68,7 +68,7 @@ export {HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE, WEBGL_EXTENSIONS}; * OpenLayers version. * @type {string} */ -export const VERSION = 'v4.6.4'; +export const VERSION = '5.0.0-beta.14'; /** diff --git a/tasks/set-version.js b/tasks/set-version.js new file mode 100644 index 0000000000..004f8bb9ec --- /dev/null +++ b/tasks/set-version.js @@ -0,0 +1,23 @@ +const fs = require('fs'); +const pkg = require('../package.json'); + +const index = require.resolve('../src/ol/index'); +const lines = fs.readFileSync(index, 'utf-8').split('\n'); + +const versionRegEx = /const VERSION = '(.*)';$/; + +for (let i = 0, ii = lines.length; i < ii; ++i) { + const line = lines[i]; + if (versionRegEx.test(line)) { + lines[i] = line.replace(versionRegEx, `const VERSION = '${pkg.version}';`); + break; + } +} + +const packageJson = require.resolve('../src/ol/package.json'); +const packageJsonObj = JSON.parse(fs.readFileSync(packageJson, 'utf-8')); +packageJsonObj.version = pkg.version; +fs.writeFileSync(packageJson, JSON.stringify(packageJsonObj, null, 2), 'utf-8'); + + +fs.writeFileSync(index, lines.join('\n'), 'utf-8');