Skip to content

Commit

Permalink
fix: replaced firebase dependencies to root dependency. (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz authored Jan 4, 2023
1 parent 878d86b commit 11b751d
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 182 deletions.
10 changes: 10 additions & 0 deletions .changeset/early-cats-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@moralisweb3/client-firebase-auth-utils': patch
'@moralisweb3/client-firebase-api-utils': patch
'@moralisweb3/client-firebase-evm-auth': patch
'@moralisweb3/client-firebase-sol-auth': patch
'@moralisweb3/client-firebase-evm-api': patch
'@moralisweb3/client-firebase-sol-api': patch
---

Replaced Firebase dependencies to single root dependency (`firebase`).
2 changes: 1 addition & 1 deletion demos/firebase-auth-ext/hosting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@walletconnect/web3-provider": "^1.8.0",
"assert": "^2.0.0",
"buffer": "^6.0.3",
"firebase": "^9.10.0",
"firebase": "^9.15.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions demos/firebase-auth-ext/hosting/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { signInWithMoralis as signInWithMoralisByEvm } from '@moralisweb3/client-firebase-evm-auth';
import { signInWithMoralis as signInWithMoralisBySolana } from '@moralisweb3/client-firebase-sol-auth';
import { httpsCallable } from '@firebase/functions';
import { User } from '@firebase/auth';
import { httpsCallable } from 'firebase/functions';
import { User } from 'firebase/auth';
import { Fragment, useState } from 'react';
import { auth, functions, moralisAuth } from './firebase';
import WalletConnectProvider from '@walletconnect/web3-provider';
Expand Down
6 changes: 3 additions & 3 deletions demos/firebase-auth-ext/hosting/src/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { initializeApp } from '@firebase/app';
import { getAuth, browserSessionPersistence } from '@firebase/auth';
import { connectFunctionsEmulator, getFunctions } from '@firebase/functions';
import { initializeApp } from 'firebase/app';
import { getAuth, browserSessionPersistence } from 'firebase/auth';
import { connectFunctionsEmulator, getFunctions } from 'firebase/functions';
import { getMoralisAuth } from '@moralisweb3/client-firebase-auth-utils';

export const app = initializeApp({
Expand Down
4 changes: 2 additions & 2 deletions demos/firebase-nextjs/hosting/components/Firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export async function initializeFirebase(): Promise<Firebase> {
appId: String(process.env.NEXT_PUBLIC_FIREBASE_APP_ID),
});

const auth = getAuth();
const auth = getAuth(app);
await auth.setPersistence(browserSessionPersistence);

const functions = getFunctions();
const functions = getFunctions(app);
if (window.location.hostname === 'localhost') {
connectFunctionsEmulator(functions, 'localhost', 5001);
}
Expand Down
5 changes: 1 addition & 4 deletions packages/client/firebaseApiUtils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
"typescript": "^4.9.3"
},
"dependencies": {
"@firebase/app": "^0.8.4",
"@firebase/app-types": "^0.8.1",
"@firebase/functions": "^0.8.8",
"@moralisweb3/client-api-utils": "^2.11.0",
"@moralisweb3/common-core": "^2.11.0",
"firebase": "^9.13.0"
"firebase": "^9.15.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
PaginationReader,
ResponseAdapter,
} from '@moralisweb3/common-core';
import { httpsCallable, Functions } from '@firebase/functions';
import { httpsCallable, Functions } from 'firebase/functions';

export class FirebaseClientRequestHandler implements ClientRequestHandler {
private readonly functionName: string;
Expand Down
6 changes: 1 addition & 5 deletions packages/client/firebaseAuthUtils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"typescript": "^4.9.3"
},
"dependencies": {
"@firebase/app": "^0.8.4",
"@firebase/app-types": "^0.8.1",
"@firebase/auth": "^0.20.11",
"@firebase/functions": "^0.8.8",
"firebase": "^9.13.0"
"firebase": "^9.15.0"
}
}
6 changes: 3 additions & 3 deletions packages/client/firebaseAuthUtils/src/getMoralisAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Functions, getFunctions } from '@firebase/functions';
import { FirebaseApp } from '@firebase/app';
import { Auth, getAuth } from '@firebase/auth';
import { Functions, getFunctions } from 'firebase/functions';
import { FirebaseApp } from 'firebase/app';
import { Auth, getAuth } from 'firebase/auth';

export interface MoralisAuth {
auth: Auth;
Expand Down
2 changes: 1 addition & 1 deletion packages/client/firebaseAuthUtils/src/issueToken.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { httpsCallable } from '@firebase/functions';
import { httpsCallable } from 'firebase/functions';
import { MoralisAuth } from './getMoralisAuth';
import { SignInContext } from './requestMessage';

Expand Down
2 changes: 1 addition & 1 deletion packages/client/firebaseAuthUtils/src/requestMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { httpsCallable } from '@firebase/functions';
import { httpsCallable } from 'firebase/functions';
import { MoralisAuth } from './getMoralisAuth';
import { NetworkType } from './NetworkType';

Expand Down
5 changes: 1 addition & 4 deletions packages/client/firebaseEvmApi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
"typescript": "^4.9.3"
},
"dependencies": {
"@firebase/app": "^0.8.4",
"@firebase/app-types": "^0.8.1",
"@firebase/functions": "^0.8.8",
"@moralisweb3/client-evm-api": "^2.11.0",
"@moralisweb3/client-firebase-api-utils": "^2.11.0",
"@moralisweb3/common-core": "^2.11.0",
"@moralisweb3/common-evm-utils": "^2.11.0",
"firebase": "^9.13.0"
"firebase": "^9.15.0"
}
}
4 changes: 2 additions & 2 deletions packages/client/firebaseEvmApi/src/getMoralisEvmApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FirebaseApp } from '@firebase/app';
import { FirebaseApp } from 'firebase/app';
import { Functions, getFunctions } from 'firebase/functions';
import { ClientEvmApi } from '@moralisweb3/client-evm-api';
import { Functions, getFunctions } from '@firebase/functions';
import { CommonEvmUtils } from '@moralisweb3/common-evm-utils';
import { Core } from '@moralisweb3/common-core';
import { FirebaseClientRequestHandler } from '@moralisweb3/client-firebase-api-utils';
Expand Down
4 changes: 1 addition & 3 deletions packages/client/firebaseEvmAuth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
},
"dependencies": {
"@ethersproject/providers": "^5.7.1",
"@firebase/app": "^0.8.4",
"@firebase/auth": "^0.20.11",
"@metamask/detect-provider": "^1.2.0",
"@moralisweb3/client-firebase-auth-utils": "^2.11.0",
"firebase": "^9.10.0"
"firebase": "^9.15.0"
}
}
2 changes: 1 addition & 1 deletion packages/client/firebaseEvmAuth/src/signInWithMoralis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { signInWithCustomToken, UserCredential } from '@firebase/auth';
import { signInWithCustomToken, UserCredential } from 'firebase/auth';
import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers';
import { MoralisAuth, requestMessage, issueToken } from '@moralisweb3/client-firebase-auth-utils';
import detectEthereumProvider from '@metamask/detect-provider';
Expand Down
5 changes: 1 addition & 4 deletions packages/client/firebaseSolApi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
"typescript": "^4.9.3"
},
"dependencies": {
"@firebase/app": "^0.8.4",
"@firebase/app-types": "^0.8.1",
"@firebase/functions": "^0.8.8",
"@moralisweb3/client-firebase-api-utils": "^2.11.0",
"@moralisweb3/client-sol-api": "^2.11.0",
"@moralisweb3/common-core": "^2.11.0",
"@moralisweb3/common-sol-utils": "^2.11.0",
"firebase": "^9.10.0"
"firebase": "^9.15.0"
}
}
4 changes: 2 additions & 2 deletions packages/client/firebaseSolApi/src/getMoralisSolApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FirebaseApp } from '@firebase/app';
import { FirebaseApp } from 'firebase/app';
import { Functions, getFunctions } from 'firebase/functions';
import { ClientSolApi } from '@moralisweb3/client-sol-api';
import { Functions, getFunctions } from '@firebase/functions';
import { CommonSolUtils } from '@moralisweb3/common-sol-utils';
import { Core } from '@moralisweb3/common-core';
import { FirebaseClientRequestHandler } from '@moralisweb3/client-firebase-api-utils';
Expand Down
5 changes: 1 addition & 4 deletions packages/client/firebaseSolAuth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
"typescript": "^4.9.3"
},
"dependencies": {
"@firebase/app": "^0.8.4",
"@firebase/app-types": "^0.8.1",
"@firebase/auth": "^0.20.11",
"@moralisweb3/client-firebase-auth-utils": "^2.11.0",
"bs58": "^5.0.0",
"firebase": "^9.10.0"
"firebase": "^9.15.0"
}
}
2 changes: 1 addition & 1 deletion packages/client/firebaseSolAuth/src/signInWithMoralis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { signInWithCustomToken, UserCredential } from '@firebase/auth';
import { signInWithCustomToken, UserCredential } from 'firebase/auth';
import { MoralisAuth, requestMessage, issueToken, SolanaNetwork } from '@moralisweb3/client-firebase-auth-utils';
import { encode } from 'bs58';
import { SolanaProvider } from './SolanaProvider';
Expand Down
15 changes: 12 additions & 3 deletions scripts/findMissingDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const SKIP_DIRECTORIES = ['lib', 'integration', 'node_modules', 'template'];

const IGNORE_DEPENDENCIES = ['path', 'lodash', 'child_process', 'fs'];

const FORBIDDEN_DEPENDENCIES = [
/^@firebase\//, // Use root package instead (`import * from 'firebase'`, `import * from 'firebase/auth'`)
];

function findPackages(dirPath) {
const result = [];
fs.readdirSync(dirPath).forEach((fileName) => {
Expand Down Expand Up @@ -86,7 +90,10 @@ function findPackageMissingDependencies(packageDirPath) {
}
return result;
}, []);
return { missing, total: imports.length };
const forbidden = FORBIDDEN_DEPENDENCIES.filter((regexp) => {
return imports.some((imp) => regexp.test(imp)) || dependenciesList.some((dep) => regexp.test(dep));
});
return { missing, forbidden, total: imports.length };
}

const repositoryPath = path.resolve(__dirname, '..');
Expand All @@ -101,8 +108,10 @@ for (const packagePath of allPackagePaths) {
const result = findPackageMissingDependencies(packagePath);
if (!result) {
console.log(`⏩ Package ${packageName} is private`);
} else if (result.missing.length > 0) {
console.log(`❌ Package ${packageName} has missing dependencies:\n* ${result.missing.join('\n* ')}\n`);
} else if (result.missing.length > 0 || result.forbidden.length > 0) {
const missing = result.missing.map((d) => `* [missing] ${d}`).join('\n');
const forbidden = result.forbidden.map((d) => `* [forbidden] ${d}`).join('\n');
console.log(`❌ Package ${packageName} is invalid:\n${missing}\n${forbidden}`);
exitCode = 1;
} else {
console.log(`✅ Package ${packageName} is valid (${result.total} dependencies)`);
Expand Down
Loading

1 comment on commit 11b751d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage

Title Lines Statements Branches Functions
api-utils Coverage: 25%
26.34% (49/186) 19.14% (9/47) 22.85% (8/35)
auth Coverage: 90%
92.77% (77/83) 81.81% (18/22) 90% (18/20)
evm-api Coverage: 100%
100% (81/81) 66.66% (6/9) 100% (49/49)
common-evm-utils Coverage: 64%
64.67% (974/1506) 19.44% (127/653) 35.25% (208/590)
sol-api Coverage: 96%
96.66% (29/30) 66.66% (6/9) 91.66% (11/12)
common-sol-utils Coverage: 74%
73.77% (135/183) 60% (12/20) 65.67% (44/67)
common-streams-utils Coverage: 93%
94% (1066/1134) 81.42% (399/490) 86.74% (373/430)
streams Coverage: 89%
89.35% (512/573) 68.05% (49/72) 88.98% (105/118)

Please sign in to comment.