Skip to content

Commit e619a82

Browse files
committed
registerVersion is actually on firebase object
1 parent 8fe8140 commit e619a82

File tree

5 files changed

+101
-17
lines changed

5 files changed

+101
-17
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"pretty-size": "^2.0.0",
9090
"protractor": "3.0.0",
9191
"reflect-metadata": "0.1.2",
92+
"replace-in-file": "^5.0.2",
9293
"rimraf": "^2.5.4",
9394
"schematics-utilities": "^2.0.1",
9495
"shelljs": "^0.8.0",

src/core/firebase.app.module.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { InjectionToken, NgModule, Optional, NgZone, VERSION as NG_VERSION, Version } from '@angular/core';
1+
import { InjectionToken, NgModule, Optional, NgZone, VERSION as NG_VERSION, Version, PLATFORM_ID, Inject } from '@angular/core';
22
import { app, auth, database, messaging, storage, firestore, functions, analytics, performance, remoteConfig } from 'firebase/app';
3-
// @ts-ignore (https://github.com/firebase/firebase-js-sdk/pull/1206)
4-
import firebase from 'firebase/app'; // once fixed can pull in as "default as firebase" above
3+
import * as firebase from 'firebase/app';
54

65
// INVESTIGATE Public types don't expose FirebaseOptions or FirebaseAppConfig, is this the case anylonger?
76
export interface FirebaseOptions {[key:string]: any};
@@ -25,7 +24,6 @@ export class FirebaseApp implements Partial<app.App> {
2524
firestore: () => firestore.Firestore;
2625
functions: (region?: string) => functions.Functions;
2726
remoteConfig: () => remoteConfig.RemoteConfig;
28-
registerVersion?: (library: string, version: string) => void;
2927
}
3028

3129
export const VERSION = new Version('ANGULARFIRE2_VERSION');
@@ -38,12 +36,7 @@ export function ɵfirebaseAppFactory(options: FirebaseOptions, zone: NgZone, nam
3836
const existingApp = firebase.apps.filter(app => app && app.name === config.name)[0] as any;
3937
// We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any
4038
// Could be solved with https://github.com/firebase/firebase-js-sdk/pull/1206
41-
const app = (existingApp || zone.runOutsideAngular(() => firebase.initializeApp(options, config as any))) as FirebaseApp;
42-
if (app.registerVersion) {
43-
app.registerVersion('angularfire', VERSION.full);
44-
app.registerVersion('angular', NG_VERSION.full);
45-
}
46-
return app;
39+
return (existingApp || zone.runOutsideAngular(() => firebase.initializeApp(options, config as any))) as FirebaseApp;
4740
}
4841

4942
const FirebaseAppProvider = {
@@ -69,4 +62,8 @@ export class AngularFireModule {
6962
]
7063
}
7164
}
65+
constructor(@Inject(PLATFORM_ID) platformId:Object ) {
66+
firebase.registerVersion('angularfire', VERSION.full, platformId.toString());
67+
firebase.registerVersion('angular', NG_VERSION.full);
68+
}
7269
}

tools/build.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ var dest = function () {
8282
return path_1.join.apply(void 0, __spreadArrays([process.cwd(), 'dist', 'packages-dist'], args));
8383
};
8484
var rootPackage = Promise.resolve().then(function () { return require(path_1.join(process.cwd(), 'package.json')); });
85+
function replacePackageCoreVersion() {
86+
return __awaiter(this, void 0, void 0, function () {
87+
var root, replace, result;
88+
return __generator(this, function (_a) {
89+
switch (_a.label) {
90+
case 0: return [4 /*yield*/, rootPackage];
91+
case 1:
92+
root = _a.sent();
93+
replace = require('replace-in-file');
94+
return [4 /*yield*/, replace({
95+
files: dest('**', '*.js'),
96+
from: 'ANGULARFIRE2_VERSION',
97+
to: root.version
98+
})];
99+
case 2:
100+
result = _a.sent();
101+
console.log(result);
102+
return [2 /*return*/];
103+
}
104+
});
105+
});
106+
}
85107
function replacePackageJsonVersions() {
86108
return __awaiter(this, void 0, void 0, function () {
87109
var path, root, pkg;
@@ -174,7 +196,8 @@ function buildLibrary() {
174196
fs_extra_1.copy(path_1.join(process.cwd(), 'docs'), dest('docs')),
175197
fs_extra_1.copy(src('firebase-node'), dest('firebase-node')),
176198
compileSchematics(),
177-
replacePackageJsonVersions()
199+
replacePackageJsonVersions(),
200+
replacePackageCoreVersion()
178201
])];
179202
case 2:
180203
_a.sent();

tools/build.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { spawn } from 'child_process';
2-
import { copy, writeFile, readFile, accessSync } from 'fs-extra';
2+
import { copy, writeFile, readFile } from 'fs-extra';
33
import { prettySize } from 'pretty-size';
44
import { sync as gzipSync } from 'gzip-size';
55
import { join, dirname } from 'path';
@@ -18,6 +18,16 @@ const dest = (...args:string[]) => join(process.cwd(), 'dist', 'packages-dist',
1818

1919
const rootPackage = import(join(process.cwd(), 'package.json'));
2020

21+
async function replacePackageCoreVersion() {
22+
const root = await rootPackage;
23+
const replace = require('replace-in-file');
24+
return replace({
25+
files: dest('**', '*.js'),
26+
from: 'ANGULARFIRE2_VERSION',
27+
to: root.version
28+
});
29+
}
30+
2131
async function replacePackageJsonVersions() {
2232
const path = dest('package.json');
2333
const root = await rootPackage;
@@ -69,7 +79,8 @@ async function buildLibrary() {
6979
copy(join(process.cwd(), 'docs'), dest('docs')),
7080
copy(src('firebase-node'), dest('firebase-node')),
7181
compileSchematics(),
72-
replacePackageJsonVersions()
82+
replacePackageJsonVersions(),
83+
replacePackageCoreVersion()
7384
]);
7485
}
7586

yarn.lock

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ ansi-styles@^3.2.1:
19701970
dependencies:
19711971
color-convert "^1.9.0"
19721972

1973-
ansi-styles@^4.1.0:
1973+
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
19741974
version "4.2.1"
19751975
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
19761976
integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==
@@ -3380,6 +3380,15 @@ cliui@^4.0.0:
33803380
strip-ansi "^4.0.0"
33813381
wrap-ansi "^2.0.0"
33823382

3383+
cliui@^6.0.0:
3384+
version "6.0.0"
3385+
resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
3386+
integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
3387+
dependencies:
3388+
string-width "^4.2.0"
3389+
strip-ansi "^6.0.0"
3390+
wrap-ansi "^6.2.0"
3391+
33833392
clone-deep@^4.0.1:
33843393
version "4.0.1"
33853394
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
@@ -5390,7 +5399,7 @@ find-up@^3.0.0:
53905399
dependencies:
53915400
locate-path "^3.0.0"
53925401

5393-
find-up@^4.0.0:
5402+
find-up@^4.0.0, find-up@^4.1.0:
53945403
version "4.1.0"
53955404
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
53965405
integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==
@@ -5891,7 +5900,7 @@ glob@^3.2.11, glob@~3.2:
58915900
inherits "2"
58925901
minimatch "0.3"
58935902

5894-
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4:
5903+
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6:
58955904
version "7.1.6"
58965905
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
58975906
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
@@ -10656,6 +10665,15 @@ repeating@^2.0.0:
1065610665
dependencies:
1065710666
is-finite "^1.0.0"
1065810667

10668+
replace-in-file@^5.0.2:
10669+
version "5.0.2"
10670+
resolved "https://registry.yarnpkg.com/replace-in-file/-/replace-in-file-5.0.2.tgz#bd26203b66dfb5b8112ae36a2d2cf928ea4cfe12"
10671+
integrity sha512-1Vc7Sbr/rTuHgU1PZuBb7tGsFx3D4NKdhV4BpEF2MuN/6+SoXcFtx+dZ1Zz+5Dq4k5x9js87Y+gXQYPTQ9ppkA==
10672+
dependencies:
10673+
chalk "^3.0.0"
10674+
glob "^7.1.6"
10675+
yargs "^15.0.2"
10676+
1065910677
request@^2.72.0, request@^2.74.0, request@^2.79.0, request@^2.81.0, request@^2.83.0, request@^2.87.0, request@^2.88.0:
1066010678
version "2.88.0"
1066110679
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
@@ -11745,7 +11763,7 @@ string-width@^3.0.0:
1174511763
is-fullwidth-code-point "^2.0.0"
1174611764
strip-ansi "^5.1.0"
1174711765

11748-
string-width@^4.0.0, string-width@^4.1.0:
11766+
string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0:
1174911767
version "4.2.0"
1175011768
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5"
1175111769
integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==
@@ -13141,6 +13159,15 @@ wrap-ansi@^2.0.0:
1314113159
string-width "^1.0.1"
1314213160
strip-ansi "^3.0.1"
1314313161

13162+
wrap-ansi@^6.2.0:
13163+
version "6.2.0"
13164+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
13165+
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
13166+
dependencies:
13167+
ansi-styles "^4.0.0"
13168+
string-width "^4.1.0"
13169+
strip-ansi "^6.0.0"
13170+
1314413171
wrappy@1:
1314513172
version "1.0.2"
1314613173
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
@@ -13314,6 +13341,14 @@ yargs-parser@^13.0.0:
1331413341
camelcase "^5.0.0"
1331513342
decamelize "^1.2.0"
1331613343

13344+
yargs-parser@^16.1.0:
13345+
version "16.1.0"
13346+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-16.1.0.tgz#73747d53ae187e7b8dbe333f95714c76ea00ecf1"
13347+
integrity sha512-H/V41UNZQPkUMIT5h5hiwg4QKIY1RPvoBV4XcjUbRM8Bk2oKqqyZ0DIEbTFZB0XjbtSPG8SAa/0DxCQmiRgzKg==
13348+
dependencies:
13349+
camelcase "^5.0.0"
13350+
decamelize "^1.2.0"
13351+
1331713352
1331813353
version "12.0.5"
1331913354
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
@@ -13349,6 +13384,23 @@ [email protected]:
1334913384
y18n "^4.0.0"
1335013385
yargs-parser "^13.0.0"
1335113386

13387+
yargs@^15.0.2:
13388+
version "15.1.0"
13389+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.1.0.tgz#e111381f5830e863a89550bd4b136bb6a5f37219"
13390+
integrity sha512-T39FNN1b6hCW4SOIk1XyTOWxtXdcen0t+XYrysQmChzSipvhBO8Bj0nK1ozAasdk24dNWuMZvr4k24nz+8HHLg==
13391+
dependencies:
13392+
cliui "^6.0.0"
13393+
decamelize "^1.2.0"
13394+
find-up "^4.1.0"
13395+
get-caller-file "^2.0.1"
13396+
require-directory "^2.1.1"
13397+
require-main-filename "^2.0.0"
13398+
set-blocking "^2.0.0"
13399+
string-width "^4.2.0"
13400+
which-module "^2.0.0"
13401+
y18n "^4.0.0"
13402+
yargs-parser "^16.1.0"
13403+
1335213404
yargs@^3.10.0:
1335313405
version "3.32.0"
1335413406
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995"

0 commit comments

Comments
 (0)