From 5684e47d2ddded000d6944caf7a0c8f89159616e Mon Sep 17 00:00:00 2001 From: Robert Hurst Date: Tue, 22 Oct 2024 15:30:03 +0200 Subject: [PATCH 1/2] Update version docs --- lib/mapp.mjs | 2 +- version.js | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/lib/mapp.mjs b/lib/mapp.mjs index 97c6b483dd..258f65a3b4 100644 --- a/lib/mapp.mjs +++ b/lib/mapp.mjs @@ -72,7 +72,7 @@ self.mapp = { version: '4.12.0β', - hash: 'd81f870a553c53aa8d06bef154edb5eff6792209', + hash: '44f619643cecb7979180cbf5ed5ce85a5a9ceb4b', host: document.head?.dataset?.dir || '', diff --git a/version.js b/version.js index 8fe9d93324..4f44c6d0b7 100644 --- a/version.js +++ b/version.js @@ -1,12 +1,39 @@ -const fs = require('fs'); -const { execSync } = require('child_process'); +/** + * ## Version script + * This script is used for developers to update the commit SHA in the attribution of the mapp bundle. + * This is used to track deployed applications and what exact version of the xyz framework it is using. + * To run this script you can execute `node version.js` in your terminal. + * @module version + */ +// Import required Node.js modules +const fs = require('fs'); // File system module for reading/writing files +const { execSync } = require('child_process'); // For executing shell commands synchronously +// Regular expression pattern to match 'hash: ' followed by any characters const key = 'hash:.*'; -const hash = execSync('git rev-parse HEAD').toString().trim(); -let data = fs.readFileSync('./lib/mapp.mjs', 'utf-8'); -data = data.replace(new RegExp(key, 'g'), `hash: '${hash}',`); +// Get the current git commit hash +const hash = execSync('git rev-parse HEAD') // Execute git command to get current commit hash + .toString() // Convert Buffer to string + .trim(); // Remove any whitespace -fs.writeFileSync('./lib/mapp.mjs', data); +// Read the contents of mapp.mjs file +let data = fs.readFileSync( + './lib/mapp.mjs', // Path to the file + 'utf-8' // Specify encoding +); -execSync('npm run _build'); \ No newline at end of file +// Replace all occurrences of the old hash with the new commit hash +data = data.replace( + new RegExp(key, 'g'), // Global regex to match all occurrences + `hash: '${hash}',` // Replace with new hash string +); + +// Write the updated content back to the file +fs.writeFileSync( + './lib/mapp.mjs', // Path to the file + data // Updated content +); + +// Run the build script defined in package.json +execSync('npm run _build'); // Execute build command \ No newline at end of file From a33ff6d2da52cce1949876224762f2862a307fca Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Tue, 22 Oct 2024 15:53:29 +0100 Subject: [PATCH 2/2] update DEVELOPING doc --- DEVELOPING.md | 8 +++++++ lib/mapp.mjs | 2 +- version.js | 61 +++++++++++++++++++++++++++++++++------------------ 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/DEVELOPING.md b/DEVELOPING.md index b3d82a6c38..d22fd04ca2 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -36,6 +36,14 @@ ESBuild must also be used to compile the CSS supporting the MAPP and MAPP.UI ele $ npx esbuild --bundle public/css/_ui.css --outfile=public/css/ui.css --loader:.svg=dataurl +## version.js hash + +The mapp module object holds a hash of the latest release commit which can be generated by executing the version.js script in the root. + +The version script will complete by executing the ESBuild process. + + $ node version.js + ## Express [Express.js](https://expressjs.com/) will be installed by npm as a development dependency. You can run a zero config instance by loading the express.js script in your node runtime. diff --git a/lib/mapp.mjs b/lib/mapp.mjs index 258f65a3b4..94b5605cc9 100644 --- a/lib/mapp.mjs +++ b/lib/mapp.mjs @@ -72,7 +72,7 @@ self.mapp = { version: '4.12.0β', - hash: '44f619643cecb7979180cbf5ed5ce85a5a9ceb4b', + hash: '5684e47d2ddded000d6944caf7a0c8f89159616e', host: document.head?.dataset?.dir || '', diff --git a/version.js b/version.js index 4f44c6d0b7..bb1106dd42 100644 --- a/version.js +++ b/version.js @@ -1,39 +1,58 @@ /** - * ## Version script - * This script is used for developers to update the commit SHA in the attribution of the mapp bundle. - * This is used to track deployed applications and what exact version of the xyz framework it is using. - * To run this script you can execute `node version.js` in your terminal. - * @module version - */ -// Import required Node.js modules -const fs = require('fs'); // File system module for reading/writing files +## Version script +This script is used for developers to update the commit SHA in the attribution of the mapp bundle. +This is used to track deployed applications and what exact version of the xyz framework it is using. +To run this script you can execute `node version.js` in your terminal. + +@requires module:fs + +@module version +*/ + +// File system module for reading/writing files +const fs = require('fs'); const { execSync } = require('child_process'); // For executing shell commands synchronously // Regular expression pattern to match 'hash: ' followed by any characters const key = 'hash:.*'; // Get the current git commit hash -const hash = execSync('git rev-parse HEAD') // Execute git command to get current commit hash - .toString() // Convert Buffer to string - .trim(); // Remove any whitespace +// Execute git command to get current commit hash +const hash = execSync('git rev-parse HEAD') + + // Convert Buffer to string + .toString() + + // Remove any whitespace + .trim(); // Read the contents of mapp.mjs file let data = fs.readFileSync( - './lib/mapp.mjs', // Path to the file - 'utf-8' // Specify encoding -); + + // Path to the file + './lib/mapp.mjs', + + // Specify encoding + 'utf-8'); // Replace all occurrences of the old hash with the new commit hash data = data.replace( - new RegExp(key, 'g'), // Global regex to match all occurrences - `hash: '${hash}',` // Replace with new hash string -); + + // Global regex to match all occurrences + new RegExp(key, 'g'), + + // Replace with new hash string + `hash: '${hash}',`); // Write the updated content back to the file fs.writeFileSync( - './lib/mapp.mjs', // Path to the file - data // Updated content -); + + // Path to the file + './lib/mapp.mjs', + + // Updated content + data); // Run the build script defined in package.json -execSync('npm run _build'); // Execute build command \ No newline at end of file +// Execute build command +execSync('npm run _build');