Skip to content

Commit

Permalink
geosolutions-it#7934 refactor to version plugin, moving it to About p…
Browse files Browse the repository at this point in the history
…lugin (geosolutions-it#8504)

* geosolutions-it#7934 refactor to version plugin, moving it to About plugin
* update migration guideline

# Conflicts:
#	web/client/hooks/useModulePlugins.js
#	web/client/plugins/Version.jsx
#	web/client/product/plugins.js
  • Loading branch information
MV88 committed Aug 26, 2022
1 parent dd617cc commit aa21a1f
Show file tree
Hide file tree
Showing 32 changed files with 395 additions and 397 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ web/docs
.settings/
debug.log
.vscode/settings.json
site
25 changes: 25 additions & 0 deletions build/BuildUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2022, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/


const DefinePlugin = require("webpack/lib/DefinePlugin");
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');

const gitRevPlugin = new GitRevisionPlugin({
branchCommand: 'log -n1 --format=format:"Message: %s%nCommit: %H%nDate: %aD%nAuthor: %an"'
});

const VERSION_INFO_DEFINE_PLUGIN = new DefinePlugin({
__COMMITHASH__: JSON.stringify(gitRevPlugin.commithash()),
__COMMIT_DATA__: JSON.stringify(gitRevPlugin.branch())
});


module.exports = {
VERSION_INFO_DEFINE_PLUGIN
};
5 changes: 5 additions & 0 deletions build/buildConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const castArray = require('lodash/castArray');
const {
VERSION_INFO_DEFINE_PLUGIN
} = require('./BuildUtils');

/**
* Webpack configuration builder.
* Returns a webpack configuration object for the given parameters.
Expand Down Expand Up @@ -157,6 +161,7 @@ module.exports = (...args) => mapArgumentsToObject(args, ({
}
}),
new DefinePlugin({ '__MAPSTORE_PROJECT_CONFIG__': JSON.stringify(projectConfig) }),
VERSION_INFO_DEFINE_PLUGIN,
new DefinePlugin({
// Define relative base path in cesium for loading assets
'CESIUM_BASE_URL': JSON.stringify(cesiumBaseUrl ? cesiumBaseUrl : path.join('dist', 'cesium'))
Expand Down
10 changes: 1 addition & 9 deletions build/prod-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const themeEntries = require('./themes.js').themeEntries;
const extractThemesPlugin = require('./themes.js').extractThemesPlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('./moduleFederation').plugin;
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
const DefinePlugin = require("webpack/lib/DefinePlugin");

const paths = {
base: path.join(__dirname, ".."),
Expand All @@ -14,9 +12,6 @@ const paths = {
code: path.join(__dirname, "..", "web", "client")
};

const gitRevPlugin = new GitRevisionPlugin({
branchCommand: 'log -n1 --format=format:"Message: %s%nCommit: %H%nDate: %aD%nAuthor: %an"'
});
module.exports = require('./buildConfig')({
bundles: {
"mapstore2": path.join(paths.code, "product", "app"),
Expand All @@ -27,10 +22,7 @@ module.exports = require('./buildConfig')({
},
themeEntries,
paths,
plugins: [extractThemesPlugin, ModuleFederationPlugin, new DefinePlugin({
__COMMITHASH__: JSON.stringify(gitRevPlugin.commithash()),
__COMMIT_DATA__: JSON.stringify(gitRevPlugin.branch())
})],
plugins: [extractThemesPlugin, ModuleFederationPlugin],
prod: true,
prodPlugins: [
new HtmlWebpackPlugin({
Expand Down
4 changes: 4 additions & 0 deletions build/testConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const nodePath = require('path');
const webpack = require('webpack');
const ProvidePlugin = require("webpack/lib/ProvidePlugin");
const NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin");
const {
VERSION_INFO_DEFINE_PLUGIN
} = require('./BuildUtils');

module.exports = ({browsers = [ 'ChromeHeadless' ], files, path, testFile, singleRun, basePath = ".", alias = {}}) => ({
browsers,
Expand Down Expand Up @@ -149,6 +152,7 @@ module.exports = ({browsers = [ 'ChromeHeadless' ], files, path, testFile, singl
// Define relative base path in cesium for loading assets
'CESIUM_BASE_URL': JSON.stringify(nodePath.join(basePath, 'node_modules', 'cesium', 'Source'))
}),
VERSION_INFO_DEFINE_PLUGIN,
// it's not possible to load directly from the module name `cesium/Build/Cesium/Widgets/widgets.css`
// see https://github.com/CesiumGS/cesium/issues/9212
new NormalModuleReplacementPlugin(/^cesium\/index\.css$/, nodePath.join(basePath, 'node_modules', 'cesium/Build/Cesium/Widgets/widgets.css'))
Expand Down
10 changes: 1 addition & 9 deletions build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
const path = require("path");
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
const DefinePlugin = require("webpack/lib/DefinePlugin");

const themeEntries = require('./themes.js').themeEntries;
const extractThemesPlugin = require('./themes.js').extractThemesPlugin;
const moduleFederationPlugin = require('./moduleFederation.js').plugin;


const gitRevPlugin = new GitRevisionPlugin({
branchCommand: 'log -n1 --format=format:"Message: %s%nCommit: %H%nDate: %aD%nAuthor: %an"'
});
const config = require('./buildConfig')(
{
bundles: {
Expand All @@ -26,10 +21,7 @@ const config = require('./buildConfig')(
framework: path.join(__dirname, "..", "web", "client"),
code: path.join(__dirname, "..", "web", "client")
},
plugins: [extractThemesPlugin, moduleFederationPlugin, new DefinePlugin({
__COMMITHASH__: JSON.stringify(gitRevPlugin.commithash()),
__COMMIT_DATA__: JSON.stringify(gitRevPlugin.branch())
})],
plugins: [extractThemesPlugin, moduleFederationPlugin],
prod: false
}
);
Expand Down
28 changes: 28 additions & 0 deletions docs/developer-guide/mapstore-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ This is a list of things to check if you want to update from a previous version

## Migration from 2022.01.02 to 2022.02.00

### Version plugin has been removed

We no longer maintain the Version plugin since we have moved its content inside the About plugin (see [here](https://github.com/geosolutions-it/MapStore2/issues/7934#issuecomment-1201433942) for more details)

We suggest you to clean up your project as well:

- remove Version entry it from a local list of plugins.js
- remove Version entries it from a localConfig
- add About entry into other pages of mapstore plugins array, suggest list is:
- dashboard
- geostory
- mobile
- remove Define plugins in webpack-config.js or prod.webpack-config.js, since we have moved these definition to a more general *build/buildConfig.js* file
- check that in your package.json you have this extends rule

```js
"eslintConfig": {
"extends": [
"@mapstore/eslint-config-mapstore"
],
...
```
- edit the version of the *@mapstore/eslint-config-mapstore* to **1.0.5** in your package.json so that the new globals config will be inherited
!!! note
this may fail on gha workflows, in that case we suggest to edit directly your package.json with globals taken from mapstore framework
### Support for OpenID
MapStore introduced support for OpenID for google and keycloak. In order to have this functionalities and to be aligned with the latest version of MapStore you have to update the following files in your projects:
Expand Down
10 changes: 1 addition & 9 deletions project/standard/templates/prod-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ const themeEntries = require('./MapStore2/build/themes.js').themeEntries;
const extractThemesPlugin = require('./MapStore2/build/themes.js').extractThemesPlugin;
const ModuleFederationPlugin = require('./MapStore2/build/moduleFederation').plugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
const DefinePlugin = require("webpack/lib/DefinePlugin");

const paths = {
base: __dirname,
dist: path.join(__dirname, "dist"),
framework: path.join(__dirname, "MapStore2", "web", "client"),
code: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")]
};
const gitRevPlugin = new GitRevisionPlugin({
branchCommand: 'log -n1 --format=format:"Message: %s%nCommit: %H%nDate: %aD%nAuthor: %an"'
});
module.exports = require('./MapStore2/build/buildConfig')({
bundles: {
'__PROJECTNAME__': path.join(__dirname, "js", "app"),
Expand All @@ -26,10 +21,7 @@ module.exports = require('./MapStore2/build/buildConfig')({
},
themeEntries,
paths,
plugins: [extractThemesPlugin, ModuleFederationPlugin, new DefinePlugin({
__COMMITHASH__: JSON.stringify(gitRevPlugin.commithash()),
__COMMIT_DATA__: JSON.stringify(gitRevPlugin.branch())
})],
plugins: [extractThemesPlugin, ModuleFederationPlugin],
prod: true,
publicPath: undefined,
cssPrefix: '.__PROJECTNAME__',
Expand Down
10 changes: 1 addition & 9 deletions project/standard/templates/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
const path = require("path");
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
const DefinePlugin = require("webpack/lib/DefinePlugin");

const themeEntries = require('./MapStore2/build/themes.js').themeEntries;
const extractThemesPlugin = require('./MapStore2/build/themes.js').extractThemesPlugin;
const ModuleFederationPlugin = require('./MapStore2/build/moduleFederation').plugin;

const gitRevPlugin = new GitRevisionPlugin({
branchCommand: 'log -n1 --format=format:"Message: %s%nCommit: %H%nDate: %aD%nAuthor: %an"'
});

module.exports = require('./MapStore2/build/buildConfig')({
bundles: {
Expand All @@ -25,10 +20,7 @@ module.exports = require('./MapStore2/build/buildConfig')({
framework: path.join(__dirname, "MapStore2", "web", "client"),
code: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")]
},
plugins: [extractThemesPlugin, ModuleFederationPlugin, new DefinePlugin({
__COMMITHASH__: JSON.stringify(gitRevPlugin.commithash()),
__COMMIT_DATA__: JSON.stringify(gitRevPlugin.branch())
})],
plugins: [extractThemesPlugin, ModuleFederationPlugin],
prod: false,
publicPath: undefined,
cssPrefix: '.__PROJECTNAME__',
Expand Down
5 changes: 4 additions & 1 deletion utility/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ module.exports = {
"beforeEach": false,
"after": false,
"afterEach": false,
"__DEVTOOLS__": false
"__DEVTOOLS__": false,
"__MAPSTORE_PROJECT_CONFIG__": false,
"__COMMITHASH__": false,
"__COMMIT_DATA__": false
},
"rules": {
/**
Expand Down
2 changes: 1 addition & 1 deletion utility/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapstore/eslint-config-mapstore",
"version": "1.0.3",
"version": "1.0.5",
"private": false,
"description": "ESLint Configuration for MapStore project",
"author": "GeoSolutions S.a.s.",
Expand Down
111 changes: 0 additions & 111 deletions web/client/components/Version/VersionDialog.jsx

This file was deleted.

Loading

0 comments on commit aa21a1f

Please sign in to comment.