Skip to content

Commit

Permalink
Few things (#3472)
Browse files Browse the repository at this point in the history
* Bump firebase, add auth#revokeAccessToken
* Add development and production build/serve targets, default to development for emulators
* Region select only when universal or ssr
  • Loading branch information
jamesdaniels committed Dec 7, 2023
1 parent 99a1bb1 commit 6604db7
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 457 deletions.
592 changes: 160 additions & 432 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -55,10 +55,10 @@
"@angular/platform-browser-dynamic": "^17.0.0",
"@angular/router": "^17.0.0",
"@schematics/angular": "^17.0.0",
"firebase": "^10.0.0",
"firebase": "^10.7.0",
"firebase-admin": "^9.11.1",
"firebase-functions": "^3.6.0",
"firebase-tools": "^12.2.1",
"firebase-tools": "^13.0.0",
"fs-extra": "^8.0.1",
"fuzzy": "^0.1.3",
"husky": "^4.2.5",
Expand Down
2 changes: 2 additions & 0 deletions src/auth/firebase.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/package.json
Expand Up @@ -34,7 +34,7 @@
"firebase-tools": { "optional": true }
},
"dependencies": {
"firebase": "^10.5.0",
"firebase": "^10.7.0",
"rxfire": "^6.0.5",
"@angular-devkit/schematics": "^17.0.0",
"@schematics/angular": "^17.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/schematics/interfaces.ts
Expand Up @@ -41,7 +41,8 @@ export interface NgAddNormalizedOptions {
firebaseApp: FirebaseApp|undefined;
firebaseHostingSite: FirebaseHostingSite|undefined;
sdkConfig: Record<string, string>|undefined;
buildTarget: string|undefined;
buildTarget: [string,string]|undefined;
serveTarget: [string,string]|undefined;
ssrRegion: string|undefined;
}

Expand Down
20 changes: 12 additions & 8 deletions src/schematics/ng-add.jasmine.ts
Expand Up @@ -129,9 +129,10 @@ const initialAngularJson = `{
"version": 2
},
"configurations": {
"production": {}
"production": {},
"development": {}
},
"defaultConfiguration": "production"
"defaultConfiguration": "development"
}
}
},
Expand Down Expand Up @@ -192,9 +193,10 @@ const overwriteAngularJson = `{
"version": 2
},
"configurations": {
"production": {}
"production": {},
"development": {}
},
"defaultConfiguration": "production"
"defaultConfiguration": "development"
}
}
},
Expand Down Expand Up @@ -267,9 +269,10 @@ const projectAngularJson = `{
"version": 2
},
"configurations": {
"production": {}
"production": {},
"development": {}
},
"defaultConfiguration": "production"
"defaultConfiguration": "development"
}
}
},
Expand All @@ -288,9 +291,10 @@ const projectAngularJson = `{
"version": 2
},
"configurations": {
"production": {}
"production": {},
"development": {}
},
"defaultConfiguration": "production"
"defaultConfiguration": "development"
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/schematics/setup/index.ts
Expand Up @@ -27,7 +27,8 @@ export interface SetupConfig extends DeployOptions {
firebaseApp?: FirebaseApp,
firebaseHostingSite?: FirebaseHostingSite,
sdkConfig?: Record<string, string>,
buildTarget?: string,
buildTarget?: [string, string],
serveTarget?: [string, string],
project?: string,
ssrRegion?: string,
}
Expand All @@ -51,6 +52,7 @@ export const setupProject =
firebaseHostingSite: config.firebaseHostingSite,
sdkConfig: config.sdkConfig,
buildTarget: config.buildTarget,
serveTarget: config.serveTarget,
ssrRegion: config.ssrRegion,
},
tree,
Expand Down Expand Up @@ -187,10 +189,15 @@ export const setupFirebase = (config: {
},
configurations: {
production: {
buildTarget: options.buildTarget,
buildTarget: options.buildTarget?.[0],
serveTarget: options.serveTarget?.[0],
},
development: {
buildTarget: options.buildTarget?.[1],
serveTarget: options.serveTarget?.[1],
}
},
defaultConfiguration: 'production',
defaultConfiguration: 'development',
};

tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));
Expand Down
26 changes: 16 additions & 10 deletions src/schematics/setup/prompts.ts
Expand Up @@ -4,7 +4,7 @@ import * as inquirer from 'inquirer';
import { shortSiteName } from '../common';
import { getFirebaseTools } from '../firebaseTools';
import { FEATURES, FirebaseApp, FirebaseHostingSite, FirebaseProject, PROJECT_TYPE, WorkspaceProject, featureOptions } from '../interfaces';
import { shortAppId } from '../utils';
import { isSSRApp, isUniversalApp, shortAppId } from '../utils';

// eslint-disable-next-line @typescript-eslint/no-var-requires
inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));
Expand Down Expand Up @@ -251,13 +251,19 @@ const ALLOWED_SSR_REGIONS = [
];

export const projectTypePrompt = async (project: WorkspaceProject, name: string) => {
const buildTarget = `${name}:build:${project.architect?.build?.defaultConfiguration || 'production'}`;
const { ssrRegion } = await inquirer.prompt({
type: 'list',
name: 'ssrRegion',
choices: ALLOWED_SSR_REGIONS,
message: 'In which region would you like to host server-side content?',
default: DEFAULT_REGION,
}) as { ssrRegion: string };
return { projectType: PROJECT_TYPE.WebFrameworks, ssrRegion, buildTarget };
const buildTarget = [`${name}:build:production`, `${name}:build:development`];
const serveTarget = isUniversalApp(project) ?
[`${name}:serve-ssr:production`, `${name}:serve-ssr:development`] :
[`${name}:serve:production`, `${name}:serve:development`];
if (isUniversalApp(project) || isSSRApp(project)) {
const { ssrRegion } = await inquirer.prompt({
type: 'list',
name: 'ssrRegion',
choices: ALLOWED_SSR_REGIONS,
message: 'In which region would you like to host server-side content?',
default: DEFAULT_REGION,
}) as { ssrRegion: string };
return { projectType: PROJECT_TYPE.WebFrameworks, ssrRegion, buildTarget, serveTarget };
}
return { projectType: PROJECT_TYPE.WebFrameworks, buildTarget, serveTarget };
};
4 changes: 4 additions & 0 deletions src/schematics/utils.ts
Expand Up @@ -14,6 +14,10 @@ export const isUniversalApp = (
project: WorkspaceProject
) => project.architect?.server;

export const isSSRApp = (
project: WorkspaceProject
) => !!project.architect?.build.options?.ssr;

export const hasPrerenderOption = (
project: WorkspaceProject
) => project.architect?.prerender;
Expand Down

0 comments on commit 6604db7

Please sign in to comment.