diff --git a/misc/folderDetails.js b/misc/folderDetails.js index 771913f..f3142f2 100644 --- a/misc/folderDetails.js +++ b/misc/folderDetails.js @@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const path = __importStar(require("path")); const chalk_1 = __importDefault(require("chalk")); +const child_process_1 = __importDefault(require("child_process")); const figures = __importStar(require("figures")); const fs = __importStar(require("fs-extra")); const tv4 = __importStar(require("tv4")); @@ -38,7 +39,10 @@ class FolderDetails { throw new Error('No App found to package. Missing an "app.json" file.'); } try { - this.info = JSON.parse(fs.readFileSync(this.infoFile, { encoding: 'utf-8' })); + const commitHash = child_process_1.default.execSync('git rev-parse HEAD', { cwd: this.folder }).toString().trim(); + const appInfo = JSON.parse(fs.readFileSync(this.infoFile, { encoding: 'utf-8' })); + appInfo['commitHash'] = commitHash; + this.info = appInfo; } catch (e) { throw new Error('The "app.json" file is invalid.'); diff --git a/misc/folderDetails.js.map b/misc/folderDetails.js.map index 46dbbd5..cb3d0c6 100644 --- a/misc/folderDetails.js.map +++ b/misc/folderDetails.js.map @@ -1 +1 @@ -{"version":3,"file":"folderDetails.js","sourceRoot":"","sources":["../src/misc/folderDetails.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAI7B,kDAA0B;AAC1B,iDAAmC;AACnC,6CAA+B;AAC/B,yCAA2B;AAE3B,mDAAgD;AAEhD;IAWI,YAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,EAAc,CAAC;IAC/B,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,CAAC,OAAQ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAC7D,CAAC;IACN,CAAC;IAEO,WAAW,CAAC,KAA0B,EAAE,MAAM,GAAG,IAAI;QACzD,OAAO,CAAC,GAAG,CACP,MAAM,EACN,eAAK,CAAC,GAAG,CAAC,GAAI,OAAO,CAAC,YAAa,SAAS,CAAC,EAC7C,KAAK,CAAC,OAAO,IAAI,gDAAgD,CACpE,CAAC;QAEF,OAAO,CAAC,GAAG,CACP,MAAM,EACN,MAAM,EACN,eAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,GAAG,CAAC,EACjC,gBAAgB,EAChB,eAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,GAAG,CAAC,CACtC,CAAC;QAEF,IAAI,KAAK,CAAC,SAAS,EAAE;YACjB,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAI,MAAO,IAAI,CAAC,CAAC,CAAC;SAC5E;IACL,CAAC;IAEO,aAAa,CAAC,GAAW,EAAE,MAAM,GAAG,IAAI;QAC5C,OAAO,CAAC,GAAG,CACP,MAAM,EACN,eAAK,CAAC,GAAG,CAAC,GAAI,OAAO,CAAC,YAAa,WAAW,CAAC,EAC/C,GAAG,CACN,CAAC;IACN,CAAC;CACJ;AA1HD,sCA0HC"} \ No newline at end of file +{"version":3,"file":"folderDetails.js","sourceRoot":"","sources":["../src/misc/folderDetails.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAI7B,kDAA0B;AAC1B,kEAAyC;AACzC,iDAAmC;AACnC,6CAA+B;AAC/B,yCAA2B;AAE3B,mDAAgD;AAEhD;IAWI,YAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,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,IAAI;QAC5C,OAAO,CAAC,GAAG,CACP,MAAM,EACN,eAAK,CAAC,GAAG,CAAC,GAAI,OAAO,CAAC,YAAa,WAAW,CAAC,EAC/C,GAAG,CACN,CAAC;IACN,CAAC;CACJ;AA9HD,sCA8HC"} \ No newline at end of file diff --git a/src/misc/folderDetails.ts b/src/misc/folderDetails.ts index 96ba1a3..faa66bc 100644 --- a/src/misc/folderDetails.ts +++ b/src/misc/folderDetails.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata'; import chalk from 'chalk'; +import childProcess from 'child_process'; import * as figures from 'figures'; import * as fs from 'fs-extra'; import * as tv4 from 'tv4'; @@ -50,7 +51,11 @@ export class FolderDetails { } try { - this.info = JSON.parse(fs.readFileSync(this.infoFile, { encoding: 'utf-8' })); + const commitHash:string = childProcess.execSync('git rev-parse HEAD', { cwd: this.folder }).toString().trim(); + const appInfo = JSON.parse(fs.readFileSync(this.infoFile, { encoding: 'utf-8' })); + + appInfo['commitHash'] = commitHash; + this.info = appInfo; } catch (e) { throw new Error('The "app.json" file is invalid.'); }