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`
|
`generate @nrwl/angular:storybook-configuration ${mylib} --configureCypress --generateStories --generateCypressSpecs --no-interactive`
|
||||||
);
|
);
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nrwl/storybook:configuration ${mylib} --no-interactive`
|
`generate @nrwl/angular:stories ${mylib} --generateCypressSpecs --no-interactive`
|
||||||
);
|
);
|
||||||
|
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
|
|||||||
@ -16,7 +16,11 @@ import {
|
|||||||
PropertyDeclaration,
|
PropertyDeclaration,
|
||||||
SyntaxKind
|
SyntaxKind
|
||||||
} from 'typescript';
|
} from 'typescript';
|
||||||
import { getTsSourceFile, getDecoratorMetadata } from '../../utils/ast-utils';
|
import {
|
||||||
|
getTsSourceFile,
|
||||||
|
getDecoratorMetadata,
|
||||||
|
applyWithSkipExisting
|
||||||
|
} from '../../utils/ast-utils';
|
||||||
import {
|
import {
|
||||||
getInputPropertyDeclarations,
|
getInputPropertyDeclarations,
|
||||||
getKnobType
|
getKnobType
|
||||||
@ -67,9 +71,7 @@ export function createComponentSpecFile({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
const componentSelector = getComponentSelector(tree, fullComponentPath);
|
const componentSelector = getComponentSelector(tree, fullComponentPath);
|
||||||
return chain([
|
return applyWithSkipExisting(url('./files'), [
|
||||||
mergeWith(
|
|
||||||
apply(url('./files'), [
|
|
||||||
template({
|
template({
|
||||||
projectName,
|
projectName,
|
||||||
componentFileName: componentFileName,
|
componentFileName: componentFileName,
|
||||||
@ -79,8 +81,6 @@ export function createComponentSpecFile({
|
|||||||
tmpl: ''
|
tmpl: ''
|
||||||
}),
|
}),
|
||||||
move(e2eLibIntegrationFolderPath + '/' + componentPath)
|
move(e2eLibIntegrationFolderPath + '/' + componentPath)
|
||||||
])
|
|
||||||
)
|
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import {
|
|||||||
} from '@angular-devkit/schematics';
|
} from '@angular-devkit/schematics';
|
||||||
import { findNodes } from '@nrwl/workspace';
|
import { findNodes } from '@nrwl/workspace';
|
||||||
import { PropertyDeclaration, SyntaxKind } from 'typescript';
|
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';
|
import { getSourceNodes } from '@nrwl/workspace/src/utils/ast-utils';
|
||||||
|
|
||||||
export interface CreateComponentStoriesFileSchema {
|
export interface CreateComponentStoriesFileSchema {
|
||||||
@ -48,9 +48,7 @@ export function createComponentStoriesFile({
|
|||||||
tree,
|
tree,
|
||||||
libPath + '/' + componentPath + '/' + componentFileName + '.ts'
|
libPath + '/' + componentPath + '/' + componentFileName + '.ts'
|
||||||
);
|
);
|
||||||
return chain([
|
return applyWithSkipExisting(url('./files'), [
|
||||||
mergeWith(
|
|
||||||
apply(url('./files'), [
|
|
||||||
template({
|
template({
|
||||||
componentFileName: componentFileName,
|
componentFileName: componentFileName,
|
||||||
componentName: componentName,
|
componentName: componentName,
|
||||||
@ -60,8 +58,6 @@ export function createComponentStoriesFile({
|
|||||||
tmpl: ''
|
tmpl: ''
|
||||||
}),
|
}),
|
||||||
move(libPath + '/' + componentPath)
|
move(libPath + '/' + componentPath)
|
||||||
])
|
|
||||||
)
|
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,16 @@ import {
|
|||||||
InsertChange,
|
InsertChange,
|
||||||
RemoveChange
|
RemoveChange
|
||||||
} from '@nrwl/workspace/src/utils/ast-utils';
|
} 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 * as path from 'path';
|
||||||
import { toFileName } from '@nrwl/workspace/src/utils/name-utils';
|
import { toFileName } from '@nrwl/workspace/src/utils/name-utils';
|
||||||
|
|
||||||
@ -647,3 +656,21 @@ export function getTsSourceFile(host: Tree, path: string): ts.SourceFile {
|
|||||||
|
|
||||||
return source;
|
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