From d700bf9d6dcc277450238f52b0be65f691df379d Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Tue, 9 Jan 2018 17:31:54 +0000 Subject: [PATCH] [core] Add SDK_VERSION --- .gitignore | 1 + lib/modules/core/firebase.js | 9 ++++++++ lib/modules/utils/index.js | 11 +--------- package-lock.json | 42 ++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 7a868226..68b162ad 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,4 @@ local.properties **/ios/Pods/** **/ios/ReactNativeFirebaseDemo.xcworkspace/ dist +version.js diff --git a/lib/modules/core/firebase.js b/lib/modules/core/firebase.js index abfdc52a..78317e82 100644 --- a/lib/modules/core/firebase.js +++ b/lib/modules/core/firebase.js @@ -7,6 +7,7 @@ import { NativeModules } from 'react-native'; import APPS from '../../utils/apps'; import INTERNALS from '../../utils/internals'; import App from './firebase-app'; +import VERSION from '../../version'; // module imports import { statics as AdMobStatics, MODULE_NAME as AdmobModuleName } from '../admob'; @@ -112,6 +113,14 @@ class Firebase { get apps(): Array { return APPS.apps(); } + + /** + * The current SDK version. + * @return {string} + */ + get SDK_VERSION(): string { + return VERSION; + } } export default new Firebase(); diff --git a/lib/modules/utils/index.js b/lib/modules/utils/index.js index 6991e37f..0cfb2ed0 100644 --- a/lib/modules/utils/index.js +++ b/lib/modules/utils/index.js @@ -1,11 +1,8 @@ // @flow import { NativeModules } from 'react-native'; -// import { version as ReactVersion } from 'react'; -// import ReactNativeVersion from 'react-native/Libraries/Core/ReactNativeVersion'; import INTERNALS from '../../utils/internals'; import { isIOS } from '../../utils'; import ModuleBase from '../../utils/ModuleBase'; -import PACKAGE from '../../../package.json'; import type App from '../core/firebase-app'; const FirebaseCoreModule = NativeModules.RNFirebase; @@ -106,10 +103,4 @@ export default class RNFirebaseUtils extends ModuleBase { } -export const statics = { - // VERSIONS: { - // react: ReactVersion, - // 'react-native': Object.values(ReactNativeVersion.version).slice(0, 3).join('.'), - // 'react-native-firebase': PACKAGE.version, - // }, -}; +export const statics = {}; diff --git a/package-lock.json b/package-lock.json index eaedc9aa..c5cb8750 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2680,6 +2680,15 @@ } } }, + "find-package": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/find-package/-/find-package-1.0.0.tgz", + "integrity": "sha1-13ONpn48XwVcJNPhmqGu7QY8PoM=", + "dev": true, + "requires": { + "parents": "1.0.1" + } + }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", @@ -2690,6 +2699,12 @@ "pinkie-promise": "2.0.1" } }, + "firstline": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/firstline/-/firstline-1.2.1.tgz", + "integrity": "sha1-uIZzxCAJ+IIfrCkm6ZcgrO6ST64=", + "dev": true + }, "flat-cache": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", @@ -3819,6 +3834,18 @@ "lodash.padstart": "4.6.1" } }, + "genversion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/genversion/-/genversion-2.0.1.tgz", + "integrity": "sha1-cCAQ5VD3d6VtsWbrFzL4BA8mGao=", + "dev": true, + "requires": { + "commander": "2.11.0", + "find-package": "1.0.0", + "firstline": "1.2.1", + "mkdirp": "0.5.1" + } + }, "get-caller-file": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", @@ -5829,6 +5856,15 @@ "p-limit": "1.1.0" } }, + "parents": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", + "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", + "dev": true, + "requires": { + "path-platform": "0.11.15" + } + }, "parse-glob": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", @@ -5889,6 +5925,12 @@ "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", "dev": true }, + "path-platform": { + "version": "0.11.15", + "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", + "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", + "dev": true + }, "path-type": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", diff --git a/package.json b/package.json index adad4656..9dd8d177 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "npm run build-lib && npm run build-flow", + "build": "genversion lib/version.js && npm run build-lib && npm run build-flow", "build-flow": "flow-copy-source -i */__tests__* lib dist", "build-lib": "BABEL_ENV=publish babel lib -d dist --ignore __tests__ --copy-files", "clean": "rimraf dist/", @@ -88,6 +88,7 @@ "eslint-plugin-react": "^7.4.0", "flow-bin": "^0.56.0", "flow-copy-source": "^1.2.1", + "genversion": "^2.0.1", "react": "^16.0.0", "react-dom": "^16.0.0", "react-native": "^0.50.3",