Skip to content

Commit

Permalink
fix(storybook): remove ng module import from angular stories (#2399)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Jan 30, 2020
1 parent 3ef75b8 commit 05dbcef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
16 changes: 0 additions & 16 deletions packages/angular/src/schematics/component-story/component-story.ts
@@ -1,7 +1,5 @@
import {
apply,
chain,
mergeWith,
move,
Rule,
SchematicContext,
Expand All @@ -16,8 +14,6 @@ import { getSourceNodes } from '@nrwl/workspace/src/utils/ast-utils';

export interface CreateComponentStoriesFileSchema {
libPath: string;
moduleFileName: string;
ngModuleClassName: string;
componentName: string;
componentPath: string;
componentFileName: string;
Expand All @@ -29,21 +25,11 @@ export default function(schema: CreateComponentStoriesFileSchema): Rule {

export function createComponentStoriesFile({
libPath,
moduleFileName,
ngModuleClassName,
componentName,
componentPath,
componentFileName
}: CreateComponentStoriesFileSchema): Rule {
return (tree: Tree, context: SchematicContext): Rule => {
const relativeModulePath =
componentPath
.split('/')
.filter(segment => segment !== '.')
.map(() => '..')
.join('/') +
'/' +
moduleFileName.replace(/\.ts$/, '');
const props = getInputDescriptors(
tree,
libPath + '/' + componentPath + '/' + componentFileName + '.ts'
Expand All @@ -52,8 +38,6 @@ export function createComponentStoriesFile({
template({
componentFileName: componentFileName,
componentName: componentName,
relativeModulePath,
moduleName: ngModuleClassName,
props,
tmpl: ''
}),
Expand Down
@@ -1,5 +1,4 @@
<% if(props.length > 0) { %>import { text, number, boolean } from '@storybook/addon-knobs';<% } %>
import { <%=moduleName%> } from '<%=relativeModulePath%>';
import { <%=componentName%> } from './<%=componentFileName%>';

export default {
Expand Down
6 changes: 4 additions & 2 deletions packages/angular/src/schematics/component-story/schema.json
Expand Up @@ -11,12 +11,14 @@
"moduleFileName": {
"type": "string",
"description": "File name of the module that declares this component",
"examples": ["ui-samples.module.ts"]
"examples": ["ui-samples.module.ts"],
"x-deprecated": true
},
"ngModuleClassName": {
"type": "string",
"description": "Class name of the module that declares this component",
"examples": ["UiSamplesModule"]
"examples": ["UiSamplesModule"],
"x-deprecated": true
},
"componentName": {
"type": "string",
Expand Down

0 comments on commit 05dbcef

Please sign in to comment.