Skip to content

A platform for community discussion. Free, open, simple.

DEV: Update ember-cli-deprecation-workflow from 2.2.0 to 3.0.1 (#28226)

Jarek Radosz064332ef6e61
diff --git a/app/assets/javascripts/discourse-common/addon/deprecation-workflow.js b/app/assets/javascripts/discourse-common/addon/deprecation-workflow.js
new file mode 100644
index 00000000000..4f861398103
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/deprecation-workflow.js
@@ -0,0 +1,14 @@
+const DEPRECATION_WORKFLOW = [
+ {
+ handler: "silence",
+ matchId: "ember-this-fallback.this-property-fallback",
+ },
+ { handler: "silence", matchId: "discourse.select-kit" },
+ { handler: "silence", matchId: "discourse.d-section" },
+ {
+ handler: "silence",
+ matchId: "discourse.decorate-widget.hamburger-widget-links",
+ },
+];
+
+export default DEPRECATION_WORKFLOW;
diff --git a/app/assets/javascripts/discourse-common/addon/lib/deprecated.js b/app/assets/javascripts/discourse-common/addon/lib/deprecated.js
index cb0e670c88e..e1c9a77bf04 100644
--- a/app/assets/javascripts/discourse-common/addon/lib/deprecated.js
+++ b/app/assets/javascripts/discourse-common/addon/lib/deprecated.js
@@ -1,7 +1,7 @@
+import DEPRECATION_WORKFLOW from "../deprecation-workflow";
+
const handlers = [];
const disabledDeprecations = new Set();
-const deprecationWorkflow = window.deprecationWorkflow;
-const workflows = deprecationWorkflow?.config?.workflow;
let emberDeprecationSilencer;
@@ -47,12 +47,12 @@ export default function deprecated(msg, options = {}) {
handlers.forEach((h) => h(msg, options));
- const matchedWorkflow = workflows?.find((w) => w.matchId === id);
+ const matchedWorkflow = DEPRECATION_WORKFLOW.find((w) => w.matchId === id);
if (
raiseError ||
matchedWorkflow?.handler === "throw" ||
- (!matchedWorkflow && deprecationWorkflow?.throwOnUnhandled)
+ (!matchedWorkflow && globalThis.EmberENV?.RAISE_ON_DEPRECATION)
) {
throw msg;
}
diff --git a/app/assets/javascripts/discourse/app/app.js b/app/assets/javascripts/discourse/app/app.js
index 0507c214bae..99c48d58956 100644
--- a/app/assets/javascripts/discourse/app/app.js
+++ b/app/assets/javascripts/discourse/app/app.js
@@ -1,4 +1,5 @@
/* eslint-disable simple-import-sort/imports */
+import "./deprecation-workflow";
import "decorator-transforms/globals";
import "./loader-shims";
import "./global-compat";
diff --git a/app/assets/javascripts/discourse/app/deprecation-workflow.js b/app/assets/javascripts/discourse/app/deprecation-workflow.js
new file mode 100644
index 00000000000..eab7e863616
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/deprecation-workflow.js
@@ -0,0 +1,6 @@
+import setupDeprecationWorkflow from "ember-cli-deprecation-workflow";
+import DEPRECATION_WORKFLOW from "discourse-common/deprecation-workflow";
+
+// We're using RAISE_ON_DEPRECATION in environment.js instead of
+// `throwOnUnhandled` here since it is easier to toggle.
+setupDeprecationWorkflow({ workflow: DEPRECATION_WORKFLOW });
diff --git a/app/assets/javascripts/discourse/app/initializers/deprecation-error-mode.js b/app/assets/javascripts/discourse/app/initializers/deprecation-error-mode.js
index 1d98752debe..250c3993a43 100644
--- a/app/assets/javascripts/discourse/app/initializers/deprecation-error-mode.js
+++ b/app/assets/javascripts/discourse/app/initializers/deprecation-error-mode.js
@@ -2,7 +2,7 @@ export default {
initialize() {
const params = new URLSearchParams(window.location.search);
if (params.get("safe_mode")?.split(",").includes("deprecation_errors")) {
- window.deprecationWorkflow.throwOnUnhandled = true;
+ window.EmberENV.RAISE_ON_DEPRECATION = true;
return;
}
},
diff --git a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
index 503d57de6a7..e6817452976 100644
--- a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
+++ b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
@@ -3,6 +3,7 @@ import Service, { service } from "@ember/service";
import { addGlobalNotice } from "discourse/components/global-notice";
import identifySource from "discourse/lib/source-identifier";
import { escapeExpression } from "discourse/lib/utilities";
+import DEPRECATION_WORKFLOW from "discourse-common/deprecation-workflow";
import { registerDeprecationHandler as registerDiscourseDeprecationHandler } from "discourse-common/lib/deprecated";
import { bind } from "discourse-common/utils/decorators";
import I18n from "discourse-i18n";
@@ -49,12 +50,11 @@ export default class DeprecationWarningHandler extends Service {
@bind
handle(message, opts) {
- const workflowConfigs = window.deprecationWorkflow?.config?.workflow;
- const matchingConfig = workflowConfigs.find(
+ const matchingConfig = DEPRECATION_WORKFLOW.find(
(config) => config.matchId === opts.id
);
- if (matchingConfig && matchingConfig.handler === "silence") {
+ if (matchingConfig?.handler === "silence") {
return;
}
diff --git a/app/assets/javascripts/discourse/config/deprecation-workflow.js b/app/assets/javascripts/discourse/config/deprecation-workflow.js
deleted file mode 100644
index 4a9c7f34710..00000000000
--- a/app/assets/javascripts/discourse/config/deprecation-workflow.js
+++ /dev/null
@@ -1,17 +0,0 @@
-globalThis.deprecationWorkflow = globalThis.deprecationWorkflow || {};
-globalThis.deprecationWorkflow.config = {
- // We're using RAISE_ON_DEPRECATION in environment.js instead of
- // `throwOnUnhandled` here since it is easier to toggle.
- workflow: [
- {
- handler: "silence",
- matchId: "ember-this-fallback.this-property-fallback",
- },
- { handler: "silence", matchId: "discourse.select-kit" },
- { handler: "silence", matchId: "discourse.d-section" },
- {
- handler: "silence",
- matchId: "discourse.decorate-widget.hamburger-widget-links",
- },
- ],
-};
diff --git a/app/assets/javascripts/discourse/package.json b/app/assets/javascripts/discourse/package.json
index 2ba6851a79b..44a09d44056 100644
--- a/app/assets/javascripts/discourse/package.json
+++ b/app/assets/javascripts/discourse/package.json
@@ -88,7 +88,7 @@
"ember-cli": "~5.10.0",
"ember-cli-app-version": "^7.0.0",
"ember-cli-babel": "^8.2.0",
- "ember-cli-deprecation-workflow": "^2.2.0",
+ "ember-cli-deprecation-workflow": "^3.0.1",
"ember-cli-htmlbars": "^6.3.0",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-progress-ci": "1.0.0",
diff --git a/app/assets/javascripts/discourse/tests/helpers/deprecation-counter.js b/app/assets/javascripts/discourse/tests/helpers/deprecation-counter.js
index 649beae9b32..6565a9072e7 100644
--- a/app/assets/javascripts/discourse/tests/helpers/deprecation-counter.js
+++ b/app/assets/javascripts/discourse/tests/helpers/deprecation-counter.js
@@ -1,4 +1,5 @@
import { registerDeprecationHandler } from "@ember/debug";
+import DEPRECATION_WORKFLOW from "discourse-common/deprecation-workflow";
import { registerDeprecationHandler as registerDiscourseDeprecationHandler } from "discourse-common/lib/deprecated";
import { bind } from "discourse-common/utils/decorators";
@@ -79,8 +80,7 @@ function reportToTestem(id) {
}
export function setupDeprecationCounter(qunit) {
- const config = window.deprecationWorkflow?.config?.workflow || {};
- const deprecationCounter = new DeprecationCounter(config);
+ const deprecationCounter = new DeprecationCounter(DEPRECATION_WORKFLOW);
qunit.begin(() => deprecationCounter.start());
diff --git a/app/assets/javascripts/discourse/tests/helpers/raise-on-deprecation.js b/app/assets/javascripts/discourse/tests/helpers/raise-on-deprecation.js
index 00bf1918578..07e5b485b60 100644
--- a/app/assets/javascripts/discourse/tests/helpers/raise-on-deprecation.js
+++ b/app/assets/javascripts/discourse/tests/helpers/raise-on-deprecation.js
@@ -1,28 +1,30 @@
import { registerDeprecationHandler } from "@ember/debug";
import QUnit from "qunit";
+import DEPRECATION_WORKFLOW from "discourse-common/deprecation-workflow";
import { registerDeprecationHandler as registerDiscourseDeprecationHandler } from "discourse-common/lib/deprecated";
let disabled = false;
export function configureRaiseOnDeprecation() {
- const workflows = window.deprecationWorkflow?.config?.workflow;
- if (!workflows) {
- return;
- }
-
if (window.EmberENV.RAISE_ON_DEPRECATION !== undefined) {
return;
}
registerDeprecationHandler((message, options, next) => {
- if (disabled || workflows.find((w) => w.matchId === options.id)) {
+ if (
+ disabled ||
+ DEPRECATION_WORKFLOW.find((w) => w.matchId === options.id)
+ ) {
return next(message, options);
}
raiseDeprecationError(message, options);
});
registerDiscourseDeprecationHandler((message, options) => {
- if (disabled || workflows.find((w) => w.matchId === options?.id)) {
+ if (
+ disabled ||
+ DEPRECATION_WORKFLOW.find((w) => w.matchId === options?.id)
+ ) {
return;
}
raiseDeprecationError(message, options);
diff --git a/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.js b/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.js
index eee21f17aca..708c1813ce1 100644
--- a/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.js
+++ b/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.js
@@ -29,7 +29,8 @@ define("discourse/lib/deprecate-shim", ["exports"], function (exports) {
require("@ember/debug").registerDeprecationHandler(
function shimLogDeprecationToConsole(message, options) {
- var updatedMessage = formatMessage(message, options);
+ const updatedMessage = formatMessage(message, options);
+ // eslint-disable-next-line no-console
console.warn(`DEPRECATION: ${updatedMessage}`);
}
);
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index da00e5888c7..b9925d29ff5 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -86,6 +86,7 @@ module PrettyText
)
%w[
+ discourse-common/addon/deprecation-workflow
discourse-common/addon/lib/get-url
discourse-common/addon/lib/object
discourse-common/addon/lib/deprecated
diff --git a/yarn.lock b/yarn.lock
index 34e36a5bade..c71be9a36a7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -154,7 +154,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.25.2.tgz#e41928bd33475305c586f6acbbb7e3ade7a6f7f5"
integrity sha512-bYcppcpKBvX4znYaPEeFau03bp89ShqNMLs+rmdptMw+heSZh9+z84d2YG+K7cYLbWwzdjtDoW/uqZmPjulClQ==
-"@babel/core@^7.12.0", "@babel/core@^7.14.5", "@babel/core@^7.16.10", "@babel/core@^7.16.7", "@babel/core@^7.18.6", "@babel/core@^7.20.12", "@babel/core@^7.23.6", "@babel/core@^7.24.6", "@babel/core@^7.25.2", "@babel/core@^7.3.4":
+"@babel/core@^7.12.0", "@babel/core@^7.14.5", "@babel/core@^7.16.10", "@babel/core@^7.16.7", "@babel/core@^7.18.6", "@babel/core@^7.20.12", "@babel/core@^7.23.2", "@babel/core@^7.23.6", "@babel/core@^7.24.6", "@babel/core@^7.25.2", "@babel/core@^7.3.4":
version "7.25.2"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.25.2.tgz#ed8eec275118d7613e77a352894cd12ded8eba77"
integrity sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==
@@ -3923,7 +3923,7 @@ broccoli-funnel@^2.0.0, broccoli-funnel@^2.0.2:
symlink-or-copy "^1.0.0"
walk-sync "^0.3.1"
-broccoli-funnel@^3.0.3, broccoli-funnel@^3.0.7, broccoli-funnel@^3.0.8:
+broccoli-funnel@^3.0.7, broccoli-funnel@^3.0.8:
version "3.0.8"
resolved "https://registry.yarnpkg.com/broccoli-funnel/-/broccoli-funnel-3.0.8.tgz#f5b62e2763c3918026a15a3c833edc889971279b"
integrity sha512-ng4eIhPYiXqMw6SyGoxPHR3YAwEd2lr9FgBI1CyTbspl4txZovOsmzFkMkGAlu88xyvYXJqHiM2crfLa65T1BQ==
@@ -4088,7 +4088,7 @@ broccoli-plugin@^2.1.0:
rimraf "^2.3.4"
symlink-or-copy "^1.1.8"
-broccoli-plugin@^4.0.0, broccoli-plugin@^4.0.2, broccoli-plugin@^4.0.3, broccoli-plugin@^4.0.5, broccoli-plugin@^4.0.7:
+broccoli-plugin@^4.0.0, broccoli-plugin@^4.0.2, broccoli-plugin@^4.0.3, broccoli-plugin@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/broccoli-plugin/-/broccoli-plugin-4.0.7.tgz#dd176a85efe915ed557d913744b181abe05047db"
integrity sha512-a4zUsWtA1uns1K7p9rExYVYG99rdKeGRymW0qOCNkvDPHQxVi3yVyJHhQbM3EZwdt2E0mnhr5e0c/bPpJ7p3Wg==
@@ -5400,15 +5400,14 @@ ember-cli-babel@^8.2.0:
resolve-package-path "^4.0.3"
semver "^7.3.8"
-ember-cli-deprecation-workflow@^2.2.0:
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/ember-cli-deprecation-workflow/-/ember-cli-deprecation-workflow-2.2.0.tgz#277d56bdafc15dbdb7a58dee598402cdf50e0d08"
- integrity sha512-23bXZqZJBJSKBTfT0LK7qzSJX861TgafL6RVdMfn/iubpLnoZIWergYwEdgs24CNTUbuehVbHy2Q71o8jYfwfw==
+ember-cli-deprecation-workflow@^3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/ember-cli-deprecation-workflow/-/ember-cli-deprecation-workflow-3.0.1.tgz#2891ed87df1a0f076f0b6db813e2b8e0e8fc0e80"
+ integrity sha512-d5wM5IHu+HjIK2TucQWOTFD9725Dx+xBZ3oBc0ZLaB8mdTV3wrAOrQ1vyzcuZEe/uvFBhr5TIy5QP+UNJ2q8Hg==
dependencies:
+ "@babel/core" "^7.23.2"
"@ember/string" "^3.0.0"
- broccoli-funnel "^3.0.3"
- broccoli-merge-trees "^4.2.0"
- broccoli-plugin "^4.0.5"
+ ember-cli-babel "^8.2.0"
ember-cli-get-component-path-option@^1.0.0:
version "1.0.0"