fix(nx): skip existing stories and cypress specs
This commit is contained in:
parent
1d3884bd45
commit
ac33f049b2
@ -76,7 +76,7 @@ forEachCli(() => {
|
||||
`generate @nrwl/angular:storybook-configuration ${mylib} --configureCypress --generateStories --generateCypressSpecs --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nrwl/storybook:configuration ${mylib} --no-interactive`
|
||||
`generate @nrwl/angular:stories ${mylib} --generateCypressSpecs --no-interactive`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
|
||||
@ -16,7 +16,11 @@ import {
|
||||
PropertyDeclaration,
|
||||
SyntaxKind
|
||||
} from 'typescript';
|
||||
import { getTsSourceFile, getDecoratorMetadata } from '../../utils/ast-utils';
|
||||
import {
|
||||
getTsSourceFile,
|
||||
getDecoratorMetadata,
|
||||
applyWithSkipExisting
|
||||
} from '../../utils/ast-utils';
|
||||
import {
|
||||
getInputPropertyDeclarations,
|
||||
getKnobType
|
||||
@ -67,9 +71,7 @@ export function createComponentSpecFile({
|
||||
}
|
||||
);
|
||||
const componentSelector = getComponentSelector(tree, fullComponentPath);
|
||||
return chain([
|
||||
mergeWith(
|
||||
apply(url('./files'), [
|
||||
return applyWithSkipExisting(url('./files'), [
|
||||
template({
|
||||
projectName,
|
||||
componentFileName: componentFileName,
|
||||
@ -79,8 +81,6 @@ export function createComponentSpecFile({
|
||||
tmpl: ''
|
||||
}),
|
||||
move(e2eLibIntegrationFolderPath + '/' + componentPath)
|
||||
])
|
||||
)
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import {
|
||||
} from '@angular-devkit/schematics';
|
||||
import { findNodes } from '@nrwl/workspace';
|
||||
import { PropertyDeclaration, SyntaxKind } from 'typescript';
|
||||
import { getTsSourceFile } from '../../utils/ast-utils';
|
||||
import { getTsSourceFile, applyWithSkipExisting } from '../../utils/ast-utils';
|
||||
import { getSourceNodes } from '@nrwl/workspace/src/utils/ast-utils';
|
||||
|
||||
export interface CreateComponentStoriesFileSchema {
|
||||
@ -48,9 +48,7 @@ export function createComponentStoriesFile({
|
||||
tree,
|
||||
libPath + '/' + componentPath + '/' + componentFileName + '.ts'
|
||||
);
|
||||
return chain([
|
||||
mergeWith(
|
||||
apply(url('./files'), [
|
||||
return applyWithSkipExisting(url('./files'), [
|
||||
template({
|
||||
componentFileName: componentFileName,
|
||||
componentName: componentName,
|
||||
@ -60,8 +58,6 @@ export function createComponentStoriesFile({
|
||||
tmpl: ''
|
||||
}),
|
||||
move(libPath + '/' + componentPath)
|
||||
])
|
||||
)
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
||||
@ -8,7 +8,16 @@ import {
|
||||
InsertChange,
|
||||
RemoveChange
|
||||
} from '@nrwl/workspace/src/utils/ast-utils';
|
||||
import { Tree, SchematicsException } from '@angular-devkit/schematics';
|
||||
import {
|
||||
Tree,
|
||||
SchematicsException,
|
||||
Source,
|
||||
Rule,
|
||||
SchematicContext,
|
||||
mergeWith,
|
||||
apply,
|
||||
forEach
|
||||
} from '@angular-devkit/schematics';
|
||||
import * as path from 'path';
|
||||
import { toFileName } from '@nrwl/workspace/src/utils/name-utils';
|
||||
|
||||
@ -647,3 +656,21 @@ export function getTsSourceFile(host: Tree, path: string): ts.SourceFile {
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
export function applyWithSkipExisting(source: Source, rules: Rule[]): Rule {
|
||||
return (tree: Tree, _context: SchematicContext) => {
|
||||
const rule = mergeWith(
|
||||
apply(source, [
|
||||
...rules,
|
||||
forEach(fileEntry => {
|
||||
if (tree.exists(fileEntry.path)) {
|
||||
return null;
|
||||
}
|
||||
return fileEntry;
|
||||
})
|
||||
])
|
||||
);
|
||||
|
||||
return rule(tree, _context);
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user