fix(storybook): find any module file
This commit is contained in:
parent
e2b8406692
commit
c2bac02420
@ -32,6 +32,11 @@ describe('schematic:stories', () => {
|
||||
'libs/test-ui-lib/src/lib/test-other/test-other.component.stories.ts'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
'libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.stories.ts'
|
||||
)
|
||||
).toBeTruthy();
|
||||
const propLines = [
|
||||
`buttonType: text('buttonType', 'button'),`,
|
||||
`style: text('style', 'default'),`,
|
||||
@ -137,6 +142,23 @@ export async function createTestUILib(libName: string): Promise<Tree> {
|
||||
`import * as ButtonExports from './test-button/test-button.component';
|
||||
${appTree.read(modulePath)}`
|
||||
);
|
||||
appTree = await callRule(
|
||||
externalSchematic('@schematics/angular', 'module', {
|
||||
name: 'nested',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib`
|
||||
}),
|
||||
appTree
|
||||
);
|
||||
appTree = await callRule(
|
||||
externalSchematic('@schematics/angular', 'component', {
|
||||
name: 'nested-button',
|
||||
project: libName,
|
||||
module: 'nested',
|
||||
path: `libs/${libName}/src/lib/nested`
|
||||
}),
|
||||
appTree
|
||||
);
|
||||
appTree.overwrite(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.ts`,
|
||||
`
|
||||
|
||||
@ -29,12 +29,15 @@ export function createAllStories(
|
||||
context.logger.debug('adding .storybook folder to lib');
|
||||
|
||||
const libPath = getProjectConfig(tree, projectName).sourceRoot + '/lib';
|
||||
let moduleFilePaths = [] as string[];
|
||||
tree.getDir(libPath).visit(filePath => {
|
||||
if (!filePath.endsWith('.module.ts')) {
|
||||
return;
|
||||
}
|
||||
moduleFilePaths.push(filePath);
|
||||
});
|
||||
return chain(
|
||||
tree
|
||||
.getDir(libPath)
|
||||
.subfiles.filter(fileName => fileName.endsWith('.module.ts'))
|
||||
.map(fileName => {
|
||||
const filePath = libPath + '/' + fileName;
|
||||
moduleFilePaths.map(filePath => {
|
||||
const file = getTsSourceFile(tree, filePath);
|
||||
|
||||
const ngModuleDecorators = getDecoratorMetadata(
|
||||
@ -113,26 +116,24 @@ export function createAllStories(
|
||||
}
|
||||
});
|
||||
|
||||
const modulePath = filePath.substr(0, filePath.lastIndexOf('/'));
|
||||
return chain(
|
||||
componentInfo
|
||||
.filter(info => info !== undefined)
|
||||
.map(info =>
|
||||
chain([
|
||||
schematic<CreateComponentStoriesFileSchema>(
|
||||
'component-story',
|
||||
{
|
||||
libPath,
|
||||
schematic<CreateComponentStoriesFileSchema>('component-story', {
|
||||
libPath: modulePath,
|
||||
componentName: info.name,
|
||||
componentPath: info.path,
|
||||
componentFileName: info.componentFileName
|
||||
}
|
||||
),
|
||||
}),
|
||||
generateCypressSpecs
|
||||
? schematic<CreateComponentSpecFileSchema>(
|
||||
'component-cypress-spec',
|
||||
{
|
||||
projectName,
|
||||
libPath,
|
||||
libPath: modulePath,
|
||||
componentName: info.name,
|
||||
componentPath: info.path,
|
||||
componentFileName: info.componentFileName
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user