export function addFixesToServer()

in src/schematics/utils.ts [155:178]


export function addFixesToServer(host: Tree, options: { sourcePath: string, features: FEATURES[]}) {
  const serverPath = `/server.ts`;

  if (!host.exists(serverPath)) {
    return host;
  }

  const text = host.read(serverPath);
  if (text === null) {
    throw new SchematicsException(`File ${serverPath} does not exist.`);
  }
  const sourceText = text.toString('utf-8');
  const addZonePatch = !sourceText.includes('import \'zone.js/dist/zone-patch-rxjs\';');
  const addFirestorePatch = options.features.includes(FEATURES.Firestore) &&
    !sourceText.includes('import \'@angular/fire/firestore-protos\';');

  if (addZonePatch || addFirestorePatch) {
    overwriteIfExists(host, serverPath, sourceText.replace('import \'zone.js/dist/zone-node\';', `import 'zone.js/dist/zone-node';
${addZonePatch ? 'import \'zone.js/dist/zone-patch-rxjs\';' : ''}
${addFirestorePatch ? 'import \'@angular/fire/firestore-protos\';' : ''}`));
  }

  return host;
}