Skip to content

Commit d7bb5af

Browse files
authored
Merge pull request #134 from xg-wang/upgrade
Deprecate Logger and merge Drop support for ember<2.16 Use whatwg-fetch instead of forked version.
2 parents 9e25f5f + d14471f commit d7bb5af

File tree

7 files changed

+1700
-595
lines changed

7 files changed

+1700
-595
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ module.exports = {
99
env: {
1010
browser: true
1111
},
12-
rules: {},
12+
rules: {
13+
'no-console': ["error", { allow: ['warn'] }]
14+
},
1315
overrides: [
1416
// node files
1517
{

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ env:
2222
matrix:
2323
# we recommend new addons test the current and previous LTS
2424
# as well as latest stable release (bonus points to beta/canary)
25-
- EMBER_TRY_SCENARIO=ember-lts-2.12
2625
- EMBER_TRY_SCENARIO=ember-lts-2.16
2726
- EMBER_TRY_SCENARIO=ember-lts-2.18
2827
- EMBER_TRY_SCENARIO=ember-release

addon/mixins/adapter-fetch.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import Ember from 'ember';
21
import Mixin from '@ember/object/mixin';
3-
import { assign, merge } from '@ember/polyfills'
2+
import { assign } from '@ember/polyfills'
43
import RSVP from 'rsvp';
54
import fetch from 'fetch';
6-
7-
import { serializeQueryParams } from 'ember-fetch/utils/serialize-query-params';
8-
9-
const {
10-
Logger: { warn }
11-
} = Ember;
5+
import { serializeQueryParams } from '../utils/serialize-query-params';
126

137
/**
148
* Helper function to create a plain object from the response's Headers.
@@ -32,16 +26,13 @@ export function headersToObject(headers) {
3226
* @returns {Object}
3327
*/
3428
export function mungOptionsForFetch(_options, adapter) {
35-
// This allows this mixin to be backward compatible with Ember < 2.5.
36-
const combineObjs = (assign || merge);
37-
const options = combineObjs({
29+
const options = assign({
3830
credentials: 'same-origin',
3931
}, _options);
4032

4133
let adapterHeaders = adapter.get('headers');
4234
if (adapterHeaders) {
43-
// This double use of `combineObjs` is necessary because `merge` only accepts two arguments.
44-
options.headers = combineObjs(combineObjs({}, options.headers || {}), adapterHeaders);
35+
options.headers = assign(options.headers || {}, adapterHeaders);
4536
}
4637

4738
// Default to 'GET' in case `type` is not passed in (mimics jQuery.ajax).
@@ -93,7 +84,7 @@ export function determineBodyPromise(response, requestData) {
9384
if (response.ok && (status === 204 || status === 205 || requestData.method === 'HEAD')) {
9485
payload = { data: null };
9586
} else {
96-
warn('This response was unable to be parsed as json.', payload);
87+
console.warn('This response was unable to be parsed as json.', payload);
9788
}
9889
}
9990
return payload;

config/ember-try.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ module.exports = function() {
1111
return {
1212
useYarn: true,
1313
scenarios: [
14-
{
15-
name: 'ember-lts-2.12',
16-
npm: {
17-
devDependencies: {
18-
'ember-source': '~2.12.0'
19-
}
20-
}
21-
},
2214
{
2315
name: 'ember-lts-2.16',
2416
npm: {

index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ function treeForBrowserFetch() {
150150
]
151151
}
152152
});
153-
// Fork whatwg-fetch to provide umd build before official release, no extra change made.
154-
// We will get back to the official one when new version released.
155-
const fetchNode = new Rollup(path.dirname(path.dirname(require.resolve('@xg-wang/whatwg-fetch'))), {
153+
const fetchNode = new Rollup(path.dirname(path.dirname(require.resolve('whatwg-fetch'))), {
156154
rollup: {
157155
input: 'fetch.js',
158156
output: {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"test:node": "mocha"
2121
},
2222
"dependencies": {
23-
"@xg-wang/whatwg-fetch": "^3.0.0",
2423
"abortcontroller-polyfill": "^1.1.9",
2524
"babel-core": "^6.26.3",
2625
"babel-preset-env": "^1.7.0",
@@ -31,7 +30,8 @@
3130
"broccoli-templater": "^2.0.1",
3231
"ember-cli-babel": "^6.8.2",
3332
"node-fetch": "^2.0.0-alpha.9",
34-
"rollup-plugin-babel": "^3.0.7"
33+
"rollup-plugin-babel": "^3.0.7",
34+
"whatwg-fetch": "^3.0.0"
3535
},
3636
"devDependencies": {
3737
"broccoli-asset-rev": "^2.4.5",
@@ -53,7 +53,7 @@
5353
"ember-resolver": "^4.0.0",
5454
"ember-source": "~3.0.0",
5555
"ember-source-channel-url": "^1.0.1",
56-
"ember-try": "^0.2.23",
56+
"ember-try": "^1.1.0",
5757
"eslint-plugin-ember": "^5.0.0",
5858
"eslint-plugin-node": "^5.2.1",
5959
"loader.js": "^4.2.3",

0 commit comments

Comments
 (0)