How to use the @nestjs/schematics/utils/module.finder.ModuleFinder function in @nestjs/schematics

To help you get started, we’ve selected a few @nestjs/schematics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devonfw / devon4node / packages / schematics / src / lib / init-typeorm / init-typeorm.factory.ts View on Github external
return (tree: Tree): Tree => {
    const module = new ModuleFinder(tree).find({
      name: 'core',
      path: join('.' as Path, project || '.', 'src/app/core/') as Path,
    });
    if (!module) {
      return tree;
    }

    const config = existsConfigModule(tree, project || '.');

    let fileContent: string | undefined = tree.read(module)!.toString('utf-8');

    if (fileContent!.includes('TypeOrmModule.forRoot')) {
      return tree;
    }

    if (!config) {
github devonfw / devon4node / packages / schematics / src / lib / entity / entity.factory.ts View on Github external
return (tree: Tree) => {
    const modulePosiblePath = join(options.path! as Path, '../..');
    const moduleName = strings.classify(basename(modulePosiblePath) + '-module');

    const module = new ModuleFinder(tree).find({
      name: moduleName,
      path: modulePosiblePath,
    });
    if (!module) {
      return tree;
    }

    let content = tree.read(module)!.toString();

    content = addImports(content, strings.classify(options.name), './model');
    content = addImports(content, 'TypeOrmModule', '@nestjs/typeorm');

    tree.overwrite(
      module,
      formatTsFile(addTypeormFeatureToModule(content, moduleName, strings.classify(options.name))),
    );
github devonfw / devon4node / packages / schematics / src / lib / mailer / mailer.factory.ts View on Github external
function addMailerToCoreModule(path: string, tree: Tree, existsConfig: boolean) {
  const core = new ModuleFinder(tree).find({
    name: 'core',
    path: join(path as Path, 'src/app/core') as Path,
  });
  if (!core) {
    return;
  }

  let coreContent: string | undefined = tree.read(core)!.toString();

  if (coreContent.includes('MailerModule')) {
    return;
  }

  if (existsConfig) {
    coreContent = addImports(coreContent, 'ConfigurationService', './configuration/services');
    coreContent = addToModuleDecorator(
github devonfw / devon4node / packages / schematics / src / utils / tree-utils.ts View on Github external
export function existsConfigModule(tree: Tree, path: string): boolean {
  const config = new ModuleFinder(tree).find({
    name: 'configuration',
    path: join('.' as Path, path || '.', 'src/app/core/configuration') as Path,
  });

  return !!config && basename(config) === 'configuration.module.ts';
}
github devonfw / devon4node / packages / schematics / src / lib / devon4node-application / devon4node-application.factory.ts View on Github external
return (tree: Tree) => {
    const module = new ModuleFinder(tree).find({
      name: 'app',
      path: (project + '/src/app/') as Path,
    });
    if (!module) {
      return tree;
    }

    const fileContent = addToModuleDecorator(
      tree.read(module)!.toString('utf-8'),
      'AppModule',
      './core/core.module',
      'CoreModule',
      'imports',
      false,
    );
github devonfw / devon4node / packages / schematics / src / lib / controller / controller.factory.ts View on Github external
return (tree: Tree): Tree => {
    const moduleName = strings.classify(basename(modulePath as Path) + '-module');
    const module = new ModuleFinder(tree).find({
      name: basename(modulePath as Path),
      path: modulePath as Path,
    });
    if (!module) {
      return tree;
    }

    const fileContent = addToModuleDecorator(
      tree.read(module)!.toString('utf-8'),
      moduleName,
      './controllers',
      strings.classify(controllerName) + 'Controller',
      'controllers',
      false,
    );
github devonfw / devon4node / packages / schematics / src / lib / auth-jwt / auth.factory.ts View on Github external
return (tree: Tree): Tree => {
    const module = new ModuleFinder(tree).find({
      name: 'core',
      path: join('.' as Path, project || '.', 'src/app/core/') as Path,
    });
    if (!module) {
      return tree;
    }

    let fileContent = addToModuleDecorator(
      tree.read(module)!.toString('utf-8'),
      'CoreModule',
      './auth/auth.module',
      'AuthModule',
      'imports',
      true,
    );
github devonfw / devon4node / packages / schematics / src / lib / crud / crud.factory.ts View on Github external
return (tree: Tree): Tree => {
    const moduleName = strings.classify(basename(modulePath as Path) + '-module');
    const module = new ModuleFinder(tree).find({
      name: basename(modulePath as Path),
      path: modulePath as Path,
    });
    if (!module) {
      return tree;
    }

    let fileContent = addToModuleDecorator(
      tree.read(module)!.toString('utf-8'),
      moduleName,
      './services',
      strings.classify(crudName) + 'CrudService',
      'providers',
      false,
    );
github devonfw / devon4node / packages / schematics / src / lib / service / service.factory.ts View on Github external
return (tree: Tree): Tree => {
    const moduleName = strings.classify(basename(modulePath as Path) + '-module');
    const module = new ModuleFinder(tree).find({
      name: basename(modulePath as Path),
      path: modulePath as Path,
    });
    if (!module) {
      return tree;
    }

    const fileContent = addToModuleDecorator(
      tree.read(module)!.toString('utf-8'),
      moduleName,
      './services',
      strings.classify(serviceName) + 'Service',
      'providers',
      false,
    );

@nestjs/schematics

Nest - modern, fast, powerful node.js web framework (@schematics)

MIT
Latest version published 2 months ago

Package Health Score

92 / 100
Full package analysis

Popular @nestjs/schematics functions

Similar packages