angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.64k stars 2.2k forks source link

feat(ng-deploy): add option for buildTarget #2063

Closed FrozenPandaz closed 3 years ago

FrozenPandaz commented 5 years ago

Current Behavior

Right now, the @angular/fire:deploy builder infers the build target to be targetProject:build:production. This makes it impossible to deploy targetProject:build:staging which may have different environment variables etc.

Expected Behavior

Option 1

Add an option for buildTarget so that the full targetProject:build:staging can be passed in and scheduled.

Personally, since schematics can generate the config via ng add or ng generate, I would opt for this one.

Option 2

Add an option for configuration so that staging can be passed in and targetProject:build:staging can be scheduled.

More Thoughts

Inferring the build target is okay, but I would rather not schedule anything at all if I leave it blank so a user can build separately ahead of time in the case Firebase Functions are someday supported. :)

Caveat

This configuration information might be important for knowing which Firebase project/ target to deploy to. This might be better done in a separate option.

FrozenPandaz commented 5 years ago

cc @kirjs + @mgechev

mgechev commented 5 years ago

This makes sense. Maybe call the option environment?

The advanced use case in the More Thoughts section we can plan in the future.

JohannesHoppe commented 4 years ago

I have started a discussion here about this topic. It would be great if we could find a common approach so that the expected behaviour and usability of the different builders are consistent.

Currently, there could be a majority for the following options:

mgechev commented 4 years ago

--configuration sounds good. I also find it coherent with the other CLI commands.

--no-build makes sense as well for advanced use cases.

alan-agius4 commented 4 years ago

In the CLI, this same option is called browserTarget / serverTarget.

https://github.com/angular/angular-cli/blob/60746edc4cc6369c0fb3f6b69a5764b03e4379da/packages/angular_devkit/build_angular/src/app-shell/schema.json#L7-L16

configuration is misleading as it might be confused with configurations, I opt for buildTarget.

"deploy": {
    "builder": "@deploy:deploy-builder",
    "options": {
        "buildTarget": "project:browser"
    },
    "configurations": {
        "staging": {
            "buildTarget": "project:browser:staging"
        }
    }
},

Example

ng deploy --configurations staging
wagnermaciel commented 4 years ago

@alan-agius4 safe to close this?

alan-agius4 commented 4 years ago

Looks like it was addressed by https://github.com/angular/angularfire/issues/2063.

So this can be closed.

Splaktar commented 4 years ago

When I do a deployment to staging, I need two things to happen

  1. Build my "staging" configuration in `projectname:build:staging"
  2. Deploy to my staging target in .firebaserc

PR https://github.com/angular/angularfire/issues/2063 only covers 1 as far as I can tell. Is there any solution for 2?

The deploy docs are out dated and low on details.

Splaktar commented 4 years ago

For now, it seems to always pick the first entry in the .firebaserc "targets": {} node. So you can swap those each time you want to change between production/staging.

But that's too fragile, so I'm just going to use something like the following and avoid ng deploy for now

"deploy": "npm run build:staging && firebase use staging && firebase deploy --only hosting",
"deploy:prod": "npm run build:prod && firebase use production && firebase deploy --only hosting",
george43g commented 4 years ago

Just a heads up - I submitted a PR to allow configuring the firebase project deploy target as well. These can be actual projects or aliases you set up via the CLI or .firebaserc. There's an issue preventing the use of multiple configurations at the moment, so ng deploy myApp --configuration production does not yet work.

george43g commented 4 years ago

When I do a deployment to staging, I need two things to happen

  1. Build my "staging" configuration in `projectname:build:staging"
  2. Deploy to my staging target in .firebaserc

PR #2063 only covers 1 as far as I can tell. Is there any solution for 2?

The deploy docs are out dated and low on details.

And to finally make this possible, I've made a bug/feature request at the CLI end: https://github.com/angular/angular-cli/issues/17332

This is to enable using the --configuration=production flag, or any environment you wish, that will set the buildTarget and firebaseProject options respectively.

cfonger commented 3 years ago

Seems like this is now implemented? https://github.com/angular/angularfire/blob/c57cef4a0d08f7df43754a30c18d707d1806cbd0/src/schematics/deploy/schema.json#L7

jamesdaniels commented 3 years ago

More options dropped in 6.1.0-rc.1, we should have this covered now.