From 626a56f6139e01376c7ac4656e21eb8000ed28d3 Mon Sep 17 00:00:00 2001 From: James Daniels Date: Tue, 14 May 2024 11:42:14 -0400 Subject: [PATCH] ng-add providers --- src/schematics/setup/index.ts | 4 ++-- src/schematics/utils.ts | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/schematics/setup/index.ts b/src/schematics/setup/index.ts index cf882e610..4cf04bb37 100644 --- a/src/schematics/setup/index.ts +++ b/src/schematics/setup/index.ts @@ -2,7 +2,7 @@ import { writeFileSync } from 'fs'; import { join } from 'path'; import { asWindowsPath, normalize } from '@angular-devkit/core'; import { SchematicContext, SchematicsException, Tree, chain } from '@angular-devkit/schematics'; -import { addRootImport } from '@schematics/angular/utility'; +import { addRootProvider } from '@schematics/angular/utility'; import { generateFirebaseRc, overwriteIfExists, @@ -64,7 +64,7 @@ export const setupProject = const featuresToImport = features.filter(it => it !== FEATURES.Hosting); if (featuresToImport.length > 0) { return chain([ - addRootImport(projectName, ({code, external}) => { + addRootProvider(projectName, ({code, external}) => { external('initializeApp', '@angular/fire/app'); return code`${external('provideFirebaseApp', '@angular/fire/app')}(() => initializeApp(${JSON.stringify(config.sdkConfig)}))`; }), diff --git a/src/schematics/utils.ts b/src/schematics/utils.ts index 44bb4e3f7..aeab94762 100644 --- a/src/schematics/utils.ts +++ b/src/schematics/utils.ts @@ -2,7 +2,7 @@ import { readFileSync } from 'fs'; import { join } from 'path'; import { Rule, SchematicsException, Tree, chain } from '@angular-devkit/schematics'; import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'; -import { addRootImport, addRootProvider } from '@schematics/angular/utility'; +import { addRootProvider } from '@schematics/angular/utility'; import { findNode } from '@schematics/angular/utility/ast-utils'; import { InsertChange, ReplaceChange, applyToUpdateRecorder } from '@schematics/angular/utility/change'; import { overwriteIfExists } from './common'; @@ -186,7 +186,7 @@ export function featureToRules(features: FEATURES[], projectName: string) { switch (feature) { case FEATURES.AppCheck: // TODO make this smarter in Angular Universal - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('initializeAppCheck', '@angular/fire/app-check'); external('ReCaptchaEnterpriseProvider', '@angular/fire/app-check'); return code`${external('provideAppCheck', '@angular/fire/app-check')}(() => { @@ -197,7 +197,7 @@ export function featureToRules(features: FEATURES[], projectName: string) { }); case FEATURES.Analytics: return chain([ - addRootImport(projectName, ({code, external}) => { + addRootProvider(projectName, ({code, external}) => { external('getAnalytics', '@angular/fire/analytics'); return code`${external('provideAnalytics', '@angular/fire/analytics')}(() => getAnalytics())`; }), @@ -212,44 +212,44 @@ export function featureToRules(features: FEATURES[], projectName: string) { ] : []), ]) case FEATURES.Authentication: - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getAuth', '@angular/fire/auth'); return code`${external('provideAuth', '@angular/fire/auth')}(() => getAuth())`; }); case FEATURES.Database: - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getDatabase', '@angular/fire/database'); return code`${external('provideDatabase', '@angular/fire/database')}(() => getDatabase())`; }); case FEATURES.Firestore: - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getFirestore', '@angular/fire/firestore'); return code`${external('provideFirestore', '@angular/fire/firestore')}(() => getFirestore())`; }); case FEATURES.Functions: - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getFunctions', '@angular/fire/functions'); return code`${external('provideFunctions', '@angular/fire/functions')}(() => getFunctions())`; }); case FEATURES.Messaging: // TODO add the service worker - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getMessaging', '@angular/fire/messaging'); return code`${external('provideMessaging', '@angular/fire/messaging')}(() => getMessaging())`; }); case FEATURES.Performance: - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getPerformance', '@angular/fire/performance'); return code`${external('providePerformance', '@angular/fire/performance')}(() => getPerformance())`; }); case FEATURES.Storage: - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getStorage', '@angular/fire/storage'); return code`${external('provideStorage', '@angular/fire/storage')}(() => getStorage())`; }); case FEATURES.RemoteConfig: // TODO consider downloading the defaults - return addRootImport(projectName, ({code, external}) => { + return addRootProvider(projectName, ({code, external}) => { external('getRemoteConfig', '@angular/fire/remote-config'); return code`${external('provideRemoteConfig', '@angular/fire/remote-config')}(() => getRemoteConfig())`; });