Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI Tests

on:
- pull_request
- push

env:
CI: true

jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 10.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- run: npm install

- name: "Lint and Test"
run: ./scripts/test.sh
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
package-lock.json
node_modules
node_modules

tsconfig.json
dist/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ on [firebase.google.com](https://firebase.google.com/docs/).
## Contributing

We love contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.

## Build Status

[![Actions Status][gh-actions-badge]][gh-actions]

[gh-actions]: https://github.com/firebase/snippets-web/actions
[gh-actions-badge]: https://github.com/firebase/snippets-web/workflows/CI%20Tests/badge.svg
21 changes: 4 additions & 17 deletions auth/link-multiple-accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ function getProviders() {
// [END auth_get_providers]
}

function simpleLink() {
// This is just a dummy variable for sample purposes, the other
// snippets demonstrate how to get a real credential.
var credential = new firebase.auth.AuthCredential();

function simpleLink(credential) {
// [START auth_simple_link]
auth.currentUser.linkWithCredential(credential)
.then(function(usercred) {
Expand All @@ -52,11 +48,7 @@ function simpleLink() {
// [END auth_simple_link]
}

function anonymousLink() {
// This is just a dummy variable for sample purposes, the other
// snippets demonstrate how to get a real credential.
var credential = new firebase.auth.AuthCredential();

function anonymousLink(credential) {
// [START auth_anonymous_link]
auth.currentUser.linkWithCredential(credential)
.then(function(usercred) {
Expand Down Expand Up @@ -108,11 +100,7 @@ function linkWithRedirect() {
// [END auth_get_redirect_result]
}

function mergeAccounts() {
// This is just a dummy variable for sample purposes, the other
// snippets demonstrate how to get a real credential.
var newCredential = new firebase.auth.AuthCredential();

function mergeAccounts(newCredential) {
// [START auth_merge_accounts]
// The implementation of how you store your user data depends on your application
var repo = new MyUserDataRepo();
Expand Down Expand Up @@ -150,7 +138,6 @@ function mergeAccounts() {
// If there are errors we want to undo the data merge/deletion
console.log("Sign In Error", error);
repo.set(prevUser, prevUserData);
repo.set(currentUser, currentUserData);
});
// [END auth_merge_accounts]
}
Expand All @@ -164,7 +151,7 @@ function makeEmailCredential() {
// [END auth_make_email_credential]
}

function unlink() {
function unlink(providerId) {
var user = auth.currentUser;

// [START auth_unlink_provider]
Expand Down
4 changes: 3 additions & 1 deletion auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "auth",
"version": "1.0.0",
"scripts": {},
"scripts": {
"compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc"
},
"license": "Apache 2.0",
"dependencies": {
"firebase": "^7.12.0"
Expand Down
7 changes: 6 additions & 1 deletion database/emulator-suite.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

function onDocumentReady(firebase) {
// These samples are intended for Web so this import would normally be
// done in HTML however using modules here is more convenient for
// ensuring sample correctness offline.
var firebase = require("firebase/app");
require("firebase/database");

function onDocumentReady(firebase) {
//[START rtdb_emulator_connect]
if (location.hostname === "localhost") {

Expand Down
11 changes: 11 additions & 0 deletions database/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "database",
"version": "1.0.0",
"scripts": {
"compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc"
},
"license": "Apache 2.0",
"dependencies": {
"firebase": "^7.12.0"
}
}
6 changes: 6 additions & 0 deletions database/read-and-write.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// These samples are intended for Web so this import would normally be
// done in HTML however using modules here is more convenient for
// ensuring sample correctness offline.
var firebase = require("firebase/app");
require("firebase/database");

// [START rtdb_write_new_user]
function writeUserData(userId, name, email, imageUrl) {
firebase.database().ref('users/' + userId).set({
Expand Down
4 changes: 2 additions & 2 deletions firebaseapp/firebaseapp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var firebase = require('@firebase/app');
var firebase = require('firebase/app');

function multpleFirebaseApps() {
// [START firebase_options]
Expand All @@ -21,4 +21,4 @@ function multpleFirebaseApps() {
// Access services, such as the Realtime Database
// secondaryApp.database();
// [END firebase_secondary]
}
}
4 changes: 3 additions & 1 deletion firebaseapp/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "firebaseapp",
"version": "1.0.0",
"scripts": {},
"scripts": {
"compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc"
},
"license": "Apache-2.0",
"dependencies": {
"firebase": "^7.9.2"
Expand Down
2 changes: 1 addition & 1 deletion firestore/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<div id="mocha"></div>

<script src="https://cdn.rawgit.com/Automattic/expect.js/0.3.1/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chai@4.2.0/index.js"></script>
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>

<script>mocha.setup('bdd')</script>
Expand Down
10 changes: 9 additions & 1 deletion firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"name": "firestore",
"version": "1.0.0",
"scripts": {},
"scripts": {
"compile": "cp ../tsconfig.json.template ./tsconfig.json && tsc"
},
"license": "Apache-2.0",
"dependencies": {
"firebase": "^7.17.1"
},
"devDependencies": {
"@types/chai": "^4.2.12",
"@types/mocha": "^8.0.3",
"chai": "^4.2.0",
"mocha": "^8.1.3"
}
}
Loading