mirror of
https://github.com/hanzoai/firebase-js-sdk.git
synced 2026-09-24 16:59:10 +00:00
Monorepo Refactor (#171)
* Refactor monorepo to use yarn workspaces and lerna
WIP: testing
Refactor folder structure to use lerna
WIP: more testing
feat(util): add deferred class
Publish
- @firebase/[email protected]
- @firebase/[email protected]
WIP: asdoifj
WIP: build artifact
WIP: asdf
Cleaning up from .gitignore
Add prepublish script
Isolate base configs
Making top level scripts parallel
Adding storage
Add messaging
Adding database code
TODO: Fix all of the broken issues and import the rest of the utils
Adding type info
add database
Adding firebase package
Generating ES Module builds
Attaching firebase.js to the global scope
Adding lint-staged to the build
Removing commitizen dependency
Updating metafiles
Working on devx
Add react-native package
Move packages/firebase -> packages/core
Fix issues with package.json
Bump core version
testing a thing
Add more entries to the .npmignore
* Refactor to better separate ESM/CJS builds
* Adding test:setup script
* Fix breaking test (sourcemaps loaded in the test breaks the regex)
* Remove commitizen message from CONTRIBUTING.md
* WIP: Migrate integration tests
* Adding namespace integration tests
* Add messaging integration tests
* Fix issue with indv-module builds
* Committing yarn.lock
* Import 4.4.0 Changes
* Add dev scripts, move core -> firebase
* Add missing dependencies, flesh out dev experience
* Add top level repl for test/debugging
* Make the REPL pretty
* Refactor to scope prepublish execution
* Add @firebase/auth
* Fixing broken int tests
* Picking up missing changes from edad44d9bc
* Adding comment to .prettierignore
* Fixed issue where firebase didn't exist on reset
* Update yarn.lock for lint-staged
* Refactor test setup script and .travis.yml
* Fix firebase package dep versions
* Refactor precommit hook -> prepush hook
* [AUTOMATED]: Format Styling
* Update prettier and prettierrc
* [AUTOMATED]: Format Styling
* Adding dist to .prettierignore
* Fixing some oddities in yarn.lock
* Refactor hooks prepublish -> prepare
* Updating top-level scripts
* Add pretest validation/checking
* [AUTOMATED]: Prettier Code Styling
* Running travis tests w/ xvfb-run
* Add a spinner instead of the prettier stdio
* update yarn.lock
* [AUTOMATED]: Prettier Code Styling
* Fixing child process STDOUT
* [AUTOMATED]: Prettier Code Styling
* Switch to using stopAndPersist()
* Moving file gitHooks/index.js -> gitHooks/prepush.js
* Remove legacy .lintstagedrc
* Add typinngs file for those only including fiebase/app
* Add initial stub for @firebase/polyfill
* Adding new clean yarn.lock
* Refactor const -> var (no transpiling)
* Add automated license header validation
* [AUTOMATED]: Prettier Code Styling
* [AUTOMATED]: License Headers
* Aesthetic prepush validation things
* [AUTOMATED]: Prettier Code Styling
* Add karma-sauce-launcher
* Attempt 1: Try to get saucelabs browser testing working
* Attempt 2: Adding sauceLabs config prop to karma.base
* [AUTOMATED]: Prettier Code Styling
* Attempt 3: Getting rid of the connectOptions
* [AUTOMATED]: Prettier Code Styling
* Fix CODEOWNERS
* Add module boilerplate for @firebase/firestore
* Refactor Firestore source to standalone package
* Remove unneeded typings
* Remove unneeded promise dependency
* Fix top level paths
* Bump firebase package version
* Fix firestore source paths
* Fix @firebase/app reference
* Refactor to fix TSC errors
* Refactor to make node unit tests work
* Publish
- @firebase/[email protected]
- @firebase/[email protected]
- @firebase/[email protected]
- [email protected]
- @firebase/[email protected]
- @firebase/[email protected]
- @firebase/[email protected]
- @firebase/[email protected]
- @firebase/[email protected]
* Add firestore to main firebase binary
* Pin firebase package to strict versions
* Fix browser firestore tests
* [AUTOMATED]: Prettier Code Styling
* [AUTOMATED]: License Headers
* Changing base karma browsers
* Disabling cross-browser karma tests
* [AUTOMATED]: Prettier Code Styling
* Removing sauce_connect addon from .travis.yml
* Refactor messaging test script
* Refactor the browserNoActivityTimeout
* [AUTOMATED]: Prettier Code Styling
* Adding polyfills to the main browser bundles
* Add firestore/README.md
TODO(jshcrowthe): Fix these tests per the comments in this file
* Fix firestore VSCode scripts
* Fix regex for firestore __data__ prop
* [AUTOMATED]: Prettier Code Styling
* Initial Commit
* Add a brief README.md
* Add *.tgz to .npmignore
* Publish: v0.1.1
* Turn on advanced optimizations for this code
* Leverage "ADVANCED_OPTIMIZATIONS" mode in closure compilation
* 0.2.0
* Add XhrIo prototype overrides
* 0.2.1
* Remove unneeded lockfile
* Fixing dependency versions
* [AUTOMATED]: Prettier Code Styling
* [AUTOMATED]: License Headers
* TEMP: Remove saucelabs reporter
* Fix prettier styling bug (fights with closure)
* Update firebase/app typings
* Leverage default exports
* Updating top-level README.md
* Refactor mocha timeout to be 20 seconds for firestore
* Addressing some review comments from @mikelehen
* temp
* Fixing license header spacing issues
* Refactor license header check
* [AUTOMATED]: Prettier Code Styling
* [AUTOMATED]: License Headers
* Revert "[AUTOMATED]: License Headers"
This reverts commit 559068ceb070519f39207e15886e147787cd941a.
* Revert "Refactor license header check"
This reverts commit 34c671ab9730d6480e487b6ddcd7283f7df3979a.
* Fixing more license headers
* Add @wilhuff and @wti806 to CODEOWNERS
* Adding one more --auto-watch flag
* Add 3 retries to firestore tests
* Bumping browserNoActiityTimeout
* @firebase/app - package.json housekeeping
* @firebase/auth - README.md housekeeping
* @firebase/database - README.md housekeeping
* @firebase/firestore - README.md housekeeping
* Updating auth readme
* @firebase/messaging - README.md housekeeping
* Updating database readme
* Fixing issue with messaging/package.json (copy-paste fail)
* @firebase/polyfill - README.md housekeeping
* @firebase/storage - README.md housekeeping
* @firebase/util - README.md housekeeping
* Fixing package.json repo links
* Refactor from PromiseLike -> Promise
* Add firebase externs
* [AUTOMATED]: Prettier Code Styling
* Fix license values in package.json
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
types: [
|
||||
{value: 'feat', name: 'feat: A new feature'},
|
||||
{value: 'fix', name: 'fix: A bug fix'},
|
||||
{value: 'docs', name: 'docs: Documentation only changes'},
|
||||
{value: 'style', name: 'style: Changes that deal with code style as opposed to functionality\n (white-space, formatting, missing semi-colons, etc)'},
|
||||
{value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature'},
|
||||
{value: 'perf', name: 'perf: A code change that improves performance'},
|
||||
{value: 'test', name: 'test: Adding missing tests'},
|
||||
{value: 'chore', name: 'chore: Changes to the build process, auxiliary tools\n or other processes such as documentation generation'},
|
||||
{value: 'revert', name: 'revert: Revert to a commit'},
|
||||
{value: 'WIP', name: 'WIP: Work in progress'}
|
||||
],
|
||||
scopes: [
|
||||
{name: 'auth'},
|
||||
{name: 'storage'},
|
||||
{name: 'messaging'},
|
||||
{name: 'database'},
|
||||
{name: 'app'},
|
||||
{name: '* (All of the above, or general package concerns)', value: '*'},
|
||||
],
|
||||
allowCustomScopes: true,
|
||||
allowBreakingChanges: ['feat', 'fix']
|
||||
};
|
||||
+5
-17
@@ -4,29 +4,17 @@
|
||||
# These owners will be the default owners for everything in the repo.
|
||||
* @jshcrowthe
|
||||
|
||||
# Order is important. The last matching pattern has the most precedence.
|
||||
# So if a pull request only touches javascript files, only these owners
|
||||
# will be requested to review.
|
||||
*.js @jshcrowthe
|
||||
|
||||
# You can also use email addresses if you prefer.
|
||||
|
||||
# Database Code
|
||||
src/database @mikelehen @schmidt-sebastian
|
||||
tests/database @mikelehen @schmidt-sebastian
|
||||
packages/database @mikelehen @schmidt-sebastian
|
||||
|
||||
# Firestore Code
|
||||
src/firestore @mikelehen @schmidt-sebastian
|
||||
tests/firestore @mikelehen @schmidt-sebastian
|
||||
integration/firestore @mikelehen @schmidt-sebastian
|
||||
packages/firestore @mikelehen @schmidt-sebastian @wilhuff
|
||||
|
||||
# Storage Code
|
||||
src/storage @sphippen
|
||||
tests/storage @sphippen
|
||||
packages/storage @sphippen
|
||||
|
||||
# Messaging Code
|
||||
src/messaging @gauntface
|
||||
tests/messaging @gauntface
|
||||
packages/messaging @gauntface
|
||||
|
||||
# Auth Code
|
||||
src/auth.build.js @bojeil-google
|
||||
packages/auth @bojeil-google @wti806
|
||||
|
||||
+14
-11
@@ -1,12 +1,15 @@
|
||||
# Build/Dependencies
|
||||
node_modules
|
||||
dist
|
||||
.awcache
|
||||
/config/project.json
|
||||
|
||||
# Misc
|
||||
*.log
|
||||
|
||||
# OS Specific Files
|
||||
.DS_Store
|
||||
node_modules/
|
||||
/dist
|
||||
npm-debug.log
|
||||
/coverage
|
||||
/.nyc_output
|
||||
/tests/config
|
||||
temp/
|
||||
/.vscode
|
||||
/.ts-node
|
||||
/.idea
|
||||
/.awcache
|
||||
|
||||
# Editor Configs
|
||||
.idea
|
||||
.vscode
|
||||
@@ -0,0 +1,3 @@
|
||||
# This file is pre-built and need not be formatted
|
||||
packages/auth/src/auth.js
|
||||
dist
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
singleQuote: true,
|
||||
printWidth: 80
|
||||
}
|
||||
+3
-19
@@ -1,36 +1,20 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 6
|
||||
- stable
|
||||
cache: yarn
|
||||
|
||||
# Define global C++ compiler version
|
||||
env:
|
||||
global:
|
||||
- CXX=g++-4.8
|
||||
matrix:
|
||||
- TEST_ENV=node
|
||||
- TEST_ENV=browser
|
||||
before_install:
|
||||
# Yarn defaults to an old version, make sure we
|
||||
# get an up to date version
|
||||
- npm install -g yarn
|
||||
before_script:
|
||||
- export PATH=$PATH:./node_modules/.bin
|
||||
- mkdir -p tests/config && echo "$PROJECT_CONFIG" > tests/config/project.json
|
||||
- npm run test:setup -- --token $FIREBASE_TOKEN --projectId $FIREBASE_PROJECT
|
||||
script:
|
||||
gulp test --env="$TEST_ENV"
|
||||
|
||||
# Integration Test suite
|
||||
jobs:
|
||||
include:
|
||||
- stage: Integration Tests
|
||||
script: ./integration/webpack/runner.sh
|
||||
- script: ./integration/browserify/runner.sh
|
||||
- script: ./integration/typescript/runner.sh
|
||||
- script: ./integration/serviceWorker/runner.sh
|
||||
- script: ./integration/quickstart/runner.sh
|
||||
- script: ./integration/messaging/runner.sh
|
||||
- script: ./integration/firestore/runner.sh
|
||||
- xvfb-run npm test
|
||||
|
||||
# Misc Addons/Configs
|
||||
dist: trusty
|
||||
|
||||
Vendored
+26
-7
@@ -8,24 +8,43 @@
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Firestore Unit Tests (Node)",
|
||||
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
|
||||
"args": ["test", "--suite=firestore/unit/", "--env=node"],
|
||||
"port": 9229,
|
||||
"program": "${workspaceRoot}/packages/firestore/node_modules/.bin/_mocha",
|
||||
"cwd": "${workspaceRoot}/packages/firestore",
|
||||
"args": [
|
||||
"--compilers", "ts:ts-node/register",
|
||||
"-r", "src/platform_node/node_init.ts",
|
||||
"--retries", "5",
|
||||
"--timeout", "5000",
|
||||
"test/{,!(integration|browser)/**/}*.test.ts"
|
||||
],
|
||||
"sourceMaps": true,
|
||||
"protocol": "inspector"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Firestore Unit Tests (Browser)",
|
||||
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
|
||||
"args": ["test", "--suite=firestore/unit/", "--env=browser", "--debug"]
|
||||
"program": "${workspaceRoot}/packages/firestore/node_modules/.bin/karma",
|
||||
"cwd": "${workspaceRoot}/packages/firestore",
|
||||
"args": [
|
||||
"start",
|
||||
"--auto-watch",
|
||||
"--testFiles", "test/unit/bootstrap.ts",
|
||||
"--browsers", "Chrome"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Firestore Integration Tests (Browser)",
|
||||
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
|
||||
"args": ["test", "--suite=firestore/integration", "--env=browser", "--debug"]
|
||||
"program": "${workspaceRoot}/packages/firestore/node_modules/.bin/karma",
|
||||
"cwd": "${workspaceRoot}/packages/firestore",
|
||||
"args": [
|
||||
"start",
|
||||
"--auto-watch",
|
||||
"--testFiles", "test/integration/bootstrap.ts",
|
||||
"--browsers", "Chrome"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+1
-11
@@ -102,16 +102,6 @@ Before you start working on a larger contribution, you should get in touch with
|
||||
|
||||
That's it! Thank you for your contribution!
|
||||
|
||||
## <a name="commit-message-guidelines"></a> Commit Message Guidelines
|
||||
|
||||
This repository follows the commit message format defined by the
|
||||
[validate-commit-msg](https://npm.im/validate-commit-msg) package on NPM. This is
|
||||
to make the git history easy to follow, and make it easier to identify which
|
||||
commits are associated with features, bugfixes, etc.
|
||||
|
||||
We are also Commitizen friendly! If you have the [Commitizen CLI](https://npm.im/commitizen) installed
|
||||
you can simply use `git cz` to create properly formatted commit messages.
|
||||
|
||||
[archive]: https://github.com/firebase/firebase-js-sdk/issues?utf8=%E2%9C%93&q=is%3Aissue
|
||||
[file-an-issue]: https://github.com/firebase/firebase-js-sdk/issues/new
|
||||
[firebase-google-group]: https://groups.google.com/forum/#!forum/firebase-talk
|
||||
@@ -123,4 +113,4 @@ you can simply use `git cz` to create properly formatted commit messages.
|
||||
[jsbin]: http://jsbin.com/rinilu/edit?js,console
|
||||
[slack]: https://firebase-community.appspot.com/
|
||||
[stackoverflow]: http://stackoverflow.com/questions/tagged/firebase
|
||||
[support]: https://firebase.google.com/support/
|
||||
[support]: https://firebase.google.com/support/
|
||||
|
||||
@@ -16,150 +16,118 @@ To get started using Firebase, see
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before you can start working on the Firebase JS SDK, you need to have Node.js 6.0 or
|
||||
greater installed on your machine. After doing this, you must also install the
|
||||
dependencies for this package.
|
||||
#### Node.js
|
||||
|
||||
Before you can start working on the Firebase JS SDK, you need to have Node.js
|
||||
`8.0.0` or greater installed on your machine.
|
||||
|
||||
To download Node.js visit https://nodejs.org/en/download/.
|
||||
|
||||
Once you've verified that you are using version 6.0 or later (run `node -v` to see your
|
||||
current running version of Node.js), you can install the dependencies by running:
|
||||
_NOTE: You can use a tool like [`NVM`](https://github.com/creationix/nvm)
|
||||
or [`N`](https://github.com/tj/n) to install and manage multiple node versions_
|
||||
|
||||
#### Yarn
|
||||
|
||||
In addition to Node.js we use `yarn` to facilitate multi package development.
|
||||
|
||||
To install `yarn` follow the instructions listed on their website:
|
||||
https://yarnpkg.com/en/docs/install
|
||||
|
||||
#### Verify Prerequisites
|
||||
|
||||
You can verify your setup by running the following commands in your terminal:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ node -v
|
||||
$ yarn -v
|
||||
```
|
||||
|
||||
_NOTE: This package also maintains a `yarn.lock` so you can get faster installs by installing
|
||||
dependencies with `yarn` instead._
|
||||
Your Node.js version should be `8.0.0` or greater and your `yarn` version should
|
||||
be `1.0.0` or greater.
|
||||
|
||||
### Pipeline Instructions
|
||||
_NOTE: We will update the documentation as new versions are required, however
|
||||
for continuing development on the SDK, staying up to date on the stable versions
|
||||
of these packages is advised_
|
||||
|
||||
The Firebase JS SDK is built and tested through a gulp pipeline. You will need to
|
||||
have the `gulp` command available on your system to run the tasks yourself.
|
||||
### Install Dependencies
|
||||
|
||||
To install `gulp` simply run:
|
||||
Once you have Node.js and `yarn` installed on your machine and have validated
|
||||
that you are running the proper version, you can set up the development environment
|
||||
by running the following at the root of the SDK:
|
||||
|
||||
```bash
|
||||
$ npm install -g gulp-cli
|
||||
```
|
||||
|
||||
_NOTE: Installing `gulp-cli` is optional as you can simply leverage the npm commands
|
||||
for most interactions._
|
||||
|
||||
## Gulp Pipeline
|
||||
|
||||
Most of the tasks for interacting with the SDK are defined through gulp. If you
|
||||
installed gulp globally, you can run the following to see all of the available
|
||||
gulp tasks:
|
||||
|
||||
```bash
|
||||
gulp --tasks
|
||||
$ yarn
|
||||
```
|
||||
|
||||
## Testing the SDK
|
||||
|
||||
To run all tests for the SDK you must first supply a firebase project config for
|
||||
your tests. This is done by creating a file called `project.json` and at the
|
||||
following path:
|
||||
### Test Setup
|
||||
|
||||
```
|
||||
tests/config/project.json
|
||||
A production project is required to test the Firebase JS SDK. You can create a
|
||||
new project by visiting the [Firebase Console](https://console.firebase.google.com/).
|
||||
|
||||
#### Automated Setup
|
||||
|
||||
Most of the test setup can be done by running the following command at the root
|
||||
of the package:
|
||||
|
||||
```bash
|
||||
yarn test:setup
|
||||
```
|
||||
|
||||
This file should contain a JSON object with your app information (i.e. the same
|
||||
information you would pass to `firebase.initializeApp`).
|
||||
#### Authentication Support
|
||||
|
||||
### Project Config
|
||||
|
||||
The project supplied in your `project.json` needs to be properly configured to
|
||||
succesfully run the tests.
|
||||
|
||||
#### Database Rules
|
||||
|
||||
_i.e._
|
||||
|
||||
```json
|
||||
{
|
||||
"rules": {
|
||||
".read": "true",
|
||||
".write": "true"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Authentiaction Support
|
||||
|
||||
Enable the `Anonymous` sign-in provider.
|
||||
This is the only piece of config that must be done manually. Visit the
|
||||
authentication config in your project and enable the `Anonymous` sign-in
|
||||
provider to complete your project config.
|
||||
|
||||
### Running the tests
|
||||
|
||||
After you have the `project.json` and have properly configured the project,
|
||||
simply run: `npm test` at the root of this package.
|
||||
|
||||
You can also run the tests by calling `gulp test` if you have gulp installed.
|
||||
|
||||
You can decrease the testing scope by providing the optional `suite`/`env` arguments to `npm/gulp test`.
|
||||
|
||||
_e.g._
|
||||
Each of the directories in the `integration` directory as well as the `packages`
|
||||
directory have their own test suites. These can be run altogether by running the
|
||||
following command at the root of the package:
|
||||
|
||||
```bash
|
||||
$ gulp test --suite=firestore --env=node
|
||||
$ yarn test
|
||||
```
|
||||
|
||||
Any directory path in the tests directory serves as a valid value for the `--suite` flag.
|
||||
|
||||
Valid values for the `--env` flag are `node`/`browser`.
|
||||
|
||||
### Integration Tests
|
||||
|
||||
These tests are functionally different enough from the normal test suite that they have their own README.md. Please view it [here](./integration/README.md):
|
||||
In addition, you can run any of the tests individually by running `yarn test` in
|
||||
an individaul package directory.
|
||||
|
||||
## Building the SDK
|
||||
|
||||
### Introduction
|
||||
|
||||
The Javascript SDK is built through a gulp pipeline.
|
||||
The Firebase JS SDK is built with a series of individual packages that are all
|
||||
contained in this repository. Development is coordinated via [yarn
|
||||
workspaces](https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/) and
|
||||
[Lerna](https://lernajs.io/) (a monorepo management tool).
|
||||
|
||||
To build the project run `npm run build` in your CLI.
|
||||
Each package in the `packages` directory, constitute a piece of our
|
||||
implementation. The SDK is built via a combination of all of these packages
|
||||
which are published under the [`firebase`
|
||||
scope](https://www.npmjs.com/search?q=scope%3Afirebase) on NPM.
|
||||
|
||||
This will generate all of the output assets in a `/dist` folder available at the
|
||||
root of this project.
|
||||
### Helper Scripts
|
||||
|
||||
Each of the different types of source files are explained more in detail below.
|
||||
Each package in the `packages` directory exposes a `dev` script. This script
|
||||
will set up a watcher for development on the indiviual piece of the SDK. In
|
||||
addition, there is a top level `dev` script that can be run to start all of the
|
||||
watch tasks as well as a sandbox server.
|
||||
|
||||
### Source File Handling
|
||||
You can run the dev script by running the following at the root of the package:
|
||||
|
||||
Our source files are all located in the `/src` directory. This currently contains
|
||||
a variety of different sources (typescript, prebuilt binaries, legacy). We handle
|
||||
each of these cases in our gulp pipeline.
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
#### Typescript Source
|
||||
### Prepush Hooks
|
||||
|
||||
This is the planned source language for this repo. As we are able, all components
|
||||
will be migrated to typescript and processed in the following flow:
|
||||
|
||||
1. TS Files are compiled to ES6 using the Typescript compiler
|
||||
1. ES6 Files are transpiled to CJS Modules using Babel
|
||||
1. ES6 Files are processed with webpack to attach to the window global
|
||||
|
||||
#### Prebuilt Binaries
|
||||
|
||||
To allow firebase to build from Github we consume prebuilt binaries of our components
|
||||
until the source is migrated to this repo.
|
||||
|
||||
These files are processed in the following flow:
|
||||
|
||||
1. Prebuilt browser binaries are ready to consume individually in the browser
|
||||
however we need to wrap them in a CJS module wrapper for node/webpack/browserify
|
||||
consumption.
|
||||
1. The Firebase App binary is generated (from TS) and concatenated with the
|
||||
browser binaries of each individual module to create `firebase.js`.
|
||||
|
||||
#### Legacy Files
|
||||
|
||||
These files are built in this repo but are being migrated to typescript as we are able.
|
||||
Once these files are migrated, the associated build process, will be removed.
|
||||
As part of this repo, we use the NPM package [`husky`](https://npm.im/husky) to
|
||||
implement git hooks. We leverage the prepush hook to do two things:
|
||||
|
||||
- Automated code styling (using [`prettier`](https://npm.im/prettier))
|
||||
- Automated LICENSE header insertion
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"rules": {
|
||||
".read": true,
|
||||
".write": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"database": {
|
||||
"rules": "database.rules.json"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const karma = require('karma');
|
||||
const path = require('path');
|
||||
const webpackTestConfig = require('./webpack.test');
|
||||
|
||||
/**
|
||||
* Custom SauceLabs Launchers
|
||||
*/
|
||||
const sauceLabsBrowsers = {
|
||||
desktop_Safari: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'safari',
|
||||
platform: 'OS X 10.11',
|
||||
version: '9.0'
|
||||
},
|
||||
iOS_Safari: {
|
||||
appiumVersion: '1.6.5',
|
||||
base: 'SauceLabs',
|
||||
browserName: 'Safari',
|
||||
deviceName: 'iPhone Simulator',
|
||||
deviceOrientation: 'portrait',
|
||||
platformName: 'iOS',
|
||||
platformVersion: '9.0'
|
||||
},
|
||||
IE_11: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 8.1',
|
||||
version: '11'
|
||||
}
|
||||
};
|
||||
|
||||
const config = {
|
||||
// disable watcher
|
||||
autoWatch: false,
|
||||
|
||||
// Doing 65 seconds to allow for the 20 second firestore tests
|
||||
browserNoActivityTimeout: 65000,
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
'test/**/*.ts': ['webpack', 'sourcemap']
|
||||
},
|
||||
|
||||
mime: {
|
||||
'text/x-typescript': ['ts', 'tsx']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['spec' /*, 'saucelabs' */],
|
||||
|
||||
// web server port
|
||||
port: 8080,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: karma.constants.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
customLaunchers: sauceLabsBrowsers,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless'],
|
||||
|
||||
webpack: webpackTestConfig,
|
||||
|
||||
webpackMiddleware: {
|
||||
quiet: true,
|
||||
stats: {
|
||||
colors: true
|
||||
}
|
||||
},
|
||||
|
||||
sauceLabs: {
|
||||
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
|
||||
username: process.env.SAUCE_USERNAME,
|
||||
accessKey: process.env.SAUCE_ACCESS_KEY,
|
||||
startConnect: false
|
||||
},
|
||||
|
||||
singleRun: false
|
||||
};
|
||||
|
||||
// In CI environment, use saucelabs to test
|
||||
if (false /* process.env.TRAVIS */) {
|
||||
config.browsers = [...config.browsers, ...Object.keys(sauceLabsBrowsers)];
|
||||
}
|
||||
|
||||
module.exports = config;
|
||||
@@ -1,24 +1,20 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"lib": [
|
||||
"es5",
|
||||
"es2015",
|
||||
"es2015.promise",
|
||||
"dom"
|
||||
],
|
||||
"allowJs": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "tmp",
|
||||
"target": "ES5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": true,
|
||||
"typeRoots" : [
|
||||
"node_modules/@types"
|
||||
"target": "es5",
|
||||
"typeRoots": [
|
||||
"../node_modules/@types"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
devtool: 'eval-source-map',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
exclude: /node_modules/,
|
||||
use: 'ts-loader'
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: ['source-map-loader'],
|
||||
enforce: 'pre'
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
modules: ['node_modules', path.resolve(__dirname, '../../node_modules')],
|
||||
extensions: ['.js', '.ts']
|
||||
}
|
||||
};
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const path = require('path');
|
||||
const cwd = process.cwd();
|
||||
const karma = require('karma');
|
||||
|
||||
const configObj = {
|
||||
root: path.resolve(cwd),
|
||||
pkg: require(path.resolve(cwd, 'package.json')),
|
||||
testConfig: {
|
||||
timeout: 5000,
|
||||
retries: 5
|
||||
},
|
||||
tsconfig: require(path.resolve(cwd, 'tsconfig.json')),
|
||||
tsconfigTest: require(path.resolve(cwd, 'tsconfig.test.json')),
|
||||
paths: {
|
||||
outDir: path.resolve(cwd, 'dist'),
|
||||
tempDir: path.resolve(cwd, 'temp'),
|
||||
},
|
||||
babel: {
|
||||
plugins: [
|
||||
'add-module-exports',
|
||||
],
|
||||
presets: [
|
||||
['env', {
|
||||
"targets": {
|
||||
"browsers": [
|
||||
"ie >= 9"
|
||||
]
|
||||
},
|
||||
}]
|
||||
]
|
||||
},
|
||||
babelWebpack: {
|
||||
presets: [
|
||||
["env", {
|
||||
"modules": false,
|
||||
"targets": {
|
||||
"browsers": [
|
||||
"ie >= 9"
|
||||
]
|
||||
},
|
||||
}]
|
||||
]
|
||||
},
|
||||
karma: {
|
||||
autoWatch: false,
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
|
||||
browserNoActivityTimeout: 30000,
|
||||
|
||||
customHeaders: [{
|
||||
match: '.*',
|
||||
name: 'Service-Worker-Allowed',
|
||||
value: '/'
|
||||
}],
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: [
|
||||
'mocha',
|
||||
'karma-typescript'
|
||||
],
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
'**/*.ts': ['karma-typescript']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['spec'],
|
||||
|
||||
// web server port
|
||||
port: 8080,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: karma.constants.LOG_INFO,
|
||||
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless'],
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: 1,
|
||||
|
||||
// karma-typescript config
|
||||
karmaTypescriptConfig: {
|
||||
tsconfig: `./tsconfig.test.json`
|
||||
},
|
||||
|
||||
// Stub for client config
|
||||
client: {
|
||||
mocha: {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
configObj.karma.client.mocha.timeout = configObj.testConfig.timeout;
|
||||
configObj.karma.client.mocha.retries = configObj.testConfig.retries;
|
||||
|
||||
module.exports = configObj;
|
||||
@@ -1,440 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const gulp = require('gulp');
|
||||
const merge = require('merge2');
|
||||
const config = require('../config');
|
||||
const ts = require("gulp-typescript");
|
||||
const tsProject = ts.createProject('tsconfig.json');
|
||||
const babel = require('gulp-babel');
|
||||
const rename = require('gulp-rename');
|
||||
const through = require('through2');
|
||||
const path = require('path');
|
||||
const clone = require('gulp-clone');
|
||||
const webpack = require('webpack');
|
||||
const webpackStream = require('webpack-stream');
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const concat = require('gulp-concat');
|
||||
const replace = require('gulp-replace');
|
||||
const gulpFile = require('gulp-file');
|
||||
const rimraf = require('rimraf');
|
||||
const header = require('gulp-header');
|
||||
const gitRev = require('git-rev-sync');
|
||||
const gulpIf = require('gulp-if');
|
||||
const stripComments = require('gulp-strip-comments');
|
||||
const filesize = require('filesize');
|
||||
const glob = require('glob');
|
||||
const fs = require('fs');
|
||||
const gzipSize = require('gzip-size');
|
||||
const WrapperPlugin = require('wrapper-webpack-plugin');
|
||||
const { CheckerPlugin } = require('awesome-typescript-loader');
|
||||
|
||||
function cleanDist(dir) {
|
||||
return function cleanDistDirectory(done) {
|
||||
rimraf(`${config.paths.outDir}${ dir ? `/${dir}` : ''}`, done);
|
||||
}
|
||||
}
|
||||
|
||||
function compileTypescriptToES2015() {
|
||||
const stream = tsProject.src()
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(tsProject());
|
||||
return merge([
|
||||
stream.dts
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/es2015`)),
|
||||
stream.js
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/es2015`))
|
||||
]);
|
||||
};
|
||||
|
||||
function compileES2015ToCJS() {
|
||||
return gulp.src('dist/es2015/**/*.js')
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(babel(config.babel))
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/cjs`))
|
||||
};
|
||||
|
||||
function processPrebuiltFilesForBrowser() {
|
||||
return gulp.src([
|
||||
'src/**/*.build.js',
|
||||
])
|
||||
.pipe(stripComments())
|
||||
.pipe(rename(_path => {
|
||||
_path.basename = `firebase-${_path.basename.replace('.build', '')}`;
|
||||
return _path;
|
||||
}))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/browser`));
|
||||
}
|
||||
|
||||
function processPrebuiltFilesForCJS() {
|
||||
return gulp.src([
|
||||
'src/**/*.build.js',
|
||||
])
|
||||
.pipe(stripComments())
|
||||
.pipe(rename(_path => {
|
||||
_path.basename = `${_path.basename.replace('.build', '')}`;
|
||||
return _path;
|
||||
}))
|
||||
.pipe(through.obj(function(file, encoding, cb) {
|
||||
const _path = path.parse(file.path);
|
||||
const moduleName = _path.name.replace('.build', '').replace('-node', '');
|
||||
|
||||
file.contents = Buffer.concat([
|
||||
new Buffer(`var firebase = require('./app');
|
||||
(function(){`),
|
||||
file.contents,
|
||||
new Buffer(`}).call(typeof global !== undefined ? global : typeof self !== undefined ? self : typeof window !== undefined ? window : {});`)
|
||||
]);
|
||||
|
||||
this.push(file);
|
||||
return cb();
|
||||
}))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/cjs`));
|
||||
}
|
||||
|
||||
function compileIndvES2015ModulesToBrowser() {
|
||||
const isFirebaseApp = fileName => {
|
||||
const pathObj = path.parse(fileName);
|
||||
return pathObj.name === 'firebase-app';
|
||||
};
|
||||
|
||||
const webpackConfig = {
|
||||
devtool: 'source-map',
|
||||
entry: {
|
||||
'firebase-app': './src/app.ts',
|
||||
'firebase-storage': './src/storage.ts',
|
||||
'firebase-messaging': './src/messaging.ts',
|
||||
'firebase-database': './src/database.ts',
|
||||
'firebase-firestore': './src/firestore.ts',
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
jsonpFunction: 'webpackJsonpFirebase',
|
||||
path: path.resolve(__dirname, './dist/browser'),
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.tsx?$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'awesome-typescript-loader',
|
||||
options: {
|
||||
useCache: true,
|
||||
useBabel: true,
|
||||
babelOptions: config.babelWebpack
|
||||
}
|
||||
}]
|
||||
},
|
||||
plugins: [
|
||||
new CheckerPlugin(),
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'firebase-app'
|
||||
}),
|
||||
new WrapperPlugin({
|
||||
header: fileName => {
|
||||
return isFirebaseApp(fileName) ? `var firebase = (function() {
|
||||
var window = typeof window === 'undefined' ? self : window;
|
||||
return ` : `try {
|
||||
`;
|
||||
},
|
||||
footer: fileName => {
|
||||
// Note: '.default' needed because of https://github.com/babel/babel/issues/2212
|
||||
return isFirebaseApp(fileName) ? `
|
||||
})().default;` : `
|
||||
} catch(error) {
|
||||
throw new Error(
|
||||
'Cannot instantiate ${fileName} - ' +
|
||||
'be sure to load firebase-app.js first.'
|
||||
)
|
||||
}`
|
||||
}
|
||||
}),
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
sourceMap: true,
|
||||
mangle: {
|
||||
props: {
|
||||
ignore_quoted: true,
|
||||
// NOTE: Firestore uses __foo__ variables that must not be mangled.
|
||||
regex: /^_[^_]|[^_]_$/
|
||||
}
|
||||
},
|
||||
compress: {
|
||||
passes: 3,
|
||||
unsafe: true,
|
||||
warnings: false,
|
||||
}
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.js']
|
||||
},
|
||||
};
|
||||
|
||||
return gulp.src('src/**/*.ts')
|
||||
.pipe(webpackStream(webpackConfig, webpack))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/browser`));
|
||||
}
|
||||
|
||||
function buildBrowserFirebaseJs() {
|
||||
// Exclude firebase-firestore from combined firebase.js
|
||||
return gulp.src([
|
||||
'./dist/browser/*.js',
|
||||
'!./dist/browser/firebase-firestore.js'
|
||||
])
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(concat('firebase.js'))
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/browser`));
|
||||
}
|
||||
|
||||
function buildAltEnvFirebaseJs() {
|
||||
const babelConfig = Object.assign({}, config.babel, {
|
||||
plugins: config.babel.plugins
|
||||
});
|
||||
return gulp.src([
|
||||
'./dist/es2015/firebase-browser.js',
|
||||
'./dist/es2015/firebase-node.js',
|
||||
'./dist/es2015/firebase-react-native.js',
|
||||
])
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(babel(babelConfig))
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/cjs`));
|
||||
}
|
||||
|
||||
function copyPackageContents() {
|
||||
const copyBrowserCode = gulp.src('./dist/browser/**/*')
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/package`));
|
||||
|
||||
const copyCJSCode = gulp.src([
|
||||
'./dist/cjs/**/*',
|
||||
'!./dist/cjs/firebase.js*'
|
||||
])
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/package`));
|
||||
|
||||
return merge([
|
||||
copyBrowserCode,
|
||||
copyCJSCode
|
||||
]);
|
||||
}
|
||||
|
||||
function compileMetaFiles() {
|
||||
const outPkg = (_pkg => {
|
||||
// Format the new package.json
|
||||
let obj = Object.assign({}, _pkg, {
|
||||
scripts: null,
|
||||
devDependencies: null,
|
||||
main: 'firebase-node.js',
|
||||
browser: 'firebase-browser.js',
|
||||
'react-native': 'firebase-react-native.js',
|
||||
types: 'firebase.d.ts',
|
||||
nyc: null,
|
||||
babel: null,
|
||||
});
|
||||
|
||||
// Delete all props that are falsy
|
||||
for (let key in obj) {
|
||||
if (!obj[key]) delete obj[key];
|
||||
}
|
||||
|
||||
// Return formatted JSON string
|
||||
return JSON.stringify(obj, null, 2);
|
||||
})(config.pkg);
|
||||
|
||||
const pkgJson = gulpFile('package.json', outPkg, {src: true })
|
||||
|
||||
const copyFiles = gulp.src([
|
||||
'LICENSE',
|
||||
'./dist/global/*',
|
||||
'./typings/**/*'
|
||||
]);
|
||||
|
||||
const copyReadme = gulp.src('README.public.md')
|
||||
.pipe(rename({
|
||||
basename: 'README'
|
||||
}))
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/package/`));
|
||||
|
||||
const copyExterns = gulp.src('./externs/**/*')
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/package/externs`));
|
||||
|
||||
return merge([
|
||||
merge([copyFiles,pkgJson])
|
||||
.pipe(gulp.dest(`${config.paths.outDir}/package`)),
|
||||
copyExterns,
|
||||
copyReadme
|
||||
]);
|
||||
}
|
||||
|
||||
function injectSDKVersion() {
|
||||
return gulp.src('./dist/package/**/*', {base: '.'})
|
||||
.pipe(replace(/\${JSCORE_VERSION}/g, config.pkg.version))
|
||||
.pipe(gulp.dest('.'));
|
||||
}
|
||||
|
||||
function cleanComments() {
|
||||
return gulp.src([
|
||||
'./dist/package/**/*.js',
|
||||
'!./dist/package/externs/*'
|
||||
], {base: '.'})
|
||||
.pipe(stripComments({
|
||||
// TODO: Remove this comment in 3.8.0 release
|
||||
ignore: /\/\/# sourceMappingURL=.+\.map/g
|
||||
}))
|
||||
.pipe(gulp.dest('.'));
|
||||
}
|
||||
|
||||
function injectLicenseInfo() {
|
||||
const rev = gitRev.short();
|
||||
|
||||
const licenseHeader = `/*! @license Firebase v${config.pkg.version}
|
||||
Build: rev-${rev}
|
||||
Terms: https://firebase.google.com/terms/ */
|
||||
|
||||
`;
|
||||
|
||||
const bigLicenseHeader = `/*! @license Firebase v${config.pkg.version}
|
||||
Build: rev-${rev}
|
||||
Terms: https://firebase.google.com/terms/
|
||||
|
||||
---
|
||||
|
||||
typedarray.js
|
||||
Copyright (c) 2010, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE. */
|
||||
|
||||
`;
|
||||
|
||||
return gulp.src('./dist/package/**/*.js', {base: '.'})
|
||||
.pipe(gulpIf(file => {
|
||||
const _path = path.parse(file.path);
|
||||
return _path.base !== 'firebase.js' && !~_path.base.indexOf('database');
|
||||
},header(licenseHeader), header(bigLicenseHeader)))
|
||||
.pipe(gulp.dest('.'));
|
||||
}
|
||||
|
||||
function logFileSize(done) {
|
||||
console.log('\r\n| File | Parsed Size | Gzip Size');
|
||||
console.log('|----------|-------------|------|');
|
||||
|
||||
const filePaths = glob.sync('./dist/browser/*.js');
|
||||
filePaths
|
||||
.map(filePath => {
|
||||
const _path = path.parse(filePath);
|
||||
return path.resolve(_path.dir, `../package/${_path.base}`);
|
||||
})
|
||||
.map(filePath => {
|
||||
const _path = path.parse(filePath);
|
||||
const fileContents = fs.readFileSync(filePath, 'utf8');
|
||||
const rawSize = fs.statSync(filePath).size;
|
||||
const size = filesize(rawSize);
|
||||
const gzip = filesize(gzipSize.sync(fileContents));
|
||||
return {
|
||||
file: _path.base,
|
||||
size,
|
||||
gzip
|
||||
};
|
||||
})
|
||||
.forEach(obj => console.log(`| ${obj.file} | ${obj.size} | ${obj.gzip} |`));
|
||||
|
||||
console.log('\r\n');
|
||||
done();
|
||||
}
|
||||
|
||||
/**
|
||||
* GULP TASKS
|
||||
*
|
||||
* Gulp tasks in Gulp 4.0 are a description of a series of functions.
|
||||
* The functions are all above and are easier to maintain individually
|
||||
*
|
||||
* Each "task" is then responsible for wiring up the dep trees itself,
|
||||
* because of this you have a finer degree of control of the ordering
|
||||
* of your tasks **and** you can optimize the parallelization of each
|
||||
* task.
|
||||
*/
|
||||
|
||||
gulp.task('build:es2015', gulp.series([
|
||||
compileTypescriptToES2015,
|
||||
]));
|
||||
|
||||
gulp.task('build:cjs', gulp.parallel([
|
||||
gulp.series([
|
||||
compileTypescriptToES2015,
|
||||
gulp.parallel(compileES2015ToCJS, buildAltEnvFirebaseJs)
|
||||
]),
|
||||
processPrebuiltFilesForCJS,
|
||||
]));
|
||||
|
||||
gulp.task('process:prebuilt', gulp.parallel([
|
||||
processPrebuiltFilesForBrowser,
|
||||
processPrebuiltFilesForCJS
|
||||
]));
|
||||
|
||||
// This is the optimized build path, we reuse this in
|
||||
// a couple places so capturing it here
|
||||
const compileSourceAssets = gulp.series([
|
||||
compileTypescriptToES2015,
|
||||
gulp.parallel([
|
||||
compileIndvES2015ModulesToBrowser,
|
||||
compileES2015ToCJS,
|
||||
])
|
||||
]);
|
||||
|
||||
gulp.task('build:browser', gulp.series([
|
||||
// Build the src assets and prebuilt assets in
|
||||
// parallel
|
||||
gulp.parallel([
|
||||
compileSourceAssets,
|
||||
processPrebuiltFilesForBrowser,
|
||||
]),
|
||||
buildBrowserFirebaseJs
|
||||
]));
|
||||
|
||||
const buildSDK = exports.buildSDK = gulp.series([
|
||||
cleanDist(),
|
||||
gulp.parallel([
|
||||
compileSourceAssets,
|
||||
processPrebuiltFilesForBrowser,
|
||||
processPrebuiltFilesForCJS,
|
||||
compileMetaFiles
|
||||
]),
|
||||
gulp.parallel(buildBrowserFirebaseJs, buildAltEnvFirebaseJs),
|
||||
copyPackageContents,
|
||||
injectLicenseInfo,
|
||||
injectSDKVersion,
|
||||
logFileSize
|
||||
]);
|
||||
|
||||
gulp.task('build', buildSDK);
|
||||
@@ -1,127 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const gulp = require('gulp');
|
||||
const mocha = require('gulp-mocha');
|
||||
const setEnv = require('gulp-env').set;
|
||||
const karma = require('karma');
|
||||
const config = require('../config');
|
||||
const buildTasks = require('./build');
|
||||
const argv = require('yargs').argv;
|
||||
|
||||
function runNodeTest(suite = '**') {
|
||||
/**
|
||||
* Custom error handler for "No test files found" errors
|
||||
*/
|
||||
return gulp.src([
|
||||
`tests/**/${suite}/**/*.test.ts`,
|
||||
'src/firestore/platform_node/node_init.ts',
|
||||
// TODO(b/66918026): Re-enable Firestore integration tests on node.
|
||||
'!tests/firestore/integration/**/*.test.ts',
|
||||
'!tests/**/browser/**/*.test.ts',
|
||||
'!tests/**/binary/**/*.test.ts',
|
||||
'!src/firebase-*.ts',
|
||||
], { read: false })
|
||||
.pipe(setEnv({
|
||||
TS_NODE_PROJECT: 'tsconfig.test.json'
|
||||
}))
|
||||
.pipe(mocha({
|
||||
reporter: 'spec',
|
||||
compilers: 'ts:ts-node/register',
|
||||
timeout: config.testConfig.timeout,
|
||||
retries: config.testConfig.retries,
|
||||
inspect: true
|
||||
}))
|
||||
.on('error', err => {
|
||||
if (err && err.message && ~err.message.indexOf('No test files found')) return;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
function runBrowserTest(suite = '.*', debug) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let karmaConfig = Object.assign({}, config.karma, {
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
`./src/**/*.ts`,
|
||||
`./tests/**/*.ts`,
|
||||
{ pattern: `./tests/config/**/*`, included: false, served: true }
|
||||
],
|
||||
|
||||
// list of files to exclude from the included globs above
|
||||
exclude: [
|
||||
// we don't want this file as it references files that only exist once compiled
|
||||
`./src/firebase-*.ts`,
|
||||
|
||||
// We don't want to load the node env
|
||||
`./src/utils/nodePatches.ts`,
|
||||
|
||||
// Don't include node test files
|
||||
'./tests/**/node/**/*.test.ts',
|
||||
|
||||
// Don't include binary test files
|
||||
'./tests/**/binary/**/*.test.ts',
|
||||
],
|
||||
});
|
||||
|
||||
Object.assign(karmaConfig.karmaTypescriptConfig, {
|
||||
bundlerOptions: {
|
||||
entrypoints: new RegExp(`^.*tests/${suite}.*\.test\.ts$|^.*src/firestore/platform_browser/browser_init.ts$`)
|
||||
}
|
||||
});
|
||||
|
||||
if (debug) {
|
||||
karmaConfig = Object.assign({}, karmaConfig, {
|
||||
autoWatch: true,
|
||||
singleRun: false,
|
||||
browsers: ['Chrome']
|
||||
});
|
||||
|
||||
Object.assign(karmaConfig.karmaTypescriptConfig, {
|
||||
coverageOptions: {
|
||||
instrumentation: false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
new karma.Server(karmaConfig, exitcode => {
|
||||
if (exitcode) return reject(exitcode);
|
||||
resolve();
|
||||
}).start();
|
||||
});
|
||||
}
|
||||
|
||||
function runTests(devMode) {
|
||||
const suite = argv.suite || '';
|
||||
const env = argv.env || '*';
|
||||
const debug = !!argv.debug || false;
|
||||
console.log('debug:', debug);
|
||||
console.log(`Values: ${suite}:${env}`);
|
||||
|
||||
switch(env) {
|
||||
case 'node': return runNodeTest(suite);
|
||||
case 'browser': return runBrowserTest(suite, debug);
|
||||
default:
|
||||
// Incidentally this works returning a stream and promise value
|
||||
return Promise.all([
|
||||
runNodeTest(suite),
|
||||
runBrowserTest(suite, debug),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
exports.runTests = runTests;
|
||||
|
||||
gulp.task('test', runTests);
|
||||
@@ -1,5 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src='dist/browser/firebase.js'></script>
|
||||
</head>
|
||||
</html>
|
||||
@@ -1,37 +0,0 @@
|
||||
# Integration Test Suites
|
||||
|
||||
These test suites are high level validation suites that are largely coupled to an environment. They will test things like:
|
||||
|
||||
- Service Worker Integration
|
||||
- Compatability with Webpack/Browserify/Typescript etc
|
||||
- High level UI testing
|
||||
- Others with same kinds of environmental restriction
|
||||
|
||||
Each test suite is expected to be fully isolated so some small duplication of config files and such is expected.
|
||||
|
||||
Each suite also contains a `runner.sh` file that contains the logic to actually test the module. **Make no assumptions** as you write these tests as nothing is provided by default (e.g. the current codebase hasn't built yet, test config files may not exist, etc).
|
||||
|
||||
## `shared` Directory
|
||||
|
||||
The `shared` directory in this folder currently contains two files:
|
||||
|
||||
- `namespaceDefinition.json`
|
||||
- `validator.js`
|
||||
|
||||
These two files can be used to validate the firebase namespace and currently serves as the base for many of our integration tests.
|
||||
|
||||
_NOTE: `validator.js` should only be used **after** initializing a test firebase app (i.e. make a call to `firebase.initializeApp` before validating the namespace)_
|
||||
|
||||
## Authoring an Integration Test
|
||||
|
||||
The point of the integration tests is to be as flexible as possible. The only convention that I would recommend is supplying a `runner.sh` file to do the actual work of the test.
|
||||
|
||||
That said, if you are looking for a pattern to follow, the process that was followed for several of the tests, is outlined below:
|
||||
|
||||
- Copy the test files to a temporary working directory
|
||||
- Setup an `EXIT` trap to cleanup the temporary directory at the end of the script
|
||||
- Ensure that the SDK gets built if it doesn't already exist
|
||||
- `npm install` the folder `dist/package`, this allows the test to function as if the SDK was installed from NPM
|
||||
- (For tests that are only validating the firebase namespace) copy the `shared` directory above into the working directory
|
||||
|
||||
The tests are then ran with karma/mocha/webdriver.io/selenium or whatever else you need to accomplish the purpose of your test. Each of these runners requires their own config (and sometimes their own dependencies), supply these config files directly in the test directory (e.g. many of the suites have their own package.json) as the tests are meant to be isolated from each other as much as possible.
|
||||
@@ -14,49 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Karma configuration
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
const karma = require('karma');
|
||||
const path = require('path');
|
||||
const karmaBase = require('../../config/karma.base');
|
||||
|
||||
module.exports = function(config) {
|
||||
const karmaConfig = Object.assign({}, karmaBase, {
|
||||
// files to load into karma
|
||||
files: [{ pattern: `dist/**/*` }],
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha'],
|
||||
frameworks: ['mocha']
|
||||
});
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'build/**/*'
|
||||
],
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['spec'],
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless'],
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity
|
||||
})
|
||||
}
|
||||
config.set(karmaConfig);
|
||||
};
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
{
|
||||
"name": "firebase-browserify-test",
|
||||
"version": "1.0.0",
|
||||
"main": "runner.sh",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"pretest": "mkdirp dist && browserify src/namespace.test.js -o dist/namespace.test.js",
|
||||
"test": "karma start --single-run"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^14.4.0",
|
||||
"chai": "^3.5.0",
|
||||
"browserify": "^14.4.0",
|
||||
"chai": "^4.1.1",
|
||||
"karma": "^1.7.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sauce-launcher": "^1.2.0",
|
||||
"karma-spec-reporter": "0.0.31",
|
||||
"mocha": "^3.5.0"
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^3.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Variables
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
|
||||
GULP_CLI="$ROOT/node_modules/.bin/gulp"
|
||||
BROWSERIFY_CLI="$ROOT/node_modules/.bin/browserify"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
WORK_DIR=`mktemp -d`
|
||||
|
||||
# check if tmp dir was created
|
||||
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
|
||||
echo "Could not create temp dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# deletes the temp directory
|
||||
function cleanup {
|
||||
rm -rf "$WORK_DIR"
|
||||
echo "Deleted temp working directory $WORK_DIR"
|
||||
}
|
||||
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
trap cleanup EXIT
|
||||
|
||||
# Enter work dir
|
||||
pushd "$WORK_DIR"
|
||||
|
||||
if [ ! -d "$ROOT/dist/package" ]; then
|
||||
pushd $ROOT
|
||||
$GULP_CLI build
|
||||
popd
|
||||
fi
|
||||
|
||||
# Simulate env
|
||||
cp $DIR/* .
|
||||
cp $DIR/../shared/* .
|
||||
npm install
|
||||
npm install "$ROOT/dist/package"
|
||||
|
||||
# Build the new env
|
||||
mkdir -p build
|
||||
./node_modules/.bin/browserify namespace.test.js -o build/bundle.js
|
||||
|
||||
# Run the tests
|
||||
./node_modules/.bin/karma start
|
||||
+4
-4
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
const firebase = require('firebase');
|
||||
const namespaceDefinition = require('./namespaceDefinition');
|
||||
const validateNamespace = require('./validator');
|
||||
const namespaceDefinition = require('../../shared/namespaceDefinition');
|
||||
const validateNamespace = require('../../shared/validator');
|
||||
|
||||
firebase.initializeApp({
|
||||
apiKey: 'test-api-key',
|
||||
@@ -27,6 +27,6 @@ firebase.initializeApp({
|
||||
messagingSenderId: '012345678910'
|
||||
});
|
||||
|
||||
describe("Firebase Namespace Validation", function() {
|
||||
describe('Firebase Namespace Validation', function() {
|
||||
validateNamespace(namespaceDefinition, firebase);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
These tests are intended to be run against the minified compiled version of the
|
||||
firebase binary (i.e. `firebase.js` and `firebase-firestore.js` of the `firebase`
|
||||
package).
|
||||
|
||||
They are currently just rerunning tests against the uncompiled version and we
|
||||
need to address that.
|
||||
@@ -21,14 +21,10 @@ module.exports = function(config) {
|
||||
config.set({
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: [
|
||||
'mocha',
|
||||
],
|
||||
frameworks: ['mocha'],
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
{ pattern: 'tests/**/*.test.ts' }
|
||||
],
|
||||
files: [{ pattern: 'tests/**/*.test.ts' }],
|
||||
|
||||
client: {
|
||||
mocha: {
|
||||
@@ -43,7 +39,7 @@ module.exports = function(config) {
|
||||
},
|
||||
|
||||
mime: {
|
||||
'text/x-typescript': ['ts','tsx']
|
||||
'text/x-typescript': ['ts', 'tsx']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
@@ -70,5 +66,5 @@ module.exports = function(config) {
|
||||
singleRun: true,
|
||||
|
||||
webpack: webpackConfig
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -19,13 +19,15 @@ const webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.tsx?$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'ts-loader'
|
||||
}]
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'ts-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts']
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Currently `firebase-js-sdk` does not have any selenium support so these
|
||||
tests need to be run manually until such a time that support is made available
|
||||
and tests are ported over.
|
||||
@@ -23,11 +23,11 @@ Promise.all([
|
||||
seleniumAssistant.downloadLocalBrowser('chrome', 'unstable', 48),
|
||||
seleniumAssistant.downloadLocalBrowser('firefox', 'stable', 48),
|
||||
seleniumAssistant.downloadLocalBrowser('firefox', 'beta', 48),
|
||||
seleniumAssistant.downloadLocalBrowser('firefox', 'unstable', 48),
|
||||
seleniumAssistant.downloadLocalBrowser('firefox', 'unstable', 48)
|
||||
])
|
||||
.then(() => {
|
||||
console.log('Browser download complete.');
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Browser download failed.');
|
||||
});
|
||||
.then(() => {
|
||||
console.log('Browser download complete.');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Browser download failed.');
|
||||
});
|
||||
|
||||
Generated
-1908
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"name": "firebase-messaging-selenium-test",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"test": "node ./download-browsers.js && mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.1.1",
|
||||
"chromedriver": "^2.31.0",
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -ev
|
||||
|
||||
# Variables
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
|
||||
GULP_CLI="$ROOT/node_modules/.bin/gulp"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
WORK_DIR=`mktemp -d`
|
||||
|
||||
# check if tmp dir was created
|
||||
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
|
||||
echo "Could not create temp dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# deletes the temp directory
|
||||
function cleanup {
|
||||
rm -rf "$WORK_DIR"
|
||||
echo "Deleted temp working directory $WORK_DIR"
|
||||
}
|
||||
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
# trap cleanup EXIT
|
||||
|
||||
# Enter work dir
|
||||
pushd "$WORK_DIR"
|
||||
|
||||
if [ ! -d "$ROOT/dist/package" ]; then
|
||||
pushd $ROOT
|
||||
$GULP_CLI build
|
||||
popd
|
||||
fi
|
||||
|
||||
# Simulate env
|
||||
cp -r $DIR/* .
|
||||
npm install
|
||||
|
||||
echo "$ROOT/dist/package"
|
||||
npm install "$ROOT/dist/package"
|
||||
|
||||
if hash xvfb-run 2>/dev/null; then
|
||||
xvfb-run npm run test
|
||||
else
|
||||
npm run test
|
||||
fi
|
||||
@@ -33,7 +33,7 @@ describe('Firebase Messaging Integration Tests', () => {
|
||||
return testServer.stop();
|
||||
});
|
||||
|
||||
const performTestInBrowser = (seleniumBrowser) => {
|
||||
const performTestInBrowser = seleniumBrowser => {
|
||||
// Mocha must have functions in describe and it functions due to its
|
||||
// binding behavior
|
||||
describe(`Test Messaging in ${seleniumBrowser.getPrettyName()}`, function() {
|
||||
@@ -47,11 +47,14 @@ describe('Firebase Messaging Integration Tests', () => {
|
||||
this.timeout(10 * 1000);
|
||||
|
||||
// Configure the notification permissions
|
||||
switch(seleniumBrowser.getId()) {
|
||||
switch (seleniumBrowser.getId()) {
|
||||
case 'firefox': {
|
||||
const ffProfile = new seleniumFirefox.Profile();
|
||||
ffProfile.setPreference('security.turn_off_all_security_so_that_' +
|
||||
'viruses_can_take_over_this_computer', true);
|
||||
ffProfile.setPreference(
|
||||
'security.turn_off_all_security_so_that_' +
|
||||
'viruses_can_take_over_this_computer',
|
||||
true
|
||||
);
|
||||
ffProfile.setPreference('dom.push.testing.ignorePermission', true);
|
||||
ffProfile.setPreference('notification.prompt.testing', true);
|
||||
ffProfile.setPreference('notification.prompt.testing.allow', true);
|
||||
@@ -64,23 +67,25 @@ describe('Firebase Messaging Integration Tests', () => {
|
||||
profile: {
|
||||
content_settings: {
|
||||
exceptions: {
|
||||
notifications: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
notifications: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
chromePreferences.profile.content_settings.
|
||||
exceptions.notifications[testServer.serverAddress + ',*'] = {
|
||||
setting: 1,
|
||||
chromePreferences.profile.content_settings.exceptions.notifications[
|
||||
testServer.serverAddress + ',*'
|
||||
] = {
|
||||
setting: 1
|
||||
};
|
||||
seleniumBrowser.getSeleniumOptions().setUserPreferences(chromePreferences);
|
||||
seleniumBrowser
|
||||
.getSeleniumOptions()
|
||||
.setUserPreferences(chromePreferences);
|
||||
/* eslint-enable camelcase */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return seleniumBrowser.getSeleniumDriver()
|
||||
.then((driver) => {
|
||||
return seleniumBrowser.getSeleniumDriver().then(driver => {
|
||||
currentWebDriver = driver;
|
||||
});
|
||||
});
|
||||
@@ -94,16 +99,17 @@ describe('Firebase Messaging Integration Tests', () => {
|
||||
});
|
||||
|
||||
const getInPageToken = () => {
|
||||
return currentWebDriver.wait(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return document.querySelector('.js-token').textContent.length > 0;
|
||||
return currentWebDriver
|
||||
.wait(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return document.querySelector('.js-token').textContent.length > 0;
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return document.querySelector('.js-token').textContent;
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return document.querySelector('.js-token').textContent;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const sendFCMMessage = (endpoint, apiBody) => {
|
||||
@@ -111,116 +117,144 @@ describe('Firebase Messaging Integration Tests', () => {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(apiBody),
|
||||
headers: {
|
||||
'Authorization': 'key=AIzaSyCqJkOa5awRsZ-1EyuAwU4loC3YXDBouIo',
|
||||
Authorization: 'key=AIzaSyCqJkOa5awRsZ-1EyuAwU4loC3YXDBouIo',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
// FCM will return HTML is there is an error so we can't parse
|
||||
// the response as JSON, instead have to read as text, then parse
|
||||
// then handle the possible error.
|
||||
return response.text()
|
||||
.then((responseText) => {
|
||||
try {
|
||||
return JSON.parse(responseText);
|
||||
} catch (err) {
|
||||
throw new Error(`Unexpected response: '${responseText}'`);
|
||||
.then(response => {
|
||||
// FCM will return HTML is there is an error so we can't parse
|
||||
// the response as JSON, instead have to read as text, then parse
|
||||
// then handle the possible error.
|
||||
return response.text().then(responseText => {
|
||||
try {
|
||||
return JSON.parse(responseText);
|
||||
} catch (err) {
|
||||
throw new Error(`Unexpected response: '${responseText}'`);
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(responseObj => {
|
||||
if (responseObj.success !== 1) {
|
||||
throw new Error(
|
||||
'Unexpected response: ' + JSON.stringify(responseObj)
|
||||
);
|
||||
}
|
||||
});
|
||||
})
|
||||
.then((responseObj) => {
|
||||
if (responseObj.success !== 1) {
|
||||
throw new Error('Unexpected response: ' +JSON.stringify(responseObj));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getInPageMessage = () => {
|
||||
return currentWebDriver.wait(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return document.querySelectorAll('.js-message-list > li').length > 0;
|
||||
return currentWebDriver
|
||||
.wait(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return (
|
||||
document.querySelectorAll('.js-message-list > li').length > 0
|
||||
);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return document.querySelector('.js-message-list > li:first-child')
|
||||
.textContent;
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return currentWebDriver.executeScript(() => {
|
||||
return document.querySelector('.js-message-list > li:first-child').textContent;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const performTest = (dataPayload, notificationPayload) => {
|
||||
return currentWebDriver.get(`${testServer.serverAddress}/demo-valid/`)
|
||||
.then(() => getInPageToken())
|
||||
.then((fcmToken) => {
|
||||
const fcmAPIPayload = {};
|
||||
fcmAPIPayload.to = fcmToken;
|
||||
const performTest = (dataPayload, notificationPayload, context) => {
|
||||
return currentWebDriver
|
||||
.get(`${testServer.serverAddress}/demo-valid/`)
|
||||
.then(() => getInPageToken())
|
||||
.then(fcmToken => {
|
||||
const fcmAPIPayload = {};
|
||||
fcmAPIPayload.to = fcmToken;
|
||||
|
||||
if (dataPayload != null) {
|
||||
fcmAPIPayload.data = dataPayload;
|
||||
}
|
||||
if (dataPayload != null) {
|
||||
fcmAPIPayload.data = dataPayload;
|
||||
}
|
||||
|
||||
if (notificationPayload != null) {
|
||||
fcmAPIPayload.notification = notificationPayload;
|
||||
}
|
||||
if (notificationPayload != null) {
|
||||
fcmAPIPayload.notification = notificationPayload;
|
||||
}
|
||||
|
||||
return sendFCMMessage(PROD_ENDPOINT, fcmAPIPayload);
|
||||
})
|
||||
.then(() => {
|
||||
return getInPageMessage();
|
||||
})
|
||||
.then((inPageMessage) => {
|
||||
const inPageObj = JSON.parse(inPageMessage);
|
||||
if (dataPayload) {
|
||||
expect(inPageObj.data).to.deep.equal(dataPayload);
|
||||
} else {
|
||||
expect(typeof inPageObj.data).to.equal('undefined');
|
||||
}
|
||||
if (notificationPayload) {
|
||||
expect(inPageObj.notification).to.deep.equal(notificationPayload);
|
||||
} else {
|
||||
expect(typeof inPageObj.notification).to.equal('undefined');
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
return new Promise((resolve) => setTimeout(resolve, 4000));
|
||||
});
|
||||
return sendFCMMessage(PROD_ENDPOINT, fcmAPIPayload);
|
||||
})
|
||||
.then(() => {
|
||||
return getInPageMessage();
|
||||
})
|
||||
.then(inPageMessage => {
|
||||
const inPageObj = JSON.parse(inPageMessage);
|
||||
if (dataPayload) {
|
||||
expect(inPageObj.data).to.deep.equal(dataPayload);
|
||||
} else {
|
||||
expect(typeof inPageObj.data).to.equal('undefined');
|
||||
}
|
||||
if (notificationPayload) {
|
||||
expect(inPageObj.notification).to.deep.equal(notificationPayload);
|
||||
} else {
|
||||
expect(typeof inPageObj.notification).to.equal('undefined');
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
return new Promise(resolve => setTimeout(resolve, 4000));
|
||||
})
|
||||
.catch(err => {
|
||||
if (seleniumBrowser.getReleaseName() === 'unstable') {
|
||||
console.warn(
|
||||
chalk`{yellow WARNING: Test failed in unstable browser, skipping}`
|
||||
);
|
||||
console.warn(err);
|
||||
if (context) {
|
||||
return context.skip();
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
|
||||
it('should send and receive messages with no payload', function() {
|
||||
return performTest(null, null);
|
||||
return performTest(null, null, this);
|
||||
});
|
||||
|
||||
it('should send and receive messages with data payload', function() {
|
||||
return performTest({hello: 'world'}, null);
|
||||
return performTest({ hello: 'world' }, null, this);
|
||||
});
|
||||
|
||||
it('should send and receive messages with notification payload', function() {
|
||||
return performTest(null, {
|
||||
title: 'Test Title',
|
||||
body: 'Test Body',
|
||||
icon: '/test/icon.png',
|
||||
click_action: '/',
|
||||
tag: 'test-tag',
|
||||
});
|
||||
return performTest(
|
||||
null,
|
||||
{
|
||||
title: 'Test Title',
|
||||
body: 'Test Body',
|
||||
icon: '/test/icon.png',
|
||||
click_action: '/',
|
||||
tag: 'test-tag'
|
||||
},
|
||||
this
|
||||
);
|
||||
});
|
||||
|
||||
it('should send and receive messages with data & notification payload', function() {
|
||||
return performTest({hello: 'world'}, {
|
||||
title: 'Test Title',
|
||||
body: 'Test Body',
|
||||
icon: '/test/icon.png',
|
||||
click_action: '/',
|
||||
tag: 'test-tag',
|
||||
});
|
||||
return performTest(
|
||||
{ hello: 'world' },
|
||||
{
|
||||
title: 'Test Title',
|
||||
body: 'Test Body',
|
||||
icon: '/test/icon.png',
|
||||
click_action: '/',
|
||||
tag: 'test-tag'
|
||||
},
|
||||
this
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const availableBrowsers = seleniumAssistant.getLocalBrowsers();
|
||||
availableBrowsers.forEach((assistantBrowser) => {
|
||||
availableBrowsers.forEach(assistantBrowser => {
|
||||
// Only test on Chrome and Firefox
|
||||
if (assistantBrowser.getId() !== 'chrome' &&
|
||||
assistantBrowser.getId() !== 'firefox') {
|
||||
if (
|
||||
assistantBrowser.getId() !== 'chrome' &&
|
||||
assistantBrowser.getId() !== 'firefox'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
<h6>Notification Only</h6>
|
||||
<p class="js-notification-curl-command"></p>
|
||||
|
||||
<script src="/node_modules/firebase/firebase-app.js"></script>
|
||||
<script src="/node_modules/firebase/firebase-messaging.js"></script>
|
||||
<script src="/firebase/firebase-app.js"></script>
|
||||
<script src="/firebase/firebase-messaging.js"></script>
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -35,19 +35,21 @@ class DemoApp {
|
||||
this._getTokenBtn = document.querySelector('.js-get-token');
|
||||
this._deleteTokenBtn = document.querySelector('.js-delete-token');
|
||||
this._dataCurlCommandElement = document.querySelector(
|
||||
'.js-data-curl-command');
|
||||
'.js-data-curl-command'
|
||||
);
|
||||
this._notificationCurlCommandElement = document.querySelector(
|
||||
'.js-notification-curl-command');
|
||||
'.js-notification-curl-command'
|
||||
);
|
||||
|
||||
this.disableAllButtons_();
|
||||
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyA_hMf2etaedqV5eJC9Hyv7_YoA3zJIKhc",
|
||||
authDomain: "fcm-sdk-testing.firebaseapp.com",
|
||||
databaseURL: "https://fcm-sdk-testing.firebaseio.com",
|
||||
storageBucket: "fcm-sdk-testing.appspot.com",
|
||||
messagingSenderId: "153517668099"
|
||||
apiKey: 'AIzaSyA_hMf2etaedqV5eJC9Hyv7_YoA3zJIKhc',
|
||||
authDomain: 'fcm-sdk-testing.firebaseapp.com',
|
||||
databaseURL: 'https://fcm-sdk-testing.firebaseio.com',
|
||||
storageBucket: 'fcm-sdk-testing.appspot.com',
|
||||
messagingSenderId: '153517668099'
|
||||
};
|
||||
firebase.initializeApp(config);
|
||||
|
||||
@@ -61,12 +63,14 @@ class DemoApp {
|
||||
this.initializeBtnListeners_();
|
||||
|
||||
// Initializa state of token
|
||||
this._messaging.getToken()
|
||||
.then(token => {
|
||||
this.updateUI_(token);
|
||||
}, () => {
|
||||
this.updateUI_();
|
||||
});
|
||||
this._messaging.getToken().then(
|
||||
token => {
|
||||
this.updateUI_(token);
|
||||
},
|
||||
() => {
|
||||
this.updateUI_();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,33 +82,36 @@ class DemoApp {
|
||||
this._permissionsBtn.addEventListener('click', () => {
|
||||
this.disableAllButtons_();
|
||||
|
||||
this._messaging.requestPermission()
|
||||
.then(() => this.updateUI_())
|
||||
.catch(err => {
|
||||
this.handleError_(err);
|
||||
this.updateUI_();
|
||||
});
|
||||
this._messaging
|
||||
.requestPermission()
|
||||
.then(() => this.updateUI_())
|
||||
.catch(err => {
|
||||
this.handleError_(err);
|
||||
this.updateUI_();
|
||||
});
|
||||
});
|
||||
|
||||
this._deleteTokenBtn.addEventListener('click', () => {
|
||||
this.disableAllButtons_();
|
||||
|
||||
this._messaging.getToken()
|
||||
.then(token => {
|
||||
if (token) {
|
||||
return this._messaging.deleteToken(token);
|
||||
}
|
||||
})
|
||||
.then(() => this.updateUI_())
|
||||
.catch(err => this.handleError_(err));
|
||||
this._messaging
|
||||
.getToken()
|
||||
.then(token => {
|
||||
if (token) {
|
||||
return this._messaging.deleteToken(token);
|
||||
}
|
||||
})
|
||||
.then(() => this.updateUI_())
|
||||
.catch(err => this.handleError_(err));
|
||||
});
|
||||
|
||||
this._getTokenBtn.addEventListener('click', () => {
|
||||
this.disableAllButtons_();
|
||||
|
||||
this._messaging.getToken()
|
||||
.then(token => this.updateUI_(token))
|
||||
.catch(err => this.handleError_(err));
|
||||
this._messaging
|
||||
.getToken()
|
||||
.then(token => this.updateUI_(token))
|
||||
.catch(err => this.handleError_(err));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,12 +129,14 @@ class DemoApp {
|
||||
populateCurlDetails_(token) {
|
||||
const serverKey = 'AIzaSyCqJkOa5awRsZ-1EyuAwU4loC3YXDBouIo';
|
||||
const endpoint = 'https://jmt17.google.com';
|
||||
const dataCurlCommand = `curl ` +
|
||||
const dataCurlCommand =
|
||||
`curl ` +
|
||||
`--header "Authorization: key=${serverKey}" ` +
|
||||
`--header "Content-Type: application/json" ` +
|
||||
`-d '{\"to\": \"${token}\", \"data\": {\"Hello\": \"World\"}}' ` +
|
||||
`${endpoint}/gcm/send`;
|
||||
const notificationCurlCommand = `curl ` +
|
||||
const notificationCurlCommand =
|
||||
`curl ` +
|
||||
`--header "Authorization: key=${serverKey}" ` +
|
||||
`--header "Content-Type: application/json" ` +
|
||||
`-d '{\"to\": \"${token}\", \"notification\": ` +
|
||||
@@ -152,7 +161,7 @@ class DemoApp {
|
||||
* if available.
|
||||
*/
|
||||
updateUI_(currentToken) {
|
||||
switch(Notification.permission) {
|
||||
switch (Notification.permission) {
|
||||
case 'granted':
|
||||
this._permissionsBtn.disabled = true;
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
importScripts('/node_modules/firebase/firebase-app.js');
|
||||
importScripts('/node_modules/firebase/firebase-messaging.js');
|
||||
importScripts('/firebase/firebase-app.js');
|
||||
importScripts('/firebase/firebase-messaging.js');
|
||||
|
||||
firebase.initializeApp({
|
||||
messagingSenderId: "153517668099"
|
||||
messagingSenderId: '153517668099'
|
||||
});
|
||||
|
||||
const messaging = firebase.messaging();
|
||||
|
||||
@@ -23,7 +23,11 @@ class MessagingTestServer {
|
||||
constructor() {
|
||||
this._app = express();
|
||||
this._app.use('/', express.static(__dirname));
|
||||
this._app.use('/node_modules', express.static(path.join(__dirname, '..', '..', 'node_modules')));
|
||||
console.log('Firebase Path:', path.dirname(require.resolve('firebase')));
|
||||
this._app.use(
|
||||
'/firebase',
|
||||
express.static(path.dirname(require.resolve('firebase')))
|
||||
);
|
||||
this._app.use('/', express.static(path.join(__dirname, 'shared-files')));
|
||||
|
||||
this._server = null;
|
||||
@@ -34,7 +38,7 @@ class MessagingTestServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
return `http://localhost:${PORT_NUMBER}`
|
||||
return `http://localhost:${PORT_NUMBER}`;
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -43,7 +47,7 @@ class MessagingTestServer {
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this._server = this._app.listen(PORT_NUMBER, function () {
|
||||
this._server = this._app.listen(PORT_NUMBER, function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
@@ -53,7 +57,7 @@ class MessagingTestServer {
|
||||
// currently open sockets. So call `closethis._server
|
||||
stop() {
|
||||
if (!this._server) {
|
||||
return Promise.resolve();;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
this._server.close();
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
|
||||
// Karma configuration
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: [
|
||||
'mocha',
|
||||
'karma-typescript'
|
||||
],
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
{ pattern: 'src/**/*.ts' }
|
||||
],
|
||||
|
||||
preprocessors: {
|
||||
'**/*.ts': ['karma-typescript']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['spec', 'karma-typescript'],
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless'],
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true,
|
||||
})
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "firebase-quickstart-test",
|
||||
"version": "1.0.0",
|
||||
"main": "runner.sh",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^3.4.35",
|
||||
"@types/mocha": "^2.2.39",
|
||||
"@types/node": "^7.0.8",
|
||||
"chai": "^3.5.0",
|
||||
"firebase-tools": "^3.9.2",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"serve": "^6.0.6",
|
||||
"ts-node": "^3.3.0",
|
||||
"typescript": "^2.4.2",
|
||||
"wdio-mocha-framework": "^0.5.10",
|
||||
"wdio-sauce-service": "^0.4.0",
|
||||
"wdio-selenium-standalone-service": "0.0.9",
|
||||
"wdio-spec-reporter": "^0.1.0",
|
||||
"webdriverio": "^4.8.0"
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -ev
|
||||
|
||||
# Variables
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
|
||||
GULP_CLI="$ROOT/node_modules/.bin/gulp"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
WORK_DIR=`mktemp -d`
|
||||
|
||||
# check if tmp dir was created
|
||||
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
|
||||
echo "Could not create temp dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# deletes the temp directory
|
||||
function cleanup {
|
||||
echo "Deleting temp working directory $WORK_DIR"
|
||||
rm -rf "$WORK_DIR"
|
||||
echo "Killing child processes"
|
||||
pkill -P $$
|
||||
}
|
||||
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
trap cleanup EXIT
|
||||
|
||||
# Validate that we have the necessary configs
|
||||
[ -z "$FIREBASE_TOKEN" ] && { echo "Environment variable FIREBASE_TOKEN not set"; exit 1; }
|
||||
[ -z "$FIREBASE_PROJECT" ] && { echo "Environment variable FIREBASE_PROJECT not set"; exit 1; }
|
||||
|
||||
# Enter work dir
|
||||
pushd "$WORK_DIR"
|
||||
|
||||
if [ ! -d "$ROOT/dist/package" ]; then
|
||||
pushd $ROOT
|
||||
$GULP_CLI build
|
||||
popd
|
||||
fi
|
||||
|
||||
# Simulate env
|
||||
cp -r $DIR/* .
|
||||
npm install
|
||||
npm install "$ROOT/dist/package"
|
||||
|
||||
# Mount the new SDK
|
||||
./node_modules/.bin/serve ./node_modules/firebase -p 5000 &
|
||||
|
||||
startFirebaseServer() {
|
||||
# Capture variables
|
||||
local DIR="$1"
|
||||
local PORT="$2"
|
||||
|
||||
# Enter the passed directory
|
||||
pushd $DIR
|
||||
|
||||
# Start firebase server
|
||||
"$WORK_DIR/node_modules/.bin/firebase" use --add $FIREBASE_PROJECT --token $FIREBASE_TOKEN
|
||||
"$WORK_DIR/node_modules/.bin/firebase" serve -p $PORT &
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
# Enter temp dir
|
||||
pushd $(mktemp -d)
|
||||
|
||||
# Clone https://github.com/firebase/quickstart-js
|
||||
git clone https://github.com/firebase/quickstart-js.git .
|
||||
|
||||
# Edit the source to point to our new binaries
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
sed -i '.bak' 's/\/__\/firebase\/3.9.0/http:\/\/localhost:5000/g' **/*.html
|
||||
else
|
||||
sed -i 's/\/__\/firebase\/3.9.0/http:\/\/localhost:5000/g' **/*.html
|
||||
fi
|
||||
|
||||
# Start servers
|
||||
startFirebaseServer storage 5001
|
||||
startFirebaseServer database 5002
|
||||
|
||||
# Go back to firebase-js-sdk
|
||||
popd
|
||||
|
||||
# Give the servers a few seconds to spin up
|
||||
sleep 10
|
||||
|
||||
# Exec tests
|
||||
"$WORK_DIR/node_modules/webdriverio/bin/wdio"
|
||||
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
declare var $: any;
|
||||
declare var $$: any;
|
||||
declare var browser: any;
|
||||
declare var window: any;
|
||||
import { expect } from 'chai';
|
||||
|
||||
const testUrl = 'http://localhost:5002';
|
||||
|
||||
function createNewPost(title: string) {
|
||||
browser.click('#add');
|
||||
browser.waitForVisible('#message-form');
|
||||
browser.setValue('#new-post-title', title);
|
||||
browser.setValue('#new-post-message', `Test post`);
|
||||
browser.click('button[type=submit]');
|
||||
browser.waitForVisible('#user-posts-list');
|
||||
}
|
||||
|
||||
function clearSession() {
|
||||
browser.execute(() => {
|
||||
window.firebase.auth().signOut();
|
||||
window.firebase.auth().signInAnonymously();
|
||||
});
|
||||
|
||||
waitForSession();
|
||||
|
||||
browser.click('#menu-recent');
|
||||
browser.waitUntil(() => {
|
||||
const classes = browser.getAttribute('#menu-recent', 'class');
|
||||
return ~classes.indexOf('is-active');
|
||||
});
|
||||
}
|
||||
|
||||
function waitForSession() {
|
||||
browser.waitUntil(() => {
|
||||
return browser.execute(() => {
|
||||
return (
|
||||
window.firebase &&
|
||||
window.firebase.auth() &&
|
||||
!!window.firebase.auth().currentUser
|
||||
);
|
||||
}).value;
|
||||
});
|
||||
}
|
||||
|
||||
describe('Database Tests', function() {
|
||||
beforeEach(function() {
|
||||
browser.url(testUrl);
|
||||
expect(browser.getTitle()).to.equal('Firebase Database Quickstart');
|
||||
|
||||
browser.waitUntil(() => browser.execute(() => !!window.firebase).value);
|
||||
|
||||
clearSession();
|
||||
});
|
||||
it('Should properly post a new topic (db push)', function() {
|
||||
const title = `Post at (${new Date().getTime()})`;
|
||||
|
||||
createNewPost(title);
|
||||
|
||||
const text = browser.getText(
|
||||
'#user-posts-list .post .mdl-card__title-text'
|
||||
);
|
||||
expect(text).to.equal(title);
|
||||
});
|
||||
it('Should properly like a post (db transaction)', function() {
|
||||
createNewPost('Likable Post');
|
||||
|
||||
browser.click('#user-posts-list .post .star .not-starred');
|
||||
const count = browser.getText('#user-posts-list .post .star .star-count');
|
||||
|
||||
expect(parseInt(count, 10)).to.equal(1);
|
||||
});
|
||||
it('Should properly read a post/like from another user', function() {
|
||||
const title = `Likable Post (${new Date().getTime()})`;
|
||||
|
||||
createNewPost(title);
|
||||
browser.click('#user-posts-list .post:first-child .star .not-starred');
|
||||
|
||||
clearSession();
|
||||
|
||||
browser.waitForExist('#recent-posts-list .post');
|
||||
|
||||
const createdPost = $(`h4=${title}`).$('../../..');
|
||||
const initialCount = parseInt(createdPost.$('.star-count').getText(), 10);
|
||||
expect(initialCount).to.not.be.undefined;
|
||||
|
||||
createdPost
|
||||
.$$('.star .material-icons')
|
||||
.filter((el: any) => el.isVisible())
|
||||
.reduce((val: any, el: any) => val || el, null)
|
||||
.click();
|
||||
|
||||
const finalCount = parseInt(createdPost.$('.star-count').getText(), 10);
|
||||
|
||||
expect(finalCount).to.equal(initialCount + 1);
|
||||
});
|
||||
});
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
declare var browser: any;
|
||||
declare var window: any;
|
||||
|
||||
import { expect } from 'chai';
|
||||
import { resolve } from 'path';
|
||||
import 'isomorphic-fetch';
|
||||
|
||||
describe('Storage Tests', function() {
|
||||
beforeEach(function() {
|
||||
browser.url('http://localhost:5001');
|
||||
expect(browser.getTitle()).to.equal(
|
||||
'Firebase SDK for Cloud Storage Quickstart'
|
||||
);
|
||||
|
||||
// Pause to allow for anonymous sign in (POTENTIAL RACE CONDITION HERE)
|
||||
browser.waitUntil(() => {
|
||||
const result = browser.execute(
|
||||
() =>
|
||||
window.firebase &&
|
||||
window.firebase.auth() &&
|
||||
!!window.firebase.auth().currentUser
|
||||
);
|
||||
|
||||
return result.value;
|
||||
});
|
||||
});
|
||||
it('Should properly upload a file with anonymous auth', async function() {
|
||||
browser.chooseFile('#file', resolve(__dirname, './test.json'));
|
||||
const textSelector = '#linkbox a';
|
||||
browser.waitForExist(textSelector, 5000);
|
||||
const url = browser.getAttribute(textSelector, 'href');
|
||||
|
||||
expect(url).to.contain('firebasestorage');
|
||||
|
||||
const file = await fetch(url);
|
||||
expect(await file.json()).to.deep.equal(require('./test.json'));
|
||||
});
|
||||
});
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempor elit mi, nec ullamcorper neque lacinia vitae. Nulla porttitor ac mauris a mollis. Praesent pellentesque lacinia metus, in commodo risus vulputate eget. Vestibulum volutpat ullamcorper porta. Phasellus fringilla faucibus nisi, at sodales dolor maximus nec. Integer quis purus sed urna viverra pellentesque. Suspendisse potenti. Phasellus lobortis sagittis metus quis accumsan. Suspendisse pulvinar pretium mauris, quis congue risus scelerisque ac. Morbi quis placerat ante, in congue elit. Suspendisse et enim dictum, varius est quis, hendrerit nibh. Fusce vitae molestie sapien. Duis finibus cursus quam sed blandit."
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
exports.config = {
|
||||
user: process.env.SAUCE_USERNAME,
|
||||
key: process.env.SAUCE_ACCESS_KEY,
|
||||
//
|
||||
// ==================
|
||||
// Specify Test Files
|
||||
// ==================
|
||||
// Define which test specs should run. The pattern is relative to the directory
|
||||
// from which `wdio` was called. Notice that, if you are calling `wdio` from an
|
||||
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
|
||||
// directory is where your package.json resides, so `wdio` will be called from there.
|
||||
//
|
||||
specs: [
|
||||
'./src/**/*.ts'
|
||||
],
|
||||
// Patterns to exclude.
|
||||
exclude: [
|
||||
// 'path/to/excluded/files'
|
||||
],
|
||||
//
|
||||
// ============
|
||||
// Capabilities
|
||||
// ============
|
||||
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
|
||||
// time. Depending on the number of capabilities, WebdriverIO launches several test
|
||||
// sessions. Within your capabilities you can overwrite the spec and exclude options in
|
||||
// order to group specific specs to a specific capability.
|
||||
//
|
||||
// First, you can define how many instances should be started at the same time. Let's
|
||||
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
|
||||
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
|
||||
// files and you set maxInstances to 10, all spec files will get tested at the same time
|
||||
// and 30 processes will get spawned. The property handles how many capabilities
|
||||
// from the same test should run tests.
|
||||
//
|
||||
maxInstances: 10,
|
||||
//
|
||||
// If you have trouble getting all important capabilities together, check out the
|
||||
// Sauce Labs platform configurator - a great tool to configure your capabilities:
|
||||
// https://docs.saucelabs.com/reference/platforms-configurator
|
||||
//
|
||||
capabilities: [{
|
||||
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
|
||||
// grid with only 5 firefox instances available you can make sure that not more than
|
||||
// 5 instances get started at a time.
|
||||
maxInstances: 5,
|
||||
//
|
||||
browserName: 'chrome'
|
||||
}],
|
||||
//
|
||||
// ===================
|
||||
// Test Configurations
|
||||
// ===================
|
||||
// Define all options that are relevant for the WebdriverIO instance here
|
||||
//
|
||||
// By default WebdriverIO commands are executed in a synchronous way using
|
||||
// the wdio-sync package. If you still want to run your tests in an async way
|
||||
// e.g. using promises you can set the sync option to false.
|
||||
sync: true,
|
||||
//
|
||||
// Level of logging verbosity: silent | verbose | command | data | result | error
|
||||
logLevel: 'verbose',
|
||||
//
|
||||
// Enables colors for log output.
|
||||
coloredLogs: true,
|
||||
//
|
||||
// If you only want to run your tests until a specific amount of tests have failed use
|
||||
// bail (default is 0 - don't bail, run all tests).
|
||||
bail: 0,
|
||||
//
|
||||
// Saves a screenshot to a given path if a command fails.
|
||||
screenshotPath: './errorShots/',
|
||||
//
|
||||
// Set a base URL in order to shorten url command calls. If your url parameter starts
|
||||
// with "/", then the base url gets prepended.
|
||||
baseUrl: 'http://localhost',
|
||||
//
|
||||
// Default timeout for all waitFor* commands.
|
||||
waitforTimeout: 30000,
|
||||
//
|
||||
// Default timeout in milliseconds for request
|
||||
// if Selenium Grid doesn't send response
|
||||
connectionRetryTimeout: 90000,
|
||||
//
|
||||
// Default request retries count
|
||||
connectionRetryCount: 3,
|
||||
//
|
||||
// Initialize the browser instance with a WebdriverIO plugin. The object should have the
|
||||
// plugin name as key and the desired plugin options as properties. Make sure you have
|
||||
// the plugin installed before running any tests. The following plugins are currently
|
||||
// available:
|
||||
// WebdriverCSS: https://github.com/webdriverio/webdrivercss
|
||||
// WebdriverRTC: https://github.com/webdriverio/webdriverrtc
|
||||
// Browserevent: https://github.com/webdriverio/browserevent
|
||||
// plugins: {
|
||||
// webdrivercss: {
|
||||
// screenshotRoot: 'my-shots',
|
||||
// failedComparisonsRoot: 'diffs',
|
||||
// misMatchTolerance: 0.05,
|
||||
// screenWidth: [320,480,640,1024]
|
||||
// },
|
||||
// webdriverrtc: {},
|
||||
// browserevent: {}
|
||||
// },
|
||||
//
|
||||
// Test runner services
|
||||
// Services take over a specific job you don't want to take care of. They enhance
|
||||
// your test setup with almost no effort. Unlike plugins, they don't add new
|
||||
// commands. Instead, they hook themselves up into the test process.
|
||||
// services: [],//
|
||||
services: ['sauce'],
|
||||
|
||||
sauceConnect: true,
|
||||
sauceConnectOpts: {
|
||||
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
|
||||
},
|
||||
// Framework you want to run your specs with.
|
||||
// The following are supported: Mocha, Jasmine, and Cucumber
|
||||
// see also: http://webdriver.io/guide/testrunner/frameworks.html
|
||||
//
|
||||
// Make sure you have the wdio adapter package for the specific framework installed
|
||||
// before running any tests.
|
||||
framework: 'mocha',
|
||||
//
|
||||
// Test reporter for stdout.
|
||||
// The only one supported by default is 'dot'
|
||||
// see also: http://webdriver.io/guide/testrunner/reporters.html
|
||||
reporters: ['spec'],
|
||||
|
||||
//
|
||||
// Options to be passed to Mocha.
|
||||
// See the full list at http://mochajs.org/
|
||||
mochaOpts: {
|
||||
ui: 'bdd',
|
||||
compilers: ['ts:ts-node/register'],
|
||||
timeout: 60000
|
||||
},
|
||||
//
|
||||
// =====
|
||||
// Hooks
|
||||
// =====
|
||||
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
|
||||
// it and to build services around it. You can either apply a single function or an array of
|
||||
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
|
||||
// resolved to continue.
|
||||
/**
|
||||
* Gets executed once before all workers get launched.
|
||||
* @param {Object} config wdio configuration object
|
||||
* @param {Array.<Object>} capabilities list of capabilities details
|
||||
*/
|
||||
// onPrepare: function (config, capabilities) {
|
||||
// },
|
||||
/**
|
||||
* Gets executed just before initialising the webdriver session and test framework. It allows you
|
||||
* to manipulate configurations depending on the capability or spec.
|
||||
* @param {Object} config wdio configuration object
|
||||
* @param {Array.<Object>} capabilities list of capabilities details
|
||||
* @param {Array.<String>} specs List of spec file paths that are to be run
|
||||
*/
|
||||
// beforeSession: function (config, capabilities, specs) {
|
||||
// },
|
||||
/**
|
||||
* Gets executed before test execution begins. At this point you can access to all global
|
||||
* variables like `browser`. It is the perfect place to define custom commands.
|
||||
* @param {Array.<Object>} capabilities list of capabilities details
|
||||
* @param {Array.<String>} specs List of spec file paths that are to be run
|
||||
*/
|
||||
// before: function (capabilities, specs) {
|
||||
// },
|
||||
//
|
||||
/**
|
||||
* Hook that gets executed before the suite starts
|
||||
* @param {Object} suite suite details
|
||||
*/
|
||||
// beforeSuite: function (suite) {
|
||||
// },
|
||||
/**
|
||||
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
|
||||
* beforeEach in Mocha)
|
||||
*/
|
||||
// beforeHook: function () {
|
||||
// },
|
||||
/**
|
||||
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
|
||||
* afterEach in Mocha)
|
||||
*/
|
||||
// afterHook: function () {
|
||||
// },
|
||||
/**
|
||||
* Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
||||
* @param {Object} test test details
|
||||
*/
|
||||
// beforeTest: function (test) {
|
||||
// },
|
||||
/**
|
||||
* Runs before a WebdriverIO command gets executed.
|
||||
* @param {String} commandName hook command name
|
||||
* @param {Array} args arguments that command would receive
|
||||
*/
|
||||
// beforeCommand: function (commandName, args) {
|
||||
// },
|
||||
/**
|
||||
* Runs after a WebdriverIO command gets executed
|
||||
* @param {String} commandName hook command name
|
||||
* @param {Array} args arguments that command would receive
|
||||
* @param {Number} result 0 - command success, 1 - command error
|
||||
* @param {Object} error error object if any
|
||||
*/
|
||||
// afterCommand: function (commandName, args, result, error) {
|
||||
// },
|
||||
/**
|
||||
* Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
||||
* @param {Object} test test details
|
||||
*/
|
||||
// afterTest: function (test) {
|
||||
// },
|
||||
/**
|
||||
* Hook that gets executed after the suite has ended
|
||||
* @param {Object} suite suite details
|
||||
*/
|
||||
// afterSuite: function (suite) {
|
||||
// },
|
||||
/**
|
||||
* Gets executed after all tests are done. You still have access to all global variables from
|
||||
* the test.
|
||||
* @param {Number} result 0 - test pass, 1 - test fail
|
||||
* @param {Array.<Object>} capabilities list of capabilities details
|
||||
* @param {Array.<String>} specs List of spec file paths that ran
|
||||
*/
|
||||
// after: function (result, capabilities, specs) {
|
||||
// },
|
||||
/**
|
||||
* Gets executed right after terminating the webdriver session.
|
||||
* @param {Object} config wdio configuration object
|
||||
* @param {Array.<Object>} capabilities list of capabilities details
|
||||
* @param {Array.<String>} specs List of spec file paths that ran
|
||||
*/
|
||||
// afterSession: function (config, capabilities, specs) {
|
||||
// },
|
||||
/**
|
||||
* Gets executed after all workers got shut down and the process is about to exit. It is not
|
||||
* possible to defer the end of the process using a promise.
|
||||
* @param {Object} exitCode 0 - success, 1 - fail
|
||||
*/
|
||||
// onComplete: function(exitCode) {
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Karma configuration
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha'],
|
||||
|
||||
customHeaders: [{
|
||||
match: '.*',
|
||||
name: 'Service-Worker-Allowed',
|
||||
value: '/'
|
||||
}],
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'build/**/*',
|
||||
{ pattern: 'serviceWorker.js', served: true, included: false },
|
||||
{ pattern: 'node_modules/firebase/**/*', served: true, included: false }
|
||||
],
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['spec'],
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless'],
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity
|
||||
})
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "firebase-service-worker-test",
|
||||
"version": "1.0.0",
|
||||
"main": "runner.sh",
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"karma": "^1.7.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-spec-reporter": "0.0.31",
|
||||
"mocha": "^3.5.0",
|
||||
"webpack": "^3.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Variables
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
|
||||
GULP_CLI="$ROOT/node_modules/.bin/gulp"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
WORK_DIR=`mktemp -d`
|
||||
|
||||
# check if tmp dir was created
|
||||
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
|
||||
echo "Could not create temp dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# deletes the temp directory
|
||||
function cleanup {
|
||||
rm -rf "$WORK_DIR"
|
||||
echo "Deleted temp working directory $WORK_DIR"
|
||||
}
|
||||
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
trap cleanup EXIT
|
||||
|
||||
# Enter work dir
|
||||
pushd "$WORK_DIR"
|
||||
|
||||
if [ ! -d "$ROOT/dist/package" ]; then
|
||||
pushd $ROOT
|
||||
$GULP_CLI build
|
||||
popd
|
||||
fi
|
||||
|
||||
# Simulate env
|
||||
cp $DIR/* .
|
||||
npm install
|
||||
npm install "$ROOT/dist/package"
|
||||
|
||||
# Build the new env
|
||||
./node_modules/.bin/webpack
|
||||
|
||||
# Run the tests
|
||||
./node_modules/.bin/karma start
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
importScripts('./node_modules/firebase/firebase-app.js');
|
||||
|
||||
addEventListener('install', function(event) {
|
||||
// Dynamically load the latest service-worker (w/o reloading or closing
|
||||
// the current open tabs).
|
||||
event.waitUntil(self.skipWaiting());
|
||||
});
|
||||
|
||||
addEventListener('activate', function(event) {
|
||||
event.waitUntil(self.clients.claim());
|
||||
});
|
||||
|
||||
addEventListener('fetch', function(event) {
|
||||
if (event.request.url.endsWith('/SDK_VERSION')) {
|
||||
const res = new Response(JSON.stringify(firebase.SDK_VERSION), {
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
event.respondWith(res);
|
||||
}
|
||||
});
|
||||
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe("Firebase App Service Worker", function() {
|
||||
// Long Timeout to Allow plenty of time for service worker registration
|
||||
this.timeout(Infinity);
|
||||
let swRegistration;
|
||||
before("Load Service Worker", function() {
|
||||
expect(navigator.serviceWorker).to.be.ok;
|
||||
|
||||
// Service worker is a root - so it can process ALL requests to the domain.
|
||||
// Using absolute path and the webpack and browserify builds will have
|
||||
// builds of these test file with different subdirectory structures in temp/
|
||||
const swFile = '/base/serviceWorker.js';
|
||||
|
||||
return navigator.serviceWorker.register(swFile, {scope: '/'})
|
||||
.then(function(registration) {
|
||||
return (swRegistration = registration);
|
||||
})
|
||||
.then(function(registration) {
|
||||
return new Promise(function(resolve) {
|
||||
const interval = setInterval(function() {
|
||||
if (registration.active) {
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}
|
||||
}, 150);
|
||||
});
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.error('SW Registration Error');
|
||||
console.error('Attempted to register: ', swFile);
|
||||
console.error('Error msg: ', error.message);
|
||||
console.error('Error stack: ', JSON.stringify(error.stack));
|
||||
throw error;
|
||||
});
|
||||
});
|
||||
|
||||
after('Unload Service Worker', function() {
|
||||
return swRegistration && swRegistration.unregister();
|
||||
});
|
||||
|
||||
it("Firebase version in worker", function() {
|
||||
return fetch('/SDK_VERSION')
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(json) {
|
||||
expect(json).to.contain('4.');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -33,8 +33,12 @@ function validateNamespace(definition, candidate) {
|
||||
* Grab all of the keys that aren't meta properties and capture
|
||||
* them for more testing later
|
||||
*/
|
||||
const internalKeys = Object.keys(definitionChunk).filter(iKey => !~iKey.indexOf('__'));
|
||||
const returnKeys = Object.keys(definitionChunk).filter(iKey => ~iKey.indexOf('__return'));
|
||||
const internalKeys = Object.keys(definitionChunk).filter(
|
||||
iKey => !~iKey.indexOf('__')
|
||||
);
|
||||
const returnKeys = Object.keys(definitionChunk).filter(
|
||||
iKey => ~iKey.indexOf('__return')
|
||||
);
|
||||
describe(`${key}`, function() {
|
||||
/**
|
||||
* Tests of the actual API
|
||||
@@ -49,7 +53,7 @@ function validateNamespace(definition, candidate) {
|
||||
* If both the definition and candidate pieces are truthy
|
||||
* then we can continue validation of the nested layers
|
||||
*/
|
||||
if(definitionChunk && candidateChunk) {
|
||||
if (definitionChunk && candidateChunk) {
|
||||
validateNamespace(definitionChunk, candidateChunk);
|
||||
}
|
||||
|
||||
@@ -67,11 +71,16 @@ function validateNamespace(definition, candidate) {
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
if (definitionChunk.__type === 'function' && definitionChunk.__return && candidateChunk()) {
|
||||
validateNamespace(definitionChunk.__return, candidateChunk());
|
||||
if (
|
||||
definitionChunk.__type === 'function' &&
|
||||
definitionChunk.__return &&
|
||||
typeof candidateChunk === 'function' &&
|
||||
candidateChunk()
|
||||
) {
|
||||
validateNamespace(definitionChunk.__return, candidateChunk());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = validateNamespace;
|
||||
module.exports = validateNamespace;
|
||||
|
||||
@@ -14,48 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const karma = require('karma');
|
||||
const path = require('path');
|
||||
const karmaBase = require('../../config/karma.base');
|
||||
|
||||
// Karma configuration
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
const karmaConfig = Object.assign({}, karmaBase, {
|
||||
// files to load into karma
|
||||
files: ['test/**/*.test.*'],
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: [
|
||||
'mocha',
|
||||
'karma-typescript'
|
||||
],
|
||||
frameworks: ['mocha']
|
||||
});
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
{ pattern: 'src/**/*.ts' }
|
||||
],
|
||||
|
||||
preprocessors: {
|
||||
'**/*.ts': ['karma-typescript']
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['spec', 'karma-typescript'],
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless'],
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true,
|
||||
})
|
||||
}
|
||||
config.set(karmaConfig);
|
||||
};
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
{
|
||||
"name": "firebase-typescript-test",
|
||||
"version": "1.0.0",
|
||||
"main": "runner.sh",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"test": "karma start --single-run"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^3.4.35",
|
||||
"@types/chai": "^4.0.4",
|
||||
"@types/mocha": "^2.2.39",
|
||||
"@types/node": "^7.0.8",
|
||||
"chai": "^3.5.0",
|
||||
"chai": "^4.1.1",
|
||||
"karma": "^1.7.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sauce-launcher": "^1.2.0",
|
||||
"karma-spec-reporter": "0.0.31",
|
||||
"karma-typescript": "^3.0.5",
|
||||
"mocha": "^3.5.0",
|
||||
"npm-run-all": "^4.1.1",
|
||||
"typescript": "^2.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Variables
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
|
||||
GULP_CLI="$ROOT/node_modules/.bin/gulp"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
WORK_DIR=`mktemp -d`
|
||||
|
||||
# check if tmp dir was created
|
||||
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
|
||||
echo "Could not create temp dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# deletes the temp directory
|
||||
function cleanup {
|
||||
rm -rf "$WORK_DIR"
|
||||
echo "Deleted temp working directory $WORK_DIR"
|
||||
}
|
||||
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
trap cleanup EXIT
|
||||
|
||||
# Enter work dir
|
||||
pushd "$WORK_DIR"
|
||||
|
||||
if [ ! -d "$ROOT/dist/package" ]; then
|
||||
pushd $ROOT
|
||||
$GULP_CLI build
|
||||
popd
|
||||
fi
|
||||
|
||||
# Simulate env
|
||||
cp -r $DIR/* .
|
||||
cp $DIR/../shared/* ./src
|
||||
npm install
|
||||
npm install "$ROOT/dist/package"
|
||||
|
||||
# Run the tests (this compiles the tests)
|
||||
./node_modules/.bin/karma start
|
||||
+2
-2
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
import * as firebase from 'firebase';
|
||||
import * as namespaceDefinition from './namespaceDefinition.json';
|
||||
import * as validateNamespace from './validator';
|
||||
import * as namespaceDefinition from '../../shared/namespaceDefinition.json';
|
||||
import * as validateNamespace from '../../shared/validator';
|
||||
|
||||
firebase.initializeApp({
|
||||
apiKey: 'test-api-key',
|
||||
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"extends": "../../config/tsconfig.base.json",
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"declaration": false,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "tmp",
|
||||
"outDir": "dist",
|
||||
"target": "ES5",
|
||||
"sourceMap": true,
|
||||
"typeRoots" : [
|
||||
"node_modules/@types"
|
||||
]
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,49 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Karma configuration
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
const karma = require('karma');
|
||||
const path = require('path');
|
||||
const karmaBase = require('../../config/karma.base');
|
||||
|
||||
module.exports = function(config) {
|
||||
const karmaConfig = Object.assign({}, karmaBase, {
|
||||
// files to load into karma
|
||||
files: [{ pattern: `dist/**/*` }],
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha'],
|
||||
frameworks: ['mocha']
|
||||
});
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'build/**/*'
|
||||
],
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['spec'],
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless'],
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity
|
||||
})
|
||||
}
|
||||
config.set(karmaConfig);
|
||||
};
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
{
|
||||
"name": "firebase-webpack-test",
|
||||
"version": "1.0.0",
|
||||
"main": "runner.sh",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"pretest": "webpack",
|
||||
"test": "karma start --single-run"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"chai": "^4.1.1",
|
||||
"karma": "^1.7.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sauce-launcher": "^1.2.0",
|
||||
"karma-spec-reporter": "0.0.31",
|
||||
"mocha": "^3.5.0",
|
||||
"webpack": "^3.0.0"
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Variables
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
|
||||
GULP_CLI="$ROOT/node_modules/.bin/gulp"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
WORK_DIR=`mktemp -d`
|
||||
|
||||
# check if tmp dir was created
|
||||
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
|
||||
echo "Could not create temp dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# deletes the temp directory
|
||||
function cleanup {
|
||||
rm -rf "$WORK_DIR"
|
||||
echo "Deleted temp working directory $WORK_DIR"
|
||||
}
|
||||
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
trap cleanup EXIT
|
||||
|
||||
# Enter work dir
|
||||
pushd "$WORK_DIR"
|
||||
|
||||
if [ ! -d "$ROOT/dist/package" ]; then
|
||||
pushd $ROOT
|
||||
$GULP_CLI build
|
||||
popd
|
||||
fi
|
||||
|
||||
# Simulate env
|
||||
cp $DIR/* .
|
||||
cp $DIR/../shared/* .
|
||||
npm install
|
||||
npm install "$ROOT/dist/package"
|
||||
|
||||
# Build the new env
|
||||
./node_modules/.bin/webpack
|
||||
|
||||
# Run the tests
|
||||
./node_modules/.bin/karma start
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
const firebase = require('firebase');
|
||||
const namespaceDefinition = require('./namespaceDefinition');
|
||||
const validateNamespace = require('./validator');
|
||||
const namespaceDefinition = require('../../shared/namespaceDefinition');
|
||||
const validateNamespace = require('../../shared/validator');
|
||||
|
||||
firebase.initializeApp({
|
||||
apiKey: 'test-api-key',
|
||||
@@ -27,6 +27,6 @@ firebase.initializeApp({
|
||||
messagingSenderId: '012345678910'
|
||||
});
|
||||
|
||||
describe("Firebase Namespace Validation", function() {
|
||||
describe('Firebase Namespace Validation', function() {
|
||||
validateNamespace(namespaceDefinition, firebase);
|
||||
});
|
||||
});
|
||||
@@ -17,9 +17,9 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: path.resolve(__dirname, 'namespace.test.js'),
|
||||
entry: path.resolve(__dirname, 'src/namespace.test.js'),
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'build'),
|
||||
filename: 'build.js'
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'namespace.test.js'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"lerna": "2.1.0",
|
||||
"version": "independent",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
"integration/*"
|
||||
],
|
||||
"useWorkspaces": true
|
||||
}
|
||||
+34
-95
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "firebase",
|
||||
"version": "4.5.0",
|
||||
"description": "Firebase JavaScript library for web and Node.js",
|
||||
"name": "firebase-wrapper",
|
||||
"version": "0.1.0",
|
||||
"description": "Monorepo for the Firebase JavaScript SDK",
|
||||
"private": true,
|
||||
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://firebase.google.com/",
|
||||
"homepage": "https://github.com/firebase/firebase-js-sdk",
|
||||
"keywords": [
|
||||
"authentication",
|
||||
"database",
|
||||
@@ -13,102 +14,40 @@
|
||||
"realtime",
|
||||
"storage"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "lerna run --parallel --scope @firebase/* --scope firebase dev",
|
||||
"prepare": "lerna run --scope @firebase/* --scope firebase prepare",
|
||||
"prepush": "node tools/gitHooks/prepush.js",
|
||||
"publish:packages": "lerna publish --scope @firebase/* --scope firebase --registry http://localhost:4873",
|
||||
"repl": "node tools/repl.js",
|
||||
"pretest": "node tools/pretest.js",
|
||||
"test": "lerna run --parallel test",
|
||||
"test:setup": "node tools/config.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/firebase/firebase-js-sdk.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build:package": "gulp build && cd dist/package && npm install --production && npm shrinkwrap && npm pack && shx mv *.tgz ../",
|
||||
"build": "gulp build",
|
||||
"commitmsg": "validate-commit-msg",
|
||||
"dev": "gulp dev",
|
||||
"precommit": "lint-staged",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"main": "index.js",
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
"integration/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/chai": "^3.4.35",
|
||||
"@types/mocha": "^2.2.39",
|
||||
"@types/node": "^7.0.8",
|
||||
"@types/sinon": "^1.16.35",
|
||||
"awesome-typescript-loader": "^3.2.1",
|
||||
"babel-cli": "^6.23.0",
|
||||
"babel-core": "^6.24.0",
|
||||
"babel-plugin-add-module-exports": "^0.2.1",
|
||||
"babel-plugin-inline-replace-variables": "^1.2.2",
|
||||
"babel-plugin-minify-dead-code-elimination": "^0.1.4",
|
||||
"babel-preset-env": "^1.2.1",
|
||||
"chai": "^3.5.0",
|
||||
"chalk": "^2.1.0",
|
||||
"child-process-promise": "^2.2.1",
|
||||
"cross-env": "^5.0.1",
|
||||
"cz-customizable": "^5.0.0",
|
||||
"filesize": "^3.5.6",
|
||||
"git-rev-sync": "^1.9.0",
|
||||
"google-closure-compiler-js": "^20170218.0.0",
|
||||
"grpc": "^1.6.0",
|
||||
"gulp": "gulpjs/gulp#4.0",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-clone": "^1.0.0",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-env": "^0.4.0",
|
||||
"gulp-file": "^0.3.0",
|
||||
"gulp-header": "^1.8.8",
|
||||
"gulp-if": "^2.0.2",
|
||||
"gulp-istanbul": "^1.1.1",
|
||||
"gulp-mocha": "^4.1.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-replace": "^0.5.4",
|
||||
"gulp-sourcemaps": "^2.4.1",
|
||||
"gulp-strip-comments": "^2.4.5",
|
||||
"gulp-typescript": "^3.1.6",
|
||||
"gzip-size": "^3.0.0",
|
||||
"husky": "^0.13.3",
|
||||
"jsdom": "^9.12.0",
|
||||
"karma": "^1.7.0",
|
||||
"karma-chrome-launcher": "^2.0.0",
|
||||
"karma-firefox-launcher": "^1.0.1",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-spec-reporter": "^0.0.30",
|
||||
"karma-typescript": "^3.0.4",
|
||||
"lint-staged": "^4.0.0",
|
||||
"merge2": "^1.0.3",
|
||||
"mkdirp": "^0.5.1",
|
||||
"prettier": "1.7.0",
|
||||
"protobufjs": "^6.8.0",
|
||||
"require-dir": "^0.3.1",
|
||||
"rimraf": "^2.6.1",
|
||||
"shx": "^0.2.2",
|
||||
"sinon": "^2.1.0",
|
||||
"through2": "^2.0.3",
|
||||
"ts-node": "^3.3.0",
|
||||
"typescript": "^2.4.2",
|
||||
"validate-commit-msg": "^2.12.1",
|
||||
"vinyl-named": "^1.1.0",
|
||||
"webpack": "^3.0.0",
|
||||
"webpack-stream": "^3.2.0",
|
||||
"wrapper-webpack-plugin": "^0.1.11",
|
||||
"yargs": "^8.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/webchannel-wrapper": "^0.2.1",
|
||||
"dom-storage": "^2.0.2",
|
||||
"faye-websocket": "0.9.3",
|
||||
"jsonwebtoken": "^7.3.0",
|
||||
"promise-polyfill": "^6.0.2",
|
||||
"xmlhttprequest": "^1.8.0"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-customizable"
|
||||
},
|
||||
"cz-customizable": {
|
||||
"config": "./.cz-config.js"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"**/*.ts": [
|
||||
"prettier --write --single-quote",
|
||||
"git add"
|
||||
]
|
||||
"firebase-tools": "^3.10.1",
|
||||
"glob": "^7.1.2",
|
||||
"gulp-sourcemaps": "^2.6.1",
|
||||
"gulp-typescript": "^3.2.2",
|
||||
"husky": "^0.14.3",
|
||||
"inquirer": "^3.2.3",
|
||||
"lerna": "^2.1.0",
|
||||
"merge2": "^1.2.0",
|
||||
"mz": "^2.7.0",
|
||||
"ora": "^1.3.0",
|
||||
"prettier": "^1.7.0",
|
||||
"semver": "^5.4.1",
|
||||
"simple-git": "^1.77.0",
|
||||
"yargs": "^9.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Directories not needed by end users
|
||||
/src
|
||||
test
|
||||
|
||||
# Files not needed by end users
|
||||
gulpfile.js
|
||||
index.ts
|
||||
karma.conf.js
|
||||
tsconfig.json
|
||||
@@ -0,0 +1,51 @@
|
||||
# `@firebase/app`
|
||||
|
||||
This is the primary entrypoint to the Firebase JS SDK. **All apps using firebase
|
||||
will need this package**. Other `@firebase` packages are typically mounted on to
|
||||
the namespaces exposed by this package.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this package by running the following in your project:
|
||||
|
||||
```bash
|
||||
$ npm install @firebase/app
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
You can then use the firebase namespace exposed by this package as illustrated
|
||||
below:
|
||||
|
||||
**ES Modules**
|
||||
|
||||
### Referencing the `firebase` export:
|
||||
|
||||
```javascript
|
||||
import { firebase } from '@firebase/app';
|
||||
|
||||
// Do stuff w/ `firebase`
|
||||
```
|
||||
|
||||
### Referencing the default export:
|
||||
|
||||
```javascript
|
||||
import firebase from '@firebase/app';
|
||||
|
||||
// Do stuff w/ `firebase`
|
||||
```
|
||||
|
||||
**CommonJS Modules**
|
||||
|
||||
```javascript
|
||||
const firebase = require('@firebase/app').default;
|
||||
|
||||
// Do stuff with `firebase`
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
For comprehensive documentation please see the [Firebase Reference
|
||||
Docs][reference-docs].
|
||||
|
||||
[reference-docs]: https://firebase.google.com/docs/reference/js/
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const gulp = require('gulp');
|
||||
const tools = require('../../tools/build');
|
||||
|
||||
const buildModule = gulp.parallel([
|
||||
tools.buildCjs(__dirname),
|
||||
tools.buildEsm(__dirname)
|
||||
]);
|
||||
|
||||
const setupWatcher = () => {
|
||||
gulp.watch('src/**/*', buildModule);
|
||||
};
|
||||
|
||||
gulp.task('build', buildModule);
|
||||
|
||||
gulp.task('dev', gulp.parallel([setupWatcher]));
|
||||
@@ -13,13 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Import the needed shims
|
||||
import './utils/shims';
|
||||
|
||||
// Import the createFirebaseNamespace function
|
||||
import { createFirebaseNamespace, FirebaseNamespace } from './app/firebase_app';
|
||||
import { createFirebaseNamespace, FirebaseNamespace } from './src/firebaseApp';
|
||||
|
||||
// Export a single instance of firebase app
|
||||
const firebase: FirebaseNamespace = createFirebaseNamespace();
|
||||
export {
|
||||
FirebaseApp,
|
||||
FirebaseAuthTokenData,
|
||||
FirebaseNamespace,
|
||||
FirebaseService,
|
||||
FirebaseServiceFactory,
|
||||
FirebaseServiceNamespace
|
||||
} from './src/firebaseApp';
|
||||
|
||||
export const firebase = createFirebaseNamespace();
|
||||
|
||||
export default firebase;
|
||||
@@ -14,20 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let scope;
|
||||
const karma = require('karma');
|
||||
const path = require('path');
|
||||
const karmaBase = require('../../config/karma.base');
|
||||
|
||||
if (typeof global !== 'undefined') {
|
||||
scope = global;
|
||||
} else if (typeof self !== 'undefined') {
|
||||
scope = self;
|
||||
} else {
|
||||
try {
|
||||
scope = Function('return this')();
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
'polyfill failed because global object is unavailable in this environment'
|
||||
);
|
||||
}
|
||||
}
|
||||
module.exports = function(config) {
|
||||
const karmaConfig = Object.assign({}, karmaBase, {
|
||||
// files to load into karma
|
||||
files: [{ pattern: `test/**/*` }],
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha']
|
||||
});
|
||||
|
||||
export const globalScope = scope;
|
||||
config.set(karmaConfig);
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "@firebase/app",
|
||||
"version": "0.1.0",
|
||||
"description": "The primary entrypoint to the Firebase JS SDK",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"scripts": {
|
||||
"dev": "gulp dev",
|
||||
"test": "run-p test:browser test:node",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:node": "mocha test/**/*.test.* --compilers ts:ts-node/register",
|
||||
"prepare": "gulp build"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@firebase/util": "^0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.0.4",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/sinon": "^2.3.3",
|
||||
"chai": "^4.1.1",
|
||||
"gulp": "gulpjs/gulp#4.0",
|
||||
"karma": "^1.7.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-cli": "^1.0.1",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sauce-launcher": "^1.2.0",
|
||||
"karma-sourcemap-loader": "^0.3.7",
|
||||
"karma-spec-reporter": "^0.0.31",
|
||||
"karma-webpack": "^2.0.4",
|
||||
"mocha": "^3.5.0",
|
||||
"npm-run-all": "^4.1.1",
|
||||
"sinon": "^3.2.1",
|
||||
"source-map-loader": "^0.2.1",
|
||||
"ts-loader": "^2.3.4",
|
||||
"ts-node": "^3.3.0",
|
||||
"typescript": "^2.4.2",
|
||||
"webpack": "^3.5.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/tree/master/packages/app"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"typings": "dist/index.d.ts"
|
||||
}
|
||||
@@ -13,10 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createSubscribe, Observer, Subscribe } from './subscribe';
|
||||
import { ErrorFactory, FirebaseError } from './errors';
|
||||
import { PromiseImpl } from '../utils/promise';
|
||||
import { patchProperty, deepCopy, deepExtend } from '../utils/deep_copy';
|
||||
import { createSubscribe, Observer, Subscribe } from '@firebase/util';
|
||||
import {
|
||||
patchProperty,
|
||||
deepCopy,
|
||||
deepExtend,
|
||||
ErrorFactory,
|
||||
FirebaseError
|
||||
} from '@firebase/util';
|
||||
|
||||
export interface FirebaseAuthTokenData {
|
||||
accessToken: string;
|
||||
@@ -256,7 +260,7 @@ class FirebaseAppImpl implements FirebaseApp {
|
||||
this.options_ = deepCopy<FirebaseOptions>(options);
|
||||
this.INTERNAL = {
|
||||
getUid: () => null,
|
||||
getToken: () => PromiseImpl.resolve(null),
|
||||
getToken: () => Promise.resolve(null),
|
||||
addAuthTokenListener: (callback: (token: string | null) => void) => {
|
||||
tokenListeners.push(callback);
|
||||
// Make sure callback is called, asynchronously, in the absence of the auth module
|
||||
@@ -281,7 +285,7 @@ class FirebaseAppImpl implements FirebaseApp {
|
||||
}
|
||||
|
||||
delete(): Promise<void> {
|
||||
return new PromiseImpl(resolve => {
|
||||
return new Promise(resolve => {
|
||||
this.checkDestroyed_();
|
||||
resolve();
|
||||
})
|
||||
@@ -293,7 +297,7 @@ class FirebaseAppImpl implements FirebaseApp {
|
||||
services.push(this.services_[serviceKey][instanceKey]);
|
||||
});
|
||||
});
|
||||
return PromiseImpl.all(
|
||||
return Promise.all(
|
||||
services.map(service => {
|
||||
return service.INTERNAL!.delete();
|
||||
})
|
||||
@@ -411,7 +415,7 @@ export function createFirebaseNamespace(): FirebaseNamespace {
|
||||
initializeApp: initializeApp,
|
||||
app: app as any,
|
||||
apps: null as any,
|
||||
Promise: PromiseImpl,
|
||||
Promise: Promise,
|
||||
SDK_VERSION: '${JSCORE_VERSION}',
|
||||
INTERNAL: {
|
||||
registerService: registerService,
|
||||
@@ -422,7 +426,7 @@ export function createFirebaseNamespace(): FirebaseNamespace {
|
||||
removeApp: removeApp,
|
||||
factories: factories,
|
||||
useAsService: useAsService,
|
||||
Promise: PromiseImpl,
|
||||
Promise: Promise,
|
||||
deepExtend: deepExtend
|
||||
}
|
||||
};
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
FirebaseNamespace,
|
||||
FirebaseApp,
|
||||
FirebaseService
|
||||
} from '../../src/app/firebase_app';
|
||||
} from '../src/firebaseApp';
|
||||
import { assert } from 'chai';
|
||||
|
||||
describe('Firebase App Class', () => {
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../config/tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": [
|
||||
"dist/**/*"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Directories not needed by end users
|
||||
/src
|
||||
|
||||
# Files not needed by end users
|
||||
gulpfile.js
|
||||
@@ -0,0 +1,44 @@
|
||||
# `@firebase/auth`
|
||||
|
||||
This is the authentication component for the Firebase JS SDK. It has a peer
|
||||
dependency on the [`@firebase/app`](https://npm.im) package on NPM. This package
|
||||
is included by default in the [`firebase`](https://npm.im/firebase) wrapper
|
||||
package.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this package by running the following in your project:
|
||||
|
||||
```bash
|
||||
$ npm install @firebase/auth
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
You can then use the firebase namespace exposed by this package as illustrated
|
||||
below:
|
||||
|
||||
**ES Modules**
|
||||
|
||||
```javascript
|
||||
import firebase from '@firebase/app';
|
||||
import '@firebase/auth'
|
||||
|
||||
// Do stuff w/ `firebase` and `firebase.auth`
|
||||
```
|
||||
|
||||
**CommonJS Modules**
|
||||
|
||||
```javascript
|
||||
const firebase = require('@firebase/app').default;
|
||||
require('@firebase/auth');
|
||||
|
||||
// Do stuff with `firebase` and `firebase.auth`
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
For comprehensive documentation please see the [Firebase Reference
|
||||
Docs][reference-docs].
|
||||
|
||||
[reference-docs]: https://firebase.google.com/docs/reference/js/
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const gulp = require('gulp');
|
||||
const through2 = require('through2');
|
||||
|
||||
function buildModule() {
|
||||
return gulp
|
||||
.src('src/auth.js')
|
||||
.pipe(
|
||||
through2.obj(function(file, encoding, callback) {
|
||||
file.contents = Buffer.concat([
|
||||
new Buffer(
|
||||
`var firebase = require('@firebase/app').default; (function(){`
|
||||
),
|
||||
file.contents,
|
||||
new Buffer(
|
||||
`}).call(typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : {});`
|
||||
)
|
||||
]);
|
||||
|
||||
return callback(null, file);
|
||||
})
|
||||
)
|
||||
.pipe(gulp.dest('dist'));
|
||||
}
|
||||
|
||||
gulp.task('build', buildModule);
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@firebase/auth",
|
||||
"version": "0.1.0",
|
||||
"main": "dist/auth.js",
|
||||
"scripts": {
|
||||
"dev": "echo 'Skipping @firebase/auth dev step'",
|
||||
"test": "echo 'Skipping @firebase/auth test step'",
|
||||
"prepare": "gulp build"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"peerDependencies": {
|
||||
"@firebase/app": "^0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "gulpjs/gulp#4.0",
|
||||
"through2": "^2.0.3"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/tree/master/packages/auth"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*! @license Firebase v3.7.5
|
||||
Build: 3.7.5-rc.1
|
||||
Terms: https://firebase.google.com/terms/ */
|
||||
|
||||
(function(){var h,aa=aa||{},k=this,ba=function(a){return void 0!==a},m=function(a){return"string"==typeof a},ca=function(a){return"boolean"==typeof a},da=function(){},ea=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";
|
||||
if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==b&&"undefined"==typeof a.call)return"object";return b},fa=function(a){return null===a},ha=function(a){return"array"==ea(a)},ia=function(a){var b=ea(a);return"array"==b||"object"==b&&"number"==typeof a.length},p=function(a){return"function"==ea(a)},q=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==
|
||||
b},ja=function(a,b,c){return a.call.apply(a.bind,arguments)},ka=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}},r=function(a,b,c){r=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ja:ka;return r.apply(null,arguments)},la=function(a,b){var c=
|
||||
@@ -70,10 +68,10 @@ c);a(e)}catch(F){g(F)}}:a;e.tb=c?function(b){try{var e=c.call(d,b);!ba(e)&&b ins
|
||||
var ud=function(a,b,c){0==a.aa&&(a===c&&(b=3,c=new TypeError("Promise cannot resolve to itself")),a.aa=1,zd(c,a.yg,a.zg,a)||(a.za=c,a.aa=b,a.w=null,Jd(a),3!=b||c instanceof vd||Kd(a,c)))},zd=function(a,b,c,d){if(a instanceof C)return null!=b&&Da(b,"opt_onFulfilled should be a function."),null!=c&&Da(c,"opt_onRejected should be a function. Did you pass opt_context as the second argument instead of the third?"),Ed(a,yd(b||da,c||null,d)),!0;if(td(a))return a.then(b,c,d),!0;if(q(a))try{var e=a.then;if(p(e))return Ld(a,
|
||||
e,b,c,d),!0}catch(f){return c.call(d,f),!0}return!1},Ld=function(a,b,c,d,e){var f=!1,g=function(a){f||(f=!0,c.call(e,a))},l=function(a){f||(f=!0,d.call(e,a))};try{b.call(a,g,l)}catch(n){l(n)}},Jd=function(a){a.pd||(a.pd=!0,dd(a.yf,a))},Hd=function(a){var b=null;a.ua&&(b=a.ua,a.ua=b.next,b.next=null);a.ua||(a.kb=null);null!=b&&w(null!=b.Ua);return b};C.prototype.yf=function(){for(var a;a=Hd(this);)Id(this,a,this.aa,this.za);this.pd=!1};
|
||||
var Id=function(a,b,c,d){if(3==c&&b.tb&&!b.Hb)for(;a&&a.vc;a=a.w)a.vc=!1;if(b.child)b.child.w=null,Md(b,c,d);else try{b.Hb?b.Ua.call(b.context):Md(b,c,d)}catch(e){Nd.call(null,e)}xd.put(b)},Md=function(a,b,c){2==b?a.Ua.call(a.context,c):a.tb&&a.tb.call(a.context,c)},Kd=function(a,b){a.vc=!0;dd(function(){a.vc&&Nd.call(null,b)})},Nd=Uc,vd=function(a){u.call(this,a)};t(vd,u);vd.prototype.name="cancel";/*
|
||||
Portions of this code are from MochiKit, received by
|
||||
The Closure Authors under the MIT license. All other code is Copyright
|
||||
2005-2009 The Closure Authors. All Rights Reserved.
|
||||
*/
|
||||
Portions of this code are from MochiKit, received by
|
||||
The Closure Authors under the MIT license. All other code is Copyright
|
||||
2005-2009 The Closure Authors. All Rights Reserved.
|
||||
*/
|
||||
var Od=function(a,b){this.Rc=[];this.Le=a;this.qe=b||null;this.Pb=this.nb=!1;this.za=void 0;this.ae=this.ge=this.gd=!1;this.Zc=0;this.w=null;this.hd=0};Od.prototype.cancel=function(a){if(this.nb)this.za instanceof Od&&this.za.cancel();else{if(this.w){var b=this.w;delete this.w;a?b.cancel(a):(b.hd--,0>=b.hd&&b.cancel())}this.Le?this.Le.call(this.qe,this):this.ae=!0;this.nb||Pd(this,new Qd)}};Od.prototype.oe=function(a,b){this.gd=!1;Rd(this,a,b)};
|
||||
var Rd=function(a,b,c){a.nb=!0;a.za=c;a.Pb=!b;Sd(a)},Ud=function(a){if(a.nb){if(!a.ae)throw new Td;a.ae=!1}};Od.prototype.callback=function(a){Ud(this);Vd(a);Rd(this,!0,a)};var Pd=function(a,b){Ud(a);Vd(b);Rd(a,!1,b)},Vd=function(a){w(!(a instanceof Od),"An execution sequence may not be initiated with a blocking Deferred.")},Xd=function(a,b){Wd(a,null,b,void 0)},Wd=function(a,b,c,d){w(!a.ge,"Blocking Deferreds can not be re-used");a.Rc.push([b,c,d]);a.nb&&Sd(a)};
|
||||
Od.prototype.then=function(a,b,c){var d,e,f=new C(function(a,b){d=a;e=b});Wd(this,d,function(a){a instanceof Qd?f.cancel():e(a)});return f.then(a,b,c)};sd(Od);
|
||||
@@ -0,0 +1,10 @@
|
||||
# Directories not needed by end users
|
||||
/src
|
||||
test
|
||||
|
||||
# Files not needed by end users
|
||||
gulpfile.js
|
||||
index.ts
|
||||
index.node.ts
|
||||
karma.conf.js
|
||||
tsconfig.json
|
||||
@@ -0,0 +1,44 @@
|
||||
# `@firebase/database`
|
||||
|
||||
This is the realtime database component for the Firebase JS SDK. It has a peer
|
||||
dependency on the [`@firebase/app`](https://npm.im) package on NPM. This package
|
||||
is included by default in the [`firebase`](https://npm.im/firebase) wrapper
|
||||
package.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this package by running the following in your project:
|
||||
|
||||
```bash
|
||||
$ npm install @firebase/database
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
You can then use the firebase namespace exposed by this package as illustrated
|
||||
below:
|
||||
|
||||
**ES Modules**
|
||||
|
||||
```javascript
|
||||
import firebase from '@firebase/app';
|
||||
import '@firebase/database'
|
||||
|
||||
// Do stuff w/ `firebase` and `firebase.auth`
|
||||
```
|
||||
|
||||
**CommonJS Modules**
|
||||
|
||||
```javascript
|
||||
const firebase = require('@firebase/app').default;
|
||||
require('@firebase/database');
|
||||
|
||||
// Do stuff with `firebase` and `firebase.auth`
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
For comprehensive documentation please see the [Firebase Reference
|
||||
Docs][reference-docs].
|
||||
|
||||
[reference-docs]: https://firebase.google.com/docs/reference/js/
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const gulp = require('gulp');
|
||||
const tools = require('../../tools/build');
|
||||
|
||||
const buildModule = gulp.parallel([
|
||||
tools.buildCjs(__dirname),
|
||||
tools.buildEsm(__dirname)
|
||||
]);
|
||||
|
||||
const setupWatcher = () => {
|
||||
gulp.watch('src/**/*', buildModule);
|
||||
};
|
||||
|
||||
gulp.task('build', buildModule);
|
||||
|
||||
gulp.task('dev', gulp.parallel([setupWatcher]));
|
||||
@@ -14,16 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import firebase from './app';
|
||||
import { FirebaseApp, FirebaseNamespace } from './app/firebase_app';
|
||||
import { Database } from './database/api/Database';
|
||||
import { Query } from './database/api/Query';
|
||||
import { Reference } from './database/api/Reference';
|
||||
import { enableLogging } from './database/core/util/util';
|
||||
import { RepoManager } from './database/core/RepoManager';
|
||||
import * as INTERNAL from './database/api/internal';
|
||||
import * as TEST_ACCESS from './database/api/test_access';
|
||||
import { isNodeSdk } from './utils/environment';
|
||||
import firebase, { FirebaseApp, FirebaseNamespace } from '@firebase/app';
|
||||
import { Database } from './src/api/Database';
|
||||
import { Query } from './src/api/Query';
|
||||
import { Reference } from './src/api/Reference';
|
||||
import { enableLogging } from './src/core/util/util';
|
||||
import { RepoManager } from './src/core/RepoManager';
|
||||
import * as INTERNAL from './src/api/internal';
|
||||
import * as TEST_ACCESS from './src/api/test_access';
|
||||
import { isNodeSdk } from '@firebase/util';
|
||||
import './src/nodePatches';
|
||||
|
||||
export function registerDatabase(instance: FirebaseNamespace) {
|
||||
// Register the Database Service with the 'firebase' namespace.
|
||||
@@ -49,27 +49,4 @@ export function registerDatabase(instance: FirebaseNamespace) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extensions to the FirebaseApp and FirebaseNamespaces interfaces
|
||||
*/
|
||||
declare module './app/firebase_app' {
|
||||
interface FirebaseApp {
|
||||
database?(): Database;
|
||||
}
|
||||
}
|
||||
|
||||
declare module './app/firebase_app' {
|
||||
interface FirebaseNamespace {
|
||||
database?: {
|
||||
(app?: FirebaseApp): Database;
|
||||
Database;
|
||||
enableLogging;
|
||||
INTERNAL;
|
||||
Query;
|
||||
Reference;
|
||||
ServerValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
registerDatabase(firebase);
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import firebase, { FirebaseApp, FirebaseNamespace } from '@firebase/app';
|
||||
import { Database } from './src/api/Database';
|
||||
import { Query } from './src/api/Query';
|
||||
import { Reference } from './src/api/Reference';
|
||||
import { enableLogging } from './src/core/util/util';
|
||||
import { RepoManager } from './src/core/RepoManager';
|
||||
import * as INTERNAL from './src/api/internal';
|
||||
import * as TEST_ACCESS from './src/api/test_access';
|
||||
import { isNodeSdk } from '@firebase/util';
|
||||
|
||||
export function registerDatabase(instance: FirebaseNamespace) {
|
||||
// Register the Database Service with the 'firebase' namespace.
|
||||
const namespace = instance.INTERNAL.registerService(
|
||||
'database',
|
||||
(app, unused, url) => RepoManager.getInstance().databaseFromApp(app, url),
|
||||
// firebase.database namespace properties
|
||||
{
|
||||
Reference,
|
||||
Query,
|
||||
Database,
|
||||
enableLogging,
|
||||
INTERNAL,
|
||||
ServerValue: Database.ServerValue,
|
||||
TEST_ACCESS
|
||||
},
|
||||
null,
|
||||
true
|
||||
);
|
||||
|
||||
if (isNodeSdk()) {
|
||||
module.exports = namespace;
|
||||
}
|
||||
}
|
||||
|
||||
registerDatabase(firebase);
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const karma = require('karma');
|
||||
const path = require('path');
|
||||
const karmaBase = require('../../config/karma.base');
|
||||
|
||||
module.exports = function(config) {
|
||||
const karmaConfig = Object.assign({}, karmaBase, {
|
||||
// files to load into karma
|
||||
files: [{ pattern: `test/**/*.test.ts` }],
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha']
|
||||
});
|
||||
|
||||
config.set(karmaConfig);
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "@firebase/database",
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"main": "dist/cjs/index.node.js",
|
||||
"browser": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"scripts": {
|
||||
"dev": "gulp dev",
|
||||
"test": "run-p test:browser test:node",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:node": "mocha 'test/{,!(browser)/**/}*.test.ts' --compilers ts:ts-node/register -r src/nodePatches.ts --retries 5 --timeout 5000",
|
||||
"prepare": "gulp build"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"peerDependencies": {
|
||||
"@firebase/app": "^0.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/util": "^0.1.0",
|
||||
"faye-websocket": "0.9.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.0.4",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^8.0.28",
|
||||
"@types/sinon": "^2.3.3",
|
||||
"chai": "^4.1.1",
|
||||
"gulp": "gulpjs/gulp#4.0",
|
||||
"karma": "^1.7.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-cli": "^1.0.1",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sauce-launcher": "^1.2.0",
|
||||
"karma-sourcemap-loader": "^0.3.7",
|
||||
"karma-spec-reporter": "^0.0.31",
|
||||
"karma-webpack": "^2.0.4",
|
||||
"mocha": "^3.5.0",
|
||||
"npm-run-all": "^4.1.1",
|
||||
"sinon": "^3.2.1",
|
||||
"source-map-loader": "^0.2.1",
|
||||
"ts-loader": "^2.3.4",
|
||||
"ts-node": "^3.3.0",
|
||||
"typescript": "^2.4.2",
|
||||
"webpack": "^3.5.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/tree/master/packages/database"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||
},
|
||||
"typings": "dist/index.d.ts"
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { validateArgCount, validateCallback } from '../../utils/validation';
|
||||
import { validateArgCount, validateCallback } from '@firebase/util';
|
||||
import { validatePathString } from '../core/util/validation';
|
||||
import { Path } from '../core/util/Path';
|
||||
import { PRIORITY_INDEX } from '../core/snap/indexes/PriorityIndex';
|
||||
@@ -17,13 +17,12 @@
|
||||
import { fatal } from '../core/util/util';
|
||||
import { parseRepoInfo } from '../core/util/libs/parser';
|
||||
import { Path } from '../core/util/Path';
|
||||
import { PromiseImpl } from '../../utils/promise';
|
||||
import { Reference } from './Reference';
|
||||
import { Repo } from '../core/Repo';
|
||||
import { RepoManager } from '../core/RepoManager';
|
||||
import { validateArgCount } from '../../utils/validation';
|
||||
import { validateArgCount } from '@firebase/util';
|
||||
import { validateUrl } from '../core/util/validation';
|
||||
import { FirebaseApp, FirebaseService } from '../../app/firebase_app';
|
||||
import { FirebaseApp, FirebaseService } from '@firebase/app';
|
||||
import { RepoInfo } from '../core/RepoInfo';
|
||||
|
||||
/**
|
||||
@@ -140,6 +139,6 @@ export class DatabaseInternals {
|
||||
(this.database as any).root_ = null;
|
||||
this.database.INTERNAL = null;
|
||||
this.database = null;
|
||||
return PromiseImpl.resolve();
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { assert } from '../../utils/assert';
|
||||
import { assert } from '@firebase/util';
|
||||
import { KEY_INDEX } from '../core/snap/indexes/KeyIndex';
|
||||
import { PRIORITY_INDEX } from '../core/snap/indexes/PriorityIndex';
|
||||
import { VALUE_INDEX } from '../core/snap/indexes/ValueIndex';
|
||||
@@ -33,13 +33,13 @@ import {
|
||||
validateArgCount,
|
||||
validateCallback,
|
||||
validateContextObject
|
||||
} from '../../utils/validation';
|
||||
} from '@firebase/util';
|
||||
import {
|
||||
ValueEventRegistration,
|
||||
ChildEventRegistration,
|
||||
EventRegistration
|
||||
} from '../core/view/EventRegistration';
|
||||
import { Deferred, attachDummyErrorHandler } from '../../utils/promise';
|
||||
import { Deferred } from '@firebase/util';
|
||||
import { Repo } from '../core/Repo';
|
||||
import { QueryParams } from '../core/view/QueryParams';
|
||||
import { Reference } from './Reference';
|
||||
@@ -317,8 +317,10 @@ export class Query {
|
||||
// because the API currently expects callbacks will be called synchronously if the data is cached, but this is
|
||||
// against the Promise specification.
|
||||
let firstCall = true;
|
||||
const deferred = new Deferred();
|
||||
attachDummyErrorHandler(deferred.promise);
|
||||
const deferred = new Deferred<DataSnapshot>();
|
||||
|
||||
// A dummy error handler in case a user wasn't expecting promises
|
||||
deferred.promise.catch(() => {});
|
||||
|
||||
const onceCallback = (snapshot: DataSnapshot) => {
|
||||
// NOTE: Even though we unsubscribe, we may get called multiple times if a single action (e.g. set() with JSON)
|
||||
@@ -31,12 +31,8 @@ import {
|
||||
validateFirebaseDataArg,
|
||||
validateWritablePath
|
||||
} from '../core/util/validation';
|
||||
import { validateArgCount, validateCallback } from '../../utils/validation';
|
||||
import {
|
||||
Deferred,
|
||||
attachDummyErrorHandler,
|
||||
PromiseImpl
|
||||
} from '../../utils/promise';
|
||||
import { validateArgCount, validateCallback } from '@firebase/util';
|
||||
import { Deferred } from '@firebase/util';
|
||||
import { SyncPoint } from '../core/SyncPoint';
|
||||
import { Database } from './Database';
|
||||
import { DataSnapshot } from './DataSnapshot';
|
||||
@@ -259,9 +255,9 @@ export class Reference extends Query {
|
||||
|
||||
if (applyLocally === undefined) applyLocally = true;
|
||||
|
||||
const deferred = new Deferred();
|
||||
const deferred = new Deferred<TransactionResult>();
|
||||
if (typeof onComplete === 'function') {
|
||||
attachDummyErrorHandler(deferred.promise);
|
||||
deferred.promise.catch(() => {});
|
||||
}
|
||||
|
||||
const promiseComplete = function(
|
||||
@@ -338,14 +334,14 @@ export class Reference extends Query {
|
||||
if (value != null) {
|
||||
promise = thennablePushRef.set(value, onComplete).then(() => pushRef);
|
||||
} else {
|
||||
promise = PromiseImpl.resolve(pushRef);
|
||||
promise = Promise.resolve(pushRef);
|
||||
}
|
||||
|
||||
thennablePushRef.then = promise.then.bind(promise);
|
||||
thennablePushRef.catch = promise.then.bind(promise, undefined);
|
||||
|
||||
if (typeof onComplete === 'function') {
|
||||
attachDummyErrorHandler(promise);
|
||||
promise.catch(() => {});
|
||||
}
|
||||
|
||||
return thennablePushRef;
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { DataSnapshot } from './DataSnapshot';
|
||||
import { validateArgCount } from '../../utils/validation';
|
||||
import { validateArgCount } from '@firebase/util';
|
||||
|
||||
export class TransactionResult {
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { validateArgCount, validateCallback } from '../../utils/validation';
|
||||
import { validateArgCount, validateCallback } from '@firebase/util';
|
||||
import {
|
||||
validateWritablePath,
|
||||
validateFirebaseDataArg,
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
validateFirebaseMergeDataArg
|
||||
} from '../core/util/validation';
|
||||
import { warn } from '../core/util/util';
|
||||
import { Deferred } from '../../utils/promise';
|
||||
import { Deferred } from '@firebase/util';
|
||||
import { Repo } from '../core/Repo';
|
||||
import { Path } from '../core/util/Path';
|
||||
|
||||
@@ -43,7 +43,7 @@ export class OnDisconnect {
|
||||
cancel(onComplete?: (a: Error | null) => void): Promise<void> {
|
||||
validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
||||
validateCallback('OnDisconnect.cancel', 1, onComplete, true);
|
||||
const deferred = new Deferred();
|
||||
const deferred = new Deferred<void>();
|
||||
this.repo_.onDisconnectCancel(
|
||||
this.path_,
|
||||
deferred.wrapCallback(onComplete)
|
||||
@@ -59,7 +59,7 @@ export class OnDisconnect {
|
||||
validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
||||
validateWritablePath('OnDisconnect.remove', this.path_);
|
||||
validateCallback('OnDisconnect.remove', 1, onComplete, true);
|
||||
const deferred = new Deferred();
|
||||
const deferred = new Deferred<void>();
|
||||
this.repo_.onDisconnectSet(
|
||||
this.path_,
|
||||
null,
|
||||
@@ -78,7 +78,7 @@ export class OnDisconnect {
|
||||
validateWritablePath('OnDisconnect.set', this.path_);
|
||||
validateFirebaseDataArg('OnDisconnect.set', 1, value, this.path_, false);
|
||||
validateCallback('OnDisconnect.set', 2, onComplete, true);
|
||||
const deferred = new Deferred();
|
||||
const deferred = new Deferred<void>();
|
||||
this.repo_.onDisconnectSet(
|
||||
this.path_,
|
||||
value,
|
||||
@@ -110,7 +110,7 @@ export class OnDisconnect {
|
||||
validatePriority('OnDisconnect.setWithPriority', 2, priority, false);
|
||||
validateCallback('OnDisconnect.setWithPriority', 3, onComplete, true);
|
||||
|
||||
const deferred = new Deferred();
|
||||
const deferred = new Deferred<void>();
|
||||
this.repo_.onDisconnectSetWithPriority(
|
||||
this.path_,
|
||||
value,
|
||||
@@ -150,7 +150,7 @@ export class OnDisconnect {
|
||||
false
|
||||
);
|
||||
validateCallback('OnDisconnect.update', 2, onComplete, true);
|
||||
const deferred = new Deferred();
|
||||
const deferred = new Deferred<void>();
|
||||
this.repo_.onDisconnectUpdate(
|
||||
this.path_,
|
||||
objectToMerge,
|
||||
+1
-1
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FirebaseApp, FirebaseAuthTokenData } from '@firebase/app';
|
||||
import { log, warn } from './util/util';
|
||||
import { FirebaseApp, FirebaseAuthTokenData } from '../../app/firebase_app';
|
||||
|
||||
/**
|
||||
* Abstraction around FirebaseApp's token fetching capabilities.
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
import { ImmutableTree } from './util/ImmutableTree';
|
||||
import { Path } from './util/Path';
|
||||
import { forEach } from '../../utils/obj';
|
||||
import { forEach } from '@firebase/util';
|
||||
import { Node, NamedNode } from './snap/Node';
|
||||
import { PRIORITY_INDEX } from './snap/indexes/PriorityIndex';
|
||||
import { assert } from '../../utils/assert';
|
||||
import { assert } from '@firebase/util';
|
||||
import { ChildrenNode } from './snap/ChildrenNode';
|
||||
|
||||
/**
|
||||
+13
-12
@@ -14,22 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import firebase from '../../app';
|
||||
import { forEach, contains, isEmpty, getCount, safeGet } from '../../utils/obj';
|
||||
import { stringify } from '../../utils/json';
|
||||
import { assert } from '../../utils/assert';
|
||||
import firebase from '@firebase/app';
|
||||
import { forEach, contains, isEmpty, getCount, safeGet } from '@firebase/util';
|
||||
import { stringify } from '@firebase/util';
|
||||
import { assert } from '@firebase/util';
|
||||
import { error, log, logWrapper, warn, ObjectToUniqueKey } from './util/util';
|
||||
import { Path } from './util/Path';
|
||||
import { VisibilityMonitor } from './util/VisibilityMonitor';
|
||||
import { OnlineMonitor } from './util/OnlineMonitor';
|
||||
import { isAdmin, isValidFormat } from '../../utils/jwt';
|
||||
import { isAdmin, isValidFormat } from '@firebase/util';
|
||||
import { Connection } from '../realtime/Connection';
|
||||
import { CONSTANTS } from '../../utils/constants';
|
||||
import {
|
||||
isMobileCordova,
|
||||
isReactNative,
|
||||
isNodeSdk
|
||||
} from '../../utils/environment';
|
||||
import { CONSTANTS } from '@firebase/util';
|
||||
import { isMobileCordova, isReactNative, isNodeSdk } from '@firebase/util';
|
||||
import { ServerActions } from './ServerActions';
|
||||
import { AuthTokenProvider } from './AuthTokenProvider';
|
||||
import { RepoInfo } from './RepoInfo';
|
||||
@@ -287,7 +283,12 @@ export class PersistentConnection extends ServerActions {
|
||||
const warnings = safeGet(payload, 'w');
|
||||
if (Array.isArray(warnings) && ~warnings.indexOf('no_index')) {
|
||||
const indexSpec =
|
||||
'".indexOn": "' + query.getQueryParams().getIndex().toString() + '"';
|
||||
'".indexOn": "' +
|
||||
query
|
||||
.getQueryParams()
|
||||
.getIndex()
|
||||
.toString() +
|
||||
'"';
|
||||
const indexPath = query.path.toString();
|
||||
warn(
|
||||
`Using an unspecified index. Your data will be downloaded and ` +
|
||||
+4
-4
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { assert } from '../../utils/assert';
|
||||
import { assert } from '@firebase/util';
|
||||
import { logWrapper, warn } from './util/util';
|
||||
import { jsonEval } from '../../utils/json';
|
||||
import { safeGet } from '../../utils/obj';
|
||||
import { querystring } from '../../utils/util';
|
||||
import { jsonEval } from '@firebase/util';
|
||||
import { safeGet } from '@firebase/util';
|
||||
import { querystring } from '@firebase/util';
|
||||
import { ServerActions } from './ServerActions';
|
||||
import { RepoInfo } from './RepoInfo';
|
||||
import { AuthTokenProvider } from './AuthTokenProvider';
|
||||
@@ -24,9 +24,9 @@ import { Path } from './util/Path';
|
||||
import { SparseSnapshotTree } from './SparseSnapshotTree';
|
||||
import { SyncTree } from './SyncTree';
|
||||
import { SnapshotHolder } from './SnapshotHolder';
|
||||
import { stringify } from '../../utils/json';
|
||||
import { stringify } from '@firebase/util';
|
||||
import { beingCrawled, each, exceptionGuard, warn, log } from './util/util';
|
||||
import { map, forEach, isEmpty } from '../../utils/obj';
|
||||
import { map, forEach, isEmpty } from '@firebase/util';
|
||||
import { AuthTokenProvider } from './AuthTokenProvider';
|
||||
import { StatsManager } from './stats/StatsManager';
|
||||
import { StatsReporter } from './stats/StatsReporter';
|
||||
@@ -34,7 +34,7 @@ import { StatsListener } from './stats/StatsListener';
|
||||
import { EventQueue } from './view/EventQueue';
|
||||
import { PersistentConnection } from './PersistentConnection';
|
||||
import { ReadonlyRestClient } from './ReadonlyRestClient';
|
||||
import { FirebaseApp } from '../../app/firebase_app';
|
||||
import { FirebaseApp } from '@firebase/app';
|
||||
import { RepoInfo } from './RepoInfo';
|
||||
import { Database } from '../api/Database';
|
||||
import { ServerActions } from './ServerActions';
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { assert } from '../../utils/assert';
|
||||
import { forEach } from '../../utils/obj';
|
||||
import { assert } from '@firebase/util';
|
||||
import { forEach } from '@firebase/util';
|
||||
import { PersistentStorage } from './storage/storage';
|
||||
import { LONG_POLLING, WEBSOCKET } from '../realtime/Constants';
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FirebaseApp } from '../../app/firebase_app';
|
||||
import { safeGet } from '../../utils/obj';
|
||||
import { FirebaseApp } from '@firebase/app';
|
||||
import { safeGet } from '@firebase/util';
|
||||
import { Repo } from './Repo';
|
||||
import { fatal } from './util/util';
|
||||
import { parseRepoInfo } from './util/libs/parser';
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { assert } from '../../utils/assert';
|
||||
import { assert } from '@firebase/util';
|
||||
import { Reference } from '../api/Reference';
|
||||
import { DataSnapshot } from '../api/DataSnapshot';
|
||||
import { Path } from './util/Path';
|
||||
@@ -24,7 +24,7 @@ import { Node } from './snap/Node';
|
||||
import { LUIDGenerator, warn, exceptionGuard } from './util/util';
|
||||
import { resolveDeferredValueSnapshot } from './util/ServerValues';
|
||||
import { isValidPriority, validateFirebaseData } from './util/validation';
|
||||
import { contains, safeGet } from '../../utils/obj';
|
||||
import { contains, safeGet } from '@firebase/util';
|
||||
import { nodeFromJSON } from './snap/nodeFromJSON';
|
||||
import { ChildrenNode } from './snap/ChildrenNode';
|
||||
import { Repo } from './Repo';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user