Skip to content
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

Few things #3472

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
592 changes: 160 additions & 432 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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