open-vault/ui/blueprints/story/index.js
Matthew Irish 29a85fa1c5
UI kmip acceptance (#7129)
* change the story blueprint so that using -ir will generate a story in the expected place for in-repo addons and engines

* update gen-story-md script to do output md to stories folder inside of in-repo addons and engines

* update storybook config to look for story files in /lib

* add story for list-view component

* add list view page object

* add kmip page objects and tests

* update storybook commands in the README

* split tests up more

* update var name in storybook
2019-08-01 16:04:59 -05:00

54 lines
1.4 KiB
JavaScript

'use strict';
const getPathOption = require('ember-cli-get-component-path-option');
const stringUtil = require('ember-cli-string-utils');
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));
}
module.exports = {
description: 'generates a story for storybook',
fileMapTokens: function() {
let { project } = this;
return {
__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);
},
__markdownname__: function(options) {
return options.dasherizedModuleName;
},
__name__: function(options) {
return options.dasherizedModuleName;
},
};
},
locals: function(options) {
let contents = '';
let importMD = "import notes from './" + stringUtil.dasherize(options.entity.name) + ".md';\n";
return {
importMD: importMD,
contents: contents,
path: getPathOption(options),
header: stringUtil
.dasherize(options.entity.name)
.split('-')
.map(word => stringUtil.capitalize(word))
.join(' '),
};
},
};