Skip to content

Commit a62e70a

Browse files
committed
Remove deprecated features for ember-cli-fastboot v3 release
* `@service('fastboot')` * `cookies` -> `this.fastboot.request.cookies` * `headers` -> `this.fastboot.request.headers` * `host` -> `this.fastboot.request.host` * `ember-addon.fastBootDependencies` -> `ember-addon.fastbootDependencies` (the lowercased 'b') * `app/initializers|instance-initialzers/fastboot` -> `fastboot/initializers|instance-initializers/`
1 parent e4d0b7c commit a62e70a

File tree

3 files changed

+12
-57
lines changed

3 files changed

+12
-57
lines changed

packages/ember-cli-fastboot/addon/services/fastboot.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* global FastBoot */
2-
import { deprecate } from '@ember/application/deprecations';
32
import { computed, get } from '@ember/object';
4-
import { deprecatingAlias, readOnly } from '@ember/object/computed';
3+
import { readOnly } from '@ember/object/computed';
54
import { assert } from '@ember/debug';
65
import EObject from '@ember/object';
76
import Service from '@ember/service';
@@ -65,8 +64,6 @@ const Shoebox = EObject.extend({
6564
});
6665

6766
const FastBootService = Service.extend({
68-
cookies: deprecatingAlias('request.cookies', { id: 'fastboot.cookies-to-request', until: '0.9.9' }),
69-
headers: deprecatingAlias('request.headers', { id: 'fastboot.headers-to-request', until: '0.9.9' }),
7067
isFastBoot: typeof FastBoot !== 'undefined',
7168

7269
isFastboot: computed(function() {
@@ -83,16 +80,6 @@ const FastBootService = Service.extend({
8380
this.set('shoebox', shoebox);
8481
},
8582

86-
host: computed(function() {
87-
deprecate(
88-
'Usage of fastboot service\'s `host` property is deprecated. Please use `request.host` instead.',
89-
false,
90-
{ id: 'fastboot.host-to-request', until: '0.9.9' }
91-
);
92-
93-
return this._fastbootInfo.request.host();
94-
}),
95-
9683
response: readOnly('_fastbootInfo.response'),
9784
metadata: readOnly('_fastbootInfo.metadata'),
9885

packages/ember-cli-fastboot/lib/broccoli/fastboot-config.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module.exports = class FastBootConfig extends Plugin {
8989
let ui = this.ui;
9090

9191
eachAddonPackage(this.project, pkg => {
92-
let deps = getFastBootDependencies(pkg, ui);
92+
let deps = getFastBootDependencies(pkg);
9393

9494
if (deps) {
9595
deps.forEach(dep => {
@@ -200,16 +200,14 @@ function eachAddonPackage(project, cb) {
200200
project.addons.map(addon => cb(addon.pkg));
201201
}
202202

203-
function getFastBootDependencies(pkg, ui) {
203+
function getFastBootDependencies(pkg) {
204204
let addon = pkg['ember-addon'];
205205
if (!addon) {
206206
return addon;
207207
}
208208

209-
let deps = addon.fastBootDependencies;
210-
if (deps) {
211-
ui.writeDeprecateLine('ember-addon.fastBootDependencies has been replaced with ember-addon.fastbootDependencies [addon: ' + pkg.name + ']');
212-
return deps;
209+
if (addon.fastBootDependencies) {
210+
throw new SilentError('ember-addon.fastBootDependencies has been replaced with ember-addon.fastbootDependencies [addon: ' + pkg.name + ']')
213211
}
214212

215213
return addon.fastbootDependencies;

packages/ember-cli-fastboot/lib/build-utilities/migrate-initializers.js

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
const path = require('path');
44
const fs = require('fs-extra');
5+
const SilentError = require('silent-error');
56
const existsSync = fs.existsSync;
67

7-
const fastbootInitializerTypes = [ 'initializers', 'instance-initializers'];
8-
const FASTBOOT_DIR = 'fastboot';
8+
const fastbootInitializerTypes = ['initializers', 'instance-initializers'];
99

1010
/**
1111
* Helper function to check if there are any `(instance-)?intializers/[browser|fastboot]/` path under the
@@ -36,7 +36,7 @@ function _checkBrowserInitializers(rootPath) {
3636
if (isBrowserInitializersPresent) {
3737
const errorMsg = `FastBoot build no longer supports ${rootPath}/app/(instance-)?initializers/browser structure. ` +
3838
`Please refer to http://ember-fastboot.com/docs/addon-author-guide#browser-only-or-node-only-initializers for a migration path.`;
39-
throw new Error(errorMsg);
39+
throw new SilentError(errorMsg);
4040
}
4141
}
4242

@@ -45,41 +45,11 @@ function _checkBrowserInitializers(rootPath) {
4545
* @param {Object} project
4646
* @param {String} rootPath
4747
*/
48-
function _moveFastBootInitializers(project, rootPath) {
49-
48+
function _checkFastBootInitializers(project, rootPath) {
5049
// check to see if it is a fastboot complaint addon
5150
const isFastbootAddon = _checkInitializerTypeExists(rootPath, 'fastboot');
5251
if (isFastbootAddon) {
53-
project.ui.writeDeprecateLine(`Having fastboot specific code in app directory of ${rootPath} is deprecated. Please move it to fastboot/app directory.`);
54-
55-
const fastbootDirPath = path.join(rootPath, FASTBOOT_DIR);
56-
// check if fastboot/app exists
57-
if (!existsSync(fastbootDirPath)) {
58-
fs.mkdirsSync(fastbootDirPath);
59-
}
60-
61-
// copy over app/initializers/fastboot and app/instance/initializers/fastboot
62-
fastbootInitializerTypes.forEach((fastbootInitializerType) => {
63-
const srcFastbootPath = path.join(rootPath, 'app', fastbootInitializerType, 'fastboot');
64-
65-
if (existsSync(srcFastbootPath)) {
66-
const destFastbootPath = path.join(fastbootDirPath, fastbootInitializerType);
67-
if (!existsSync(destFastbootPath)) {
68-
fs.mkdirSync(destFastbootPath);
69-
}
70-
71-
// fastboot initializer type exists so we need to move this fastboot/app
72-
const fastbootFiles = fs.readdirSync(srcFastbootPath);
73-
fastbootFiles.forEach((fastbootFile) => {
74-
const srcPath = path.join(srcFastbootPath, fastbootFile);
75-
const destPath = path.join(destFastbootPath, fastbootFile);
76-
fs.copySync(srcPath, destPath);
77-
78-
// delete the original path files so that there are no two initializers with the same name
79-
fs.unlinkSync(srcPath);
80-
});
81-
}
82-
});
52+
throw new SilentError(`Having fastboot specific code in app directory of ${rootPath} is deprecated. Please move it to fastboot/app directory.`);
8353
}
8454
}
8555

@@ -93,7 +63,7 @@ function _migrateAddonInitializers(project) {
9363
const currentAddonPath = addon.root;
9464

9565
_checkBrowserInitializers(currentAddonPath);
96-
_moveFastBootInitializers(project, currentAddonPath);
66+
_checkFastBootInitializers(project, currentAddonPath);
9767
});
9868
}
9969

@@ -106,7 +76,7 @@ function _migrateHostAppInitializers(project) {
10676
const hostAppPath = path.join(project.root);
10777

10878
_checkBrowserInitializers(hostAppPath);
109-
_moveFastBootInitializers(project, hostAppPath);
79+
_checkFastBootInitializers(project, hostAppPath);
11080
}
11181

11282
/**

0 commit comments

Comments
 (0)