Skip to content

Commit 984006d

Browse files
authored
fix(storage): Fix for typing issue with Firebase v7 (#2703)
* Faster better stronger tests * Found the typing issue with Firebase v7, thanks matrix tests!
1 parent de46399 commit 984006d

File tree

6 files changed

+113
-69
lines changed

6 files changed

+113
-69
lines changed

.github/workflows/test.yml

+62-31
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,27 @@ jobs:
2121
uses: actions/setup-node@v2-beta
2222
with:
2323
node-version: '14'
24-
- name: Use yarn cache
24+
- name: node_modules cache
2525
uses: actions/cache@v2
26+
id: node_modules_cache
2627
with:
27-
path: |
28-
./node_modules
29-
~/.npm-packages-offline-cache
30-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
28+
path: ./node_modules
29+
key: ${{ runner.os }}-14-8-node_modules-${{ hashFiles('yarn.lock') }}
3130
restore-keys: |
32-
${{ runner.os }}-yarn-
33-
${{ runner.os }}-
31+
${{ runner.os }}-14-8-node_modules-
32+
${{ runner.os }}-14-node_modules-
33+
- name: Yarn offline cache
34+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
35+
uses: actions/cache@v2
36+
with:
37+
path: ~/.npm-packages-offline-cache
38+
key: yarn-offline-${{ hashFiles('**/yarn.lock') }}
39+
restore-keys: yarn-offline
3440
- name: Install deps
41+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
3542
run: |
3643
yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache
44+
yarn config set yarn-offline-mirror-pruning true
3745
yarn install --frozen-lockfile --prefer-offline
3846
- name: Build
3947
id: yarn-pack-dir
@@ -44,13 +52,16 @@ jobs:
4452
name: angularfire-${{ github.run_id }}
4553
path: dist
4654
retention-days: 1
55+
4756
test:
4857
runs-on: ubuntu-latest
4958
needs: build
5059
strategy:
5160
matrix:
5261
node: ["10", "12", "14"]
53-
name: Test Node.js ${{ matrix.node }} (Ubuntu)
62+
firebase: ["7", "8"]
63+
fail-fast: false
64+
name: Test Firebase v${{ matrix.firebase }} on Node.js ${{ matrix.node }}
5465
steps:
5566
- name: Checkout
5667
uses: actions/checkout@v2
@@ -59,36 +70,48 @@ jobs:
5970
with:
6071
node-version: ${{ matrix.node }}
6172
check-latest: true
62-
- name: Use yarn cache
73+
- name: node_modules cache
74+
id: node_modules_cache
6375
uses: actions/cache@v2
6476
with:
65-
path: |
66-
./node_modules
67-
~/.npm-packages-offline-cache
68-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
77+
path: ./node_modules
78+
key: ${{ runner.os }}-${{ matrix.node }}-${{ matrix.firebase }}-node_modules-${{ hashFiles('yarn.lock') }}
6979
restore-keys: |
70-
${{ runner.os }}-yarn-
71-
${{ runner.os }}-
72-
- name: Use Firebase emulator cache
80+
${{ runner.os }}-${{ matrix.node }}-${{ matrix.firebase }}-node_modules-
81+
${{ runner.os }}-${{ matrix.node }}-node_modules-
82+
- name: Yarn offline cache
83+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
7384
uses: actions/cache@v2
7485
with:
75-
path: ~/.cache/firebase/emulators
76-
key: firebase_emulators
86+
path: ~/.npm-packages-offline-cache
87+
key: yarn-offline-${{ hashFiles('**/yarn.lock') }}
88+
restore-keys: yarn-offline
7789
- name: Install deps
90+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
7891
run: |
7992
yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache
80-
yarn config set yarn-offline-mirror-pruning true
8193
yarn install --frozen-lockfile --prefer-offline
94+
yarn add firebase@^${{ matrix.firebase }}.0 --prefer-offline
95+
- name: Firebase emulator cache
96+
uses: actions/cache@v2
97+
with:
98+
path: ~/.cache/firebase/emulators
99+
key: firebase_emulators
82100
- name: 'Download Artifacts'
83101
uses: actions/download-artifact@v2
84102
- name: Run tests
85103
run: |
86104
mv angularfire-${{ github.run_id }} dist
87105
yarn test:node
106+
88107
headless:
89108
runs-on: ubuntu-latest
90109
needs: build
91-
name: Test Headless Chrome (Ubuntu)
110+
name: Test Firebase v${{ matrix.firebase }} on Headless Chrome
111+
strategy:
112+
matrix:
113+
firebase: ["7", "8"]
114+
fail-fast: false
92115
steps:
93116
- name: Checkout
94117
uses: actions/checkout@v2
@@ -97,32 +120,40 @@ jobs:
97120
with:
98121
node-version: '14'
99122
check-latest: true
100-
- name: Use yarn cache
123+
- name: node_modules cache
124+
id: node_modules_cache
101125
uses: actions/cache@v2
102126
with:
103-
path: |
104-
./node_modules
105-
~/.npm-packages-offline-cache
106-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
127+
path: ./node_modules
128+
key: ${{ runner.os }}-14-${{ matrix.firebase }}-node_modules-${{ hashFiles('yarn.lock') }}
107129
restore-keys: |
108-
${{ runner.os }}-yarn-
109-
${{ runner.os }}-
110-
- name: Use Firebase emulator cache
130+
${{ runner.os }}-14-${{ matrix.firebase }}-node_modules-
131+
${{ runner.os }}-14-node_modules-
132+
- name: Yarn offline cache
133+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
111134
uses: actions/cache@v2
112135
with:
113-
path: ~/.cache/firebase/emulators
114-
key: firebase_emulators
136+
path: ~/.npm-packages-offline-cache
137+
key: yarn-offline-${{ hashFiles('**/yarn.lock') }}
138+
restore-keys: yarn-offline
115139
- name: Install deps
140+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
116141
run: |
117142
yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache
118-
yarn config set yarn-offline-mirror-pruning true
119143
yarn install --frozen-lockfile --prefer-offline
144+
yarn add firebase@^${{ matrix.firebase }}.0 --prefer-offline
145+
- name: Firebase emulator cache
146+
uses: actions/cache@v2
147+
with:
148+
path: ~/.cache/firebase/emulators
149+
key: firebase_emulators
120150
- name: 'Download Artifacts'
121151
uses: actions/download-artifact@v2
122152
- name: Run tests
123153
run: |
124154
mv angularfire-${{ github.run_id }} dist
125155
yarn test:chrome-headless
156+
126157
publish:
127158
runs-on: ubuntu-latest
128159
name: Publish (NPM)

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@angular/platform-browser": "^9.0.0 || ^10.0.0 || ^11.0.0",
5050
"@angular/platform-browser-dynamic": "^9.0.0 || ^10.0.0 || ^11.0.0",
5151
"@angular/router": "^9.0.0 || ^10.0.0 || ^11.0.0",
52-
"firebase": "^7.0.0 || ^8.0.0",
52+
"firebase": "^7.0 || ^8.0",
5353
"firebase-admin": "^8.10.0",
5454
"firebase-functions": "^3.6.0",
5555
"firebase-tools": "^8.0.0",
@@ -78,7 +78,6 @@
7878
"@angular/cli": "^9.0.0 || ^10.0.0 || ^11.0.0",
7979
"@angular/compiler-cli": "^9.0.0 || ^10.0.0 || ^11.0.0",
8080
"@angular/platform-server": "^9.0.0 || ^10.0.0 || ^11.0.0",
81-
"@firebase/app-types": "^0.6.1",
8281
"@types/fs-extra": "^7.0.0",
8382
"@types/gzip-size": "^5.1.1",
8483
"@types/inquirer": "^0.0.44",
@@ -90,6 +89,7 @@
9089
"concurrently": "^2.2.0",
9190
"conventional-changelog-cli": "^1.2.0",
9291
"firebase-functions-test": "^0.2.2",
92+
"globalthis": "^1.0.1",
9393
"gzip-size": "^5.1.1",
9494
"jasmine": "^3.4.0",
9595
"jasmine-core": "~3.5.0",

src/database/list/changes.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import firebase from 'firebase/app';
22
import { AngularFireModule, FirebaseApp } from '@angular/fire';
3-
import { AngularFireDatabase, AngularFireDatabaseModule, listChanges, URL } from '../public_api';
3+
import { AngularFireDatabase, AngularFireDatabaseModule, listChanges, URL } from '@angular/fire/database';
44
import { TestBed } from '@angular/core/testing';
55
import { COMMON_CONFIG } from '../../test-config';
66
import { skip, take } from 'rxjs/operators';

src/storage/observable/fromTask.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { Observable } from 'rxjs';
22
import { shareReplay } from 'rxjs/operators';
33
import { UploadTask, UploadTaskSnapshot } from '../interfaces';
44

5+
// need to import, else the types become import('firebase/app').default.storage.UploadTask
6+
// and it no longer works w/Firebase v7
7+
import firebase from 'firebase/app';
8+
59
export function fromTask(task: UploadTask) {
610
return new Observable<UploadTaskSnapshot>(subscriber => {
711
const progress = (snap: UploadTaskSnapshot) => subscriber.next(snap);

tools/jasmine.js

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ require('zone.js/dist/task-tracking');
2121
const { getTestBed } = require('@angular/core/testing');
2222
const { platformServerTesting, ServerTestingModule } = require('@angular/platform-server/testing');
2323

24+
global['globalThis'] = require('globalthis/polyfill')();
25+
2426
// First, initialize the Angular testing environment.
2527
getTestBed().initTestEnvironment(
2628
ServerTestingModule,

yarn.lock

+42-35
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@
11691169
"@firebase/util" "0.3.4"
11701170
tslib "^1.11.1"
11711171

1172-
"@firebase/[email protected]", "@firebase/app-types@^0.6.1":
1172+
"@firebase/[email protected]":
11731173
version "0.6.1"
11741174
resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.6.1.tgz#dcbd23030a71c0c74fc95d4a3f75ba81653850e9"
11751175
integrity sha512-L/ZnJRAq7F++utfuoTKX4CLBG5YR7tFO3PLzG1/oXXKEezJ0kRL3CMRoueBEmTCzVb/6SIs2Qlaw++uDgi5Xyg==
@@ -1197,10 +1197,10 @@
11971197
resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.10.1.tgz#7815e71c9c6f072034415524b29ca8f1d1770660"
11981198
integrity sha512-/+gBHb1O9x/YlG7inXfxff/6X3BPZt4zgBv4kql6HEmdzNQCodIRlEYnI+/da+lN+dha7PjaFH7C7ewMmfV7rw==
11991199

1200-
"@firebase/[email protected].1":
1201-
version "0.15.1"
1202-
resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.15.1.tgz#2e0e7397d6f754d81916babd9bce21a51f4b25a3"
1203-
integrity sha512-qVJTmq/6l3/o6V93nAD+n1ExTywbKEFYbuuI1TZIUryy5KSXOFnxilmZI4yJeQSZ3ee06YiJsIRYRaYUeg6JQQ==
1200+
"@firebase/[email protected].2":
1201+
version "0.15.2"
1202+
resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.15.2.tgz#9ada3f37620d131a1c56994138a599b5c9f9ca2e"
1203+
integrity sha512-2n32PBi6x9jVhc0E/ewKLUCYYTzFEXL4PNkvrrlGKbzeTBEkkyzfgUX7OV9UF5wUOG+gurtUthuur1zspZ/9hg==
12041204
dependencies:
12051205
"@firebase/auth-types" "0.10.1"
12061206

@@ -1227,21 +1227,21 @@
12271227
dependencies:
12281228
"@firebase/app-types" "0.6.1"
12291229

1230-
"@firebase/[email protected].0":
1231-
version "0.6.0"
1232-
resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.6.0.tgz#7795bc6b1db93f4cbda9a241c8dfe1bb86033dc6"
1233-
integrity sha512-ljpU7/uboCGqFSe9CNgwd3+Xu5N8YCunzfPpeueuj2vjnmmypUi4QWxgC3UKtGbuv1q+crjeudZGLxnUoO0h7w==
1230+
"@firebase/[email protected].1":
1231+
version "0.6.1"
1232+
resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.6.1.tgz#cf1cfc03e617ed4c2561703781f85ba4c707ff65"
1233+
integrity sha512-JtL3FUbWG+bM59iYuphfx9WOu2Mzf0OZNaqWiQ7lJR8wBe7bS9rIm9jlBFtksB7xcya1lZSQPA/GAy2jIlMIkA==
12341234
dependencies:
12351235
"@firebase/app-types" "0.6.1"
12361236

1237-
"@firebase/database@0.7.1":
1238-
version "0.7.1"
1239-
resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.7.1.tgz#900d2e6ed734249e65e5f159293830e4f4285d6e"
1240-
integrity sha512-8j3KwksaYMSbIsEjOIarZD3vj4jGJjIlLGIAiO/4P4XyOtrlnxIiH7G0UdIZlcvKU4Gsgg0nthT2+EapROmHWA==
1237+
"@firebase/database@0.8.1":
1238+
version "0.8.1"
1239+
resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.8.1.tgz#a7bc1c01052d35817a242c21bfe09ab29ee485a3"
1240+
integrity sha512-/1HhR4ejpqUaM9Cn3KSeNdQvdlehWIhdfTVWFxS73ZlLYf7ayk9jITwH10H3ZOIm5yNzxF67p/U7Z/0IPhgWaQ==
12411241
dependencies:
12421242
"@firebase/auth-interop-types" "0.1.5"
12431243
"@firebase/component" "0.1.21"
1244-
"@firebase/database-types" "0.6.0"
1244+
"@firebase/database-types" "0.6.1"
12451245
"@firebase/logger" "0.2.6"
12461246
"@firebase/util" "0.3.4"
12471247
faye-websocket "0.11.3"
@@ -1265,16 +1265,16 @@
12651265
resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-2.0.0.tgz#1f6212553b240f1a8905bb8dcf1f87769138c5c0"
12661266
integrity sha512-ZGb7p1SSQJP0Z+kc9GAUi+Fx5rJatFddBrS1ikkayW+QHfSIz0omU23OgSHcBGTxe8dJCeKiKA2Yf+tkDKO/LA==
12671267

1268-
"@firebase/[email protected].1":
1269-
version "2.0.1"
1270-
resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-2.0.1.tgz#2d4734ecd5d165582eedea8487849c5535a55c0e"
1271-
integrity sha512-7WMv3b+2P/6SOE0RxPB+S6k75/vYTDhOpPBp6JH6nPQjS9mGtR9m0adKtXjOBBugcbK6sBgPMzxmQGwQl8lW4w==
1268+
"@firebase/[email protected].4":
1269+
version "2.0.4"
1270+
resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-2.0.4.tgz#c4be6f3540f607fd8e200cfba83c4997c29447fe"
1271+
integrity sha512-fzJKj/4h4jOwPSfHB42XBJIC0zsPsepU6FcBO+8nSx7G2IPfTw8cMgSNin2gPqX6tR1w1NQtHiSlXiRKsbMZdA==
12721272
dependencies:
12731273
"@firebase/component" "0.1.21"
12741274
"@firebase/firestore-types" "2.0.0"
12751275
"@firebase/logger" "0.2.6"
12761276
"@firebase/util" "0.3.4"
1277-
"@firebase/webchannel-wrapper" "0.4.0"
1277+
"@firebase/webchannel-wrapper" "0.4.1"
12781278
"@grpc/grpc-js" "^1.0.0"
12791279
"@grpc/proto-loader" "^0.5.0"
12801280
node-fetch "2.6.1"
@@ -1382,10 +1382,10 @@
13821382
resolved "https://registry.yarnpkg.com/@firebase/storage-types/-/storage-types-0.3.13.tgz#cd43e939a2ab5742e109eb639a313673a48b5458"
13831383
integrity sha512-pL7b8d5kMNCCL0w9hF7pr16POyKkb3imOW7w0qYrhBnbyJTdVxMWZhb0HxCFyQWC0w3EiIFFmxoz8NTFZDEFog==
13841384

1385-
"@firebase/[email protected].1":
1386-
version "0.4.1"
1387-
resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.4.1.tgz#b86973a8ab3ef52f38d6463fcc7613f5801ff8e4"
1388-
integrity sha512-/l05Dn3UYynPELt0ZFJz24H49sQ8c8KnOEGR/Pk1AOjLmc71vjjobVEkgkHyy1eyfmYuAZtsc6ePOwc89YnBTg==
1385+
"@firebase/[email protected].2":
1386+
version "0.4.2"
1387+
resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.4.2.tgz#bc5924b87bd2fdd4ab0de49851c0125ebc236b89"
1388+
integrity sha512-87CrvKrf8kijVekRBmUs8htsNz7N5X/pDhv3BvJBqw8K65GsUolpyjx0f4QJRkCRUYmh3MSkpa5P08lpVbC6nQ==
13891389
dependencies:
13901390
"@firebase/component" "0.1.21"
13911391
"@firebase/storage-types" "0.3.13"
@@ -1406,10 +1406,10 @@
14061406
dependencies:
14071407
tslib "^1.11.1"
14081408

1409-
"@firebase/[email protected].0":
1410-
version "0.4.0"
1411-
resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.4.0.tgz#becce788818d3f47f0ac1a74c3c061ac1dcf4f6d"
1412-
integrity sha512-8cUA/mg0S+BxIZ72TdZRsXKBP5n5uRcE3k29TZhZw6oIiHBt9JA7CTb/4pE1uKtE/q5NeTY2tBDcagoZ+1zjXQ==
1409+
"@firebase/[email protected].1":
1410+
version "0.4.1"
1411+
resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.4.1.tgz#600f2275ff54739ad5ac0102f1467b8963cd5f71"
1412+
integrity sha512-0yPjzuzGMkW1GkrC8yWsiN7vt1OzkMIi9HgxRmKREZl2wnNPOKo/yScTjXf/O57HM8dltqxPF6jlNLFVtc2qdw==
14131413

14141414
"@google-cloud/common@^2.1.1":
14151415
version "2.4.0"
@@ -5877,24 +5877,24 @@ firebase-tools@^8.0.0:
58775877
winston "^3.0.0"
58785878
ws "^7.2.3"
58795879

5880-
"firebase@^7.0.0 || ^8.0.0":
5881-
version "8.0.1"
5882-
resolved "https://registry.yarnpkg.com/firebase/-/firebase-8.0.1.tgz#24836c654c8577abd640439a5f1bc707bbd9f236"
5883-
integrity sha512-7QQKw+ycoR3LhMlxhPM+ND1F2Fx1eDlf3E55xYbmooxFW1t0p94HNENBc3JZytR1H0VoG9nSm2QEHsdr/Ca1Rg==
5880+
"firebase@^7.0 || ^8.0":
5881+
version "8.1.1"
5882+
resolved "https://registry.yarnpkg.com/firebase/-/firebase-8.1.1.tgz#379094b724053931fda1086e9020a17b578e50d5"
5883+
integrity sha512-w1plr2jYvzBkx/rHE6A0EJf9318ufA5omShLuGocPlQtrvphel+KJcd+R02outE5E2lSDhyM0l3EoiA0YCD4hA==
58845884
dependencies:
58855885
"@firebase/analytics" "0.6.2"
58865886
"@firebase/app" "0.6.13"
58875887
"@firebase/app-types" "0.6.1"
5888-
"@firebase/auth" "0.15.1"
5889-
"@firebase/database" "0.7.1"
5890-
"@firebase/firestore" "2.0.1"
5888+
"@firebase/auth" "0.15.2"
5889+
"@firebase/database" "0.8.1"
5890+
"@firebase/firestore" "2.0.4"
58915891
"@firebase/functions" "0.6.1"
58925892
"@firebase/installations" "0.4.19"
58935893
"@firebase/messaging" "0.7.3"
58945894
"@firebase/performance" "0.4.4"
58955895
"@firebase/polyfill" "0.3.36"
58965896
"@firebase/remote-config" "0.1.30"
5897-
"@firebase/storage" "0.4.1"
5897+
"@firebase/storage" "0.4.2"
58985898
"@firebase/util" "0.3.4"
58995899

59005900
flat-arguments@^1.0.0:
@@ -6359,6 +6359,13 @@ globals@^9.18.0:
63596359
resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
63606360
integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==
63616361

6362+
globalthis@^1.0.1:
6363+
version "1.0.1"
6364+
resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.1.tgz#40116f5d9c071f9e8fb0037654df1ab3a83b7ef9"
6365+
integrity sha512-mJPRTc/P39NH/iNG4mXa9aIhNymaQikTrnspeCa2ZuJ+mH2QN/rXwtX3XwKrHqWgUQFbNZKtHM105aHzJalElw==
6366+
dependencies:
6367+
define-properties "^1.1.3"
6368+
63626369
globby@^11.0.1:
63636370
version "11.0.1"
63646371
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357"

0 commit comments

Comments
 (0)