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

Test assets moved to test-vendor.js and test-vendor.css. #1288

Merged
merged 4 commits into from
Jul 6, 2014
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [BUGFIX] Fix issue with `ember build` failing if the public/ folder was deleted. [#1270](https://github.com/stefanpenner/ember-cli/issues/1270)
* [BREAKING ENHANCEMENT] CoffeeScript support is now brought in by `ember-cli-coffeescript`. To use CoffeeScript with future versions run `npm install --save-dev ember-cli-coffeescript` (and `broccoli-coffee` is no longer needed as a direct dependency). [#1289](https://github.com/stefanpenner/ember-cli/pull/1289)
* [BUGFIX] `Blueprint.prototype.normalizeEntityName`'s return value should update the entity name. [#1283](https://github.com/stefanpenner/ember-cli/issues/1283)
* [BREAKING ENHANCEMENT] Move test only js/css assets into test-vendor.js and test-vendor.css respectively. [#1288](https://github.com/stefanpenner/ember-cli/pull/1288)

### 0.0.39

Expand Down
5 changes: 2 additions & 3 deletions blueprints/app/files/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/<%= name %>.css">
<link rel="stylesheet" href="assets/qunit.css">
<link rel="stylesheet" href="assets/test-vendor.css">
<style>
#ember-testing-container {
position: absolute;
Expand All @@ -37,8 +37,7 @@
window.<%= namespace %>ENV = {{ENV}};
window.EmberENV = window.<%= namespace %>ENV.EmberENV;
</script>
<script src="assets/qunit.js"></script>
<script src="assets/qunit-notifications.js"></script>
<script src="assets/test-vendor.js"></script>
<script src="assets/vendor.js"></script>
<script src="assets/<%= name %>.js"></script>
<script src="testem.js"></script>
Expand Down
94 changes: 50 additions & 44 deletions lib/broccoli/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var compileES6 = require('broccoli-es6-concatenator');
var pickFiles = require('broccoli-static-compiler');
var jshintTrees = require('broccoli-jshint');
var concatFiles = require('broccoli-concat');
var moveFile = require('broccoli-file-mover');
var remove = require('broccoli-file-remover');

var upstreamMergeTrees = require('broccoli-merge-trees');
Expand Down Expand Up @@ -116,6 +115,21 @@ function EmberApp(options) {
'ember/load-initializers': ['default']
}
}
],
'qunit.js' : [
'vendor/qunit/qunit/qunit.js', {
type: 'test '
}
],
'qunit.css': [
'vendor/qunit/qunit/qunit.css', {
type: 'test'
}
],
'qunit-notifications.js': [
'vendor/qunit-notifications/index.js', {
type: 'test'
}
]
}, defaults);

Expand All @@ -131,11 +145,13 @@ function EmberApp(options) {
vendor: unwatchedTree('vendor'),
}, defaults);

this.importWhitelist = {};
this.legacyFilesToAppend = [];
this.vendorStaticStyles = [];
this.otherAssetPaths = [];
this._importTrees = [];
this.importWhitelist = {};
this.legacyFilesToAppend = [];
this.vendorStaticStyles = [];
this.otherAssetPaths = [];
this._importTrees = [];
this.legacyTestFilesToAppend = [];
this.vendorTestStaticStyles = [];

this.trees = this.options.trees;

Expand Down Expand Up @@ -174,13 +190,12 @@ EmberApp.prototype.addonPostprocessTree = function(type, tree) {

EmberApp.prototype.populateLegacyFiles = function () {
var name;

for (name in this.vendorFiles) {
var args = this.vendorFiles[name];

if (args === null) { continue; }

this.import.apply(this, [].concat(this.vendorFiles[name]));
this.import.apply(this, [].concat(args));
}
};

Expand Down Expand Up @@ -412,27 +427,16 @@ EmberApp.prototype.styles = memoize(function() {
});

EmberApp.prototype.testFiles = memoize(function() {
var qunitFiles = pickFiles(this.trees.vendor, {
srcDir: '/qunit/qunit',
files: [
'qunit.css', 'qunit.js'
],
destDir: '/assets/'
});
var vendor = this._processedVendorTree();

var notificationsFile = moveFile(this.trees.vendor, {
srcFile: '/qunit-notifications/index.js',
destFile: '/assets/qunit-notifications.js',
duplicate: false,
description: 'moveFile - notificationsFile'
var testJs = concatFiles(vendor, {
inputFiles: this.legacyTestFilesToAppend,
outputFile: '/assets/test-vendor.js'
});

qunitFiles = mergeTrees([
qunitFiles,
notificationsFile
], {
overwrite: true,
description: 'TreeMerger (qunitFiles)'
var testCss = concatFiles(vendor, {
inputFiles: this.vendorTestStaticStyles,
outputFile: '/assets/test-vendor.css'
});

var testemPath = path.join(__dirname, 'testem');
Expand Down Expand Up @@ -463,7 +467,8 @@ EmberApp.prototype.testFiles = memoize(function() {
});

var sourceTrees = [
qunitFiles,
testJs,
testCss,
testemTree,
iconsTree,
testLoader
Expand Down Expand Up @@ -498,33 +503,26 @@ EmberApp.prototype.import = function(asset, options) {
assetPath = asset;
}

if (assetPath === null) {
if (!assetPath) {
return;
}

if (assetPath.split('/').length < 2) {
console.log(chalk.red('Using `app.import` with a file in the root of `vendor/` causes a significant performance penalty. Please move `'+ assetPath + '` into a subdirectory.'));
}

var isJs = isType(assetPath, 'js');
if (isJs && typeof options === 'object' && typeof options.exports === 'undefined') {
console.log(chalk.red('app.import('+ assetPath +') - Passing modules object is deprecated. Please pass an option object with modules as export key (see http://git.io/H1GsPw for more info).'));

options = {
exports: options
};
}

options = options || {};
options = defaults(options || {}, {
type: 'vendor'
});

if (/[\*\,]/.test(assetPath)) {
throw new Error('You must pass a file path (without glob pattern) to `app.import`. path was: `' + assetPath + '`');
}

var directory = path.dirname(assetPath);
var directory = path.dirname(assetPath);
var subdirectory = directory.replace(/^vendor\//, '');
var extension = path.extname(assetPath);
var basename = path.basename(assetPath);
var extension = path.extname(assetPath);
var basename = path.basename(assetPath);

if (!extension) {
throw new Error('You must pass a file to `app.import`. For directories specify them to the constructor under the `trees` option.');
Expand All @@ -539,12 +537,20 @@ EmberApp.prototype.import = function(asset, options) {
this._importTrees.push(assetTree);
}

if (isJs) {
this.legacyFilesToAppend.push(assetPath);
if (isType(assetPath, 'js')) {
if(options.type === 'vendor') {
this.legacyFilesToAppend.push(assetPath);
} else {
this.legacyTestFilesToAppend.push(assetPath);
}

this.importWhitelist = assign(this.importWhitelist, options.exports || {});
} else if (extension === '.css') {
this.vendorStaticStyles.push(assetPath);
if(options.type === 'vendor') {
this.vendorStaticStyles.push(assetPath);
} else {
this.vendorTestStaticStyles.push(assetPath);
}
} else {
var destDir = options.destDir;
if (destDir === '') {
Expand Down