Skip to content

Commit

Permalink
Allow ng16 peer (#3361)
Browse files Browse the repository at this point in the history
* Allow peer of ng 16, firebase-tools 12
* Cleanup ng-add to use web frameworks
* Cleanup tests

---

Co-authored-by: robertIsaac <robertIsaac@users.noreply.github.com>
  • Loading branch information
jamesdaniels and robertIsaac committed May 27, 2023
1 parent 1ec218a commit 7a2402a
Show file tree
Hide file tree
Showing 27 changed files with 5,391 additions and 6,771 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
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
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
@@ -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
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
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
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
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
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
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

0 comments on commit 7a2402a

Please sign in to comment.