Add set-version task to set version from package.json
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openlayers",
|
"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",
|
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"map",
|
"map",
|
||||||
@@ -16,8 +16,10 @@
|
|||||||
"serve-examples": "mkdir -p build/examples && webpack --config examples/webpack/config.js --mode development --watch & serve build/examples",
|
"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-examples": "webpack --config examples/webpack/config.js --mode production",
|
||||||
"build-index": "node tasks/generate-index",
|
"build-index": "node tasks/generate-index",
|
||||||
"prebuild": "npm run build-index",
|
"set-version": "node tasks/set-version",
|
||||||
"build": "rollup --config config/rollup.js",
|
"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",
|
"presrc-closure": "npm run prebuild",
|
||||||
"src-closure": "node tasks/transform-types",
|
"src-closure": "node tasks/transform-types",
|
||||||
"pretypecheck": "npm run src-closure",
|
"pretypecheck": "npm run src-closure",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {VERSION, inherits} from './index.js';
|
|||||||
*/
|
*/
|
||||||
const AssertionError = function(code) {
|
const AssertionError = function(code) {
|
||||||
|
|
||||||
const path = VERSION ? VERSION.split('-')[0] : 'latest';
|
const path = VERSION.split('-')[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export {HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE, WEBGL_EXTENSIONS};
|
|||||||
* OpenLayers version.
|
* OpenLayers version.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
export const VERSION = 'v4.6.4';
|
export const VERSION = '5.0.0-beta.14';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
23
tasks/set-version.js
Normal file
23
tasks/set-version.js
Normal file
@@ -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');
|
||||||
Reference in New Issue
Block a user