Skip to content

Commit 5efaf6f

Browse files
committed
build: phoenix pro build info in about box
1 parent aa62f90 commit 5efaf6f

File tree

7 files changed

+64
-3
lines changed

7 files changed

+64
-3
lines changed

gulpfile.js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,10 +1075,10 @@ function _patchMinifiedCSSInDistIndex() {
10751075

10761076
const createDistTest = series(copyDistToDistTestFolder, copyTestToDistTestFolder, copyIndexToDistTestFolder);
10771077

1078-
exports.build = series(optionalBuild.clonePhoenixProRepo, copyThirdPartyLibs.copyAll, makeLoggerConfig, generateProLoaderFiles, zipDefaultProjectFiles, zipSampleProjectFiles,
1078+
exports.build = series(optionalBuild.clonePhoenixProRepo, optionalBuild.generateProBuildInfo, copyThirdPartyLibs.copyAll, makeLoggerConfig, generateProLoaderFiles, zipDefaultProjectFiles, zipSampleProjectFiles,
10791079
makeBracketsConcatJS, makeBracketsConcatJSWithMinifiedBrowserScripts, _compileLessSrc, _cleanReleaseBuildArtefactsInSrc, // these are here only as sanity check so as to catch release build minify fails not too late
10801080
createSrcCacheManifest, validatePackageVersions);
1081-
exports.buildDebug = series(optionalBuild.clonePhoenixProRepo, copyThirdPartyLibs.copyAllDebug, makeLoggerConfig, generateProLoaderFiles, zipDefaultProjectFiles,
1081+
exports.buildDebug = series(optionalBuild.clonePhoenixProRepo, optionalBuild.generateProBuildInfo, copyThirdPartyLibs.copyAllDebug, makeLoggerConfig, generateProLoaderFiles, zipDefaultProjectFiles,
10821082
makeBracketsConcatJS, makeBracketsConcatJSWithMinifiedBrowserScripts, _compileLessSrc, _cleanReleaseBuildArtefactsInSrc, // these are here only as sanity check so as to catch release build minify fails not too late
10831083
zipSampleProjectFiles, createSrcCacheManifest);
10841084
exports.clean = series(cleanDist);

gulpfile.js/optional-build.js

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,52 @@ function clonePhoenixProRepo() {
185185
});
186186
}
187187

188-
// Export the function
188+
/**
189+
* Generates a JSON file with phoenix-pro build information including the commit ID.
190+
* Only generates if the phoenix-pro folder exists.
191+
* If the phoenix-pro directory is not a git repository, the commit ID will be "unknown".
192+
*/
193+
function generateProBuildInfo() {
194+
return new Promise((resolve) => {
195+
const phoenixProPath = path.resolve(__dirname, '../src/extensionsIntegrated/phoenix-pro');
196+
197+
// Only generate if phoenix-pro folder exists
198+
if (!fs.existsSync(phoenixProPath)) {
199+
console.log('Phoenix Pro folder not found, skipping buildInfo.json generation');
200+
resolve();
201+
return;
202+
}
203+
204+
const gitPath = path.join(phoenixProPath, '.git');
205+
let commitID = "unknown";
206+
207+
if (fs.existsSync(gitPath)) {
208+
try {
209+
commitID = execSync('git rev-parse --short HEAD', {
210+
cwd: phoenixProPath,
211+
encoding: 'utf8'
212+
}).trim();
213+
console.log(`Phoenix Pro commit ID: ${commitID}`);
214+
} catch (error) {
215+
console.warn('Could not get phoenix-pro commit ID:', error.message);
216+
commitID = "unknown";
217+
}
218+
} else {
219+
console.log('Phoenix Pro is not a git repository, using "unknown" for commit ID');
220+
}
221+
222+
const buildInfo = {
223+
phoenixProCommitID: commitID
224+
};
225+
226+
const buildInfoPath = path.join(phoenixProPath, 'proBuildInfo.json');
227+
fs.writeFileSync(buildInfoPath, JSON.stringify(buildInfo, null, 2));
228+
229+
console.log('Generated phoenix-pro/proBuildInfo.json');
230+
resolve();
231+
});
232+
}
233+
234+
// Export the functions
189235
exports.clonePhoenixProRepo = clonePhoenixProRepo;
236+
exports.generateProBuildInfo = generateProBuildInfo;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
proBuildInfo.json

src/extensionsIntegrated/phoenix-pro/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ define(function (require, exports, module) {
1616
throw new Error("KernalModeTrust is not defined. Cannot boot without trust ring");
1717
}
1818

19+
const proBuildInfoJSON = require("text!./proBuildInfo.json");
20+
const proBuildInfo = JSON.parse(proBuildInfoJSON);
21+
Phoenix.pro.commitID = proBuildInfo.phoenixProCommitID;
22+
1923
const HelperCode = require("text!./browser-context/helper.js");
2024
const ToolBoxCode = require("text!./browser-context/tool-box.js");
2125
const InfoBoxCode = require("text!./browser-context/info-box.js");

src/help/HelpCommandHandlers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ define(function (require, exports, module) {
7272
Strings: Strings
7373
};
7474

75+
// If we have phoenix pro optional features built in
76+
if (Phoenix.pro.commitID) {
77+
templateVars.PRO_BUILD_COMMIT = window.Phoenix.pro.commitID;
78+
}
79+
7580
Dialogs.showModalDialogUsingTemplate(Mustache.render(AboutDialogTemplate, templateVars));
7681

7782
// Get containers

src/htmlContent/about-dialog.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ <h1 class="dialog-title">{{Strings.ABOUT}}</h1>
88
<h2>{{APP_NAME_ABOUT_BOX}}</h2>
99
<div class="about-info">
1010
<p class="dialog-message">{{Strings.ABOUT_TEXT_LINE1}} <span id="about-build-number">{{BUILD_INFO}}</span>
11+
{{#PRO_BUILD_COMMIT}}
12+
<br><span class="dialog-message">{{Strings.ABOUT_TEXT_PRO_BUILD}}{{PRO_BUILD_COMMIT}}</span>
13+
{{/PRO_BUILD_COMMIT}}
1114
{{#BUILD_TIMESTAMP}}
1215
<br><span class="dialog-message">{{Strings.ABOUT_TEXT_BUILD_TIMESTAMP}}{{BUILD_TIMESTAMP}}</span>
1316
{{/BUILD_TIMESTAMP}}

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ define({
706706
"CLOSE": "Close",
707707
"ABOUT_TEXT_LINE1": "Release {VERSION_MAJOR}.{VERSION_MINOR} {BUILD_TYPE} {VERSION}",
708708
"ABOUT_TEXT_BUILD_TIMESTAMP": "build timestamp: ",
709+
"ABOUT_TEXT_PRO_BUILD": "Phoenix Pro Build: ",
709710
"ABOUT_RELEASE_CREDITS": "Release Credits:",
710711
"ABOUT_TEXT_LINE3": "Third Party Libraries that we use - <a href='https://github.com/phcode-dev/phoenix/tree/main/src/thirdparty/licences'> Licences and Attributions</a> . ",
711712
"ABOUT_TEXT_LINE4": "Documentation and source at <a href='https://github.com/phcode-dev/phoenix/'>https://github.com/phcode-dev/phoenix/</a>",

0 commit comments

Comments
 (0)