Skip to content

Commit 3d1f3f3

Browse files
authored
Merge pull request #325 from kratiahuja/manifest-update
Create an array of app & vendor files for fastboot manifest
2 parents a39f775 + fe18ed7 commit 3d1f3f3

3 files changed

Lines changed: 39 additions & 16 deletions

File tree

lib/broccoli/fastboot-build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function FastBootBuild(options) {
2424
})[0];
2525

2626
if (assetRev && assetRev.options) {
27-
this.assetMapEnabled = !!(assetRev.options.enabled && assetRev.options.assetMapPath);
27+
this.assetMapEnabled = !!(assetRev.options.enabled && assetRev.options.generateAssetMap);
2828

2929
if (assetRev.options.assetMapPath) {
3030
this.assetMapPath = assetRev.options.assetMapPath;

lib/broccoli/fastboot-config.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var md5Hex = require('md5-hex');
55
var path = require('path');
66
var Plugin = require('broccoli-plugin');
77

8-
var LATEST_SCHEMA_VERSION = 1;
8+
var LATEST_SCHEMA_VERSION = 2;
99

1010
function FastBootConfig(inputNode, options) {
1111
Plugin.call(this, [inputNode], {
@@ -14,6 +14,7 @@ function FastBootConfig(inputNode, options) {
1414

1515
this.project = options.project;
1616
this.name = options.name;
17+
this.assetMapEnabled = options.assetMapEnabled;
1718
this.ui = options.ui;
1819
this.fastbootAppConfig = options.fastbootAppConfig;
1920
this.outputPaths = options.outputPaths;
@@ -121,8 +122,8 @@ FastBootConfig.prototype.buildManifest = function() {
121122
var vendorFile = 'fastboot/' + vendorFileName + '.js';
122123

123124
var manifest = {
124-
appFile: appFile,
125-
vendorFile: vendorFile,
125+
appFiles: [appFile],
126+
vendorFiles: [vendorFile],
126127
htmlFile: this.htmlFile
127128
};
128129

@@ -139,10 +140,20 @@ FastBootConfig.prototype.buildManifest = function() {
139140
assets[rewrittenKey] = assetToFastboot(rewrittenAssets.assets[key]);
140141
}
141142

142-
['appFile', 'vendorFile'].forEach(function(file) {
143-
// Update package.json with the fingerprinted file.
144-
manifest[file] = assets[manifest[file]];
143+
// update the vendor file with the fingerprinted file
144+
var rewrittenVendorFiles = [];
145+
manifest['vendorFiles'].forEach(function(file) {
146+
rewrittenVendorFiles.push(assets[file]);
145147
});
148+
manifest['vendorFiles'] = rewrittenVendorFiles;
149+
150+
// update the app files array with fingerprinted files
151+
var rewrittenAppFiles = [];
152+
manifest['appFiles'].forEach(function(file) {
153+
rewrittenAppFiles.push(assets[file]);
154+
});
155+
manifest['appFiles'] = rewrittenAppFiles;
156+
146157
}
147158

148159
this.manifest = manifest;

test/package-json-test.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('generating package.json', function() {
4545
it("contains a schema version", function() {
4646
var pkg = fs.readJsonSync(app.filePath('/dist/package.json'));
4747

48-
expect(pkg.fastboot.schemaVersion).to.deep.equal(1);
48+
expect(pkg.fastboot.schemaVersion).to.deep.equal(2);
4949
});
5050

5151
it("contains a whitelist of allowed module names", function() {
@@ -64,9 +64,9 @@ describe('generating package.json', function() {
6464
var pkg = fs.readJsonSync(app.filePath('/dist/package.json'));
6565

6666
expect(pkg.fastboot.manifest).to.deep.equal({
67-
appFile: 'fastboot/module-whitelist.js',
67+
appFiles: ['fastboot/module-whitelist.js'],
6868
htmlFile: 'index.html',
69-
vendorFile: 'fastboot/vendor.js'
69+
vendorFiles: ['fastboot/vendor.js']
7070
});
7171
});
7272

@@ -114,9 +114,13 @@ describe('generating package.json', function() {
114114

115115
var manifest = pkg.fastboot.manifest;
116116

117-
expect(p(manifest.appFile)).to.be.a.file();
117+
manifest.appFiles.forEach(function(file) {
118+
expect(p(file)).to.be.a.file();
119+
});
118120
expect(p(manifest.htmlFile)).to.be.a.file();
119-
expect(p(manifest.vendorFile)).to.be.a.file();
121+
manifest.vendorFiles.forEach(function(file) {
122+
expect(p(file)).to.be.a.file();
123+
});
120124
});
121125
});
122126

@@ -141,9 +145,13 @@ describe('generating package.json', function() {
141145
var pkg = fs.readJsonSync(customApp.filePath('/dist/package.json'));
142146
var manifest = pkg.fastboot.manifest;
143147

144-
expect(p(manifest.appFile)).to.be.a.file();
148+
manifest.appFiles.forEach(function(file) {
149+
expect(p(file)).to.be.a.file();
150+
});
145151
expect(p(manifest.htmlFile)).to.be.a.file();
146-
expect(p(manifest.vendorFile)).to.be.a.file();
152+
manifest.vendorFiles.forEach(function(file) {
153+
expect(p(file)).to.be.a.file();
154+
});
147155
});
148156

149157
});
@@ -168,9 +176,13 @@ describe('generating package.json', function() {
168176
var pkg = fs.readJsonSync(customApp.filePath('/dist/package.json'));
169177
var manifest = pkg.fastboot.manifest;
170178

171-
expect(p(manifest.appFile)).to.be.a.file();
179+
manifest.appFiles.forEach(function(file) {
180+
expect(p(file)).to.be.a.file();
181+
});
172182
expect(p(manifest.htmlFile)).to.be.a.file();
173-
expect(p(manifest.vendorFile)).to.be.a.file();
183+
manifest.vendorFiles.forEach(function(file) {
184+
expect(p(file)).to.be.a.file();
185+
});
174186
});
175187

176188
});

0 commit comments

Comments
 (0)