mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 13:23:12 +08:00 
			
		
		
		
	feat: project init
This commit is contained in:
		
							
								
								
									
										10
									
								
								.github/workflows/scripts/adb_all_emulators.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								.github/workflows/scripts/adb_all_emulators.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #!/bin/bash | ||||
| echo "Running $1 on all running emulators..." | ||||
| devices=`adb devices` | ||||
|  | ||||
| for device in $devices; do | ||||
|     if [[ "$device" =~ "emulator-" ]]; then | ||||
|       adb -s $device $1 | ||||
|     fi     | ||||
| done     | ||||
| echo "All Done." | ||||
							
								
								
									
										13
									
								
								.github/workflows/scripts/database.rules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/scripts/database.rules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| { | ||||
|   "rules": { | ||||
|     // Database in general is closed. Read/Write to anything but "tests/" will fail. | ||||
|     ".read": false, | ||||
|     ".write": false, | ||||
|  | ||||
|     // ..."tests" node will succeed | ||||
|      "tests": { | ||||
|         ".read": true, | ||||
|         ".write": true, | ||||
|      } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										39
									
								
								.github/workflows/scripts/firebase.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								.github/workflows/scripts/firebase.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| { | ||||
|   "firestore": { | ||||
|     "rules": "firestore.rules", | ||||
|     "indexes": "firestore.indexes.json" | ||||
|   }, | ||||
|   "functions": { | ||||
|     "predeploy": [ | ||||
|       "yarn", | ||||
|       "yarn --prefix \"$RESOURCE_DIR\" build" | ||||
|     ], | ||||
|     "source": "functions" | ||||
|   }, | ||||
|   "database": { | ||||
|     "rules": "database.rules" | ||||
|   }, | ||||
|   "storage": { | ||||
|     "rules": "storage.rules" | ||||
|   }, | ||||
|   "emulators": { | ||||
|     "auth": { | ||||
|       "port": 9099 | ||||
|     }, | ||||
|     "database": { | ||||
|       "port": 9000 | ||||
|     }, | ||||
|     "firestore": { | ||||
|       "port": 8080 | ||||
|     }, | ||||
|     "functions": { | ||||
|       "port": 5001 | ||||
|     }, | ||||
|     "storage": { | ||||
|       "port": 9199 | ||||
|     }, | ||||
|     "ui": { | ||||
|       "enabled": true | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										72
									
								
								.github/workflows/scripts/firestore.indexes.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								.github/workflows/scripts/firestore.indexes.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | ||||
| { | ||||
|   "indexes": [ | ||||
|     { | ||||
|       "collectionGroup": "firestore", | ||||
|       "queryScope": "COLLECTION", | ||||
|       "fields": [ | ||||
|         { | ||||
|           "fieldPath": "a", | ||||
|           "order": "ASCENDING" | ||||
|         }, | ||||
|         { | ||||
|           "fieldPath": "b", | ||||
|           "order": "ASCENDING" | ||||
|         } | ||||
|       ] | ||||
|     } | ||||
|   ], | ||||
|   "fieldOverrides": [ | ||||
|     { | ||||
|       "collectionGroup": "collectionGroup", | ||||
|       "fieldPath": "value", | ||||
|       "indexes": [ | ||||
|         { | ||||
|           "order": "ASCENDING", | ||||
|           "queryScope": "COLLECTION" | ||||
|         }, | ||||
|         { | ||||
|           "order": "DESCENDING", | ||||
|           "queryScope": "COLLECTION" | ||||
|         }, | ||||
|         { | ||||
|           "arrayConfig": "CONTAINS", | ||||
|           "queryScope": "COLLECTION" | ||||
|         }, | ||||
|         { | ||||
|           "order": "ASCENDING", | ||||
|           "queryScope": "COLLECTION_GROUP" | ||||
|         }, | ||||
|         { | ||||
|           "order": "DESCENDING", | ||||
|           "queryScope": "COLLECTION_GROUP" | ||||
|         } | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       "collectionGroup": "collectionGroup", | ||||
|       "fieldPath": "number", | ||||
|       "indexes": [ | ||||
|         { | ||||
|           "order": "ASCENDING", | ||||
|           "queryScope": "COLLECTION" | ||||
|         }, | ||||
|         { | ||||
|           "order": "DESCENDING", | ||||
|           "queryScope": "COLLECTION" | ||||
|         }, | ||||
|         { | ||||
|           "arrayConfig": "CONTAINS", | ||||
|           "queryScope": "COLLECTION" | ||||
|         }, | ||||
|         { | ||||
|           "order": "ASCENDING", | ||||
|           "queryScope": "COLLECTION_GROUP" | ||||
|         }, | ||||
|         { | ||||
|           "order": "DESCENDING", | ||||
|           "queryScope": "COLLECTION_GROUP" | ||||
|         } | ||||
|       ] | ||||
|     } | ||||
|   ] | ||||
| } | ||||
							
								
								
									
										17
									
								
								.github/workflows/scripts/firestore.rules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/scripts/firestore.rules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| rules_version = '2'; | ||||
| service cloud.firestore { | ||||
|   match /databases/{database}/documents { | ||||
|   match /{document=**} { | ||||
|       allow read, write: if false; | ||||
|     } | ||||
|   match /firestore-bundle-tests/{document=**} { | ||||
|       allow read, write: if true; | ||||
|     } | ||||
|   match /firestore/{document=**} { | ||||
|       allow read, write: if true; | ||||
|     }  | ||||
|   match /{path=**}/collectionGroup/{documentId} { | ||||
|       allow read, write: if true; | ||||
|     }   | ||||
|   } | ||||
| } | ||||
							
								
								
									
										10
									
								
								.github/workflows/scripts/functions/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.github/workflows/scripts/functions/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Compiled JavaScript files | ||||
| lib/**/*.js | ||||
| lib/**/*.js.map | ||||
|  | ||||
| # TypeScript v1 declaration files | ||||
| typings/ | ||||
|  | ||||
| # Node.js dependency directory | ||||
| node_modules/ | ||||
| yarn.lock | ||||
							
								
								
									
										24
									
								
								.github/workflows/scripts/functions/package.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								.github/workflows/scripts/functions/package.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| { | ||||
|   "name": "functions", | ||||
|   "scripts": { | ||||
|     "build": "tsc", | ||||
|     "serve": "npm run build && firebase emulators:start --only functions", | ||||
|     "shell": "npm run build && firebase functions:shell", | ||||
|     "start": "npm run shell", | ||||
|     "deploy": "firebase deploy --only functions", | ||||
|     "logs": "firebase functions:log" | ||||
|   }, | ||||
|   "engines": { | ||||
|     "node": "16" | ||||
|   }, | ||||
|   "main": "lib/index.js", | ||||
|   "dependencies": { | ||||
|     "firebase-admin": "^11.3.0", | ||||
|     "firebase-functions": "^4.2.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "firebase-functions-test": "^3.0.0", | ||||
|     "typescript": "^4.9.5" | ||||
|   }, | ||||
|   "private": true | ||||
| } | ||||
							
								
								
									
										13
									
								
								.github/workflows/scripts/functions/src/exports.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/scripts/functions/src/exports.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| /* | ||||
|  * | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
| */ | ||||
|  | ||||
| /* eslint-disable global-require */ | ||||
| module.exports = { | ||||
|   SAMPLE_DATA: require('./functions/sample-data'), | ||||
| }; | ||||
							
								
								
									
										12
									
								
								.github/workflows/scripts/functions/src/index.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								.github/workflows/scripts/functions/src/index.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| import * as functions from 'firebase-functions'; | ||||
|  | ||||
| // // Start writing Firebase Functions | ||||
| // // https://firebase.google.com/docs/functions/typescript | ||||
| // | ||||
| export const helloWorld = functions.https.onRequest((request, response) => { | ||||
|   functions.logger.info('Hello logs!', { structuredData: true }); | ||||
|   response.send('{ "data": "Hello from Firebase!" }'); | ||||
| }); | ||||
|  | ||||
| export { testFunctionCustomRegion } from './testFunctionCustomRegion'; | ||||
| export { testFunctionDefaultRegion } from './testFunctionDefaultRegion'; | ||||
							
								
								
									
										80
									
								
								.github/workflows/scripts/functions/src/sample-data.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								.github/workflows/scripts/functions/src/sample-data.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| /* | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
|  */ | ||||
|  | ||||
| const SAMPLE_DATA: { [key: string]: any } = { | ||||
|   number: 1234, | ||||
|   string: 'acde', | ||||
|   boolean: true, | ||||
|   null: null, | ||||
|   object: { | ||||
|     number: 1234, | ||||
|     string: 'acde', | ||||
|     boolean: true, | ||||
|     null: null, | ||||
|   }, | ||||
|   array: [1234, 'acde', true, null], | ||||
|   deepObject: { | ||||
|     array: [1234, 'acde', false, null], | ||||
|     object: { | ||||
|       number: 1234, | ||||
|       string: 'acde', | ||||
|       boolean: true, | ||||
|       null: null, | ||||
|       array: [1234, 'acde', true, null], | ||||
|     }, | ||||
|     number: 1234, | ||||
|     string: 'acde', | ||||
|     boolean: true, | ||||
|     null: null, | ||||
|   }, | ||||
|   deepArray: [ | ||||
|     1234, | ||||
|     'acde', | ||||
|     true, | ||||
|     null, | ||||
|     [1234, 'acde', true, null], | ||||
|     { | ||||
|       number: 1234, | ||||
|       string: 'acde', | ||||
|       boolean: true, | ||||
|       null: null, | ||||
|       array: [1234, 'acde', true, null], | ||||
|     }, | ||||
|   ], | ||||
|   deepMap: { | ||||
|     number: 123, | ||||
|     string: 'foo', | ||||
|     booleanTrue: true, | ||||
|     booleanFalse: false, | ||||
|     null: null, | ||||
|     list: ['1', 2, true, false], | ||||
|     map: { | ||||
|       number: 123, | ||||
|       string: 'foo', | ||||
|       booleanTrue: true, | ||||
|       booleanFalse: false, | ||||
|       null: null, | ||||
|     }, | ||||
|   }, | ||||
|   deepList: [ | ||||
|     '1', | ||||
|     2, | ||||
|     true, | ||||
|     false, | ||||
|     ['1', 2, true, false], | ||||
|     { | ||||
|       number: 123, | ||||
|       string: 'foo', | ||||
|       booleanTrue: true, | ||||
|       booleanFalse: false, | ||||
|       null: null, | ||||
|     }, | ||||
|   ], | ||||
| }; | ||||
|  | ||||
| export default SAMPLE_DATA; | ||||
							
								
								
									
										14
									
								
								.github/workflows/scripts/functions/src/testFunctionCustomRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.github/workflows/scripts/functions/src/testFunctionCustomRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| /* | ||||
|  * | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
|  */ | ||||
|  | ||||
| import * as functions from 'firebase-functions'; | ||||
|  | ||||
| export const testFunctionCustomRegion = functions | ||||
|   .region('europe-west1') | ||||
|   .https.onCall(() => 'europe-west1'); | ||||
							
								
								
									
										70
									
								
								.github/workflows/scripts/functions/src/testFunctionDefaultRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								.github/workflows/scripts/functions/src/testFunctionDefaultRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| /* | ||||
|  * | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
|  */ | ||||
|  | ||||
| import * as assert from 'assert'; | ||||
| import { FirebaseError } from 'firebase-admin'; | ||||
| import * as functions from 'firebase-functions'; | ||||
| import SAMPLE_DATA from './sample-data'; | ||||
|  | ||||
| export const testFunctionDefaultRegion = functions.https.onCall(data => { | ||||
|   console.log(Date.now(), data); | ||||
|  | ||||
|   if (typeof data === 'undefined') { | ||||
|     return 'undefined'; | ||||
|   } | ||||
|  | ||||
|   if (typeof data === 'string') { | ||||
|     return 'string'; | ||||
|   } | ||||
|  | ||||
|   if (typeof data === 'number') { | ||||
|     return 'number'; | ||||
|   } | ||||
|  | ||||
|   if (typeof data === 'boolean') { | ||||
|     return 'boolean'; | ||||
|   } | ||||
|  | ||||
|   if (data === null) { | ||||
|     return 'null'; | ||||
|   } | ||||
|  | ||||
|   if (Array.isArray(data)) { | ||||
|     return 'array'; | ||||
|   } | ||||
|  | ||||
|   const { type, asError, inputData } = data; | ||||
|   if (!Object.hasOwnProperty.call(SAMPLE_DATA, type)) { | ||||
|     throw new functions.https.HttpsError('invalid-argument', 'Invalid test requested.'); | ||||
|   } | ||||
|  | ||||
|   const outputData = SAMPLE_DATA[type]; | ||||
|  | ||||
|   try { | ||||
|     assert.deepEqual(outputData, inputData); | ||||
|   } catch (e) { | ||||
|     console.error(e); | ||||
|     throw new functions.https.HttpsError( | ||||
|       'invalid-argument', | ||||
|       'Input and Output types did not match.', | ||||
|       (e as FirebaseError).message, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   // all good | ||||
|   if (asError) { | ||||
|     throw new functions.https.HttpsError( | ||||
|       'cancelled', | ||||
|       'Response data was requested to be sent as part of an Error payload, so here we are!', | ||||
|       outputData, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   return outputData; | ||||
| }); | ||||
							
								
								
									
										16
									
								
								.github/workflows/scripts/functions/tsconfig.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								.github/workflows/scripts/functions/tsconfig.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| { | ||||
|   "compilerOptions": { | ||||
|     "module": "commonjs", | ||||
|     "noImplicitReturns": true, | ||||
|     "noUnusedLocals": true, | ||||
|     "outDir": "lib", | ||||
|     "sourceMap": true, | ||||
|     "skipLibCheck": true, | ||||
|     "strict": true, | ||||
|     "target": "es2017" | ||||
|   }, | ||||
|   "compileOnSave": true, | ||||
|   "include": [ | ||||
|     "src" | ||||
|   ] | ||||
| } | ||||
							
								
								
									
										6
									
								
								.github/workflows/scripts/start-firebase-emulator.bat
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/scripts/start-firebase-emulator.bat
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| @REM this pushd is likely not needed, but just in case | ||||
| pushd "%~dp0" | ||||
| @REM this is just to see what our current directory is. Should be .github/workflow/scripts | ||||
| echo %cd% | ||||
| @REM strangely, unless you specify the config file as being right in the current directory, it won't find it, and everything fails | ||||
| yarn firebase emulators:start --config %cd%\firebase.json --only auth,database,firestore,functions,storage --project react-native-firebase-testing | ||||
							
								
								
									
										44
									
								
								.github/workflows/scripts/start-firebase-emulator.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								.github/workflows/scripts/start-firebase-emulator.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| #!/bin/bash | ||||
| if ! [ -x "$(command -v firebase)" ]; then | ||||
|   echo "❌ Firebase-tools CLI is missing. Run 'npm i -g firebase-tools' or the equivalent" | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| EMU_START_COMMAND="firebase emulators:start --only auth,database,firestore,functions,storage --project react-native-firebase-testing" | ||||
| #EMU_START_COMMAND="sleep 120" | ||||
| MAX_RETRIES=3 | ||||
| MAX_CHECKATTEMPTS=60 | ||||
| CHECKATTEMPTS_WAIT=1 | ||||
|  | ||||
| # Make sure functions are ready to go | ||||
| pushd "$(dirname "$0")/functions" && yarn && yarn build && popd | ||||
|  | ||||
|  | ||||
| RETRIES=1 | ||||
| while [ $RETRIES -le $MAX_RETRIES ]; do | ||||
|  | ||||
|   if [ "$1" == "--no-daemon" ]; then | ||||
|     echo "Starting Firebase Emulator Suite in foreground." | ||||
|     $EMU_START_COMMAND | ||||
|     exit 0 | ||||
|   else | ||||
|     echo "Starting Firebase Emulator Suite in background." | ||||
|     $EMU_START_COMMAND & | ||||
|     CHECKATTEMPTS=1 | ||||
|     while [ $CHECKATTEMPTS -le $MAX_CHECKATTEMPTS ]; do | ||||
|       sleep $CHECKATTEMPTS_WAIT | ||||
|       if curl --output /dev/null --silent --fail http://localhost:8080; then | ||||
|         echo "Firebase Emulator Suite is online!" | ||||
|         exit 0; | ||||
|       fi | ||||
|       echo "Waiting for Firebase Emulator Suite to come online, check $CHECKATTEMPTS of $MAX_CHECKATTEMPTS..." | ||||
|       ((CHECKATTEMPTS = CHECKATTEMPTS + 1)) | ||||
|     done | ||||
|   fi | ||||
|  | ||||
|   echo "Firebase Emulator Suite did not come online in $MAX_CHECKATTEMPTS checks. Try $RETRIES of $MAX_RETRIES." | ||||
|   ((RETRIES = RETRIES + 1)) | ||||
|  | ||||
| done | ||||
| echo "Firebase Emulator Suite did not come online after $MAX_RETRIES attempts." | ||||
| exit 1 | ||||
							
								
								
									
										21
									
								
								.github/workflows/scripts/storage.rules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								.github/workflows/scripts/storage.rules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| rules_version = '2'; | ||||
| service firebase.storage { | ||||
|   match /b/{bucket}/o { | ||||
|     match /{document=**} { | ||||
|       allow read, write: if false; | ||||
|     } | ||||
|  | ||||
|     match /writeOnly.jpeg { | ||||
|       allow read: if false; | ||||
|       allow write: if true; | ||||
|     } | ||||
|  | ||||
|     match /playground/{document=**} { | ||||
|       allow read, write: if true; | ||||
|     } | ||||
|  | ||||
|     match /react-native-firebase-testing/{document=**} { | ||||
|       allow read, write: if true; | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 steven
					steven