Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should update `angular.json` file', async () => {
const tree = await runSchematic(
'cypress-project',
{ name: 'test-ui-lib' },
appTree
);
const project = getProjectConfig(tree, 'test-ui-lib-e2e');
expect(project.architect.e2e.options.devServerTarget).toEqual(
'test-ui-lib:storybook'
);
expect(project.architect.e2e.options.headless).toBeUndefined();
expect(project.architect.e2e.options.watch).toBeUndefined();
expect(project.architect.e2e.configurations.headless).toBeUndefined();
});
});
return (host: Tree) => {
const projectConfig = getProjectConfig(host, options.project);
if (projectConfig.architect.test) {
throw new Error(
`${options.project} already has a test architect option.`
);
}
};
}
return (tree: Tree, context: SchematicContext) => {
context.logger.debug('adding .storybook folder to lib');
const libPath = getProjectConfig(tree, projectName).sourceRoot + '/lib';
return chain(
tree
.getDir(libPath)
.subfiles.filter(fileName => fileName.endsWith('.module.ts'))
.map(fileName => {
const filePath = libPath + '/' + fileName;
const file = getTsSourceFile(tree, filePath);
const ngModuleDecorators = getDecoratorMetadata(
file,
'NgModule',
'@angular/core'
);
if (ngModuleDecorators.length === 0) {
throw new SchematicsException(
`No @NgModule decorator in ${filePath}`
return (tree: Tree, context: SchematicContext) => {
context.logger.debug('adding .storybook folder to lib');
const projectConfig = getProjectConfig(tree, projectName);
return chain([
applyWithSkipExisting(url('./lib-files'), [
template({
tmpl: '',
uiFramework,
offsetFromRoot: offsetFromRoot(projectConfig.root)
}),
move(projectConfig.root)
])
])(tree, context);
};
}
return (host: Tree, context: SchematicContext) => {
const projectConfig = getProjectConfig(host, options.name);
return updateJsonInTree(`${projectConfig.root}/tsconfig.json`, json => {
json.compilerOptions.types.push('jest');
return json;
});
};
}
return (tree: Tree) => {
const projectPath = getProjectConfig(tree, projectName).root;
const tsConfigPath = projectPath + '/tsconfig.lib.json';
const projectTsConfig = parseJsonAtPath(tree, tsConfigPath);
let tsConfigContent: any;
if (projectTsConfig && projectTsConfig.value) {
tsConfigContent = projectTsConfig.value;
} else {
return tree;
}
tsConfigContent.exclude = [...tsConfigContent.exclude, '**/*.stories.ts'];
tree.overwrite(
tsConfigPath,
JSON.stringify(tsConfigContent, null, 2) + '\n'
return (host: Tree) => {
const projectConfig = getProjectConfig(host, options.project);
return updateJsonInTree(join(projectConfig.root, 'tsconfig.json'), json => {
return {
...json,
compilerOptions: {
...json.compilerOptions,
types: Array.from(
new Set([...(json.compilerOptions.types || []), 'jasmine'])
)
}
};
});
};
}
return (host: Tree) => {
const projectConfig = getProjectConfig(host, options.project);
if (!host.exists(join(projectConfig.root, 'tsconfig.json'))) {
throw new Error(
`Expected ${join(
projectConfig.root,
'tsconfig.json'
)} to exist. Please create one.`
);
}
return updateJsonInTree(join(projectConfig.root, 'tsconfig.json'), json => {
return {
...json,
compilerOptions: {
...json.compilerOptions,
types: Array.from(
new Set([...(json.compilerOptions.types || []), 'node', 'jest'])
)