Skip to content

Target ng16 #3361

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

Merged
merged 32 commits into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f9e2279
Target ng16
jamesdaniels May 26, 2023
ec08128
Simplify the test suite
jamesdaniels May 26, 2023
3364675
Node 16 latest
jamesdaniels May 26, 2023
faaf4ed
Ignore engines for now
jamesdaniels May 26, 2023
ffdeacd
Dont pull cache from newer ng
jamesdaniels May 26, 2023
bf11b36
Upgrade
jamesdaniels May 26, 2023
642f83a
Turns out that wasnt it
jamesdaniels May 26, 2023
f731764
Cleanup
jamesdaniels May 26, 2023
c35542a
Dont bump versions
jamesdaniels May 26, 2023
290a61f
Fix prerender
jamesdaniels May 26, 2023
6362e32
Simplify
jamesdaniels May 26, 2023
a657482
Drop canaries for now, add seperate browser
jamesdaniels May 26, 2023
1da68ef
simplify
jamesdaniels May 26, 2023
d94e575
Drop contrib to Node 16, add firefox and safari tests
jamesdaniels May 26, 2023
f83d1df
Fix messaging test in safari
jamesdaniels May 26, 2023
cc42574
Version 2 of ng-deploy, use web frameworks
jamesdaniels May 27, 2023
47256f2
Fix ng-add tests
jamesdaniels May 27, 2023
79ada35
Messaging should be null
jamesdaniels May 27, 2023
7251105
Update java on macos for emulators
jamesdaniels May 27, 2023
85feb66
Always setup java
jamesdaniels May 27, 2023
22f544f
Mark falky windows tests as pending
jamesdaniels May 27, 2023
aae706a
window.navigator.platform
jamesdaniels May 27, 2023
8c084bb
Maybe the case or its win64
jamesdaniels May 27, 2023
f6ab5c8
Throw the platform, see whats up
jamesdaniels May 27, 2023
255babf
Pending isnt working in asyncs...
jamesdaniels May 27, 2023
183b535
Mark browser test as required
jamesdaniels May 27, 2023
36041ab
Skip more tests in windows, try demo proj
jamesdaniels May 27, 2023
8b68530
Test doesnt need the emulator cache
jamesdaniels May 27, 2023
e45b694
Upgrade actions
jamesdaniels May 27, 2023
0a4cfbe
Syntax error and upgrade codeql
jamesdaniels May 27, 2023
303b161
Another flaky test on windows, publish requires browser
jamesdaniels May 27, 2023
5eb4172
Tests are just flaky on windows i guess
jamesdaniels May 27, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

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

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
284 changes: 76 additions & 208 deletions .github/workflows/test.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ AngularFire doesn't follow Angular's versioning as Firebase also has breaking ch

| Angular | Firebase | AngularFire |
| --------|----------|--------------|
| 16 | 9 | ^7.6 |
| 15 | 9 | ^7.5 |
| 14 | 9 | ^7.4 |
| 13 | 9 | ^7.2 |
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@angular/fire",
"version": "7.5.0",
"version": "7.6.0",
"description": "The official Angular library for Firebase.",
"private": true,
"scripts": {
"test": "npm run build:jasmine && npm run test:node && npm run test:chrome-headless",
"test:watch": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=true --browsers=Chrome\"",
"test:chrome": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=Chrome\"",
"test:firefox": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=Firefox\"",
"test:safari": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=SafariNative\"",
"test:chrome-headless": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=ChromeHeadless\"",
"test:firefox-headless": "npx firebase-tools@latest emulators:exec --project=angularfire2-test \"ng test --watch=false --browsers=FirefoxHeadless\"",
"test:watch": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=true --browsers=Chrome\"",
"test:chrome": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=Chrome\"",
"test:firefox": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=Firefox\"",
"test:safari": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=SafariNative\"",
"test:chrome-headless": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=ChromeHeadless\"",
"test:firefox-headless": "npx --yes firebase-tools emulators:exec --project=demo123 \"ng test --watch=false --browsers=FirefoxHeadless\"",
"lint": "ng lint",
"test:node": "node -r tsconfig-paths/register ./dist/out-tsc/jasmine/tools/jasmine.js --input-type=commonjs",
"test:node-esm": "node -r tsconfig-paths/register ./dist/out-tsc/jasmine/tools/jasmine.mjs --input-type=commonjs",
Expand Down Expand Up @@ -57,7 +57,7 @@
"firebase": "^9.8.2",
"firebase-admin": "^9.11.1",
"firebase-functions": "^3.6.0",
"firebase-tools": "^9.0.0",
"firebase-tools": "^12.2.1",
"fs-extra": "^8.0.1",
"fuzzy": "^0.1.3",
"husky": "^4.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ describe('AngularFirestoreCollectionGroup', () => {

it('should be able to filter snapshotChanges() types - removed', done => {
(async () => {

const ITEMS = 10;
const { ref, stocks, names } = await collectionHarness(afs, ITEMS);

Expand Down
13 changes: 10 additions & 3 deletions src/messaging/messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ describe('Messaging', () => {
messaging = TestBed.inject(Messaging);
});

it('should be injectable', () => {
expect(providedMessaging).toBeTruthy();
expect(messaging).toEqual(providedMessaging);
it('should be injectable', async (done) => {
const supported = await isSupported();
if (supported) {
expect(providedMessaging).toBeTruthy();
expect(messaging).toEqual(providedMessaging);
} else {
expect(providedMessaging).toBeUndefined();
expect(messaging).toBeNull();
}
done();
});

});
Expand Down
14 changes: 7 additions & 7 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
"author": "angular,firebase",
"license": "MIT",
"peerDependencies": {
"@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
"@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
"@angular/platform-browser": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
"@angular/platform-browser-dynamic": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
"@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
"@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
"@angular/platform-browser": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
"@angular/platform-browser-dynamic": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
"rxjs": "~6.6.0 || ^7.0.0",
"firebase-tools": "^9.9.0 || ^10.0.0 || ^11.0.0"
"firebase-tools": "^9.9.0 || ^10.0.0 || ^11.0.0 || ^12.0.0"
},
"peerDependenciesMeta": {
"firebase-tools": { "optional": true }
},
"dependencies": {
"firebase": "^9.8.0",
"rxfire": "^6.0.0",
"@angular-devkit/schematics": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
"@schematics/angular": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
"@angular-devkit/schematics": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
"@schematics/angular": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
"tslib": "^2.0.0",
"fuzzy": "^0.1.3",
"inquirer-autocomplete-prompt": "^1.0.1",
Expand Down
63 changes: 36 additions & 27 deletions src/schematics/deploy/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { copySync, removeSync } from 'fs-extra';
import { dirname, join } from 'path';
import { execSync, spawn, SpawnOptionsWithoutStdio } from 'child_process';
import { defaultFunction, functionGen2, defaultPackage, DEFAULT_FUNCTION_NAME, dockerfile } from './functions-templates';
import { satisfies } from 'semver';
import { satisfies, lt } from 'semver';
import open from 'open';
import { SchematicsException } from '@angular-devkit/schematics';
import { firebaseFunctionsDependencies } from '../versions.json';
Expand Down Expand Up @@ -79,7 +79,7 @@ const deployToHosting = async (
await firebaseTools.serve({
port: DEFAULT_EMULATOR_PORT,
host: DEFAULT_EMULATOR_HOST,
targets: [`hosting:${siteTarget}`],
only: `hosting:${siteTarget}`,
nonInteractive: true,
projectRoot: workspaceRoot,
});
Expand All @@ -92,6 +92,8 @@ const deployToHosting = async (

if (!deployProject) { return; }

process.env.FIREBASE_FRAMEWORKS_SKIP_BUILD = 'true';

}

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

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

const run = await context.scheduleTarget(
targetFromTargetString(prerenderBuildTarget.name),
prerenderBuildTarget.options
);
await run.result;
const run = await context.scheduleTarget(
targetFromTargetString(prerenderBuildTarget.name),
prerenderBuildTarget.options
);
await run.result;

} else {
} else {

if (!context.target) {
throw new Error('Cannot execute the build target');
}
if (!context.target) {
throw new Error('Cannot execute the build target');
}

context.logger.info(`📦 Building "${context.target.project}"`);
context.logger.info(`📦 Building "${context.target.project}"`);

const builders = [
context.scheduleTarget(
targetFromTargetString(staticBuildTarget.name),
staticBuildTarget.options
).then(run => run.result)
];
const builders = [
context.scheduleTarget(
targetFromTargetString(staticBuildTarget.name),
staticBuildTarget.options
).then(run => run.result)
];

if (serverBuildTarget) {
builders.push(context.scheduleTarget(
targetFromTargetString(serverBuildTarget.name),
serverBuildTarget.options
).then(run => run.result));
}
if (serverBuildTarget) {
builders.push(context.scheduleTarget(
targetFromTargetString(serverBuildTarget.name),
serverBuildTarget.options
).then(run => run.result));
}

await Promise.all(builders);
await Promise.all(builders);
}
}

try {
Expand Down Expand Up @@ -457,7 +466,7 @@ export default async function deploy(

firebaseTools.logger.logger.add(logger);

if (serverBuildTarget) {
if ((!options.version || options.version < 2) && serverBuildTarget) {
if (options.ssr === 'cloud-run') {
await deployToCloudRun(
firebaseTools,
Expand Down
5 changes: 3 additions & 2 deletions src/schematics/firebaseTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ declare global {
export const getFirebaseTools = () => globalThis.firebaseTools ?
Promise.resolve(globalThis.firebaseTools) :
new Promise<FirebaseTools>((resolve, reject) => {
process.env.FIREBASE_CLI_EXPERIMENTS ||= 'webframeworks';
try {
resolve(require('firebase-tools'));
} catch (e) {
try {
const root = execSync('npm root -g').toString().trim();
const root = execSync('npm root --location=global').toString().trim();
resolve(require(`${root}/firebase-tools`));
} catch (e) {
const spinner = ora({
text: `Installing firebase-tools...`,
// Workaround for https://github.com/sindresorhus/ora/issues/136.
discardStdin: process.platform !== 'win32',
}).start();
spawn('npm', ['i', '-g', 'firebase-tools'], {
spawn('npm', ['i', '--location=global', 'firebase-tools'], {
stdio: 'pipe',
shell: true,
}).on('close', (code) => {
Expand Down
12 changes: 7 additions & 5 deletions src/schematics/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const featureOptions = [
{ name: 'Remote Config', value: FEATURES.RemoteConfig },
];

export const enum PROJECT_TYPE { Static, CloudFunctions, CloudRun }
export const enum PROJECT_TYPE { Static, CloudFunctions, CloudRun, WebFrameworks }

export interface NgAddOptions {
firebaseProject: string;
Expand All @@ -39,10 +39,11 @@ export interface NgAddNormalizedOptions {
firebaseApp: FirebaseApp|undefined;
firebaseHostingSite: FirebaseHostingSite|undefined;
sdkConfig: Record<string, string>|undefined;
prerender: boolean;
prerender: boolean|undefined;
browserTarget: string|undefined;
serverTarget: string|undefined;
prerenderTarget: string|undefined;
ssrRegion: string|undefined;
}

export interface DeployOptions {
Expand Down Expand Up @@ -139,9 +140,9 @@ export interface FirebaseHostingRewrite {

export interface FirebaseHostingConfig {
public?: string;
ignore: string[];
target: string;
rewrites: FirebaseHostingRewrite[];
ignore?: string[];
target?: string;
rewrites?: FirebaseHostingRewrite[];
}

export interface FirebaseFunctionsConfig { [key: string]: any; }
Expand Down Expand Up @@ -179,6 +180,7 @@ export interface DeployBuilderSchema {
cloudRunOptions?: Partial<CloudRunOptions>;
outputPath?: string;
CF3v2?: boolean;
version?: number;
}

export interface CloudRunOptions {
Expand Down
Loading