Skip to content

Commit 7a2402a

Browse files
Allow ng16 peer (#3361)
* Allow peer of ng 16, firebase-tools 12 * Cleanup ng-add to use web frameworks * Cleanup tests --- Co-authored-by: robertIsaac <[email protected]>
1 parent 1ec218a commit 7a2402a

27 files changed

+5391
-6771
lines changed

.github/workflows/codeql-analysis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
# Initializes the CodeQL tools for scanning.
4141
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@v1
42+
uses: github/codeql-action/init@v2
4343
with:
4444
languages: ${{ matrix.language }}
4545
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -50,7 +50,7 @@ jobs:
5050
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5151
# If this step fails, then you should remove it and run the build manually (see below)
5252
- name: Autobuild
53-
uses: github/codeql-action/autobuild@v1
53+
uses: github/codeql-action/autobuild@v2
5454

5555
# ℹ️ Command-line programs to run using the OS shell.
5656
# 📚 https://git.io/JvXDl
@@ -64,4 +64,4 @@ jobs:
6464
# make release
6565

6666
- name: Perform CodeQL Analysis
67-
uses: github/codeql-action/analyze@v1
67+
uses: github/codeql-action/analyze@v2

.github/workflows/test.yml

+76-208
Large diffs are not rendered by default.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ AngularFire doesn't follow Angular's versioning as Firebase also has breaking ch
6969

7070
| Angular | Firebase | AngularFire |
7171
| --------|----------|--------------|
72+
| 16 | 9 | ^7.6 |
7273
| 15 | 9 | ^7.5 |
7374
| 14 | 9 | ^7.4 |
7475
| 13 | 9 | ^7.2 |

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "@angular/fire",
3-
"version": "7.5.0",
3+
"version": "7.6.0",
44
"description": "The official Angular library for Firebase.",
55
"private": true,
66
"scripts": {
77
"test": "npm run build:jasmine && npm run test:node && npm run test:chrome-headless",
8-
"test:watch": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=true --browsers=Chrome\"",
9-
"test:chrome": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=Chrome\"",
10-
"test:firefox": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=Firefox\"",
11-
"test:safari": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=SafariNative\"",
12-
"test:chrome-headless": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=ChromeHeadless\"",
13-
"test:firefox-headless": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=FirefoxHeadless\"",
8+
"test:watch": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=true --browsers=Chrome\"",
9+
"test:chrome": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=Chrome\"",
10+
"test:firefox": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=Firefox\"",
11+
"test:safari": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=SafariNative\"",
12+
"test:chrome-headless": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=ChromeHeadless\"",
13+
"test:firefox-headless": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=FirefoxHeadless\"",
1414
"lint": "ng lint",
1515
"test:node": "node -r tsconfig-paths/register ./dist/out-tsc/jasmine/tools/jasmine.js --input-type=commonjs",
1616
"test:node-esm": "node -r tsconfig-paths/register ./dist/out-tsc/jasmine/tools/jasmine.mjs --input-type=commonjs",
@@ -57,7 +57,7 @@
5757
"firebase": "^9.8.2",
5858
"firebase-admin": "^9.11.1",
5959
"firebase-functions": "^3.6.0",
60-
"firebase-tools": "^9.0.0",
60+
"firebase-tools": "^12.2.1",
6161
"fs-extra": "^8.0.1",
6262
"fuzzy": "^0.1.3",
6363
"husky": "^4.2.5",

src/compat/firestore/collection-group/collection-group.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ describe('AngularFirestoreCollectionGroup', () => {
353353

354354
it('should be able to filter snapshotChanges() types - removed', done => {
355355
(async () => {
356+
356357
const ITEMS = 10;
357358
const { ref, stocks, names } = await collectionHarness(afs, ITEMS);
358359

src/messaging/messaging.spec.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ describe('Messaging', () => {
3535
messaging = TestBed.inject(Messaging);
3636
});
3737

38-
it('should be injectable', () => {
39-
expect(providedMessaging).toBeTruthy();
40-
expect(messaging).toEqual(providedMessaging);
38+
it('should be injectable', async (done) => {
39+
const supported = await isSupported();
40+
if (supported) {
41+
expect(providedMessaging).toBeTruthy();
42+
expect(messaging).toEqual(providedMessaging);
43+
} else {
44+
expect(providedMessaging).toBeUndefined();
45+
expect(messaging).toBeNull();
46+
}
47+
done();
4148
});
4249

4350
});

src/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@
2323
"author": "angular,firebase",
2424
"license": "MIT",
2525
"peerDependencies": {
26-
"@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
27-
"@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
28-
"@angular/platform-browser": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
29-
"@angular/platform-browser-dynamic": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
26+
"@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
27+
"@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
28+
"@angular/platform-browser": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
29+
"@angular/platform-browser-dynamic": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
3030
"rxjs": "~6.6.0 || ^7.0.0",
31-
"firebase-tools": "^9.9.0 || ^10.0.0 || ^11.0.0"
31+
"firebase-tools": "^9.9.0 || ^10.0.0 || ^11.0.0 || ^12.0.0"
3232
},
3333
"peerDependenciesMeta": {
3434
"firebase-tools": { "optional": true }
3535
},
3636
"dependencies": {
3737
"firebase": "^9.8.0",
3838
"rxfire": "^6.0.0",
39-
"@angular-devkit/schematics": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
40-
"@schematics/angular": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
39+
"@angular-devkit/schematics": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
40+
"@schematics/angular": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
4141
"tslib": "^2.0.0",
4242
"fuzzy": "^0.1.3",
4343
"inquirer-autocomplete-prompt": "^1.0.1",

src/schematics/deploy/actions.ts

+36-27
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { copySync, removeSync } from 'fs-extra';
55
import { dirname, join } from 'path';
66
import { execSync, spawn, SpawnOptionsWithoutStdio } from 'child_process';
77
import { defaultFunction, functionGen2, defaultPackage, DEFAULT_FUNCTION_NAME, dockerfile } from './functions-templates';
8-
import { satisfies } from 'semver';
8+
import { satisfies, lt } from 'semver';
99
import open from 'open';
1010
import { SchematicsException } from '@angular-devkit/schematics';
1111
import { firebaseFunctionsDependencies } from '../versions.json';
@@ -79,7 +79,7 @@ const deployToHosting = async (
7979
await firebaseTools.serve({
8080
port: DEFAULT_EMULATOR_PORT,
8181
host: DEFAULT_EMULATOR_HOST,
82-
targets: [`hosting:${siteTarget}`],
82+
only: `hosting:${siteTarget}`,
8383
nonInteractive: true,
8484
projectRoot: workspaceRoot,
8585
});
@@ -92,6 +92,8 @@ const deployToHosting = async (
9292

9393
if (!deployProject) { return; }
9494

95+
process.env.FIREBASE_FRAMEWORKS_SKIP_BUILD = 'true';
96+
9597
}
9698

9799
return await firebaseTools.deploy({
@@ -394,37 +396,44 @@ export default async function deploy(
394396
console.log(`Logged into Firebase as ${user.email}.`);
395397
}
396398

397-
if (prerenderBuildTarget) {
399+
if (options.version && options.version >= 2) {
400+
if (lt(firebaseTools.cli.version(), '12.2')) {
401+
throw new SchematicsException('firebase-tools version 12.2+ is required.');
402+
}
403+
process.env.FIREBASE_FRAMEWORK_BUILD_TARGET = (prerenderBuildTarget || serverBuildTarget || staticBuildTarget).name;
404+
} else {
405+
if (prerenderBuildTarget) {
398406

399-
const run = await context.scheduleTarget(
400-
targetFromTargetString(prerenderBuildTarget.name),
401-
prerenderBuildTarget.options
402-
);
403-
await run.result;
407+
const run = await context.scheduleTarget(
408+
targetFromTargetString(prerenderBuildTarget.name),
409+
prerenderBuildTarget.options
410+
);
411+
await run.result;
404412

405-
} else {
413+
} else {
406414

407-
if (!context.target) {
408-
throw new Error('Cannot execute the build target');
409-
}
415+
if (!context.target) {
416+
throw new Error('Cannot execute the build target');
417+
}
410418

411-
context.logger.info(`📦 Building "${context.target.project}"`);
419+
context.logger.info(`📦 Building "${context.target.project}"`);
412420

413-
const builders = [
414-
context.scheduleTarget(
415-
targetFromTargetString(staticBuildTarget.name),
416-
staticBuildTarget.options
417-
).then(run => run.result)
418-
];
421+
const builders = [
422+
context.scheduleTarget(
423+
targetFromTargetString(staticBuildTarget.name),
424+
staticBuildTarget.options
425+
).then(run => run.result)
426+
];
419427

420-
if (serverBuildTarget) {
421-
builders.push(context.scheduleTarget(
422-
targetFromTargetString(serverBuildTarget.name),
423-
serverBuildTarget.options
424-
).then(run => run.result));
425-
}
428+
if (serverBuildTarget) {
429+
builders.push(context.scheduleTarget(
430+
targetFromTargetString(serverBuildTarget.name),
431+
serverBuildTarget.options
432+
).then(run => run.result));
433+
}
426434

427-
await Promise.all(builders);
435+
await Promise.all(builders);
436+
}
428437
}
429438

430439
try {
@@ -457,7 +466,7 @@ export default async function deploy(
457466

458467
firebaseTools.logger.logger.add(logger);
459468

460-
if (serverBuildTarget) {
469+
if ((!options.version || options.version < 2) && serverBuildTarget) {
461470
if (options.ssr === 'cloud-run') {
462471
await deployToCloudRun(
463472
firebaseTools,

src/schematics/firebaseTools.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ declare global {
1010
export const getFirebaseTools = () => globalThis.firebaseTools ?
1111
Promise.resolve(globalThis.firebaseTools) :
1212
new Promise<FirebaseTools>((resolve, reject) => {
13+
process.env.FIREBASE_CLI_EXPERIMENTS ||= 'webframeworks';
1314
try {
1415
resolve(require('firebase-tools'));
1516
} catch (e) {
1617
try {
17-
const root = execSync('npm root -g').toString().trim();
18+
const root = execSync('npm root --location=global').toString().trim();
1819
resolve(require(`${root}/firebase-tools`));
1920
} catch (e) {
2021
const spinner = ora({
2122
text: `Installing firebase-tools...`,
2223
// Workaround for https://github.com/sindresorhus/ora/issues/136.
2324
discardStdin: process.platform !== 'win32',
2425
}).start();
25-
spawn('npm', ['i', '-g', 'firebase-tools'], {
26+
spawn('npm', ['i', '--location=global', 'firebase-tools'], {
2627
stdio: 'pipe',
2728
shell: true,
2829
}).on('close', (code) => {

src/schematics/interfaces.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const featureOptions = [
2626
{ name: 'Remote Config', value: FEATURES.RemoteConfig },
2727
];
2828

29-
export const enum PROJECT_TYPE { Static, CloudFunctions, CloudRun }
29+
export const enum PROJECT_TYPE { Static, CloudFunctions, CloudRun, WebFrameworks }
3030

3131
export interface NgAddOptions {
3232
firebaseProject: string;
@@ -39,10 +39,11 @@ export interface NgAddNormalizedOptions {
3939
firebaseApp: FirebaseApp|undefined;
4040
firebaseHostingSite: FirebaseHostingSite|undefined;
4141
sdkConfig: Record<string, string>|undefined;
42-
prerender: boolean;
42+
prerender: boolean|undefined;
4343
browserTarget: string|undefined;
4444
serverTarget: string|undefined;
4545
prerenderTarget: string|undefined;
46+
ssrRegion: string|undefined;
4647
}
4748

4849
export interface DeployOptions {
@@ -139,9 +140,9 @@ export interface FirebaseHostingRewrite {
139140

140141
export interface FirebaseHostingConfig {
141142
public?: string;
142-
ignore: string[];
143-
target: string;
144-
rewrites: FirebaseHostingRewrite[];
143+
ignore?: string[];
144+
target?: string;
145+
rewrites?: FirebaseHostingRewrite[];
145146
}
146147

147148
export interface FirebaseFunctionsConfig { [key: string]: any; }
@@ -179,6 +180,7 @@ export interface DeployBuilderSchema {
179180
cloudRunOptions?: Partial<CloudRunOptions>;
180181
outputPath?: string;
181182
CF3v2?: boolean;
183+
version?: number;
182184
}
183185

184186
export interface CloudRunOptions {

0 commit comments

Comments
 (0)