Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions packages/ember-cli-fastboot/addon/services/fastboot.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global FastBoot */
import { deprecate } from '@ember/application/deprecations';
import { computed, get } from '@ember/object';
import { deprecatingAlias, readOnly } from '@ember/object/computed';
import { readOnly } from '@ember/object/computed';
import { assert } from '@ember/debug';
import EObject from '@ember/object';
import Service from '@ember/service';
Expand Down Expand Up @@ -65,8 +64,6 @@ const Shoebox = EObject.extend({
});

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

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

host: computed(function() {
deprecate(
'Usage of fastboot service\'s `host` property is deprecated. Please use `request.host` instead.',
false,
{ id: 'fastboot.host-to-request', until: '0.9.9' }
);

return this._fastbootInfo.request.host();
}),

response: readOnly('_fastbootInfo.response'),
metadata: readOnly('_fastbootInfo.metadata'),

Expand Down
10 changes: 4 additions & 6 deletions packages/ember-cli-fastboot/lib/broccoli/fastboot-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports = class FastBootConfig extends Plugin {
let ui = this.ui;

eachAddonPackage(this.project, pkg => {
let deps = getFastBootDependencies(pkg, ui);
let deps = getFastBootDependencies(pkg);

if (deps) {
deps.forEach(dep => {
Expand Down Expand Up @@ -200,16 +200,14 @@ function eachAddonPackage(project, cb) {
project.addons.map(addon => cb(addon.pkg));
}

function getFastBootDependencies(pkg, ui) {
function getFastBootDependencies(pkg) {
let addon = pkg['ember-addon'];
if (!addon) {
return addon;
}

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

return addon.fastbootDependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

const path = require('path');
const fs = require('fs-extra');
const SilentError = require('silent-error');
const existsSync = fs.existsSync;

const fastbootInitializerTypes = [ 'initializers', 'instance-initializers'];
const FASTBOOT_DIR = 'fastboot';
const fastbootInitializerTypes = ['initializers', 'instance-initializers'];

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

Expand All @@ -45,41 +45,11 @@ function _checkBrowserInitializers(rootPath) {
* @param {Object} project
* @param {String} rootPath
*/
function _moveFastBootInitializers(project, rootPath) {

function _checkFastBootInitializers(project, rootPath) {
// check to see if it is a fastboot complaint addon
const isFastbootAddon = _checkInitializerTypeExists(rootPath, 'fastboot');
if (isFastbootAddon) {
project.ui.writeDeprecateLine(`Having fastboot specific code in app directory of ${rootPath} is deprecated. Please move it to fastboot/app directory.`);

const fastbootDirPath = path.join(rootPath, FASTBOOT_DIR);
// check if fastboot/app exists
if (!existsSync(fastbootDirPath)) {
fs.mkdirsSync(fastbootDirPath);
}

// copy over app/initializers/fastboot and app/instance/initializers/fastboot
fastbootInitializerTypes.forEach((fastbootInitializerType) => {
const srcFastbootPath = path.join(rootPath, 'app', fastbootInitializerType, 'fastboot');

if (existsSync(srcFastbootPath)) {
const destFastbootPath = path.join(fastbootDirPath, fastbootInitializerType);
if (!existsSync(destFastbootPath)) {
fs.mkdirSync(destFastbootPath);
}

// fastboot initializer type exists so we need to move this fastboot/app
const fastbootFiles = fs.readdirSync(srcFastbootPath);
fastbootFiles.forEach((fastbootFile) => {
const srcPath = path.join(srcFastbootPath, fastbootFile);
const destPath = path.join(destFastbootPath, fastbootFile);
fs.copySync(srcPath, destPath);

// delete the original path files so that there are no two initializers with the same name
fs.unlinkSync(srcPath);
});
}
});
throw new SilentError(`Having fastboot specific code in app directory of ${rootPath} is deprecated. Please move it to fastboot/app directory.`);
}
}

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

_checkBrowserInitializers(currentAddonPath);
_moveFastBootInitializers(project, currentAddonPath);
_checkFastBootInitializers(project, currentAddonPath);
});
}

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

_checkBrowserInitializers(hostAppPath);
_moveFastBootInitializers(project, hostAppPath);
_checkFastBootInitializers(project, hostAppPath);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test-packages/basic-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"test:mocha": "mocha"
},
"dependencies": {
"ember-fastboot-build-example": "0.1.2",
"rsvp": "^4.8.5"
},
"devDependencies": {
Expand Down Expand Up @@ -58,6 +57,7 @@
"eslint-plugin-ember": "^8.6.0",
"eslint-plugin-node": "^11.1.0",
"execa": "^4.0.3",
"example-addon": "*",
"fake-addon": "*",
"fake-addon-2": "*",
"loader.js": "^4.7.0",
Expand Down
6 changes: 3 additions & 3 deletions test-packages/basic-app/test/package-json-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ describe("generating package.json", function () {
appFiles: [
"assets/basic-app.js",
"assets/basic-app-fastboot.js",
"ember-fastboot-build-example/bar.js",
"example-addon/bar.js",
],
htmlFile: "index.html",
vendorFiles: [
"ember-fastboot-build-example/foo.js",
"example-addon/foo.js",
"assets/vendor.js",
"assets/auto-import-fastboot.js",
"ember-fetch/fetch-fastboot.js",
Expand Down Expand Up @@ -127,7 +127,7 @@ describe("generating package.json", function () {
});
});

it("contains additional config from ember-fastboot-build-example addon", function () {
it("contains additional config from example-addon", function () {
let pkg = fs.readJSONSync("dist/package.json");

expect(pkg.fastboot.config["foo"]).to.equal("bar");
Expand Down
9 changes: 9 additions & 0 deletions test-packages/example-addon/.ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
20 changes: 20 additions & 0 deletions test-packages/example-addon/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
54 changes: 54 additions & 0 deletions test-packages/example-addon/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
},
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script'
},
env: {
browser: false,
node: true
},
plugins: ['node'],
extends: ['plugin:node/recommended']
}
]
};
25 changes: 25 additions & 0 deletions test-packages/example-addon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/.env*
/.pnp*
/.sass-cache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
32 changes: 32 additions & 0 deletions test-packages/example-addon/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# compiled output
/dist/
/tmp/

# dependencies
/bower_components/

# misc
/.bowerrc
/.editorconfig
/.ember-cli
/.env*
/.eslintignore
/.eslintrc.js
/.git/
/.gitignore
/.template-lintrc.js
/.travis.yml
/.watchmanconfig
/bower.json
/config/ember-try.js
/CONTRIBUTING.md
/ember-cli-build.js
/testem.js
/tests/
/yarn.lock
.gitkeep

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
5 changes: 5 additions & 0 deletions test-packages/example-addon/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: 'octane'
};
38 changes: 38 additions & 0 deletions test-packages/example-addon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
example-addon
==============================================================================

[Short description of the addon.]


Compatibility
------------------------------------------------------------------------------

* Ember.js v3.12 or above
* Ember CLI v2.13 or above
* Node.js v10 or above


Installation
------------------------------------------------------------------------------

```
ember install example-addon
```


Usage
------------------------------------------------------------------------------

[Longer description of how to use the addon in apps.]


Contributing
------------------------------------------------------------------------------

See the [Contributing](CONTRIBUTING.md) guide for details.


License
------------------------------------------------------------------------------

This project is licensed under the [MIT License](LICENSE.md).
Empty file.
Empty file.
Loading