Skip to content
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

Update to support ember-qunit@5 #652

Merged
merged 16 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 11 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
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ jobs:
- ember-default-with-jquery
- ember-default-with-mocha
- ember-classic
- embroider
- embroider-with-mocha
- embroider-safe
- embroider-safe-with-mocha
- embroider-optimized
- embroider-optimized-with-mocha
- ember-lts-3.24
- ember-lts-3.20
- ember-lts-3.16
- ember-lts-3.12
Expand Down
94 changes: 44 additions & 50 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');
const mergeWith = require('lodash.mergewith');

function mochaScenario(scenario = {}) {
return mergeWith({}, scenario, {
devDependencies: {
'chai-dom': '*',
'ember-cli-chai': '*',
'ember-mocha': '*',
'ember-qunit': null
}
});
}

const command = [
'ember',
Expand Down Expand Up @@ -34,6 +47,22 @@ module.exports = async function() {
}
}
},
{
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': '~3.20.0'
}
}
},
{
name: 'ember-lts-3.24',
npm: {
devDependencies: {
'ember-source': '~3.24.0'
}
}
},
{
name: 'ember-release',
npm: {
Expand Down Expand Up @@ -71,14 +100,9 @@ module.exports = async function() {
}
}
},
{
name: 'ember-default-with-mocha',
npm: {
devDependencies: {
'ember-mocha': '*'
}
}
},
mochaScenario({
name: 'ember-default-with-mocha'
}),
{
name: 'ember-classic',
env: {
Expand All @@ -94,48 +118,18 @@ module.exports = async function() {
}
}
},
{
name: 'embroider',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
},
},
},
{
name: 'embroider-with-mocha',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
'ember-mocha': '*',
},
},
},
{
name: 'embroider-optimized',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
},
}
},
{
name: 'embroider-optimized-with-mocha',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
'ember-mocha': '*',
},
}
}
embroiderSafe(),
embroiderSafe(
mochaScenario({
name: 'embroider-safe-with-mocha'
})
),
embroiderOptimized(),
embroiderOptimized(
mochaScenario({
name: 'embroider-optimized-with-mocha'
})
)
]
};
};
36 changes: 11 additions & 25 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,20 @@
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
const self = defaults.project.findAddonByName('ember-exam');
const autoImport = self.options.autoImport;
let app = new EmberAddon(defaults, {
// Add options here
autoImport
});

/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/

// Use embroider if it's present (it can get added by ember-try)
if ('@embroider/core' in app.dependencies()) {
/* eslint-disable node/no-missing-require, node/no-extraneous-require */
const { Webpack } = require('@embroider/webpack');
const { compatBuild } = require('@embroider/compat');
/* eslint-enable node/no-missing-require, node/no-extraneous-require */
let config = {};
if (process.env.EMBER_TRY_SCENARIO === 'embroider-optimized') {
config = {
staticAddonTrees: true,
staticAddonTestSupportTrees: true,
staticHelpers: true,
staticComponents: true,
const { maybeEmbroider } = require('@embroider/test-setup');
return maybeEmbroider(app, {
packagerOptions: {
webpackConfig: {
externals: {
mocha: 'mocha'
}
}
}
return compatBuild(app, Webpack, config);
} else {
return app.toTree();
}
});
};
31 changes: 31 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,41 @@

'use strict';

const VersionChecker = require('ember-cli-version-checker');

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

includedCommands() {
return require('./lib/commands');
},

init() {
this._super.init.apply(this, arguments);
let versionChecker = new VersionChecker(this.project);

const hasMagicallyProvidedQUnit = versionChecker
.for('ember-qunit')
.lt('5.0.0-beta.1');

let options = {
exclude: ['ember-mocha', 'mocha']
};

// Ember-qunit < 5 provides an AMD shim for qunit but newer versions 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 condidionally 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 = this.options || {};
options.exclude.push('qunit');
this.options.autoImport = options;
} else {
this.options.autoImport = options;
}
}
};
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@
]
},
"dependencies": {
"@embroider/macros": "^0.29.0",
"@embroider/macros": "^0.36.0",
"chalk": "^4.1.0",
"cli-table3": "^0.6.0",
"debug": "^4.2.0",
"ember-auto-import": "^1.10.1",
"ember-cli-babel": "^7.21.0",
"ember-cli-version-checker": "^5.1.2",
"execa": "^4.0.3",
"fs-extra": "^9.0.1",
"js-yaml": "^3.14.0",
Expand All @@ -53,6 +55,8 @@
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.2.0",
"@embroider/test-setup": "^0.36.0",
"babel-eslint": "^10.1.0",
"codeclimate-test-reporter": "^0.5.0",
"ember-cli": "^3.21.2",
Expand All @@ -70,7 +74,7 @@
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.1",
"ember-qunit": "^4.6.0",
"ember-qunit": "^5.1.2",
thoov marked this conversation as resolved.
Show resolved Hide resolved
"ember-resolver": "^8.0.2",
"ember-source": "~3.21.3",
"ember-source-channel-url": "^1.1.0",
Expand All @@ -82,19 +86,23 @@
"fixturify": "^1.2.0",
"istanbul": "^0.4.3",
"loader.js": "^4.7.0",
"lodash.mergewith": "^4.6.2",
"mocha": "^8.1.0",
"mocha-eslint": "^6.0.0",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"qunit": "^2.14.0",
"release-it": "^14.0.2",
"release-it-lerna-changelog": "^2.4.0",
"rsvp": "^4.8.5",
"sinon": "^9.1.0",
"testdouble": "^3.16.1"
},
"peerDependencies": {
"@ember/test-helpers": "*",
thoov marked this conversation as resolved.
Show resolved Hide resolved
"ember-mocha": "*",
"ember-qunit": "*"
"ember-qunit": "*",
"qunit": "*"
thoov marked this conversation as resolved.
Show resolved Hide resolved
},
"peerDependenciesMeta": {
"ember-mocha": {
Expand Down
7 changes: 0 additions & 7 deletions tests/dummy/config/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ const browsers = [
'last 1 Safari versions'
];

const isCI = !!process.env.CI;
const isProduction = process.env.EMBER_ENV === 'production';

if (isCI || isProduction) {
browsers.push('ie 11');
}

module.exports = {
browsers
};
Loading