2019-04-03 21:06:20 +00:00
|
|
|
'use strict';
|
|
|
|
const getPathOption = require('ember-cli-get-component-path-option');
|
|
|
|
const stringUtil = require('ember-cli-string-utils');
|
2019-08-01 21:04:59 +00:00
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
function findAddonByName(addonOrProject, name) {
|
|
|
|
let addon = addonOrProject.addons.find(addon => addon.name === name);
|
|
|
|
|
|
|
|
if (addon) {
|
|
|
|
return addon;
|
|
|
|
}
|
|
|
|
|
|
|
|
return addonOrProject.addons.find(addon => findAddonByName(addon, name));
|
|
|
|
}
|
2019-04-03 21:06:20 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
description: 'generates a story for storybook',
|
|
|
|
|
|
|
|
fileMapTokens: function() {
|
2019-08-01 21:04:59 +00:00
|
|
|
let { project } = this;
|
2019-04-03 21:06:20 +00:00
|
|
|
return {
|
2019-08-01 21:04:59 +00:00
|
|
|
__path__: function(options) {
|
|
|
|
if (options.inRepoAddon) {
|
|
|
|
let addon = findAddonByName(project, options.inRepoAddon);
|
|
|
|
return path.relative(project.root, addon.root);
|
|
|
|
}
|
|
|
|
return path.relative(project.root, project.root);
|
|
|
|
},
|
2019-04-03 21:06:20 +00:00
|
|
|
__markdownname__: function(options) {
|
|
|
|
return options.dasherizedModuleName;
|
|
|
|
},
|
|
|
|
__name__: function(options) {
|
|
|
|
return options.dasherizedModuleName;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
locals: function(options) {
|
|
|
|
let contents = '';
|
|
|
|
|
|
|
|
return {
|
|
|
|
contents: contents,
|
|
|
|
path: getPathOption(options),
|
|
|
|
header: stringUtil
|
|
|
|
.dasherize(options.entity.name)
|
|
|
|
.split('-')
|
|
|
|
.map(word => stringUtil.capitalize(word))
|
|
|
|
.join(' '),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|