Skip to content
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

Ember CLI 3.0 upgrade #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions .bowerrc

This file was deleted.

14 changes: 0 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,8 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'app/**',
'addon/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
}
]
};
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
Expand All @@ -13,7 +13,8 @@
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
npm-debug.log*
yarn-error.log
testem.log
.idea/.name
.idea/ember-web-api.iml
Expand All @@ -22,3 +23,8 @@ testem.log
.idea/modules.xml
.idea/vcs.xml
.idea/workspace.xml

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

22 changes: 15 additions & 7 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
bower_components/
tests/
tmp/
dist/

/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.eslintrc.js
.gitignore
.watchmanconfig
.travis.yml
.npmignore
**/.gitkeep
bower.json
ember-cli-build.js
Brocfile.js
testem.json
testem.js

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
41 changes: 26 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,49 @@
---
language: node_js
node_js:
- "0.12"
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "4"

sudo: false
dist: trusty

addons:
chrome: stable

cache:
directories:
- node_modules
- $HOME/.npm

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-lts-2.18
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
- "npm config set spin false"
- "npm install -g npm@^2"
- npm config set spin false
- npm install -g npm@4
- npm --version
- mkdir coverage

install:
- npm install -g bower
- npm install
- bower install

script:
- ember try $EMBER_TRY_SCENARIO test
- npm run lint:js
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup

after_success:
- cat ./coverage/coverage.dat | ./node_modules/.bin/codecov
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015
Copyright (c) 2018

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
50 changes: 38 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,51 @@ That's it! Your application should now be configured to consume Web API endpoint
The Web API Adapter and Serializer both extend Ember Data's DS.RESTAdapter and DS.RESTSerializer and accept the same options.

## Contributing
------------------------------------------------------------------------------

## Installation
Installation
------------------------------------------------------------------------------

* `git clone` this repository
```
ember install my-addon
```


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

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


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

### Installation

* `git clone <repository-url>`
* `cd my-addon`
* `npm install`
* `bower install`

## Running
### Linting

* `npm run lint:js`
* `npm run lint:js -- --fix`

### Running tests

* `ember server`
* Visit your app at http://localhost:4200.
* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `npm test` – Runs `ember try:each` to test your addon against multiple Ember versions

## Running Tests
### Running the dummy application

* `ember test`
* `ember test --server`
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
>>>>>>> 1206dc0... message

## Building
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

* `ember build`
License
------------------------------------------------------------------------------

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
This project is licensed under the [MIT License](LICENSE.md).
4 changes: 2 additions & 2 deletions addon/adapters/web-api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
import DS from 'ember-data';
import { camelize } from '@ember/string';

const VALIDATION_ERROR_STATUSES = [400, 422];

Expand All @@ -25,7 +25,7 @@ export default DS.RESTAdapter.extend({

if (jsonIsObject && json.modelState) {
Object.keys(json.modelState).forEach(key => {
let newKey = Ember.String.camelize(key.substring(key.indexOf('.') + 1));
let newKey = camelize(key.substring(key.indexOf('.') + 1));
strippedErrors[newKey] = json.modelState[key];
});

Expand Down
10 changes: 6 additions & 4 deletions addon/serializers/web-api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Ember from 'ember';
import DS from 'ember-data';
import { A } from '@ember/array';
import { copy } from '@ember/object/internals';

export default DS.RESTSerializer.extend({
isNewSerializerAPI: true,
Expand All @@ -19,15 +21,15 @@ export default DS.RESTSerializer.extend({
if(isCollection) {
payload.forEach((item) => {
this._extractRelationships(store, payloadWithRoot, item, primaryModelClass);
item.attributes = Ember.copy(item, true);
item.attributes = copy(item, true);
if(item.type) {
item.type = primaryModelClass.modelName;
}
delete item.attributes.id;
});
} else {
this._extractRelationships(store, payloadWithRoot, payload, primaryModelClass);
payload.attributes = Ember.copy(payload, true);
payload.attributes = copy(payload, true);
if(payload.type) {
payload.type = primaryModelClass.modelName;
}
Expand Down Expand Up @@ -71,15 +73,15 @@ export default DS.RESTSerializer.extend({
}

let key = Ember.Inflector.inflector.pluralize(type.modelName),
arr = payload[key] || Ember.A([]),
arr = payload[key] || A([]),
pk = store.serializerFor(type.modelName).primaryKey,
id = record[pk];

if(typeof arr.findBy(pk, id) !== 'undefined') {
return true;
}

record.attributes = Ember.copy(record, true);
record.attributes = copy(record, true);
record.type = type.modelName;
delete record.attributes.id;

Expand Down
22 changes: 0 additions & 22 deletions bower.json

This file was deleted.

Loading