From c1894d8ec2d403af9d3d2c8bf90cf7a725bf78d5 Mon Sep 17 00:00:00 2001 From: Matteo V Date: Tue, 8 Sep 2020 14:38:18 +0200 Subject: [PATCH] #5972 fix npm install and remove checkcesium (#5835) * #5972 fix npm install and remove checkcesium * remove check cesium add html-to-draftjs --- package.json | 5 +++-- utility/build/checkCesium.js | 28 ---------------------------- utility/build/postInstall.js | 25 ++++++++++++++++++------- 3 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 utility/build/checkCesium.js diff --git a/package.json b/package.json index b278433756..823553bcee 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,8 @@ "geostyler-openlayers-parser": "1.1.4", "geostyler-sld-parser": "2.0.1", "history": "4.6.1", - "html2canvas": "0.5.0-beta4", + "html2canvas": "0.5.0-beta4", + "html-to-draftjs": "1.5.0", "immutable": "4.0.0-rc.12", "intersection-observer": "0.7.0", "intl": "1.2.2", @@ -249,7 +250,7 @@ "cleandoc": "rimraf web/docs && rimraf web/client/mapstore/docs", "doctest": "docma -c build/docma-config.json --dest web/client/mapstore/docs && echo documentation is accessible from the mapstore/docs path when running npm start", "i18n": "node utility/translations/findMissingTranslations.js", - "postinstall": "node utility/build/checkCesium.js && node utility/build/postInstall.js", + "postinstall": "node utility/build/postInstall.js", "clean": "rimraf ./web/client/dist", "compile": "npm run clean && mkdirp ./web/client/dist && node --max_old_space_size=2048 ./node_modules/webpack/bin/webpack.js --progress --colors --config build/prod-webpack.config.js", "analyze": "npm run clean && mkdirp ./web/client/dist && webpack --json --config build/prod-webpack.config.js | webpack-bundle-size-analyzer", diff --git a/utility/build/checkCesium.js b/utility/build/checkCesium.js deleted file mode 100644 index 341271757a..0000000000 --- a/utility/build/checkCesium.js +++ /dev/null @@ -1,28 +0,0 @@ -const fs = require('fs-extra'); -const isInProject = !fs.existsSync('./node_modules/cesium'); -const dirPrefix = isInProject ? '..' : '.'; -const dir = `${dirPrefix}/web/client/libs/Cesium`; - -console.log("Is project: " + isInProject); - -const copyFromNodeModules = () => { - console.log("Copying Cesium from node_modules..."); - fs.ensureDirSync(dir); - fs.copySync(`${dirPrefix}/node_modules/cesium`, dir); -}; - -const exists = fs.pathExistsSync(dir); -if (!exists) { - console.log("Cesium not found"); - copyFromNodeModules(); -} else { - const packageInLibs = fs.readJsonSync(dir + '/package.json', { 'throws': false }); - const packageInNodeModules = fs.readJsonSync(`${dirPrefix}/node_modules/cesium/package.json`, { 'throws': false }); - if (!packageInLibs || packageInNodeModules && packageInLibs.version !== packageInNodeModules.version) { - console.log("Installed: " + (packageInLibs && packageInLibs.version)); - console.log("Required: " + (packageInNodeModules && packageInNodeModules.version)); - console.log("Cesium version is outdated"); - copyFromNodeModules(); - } - console.log("Cesium installed"); -} diff --git a/utility/build/postInstall.js b/utility/build/postInstall.js index 036de65b9a..68760a955b 100644 --- a/utility/build/postInstall.js +++ b/utility/build/postInstall.js @@ -1,8 +1,19 @@ +console.log("********** post install **********"); + const fs = require('fs-extra'); -const isInProject = !fs.existsSync('./node_modules/cesium'); -const dirPrefix = isInProject ? '..' : '.'; -fs.removeSync(`${dirPrefix}/node_modules/leaflet-simple-graticule/node_modules`); -fs.removeSync(`${dirPrefix}/node_modules/react-sortable-items/node_modules/react-dom`); -fs.removeSync(`${dirPrefix}/node_modules/geostyler-openlayers-parser/node_modules/@terrestris`); // explicit dependency in package.json -fs.emptyDirSync(`${dirPrefix}/node_modules/mocha`); -fs.copySync(`${dirPrefix}/node_modules/@geosolutions/mocha`, `${dirPrefix}/node_modules/mocha`); +const isInProject = fs.existsSync('./MapStore2'); +console.log(isInProject ? "* in project" : "* not in project"); + +fs.removeSync(`./node_modules/leaflet-simple-graticule/node_modules`); +fs.removeSync(`./node_modules/react-sortable-items/node_modules/react-dom`); +fs.removeSync(`./node_modules/geostyler-openlayers-parser/node_modules/@terrestris`); // explicit dependency in package.json +/** + * this is run 2 times because one from the package.json of the project and one from mapstore2 library + * when run from the project there is an error when the version from mapstore is executed therefore + * we perform a check before do the copy + * */ +if (fs.existsSync('./node_modules/@geosolutions/mocha')) { + console.log("* executing the copy of mocha"); + fs.emptyDirSync(`./node_modules/mocha`); + fs.copySync(`./node_modules/@geosolutions/mocha`, `./node_modules/mocha`); +}