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 #125 from ef4/fastboot-manifest-with-tests
Maintain correctness when rewriting fastboot-capable apps
- Loading branch information
Showing
18 changed files
with
141 additions
and
5 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,4 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- "0.12" | ||
- "iojs" | ||
- "4" | ||
|
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
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
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,42 @@ | ||
/* jshint node: true */ | ||
"use strict"; | ||
|
||
var Filter = require('broccoli-persistent-filter'); | ||
var fs = require('fs'); | ||
|
||
module.exports = class FastbootManifestRewrite extends Filter { | ||
constructor(inputNode, assetMap) { | ||
super(inputNode, { annotation: 'broccoli-asset-rev/fastboot-manifest-rewrite'}); | ||
this.assetMap = assetMap; | ||
this.extensions = ['json']; | ||
} | ||
|
||
getDestFilePath(relativePath) { | ||
if (relativePath === 'package.json') { | ||
return relativePath; | ||
} | ||
} | ||
|
||
processString(contents, relativePath) { | ||
var pkg = JSON.parse(contents); | ||
if (pkg.fastboot && pkg.fastboot.manifest) { | ||
var manifest = pkg.fastboot.manifest; | ||
this._process(manifest, 'appFiles', true); | ||
this._process(manifest, 'vendorFiles', true); | ||
this._process(manifest, 'htmlFile', false); | ||
return JSON.stringify(pkg); | ||
} | ||
return contents; | ||
} | ||
|
||
_process(manifest, key, asArray) { | ||
if (manifest[key]) { | ||
if (asArray) { | ||
var assetMap = this.assetMap; | ||
manifest[key] = manifest[key].map(function(filename){ return assetMap[filename] || filename; }); | ||
} else { | ||
manifest[key] = this.assetMap[manifest[key]] || manifest[key]; | ||
} | ||
} | ||
} | ||
}; |
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
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
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,5 @@ | ||
const translations = { | ||
en: 'translations/en.json' | ||
}; | ||
|
||
console.log('Hello World'); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-us"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>Application</title> | ||
|
||
<link rel="stylesheet" href="/styles.css"> | ||
<link rel="icon" href="/images/icons/favicon.png"> | ||
</head> | ||
<body> | ||
<script type="text/javascript" src="/assets/application.js"></script> | ||
<script type="text/javascript" src=/assets/application.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,9 @@ | ||
{ | ||
"fastboot": { | ||
"manifest": { | ||
"appFiles": ["assets/application.js"], | ||
"htmlFile": "index.html", | ||
"vendorFiles": [] | ||
} | ||
} | ||
} |
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,11 @@ | ||
.sample-img { | ||
width: 50px; | ||
height: 50px; | ||
background-image: url(images/sample.png); | ||
} | ||
|
||
.sample-img2 { | ||
width: 50px; | ||
height: 50px; | ||
background-image: url('images/sample.png'); | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/fixtures/fastboot/output/assets/application-b55acd2e0e4c88b3d29cb7fdbc768eb5.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,5 @@ | ||
const translations = { | ||
en: 'translations/en.json' | ||
}; | ||
|
||
console.log('Hello World'); |
Binary file added
BIN
+937 Bytes
...tures/fastboot/output/images/icons/favicon-9243e67fccd0c5e08a3d2c158af6500d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+937 Bytes
tests/fixtures/fastboot/output/images/sample-1f6b78f1b4667adc7e397f7bf94041ab.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-us"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>Application</title> | ||
|
||
<link rel="stylesheet" href="/styles-0315ae5ce5f11670cbdea72c9bea621a.css"> | ||
<link rel="icon" href="/images/icons/favicon-9243e67fccd0c5e08a3d2c158af6500d.png"> | ||
</head> | ||
<body> | ||
<script type="text/javascript" src="/assets/application-b55acd2e0e4c88b3d29cb7fdbc768eb5.js"></script> | ||
<script type="text/javascript" src=/assets/application-b55acd2e0e4c88b3d29cb7fdbc768eb5.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 @@ | ||
{"fastboot":{"manifest":{"appFiles":["assets/application-b55acd2e0e4c88b3d29cb7fdbc768eb5.js"],"htmlFile":"index.html","vendorFiles":[]}}} |
11 changes: 11 additions & 0 deletions
11
tests/fixtures/fastboot/output/styles-0315ae5ce5f11670cbdea72c9bea621a.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,11 @@ | ||
.sample-img { | ||
width: 50px; | ||
height: 50px; | ||
background-image: url(images/sample-1f6b78f1b4667adc7e397f7bf94041ab.png); | ||
} | ||
|
||
.sample-img2 { | ||
width: 50px; | ||
height: 50px; | ||
background-image: url('images/sample-1f6b78f1b4667adc7e397f7bf94041ab.png'); | ||
} |