mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
`discourse-common` was created in the past to share logic between the 'wizard' app and the main 'discourse' app. Since then, the wizard has been consolidated into the main app, so the separation of `discourse-common` is no longer useful. This commit moves `discourse-common/(lib|utils)/*` into `discourse/lib/*`, adds shims for the imports, and updates existing uses in core.
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import { registerDeprecationHandler } from "@ember/debug";
|
|
import QUnit from "qunit";
|
|
import DEPRECATION_WORKFLOW from "discourse/deprecation-workflow";
|
|
import { registerDeprecationHandler as registerDiscourseDeprecationHandler } from "discourse/lib/deprecated";
|
|
|
|
let disabled = false;
|
|
|
|
export function configureRaiseOnDeprecation() {
|
|
if (window.EmberENV.RAISE_ON_DEPRECATION !== undefined) {
|
|
return;
|
|
}
|
|
|
|
registerDeprecationHandler((message, options, next) => {
|
|
if (
|
|
disabled ||
|
|
DEPRECATION_WORKFLOW.find((w) => w.matchId === options.id)
|
|
) {
|
|
return next(message, options);
|
|
}
|
|
raiseDeprecationError(message, options);
|
|
});
|
|
|
|
registerDiscourseDeprecationHandler((message, options) => {
|
|
if (
|
|
disabled ||
|
|
DEPRECATION_WORKFLOW.find((w) => w.matchId === options?.id)
|
|
) {
|
|
return;
|
|
}
|
|
raiseDeprecationError(message, options);
|
|
});
|
|
}
|
|
|
|
function raiseDeprecationError(message, options) {
|
|
message = `DEPRECATION IN CORE TEST: ${message} (deprecation id: ${options.id})\n\nCore test runs must be deprecation-free. Use ember-deprecation-workflow to silence unresolved deprecations.`;
|
|
if (QUnit.config.current) {
|
|
QUnit.assert.pushResult({
|
|
result: false,
|
|
message,
|
|
});
|
|
}
|
|
throw new Error(message);
|
|
}
|
|
|
|
export function disableRaiseOnDeprecation() {
|
|
disabled = true;
|
|
}
|
|
|
|
export function enableRaiseOnDeprecation() {
|
|
disabled = false;
|
|
}
|