diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 19379e87e..becdc4d6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,33 +1,120 @@ -name: Unit tests +name: Test and publish on: push: branches: - - master - pull_request: + - "**" + paths-ignore: + - "**/*.md" + release: + types: + - published jobs: build: runs-on: ubuntu-latest + name: Build steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2-beta - with: - node-version: '12' - check-latest: true - - name: yarn cache dir - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - ${{ runner.os }}- - - name: yarn test - run: | - yarn install --frozen-lockfile --prefer-offline - yarn lint - yarn build - yarn test:all + - name: Checkout + uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-node@v2-beta + with: + node-version: '14' + - name: Get cache directory + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Use yarn cache + uses: actions/cache@v2 + with: + path: | + ${{ steps.yarn-cache-dir-path.outputs.dir }} + ~/.npm-packages-offline-cache + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + ${{ runner.os }}- + - name: Install deps + 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 + run: ./tools/build.sh + - name: 'Upload Artifact' + uses: actions/upload-artifact@v2 + with: + name: angularfire-${{ github.run_id }} + path: | + angularfire.tgz + publish.sh + unpack.sh + retention-days: 1 + test: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + node: ["10", "12", "14"] + name: Test Node.js ${{ matrix.node }} (Ubuntu) + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node }} + check-latest: true + - name: Get cache directory + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Use yarn cache + uses: actions/cache@v2 + with: + path: | + ${{ steps.yarn-cache-dir-path.outputs.dir }} + ~/.npm-packages-offline-cache + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + ${{ runner.os }}- + - name: Use Firebase emulator cache + uses: actions/cache@v2 + with: + path: ~/.cache/firebase/emulators + key: firebase_emulators + - name: Install deps + 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: 'Download Artifacts' + uses: actions/download-artifact@v2 + - name: Expand Artifact + run: | + mkdir -p dist/packages-dist + chmod +x angularfire-${{ github.run_id }}/unpack.sh + ./angularfire-${{ github.run_id }}/unpack.sh + - name: Run tests + run: yarn test:all + publish: + runs-on: ubuntu-latest + name: Publish (NPM) + needs: test + if: ${{ github.ref == 'refs/heads/master' || github.event_name == 'release' }} + steps: + - name: Setup node + uses: actions/setup-node@v2-beta + with: + node-version: '14' + registry-url: 'https://registry.npmjs.org' + - name: 'Download Artifacts' + uses: actions/download-artifact@v2 + - name: Publish + run: | + cd ./angularfire-${{ github.run_id }}/ + chmod +x publish.sh + ./publish.sh + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 777568cf0..2bba22228 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,7 @@ tools/build.js coverage *.log api-*.json -src/**/base.ts \ No newline at end of file +src/**/base.ts +angularfire.tgz +unpack.sh +publish.sh \ No newline at end of file diff --git a/cloudbuild.yaml b/cloudbuild.yaml deleted file mode 100644 index 198b2bb97..000000000 --- a/cloudbuild.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# See go/angularfire-releasing for details on the AngularFire release process. -# If you need to trigger a release manually, be sure to use substitutions like so: -# @canary `gcloud builds submit --substitutions=SHORT_SHA="9b0a0b0"` -# @next `gcloud builds submit --substitutions=TAG_NAME="1.2.3-rc.1"` -# @latest `gcloud builds submit --substitutions=TAG_NAME="1.2.3"` -steps: -- name: node:lts - entrypoint: bash - args: ["./tools/build.sh"] - env: - - 'TAG_NAME=$TAG_NAME' - - 'SHORT_SHA=$SHORT_SHA' - -#- name: node:lts -# entrypoint: bash -# args: ["./tools/test.sh"] - -- name: node:lts - entrypoint: bash - env: ['TAG_NAME=$TAG_NAME'] - args: ["./tools/release.sh"] - secretEnv: ['NPM_TOKEN'] - -secrets: -- kmsKeyName: projects/angularfire/locations/global/keyRings/cloud-build/cryptoKeys/cloud-build - secretEnv: - NPM_TOKEN: CiQAwtE8WoPa1sNqAQJZ1WMODuJooVmO6zihz2hAZOfUmDsgogUSTQCq8yp8qgltY+8jWpAR9GuS1JaVhd+fTVRilqLtdi2yXSdiDPTzLhZ+30bMlAOcoc0PxhCBn3JOpn8H1xshX+mG8yK7xog2Uq+CLVx/ - -timeout: 1200s \ No newline at end of file diff --git a/src/analytics/analytics.spec.ts b/src/analytics/analytics.spec.ts index 9804f993a..a3f2b2973 100644 --- a/src/analytics/analytics.spec.ts +++ b/src/analytics/analytics.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFireAnalytics, AngularFireAnalyticsModule } from './public_api'; +import { AngularFireAnalytics, AngularFireAnalyticsModule } from '@angular/fire/analytics'; import { COMMON_CONFIG } from '../test-config'; import { rando } from '../firestore/utils.spec'; diff --git a/src/analytics/analytics.ts b/src/analytics/analytics.ts index 1f8bfe917..bcf3cc5d1 100644 --- a/src/analytics/analytics.ts +++ b/src/analytics/analytics.ts @@ -144,10 +144,11 @@ export class AngularFireAnalytics { const analytics = of(undefined).pipe( observeOn(new ɵAngularFireSchedulers(zone).outsideAngular), - switchMap(() => import('firebase/analytics')), - switchMap(() => firebase.analytics.isSupported().then(it => it, () => false)), + switchMap(() => isPlatformBrowser(platformId) ? zone.runOutsideAngular(() => import('firebase/analytics')) : EMPTY), + // SEMVER can switch to isSupported() when we only target v8 + // switchMap(() => firebase.analytics.isSupported().then(it => it, () => false)), // TODO server-side investigate use of the Universal Analytics API - switchMap(supported => supported ? of(undefined) : EMPTY), + // switchMap(supported => supported ? of(undefined) : EMPTY), map(() => { return ɵfetchInstance(`analytics`, 'AngularFireAnalytics', app, () => { const analytics = app.analytics(); diff --git a/src/auth-guard/auth-guard.spec.ts b/src/auth-guard/auth-guard.spec.ts index 7c3ed2c45..283f3c48b 100644 --- a/src/auth-guard/auth-guard.spec.ts +++ b/src/auth-guard/auth-guard.spec.ts @@ -1,7 +1,7 @@ import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FirebaseApp } from '@angular/fire'; import { COMMON_CONFIG } from '../test-config'; -import { AngularFireAuthGuard, AngularFireAuthGuardModule } from './public_api'; +import { AngularFireAuthGuard, AngularFireAuthGuardModule } from '@angular/fire/auth-guard'; import { Router, RouterModule } from '@angular/router'; import { APP_BASE_HREF } from '@angular/common'; import { rando } from '../firestore/utils.spec'; diff --git a/src/auth/auth.spec.ts b/src/auth/auth.spec.ts index 802076693..3d7be7849 100644 --- a/src/auth/auth.spec.ts +++ b/src/auth/auth.spec.ts @@ -2,7 +2,7 @@ import firebase from 'firebase/app'; import { Observable, Subject } from 'rxjs'; import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire'; -import { AngularFireAuth, AngularFireAuthModule } from './public_api'; +import { AngularFireAuth, AngularFireAuthModule } from '@angular/fire/auth'; import { COMMON_CONFIG } from '../test-config'; import 'firebase/auth'; import { rando } from '../firestore/utils.spec'; diff --git a/src/core/angularfire2.spec.ts b/src/core/angularfire2.spec.ts index 79cfdffe8..5062a411e 100644 --- a/src/core/angularfire2.spec.ts +++ b/src/core/angularfire2.spec.ts @@ -1,11 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { CompilerFactory, NgModule, NgZone, PlatformRef } from '@angular/core'; -import { AngularFireModule, FirebaseApp } from './public_api'; +import { AngularFireModule, FirebaseApp, ɵAngularFireSchedulers, ɵkeepUnstableUntilFirstFactory, ɵZoneScheduler } from '@angular/fire'; import { Observable, of, Subject } from 'rxjs'; import { COMMON_CONFIG } from '../test-config'; import { BrowserModule } from '@angular/platform-browser'; import firebase from 'firebase/app'; -import { ɵAngularFireSchedulers, ɵkeepUnstableUntilFirstFactory, ɵZoneScheduler } from './angularfire2'; import { tap } from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { rando } from '../firestore/utils.spec'; diff --git a/src/database/database.spec.ts b/src/database/database.spec.ts index 3ec1c7ea9..6ffaa23f6 100644 --- a/src/database/database.spec.ts +++ b/src/database/database.spec.ts @@ -1,5 +1,5 @@ import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire'; -import { AngularFireDatabase, AngularFireDatabaseModule, URL } from './public_api'; +import { AngularFireDatabase, AngularFireDatabaseModule, URL } from '@angular/fire/database'; import { TestBed } from '@angular/core/testing'; import { COMMON_CONFIG } from '../test-config'; import { NgZone } from '@angular/core'; diff --git a/src/database/list/audit-trail.spec.ts b/src/database/list/audit-trail.spec.ts index c866417a5..0e488da0e 100644 --- a/src/database/list/audit-trail.spec.ts +++ b/src/database/list/audit-trail.spec.ts @@ -1,16 +1,16 @@ -import { DatabaseReference } from '../interfaces'; import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFireDatabase, AngularFireDatabaseModule, auditTrail, ChildEvent, URL } from '../public_api'; +import { AngularFireDatabase, AngularFireDatabaseModule, auditTrail, ChildEvent, URL } from '@angular/fire/database'; import { TestBed } from '@angular/core/testing'; import { COMMON_CONFIG } from '../../test-config'; import { skip } from 'rxjs/operators'; import 'firebase/database'; +import firebase from 'firebase/app'; import { rando } from '../../firestore/utils.spec'; describe('auditTrail', () => { let app: FirebaseApp; let db: AngularFireDatabase; - let createRef: (path: string) => DatabaseReference; + let createRef: (path: string) => firebase.database.Reference; let batch = {}; const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ({ key: i.toString(), ...item })); Object.keys(items).forEach((key, i) => { diff --git a/src/database/list/snapshot-changes.spec.ts b/src/database/list/snapshot-changes.spec.ts index 5dfce960e..0d06e3354 100644 --- a/src/database/list/snapshot-changes.spec.ts +++ b/src/database/list/snapshot-changes.spec.ts @@ -1,6 +1,6 @@ import firebase from 'firebase/app'; import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, snapshotChanges, URL } from '../public_api'; +import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, snapshotChanges, URL } from '@angular/fire/database'; import { TestBed } from '@angular/core/testing'; import { COMMON_CONFIG } from '../../test-config'; import { BehaviorSubject } from 'rxjs'; diff --git a/src/database/list/state-changes.spec.ts b/src/database/list/state-changes.spec.ts index bbb5a9e76..34c2be17e 100644 --- a/src/database/list/state-changes.spec.ts +++ b/src/database/list/state-changes.spec.ts @@ -1,6 +1,6 @@ import firebase from 'firebase/app'; import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, stateChanges, URL } from '../public_api'; +import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, stateChanges, URL } from '@angular/fire/database'; import { TestBed } from '@angular/core/testing'; import { COMMON_CONFIG } from '../../test-config'; import { skip } from 'rxjs/operators'; diff --git a/src/database/observable/fromRef.spec.ts b/src/database/observable/fromRef.spec.ts index e7a1f966e..7bb5086f2 100644 --- a/src/database/observable/fromRef.spec.ts +++ b/src/database/observable/fromRef.spec.ts @@ -1,16 +1,16 @@ -import { DatabaseReference } from '../interfaces'; import { AngularFireModule, FirebaseApp, ɵZoneScheduler } from '@angular/fire'; -import { AngularFireDatabase, AngularFireDatabaseModule, fromRef } from '../public_api'; +import { AngularFireDatabase, AngularFireDatabaseModule, fromRef } from '@angular/fire/database'; import { TestBed } from '@angular/core/testing'; import { COMMON_CONFIG } from '../../test-config'; import { take } from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { rando } from '../../firestore/utils.spec'; +import firebase from 'firebase/app'; describe('fromRef', () => { let app: FirebaseApp; let db: AngularFireDatabase; - let ref: (path: string) => DatabaseReference; + let ref: (path: string) => firebase.database.Reference; let batch = {}; const items = [{ name: 'one' }, { name: 'two' }, { name: 'three' }].map(item => ({ key: rando(), ...item })); Object.keys(items).forEach((key) => { diff --git a/src/firestore/collection-group/collection-group.spec.ts b/src/firestore/collection-group/collection-group.spec.ts index 43d281372..74ede55ca 100644 --- a/src/firestore/collection-group/collection-group.spec.ts +++ b/src/firestore/collection-group/collection-group.spec.ts @@ -1,6 +1,5 @@ import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFirestore, AngularFirestoreCollectionGroup, AngularFirestoreModule, SETTINGS } from '../public_api'; -import { QueryGroupFn, Query } from '../interfaces'; +import { QueryGroupFn, Query , AngularFirestore, AngularFirestoreCollectionGroup, AngularFirestoreModule, SETTINGS } from '@angular/fire/firestore'; import { BehaviorSubject } from 'rxjs'; import { skip, switchMap, take } from 'rxjs/operators'; import { TestBed } from '@angular/core/testing'; diff --git a/src/firestore/collection/collection.spec.ts b/src/firestore/collection/collection.spec.ts index 3183b64a7..21071ae38 100644 --- a/src/firestore/collection/collection.spec.ts +++ b/src/firestore/collection/collection.spec.ts @@ -1,8 +1,5 @@ import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFirestore, SETTINGS } from '../firestore'; -import { AngularFirestoreModule } from '../firestore.module'; -import { AngularFirestoreCollection } from './collection'; -import { QueryFn, CollectionReference } from '../interfaces'; +import { AngularFirestore, SETTINGS, AngularFirestoreModule, AngularFirestoreCollection, QueryFn, CollectionReference } from '@angular/fire/firestore'; import { BehaviorSubject } from 'rxjs'; import { skip, switchMap, take } from 'rxjs/operators'; import 'firebase/firestore'; diff --git a/src/firestore/document/document.spec.ts b/src/firestore/document/document.spec.ts index 8ca15024c..9b5d93dcc 100644 --- a/src/firestore/document/document.spec.ts +++ b/src/firestore/document/document.spec.ts @@ -1,9 +1,5 @@ import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFirestore, SETTINGS } from '../firestore'; -import { AngularFirestoreModule } from '../firestore.module'; -import { Subscription } from 'rxjs'; -import { AngularFirestoreDocument } from './document'; -import { DocumentReference } from '../interfaces'; +import { AngularFirestore, SETTINGS, AngularFirestoreModule, AngularFirestoreDocument, DocumentReference } from '@angular/fire/firestore'; import { take } from 'rxjs/operators'; import { TestBed } from '@angular/core/testing'; diff --git a/src/firestore/firestore.spec.ts b/src/firestore/firestore.spec.ts index be957cd4b..68eb9f3a2 100644 --- a/src/firestore/firestore.spec.ts +++ b/src/firestore/firestore.spec.ts @@ -1,8 +1,5 @@ import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire'; -import { AngularFirestore, SETTINGS } from './firestore'; -import { AngularFirestoreModule } from './firestore.module'; -import { AngularFirestoreDocument } from './document/document'; -import { AngularFirestoreCollection } from './collection/collection'; +import { AngularFirestore, SETTINGS, AngularFirestoreModule, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore'; import { TestBed } from '@angular/core/testing'; import { COMMON_CONFIG } from '../test-config'; diff --git a/src/firestore/utils.spec.ts b/src/firestore/utils.spec.ts index f04604507..28b23f694 100644 --- a/src/firestore/utils.spec.ts +++ b/src/firestore/utils.spec.ts @@ -1,5 +1,5 @@ import firebase from 'firebase/app'; -import { AngularFirestoreCollection } from './collection/collection'; +import { AngularFirestoreCollection } from '@angular/fire/firestore'; export interface Stock { name: string; diff --git a/src/functions/functions.spec.ts b/src/functions/functions.spec.ts index f316f6ddf..56920ef67 100644 --- a/src/functions/functions.spec.ts +++ b/src/functions/functions.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire'; -import { AngularFireFunctions, AngularFireFunctionsModule, ORIGIN, REGION } from './public_api'; +import { AngularFireFunctions, AngularFireFunctionsModule, ORIGIN, REGION } from '@angular/fire/functions'; import { COMMON_CONFIG } from '../test-config'; import 'firebase/functions'; import { rando } from '../firestore/utils.spec'; diff --git a/src/messaging/messaging.spec.ts b/src/messaging/messaging.spec.ts index 8ff1fdc72..e72404e93 100644 --- a/src/messaging/messaging.spec.ts +++ b/src/messaging/messaging.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire'; -import { AngularFireMessaging, AngularFireMessagingModule } from './public_api'; +import { AngularFireMessaging, AngularFireMessagingModule } from '@angular/fire/messaging'; import { COMMON_CONFIG } from '../test-config'; import { rando } from '../firestore/utils.spec'; diff --git a/src/performance/performance.spec.ts b/src/performance/performance.spec.ts index c07832f3e..14bde92dd 100644 --- a/src/performance/performance.spec.ts +++ b/src/performance/performance.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FirebaseApp } from '@angular/fire'; -import { AngularFirePerformance, AngularFirePerformanceModule } from './public_api'; +import { AngularFirePerformance, AngularFirePerformanceModule } from '@angular/fire/performance'; import { COMMON_CONFIG } from '../test-config'; import { rando } from '../firestore/utils.spec'; diff --git a/src/remote-config/remote-config.spec.ts b/src/remote-config/remote-config.spec.ts index aa3a87924..f83c84eb6 100644 --- a/src/remote-config/remote-config.spec.ts +++ b/src/remote-config/remote-config.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire'; -import { AngularFireRemoteConfig, AngularFireRemoteConfigModule, DEFAULTS, SETTINGS } from './public_api'; +import { AngularFireRemoteConfig, AngularFireRemoteConfigModule, DEFAULTS, SETTINGS } from '@angular/fire/remote-config'; import { COMMON_CONFIG } from '../test-config'; import { rando } from '../firestore/utils.spec'; diff --git a/src/storage/storage.spec.ts b/src/storage/storage.spec.ts index 2f11fde08..045077cba 100644 --- a/src/storage/storage.spec.ts +++ b/src/storage/storage.spec.ts @@ -1,11 +1,10 @@ -import { forkJoin, from } from 'rxjs'; +import { forkJoin } from 'rxjs'; import { mergeMap, tap } from 'rxjs/operators'; import { TestBed } from '@angular/core/testing'; import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire'; -import { AngularFireStorage, AngularFireStorageModule, AngularFireUploadTask, BUCKET } from './public_api'; +import { AngularFireStorage, AngularFireStorageModule, AngularFireUploadTask, BUCKET } from '@angular/fire/storage'; import { COMMON_CONFIG } from '../test-config'; import { rando } from '../firestore/utils.spec'; -import { GetDownloadURLPipe } from './pipes/storageUrl.pipe'; import { ChangeDetectorRef } from '@angular/core'; import 'firebase/storage'; @@ -63,7 +62,7 @@ describe('AngularFireStorage', () => { it('should upload and delete a file', (done) => { const data = { angular: 'fire' }; const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' }); - const ref = afStorage.ref('af.json'); + const ref = afStorage.ref(rando()); const task = ref.put(blob); task.snapshotChanges() .subscribe( @@ -79,7 +78,7 @@ describe('AngularFireStorage', () => { it('should upload a file and observe the download url', (done) => { const data = { angular: 'fire' }; const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' }); - const ref = afStorage.ref('af.json'); + const ref = afStorage.ref(rando()); ref.put(blob).then(() => { const url$ = ref.getDownloadURL(); url$.subscribe( @@ -97,7 +96,7 @@ describe('AngularFireStorage', () => { it('should resolve the task as a promise', (done) => { const data = { angular: 'promise' }; const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' }); - const ref = afStorage.ref('af.json'); + const ref = afStorage.ref(rando()); const task: AngularFireUploadTask = ref.put(blob); task.then(snap => { expect(snap).toBeDefined(); @@ -112,7 +111,7 @@ describe('AngularFireStorage', () => { it('it should upload, download, and delete', (done) => { const data = { angular: 'fire' }; const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' }); - const ref = afStorage.ref('af.json'); + const ref = afStorage.ref(rando()); const task = ref.put(blob); // Wait for the upload forkJoin([task.snapshotChanges()]) @@ -131,7 +130,7 @@ describe('AngularFireStorage', () => { it('should upload, get metadata, and delete', (done) => { const data = { angular: 'fire' }; const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' }); - const ref = afStorage.ref('af.json'); + const ref = afStorage.ref(rando()); const task = ref.put(blob, { customMetadata: { blah: 'blah' } }); // Wait for the upload forkJoin([task.snapshotChanges()]) @@ -208,7 +207,8 @@ describe('AngularFireStorage w/options', () => { it('it should upload, download, and delete', (done) => { const data = { angular: 'fire' }; const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' }); - const ref = afStorage.ref('af.json'); + const name = rando(); + const ref = afStorage.ref(name); const task = ref.put(blob); // Wait for the upload forkJoin([task.snapshotChanges()]) @@ -216,7 +216,7 @@ describe('AngularFireStorage w/options', () => { // get the url download mergeMap(() => ref.getDownloadURL()), // assert the URL - tap(url => expect(url).toMatch(new RegExp(`https:\\/\\/firebasestorage\\.googleapis\\.com\\/v0\\/b\\/${storageBucket}\\/o\\/af\\.json`))), + tap(url => expect(url).toMatch(new RegExp(`https:\\/\\/firebasestorage\\.googleapis\\.com\\/v0\\/b\\/${storageBucket}\\/o\\/${name}`))), // Delete the file mergeMap(() => ref.delete()) ) diff --git a/tools/build.sh b/tools/build.sh index 5d7a559e9..d22e06666 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -1,11 +1,26 @@ -yarn +SHORT_SHA=$(git rev-parse --short $GITHUB_SHA) +TAG_TEST="^refs/tags/.+$" +LATEST_TEST="^[^-]*$" -if test $TAG_NAME; then - export VERSION=$TAG_NAME +if [[ $GITHUB_REF =~ $TAG_TEST ]]; then + OVERRIDE_VERSION=${GITHUB_REF/refs\/tags\//} + if [[ $OVERRIDE_VERSION =~ $LATEST_TEST ]]; then + NPM_TAG=latest + else + NPM_TAG=next + fi; else - export VERSION=$(npm version | sed -n "s/. '@angular\/fire': '\(.*\)',/\1/p")-canary.$SHORT_SHA -fi + OVERRIDE_VERSION=$(node -e "console.log(require('./package.json').version)")-canary.$SHORT_SHA + NPM_TAG=canary +fi; -echo $VERSION && -npm --no-git-tag-version -f version $VERSION --allow-same-version && +npm --no-git-tag-version --allow-same-version -f version $OVERRIDE_VERSION yarn build +TARBALL=$(npm pack ./dist/packages-dist | tail -n 1) +cp $TARBALL angularfire.tgz + +echo "npm publish \$(dirname \"\$0\")/angularfire.tgz --tag $NPM_TAG" > ./publish.sh +chmod +x ./publish.sh + +echo "tar -xzvf \$(dirname \"\$0\")/angularfire.tgz && rsync -a package/ ./dist/packages-dist/" > ./unpack.sh +chmod +x ./unpack.sh diff --git a/tools/build.ts b/tools/build.ts index b7cf5e0d0..72b6f105e 100644 --- a/tools/build.ts +++ b/tools/build.ts @@ -182,13 +182,9 @@ async function buildDocs() { return writeFile(`./api-${root.version}.json`, JSON.stringify(afdoc, null, 2)); } -function packLibrary() { - return spawnPromise('npm', ['pack', './dist/packages-dist']); -} - Promise.all([ buildDocs(), - buildLibrary().then(packLibrary) + buildLibrary() ]).then(measureLibrary).then(stats => console.log(` Package Size Gzipped diff --git a/tsconfig.base.json b/tsconfig.base.json index f60094014..ff4b7cac2 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -33,7 +33,7 @@ "@angular/fire/messaging": ["dist/packages-dist/messaging"], "@angular/fire/performance": ["dist/packages-dist/performance"], "@angular/fire/remote-config": ["dist/packages-dist/remote-config"], - "@angular/fire/storage": ["dist/packages-dist/storage"] + "@angular/fire/storage": ["dist/packages-dist/storage"], } } }