-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from trentmwillis/no-manifest
Properly handle noManifest option
- Loading branch information
Showing
29 changed files
with
253 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
/* jshint node: true */ | ||
'use strict'; | ||
|
||
var Funnel = require('broccoli-funnel'); | ||
|
||
module.exports = { | ||
name: 'ember-asset-loader' | ||
name: 'ember-asset-loader', | ||
|
||
/** | ||
* If the app has specified `noManifest` to be generated, then we don't | ||
* include the shim for the manifest and the service initializer. | ||
* | ||
* @override | ||
*/ | ||
treeForApp: function() { | ||
var tree = this._super.treeForApp.apply(this, arguments); | ||
var app = this.app; | ||
|
||
if (app && app.options && app.options.assetLoader && app.options.assetLoader.noManifest) { | ||
tree = new Funnel(tree, { | ||
exclude: [ | ||
'asset-manifest.js', | ||
'instance-initializers/load-asset-manifest.js' | ||
] | ||
}); | ||
} | ||
|
||
return tree; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/assets/engine.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/assets/engine.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/assets/engine.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/assets/secret.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/assets/vendor.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/assets/vendor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/assets/vendor.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
3 changes: 3 additions & 0 deletions
3
node-tests/fixtures/generator-test/bundles/blog/dependencies.manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
"shared" | ||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/shared/addon.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/shared/addon.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/blog/shared/secret.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
empty on purpose |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/chat/assets/engine.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/chat/assets/engine.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/chat/assets/engine.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/chat/assets/secret.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/chat/assets/vendor.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/chat/assets/vendor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/chat/assets/vendor.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/shared/assets/addon.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/shared/assets/addon.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/shared/assets/vendor.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
1 change: 1 addition & 0 deletions
1
node-tests/fixtures/generator-test/bundles/shared/assets/vendor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* empty on purpose */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>Dummy</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
|
||
<meta name="dummy/config/environment" content="%7B%22modulePrefix%22%3A%22dummy%22%2C%22environment%22%3A%22development%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22ember-asset-loader%22%2C%22version%22%3A%22v0.1.1%22%7D%2C%22exportApplicationGlobal%22%3Atrue%7D" /> | ||
|
||
<link rel="stylesheet" href="/assets/vendor.css"> | ||
<link rel="stylesheet" href="/assets/dummy.css"> | ||
|
||
<meta name="dummy/asset-manifest" content="" /> | ||
</head> | ||
<body> | ||
|
||
|
||
<script src="/assets/vendor.js"></script> | ||
<script src="/assets/dummy.js"></script> | ||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>Dummy</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
|
||
<meta name="dummy/config/environment" content="%7B%22modulePrefix%22%3A%22dummy%22%2C%22environment%22%3A%22development%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22ember-asset-loader%22%2C%22version%22%3A%22v0.1.1%22%7D%2C%22exportApplicationGlobal%22%3Atrue%7D" /> | ||
|
||
<link rel="stylesheet" href="/assets/vendor.css"> | ||
<link rel="stylesheet" href="/assets/dummy.css"> | ||
|
||
<meta name="dummy/asset-manifest" content="" /> | ||
</head> | ||
<body> | ||
|
||
|
||
<script src="/assets/vendor.js"></script> | ||
<script src="/assets/dummy.js"></script> | ||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>Dummy Tests</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
|
||
<meta name="dummy/config/environment" content="%7B%22modulePrefix%22%3A%22dummy%22%2C%22environment%22%3A%22test%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22none%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22LOG_ACTIVE_GENERATION%22%3Afalse%2C%22LOG_VIEW_LOOKUPS%22%3Afalse%2C%22rootElement%22%3A%22%23ember-testing%22%2C%22name%22%3A%22ember-asset-loader%22%2C%22version%22%3A%22v0.1.1%22%7D%2C%22exportApplicationGlobal%22%3Atrue%7D" /> | ||
|
||
|
||
<link rel="stylesheet" href="/assets/vendor.css"> | ||
<link rel="stylesheet" href="/assets/dummy.css"> | ||
<link rel="stylesheet" href="/assets/test-support.css"> | ||
|
||
<meta name="dummy/asset-manifest" content="" /> | ||
|
||
</head> | ||
<body> | ||
|
||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
|
||
<div id="ember-testing-container"> | ||
<div id="ember-testing"></div> | ||
</div> | ||
|
||
|
||
<script src="/testem.js" integrity=""></script> | ||
<script src="/assets/vendor.js"></script> | ||
<script src="/assets/test-support.js"></script> | ||
<script src="/assets/dummy.js"></script> | ||
<script src="/assets/tests.js"></script> | ||
|
||
|
||
<script>Ember.assert('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".', EmberENV.TESTS_FILE_LOADED);</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
var path = require('path'); | ||
var assert = require('assert'); | ||
var walk = require('walk-sync'); | ||
var broccoli = require('broccoli'); | ||
var fs = require('fs-extra'); | ||
|
||
var ManifestGenerator = require('../lib/manifest-generator'); | ||
var metaHandler = require('../lib/meta-handler'); | ||
|
||
describe('manifest-generator', function() { | ||
function createGenerator(options, outputPaths) { | ||
var Addon = ManifestGenerator.extend({ | ||
name: 'test', | ||
root: process.cwd(), | ||
app: { | ||
options: { | ||
assetLoader: options, | ||
outputPaths: outputPaths | ||
} | ||
} | ||
}); | ||
|
||
return new Addon(); | ||
} | ||
|
||
describe('contentFor', function() { | ||
it('returns a meta tag with a placeholder for head-footer', function() { | ||
var generator = createGenerator(); | ||
var result = generator.contentFor('head-footer', { modulePrefix: 'dummy' }); | ||
assert.equal(result, '<meta name="dummy/asset-manifest" content="%GENERATED_ASSET_MANIFEST%" />'); | ||
}); | ||
|
||
it('returns nothing when using the noManifest option', function() { | ||
var generator = createGenerator({ | ||
noManifest: true | ||
}); | ||
var result = generator.contentFor('head-footer', { modulePrefix: 'dummy' }); | ||
assert.equal(result, undefined); | ||
}); | ||
|
||
it('returns nothing when type is not head-footer', function() { | ||
var generator = createGenerator(); | ||
var result = generator.contentFor('head', { modulePrefix: 'dummy' }); | ||
assert.equal(result, undefined); | ||
}); | ||
}); | ||
|
||
describe('postprocessTree', function() { | ||
var fixturePath = path.join(__dirname, 'fixtures'); | ||
var inputTree = path.join(fixturePath, 'insertion-test'); | ||
|
||
it('returns the input tree if not of type all', function() { | ||
var generator = createGenerator(); | ||
var processedTree = generator.postprocessTree('js', inputTree); | ||
|
||
assert.strictEqual(processedTree, inputTree); | ||
}); | ||
|
||
it('returns the input tree when using the noManifest option', function() { | ||
var generator = createGenerator({ | ||
noManifest: true | ||
}); | ||
var processedTree = generator.postprocessTree('all', inputTree); | ||
|
||
assert.strictEqual(processedTree, inputTree); | ||
}); | ||
|
||
function verifyInsertedManifest(indexPath) { | ||
var fixturePath = path.join(__dirname, 'fixtures'); | ||
var inputTree = path.join(fixturePath, 'generator-test'); | ||
|
||
var generator = createGenerator(undefined, { | ||
app: { | ||
html: indexPath | ||
} | ||
}); | ||
var processedTree = generator.postprocessTree('all', inputTree); | ||
|
||
var builder = new broccoli.Builder(processedTree); | ||
return builder.build().then(function(results) { | ||
var output = results.directory; | ||
var outputFiles = walk(output); | ||
var inputFiles = walk(inputTree); | ||
|
||
assert.notEqual(outputFiles.indexOf('asset-manifest.json'), -1, 'the output tree contains an asset manifest'); | ||
assert.equal(inputFiles.indexOf('asset-manifest.json'), -1, 'the input tree does not contain an asset manifest'); | ||
|
||
var manifest = fs.readJsonSync(path.join(output, 'asset-manifest.json')); | ||
var escapedManifest = metaHandler.escaper(manifest); | ||
var indexFile = fs.readFileSync(path.join(output, indexPath)); | ||
|
||
assert.notEqual(indexFile.indexOf(escapedManifest), -1, 'index contains the escaped manifest'); | ||
|
||
builder.cleanup(); | ||
}); | ||
} | ||
|
||
it('generates an asset manifest, merges it into the given tree, and inserts it into index.html', function() { | ||
return verifyInsertedManifest('index.html'); | ||
}); | ||
|
||
it('inserts the asset manifest into a custom index path', function() { | ||
return verifyInsertedManifest('extra.html'); | ||
}); | ||
}); | ||
}) |