Skip to content

Commit 3a1b108

Browse files
mgechevjamesdaniels
authored andcommitted
refactor: update documentation & improve error messages (#2081)
1 parent 4292cdd commit 3a1b108

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

docs/deploy/getting-started.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ng add @angular/fire
1212

1313
*Note that the command above assumes you have global Angular CLI installed. To install Angular CLI globally run `npm i -g @angular/cli`.*
1414

15-
The command above will trigger the `@angular/fire` `ng-add` schematics. Once they install `@angular/fire`. If you are not authenticated, the schematics will open a browser which will guide you through the authentication flow. Once you authenticate, you'll see a prompt to select a Firebase hosting project.
15+
The command above will trigger the `@angular/fire` `ng-add` schematics. The schematics will open a web browser and guide you through the Firebase authentication flow (if you're not signed in already). After you authenticate, you'll see a prompt to select a Firebase hosting project.
1616

1717
The schematics will do the following:
1818

@@ -53,7 +53,7 @@ ng add @angular/fire --project=[PROJECT_NAME]
5353
As the second step, to deploy your project run:
5454

5555
```
56-
ng run [PROJECT_NAME]:deploy
56+
ng run [ANGULAR_PROJECT_NAME]:deploy
5757
```
5858

5959
The command above will trigger:

src/schematics/ng-add.ts

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { SchematicsException, Tree } from "@angular-devkit/schematics";
2-
import { FirebaseJSON, FirebaseRc } from "./interfaces";
3-
import { experimental, JsonParseMode, parseJson } from "@angular-devkit/core";
4-
import { from } from "rxjs";
5-
import { map, switchMap } from "rxjs/operators";
6-
import { Project } from "./interfaces";
7-
import { listProjects, projectPrompt } from "./utils";
1+
import { SchematicsException, Tree } from '@angular-devkit/schematics';
2+
import { FirebaseJSON, FirebaseRc } from './interfaces';
3+
import { experimental, JsonParseMode, parseJson } from '@angular-devkit/core';
4+
import { from } from 'rxjs';
5+
import { map, switchMap } from 'rxjs/operators';
6+
import { Project } from './interfaces';
7+
import { listProjects, projectPrompt } from './utils';
88

99
const stringifyFormatted = (obj: any) => JSON.stringify(obj, null, 2);
1010

@@ -24,11 +24,11 @@ function generateHostingConfig(project: string, dist: string) {
2424
return {
2525
target: project,
2626
public: dist,
27-
ignore: ["firebase.json", "**/.*", "**/node_modules/**"],
27+
ignore: ['firebase.json', '**/.*', '**/node_modules/**'],
2828
rewrites: [
2929
{
30-
source: "**",
31-
destination: "/index.html"
30+
source: '**',
31+
destination: '/index.html'
3232
}
3333
]
3434
};
@@ -106,7 +106,7 @@ const overwriteIfExists = (tree: Tree, path: string, content: string) => {
106106
function getWorkspace(
107107
host: Tree
108108
): { path: string; workspace: experimental.workspace.WorkspaceSchema } {
109-
const possibleFiles = ["/angular.json", "/.angular.json"];
109+
const possibleFiles = ['/angular.json', '/.angular.json'];
110110
const path = possibleFiles.filter(path => host.exists(path))[0];
111111

112112
const configBuffer = host.read(path);
@@ -156,19 +156,21 @@ export function ngAdd(tree: Tree, options: NgAddOptions) {
156156
options.project = workspace.defaultProject;
157157
} else {
158158
throw new SchematicsException(
159-
"No project selected and no default project in the workspace"
159+
'No Angular project selected and no default project in the workspace'
160160
);
161161
}
162162
}
163163

164164
const project = workspace.projects[options.project];
165165
if (!project) {
166-
throw new SchematicsException("Project is not defined in this workspace");
166+
throw new SchematicsException(
167+
'The specified Angular project is not defined in this workspace'
168+
);
167169
}
168170

169-
if (project.projectType !== "application") {
171+
if (project.projectType !== 'application') {
170172
throw new SchematicsException(
171-
`Deploy requires a project type of "application" in angular.json`
173+
`Deploy requires an Angular project type of "application" in angular.json`
172174
);
173175
}
174176

@@ -179,26 +181,26 @@ export function ngAdd(tree: Tree, options: NgAddOptions) {
179181
!project.architect.build.options.outputPath
180182
) {
181183
throw new SchematicsException(
182-
`Cannot read the output path (architect.build.options.outputPath) of project "${
184+
`Cannot read the output path (architect.build.options.outputPath) of the Angular project "${
183185
options.project
184186
}" in angular.json`
185187
);
186188
}
187189

188190
const outputPath = project.architect.build.options.outputPath;
189191

190-
project.architect["deploy"] = {
191-
builder: "@angular/fire:deploy",
192+
project.architect['deploy'] = {
193+
builder: '@angular/fire:deploy',
192194
options: {}
193195
};
194196

195197
tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));
196-
generateFirebaseJson(tree, "firebase.json", options.project, outputPath);
198+
generateFirebaseJson(tree, 'firebase.json', options.project!, outputPath);
197199
generateFirebaseRc(
198200
tree,
199-
".firebaserc",
201+
'.firebaserc',
200202
options.firebaseProject,
201-
options.project
203+
options.project!
202204
);
203205
return tree;
204206
}

0 commit comments

Comments
 (0)