Skip to content

Commit 8f0a618

Browse files
authored
Conditional use of addon-import blueprint via jsonapi-resource generator (#102)
* Add condition for use of addon-import blueprint via jsonapi-resource generator * Remove sleep dependency breaks build
1 parent f287f9f commit 8f0a618

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ To run the app in /tests/dummy use a proxy url for a live API
4747
* `ember test --server`
4848
* `ember test --server -m 'Unit | Mixin | service cache'`
4949
* `ember test --server --filter 'cacheUpdate'`
50+
* `npm run nodetest` tests for blueprint, e.g. `jsonapi-resource`
5051

5152
A good way to get to know more about how this addon works is to review the tests,
5253
see source code for the unit tests: [tests/unit](tests/unit).

blueprints/jsonapi-model/files/__root__/__path__/__name__.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import Ember from 'ember';
22
import Resource from 'ember-jsonapi-resources/models/resource';
33
import { attr, hasOne, hasMany } from 'ember-jsonapi-resources/models/resource';
44

5-
let <%= classifiedModuleName %> = Resource.extend({
5+
let <%= classifiedModuleName %>Model = Resource.extend({
66
type: '<%= resource %>',
77
service: Ember.inject.service('<%= resource %>'),
88

99
<%= attrs %>
1010
});
1111

12-
<%= classifiedModuleName %>.reopenClass({
12+
<%= classifiedModuleName %>Model.reopenClass({
1313

1414
getDefaults() {
1515
return {
@@ -18,4 +18,4 @@ let <%= classifiedModuleName %> = Resource.extend({
1818
}
1919
});
2020

21-
export default <%= classifiedModuleName %>;
21+
export default <%= classifiedModuleName %>Model;

blueprints/jsonapi-resource/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,21 @@ module.exports = {
5757
var modelOptions = merge({}, options, {
5858
entity: {
5959
name: entityName ? inflection.singularize(entityName) : ''
60-
}
60+
},
61+
originBlueprintName: 'jsonapi-model'
6162
});
6263

6364
var otherOptions = merge({}, options);
64-
65-
return Promise.all([
65+
var promises = [
6666
this._processBlueprint(type, 'jsonapi-model', modelOptions),
6767
this._processBlueprint(type, 'jsonapi-adapter', otherOptions),
6868
this._processBlueprint(type, 'jsonapi-serializer', otherOptions),
6969
this._processBlueprint(type, 'jsonapi-service', otherOptions),
7070
this._processBlueprint(type, 'jsonapi-initializer', otherOptions)
71-
]);
71+
];
72+
if (!!options.project.pkg['ember-addon']) {
73+
promies.push( this._processBlueprint(type, 'addon-import', modelOptions) );
74+
}
75+
return Promise.all(promises);
7276
}
7377
};

0 commit comments

Comments
 (0)