Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useEmulator() to Storage #4346

Merged
merged 15 commits into from
Apr 7, 2021
Merged

Add useEmulator() to Storage #4346

merged 15 commits into from
Apr 7, 2021

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Jan 26, 2021

Add storage().useEmulator() to current storage package and useStorageEmulator() to storage-exp.

Wait for emulator to be available before merging.

@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2021

🦋 Changeset detected

Latest commit: ed28cf6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
firebase Minor
@firebase/storage Minor
@firebase/storage-types Minor
@firebase/rules-unit-testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jan 26, 2021

Size Analysis Report

Affected Products

No changes between base commit (f24d896) and head commit (08f6a65).

@hsubox76 hsubox76 changed the title Ch storage emulator Add useEmulator() to Storage Jan 26, 2021
packages/storage/src/service.ts Outdated Show resolved Hide resolved
packages/storage/src/service.ts Outdated Show resolved Hide resolved
.changeset/tricky-seahorses-look.md Outdated Show resolved Hide resolved
packages/storage/src/service.ts Outdated Show resolved Hide resolved
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 3, 2021

Binary Size Report

Affected SDKs

  • @firebase/analytics

    Type Base (014fc2f) Head (4a609d9) Diff
    main 24.5 kB 24.2 kB -294 B (-1.2%)
  • @firebase/app

    Type Base (014fc2f) Head (4a609d9) Diff
    main 10.6 kB 9.93 kB -647 B (-6.1%)
    react-native 10.3 kB 9.64 kB -639 B (-6.2%)
  • @firebase/component

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 5.33 kB 5.37 kB +44 B (+0.8%)
    main 6.05 kB 5.69 kB -355 B (-5.9%)
    module 5.33 kB 5.37 kB +44 B (+0.8%)
  • @firebase/database

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 277 kB 275 kB -1.96 kB (-0.7%)
    esm2017 245 kB 248 kB +2.73 kB (+1.1%)
    main 280 kB 277 kB -2.20 kB (-0.8%)
    module 277 kB 275 kB -1.96 kB (-0.7%)
  • @firebase/database-exp

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 278 kB 272 kB -5.84 kB (-2.1%)
    esm2017 243 kB 245 kB +1.85 kB (+0.8%)
    main 279 kB 273 kB -6.09 kB (-2.2%)
    module 278 kB 272 kB -5.84 kB (-2.1%)
  • @firebase/firestore

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 259 kB 259 kB +34 B (+0.0%)
    esm2017 202 kB 202 kB -17 B (-0.0%)
    main 531 kB 530 kB -407 B (-0.1%)
    module 259 kB 259 kB +34 B (+0.0%)
    react-native 202 kB 202 kB -17 B (-0.0%)
  • @firebase/firestore-exp

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 199 kB 199 kB -68 B (-0.0%)
    main 505 kB 505 kB -311 B (-0.1%)
    module 199 kB 199 kB -68 B (-0.0%)
    react-native 200 kB 200 kB -68 B (-0.0%)
  • @firebase/firestore-lite

    Type Base (014fc2f) Head (4a609d9) Diff
    main 144 kB 143 kB -253 B (-0.2%)
  • @firebase/firestore/bundle

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 266 kB 266 kB +73 B (+0.0%)
    esm2017 155 kB 155 kB +22 B (+0.0%)
    main 527 kB 526 kB -432 B (-0.1%)
    module 266 kB 266 kB +73 B (+0.0%)
    react-native 155 kB 155 kB +22 B (+0.0%)
  • @firebase/firestore/memory

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 196 kB 196 kB -34 B (-0.0%)
    esm2017 152 kB 152 kB -17 B (-0.0%)
    main 324 kB 324 kB -475 B (-0.1%)
    module 196 kB 196 kB -34 B (-0.0%)
    react-native 152 kB 152 kB -17 B (-0.0%)
  • @firebase/firestore/memory-bundle

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 205 kB 205 kB +5 B (+0.0%)
    esm2017 155 kB 155 kB +22 B (+0.0%)
    main 321 kB 321 kB -513 B (-0.2%)
    module 205 kB 205 kB +5 B (+0.0%)
    react-native 155 kB 155 kB +22 B (+0.0%)
  • @firebase/installations

    Type Base (014fc2f) Head (4a609d9) Diff
    main 22.7 kB 22.2 kB -464 B (-2.0%)
    module 21.6 kB 21.6 kB +28 B (+0.1%)
  • @firebase/logger

    Type Base (014fc2f) Head (4a609d9) Diff
    main 5.75 kB 5.38 kB -368 B (-6.4%)
    module 4.83 kB 4.65 kB -179 B (-3.7%)
  • @firebase/messaging

    Type Base (014fc2f) Head (4a609d9) Diff
    main 34.9 kB 34.9 kB +22 B (+0.1%)
    module 34.4 kB 34.4 kB +28 B (+0.1%)
  • @firebase/performance

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 27.6 kB 27.7 kB +50 B (+0.2%)
    main 28.5 kB 28.0 kB -425 B (-1.5%)
    module 27.6 kB 27.7 kB +50 B (+0.2%)
  • @firebase/remote-config

    Type Base (014fc2f) Head (4a609d9) Diff
    main 23.4 kB 22.9 kB -490 B (-2.1%)
  • @firebase/rules-unit-testing

    Type Base (014fc2f) Head (4a609d9) Diff
    main 12.2 kB 12.5 kB +302 B (+2.5%)
  • @firebase/storage

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 60.2 kB 61.1 kB +896 B (+1.5%)
    esm2017 51.9 kB 52.7 kB +765 B (+1.5%)
    main 61.2 kB 61.6 kB +387 B (+0.6%)
    module 60.2 kB 61.1 kB +896 B (+1.5%)
  • @firebase/storage/exp

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 49.2 kB 50.0 kB +807 B (+1.6%)
    main 49.9 kB 50.9 kB +926 B (+1.9%)
    module 49.2 kB 50.0 kB +807 B (+1.6%)
  • @firebase/util

    Type Base (014fc2f) Head (4a609d9) Diff
    browser 20.2 kB 20.5 kB +285 B (+1.4%)
    esm2017 19.0 kB 19.2 kB +275 B (+1.4%)
    main 22.1 kB 24.8 kB +2.63 kB (+11.9%)
    module 20.2 kB 20.5 kB +285 B (+1.4%)
  • @firebase/webchannel-wrapper

    Type Base (014fc2f) Head (4a609d9) Diff
    main 47.2 kB 46.9 kB -247 B (-0.5%)
  • firebase

    Click to show 14 binary size changes.
    Type Base (014fc2f) Head (4a609d9) Diff
    firebase-analytics.js 35.7 kB 35.6 kB -45 B (-0.1%)
    firebase-app.js 19.9 kB 19.9 kB -35 B (-0.2%)
    firebase-auth.js 177 kB 177 kB +20 B (+0.0%)
    firebase-database.js 189 kB 178 kB -11.5 kB (-6.1%)
    firebase-firestore.js 304 kB 303 kB -120 B (-0.0%)
    firebase-firestore.memory.js 243 kB 243 kB -144 B (-0.1%)
    firebase-functions.js 9.99 kB 10.1 kB +141 B (+1.4%)
    firebase-installations.js 19.0 kB 19.1 kB +147 B (+0.8%)
    firebase-messaging.js 40.7 kB 40.9 kB +251 B (+0.6%)
    firebase-performance-standalone.js 48.0 kB 47.8 kB -199 B (-0.4%)
    firebase-performance.js 38.4 kB 38.2 kB -210 B (-0.5%)
    firebase-remote-config.js 36.8 kB 36.8 kB -42 B (-0.1%)
    firebase-storage.js 39.8 kB 40.4 kB +610 B (+1.5%)
    firebase.js 851 kB 840 kB -11.1 kB (-1.3%)

Test Logs

@hsubox76 hsubox76 changed the title Add useEmulator() to Storage DO NOT MERGE: Add useEmulator() to Storage Feb 3, 2021
export function makeUrl(urlPart: string): string {
return `https://${DEFAULT_HOST}/v0${urlPart}`;
export function makeUrl(urlPart: string, host: string): string {
const protocolMatch = host.match(/^(\w+):\/\/.+/);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this because emulator uses http when production use defaults to https. Seems cleaner to let the host string contain a protocol or not, and if so, parse it in this one function, than to store protocol as a separate property on StorageService and get it everywhere service.host is also used.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2021

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

Copy link

@NothingEverHappens NothingEverHappens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this safe to merge now?

.changeset/tricky-seahorses-look.md Show resolved Hide resolved
export function makeUrl(urlPart: string): string {
return `https://${DEFAULT_HOST}/v0${urlPart}`;
export function makeUrl(urlPart: string, host: string): string {
const protocolMatch = host.match(/^(\w+):\/\/.+/);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit/optional, I think using replace with callback would save some lines and be more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to easily set up a regex that would call the callback if the protocol wasn't there so I left it alone for now. We can always optimize any time so let me know if you have a snippet you want to put in.

@hsubox76 hsubox76 changed the title DO NOT MERGE: Add useEmulator() to Storage Add useEmulator() to Storage Apr 7, 2021
@hsubox76 hsubox76 merged commit 5ae7365 into master Apr 7, 2021
@hsubox76 hsubox76 deleted the ch-storage-emulator branch April 7, 2021 19:18
@vbeffa
Copy link

vbeffa commented Apr 8, 2021

@hsubox76 is this available for use yet? From the docs it seems we need to download/reference https://www.gstatic.com/firebasejs/${JSCORE_VERSION}/firebase.js but I don't see any new tags on this project.

@hsubox76
Copy link
Contributor Author

hsubox76 commented Apr 8, 2021

It's merged and should go out in the release next Thursday.

@vbeffa
Copy link

vbeffa commented Apr 8, 2021

Thanks!

@google-oss-bot google-oss-bot mentioned this pull request Apr 12, 2021
@jmcdl
Copy link

jmcdl commented Apr 14, 2021

Is this feature actually ready for firebase developers? I ask because as of v9.10.0 the firebase-tools CLI still does not include storage in the list of emulators that can be initialised.

@vbeffa
Copy link

vbeffa commented Apr 14, 2021

@jmcdl see firebase/firebase-tools#3256.

@jmcdl
Copy link

jmcdl commented Apr 14, 2021

@vbeffa thank you!

@firebase firebase locked and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants