diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b029135f2..2da3e8ab6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,19 +21,27 @@ jobs: uses: actions/setup-node@v2-beta with: node-version: '14' - - name: Use yarn cache + - name: node_modules cache uses: actions/cache@v2 + id: node_modules_cache with: - path: | - ./node_modules - ~/.npm-packages-offline-cache - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ./node_modules + key: ${{ runner.os }}-14-8-node_modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-yarn- - ${{ runner.os }}- + ${{ runner.os }}-14-8-node_modules- + ${{ runner.os }}-14-node_modules- + - name: Yarn offline cache + if: steps.node_modules_cache.outputs.cache-hit != 'true' + uses: actions/cache@v2 + with: + path: ~/.npm-packages-offline-cache + key: yarn-offline-${{ hashFiles('**/yarn.lock') }} + restore-keys: yarn-offline - name: Install deps + if: steps.node_modules_cache.outputs.cache-hit != 'true' run: | yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache + yarn config set yarn-offline-mirror-pruning true yarn install --frozen-lockfile --prefer-offline - name: Build id: yarn-pack-dir @@ -44,13 +52,16 @@ jobs: name: angularfire-${{ github.run_id }} path: dist retention-days: 1 + test: runs-on: ubuntu-latest needs: build strategy: matrix: node: ["10", "12", "14"] - name: Test Node.js ${{ matrix.node }} (Ubuntu) + firebase: ["7", "8"] + fail-fast: false + name: Test Firebase v${{ matrix.firebase }} on Node.js ${{ matrix.node }} steps: - name: Checkout uses: actions/checkout@v2 @@ -59,36 +70,48 @@ jobs: with: node-version: ${{ matrix.node }} check-latest: true - - name: Use yarn cache + - name: node_modules cache + id: node_modules_cache uses: actions/cache@v2 with: - path: | - ./node_modules - ~/.npm-packages-offline-cache - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ./node_modules + key: ${{ runner.os }}-${{ matrix.node }}-${{ matrix.firebase }}-node_modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-yarn- - ${{ runner.os }}- - - name: Use Firebase emulator cache + ${{ runner.os }}-${{ matrix.node }}-${{ matrix.firebase }}-node_modules- + ${{ runner.os }}-${{ matrix.node }}-node_modules- + - name: Yarn offline cache + if: steps.node_modules_cache.outputs.cache-hit != 'true' uses: actions/cache@v2 with: - path: ~/.cache/firebase/emulators - key: firebase_emulators + path: ~/.npm-packages-offline-cache + key: yarn-offline-${{ hashFiles('**/yarn.lock') }} + restore-keys: yarn-offline - name: Install deps + if: steps.node_modules_cache.outputs.cache-hit != 'true' run: | yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache - yarn config set yarn-offline-mirror-pruning true yarn install --frozen-lockfile --prefer-offline + yarn add firebase@^${{ matrix.firebase }}.0 --prefer-offline + - name: Firebase emulator cache + uses: actions/cache@v2 + with: + path: ~/.cache/firebase/emulators + key: firebase_emulators - name: 'Download Artifacts' uses: actions/download-artifact@v2 - name: Run tests run: | mv angularfire-${{ github.run_id }} dist yarn test:node + headless: runs-on: ubuntu-latest needs: build - name: Test Headless Chrome (Ubuntu) + name: Test Firebase v${{ matrix.firebase }} on Headless Chrome + strategy: + matrix: + firebase: ["7", "8"] + fail-fast: false steps: - name: Checkout uses: actions/checkout@v2 @@ -97,32 +120,40 @@ jobs: with: node-version: '14' check-latest: true - - name: Use yarn cache + - name: node_modules cache + id: node_modules_cache uses: actions/cache@v2 with: - path: | - ./node_modules - ~/.npm-packages-offline-cache - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ./node_modules + key: ${{ runner.os }}-14-${{ matrix.firebase }}-node_modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-yarn- - ${{ runner.os }}- - - name: Use Firebase emulator cache + ${{ runner.os }}-14-${{ matrix.firebase }}-node_modules- + ${{ runner.os }}-14-node_modules- + - name: Yarn offline cache + if: steps.node_modules_cache.outputs.cache-hit != 'true' uses: actions/cache@v2 with: - path: ~/.cache/firebase/emulators - key: firebase_emulators + path: ~/.npm-packages-offline-cache + key: yarn-offline-${{ hashFiles('**/yarn.lock') }} + restore-keys: yarn-offline - name: Install deps + if: steps.node_modules_cache.outputs.cache-hit != 'true' run: | yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache - yarn config set yarn-offline-mirror-pruning true yarn install --frozen-lockfile --prefer-offline + yarn add firebase@^${{ matrix.firebase }}.0 --prefer-offline + - name: Firebase emulator cache + uses: actions/cache@v2 + with: + path: ~/.cache/firebase/emulators + key: firebase_emulators - name: 'Download Artifacts' uses: actions/download-artifact@v2 - name: Run tests run: | mv angularfire-${{ github.run_id }} dist yarn test:chrome-headless + publish: runs-on: ubuntu-latest name: Publish (NPM) diff --git a/package.json b/package.json index bdffd4b66..63864cec2 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@angular/platform-browser": "^9.0.0 || ^10.0.0 || ^11.0.0", "@angular/platform-browser-dynamic": "^9.0.0 || ^10.0.0 || ^11.0.0", "@angular/router": "^9.0.0 || ^10.0.0 || ^11.0.0", - "firebase": "^7.0.0 || ^8.0.0", + "firebase": "^7.0 || ^8.0", "firebase-admin": "^8.10.0", "firebase-functions": "^3.6.0", "firebase-tools": "^8.0.0", @@ -78,7 +78,6 @@ "@angular/cli": "^9.0.0 || ^10.0.0 || ^11.0.0", "@angular/compiler-cli": "^9.0.0 || ^10.0.0 || ^11.0.0", "@angular/platform-server": "^9.0.0 || ^10.0.0 || ^11.0.0", - "@firebase/app-types": "^0.6.1", "@types/fs-extra": "^7.0.0", "@types/gzip-size": "^5.1.1", "@types/inquirer": "^0.0.44", @@ -90,6 +89,7 @@ "concurrently": "^2.2.0", "conventional-changelog-cli": "^1.2.0", "firebase-functions-test": "^0.2.2", + "globalthis": "^1.0.1", "gzip-size": "^5.1.1", "jasmine": "^3.4.0", "jasmine-core": "~3.5.0", diff --git a/src/database/list/changes.spec.ts b/src/database/list/changes.spec.ts index ae87b837f..b5e5209c5 100644 --- a/src/database/list/changes.spec.ts +++ b/src/database/list/changes.spec.ts @@ -1,6 +1,6 @@ import firebase from 'firebase/app'; import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFireDatabase, AngularFireDatabaseModule, listChanges, URL } from '../public_api'; +import { AngularFireDatabase, AngularFireDatabaseModule, listChanges, URL } from '@angular/fire/database'; import { TestBed } from '@angular/core/testing'; import { COMMON_CONFIG } from '../../test-config'; import { skip, take } from 'rxjs/operators'; diff --git a/src/storage/observable/fromTask.ts b/src/storage/observable/fromTask.ts index a4442dd1e..ddbb9f388 100644 --- a/src/storage/observable/fromTask.ts +++ b/src/storage/observable/fromTask.ts @@ -2,6 +2,10 @@ import { Observable } from 'rxjs'; import { shareReplay } from 'rxjs/operators'; import { UploadTask, UploadTaskSnapshot } from '../interfaces'; +// need to import, else the types become import('firebase/app').default.storage.UploadTask +// and it no longer works w/Firebase v7 +import firebase from 'firebase/app'; + export function fromTask(task: UploadTask) { return new Observable(subscriber => { const progress = (snap: UploadTaskSnapshot) => subscriber.next(snap); diff --git a/tools/jasmine.js b/tools/jasmine.js index dd9650197..d06a165c5 100644 --- a/tools/jasmine.js +++ b/tools/jasmine.js @@ -21,6 +21,8 @@ require('zone.js/dist/task-tracking'); const { getTestBed } = require('@angular/core/testing'); const { platformServerTesting, ServerTestingModule } = require('@angular/platform-server/testing'); +global['globalThis'] = require('globalthis/polyfill')(); + // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( ServerTestingModule, diff --git a/yarn.lock b/yarn.lock index 1b0da872e..86f6d94fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1169,7 +1169,7 @@ "@firebase/util" "0.3.4" tslib "^1.11.1" -"@firebase/app-types@0.6.1", "@firebase/app-types@^0.6.1": +"@firebase/app-types@0.6.1": version "0.6.1" resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.6.1.tgz#dcbd23030a71c0c74fc95d4a3f75ba81653850e9" integrity sha512-L/ZnJRAq7F++utfuoTKX4CLBG5YR7tFO3PLzG1/oXXKEezJ0kRL3CMRoueBEmTCzVb/6SIs2Qlaw++uDgi5Xyg== @@ -1197,10 +1197,10 @@ resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.10.1.tgz#7815e71c9c6f072034415524b29ca8f1d1770660" integrity sha512-/+gBHb1O9x/YlG7inXfxff/6X3BPZt4zgBv4kql6HEmdzNQCodIRlEYnI+/da+lN+dha7PjaFH7C7ewMmfV7rw== -"@firebase/auth@0.15.1": - version "0.15.1" - resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.15.1.tgz#2e0e7397d6f754d81916babd9bce21a51f4b25a3" - integrity sha512-qVJTmq/6l3/o6V93nAD+n1ExTywbKEFYbuuI1TZIUryy5KSXOFnxilmZI4yJeQSZ3ee06YiJsIRYRaYUeg6JQQ== +"@firebase/auth@0.15.2": + version "0.15.2" + resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.15.2.tgz#9ada3f37620d131a1c56994138a599b5c9f9ca2e" + integrity sha512-2n32PBi6x9jVhc0E/ewKLUCYYTzFEXL4PNkvrrlGKbzeTBEkkyzfgUX7OV9UF5wUOG+gurtUthuur1zspZ/9hg== dependencies: "@firebase/auth-types" "0.10.1" @@ -1227,21 +1227,21 @@ dependencies: "@firebase/app-types" "0.6.1" -"@firebase/database-types@0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.6.0.tgz#7795bc6b1db93f4cbda9a241c8dfe1bb86033dc6" - integrity sha512-ljpU7/uboCGqFSe9CNgwd3+Xu5N8YCunzfPpeueuj2vjnmmypUi4QWxgC3UKtGbuv1q+crjeudZGLxnUoO0h7w== +"@firebase/database-types@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.6.1.tgz#cf1cfc03e617ed4c2561703781f85ba4c707ff65" + integrity sha512-JtL3FUbWG+bM59iYuphfx9WOu2Mzf0OZNaqWiQ7lJR8wBe7bS9rIm9jlBFtksB7xcya1lZSQPA/GAy2jIlMIkA== dependencies: "@firebase/app-types" "0.6.1" -"@firebase/database@0.7.1": - version "0.7.1" - resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.7.1.tgz#900d2e6ed734249e65e5f159293830e4f4285d6e" - integrity sha512-8j3KwksaYMSbIsEjOIarZD3vj4jGJjIlLGIAiO/4P4XyOtrlnxIiH7G0UdIZlcvKU4Gsgg0nthT2+EapROmHWA== +"@firebase/database@0.8.1": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.8.1.tgz#a7bc1c01052d35817a242c21bfe09ab29ee485a3" + integrity sha512-/1HhR4ejpqUaM9Cn3KSeNdQvdlehWIhdfTVWFxS73ZlLYf7ayk9jITwH10H3ZOIm5yNzxF67p/U7Z/0IPhgWaQ== dependencies: "@firebase/auth-interop-types" "0.1.5" "@firebase/component" "0.1.21" - "@firebase/database-types" "0.6.0" + "@firebase/database-types" "0.6.1" "@firebase/logger" "0.2.6" "@firebase/util" "0.3.4" faye-websocket "0.11.3" @@ -1265,16 +1265,16 @@ resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-2.0.0.tgz#1f6212553b240f1a8905bb8dcf1f87769138c5c0" integrity sha512-ZGb7p1SSQJP0Z+kc9GAUi+Fx5rJatFddBrS1ikkayW+QHfSIz0omU23OgSHcBGTxe8dJCeKiKA2Yf+tkDKO/LA== -"@firebase/firestore@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-2.0.1.tgz#2d4734ecd5d165582eedea8487849c5535a55c0e" - integrity sha512-7WMv3b+2P/6SOE0RxPB+S6k75/vYTDhOpPBp6JH6nPQjS9mGtR9m0adKtXjOBBugcbK6sBgPMzxmQGwQl8lW4w== +"@firebase/firestore@2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-2.0.4.tgz#c4be6f3540f607fd8e200cfba83c4997c29447fe" + integrity sha512-fzJKj/4h4jOwPSfHB42XBJIC0zsPsepU6FcBO+8nSx7G2IPfTw8cMgSNin2gPqX6tR1w1NQtHiSlXiRKsbMZdA== dependencies: "@firebase/component" "0.1.21" "@firebase/firestore-types" "2.0.0" "@firebase/logger" "0.2.6" "@firebase/util" "0.3.4" - "@firebase/webchannel-wrapper" "0.4.0" + "@firebase/webchannel-wrapper" "0.4.1" "@grpc/grpc-js" "^1.0.0" "@grpc/proto-loader" "^0.5.0" node-fetch "2.6.1" @@ -1382,10 +1382,10 @@ resolved "https://registry.yarnpkg.com/@firebase/storage-types/-/storage-types-0.3.13.tgz#cd43e939a2ab5742e109eb639a313673a48b5458" integrity sha512-pL7b8d5kMNCCL0w9hF7pr16POyKkb3imOW7w0qYrhBnbyJTdVxMWZhb0HxCFyQWC0w3EiIFFmxoz8NTFZDEFog== -"@firebase/storage@0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.4.1.tgz#b86973a8ab3ef52f38d6463fcc7613f5801ff8e4" - integrity sha512-/l05Dn3UYynPELt0ZFJz24H49sQ8c8KnOEGR/Pk1AOjLmc71vjjobVEkgkHyy1eyfmYuAZtsc6ePOwc89YnBTg== +"@firebase/storage@0.4.2": + version "0.4.2" + resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.4.2.tgz#bc5924b87bd2fdd4ab0de49851c0125ebc236b89" + integrity sha512-87CrvKrf8kijVekRBmUs8htsNz7N5X/pDhv3BvJBqw8K65GsUolpyjx0f4QJRkCRUYmh3MSkpa5P08lpVbC6nQ== dependencies: "@firebase/component" "0.1.21" "@firebase/storage-types" "0.3.13" @@ -1406,10 +1406,10 @@ dependencies: tslib "^1.11.1" -"@firebase/webchannel-wrapper@0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.4.0.tgz#becce788818d3f47f0ac1a74c3c061ac1dcf4f6d" - integrity sha512-8cUA/mg0S+BxIZ72TdZRsXKBP5n5uRcE3k29TZhZw6oIiHBt9JA7CTb/4pE1uKtE/q5NeTY2tBDcagoZ+1zjXQ== +"@firebase/webchannel-wrapper@0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.4.1.tgz#600f2275ff54739ad5ac0102f1467b8963cd5f71" + integrity sha512-0yPjzuzGMkW1GkrC8yWsiN7vt1OzkMIi9HgxRmKREZl2wnNPOKo/yScTjXf/O57HM8dltqxPF6jlNLFVtc2qdw== "@google-cloud/common@^2.1.1": version "2.4.0" @@ -5877,24 +5877,24 @@ firebase-tools@^8.0.0: winston "^3.0.0" ws "^7.2.3" -"firebase@^7.0.0 || ^8.0.0": - version "8.0.1" - resolved "https://registry.yarnpkg.com/firebase/-/firebase-8.0.1.tgz#24836c654c8577abd640439a5f1bc707bbd9f236" - integrity sha512-7QQKw+ycoR3LhMlxhPM+ND1F2Fx1eDlf3E55xYbmooxFW1t0p94HNENBc3JZytR1H0VoG9nSm2QEHsdr/Ca1Rg== +"firebase@^7.0 || ^8.0": + version "8.1.1" + resolved "https://registry.yarnpkg.com/firebase/-/firebase-8.1.1.tgz#379094b724053931fda1086e9020a17b578e50d5" + integrity sha512-w1plr2jYvzBkx/rHE6A0EJf9318ufA5omShLuGocPlQtrvphel+KJcd+R02outE5E2lSDhyM0l3EoiA0YCD4hA== dependencies: "@firebase/analytics" "0.6.2" "@firebase/app" "0.6.13" "@firebase/app-types" "0.6.1" - "@firebase/auth" "0.15.1" - "@firebase/database" "0.7.1" - "@firebase/firestore" "2.0.1" + "@firebase/auth" "0.15.2" + "@firebase/database" "0.8.1" + "@firebase/firestore" "2.0.4" "@firebase/functions" "0.6.1" "@firebase/installations" "0.4.19" "@firebase/messaging" "0.7.3" "@firebase/performance" "0.4.4" "@firebase/polyfill" "0.3.36" "@firebase/remote-config" "0.1.30" - "@firebase/storage" "0.4.1" + "@firebase/storage" "0.4.2" "@firebase/util" "0.3.4" flat-arguments@^1.0.0: @@ -6359,6 +6359,13 @@ globals@^9.18.0: resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== +globalthis@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.1.tgz#40116f5d9c071f9e8fb0037654df1ab3a83b7ef9" + integrity sha512-mJPRTc/P39NH/iNG4mXa9aIhNymaQikTrnspeCa2ZuJ+mH2QN/rXwtX3XwKrHqWgUQFbNZKtHM105aHzJalElw== + dependencies: + define-properties "^1.1.3" + globby@^11.0.1: version "11.0.1" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357"