-
Notifications
You must be signed in to change notification settings - Fork 34
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
Prepare for FastBoot 1.0 #21
Changes from all commits
abefcb7
8777d6a
f4e7b7b
e7fb768
3b2ae51
a31877f
022a6e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ export function initialize(owner) { | |
|
||
export default { | ||
name: 'head-fastboot', | ||
initialize: initialize | ||
initialize | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const setupTest = require('ember-fastboot-addon-tests').setupTest; | ||
|
||
describe('FastBoot pre 1.0', function() { | ||
setupTest('fastboot-beta', { | ||
emberCliFastbootVersion: '1.0.0-beta.18' | ||
} | ||
); | ||
|
||
it('index page', function() { | ||
return this.visit('/') | ||
.then(function(res) { | ||
let $ = res.jQuery; | ||
let response = res.response; | ||
|
||
expect(response.statusCode).to.equal(200); | ||
expect($('h1').text().trim()).to.equal('Hello page'); | ||
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Hello page'); | ||
}); | ||
}); | ||
|
||
it('other page', function() { | ||
return this.visit('/other-page') | ||
.then(function(res) { | ||
let $ = res.jQuery; | ||
let response = res.response; | ||
|
||
expect(response.statusCode).to.equal(200); | ||
expect($('h1').text().trim()).to.equal('Other page'); | ||
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Other page'); | ||
}); | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const setupTest = require('ember-fastboot-addon-tests').setupTest; | ||
|
||
describe('FastBoot 1.0', function() { | ||
setupTest('fastboot', { | ||
emberCliFastbootVersion: '1.0.0-rc.1' | ||
}); | ||
|
||
it('index page', function() { | ||
return this.visit('/') | ||
.then(function(res) { | ||
let $ = res.jQuery; | ||
let response = res.response; | ||
|
||
expect(response.statusCode).to.equal(200); | ||
expect($('h1').text().trim()).to.equal('Hello page'); | ||
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Hello page'); | ||
}); | ||
}); | ||
|
||
it('other page', function() { | ||
return this.visit('/other-page') | ||
.then(function(res) { | ||
let $ = res.jQuery; | ||
let response = res.response; | ||
|
||
expect(response.statusCode).to.equal(200); | ||
expect($('h1').text().trim()).to.equal('Other page'); | ||
expect($('meta[property="og:title"]', 'head').attr('content')).to.equal('Other page'); | ||
}); | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Ember from 'ember'; | ||
import config from './config/environment'; | ||
|
||
const Router = Ember.Router.extend({ | ||
location: config.locationType, | ||
rootURL: config.rootURL | ||
}); | ||
|
||
Router.map(function() { | ||
this.route('other-page'); | ||
}); | ||
|
||
export default Router; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Ember from 'ember'; | ||
|
||
const { set } = Ember; | ||
|
||
export default Ember.Route.extend({ | ||
headData: Ember.inject.service(), | ||
afterModel() { | ||
set(this, 'headData.title', "Hello page"); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Ember from 'ember'; | ||
|
||
const { set } = Ember; | ||
|
||
export default Ember.Route.extend({ | ||
headData: Ember.inject.service(), | ||
afterModel() { | ||
set(this, 'headData.title', "Other page"); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- Add content you wish automatically added to the documents head--> | ||
<!-- here. The 'model' available in this template can be populated by--> | ||
<!-- setting values on the 'head-data' service. --> | ||
|
||
<meta property="og:title" content={{model.title}} /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hello page</h1> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Other page</h1> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Ember from 'ember'; | ||
import config from './config/environment'; | ||
|
||
const Router = Ember.Router.extend({ | ||
location: config.locationType, | ||
rootURL: config.rootURL | ||
}); | ||
|
||
Router.map(function() { | ||
this.route('other-page'); | ||
}); | ||
|
||
export default Router; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Ember from 'ember'; | ||
|
||
const { set } = Ember; | ||
|
||
export default Ember.Route.extend({ | ||
headData: Ember.inject.service(), | ||
afterModel() { | ||
set(this, 'headData.title', "Hello page"); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Ember from 'ember'; | ||
|
||
const { set } = Ember; | ||
|
||
export default Ember.Route.extend({ | ||
headData: Ember.inject.service(), | ||
afterModel() { | ||
set(this, 'headData.title', "Other page"); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- Add content you wish automatically added to the documents head--> | ||
<!-- here. The 'model' available in this template can be populated by--> | ||
<!-- setting values on the 'head-data' service. --> | ||
|
||
<meta property="og:title" content={{model.title}} /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hello page</h1> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Other page</h1> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,55 @@ | ||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var filterInitializers = require('fastboot-filter-initializers'); | ||
var VersionChecker = require('ember-cli-version-checker'); | ||
var mergeTrees = require('broccoli-merge-trees'); | ||
const path = require('path'); | ||
const filterInitializers = require('fastboot-filter-initializers'); | ||
const VersionChecker = require('ember-cli-version-checker'); | ||
const mergeTrees = require('broccoli-merge-trees'); | ||
|
||
module.exports = { | ||
name: 'ember-cli-head', | ||
|
||
treeForApp: function(defaultTree) { | ||
var checker = new VersionChecker(this); | ||
var emberVersion = checker.for('ember-source', 'npm'); | ||
treeForApp(defaultTree) { | ||
if (!process.env.FASTBOOT_NEW_BUILD) { | ||
let trees = [defaultTree]; | ||
|
||
if (!this.hasGlimmer2()) { | ||
trees.push(this.treeGenerator(path.resolve(this.root, 'app-lt-2-10'))); | ||
trees.push(this.treeGenerator(path.resolve(this.root, 'fastboot-lt-2-10'))); | ||
} | ||
|
||
let tree = mergeTrees(trees, { overwrite: true }); | ||
|
||
return filterInitializers(tree); | ||
} else { | ||
let trees = [defaultTree]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you do this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But that's just for the browser. That's covering the new FastBoot, but with an pre 2.10 ember, where we need to merge the |
||
if (!this.hasGlimmer2()) { | ||
trees.push(this.treeGenerator(path.resolve(this.root, 'app-lt-2-10'))); | ||
} | ||
|
||
return mergeTrees(trees, { overwrite: true }); | ||
} | ||
}, | ||
|
||
treeForFastBoot(tree) { | ||
// this hook will be invoked in post FastBoot 1.0 | ||
if (!this.hasGlimmer2) { | ||
let fastBootHtmlBarsTree = this.treeGenerator(path.resolve(this.root, 'fastboot-lt-2-10')); | ||
return tree ? mergeTrees([tree, fastBootHtmlBarsTree], { overwrite: true }) : fastBootHtmlBarsTree; | ||
} | ||
return tree; | ||
}, | ||
|
||
hasGlimmer2() { | ||
let checker = new VersionChecker(this); | ||
let emberVersion = checker.for('ember-source', 'npm'); | ||
|
||
if (!emberVersion.version) { | ||
emberVersion = checker.for('ember', 'bower'); | ||
} | ||
|
||
var trees = [defaultTree]; | ||
|
||
// 2.9.0-beta.1 - 2.9.0-beta.5 used glimmer2 (but 2.9.0 did not) | ||
// 2.10.0-beta.1+ includes glimmer2 | ||
if (!(emberVersion.gt('2.9.0-beta') && emberVersion.lt('2.9.0')) && !emberVersion.gt('2.10.0-beta')) { | ||
trees.push(this.treeGenerator(path.resolve(this.root, 'app-lt-2-10'))); | ||
} | ||
|
||
var tree = mergeTrees(trees, { overwrite: true }); | ||
|
||
return filterInitializers(tree); | ||
return (emberVersion.gt('2.9.0-beta') && emberVersion.lt('2.9.0')) || emberVersion.gt('2.10.0-beta'); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
"license": "MIT", | ||
"devDependencies": { | ||
"broccoli-asset-rev": "^2.4.5", | ||
"chai": "^3.5.0", | ||
"ember-ajax": "^2.4.1", | ||
"ember-cli": "2.12.2", | ||
"ember-cli-app-version": "^1.0.0", | ||
|
@@ -36,6 +37,7 @@ | |
"ember-disable-prototype-extensions": "^1.1.0", | ||
"ember-disable-proxy-controllers": "^1.0.1", | ||
"ember-export-application-global": "^1.0.5", | ||
"ember-fastboot-addon-tests": "^0.4.0", | ||
"ember-load-initializers": "^0.6.0", | ||
"ember-resolver": "^2.0.3", | ||
"ember-source": "~2.12.0", | ||
|
@@ -49,7 +51,7 @@ | |
"ember-cli-babel": "^6.0.0", | ||
"ember-cli-htmlbars": "^1.3.0", | ||
"ember-cli-version-checker": "^1.1.6", | ||
"fastboot-filter-initializers": "0.0.1" | ||
"fastboot-filter-initializers": "^0.0.2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caret here does nothing, we should bump to 0.1.0 (upstream) so that we can use caret deps... |
||
}, | ||
"engines": { | ||
"node": ">= 4" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
initialize
function needs to be wrapped in aif (typeof FastBoot != 'undefined') {...}
check to make sureember-cli-head
works in apps withoutember-cli-fastboot
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had a look at it again... I think this is not needed, as this is not part of
app
filterInitializers
(https://github.com/ronco/ember-cli-head/pull/21/files#diff-168726dbe96b3ce427e7fedce31bb0bcR23), so the browser build should not include thistreeForFastboot
And the ember 2.4 test scenario seems to be ok!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Missed the
filterInitializers
again 👍