DEV: Print version info to console on boot (#24444)

Discourse already includes version information in a `<meta` tag on the page. This commit surfaces it to the console on boot for easier access, and also adds the Ember version (which will be particularly useful as we start rolling out the upgrade to Ember 5)
This commit is contained in:
David Taylor 2023-11-20 13:27:29 +00:00 committed by GitHub
parent c803cc7067
commit 9d8abcbdfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import { registerDiscourseImplicitInjections } from "discourse/lib/implicit-inje
import { withPluginApi } from "discourse/lib/plugin-api";
import { isTesting } from "discourse-common/config/environment";
import { buildResolver } from "discourse-common/resolver";
import { VERSION } from "@ember/version";
const _pluginCallbacks = [];
let _unhandledThemeErrors = [];
@ -27,6 +28,8 @@ const Discourse = Application.extend({
// Start up the Discourse application by running all the initializers we've defined.
start() {
printDebugInfo();
document.querySelector("noscript")?.remove();
// Rewire event handling to eliminate event delegation for better compat
@ -211,4 +214,28 @@ function resolveDiscourseInitializer(moduleName, themeId) {
return initializer;
}
let printedDebugInfo = false;
function printDebugInfo() {
if (printedDebugInfo) {
return;
}
let str = " ";
const generator = document.querySelector("meta[name=generator]")?.content;
const parts = generator?.split(" ");
if (parts) {
const discourseVersion = parts[1];
const gitVersion = parts[5]?.substr(0, 10);
str += `Discourse v${discourseVersion} — https://github.com/discourse/discourse/commits/${gitVersion}`;
}
str += `Ember v${VERSION}`;
// eslint-disable-next-line no-console
console.log(str);
printedDebugInfo = true;
}
export default Discourse;