Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ? noop()
// : filter(path => !path.endsWith('-routing.module.ts.template')),
applyTemplates({
...strings,
'if-flat': (s: string) => (options.flat ? '' : s),
// lazyRoute: isLazyLoadedModuleGen,
// lazyRouteWithoutRouteModule: isLazyLoadedModuleGen && !routingModulePath,
// lazyRouteWithRouteModule: isLazyLoadedModuleGen && routingModulePath,
...options,
}),
move(parsedPath.path),
]);
return chain([
addRouteDeclarationToNgModule(options, routingModulePath),
mergeWith(templateSource),
]);
};
}
return host => {
if (!options.project) {
throw new schematics_1.SchematicsException('Option (project) is required.');
}
// tslint:disable:no-parameter-reassignment
options = common_1.detectExtension('extension', host, options);
options = common_1.applyNameAndPath('extension', host, options);
options = common_1.determineArtifactName('extension', host, options);
const operations = [];
operations.push(schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
schematics_1.template(Object.assign({}, core_1.strings, options)),
schematics_1.move(options.path),
])));
const projectRoot = project_1.buildDefaultPath(project_1.getProject(host, options.project));
const artifactName = core_1.strings.classify(options.name) + 'ExportsModule';
const moduleImportPath = `${projectRoot}/extensions/${core_1.strings.dasherize(options.name)}/exports/${core_1.strings.dasherize(options.name)}-exports.module`;
const sharedModuleOptions = {
module: `${projectRoot}/shared/shared.module.ts`,
artifactName,
moduleImportPath,
};
operations.push(registration_1.addExportToNgModule(sharedModuleOptions));
operations.push(registration_1.addImportToNgModule(sharedModuleOptions));
const appModuleOptions = {
module: `${projectRoot}/app.module.ts`,
artifactName,
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)
])
);
}
export function addFireBug(options: any): Rule {
const source = apply(url('../utils/firebug/files'), [
move(`${options.directory}/src/bootstrapScripts`)
]);
return chain([
mergeWith(source),
tree => {
addDependencyToPackageJson(tree, options, 'node-wget', '^0.4.2', true);
addDependencyToPackageJson(tree, options, 'decompress', '^4.2.0', true);
addDependencyToPackageJson(tree, options, 'decompress-targz', '^4.1.1', true);
},
tree => {
let indexContent = '';
if (tree.exists(`${options.directory}/src/bootstrapScripts/index.ts`)) {
indexContent = getFileContent(tree, `${options.directory}/src/bootstrapScripts/index.ts`);
}
createOrOverwriteFile(tree,`${options.directory}/src/bootstrapScripts/index.ts`, indexContent + 'export * from \'./firebug\';\n');
//find and overwrite environment files
createOrOverwriteFile(tree, `${options.directory}/src/environments/environment.firebug.ts`, getFileContent(tree, `${options.directory}/src/environments/environment.ts`));
return (tree: Tree, context: SchematicContext) => {
if (
tree.exists(`libs/core/base/base-component.ts`) ||
tree.exists(`libs/features/index.ts`)
) {
return noop();
}
return branchAndMerge(
mergeWith(
apply(url(`./_lib_files`), [
template({
...(options as any),
...getDefaultTemplateOptions()
}),
move('libs')
])
)
);
};
}
if (!project || !project.sourceRoot) {
throw new SchematicsException(`Project root could not be found`);
}
const sourceDir = normalize(project.sourceRoot);
const templateSource = apply(url('./files'), [
template({
options,
}),
move(sourceDir),
]);
context.logger.info(`✅️ Adding main.augury.ts...`);
return branchAndMerge(mergeWith(templateSource))(tree, context);
};
}
const e2eOptions = {
name: `${options.name}-e2e`,
relatedAppName: options.name,
rootSelector: appRootSelector,
};
if (options.projectRoot !== undefined) {
e2eOptions.projectRoot = 'e2e';
}
return schematics_1.chain([
addAppToWorkspaceFile(options, workspace),
options.skipPackageJson ? schematics_1.noop() : addDependenciesToPackageJson(),
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files/src'), [
schematics_1.template(Object.assign({ utils: core_1.strings }, options, { 'dot': '.', relativePathToWorkspaceRoot })),
schematics_1.move(sourceRoot),
])),
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files/root'), [
schematics_1.template(Object.assign({ utils: core_1.strings }, options, { 'dot': '.', relativePathToWorkspaceRoot,
rootInSrc })),
schematics_1.move(appDir),
])),
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files/lint'), [
schematics_1.template(Object.assign({ utils: core_1.strings }, options, { tsLintRoot,
relativePathToWorkspaceRoot,
prefix })),
])),
schematics_1.schematic('module', {
name: 'app',
commonModule: false,
flat: true,
routing: options.routing,
routingScope: 'Root',
path: sourceDir,
export function main(options: LibraryOptions): Rule {
options = transform(options);
return chain([
addLibraryToCliOptions(options.path, options.name),
updatePackageJson(options),
updateTsConfig(options.name, options.prefix, options.path),
branchAndMerge(mergeWith(generate(options))),
]);
}
return (host, context) => {
options.module = find_module_1.findModuleFromOptions(host, options);
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
schematics_1.template(Object.assign({}, stringUtils, { 'if-flat': (s) => options.flat ? '' : s }, options)),
schematics_1.move(sourceDir),
]);
return schematics_1.chain([
schematics_1.branchAndMerge(schematics_1.chain([
addDeclarationToNgModule(options),
schematics_1.mergeWith(templateSource),
])),
])(host, context);
};
}
function createFiles(options: NormalizedSchema): Rule {
return mergeWith(
apply(url(`./files/lib`), [
template({
...options,
...names(options.name),
tmpl: '',
offsetFromRoot: offsetFromRoot(options.projectRoot)
}),
move(options.projectRoot)
])
);
}