How to use the @ngrx/data/schematics-core.insertImport function in @ngrx/data

To help you get started, we’ve selected a few @ngrx/data 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 ngrx / platform / modules / data / schematics / ng-add / index.ts View on Github external
const modulePath = options.module!;
    const text = host.read(modulePath)!.toString();

    const source = ts.createSourceFile(
      modulePath,
      text,
      ts.ScriptTarget.Latest,
      true
    );

    const moduleToImport = options.effects
      ? 'EntityDataModule'
      : 'EntityDataModuleWithoutEffects';

    const effectsModuleImport = insertImport(
      source,
      modulePath,
      moduleToImport,
      '@ngrx/data'
    );

    const [dateEntityNgModuleImport] = addImportToModule(
      source,
      modulePath,
      options.entityConfig
        ? [moduleToImport, 'forRoot(entityConfig)'].join('.')
        : moduleToImport,
      ''
    );

    const changes = [effectsModuleImport, dateEntityNgModuleImport];
github ngrx / platform / modules / data / schematics / ng-add / index.ts View on Github external
'@ngrx/data'
    );

    const [dateEntityNgModuleImport] = addImportToModule(
      source,
      modulePath,
      options.entityConfig
        ? [moduleToImport, 'forRoot(entityConfig)'].join('.')
        : moduleToImport,
      ''
    );

    const changes = [effectsModuleImport, dateEntityNgModuleImport];

    if (options.entityConfig) {
      const entityConfigImport = insertImport(
        source,
        modulePath,
        'entityConfig',
        './entity-metadata'
      );
      changes.push(entityConfigImport);
    }

    commitChanges(host, source.fileName, changes);

    return host;
  };
}