Skip to content

Add issues/11256 behavior to track the version of extension - #67

Merged
offtherailz merged 2 commits into
geosolutions-it:masterfrom
groupe-open-rennes:master
Dec 15, 2025
Merged

offtherailz merged 2 commits into
geosolutions-it:masterfrom
groupe-open-rennes:master

Conversation

@FNI18300

@FNI18300 FNI18300 commented Oct 24, 2025 •

Copy link
Copy Markdown
Contributor

In coherence with the geosolutions-it/MapStore2#11256 issue which provide a way to display version of a deploy plugin in contexte creation, the proposal :

  • add version field in index.json
  • populate this field with the value in version.txt file
  • build the zip with the provided value

Fix geosolutions-it/MapStore2#11256

offtherailz
offtherailz previously approved these changes Dec 11, 2025
@offtherailz
offtherailz enabled auto-merge (squash) December 11, 2025 16:19
auto-merge was automatically disabled December 11, 2025 16:19

Pull request was closed

@offtherailz offtherailz reopened this Dec 11, 2025
Comment thread build/extension/prod-webpack.config.js Outdated
new CopyPlugin([
{ from: path.resolve(__dirname, "..", "..", "assets", "translations"), to: "translations" },
{ from: path.resolve(__dirname, "..", "..", "assets", "index.json"), to: "index.json" }
{ from: tmpIndex, to: 'index.json' },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ from: tmpIndex, to: 'index.json' },
{ from: tmpIndex, to: 'index.json' }

@offtherailz offtherailz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments.
The PR is good anyway, so it is ok for me to approve it, just suggesting this improvemnt

@offtherailz
offtherailz dismissed their stale review December 11, 2025 16:50

wait for comment

Comment thread build/extension/prod-webpack.config.js Outdated
Comment on lines +12 to +27
// read version.txt and produce a temporary updated index.json
const versionFile = path.resolve(__dirname, "..", "..", "version.txt");
const indexSrc = path.resolve(__dirname, "..", "..", "assets", "index.json");
const tmpIndex = path.resolve(__dirname, "..", "..", "assets", "index.json.tmp");

try {
const versionText = fs.readFileSync(versionFile, 'utf8').trim().split('-')[1];
const indexContent = JSON.parse(fs.readFileSync(indexSrc, 'utf8'));
if (Array.isArray(indexContent.plugins)) {
indexContent.plugins = indexContent.plugins.map(p => p && p.name === name ? { ...p, version: versionText } : p);
}
fs.writeFileSync(tmpIndex, JSON.stringify(indexContent, null, 4), 'utf8');
} catch (e) {
// keep behavior silent here; build will fail later if necessary
console.error('Error updating index.json from version.txt:', e);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// read version.txt and produce a temporary updated index.json
const versionFile = path.resolve(__dirname, "..", "..", "version.txt");
const indexSrc = path.resolve(__dirname, "..", "..", "assets", "index.json");
const tmpIndex = path.resolve(__dirname, "..", "..", "assets", "index.json.tmp");
try {
const versionText = fs.readFileSync(versionFile, 'utf8').trim().split('-')[1];
const indexContent = JSON.parse(fs.readFileSync(indexSrc, 'utf8'));
if (Array.isArray(indexContent.plugins)) {
indexContent.plugins = indexContent.plugins.map(p => p && p.name === name ? { ...p, version: versionText } : p);
}
fs.writeFileSync(tmpIndex, JSON.stringify(indexContent, null, 4), 'utf8');
} catch (e) {
// keep behavior silent here; build will fail later if necessary
console.error('Error updating index.json from version.txt:', e);
}
// read version and produce a temporary updated index.json
const { version: versionText } = require('../../package.json');
const indexSrc = path.resolve(__dirname, "..", "..", "assets", "index.json");
const tmpIndex = path.resolve(__dirname, "..", "..", "assets", "index.json.tmp");
try {
const indexContent = JSON.parse(fs.readFileSync(indexSrc, 'utf8'));
if (Array.isArray(indexContent.plugins)) {
indexContent.plugins = indexContent.plugins.map(p => p && p.name === name ? { ...p, version: versionText } : p);
}
fs.writeFileSync(tmpIndex, JSON.stringify(indexContent, null, 4), 'utf8');
} catch (e) {
// keep behavior silent here; build will fail later if necessary
console.error('Error updating index.json from version.txt:', e);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this is a correct behabior.
Just a question about the version.txt file presents at root folder : What is the usage or the aim of this file ?

From my understanding, this file contained the plugin version. This information is redundant with information in package.json version.

May be we could remove the version.txt file ?

@tdipisa
tdipisa requested a review from offtherailz December 15, 2025 15:23
@offtherailz
offtherailz enabled auto-merge (squash) December 15, 2025 16:04
@offtherailz

Copy link
Copy Markdown
Member

Very good 🚀 !!
❤️ Thank you very much for your contribution to MapStore ❤️ @FNI18300

@offtherailz
offtherailz merged commit 1003d34 into geosolutions-it:master Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display version of custom plugins

3 participants