Skip to content

feat(ng-deploy): add option to specify firebaseProject (#2281) (#2063) #2366

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/deploy/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,37 @@ We'll create the function and a `package.json` in your project output directory.
## Step 3: customization

To customize the deployment flow, you can use the configuration files you're already familiar with from `firebase-tools`. You can find more in the [firebase documentation](https://firebase.google.com/docs/hosting/full-config).

### Configuration Options

If you have multiple build targets and deploy targets, it is possible to specify them in your `angular.json` or `workspace.json`.

It is possible to use either your project name or project alias in `firebaseProject`. The setting provided here is equivalent to passing a project name or alias to `firebase deploy --project projectNameOrAlias`. The uppercase `-P` flag is also an alias for `--project` when using Firebase CLI.

The `buildTarget` simply points to an existing build configuration for your project. Most projects have a default configuration and a production configuration (commonly activated by using the `--prod` flag) but it is possible to specify as many build configurations as needed.

You may specify a `buildTarget` and `firebaseProject` in your `options` as follows:

```json
"deploy": {
"builder": "@angular/fire:deploy",
"options": {
"buildTarget": "projectName:build",
"firebaseProject": "developmentProject"
},
"configurations": {
"production": {
"buildTarget": "projectName:build:production",
"firebaseProject": "productionProject"
}
}
}
```

The above configuration specifies the following:

1. `ng deploy` will deploy the default project with default configuration.
2. `ng deploy projectName` will deploy the specified project with default configuration.
3. `ng deploy projectName --prod` or `ng deploy projectName --configuration='production'` will deploy `projectName` with production build settings to your production environment.

All of the options are optional. If you do not specify a `buildTarget`, it defaults to a production build (`projectName:build:production`). If you do not specify a `firebaseProject`, it defaults to the first matching deploy target found in your `.firebaserc` (where your projectName is the same as your Firebase deploy target name). The `configurations` section is also optional.
1 change: 1 addition & 0 deletions src/schematics/deploy/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export default async function deploy(

try {
await firebaseTools.use(firebaseProject, { project: firebaseProject });
context.logger.info(`🔥 Your configured Firebase project is '${firebaseProject}'`);
} catch (e) {
throw new Error(`Cannot select firebase project '${firebaseProject}'`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/schematics/deploy/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default createBuilder<any>(

const projectTargets = workspace.getProjectTargets(context.target.project);

const firebaseProject = getFirebaseProjectName(
const firebaseProject = options.firebaseProject || getFirebaseProjectName(
context.workspaceRoot,
context.target.project
);
Expand Down
4 changes: 4 additions & 0 deletions src/schematics/deploy/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"description": "Target to build.",
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
},
"firebaseProject": {
"type": "string",
"description": "The Firebase project name or project alias to use when deploying"
},
"preview": {
"type": "boolean",
"description": "Do not deploy the application, just set up the Firebase Function in the project output directory. Can be used for testing the Firebase Function with `firebase serve`."
Expand Down
1 change: 1 addition & 0 deletions src/schematics/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface FirebaseRc {

export interface DeployBuilderSchema {
buildTarget?: string;
firebaseProject?: string;
preview?: boolean;
universalBuildTarget?: string;
ssr?: boolean;
Expand Down