var stringUtil = require('ember-cli-string-utils');
var SilentError = require('silent-error');
var pathUtil = require('ember-cli-path-utils');
module.exports = {
description: 'Generates an ember-data adapter.',
availableOptions: [
{ name: 'base-class', type: String }
],
locals: function(options) {
var adapterName = options.entity.name;
var baseClass = 'JSONAPIAdapter';
var importStatement = 'import JSONAPIAdapter from \'ember-data/adapters/json-api\';';
var isAddon = options.inRepoAddon || options.project.isEmberCLIAddon();
var relativePath = pathUtil.getRelativePath(options.entity.name);
if (options.pod && options.podPath) {
relativePath = pathUtil.getRelativePath(options.podPath + options.entity.name);
}
if (!isAddon && !options.baseClass && adapterName !== 'application') {
options.baseClass = 'application';
}
if (options.baseClass === adapterName) {
throw new SilentError('Adapters cannot extend from themself. To resolve this, remove the `--base-class` option or change to a different base-class.');
}
if (options.baseClass) {
baseClass = stringUtil.classify(options.baseClass.replace('/', '-'));
baseClass = baseClass + 'Adapter';
importStatement = 'import ' + baseClass + ' from \'' + relativePath + options.baseClass + '\';';
}
return {
importStatement: importStatement,
baseClass: baseClass
};
}
};
# |
Change |
User |
Description |
Committed |
|
#1
|
23539 |
jenbottom |
Adding the basic code for ember test appk, created with 'ember new' command |
|
|