-
Notifications
You must be signed in to change notification settings - Fork 52
/
index.js
85 lines (73 loc) · 2.64 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
'use strict';
const path = require('path');
const fs = require('fs');
const VersionChecker = require('ember-cli-version-checker');
const validatePeerDependencies = require('validate-peer-dependencies');
const {
setupMiddlewareHooks,
} = require('@scalvert/ember-setup-middleware-reporter');
const CliOptionsFilter = require('./cli-options-filter');
// The different types/area for which we have content for.
const ALLOWED_CONTENT_FOR = ['test-head-footer'];
module.exports = {
name: require('./package').name,
init() {
this._super.init.apply(this, arguments);
let versionChecker = new VersionChecker(this.project);
validatePeerDependencies(__dirname, {
resolvePeerDependenciesFrom: this.parent.root,
});
const hasMagicallyProvidedQUnit = versionChecker
.for('ember-qunit')
.lt('5.0.0-beta.1');
this.options = this.options || {};
this.options.autoImport = {
webpack: {
module: {
noParse: /\baxe\.js$/,
},
},
};
// Ember-qunit < 5 provides an AMD shim for qunit but newer version now use
// ember-auto-import to include qunit. This means that qunit is no
// longer available for addons (if the parent app is using ember-qunit > 5) to
// directly import under embroider unless they are using ember-auto-import
// themselves. This conditionally falls back to not using ember-auto-import
// when the parent app is providing qunit because without this we would double
// include qunit resulting in a runtime error (qunit detects if it as
// already be added to the window object and errors if so).
if (hasMagicallyProvidedQUnit) {
this.options.autoImport.exclude = ['qunit'];
}
},
/**
* Adds content for the areas specified in the array above. It appends the
* contents of the files with the same name to the content-for block.
* @override
*/
contentFor: function (type) {
if (
process.env.EMBER_ENV !== 'production' &&
~ALLOWED_CONTENT_FOR.indexOf(type)
) {
return fs.readFileSync(
path.join(__dirname, 'content-for', type + '.html'),
);
}
},
/**
* Allow the option to enable a11y audit and middelware reporter using environmental
* variables. If set, environmental variable values are exposed to the browser
* environment via `test-support/cli-options`.
* @override
*/
treeForAddonTestSupport(tree) {
const processedTree = new CliOptionsFilter(tree);
return this._super.treeForAddonTestSupport.call(this, processedTree);
},
...setupMiddlewareHooks({
name: 'ember-a11y-testing',
urlPath: 'report-violations',
reportDir: 'ember-a11y-report',
}),
};