Skip to content

Code in schematics/deploy/builder.ts is preventing the usage of any non-default firebaseProject and firebaseHostingSite values #3077

Open
@itsdarja

Description

@itsdarja

Version info

Angular:
13.0.3

Firebase:
0.22.0

AngularFire:
7.2.0

Other (e.g. Ionic/Cordova, Node, browser, operating system):
Node:
v16.13.0

How to reproduce these conditions

Trying to accomplish working with multiple firebase projects for deployment as per instructions here: https://stackblitz.com/edit/angular-fire-start

Steps to set up and reproduce

When I try to set the different configurations for deploy command - for example:

 "deploy": {
     "builder": "@angular/fire:deploy",
      "options": {
          "prerender": false,
          "ssr": false,
          "browserTarget": "mypage:build:staging",
          "firebaseProject": "mypage-stg",
          "firebaseHostingSite": "mypage-stg"
      },
      "configurations": {
          "production": {
             "browserTarget": "mypage:build:production",
             "firebaseProject": "mypage-prod",
             "firebaseHostingSite": "mypage-prod"
          }
      }
}

And then run:
ng deploy --configuration="production"

This results with error:
An unhandled exception occurred: The Firebase Project specified by your angular.json or .firebaserc is in conflict

Debug output

An unhandled exception occurred: The Firebase Project specified by your angular.json or .firebaserc is in conflict

Looking at the text I identified the issues being the lines 25 and 33 in this file:
https://github.com/angular/angularfire/blob/master/src/schematics/deploy/builder.ts

Problematic code parts:

 if (!firebaseProject) {
    throw new Error('Cannot detirmine the Firebase Project from your angular.json or .firebaserc');
}
if (firebaseProject !== defaultFirebaseProject) {
    throw new Error('The Firebase Project specified by your angular.json or .firebaserc is in conflict');
}

and

const firebaseHostingSite = options.firebaseHostingSite || defulatFirebaseHostingSite;
if (!firebaseHostingSite) {
    throw new Error(`Cannot detirmine the Firebase Hosting Site from your angular.json or .firebaserc`);
}
if (firebaseHostingSite !== defulatFirebaseHostingSite) {
    throw new Error('The Firebase Hosting Site specified by your angular.json or .firebaserc is in conflict');
}

I can not make the sense out of this code.
Why would you prevent deploying any other value of the configuration other the default value?

Commenting out lines 25 and 33 results in the successful deployment of the desired configuration.

Expected behaviour

Being able to configure different firebase projects and hosting sites for the same project

Actual behaviour

Throwing errors when trying to use firebaseProject and firebaseHostingSite different from defaultFirebaseProject and defulatFirebaseHostingSite.

Edit: Duplicate of #3076 -> for some reason I thought that one was already closed

Activity

google-oss-bot

google-oss-bot commented on Nov 28, 2021

@google-oss-bot

This issue does not seem to follow the issue template. Make sure you provide all the required information.

YegorPavlenko

YegorPavlenko commented on Dec 28, 2021

@YegorPavlenko

Error in the https://github.com/angular/angularfire/blob/master/src/schematics/utils.ts l: 100 in the function projectFromRc(...)
wrong getting project value.

sidsaxena0

sidsaxena0 commented on Jun 21, 2022

@sidsaxena0

Is there any workaround to this, I am scratching my head for last two days over this issue.

davidecampello

davidecampello commented on Aug 24, 2022

@davidecampello

Hi, I'm having the same issue

gulands

gulands commented on Sep 25, 2022

@gulands

Any solution to this problem?

kkachniarz220

kkachniarz220 commented on Jan 16, 2023

@kkachniarz220

bump, any solutions?

HmFlashy

HmFlashy commented on May 18, 2023

@HmFlashy

Any solution to this?

aponski

aponski commented on May 18, 2023

@aponski

I'm also looking for the solution.

HmFlashy

HmFlashy commented on May 18, 2023

@HmFlashy

The only workaround found is to change by hand the .firebaserc and the firebase.json with the correct target

DieselBleifrei

DieselBleifrei commented on May 18, 2023

@DieselBleifrei

you will need to seperate the steps that are done automatically by ng deploy yourself. Meaning building of server/browser and deploying the firebase function.
In my case this was:

  1. building of the project
  2. copying the index.js file which is the base file for the function in the distfolder (you will have to create the file yourself though the content is nearly the same as the index.js file that would be created by ng deploy)
  3. running npm install inside the distfolder
  4. deploying the firebase function
self-assigned this
on Jun 23, 2023
pdela

pdela commented on Mar 7, 2024

@pdela

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Code in schematics/deploy/builder.ts is preventing the usage of any non-default firebaseProject and firebaseHostingSite values · Issue #3077 · angular/angularfire