From 33388aebf7ebd902684b58e42426954e12b26d1d Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 10 Dec 2019 11:53:57 -0800 Subject: [PATCH] Add version reporting for all packages (#2405) Add version reporting for all packages plus bundle variant suffix --- packages/app-types/index.d.ts | 2 +- packages/app/index.lite.ts | 2 +- packages/app/index.node.ts | 2 +- packages/app/index.rn.ts | 2 +- packages/app/package.json | 2 +- packages/app/src/constants.ts | 8 ++----- packages/app/src/firebaseNamespaceCore.ts | 11 +++++++-- packages/app/src/registerCoreComponents.ts | 7 ++++-- packages/app/test/platformLogger.test.ts | 23 +++++++++++++++++++ packages/auth/gulpfile.js | 5 +++- packages/auth/src/exports_auth.js | 3 +++ packages/database/index.node.ts | 4 ++++ packages/database/index.ts | 4 ++++ packages/database/rollup.config.js | 7 ++++-- packages/firebase/app/index.ts | 3 ++- .../firebase/externs/firebase-app-externs.js | 7 ++++++ packages/firebase/index.d.ts | 7 +++++- packages/firebase/rollup.config.js | 6 +++++ packages/firebase/src/index.cdn.ts | 3 ++- packages/firebase/src/index.node.ts | 3 ++- packages/firebase/src/index.perf.ts | 3 ++- packages/firebase/src/index.rn.ts | 3 ++- packages/firebase/src/index.ts | 3 ++- packages/firestore/index.node.ts | 3 +++ packages/firestore/index.ts | 3 +++ packages/firestore/rollup.config.js | 7 ++++-- packages/functions/index.node.ts | 3 +++ packages/functions/index.ts | 3 +++ packages/functions/src/config.ts | 3 --- packages/installations/src/index.ts | 4 ++++ packages/messaging/index.ts | 4 ++++ packages/messaging/rollup.config.js | 7 ++++-- packages/messaging/test/index.test.ts | 8 +++++-- packages/performance/index.ts | 4 ++++ packages/remote-config/index.ts | 4 +++- packages/storage/index.ts | 4 ++++ packages/storage/rollup.config.js | 7 ++++-- 37 files changed, 147 insertions(+), 37 deletions(-) diff --git a/packages/app-types/index.d.ts b/packages/app-types/index.d.ts index 3495c6fbd90..207e2040e39 100644 --- a/packages/app-types/index.d.ts +++ b/packages/app-types/index.d.ts @@ -103,7 +103,7 @@ export interface FirebaseNamespace { * @param library Name of 1p or 3p library (e.g. firestore, angularfire) * @param version Current version of that library. */ - registerVersion(library: string, version: string): void; + registerVersion(library: string, version: string, variant?: string): void; // The current SDK version. SDK_VERSION: string; diff --git a/packages/app/index.lite.ts b/packages/app/index.lite.ts index 9422fd3d820..2778e6b6db5 100644 --- a/packages/app/index.lite.ts +++ b/packages/app/index.lite.ts @@ -20,7 +20,7 @@ import { registerCoreComponents } from './src/registerCoreComponents'; export const firebase = createFirebaseNamespaceLite(); -registerCoreComponents(firebase); +registerCoreComponents(firebase, 'lite'); // eslint-disable-next-line import/no-default-export export default firebase; diff --git a/packages/app/index.node.ts b/packages/app/index.node.ts index f7cd69f6af9..8ddd1ad97f8 100644 --- a/packages/app/index.node.ts +++ b/packages/app/index.node.ts @@ -37,7 +37,7 @@ import { registerCoreComponents } from './src/registerCoreComponents'; export const firebase = _firebase as FirebaseNamespace; -registerCoreComponents(firebase); +registerCoreComponents(firebase, 'node'); // eslint-disable-next-line import/no-default-export export default firebase; diff --git a/packages/app/index.rn.ts b/packages/app/index.rn.ts index 0d929d13106..d71cb35c0f4 100644 --- a/packages/app/index.rn.ts +++ b/packages/app/index.rn.ts @@ -38,7 +38,7 @@ const { AsyncStorage } = require('react-native'); export const firebase = _firebase as FirebaseNamespace; -registerCoreComponents(firebase); +registerCoreComponents(firebase, 'rn'); // eslint-disable-next-line import/no-default-export export default firebase; diff --git a/packages/app/package.json b/packages/app/package.json index 23b5d6eec07..488d649abde 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -49,7 +49,7 @@ "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" }, - "typings": "dist/app/index.d.ts", + "typings": "dist/packages/app/index.d.ts", "nyc": { "extension": [ ".ts" diff --git a/packages/app/src/constants.ts b/packages/app/src/constants.ts index 3bb582170b6..6f132a0d921 100644 --- a/packages/app/src/constants.ts +++ b/packages/app/src/constants.ts @@ -26,6 +26,7 @@ import { name as performanceName } from '../../performance/package.json'; import { name as remoteConfigName } from '../../remote-config/package.json'; import { name as storageName } from '../../storage/package.json'; import { name as firestoreName } from '../../firestore/package.json'; +import { name as packageName } from '../../../package.json'; export const PLATFORM_LOG_STRING = { [appName]: 'fire-core', @@ -39,10 +40,5 @@ export const PLATFORM_LOG_STRING = { [storageName]: 'fire-gcs', [firestoreName]: 'fire-fst', 'fire-js': 'fire-js', // Platform identifier for JS SDK. - 'fire-js-all-app': 'fire-js-all-app', // firebase/app import - 'fire-js-all': 'fire-js-all', // 'firebase' import - 'fire-js-all-node': 'fire-js-all-node', - 'fire-js-all-rn': 'fire-js-all-rn', - 'fire-js-all-lite': 'fire-js-all-lite', - 'fire-js-all-cdn': 'fire-js-all-cdn' + [packageName]: 'fire-js-all' } as const; diff --git a/packages/app/src/firebaseNamespaceCore.ts b/packages/app/src/firebaseNamespaceCore.ts index 357fe2e5d57..f17ad16f6b7 100644 --- a/packages/app/src/firebaseNamespaceCore.ts +++ b/packages/app/src/firebaseNamespaceCore.ts @@ -235,10 +235,17 @@ export function createFirebaseNamespaceCore( : null; } - function registerVersion(libraryKeyOrName: string, version: string): void { + function registerVersion( + libraryKeyOrName: string, + version: string, + variant?: string + ): void { // TODO: We can use this check to whitelist strings when/if we set up // a good whitelist system. - const library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName; + let library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName; + if (variant) { + library += `-${variant}`; + } const libraryMismatch = library.match(/\s|\//); const versionMismatch = version.match(/\s|\//); if (libraryMismatch || versionMismatch) { diff --git a/packages/app/src/registerCoreComponents.ts b/packages/app/src/registerCoreComponents.ts index 8bc1bbf2cee..7d31d135500 100644 --- a/packages/app/src/registerCoreComponents.ts +++ b/packages/app/src/registerCoreComponents.ts @@ -21,7 +21,10 @@ import { Component, ComponentType } from '@firebase/component'; import { PlatformLoggerService } from './platformLoggerService'; import { name, version } from '../package.json'; -export function registerCoreComponents(firebase: FirebaseNamespace): void { +export function registerCoreComponents( + firebase: FirebaseNamespace, + variant?: string +): void { (firebase as _FirebaseNamespace).INTERNAL.registerComponent( new Component( 'platform-logger', @@ -30,7 +33,7 @@ export function registerCoreComponents(firebase: FirebaseNamespace): void { ) ); // Register `app` package. - firebase.registerVersion(name, version); + firebase.registerVersion(name, version, variant); // Register platform SDK identifier (no version). firebase.registerVersion('fire-js', ''); } diff --git a/packages/app/test/platformLogger.test.ts b/packages/app/test/platformLogger.test.ts index 51502b1039a..82d0203e7a0 100644 --- a/packages/app/test/platformLogger.test.ts +++ b/packages/app/test/platformLogger.test.ts @@ -90,6 +90,29 @@ describe('Platform Logger Service', () => { return (firebase as any)['test-shell'](); }); + it(`logs core version with bundle variant`, () => { + firebase.initializeApp({}); + registerCoreComponents(firebase, 'node'); + (firebase as _FirebaseNamespace).INTERNAL.registerComponent( + new Component( + 'test-shell', + async (container: ComponentContainer) => { + const platformLoggerProvider = container.getProvider( + 'platform-logger' + ); + const platformLogger = (await platformLoggerProvider.get()) as PlatformLoggerService; + const platformInfoString = platformLogger.getPlatformInfoString(); + expect(platformInfoString).to.include( + `fire-core-node/${appVersion}` + ); + expect(platformInfoString).to.include('fire-js/'); + }, + ComponentType.PUBLIC + ) + ); + return (firebase as any)['test-shell'](); + }); + it(`logs other components' versions`, () => { firebase.initializeApp({}); registerCoreComponents(firebase); diff --git a/packages/auth/gulpfile.js b/packages/auth/gulpfile.js index e1ec4f65280..cc4cca0a2e7 100644 --- a/packages/auth/gulpfile.js +++ b/packages/auth/gulpfile.js @@ -21,6 +21,7 @@ const del = require('del'); const express = require('express'); const path = require('path'); const sourcemaps = require('gulp-sourcemaps'); +const pkg = require('./package.json'); // The optimization level for the JS compiler. // Valid levels: WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS. @@ -79,7 +80,9 @@ function createBuildTask(filename, prefix, suffix) { ) ], language_out: 'ES5', - only_closure_dependencies: true + only_closure_dependencies: true, + // Insert current package.json version into registerVersion call. + define: `AUTH_NPM_PACKAGE_VERSION=${pkg.version}` }) ) .pipe(sourcemaps.write('.')) diff --git a/packages/auth/src/exports_auth.js b/packages/auth/src/exports_auth.js index 7b6ed725095..06126e7d531 100644 --- a/packages/auth/src/exports_auth.js +++ b/packages/auth/src/exports_auth.js @@ -48,6 +48,8 @@ goog.require('fireauth.grecaptcha'); goog.require('fireauth.idp.ProviderId'); goog.require('goog.Promise'); +/** @define {string} */ +const AUTH_NPM_PACKAGE_VERSION = ''; fireauth.exportlib.exportPrototypeMethods( fireauth.Auth.prototype, { @@ -705,6 +707,7 @@ fireauth.exportlib.exportFunction( firebase.INTERNAL.registerComponent(authComponent); firebase.INTERNAL.registerComponent(authInteropComponent); + firebase.registerVersion('@firebase/auth', AUTH_NPM_PACKAGE_VERSION); // Expose User as firebase.User. firebase.INTERNAL.extendNamespace({ diff --git a/packages/database/index.node.ts b/packages/database/index.node.ts index 784b959bf00..be7c93405cf 100644 --- a/packages/database/index.node.ts +++ b/packages/database/index.node.ts @@ -38,6 +38,8 @@ import { } from '@firebase/component'; import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; +import { name, version } from './package.json'; + setWebSocketImpl(Client); const ServerValue = Database.ServerValue; @@ -131,6 +133,8 @@ export function registerDatabase(instance: FirebaseNamespace) { .setMultipleInstances(true) ); + instance.registerVersion(name, version, 'node'); + if (isNodeSdk()) { module.exports = Object.assign({}, namespace, { initStandalone }); } diff --git a/packages/database/index.ts b/packages/database/index.ts index 4b18d8f4fa2..870fd205b30 100644 --- a/packages/database/index.ts +++ b/packages/database/index.ts @@ -31,6 +31,8 @@ import * as types from '@firebase/database-types'; import { setSDKVersion } from './src/core/version'; import { Component, ComponentType } from '@firebase/component'; +import { name, version } from './package.json'; + const ServerValue = Database.ServerValue; export function registerDatabase(instance: FirebaseNamespace) { @@ -71,6 +73,8 @@ export function registerDatabase(instance: FirebaseNamespace) { .setMultipleInstances(true) ); + instance.registerVersion(name, version); + if (isNodeSdk()) { module.exports = namespace; } diff --git a/packages/database/rollup.config.js b/packages/database/rollup.config.js index 365301f11e9..99d4d081f17 100644 --- a/packages/database/rollup.config.js +++ b/packages/database/rollup.config.js @@ -15,6 +15,7 @@ * limitations under the License. */ +import json from 'rollup-plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; @@ -29,7 +30,8 @@ const deps = Object.keys( const es5BuildPlugins = [ typescriptPlugin({ typescript - }) + }), + json() ]; const es5Builds = [ @@ -67,7 +69,8 @@ const es2017BuildPlugins = [ target: 'es2017' } } - }) + }), + json({ preferConst: true }) ]; const es2017Builds = [ diff --git a/packages/firebase/app/index.ts b/packages/firebase/app/index.ts index 6c1bb7b0ce4..f600eed7ce9 100644 --- a/packages/firebase/app/index.ts +++ b/packages/firebase/app/index.ts @@ -16,7 +16,8 @@ */ import firebase from '@firebase/app'; +import { name, version } from '../package.json'; -firebase.registerVersion('fire-js-all-app', firebase.SDK_VERSION); +firebase.registerVersion(name, version, 'app'); export default firebase; diff --git a/packages/firebase/externs/firebase-app-externs.js b/packages/firebase/externs/firebase-app-externs.js index fdc94de40d2..613b487afb1 100644 --- a/packages/firebase/externs/firebase-app-externs.js +++ b/packages/firebase/externs/firebase-app-externs.js @@ -284,3 +284,10 @@ firebase.CompleteFn; /** @typedef {function(): void} */ firebase.Unsubscribe; + +/** + * @param {string} name + * @param {string} version + * @param {?string} variant + */ +firebase.registerVersion = function(name, version, variant) {}; diff --git a/packages/firebase/index.d.ts b/packages/firebase/index.d.ts index 4d3052ab9ae..84823547e48 100644 --- a/packages/firebase/index.d.ts +++ b/packages/firebase/index.d.ts @@ -87,8 +87,13 @@ declare namespace firebase { * Registers a library's name and version for platform logging purposes. * @param library Name of 1p or 3p library (e.g. firestore, angularfire) * @param version Current version of that library. + * @param variant Bundle variant, e.g., node, rn, etc. */ - function registerVersion(library: string, version: string): void; + function registerVersion( + library: string, + version: string, + variant?: string + ): void; /** * @hidden diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index a98b2a6d7d4..ffd0085410f 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -23,6 +23,7 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import { uglify } from 'rollup-plugin-uglify'; import { terser } from 'rollup-plugin-terser'; +import json from 'rollup-plugin-json'; import pkg from './package.json'; import appPkg from './app/package.json'; @@ -33,6 +34,7 @@ const plugins = [ typescriptPlugin({ typescript }), + json(), commonjs() ]; @@ -199,6 +201,7 @@ const completeBuilds = [ typescriptPlugin({ typescript }), + json(), commonjs(), uglify() ] @@ -227,6 +230,9 @@ const completeBuilds = [ } } }), + json({ + preferConst: true + }), commonjs(), terser() ] diff --git a/packages/firebase/src/index.cdn.ts b/packages/firebase/src/index.cdn.ts index abcbc2186a3..00a51d47052 100644 --- a/packages/firebase/src/index.cdn.ts +++ b/packages/firebase/src/index.cdn.ts @@ -28,6 +28,7 @@ https://www.gstatic.com/firebasejs/5.0.0/firebase-.js import '@firebase/polyfill'; import firebase from '../app'; +import { name, version } from '../package.json'; import '../auth'; import '../database'; @@ -39,6 +40,6 @@ import '../performance'; import '../analytics'; import '../remote-config'; -firebase.registerVersion('fire-js-all-cdn', firebase.SDK_VERSION); +firebase.registerVersion(name, version, 'cdn'); export default firebase; diff --git a/packages/firebase/src/index.node.ts b/packages/firebase/src/index.node.ts index f353ff3fd3d..2c9c20ee723 100644 --- a/packages/firebase/src/index.node.ts +++ b/packages/firebase/src/index.node.ts @@ -16,12 +16,13 @@ */ import firebase from '../app'; +import { name, version } from '../package.json'; import '../auth'; import '../database'; import '../firestore'; import '../functions'; -firebase.registerVersion('fire-js-all-node', firebase.SDK_VERSION); +firebase.registerVersion(name, version, 'node'); export default firebase; diff --git a/packages/firebase/src/index.perf.ts b/packages/firebase/src/index.perf.ts index 6e5b8d392b9..122e2b46c27 100644 --- a/packages/firebase/src/index.perf.ts +++ b/packages/firebase/src/index.perf.ts @@ -17,7 +17,8 @@ import firebase from '@firebase/app'; import '@firebase/performance'; +import { name, version } from '../package.json'; -firebase.registerVersion('fire-js-all-lite', firebase.SDK_VERSION); +firebase.registerVersion(name, version, 'lite'); export default firebase; diff --git a/packages/firebase/src/index.rn.ts b/packages/firebase/src/index.rn.ts index ee6c28dcf24..853d37c4e6a 100644 --- a/packages/firebase/src/index.rn.ts +++ b/packages/firebase/src/index.rn.ts @@ -16,11 +16,12 @@ */ import firebase from '../app'; +import { name, version } from '../package.json'; import '../auth'; import '../database'; import '../storage'; -firebase.registerVersion('fire-js-all-rn', firebase.SDK_VERSION); +firebase.registerVersion(name, version, 'rn'); export default firebase; diff --git a/packages/firebase/src/index.ts b/packages/firebase/src/index.ts index bda89a78377..51619c16473 100644 --- a/packages/firebase/src/index.ts +++ b/packages/firebase/src/index.ts @@ -37,6 +37,7 @@ import 'firebase/'; `); import firebase from '../app'; +import { name, version } from '../package.json'; import '../auth'; import '../database'; @@ -48,6 +49,6 @@ import '../performance'; import '../analytics'; import '../remote-config'; -firebase.registerVersion('fire-js-all', firebase.SDK_VERSION); +firebase.registerVersion(name, version); export default firebase; diff --git a/packages/firestore/index.node.ts b/packages/firestore/index.node.ts index 138bf92b8dc..635c92d7779 100644 --- a/packages/firestore/index.node.ts +++ b/packages/firestore/index.node.ts @@ -20,8 +20,11 @@ import { configureForFirebase } from './src/platform/config'; import './src/platform_node/node_init'; import { FirebaseNamespace } from '@firebase/app-types'; +import { name, version } from './package.json'; + export function registerFirestore(instance: FirebaseNamespace): void { configureForFirebase(instance); + instance.registerVersion(name, version, 'node'); } registerFirestore(firebase); diff --git a/packages/firestore/index.ts b/packages/firestore/index.ts index 22773204b84..223f2a315ba 100644 --- a/packages/firestore/index.ts +++ b/packages/firestore/index.ts @@ -22,8 +22,11 @@ import './src/platform_browser/browser_init'; import * as types from '@firebase/firestore-types'; import { FirebaseNamespace } from '@firebase/app-types'; +import { name, version } from './package.json'; + export function registerFirestore(instance: FirebaseNamespace): void { configureForFirebase(instance); + instance.registerVersion(name, version); } registerFirestore(firebase); diff --git a/packages/firestore/rollup.config.js b/packages/firestore/rollup.config.js index aec0cb69fad..be88c8c83da 100644 --- a/packages/firestore/rollup.config.js +++ b/packages/firestore/rollup.config.js @@ -15,6 +15,7 @@ * limitations under the License. */ +import json from 'rollup-plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import copy from 'rollup-plugin-copy-assets'; @@ -31,7 +32,8 @@ const deps = Object.keys( const es5BuildPlugins = [ typescriptPlugin({ typescript - }) + }), + json() ]; const es5Builds = [ @@ -81,7 +83,8 @@ const es2017BuildPlugins = [ target: 'es2017' } } - }) + }), + json({ preferConst: true }) ]; const es2017Builds = [ diff --git a/packages/functions/index.node.ts b/packages/functions/index.node.ts index 3e30f5b452d..8a55faa84ff 100644 --- a/packages/functions/index.node.ts +++ b/packages/functions/index.node.ts @@ -19,4 +19,7 @@ import { _FirebaseNamespace } from '@firebase/app-types/private'; import { registerFunctions } from './src/config'; import 'isomorphic-fetch'; +import { name, version } from './package.json'; + registerFunctions(firebase as _FirebaseNamespace); +firebase.registerVersion(name, version, 'node'); diff --git a/packages/functions/index.ts b/packages/functions/index.ts index 7c4c6357cc3..17cb9531537 100644 --- a/packages/functions/index.ts +++ b/packages/functions/index.ts @@ -19,7 +19,10 @@ import { _FirebaseNamespace } from '@firebase/app-types/private'; import * as types from '@firebase/functions-types'; import { registerFunctions } from './src/config'; +import { name, version } from './package.json'; + registerFunctions(firebase as _FirebaseNamespace); +firebase.registerVersion(name, version); declare module '@firebase/app-types' { interface FirebaseNamespace { diff --git a/packages/functions/src/config.ts b/packages/functions/src/config.ts index dd7a077e2d9..f021e1fbcd7 100644 --- a/packages/functions/src/config.ts +++ b/packages/functions/src/config.ts @@ -23,8 +23,6 @@ import { } from '@firebase/component'; import { _FirebaseNamespace } from '@firebase/app-types/private'; -import { name, version } from '../package.json'; - /** * Type constant for Firebase Functions. */ @@ -50,5 +48,4 @@ export function registerFunctions(instance: _FirebaseNamespace): void { .setServiceProps(namespaceExports) .setMultipleInstances(true) ); - instance.registerVersion(name, version); } diff --git a/packages/installations/src/index.ts b/packages/installations/src/index.ts index 07d40868817..2590a8d8b70 100644 --- a/packages/installations/src/index.ts +++ b/packages/installations/src/index.ts @@ -23,6 +23,8 @@ import { deleteInstallation, getId, getToken } from './functions'; import { extractAppConfig } from './helpers/extract-app-config'; import { FirebaseDependencies } from './interfaces/firebase-dependencies'; +import { name, version } from '../package.json'; + export function registerInstallations(instance: _FirebaseNamespace): void { const installationsName = 'installations'; @@ -51,6 +53,8 @@ export function registerInstallations(instance: _FirebaseNamespace): void { ComponentType.PUBLIC ) ); + + instance.registerVersion(name, version); } registerInstallations(firebase as _FirebaseNamespace); diff --git a/packages/messaging/index.ts b/packages/messaging/index.ts index 355c2f01997..5c187059b33 100644 --- a/packages/messaging/index.ts +++ b/packages/messaging/index.ts @@ -29,6 +29,8 @@ import { } from '@firebase/component'; import { FirebaseInternalServices } from './src/interfaces/internal-services'; +import { name, version } from './package.json'; + export function registerMessaging(instance: _FirebaseNamespace): void { const messagingName = 'messaging'; @@ -68,6 +70,8 @@ export function registerMessaging(instance: _FirebaseNamespace): void { ComponentType.PUBLIC ).setServiceProps(namespaceExports) ); + + instance.registerVersion(name, version); } registerMessaging(firebase as _FirebaseNamespace); diff --git a/packages/messaging/rollup.config.js b/packages/messaging/rollup.config.js index dd72ab9c57b..3368ec515d3 100644 --- a/packages/messaging/rollup.config.js +++ b/packages/messaging/rollup.config.js @@ -15,6 +15,7 @@ * limitations under the License. */ +import json from 'rollup-plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; @@ -29,7 +30,8 @@ const deps = Object.keys( const es5BuildPlugins = [ typescriptPlugin({ typescript - }) + }), + json() ]; const es5Builds = [ @@ -55,7 +57,8 @@ const es2017BuildPlugins = [ target: 'es2017' } } - }) + }), + json({ preferConst: true }) ]; const es2017Builds = [ diff --git a/packages/messaging/test/index.test.ts b/packages/messaging/test/index.test.ts index baa33ab8aa3..0f0948d4e1f 100644 --- a/packages/messaging/test/index.test.ts +++ b/packages/messaging/test/index.test.ts @@ -40,13 +40,16 @@ import { FirebaseMessagingName } from '@firebase/messaging-types'; describe('Firebase Messaging > registerMessaging', () => { let registerComponent: SinonStub; + let registerVersion: SinonStub; let fakeFirebase: _FirebaseNamespace; beforeEach(() => { registerComponent = stub(); + registerVersion = stub(); fakeFirebase = { - INTERNAL: { registerComponent } + INTERNAL: { registerComponent }, + registerVersion } as any; }); @@ -54,9 +57,10 @@ describe('Firebase Messaging > registerMessaging', () => { restore(); }); - it('calls registerComponent', () => { + it('calls registerComponent and registerVersion', () => { registerMessaging(fakeFirebase); expect(registerComponent.callCount).to.equal(1); + expect(registerVersion.callCount).to.equal(1); }); describe('factoryMethod', () => { diff --git a/packages/performance/index.ts b/packages/performance/index.ts index b6bfecf9abc..79e1ed5c912 100644 --- a/packages/performance/index.ts +++ b/packages/performance/index.ts @@ -27,6 +27,8 @@ import { FirebasePerformance } from '@firebase/performance-types'; import { Component, ComponentType } from '@firebase/component'; import { FirebaseInstallations } from '@firebase/installations-types'; +import { name, version } from './package.json'; + const DEFAULT_ENTRY_NAME = '[DEFAULT]'; export function registerPerformance(instance: FirebaseNamespace): void { @@ -64,6 +66,8 @@ export function registerPerformance(instance: FirebaseNamespace): void { ComponentType.PUBLIC ) ); + + instance.registerVersion(name, version); } registerPerformance(firebase); diff --git a/packages/remote-config/index.ts b/packages/remote-config/index.ts index 09c8454ae1e..b553bd4ee0b 100644 --- a/packages/remote-config/index.ts +++ b/packages/remote-config/index.ts @@ -27,7 +27,7 @@ import { StorageCache } from './src/storage/storage_cache'; import { ERROR_FACTORY, ErrorCode } from './src/errors'; import { RetryingClient } from './src/client/retrying_client'; import { Logger, LogLevel as FirebaseLogLevel } from '@firebase/logger'; -import { name as packageName } from './package.json'; +import { name as packageName, version } from './package.json'; import { Component, ComponentType, @@ -55,6 +55,8 @@ export function registerRemoteConfig( ).setMultipleInstances(true) ); + firebaseInstance.registerVersion(packageName, version); + function remoteConfigFactory( container: ComponentContainer, namespace?: string diff --git a/packages/storage/index.ts b/packages/storage/index.ts index 7c8d2659daf..e520636bd76 100644 --- a/packages/storage/index.ts +++ b/packages/storage/index.ts @@ -30,6 +30,8 @@ import { ComponentContainer } from '@firebase/component'; +import { name, version } from './package.json'; + /** * Type constant for Firebase Storage. */ @@ -65,6 +67,8 @@ export function registerStorage(instance: _FirebaseNamespace): void { .setServiceProps(namespaceExports) .setMultipleInstances(true) ); + + instance.registerVersion(name, version); } registerStorage(firebase as _FirebaseNamespace); diff --git a/packages/storage/rollup.config.js b/packages/storage/rollup.config.js index b3d3a4740f9..d2de84132df 100644 --- a/packages/storage/rollup.config.js +++ b/packages/storage/rollup.config.js @@ -15,6 +15,7 @@ * limitations under the License. */ +import json from 'rollup-plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; @@ -28,7 +29,8 @@ const deps = Object.keys( const es5BuildPlugins = [ typescriptPlugin({ typescript - }) + }), + json() ]; const es5Builds = [ @@ -54,7 +56,8 @@ const es2017BuildPlugins = [ target: 'es2017' } } - }) + }), + json({ preferConst: true }) ]; const es2017Builds = [