Skip to content

feat: Adding server middleware support to store deprecations to disk #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
setupMiddlewareHooks,
} = require('@scalvert/ember-setup-middleware-reporter');

module.exports = {
name: require('./package').name,

Expand Down Expand Up @@ -52,4 +56,10 @@ module.exports = {

return mergeTrees([tree, configTree], { overwrite: true });
},

...setupMiddlewareHooks({
name: 'ember-cli-deprecation-workflow',
urlPath: 'report-deprecations',
reportDir: 'deprecation-reports',
}),
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"test:ember-compatibility": "ember try:each"
},
"dependencies": {
"@scalvert/ember-setup-middleware-reporter": "^0.1.1",
"broccoli-funnel": "^3.0.3",
"broccoli-merge-trees": "^4.2.0",
"broccoli-plugin": "^4.0.5",
Expand Down
21 changes: 21 additions & 0 deletions vendor/ember-cli-deprecation-workflow/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const LOG_LIMIT = 100;
messages: { }
};
self.deprecationWorkflow.logCounts = {};
self.deprecationWorkflow._fullDeprecationLog = [];

function detectWorkflow(config, message, options) {
if (!config || !config.workflow) {
Expand All @@ -32,6 +33,26 @@ const LOG_LIMIT = 100;

let registerDeprecationHandler = require.has('@ember/debug') ? require('@ember/debug').registerDeprecationHandler : Ember.Debug.registerDeprecationHandler;

if (self.deprecationWorkflow.config.disableMiddleware !== true) {
registerDeprecationHandler(function gatherAllDeprecations(message, options, next) {
self.deprecationWorkflow._fullDeprecationLog.push({ message, options });

next(message, option);
});

if (typeof QUnit !== 'undefined') {
QUnit.done(function() {
return fetch('/report-deprecations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(self.deprecationWorkflow._fullDeprecationLog),
});
});
}
}

registerDeprecationHandler(function handleDeprecationWorkflow(message, options, next){
let config = self.deprecationWorkflow.config || {};

Expand Down
36 changes: 35 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,16 @@
dependencies:
"@octokit/openapi-types" "^7.3.2"

"@scalvert/ember-setup-middleware-reporter@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@scalvert/ember-setup-middleware-reporter/-/ember-setup-middleware-reporter-0.1.1.tgz#bdd74c19d99feeef8807dea9c9ee2d272b6c1923"
integrity sha512-C5DHU6YlKaISB5utGQ+jpsMB57ZtY0uZ8UkD29j855BjqG6eJ98lhA2h/BoJbyPw89RKLP1EEXroy9+5JPoyVw==
dependencies:
"@types/fs-extra" "^9.0.12"
body-parser "^1.19.0"
errorhandler "^1.5.1"
fs-extra "^10.0.0"

"@simple-dom/interface@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@simple-dom/interface/-/interface-1.4.0.tgz#e8feea579232017f89b0138e2726facda6fbb71f"
Expand Down Expand Up @@ -1510,6 +1520,13 @@
dependencies:
"@types/node" "*"

"@types/fs-extra@^9.0.12":
version "9.0.12"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.12.tgz#9b8f27973df8a7a3920e8461517ebf8a7d4fdfaf"
integrity sha512-I+bsBr67CurCGnSenZZ7v94gd3tc3+Aj2taxMT4yu4ABLuOgOjeFxX3dokG24ztSRg5tnT00sL8BszO7gSMoIw==
dependencies:
"@types/node" "*"

"@types/glob@*", "@types/glob@^7.1.1":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183"
Expand Down Expand Up @@ -2967,7 +2984,7 @@ bn.js@^5.0.0, bn.js@^5.1.1:
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002"
integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==

[email protected]:
[email protected], body-parser@^1.19.0:
version "1.19.0"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==
Expand Down Expand Up @@ -5574,6 +5591,14 @@ error@^7.0.0:
dependencies:
string-template "~0.2.1"

errorhandler@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/errorhandler/-/errorhandler-1.5.1.tgz#b9ba5d17cf90744cd1e851357a6e75bf806a9a91"
integrity sha512-rcOwbfvP1WTViVoUjcfZicVzjhjTuhSMntHh6mW3IrEiyE6mJyXvsToJUJGlGlw/2xU9P5whlWNGlIDVeCiT4A==
dependencies:
accepts "~1.3.7"
escape-html "~1.0.3"

es-abstract@^1.18.0-next.2, es-abstract@^1.18.2:
version "1.18.3"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.3.tgz#25c4c3380a27aa203c44b2b685bba94da31b63e0"
Expand Down Expand Up @@ -6440,6 +6465,15 @@ fs-extra@^0.24.0:
path-is-absolute "^1.0.0"
rimraf "^2.2.8"

fs-extra@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1"
integrity sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==
dependencies:
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"

fs-extra@^4.0.2, fs-extra@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94"
Expand Down