Skip to content

Commit d385f5d

Browse files
committed
Bump ember-cli to 2.18.1
1 parent ed41433 commit d385f5d

34 files changed

+11564
-234
lines changed

.eslintrc.js

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,54 @@ module.exports = {
44
ecmaVersion: 2017,
55
sourceType: 'module'
66
},
7-
extends: 'eslint:recommended',
7+
plugins: [
8+
'ember'
9+
],
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:ember/recommended'
13+
],
814
env: {
915
browser: true
1016
},
1117
rules: {
12-
}
18+
},
19+
overrides: [
20+
// node files
21+
{
22+
files: [
23+
'index.js',
24+
'testem.js',
25+
'ember-cli-build.js',
26+
'config/**/*.js',
27+
'tests/dummy/config/**/*.js'
28+
],
29+
excludedFiles: [
30+
'app/**',
31+
'addon/**',
32+
'tests/dummy/app/**'
33+
],
34+
parserOptions: {
35+
sourceType: 'script',
36+
ecmaVersion: 2015
37+
},
38+
env: {
39+
browser: false,
40+
node: true
41+
},
42+
plugins: ['node'],
43+
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
44+
// add your custom rules and overrides for node files here
45+
})
46+
},
47+
48+
// test files
49+
{
50+
files: ['tests/**/*.js'],
51+
excludedFiles: ['tests/dummy/**/*.js'],
52+
env: {
53+
embertest: true
54+
}
55+
}
56+
]
1357
};

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414
/coverage/*
1515
/libpeerconnection.log
1616
npm-debug.log*
17+
yarn-error.log
1718
testem.log
19+
20+
# ember-try
21+
.node_modules.ember-try/
22+
bower.json.ember-try
23+
package.json.ember-try

.npmignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
.bowerrc
88
.editorconfig
99
.ember-cli
10-
.gitignore
1110
.eslintrc.js
11+
.gitignore
1212
.watchmanconfig
1313
.travis.yml
1414
bower.json
1515
ember-cli-build.js
1616
testem.js
17+
18+
# ember-try
19+
.node_modules.ember-try/
20+
bower.json.ember-try
21+
package.json.ember-try

.travis.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
---
22
language: node_js
33
node_js:
4-
- "6"
4+
# we recommend testing addons with the same minimum supported node version as Ember CLI
5+
# so that your addon works for all apps
6+
- "4"
57

68
sudo: false
9+
dist: trusty
10+
11+
addons:
12+
chrome: stable
713

814
cache:
915
directories:
1016
- $HOME/.npm
1117

1218
env:
13-
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
14-
- EMBER_TRY_SCENARIO=ember-lts-2.4
15-
- EMBER_TRY_SCENARIO=ember-lts-2.8
16-
- EMBER_TRY_SCENARIO=ember-release
17-
- EMBER_TRY_SCENARIO=ember-beta
18-
- EMBER_TRY_SCENARIO=ember-canary
19-
- EMBER_TRY_SCENARIO=ember-default
19+
global:
20+
# See https://git.io/vdao3 for details.
21+
- JOBS=1
22+
matrix:
23+
# we recommend new addons test the current and previous LTS
24+
# as well as latest stable release (bonus points to beta/canary)
25+
- EMBER_TRY_SCENARIO=ember-lts-2.12
26+
- EMBER_TRY_SCENARIO=ember-lts-2.16
27+
- EMBER_TRY_SCENARIO=ember-release
28+
- EMBER_TRY_SCENARIO=ember-beta
29+
- EMBER_TRY_SCENARIO=ember-canary
30+
- EMBER_TRY_SCENARIO=ember-default
2031

2132
matrix:
2233
fast_finish: true
@@ -25,16 +36,14 @@ matrix:
2536

2637
before_install:
2738
- npm config set spin false
28-
- npm install -g phantomjs-prebuilt
29-
- phantomjs --version
30-
31-
install:
32-
- npm install
39+
- npm install -g npm@4
40+
- npm --version
3341

3442
script:
43+
- npm run lint:js
3544
# Usually, it's ok to finish the test scenario without reverting
3645
# to the addon's original dependency state, skipping "cleanup".
37-
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
46+
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
3847

3948
notifications:
4049
email: false

README.md

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ember-cli-adapter-pattern [![Build Status](https://travis-ci.org/tomasbasham/ember-cli-adapter-pattern.svg?branch=master)](https://travis-ci.org/tomasbasham/ember-cli-adapter-pattern)
1+
# ember-cli-adapter-pattern [![Build Status](https://travis-ci.org/tomasbasham/ember-cli-adapter-pattern.svg?branch=master)](https://travis-ci.org/tomasbasham/ember-cli-adapter-pattern)
22

33
An [Ember CLI](https://ember-cli.com/) addon to standardise a common adapter
44
pattern.
@@ -37,11 +37,19 @@ service.
3737

3838
```JavaScript
3939
// app/services/social.js
40-
import Ember from 'ember';
40+
import Service from '@ember/service';
41+
4142
import Adaptable from 'ember-cli-adapter-pattern/mixins/adaptable';
4243
import proxyToAdapter from 'ember-cli-adapter-pattern/utils/proxy-to-adapter';
4344

44-
export default Ember.Service.extend(Adaptable, {
45+
import { getOwner } from '@ember/application';
46+
import { A } from '@ember/array';
47+
import { assert } from '@ember/debug';
48+
import { get, getWithDefault } from '@ember/object';
49+
import { on } from '@embber/object/evented';
50+
import { dasherize } from '@ember/string';
51+
52+
export default Service.extend(Adaptable, {
4553
login: proxyToAdapter('login'), // Provides a safe method to proxy your API to each adapter.
4654

4755
/**
@@ -51,13 +59,14 @@ export default Ember.Service.extend(Adaptable, {
5159
* `activateAdapters` method is
5260
* called.
5361
*/
54-
createAdapters: Ember.on('init', function() {
55-
const adapters = Ember.getWithDefault(this, 'property.with.adapter.configurations', Ember.A());
62+
createAdapters: on('init', function() {
63+
const adapters = getWithDefault(this, 'property.with.adapter.configurations', A());
5664

5765
this.set('_adapters', {});
5866
this.set('context', {});
5967

60-
this.activateAdapters(adapters); // This is important and activates configured adapters.
68+
// Activate configured adapter.
69+
this.activateAdapters(adapters);
6170
}),
6271

6372
/**
@@ -68,11 +77,11 @@ export default Ember.Service.extend(Adaptable, {
6877
* container.
6978
*/
7079
_lookupAdapter(adapterName) {
71-
Ember.assert('Could not find adapter without a name', adapterName);
80+
assert('Could not find adapter without a name', adapterName);
7281

73-
const container = this.get('container');
74-
const dasherizedAdapterName = Ember.String.dasherize(adapterName);
75-
const adapter = container.lookup(`container:${dasherizedAdapterName}`);
82+
const owner = getOwner(this);
83+
const dasherizedAdapterName = dasherize(adapterName);
84+
const adapter = owner.lookup(`container:${dasherizedAdapterName}`);
7685

7786
return adapter;
7887
}
@@ -92,14 +101,18 @@ ember object (i.e. a controller) and invoke it as normal.
92101

93102
```JavaScript
94103
// app/controller/application.js
95-
import Ember from 'ember';
104+
import Controller from '@ember/controller';
96105

97-
export default Ember.Controller.extend({
98-
social: Ember.Service.inject(),
106+
import { get } from '@ember/object';
107+
import { inject } from '@ember/service';
108+
109+
export default Controller.extend({
110+
social: inject(),
99111

100112
actions: {
101113
loginWithService() {
102-
this.get('social').login({ username: 'Jean-Luc Picard', password: 'Enterprise-D' });
114+
const social = get(this, 'social');
115+
social.login({ username: 'Jean-Luc Picard', password: 'Enterprise-D' });
103116
}
104117
}
105118
});
@@ -115,14 +128,17 @@ then you must pass in it's name to the API call.
115128

116129
```JavaScript
117130
// app/controller/application.js
118-
import Ember from 'ember';
131+
import Controller from '@ember/controller';
132+
133+
import { get } from '@ember/object';
134+
import { inject } from '@ember/service';
119135

120-
export default Ember.Controller.extend({
121-
social: Ember.Service.inject(),
136+
export default Controller.extend({
137+
social: inject(),
122138

123139
actions: {
124140
loginWithService() {
125-
this.get('social').login('Facebook', { username: 'Jean-Luc Picard', password: 'Enterprise-D' });
141+
get(this, 'social').login('Facebook', { username: 'Jean-Luc Picard', password: 'Enterprise-D' });
126142
}
127143
}
128144
});
@@ -146,10 +162,10 @@ within the `Adaptable` mixin.
146162

147163
```JavaScript
148164
// app/services/social.js
149-
import Ember from 'ember';
165+
import Service from '@ember/service';
150166
import Adaptable from 'ember-cli-adapter-pattern/mixins/adaptable';
151167

152-
export default Ember.Service.extend(Adaptable, {
168+
export default Service.extend(Adaptable, {
153169
login(...args) {
154170
// Extended operations here.
155171
this.invoke('login', ...args);

addon/mixins/adaptable.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
import Ember from 'ember';
2-
import requiredMethod from 'ember-cli-adapter-pattern/utils/required-method';
3-
4-
const {
5-
assert,
6-
copy,
7-
get,
8-
merge,
9-
on,
10-
set
11-
} = Ember;
1+
import Mixin from '@ember/object/mixin';
122

13-
const {
14-
resolve
15-
} = Ember.RSVP;
3+
import requiredMethod from 'ember-cli-adapter-pattern/utils/required-method';
164

17-
const {
18-
keys
19-
} = Object;
5+
import { assert } from '@ember/debug';
6+
import { get, set } from '@ember/object';
7+
import { on } from '@ember/object/evented';
8+
import { copy } from '@ember/object/internals';
9+
import { merge } from '@ember/polyfills';
10+
import { hash, resolve } from 'rsvp';
2011

21-
export default Ember.Mixin.create({
12+
export default Mixin.create({
2213

2314
/*
2415
* A cache of active adapters to save
@@ -104,7 +95,7 @@ export default Ember.Mixin.create({
10495
*/
10596
invoke(methodName, ...args) {
10697
const cachedAdapters = get(this, '_adapters');
107-
const adapterNames = keys(cachedAdapters);
98+
const adapterNames = Object.keys(cachedAdapters);
10899
const [selectedAdapterNames, options] = args.length > 1 ? [[args[0]], args[1]] : [adapterNames, args[0]];
109100
const context = copy(get(this, 'context'));
110101
const mergedOptions = merge(context, options);
@@ -117,7 +108,7 @@ export default Ember.Mixin.create({
117108
promises[adapterName] = resolve(adapter[methodName].call(adapter, mergedOptions));
118109
});
119110

120-
return Ember.RSVP.hash(promises);
111+
return hash(promises);
121112
},
122113

123114
/*

addon/utils/proxy-to-adapter.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import Ember from 'ember';
2-
3-
const {
4-
assert
5-
} = Ember;
1+
import EmberError from '@ember/error';
2+
import { assert } from '@ember/debug';
63

74
/*
85
* Utility method, returning a proxy function
@@ -23,7 +20,7 @@ export default function proxyToAdapter(methodName) {
2320

2421
return function(...args) {
2522
if (!this.invoke && typeof this.invoke !== 'function') {
26-
throw new Ember.Error('No invoke method. Have you forgotten to include the Adaptable mixin?');
23+
throw new EmberError('No invoke method. Have you forgotten to include the Adaptable mixin?');
2724
}
2825

2926
return this.invoke(methodName, ...args);

addon/utils/required-method.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import Ember from 'ember';
2-
3-
const {
4-
assert
5-
} = Ember;
1+
import EmberError from '@ember/error';
2+
import { assert } from '@ember/debug';
63

74
/*
85
* Utility method, returning a function that
@@ -21,6 +18,6 @@ export default function requiredMethod(methodName) {
2118
assert('Method name is required for requiredMethod.', methodName);
2219

2320
return function() {
24-
throw new Ember.Error(`Definition of method ${methodName} is required.`);
21+
throw new EmberError(`Definition of method ${methodName} is required.`);
2522
};
2623
}

addon/utils/required-property.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import Ember from 'ember';
1+
import EmberError from '@ember/error';
22

3-
const {
4-
assert,
5-
computed
6-
} = Ember;
3+
import { assert } from '@ember/debug';
4+
import { computed } from '@ember/object';
75

86
/*
97
* Utility method, returning a computed
@@ -23,6 +21,6 @@ export default function requiredProperty(propertyName) {
2321
assert('Property name is required for requiredProperty.', propertyName);
2422

2523
return computed(function() {
26-
throw new Ember.Error(`Definition of property ${propertyName} is required.`);
24+
throw new EmberError(`Definition of property ${propertyName} is required.`);
2725
});
2826
}

0 commit comments

Comments
 (0)