Skip to content

Commit

Permalink
Merge pull request #1592 from RobAndrewHurst/version_docs
Browse files Browse the repository at this point in the history
Update version docs
  • Loading branch information
dbauszus-glx authored Oct 22, 2024
2 parents 44f6196 + a33ff6d commit 7519e74
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 deletions.
8 changes: 8 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/mapp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ self.mapp = {

version: '4.12.0β',

hash: 'd81f870a553c53aa8d06bef154edb5eff6792209',
hash: '5684e47d2ddded000d6944caf7a0c8f89159616e',

host: document.head?.dataset?.dir || '',

Expand Down
58 changes: 52 additions & 6 deletions version.js
Original file line number Diff line number Diff line change
@@ -1,12 +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.
@requires module:fs
@module version
*/

// File system module for reading/writing files
const fs = require('fs');
const { execSync } = require('child_process');
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
// 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(

// 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(

// 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(

fs.writeFileSync('./lib/mapp.mjs', data);
// Path to the file
'./lib/mapp.mjs',

// Updated content
data);

execSync('npm run _build');
// Run the build script defined in package.json
// Execute build command
execSync('npm run _build');

0 comments on commit 7519e74

Please sign in to comment.