-
Notifications
You must be signed in to change notification settings - Fork 26
Add issues/11256 behavior to track the version of extension #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add issues/11256 behavior to track the version of extension #67
Conversation
| 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' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| { from: tmpIndex, to: 'index.json' }, | |
| { from: tmpIndex, to: 'index.json' } |
offtherailz
left a comment
There was a problem hiding this comment.
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
| // 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); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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); | |
| } | |
There was a problem hiding this comment.
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 ?
|
Very good 🚀 !! |
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 :
Fix geosolutions-it/MapStore2#11256