Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (): Rule => {
// host.delete(`${options.projectRoot}/tsconfig.e2e.json`);
return mergeWith(
apply(url('./files'), [
template({
tmpl: '',
...options,
offsetFromRoot: offsetFromRoot(options.projectRoot)
}),
move(options.projectRoot)
])
);
};
}
options.projectDirectory
}').then(module => module.${options.moduleName})}`
)
]);
const tsConfig = findClosestTsConfigApp(host, options.parentModule);
if (tsConfig) {
const tsConfigAppSource = host.read(tsConfig)!.toString('utf-8');
const tsConfigAppFile = ts.createSourceFile(
tsConfig,
tsConfigAppSource,
ts.ScriptTarget.Latest,
true
);
const offset = offsetFromRoot(path.dirname(tsConfig));
insert(host, tsConfig, [
...addIncludeToTsConfig(
tsConfig,
tsConfigAppFile,
`\n , "${offset}${options.projectRoot}/src/index.ts"\n`
)
]);
} else {
// we should warn the user about not finding the config
}
return host;
};
}
function createApplicationFiles(options: NormalizedSchema): Rule {
return mergeWith(
apply(url(`./files`), [
template({
...names(options.name),
...options,
tmpl: '',
offsetFromRoot: offsetFromRoot(options.appProjectRoot)
}),
options.styledModule
? filter(file => !file.endsWith(`.${options.style}`))
: noop(),
options.unitTestRunner === 'none'
? filter(file => file !== `/specs/index.spec.tsx`)
: noop(),
move(options.appProjectRoot)
])
);
}
function createApplicationFiles(options: NormalizedSchema): Rule {
return mergeWith(
apply(url(`./files/app`), [
template({
...options,
...names(options.name),
tmpl: '',
offsetFromRoot: offsetFromRoot(options.appProjectRoot)
}),
options.unitTestRunner === 'none'
? filter(file => file !== '/src/app/app.spec.ts')
: noop(),
move(options.appProjectRoot)
])
);
}
function createTsconfigSpecJson(host: Tree, project: any) {
const files = ['src/test.ts'];
const offset = offsetFromRoot(project.root);
const compilerOptions = {
outDir: `${offset}dist/out-tsc/${project.root}`,
types: ['jasmine', 'node']
};
if (project.projectType === 'application') {
files.push('src/polyfills.ts');
compilerOptions['module'] = 'commonjs';
}
createOrUpdate(
host,
`${project.root}/tsconfig.spec.json`,
serializeJson({
extends: `${offset}tsconfig.json`,
function createFiles(options: NormalizedSchema): Rule {
return mergeWith(
apply(url(`./files/lib`), [
template({
...options,
...names(options.name),
tmpl: '',
offsetFromRoot: offsetFromRoot(options.projectRoot)
}),
move(options.projectRoot),
options.publishable
? noop()
: filter(file => !file.endsWith('package.json'))
])
);
}
updateJsonInTree(`${options.e2eProjectRoot}/tsconfig.e2e.json`, json => {
return {
...json,
extends: `./tsconfig.json`,
compilerOptions: {
...json.compilerOptions,
outDir: `${offsetFromRoot(options.e2eProjectRoot)}dist/out-tsc`
}
};
})
]);
function createFiles(options: NormalizedSchema): Rule {
return mergeWith(
apply(url(`./files/lib`), [
template({
...options,
...names(options.name),
tmpl: '',
offsetFromRoot: offsetFromRoot(options.projectRoot)
}),
move(options.projectRoot)
])
);
}
return (host, context) => {
const projectConfig = getProjectConfig(host, options.project);
return mergeWith(
apply(url('./files'), [
template({
tmpl: '',
...options,
projectRoot: projectConfig.root,
isLibrary: projectConfig.projectType === 'library',
offsetFromRoot: offsetFromRoot(projectConfig.root)
}),
move(projectConfig.root)
])
)(host, context);
};
}
function addSchematicFiles(
appProjectRoot: string,
options: NormalizedSchema
): Rule {
return chain([
host => host.delete(`${appProjectRoot}/src/favicon.ico`),
mergeWith(
apply(url('./files'), [
template({
...options,
offsetFromRoot: offsetFromRoot(options.appProjectRoot)
}),
move(options.appProjectRoot)
])
)
]);
}