FireBaseアプリケーションの管理のためのアプリケーション。複数の環境とデータ移行のサポートが含まれています
近日公開
機能の追加や貢献に興味がありますか?問題を開いてください!
これはソースコードであるため、開始するのに最適な場所は、FireAdmin.ioで入手可能なFireAdminのホストバージョンをチェックすることです。
開発中、あなたはおそらく主にnpm start
に依存するでしょう。ただし、自由に追加のスクリプトがあります。
yarn <script> | 説明 |
---|---|
start | localhost:3000 でアプリを提供します |
start:dist | ./dist にアプリケーションを構築し、 localhost:3000 でfirebase serve 使用して提供します |
functions:start | locally locally( firebase functions:shell を実行します |
functions:build | ./functions/dist にクラウド関数を構築します |
functions:test | Mochaを使用して機能単位テストを実行します |
build | ./dist にアプリケーションを構築します |
test | サイプレスでE2Eテストを実行します。テストを参照してください |
lint | 潜在的なエラーのためにプロジェクトを癒します |
lint:fix | プロジェクトを癒し、すべての修正可能なエラーを修正します |
ハスキーは、 prepush
フック機能を有効にするために使用されます。現在、 prepush
スクリプトはeslint
を実行しています。これにより、コード内に糸くずがある場合はプッシュされません。これを無効にしたい場合は、 package.json
からprepush
Scriptを削除します。
├── .github # Github Settings + Github Actions Workflows
│ ├── deploy.yml # Deploy workflow (called on merges to "master" and "production" branches)
│ └── verify.yml # Verify workflow (run when PR is created)
├── cypress # UI Integration Tests
├── docs # Docs application (built with Gatsby)
│ ├── content # Content of docs (written in markdown)
│ ├── components # React components used in docs app
│ ├── gatsby-config.js # Gatsby plugin settings
│ └── gatsby-node.js # Gatsby node definitions (how templates are combined with content)
│ └── package.json # Docs package file (docs specific dependencies)
├── functions # Cloud Functions (uses Cloud Functions for Firebase)
│ ├── src # Cloud Functions Source code (each folder represents a function)
│ └── index.js # Functions entry point
├── public # Public assets
│ ├── favicon.ico # Favicon
│ ├── firebase-messaging.sw.js # Messaging Service worker (loaded by Firebase SDK)
│ └── index.html # Main HTML page container for app
├── src # Application source code
│ ├── components # Global Reusable Presentational Components
│ ├── containers # Global Reusable Container Components
│ ├── layouts # Components that dictate major page structure
│ │ └── CoreLayout # Global application layout in which to render routes
│ ├── routes # Main route definitions and async split points
│ │ ├── index.js # Bootstrap main application routes with store
│ │ └── Home # Fractal route
│ │ ├── index.js # Route definitions and async split points
│ │ ├── assets # Assets required to render components
│ │ ├── components # Presentational React Components
│ │ ├── modules # Collections of reducers/constants/actions
│ │ └── routes ** # Fractal sub-routes (** optional)
│ ├── static # Static assets
│ └── utils # Application-wide utils (form validation etc)
├── .firebaserc # Firebase project settings (including settings for CI deployment)
├── cypress.json # Cypress Integration Test settings
├── database.rules.json # Firebase Real Time Database Rules
├── firebase.json # Firebase resource settings (including which folders are deployed)
├── firestore.indexes.json # Firestore Indexes
├── firestore.rules # Firestore Database Rules
└── storage.rules # Cloud Storage Rules
^10.18.0
(最新のクラウド関数のランタイムと一致するために提案されたノード10)npm i -g firebase-tools
依存関係のインストール: yarn install
プロジェクトのFireBaseコンソール内にWebアプリを作成します(次のステップで構成が使用されます)
次の形式を持つ.env.local
を作成します(前のステップから値が入力されています):
REACT_APP_FIREBASE_apiKey= < - api key - >
REACT_APP_FIREBASE_authDomain= < - auth domain - >
REACT_APP_FIREBASE_databaseURL= < - database URL - >
REACT_APP_FIREBASE_projectId= < - project ID - >
REACT_APP_FIREBASE_storageBucket= < - storageBucket - >
REACT_APP_FIREBASE_messagingSenderId= < - message sender ID - >
REACT_APP_FIREBASE_appId= < - project app id - >
REACT_APP_FIREBASE_PUBLIC_VAPID_KEY= < - project app id - >
REACT_APP_ALGOLIA_APP_ID= < - - >
REACT_APP_ALGOLIA_API_KEY= < - - >
functions/.runtimeconfig.json
ファイルを作成します。
{
"algolia" : {
"api_key" : " <- your API KEY -> " ,
"app_id" : " <- your Algolia APP ID -> "
},
"gmail" : {
"email" : " <- gmail account for sending invite emails -> " ,
"password" : " <- password for ^ email -> "
},
"encryption" : {
"password" : " <- your own made up encryption password for service accounts -> "
}
}
機能したファイルに一致するように機能変数を設定します(機能の展開バージョン用):
firebase functions:config:set $( jq -r ' to_entries[] | [.key, (.value | tojson)] | join("=") ' < functions/.runtimeconfig.json )
ビルドプロジェクト: yarn build
FireBaseへの展開: firebase deploy
(展開、クラウド機能、ルール、ホスティング)
開発サーバーの開始: npm start
注: yarn start:dist
を使用することもできます。
firebase open hosting:site
注:これの構成は.github/workflows/app-deploy.yml
内にあります。 firebase-ci
.firebaserc
から設定を取得することにより、CI展開プロセスを簡素化するために追加されました。必要なのは、firebaseを使用して認証を提供することです。
使用可能な少なくとも2つのFirebaseプロジェクトを用意しています。1つは各環境に(ステージングと生産)
両方のprojects
、 ci
、およびtargets
セクションの両方で.firebaserc
内の情報を交換します
ログイン: firebase login:ci
認証トークンを生成します。このトークンは、CIプロバイダーがお客様に代わって展開する権利を提供するために使用されます。 gitlab用に設定が提供されますが、CIプロバイダーは任意のCIプロバイダーを使用できます。
githubアクションの秘密の中で、 FIREBASE_TOKEN
環境変数を設定します
次の環境変数をGitHubアクションの変数に追加します( /settings/ci_cd
内):
FIREBASE_TOKEN ; // Used to deploy to Firebase (token generated in last step)
CYPRESS_RECORD_KEY ; // Record key for Cypress Dashboard
SERVICE_ACCOUNT ; // Used to authenticate with database to run hosted tests
gitリモート(おそらくgithub)にコードをプッシュして、githubアクションにビルドを実行します
CI設定のその他のオプションについては、FireBase-CIドキュメントをチェックアウトします。
yarn build
firebase deploy
Note: firebase serve
を使用して、FireBaseに展開したときにアプリケーションがどのように機能するかをテストできますが、最初にyarn build
を実行してください。ドキュメントはfireadmin.io/docsで入手できます
ドキュメントのすべてのソースコードとコンテンツは、 docs
フォルダー内にあります。ドキュメントはgatsby-config.js
の設定に基づいて、Gatsbyを使用してMarkdownから静的ファイルに生成されます。
詳細については、docs readmeをご覧ください。
注:CIの展開をセットアップしている場合、E2Eテストとユニットテストは、生産ビルドを実行する前にステージング環境に対して自動的に実行できます。
クラウド関数ユニットテストは、イスタンブールによって生成されたコードカバレッジを使用して、モカで記述されます。これらのテストでは、関数環境(依存関係を含む)をスタブすることにより、クラウド関数によって処理される「バックエンド機能」をカバーします。
cd functions
に移動しますnpm i
npm test
yarn test:cov
エンドツーエンドテストはサイプレスを使用して行われ、 cypress
フォルダー内に住んでいます。これらのテストはUI機能をカバーし、fireadminのホストされた環境で直接実行されます。プロダクションに展開する前に、ステージング環境に展開した後、githubアクションでアプリケーションエンドテストが自動的に実行されます。
FireBaseコンソール内にサービスアカウントを作成します
プロジェクトのルート内のserviceAccount.json
としてサービスアカウントを保存します
FireBaseコンソールの認証タブからテスト中に使用するユーザーのUIDを取得します
次の形式でcypress.env.json
を作成します。
{
"TEST_UID" : " <- user account's UID -> "
}
yarn emulators
を実行します。これにより、エミュレーターがブートアップされます(テスト中に指摘されます)
別の末端でYun yarn start:emulate
。これにより、アプリケーションがエミュレータを指しているとブートアップします
別の端末タブで、 yarn test:emulate:run
。これにより、エミュレーターを指摘したサイプレス統合テストが実行されます(シードと検証用)
単一のテストまたはすべてのテストを実行できるサイプレスのローカルテストランナーUIを開くには、 yarn test:emulate
。
12
理由クラウド機能ランタイムは最大12
サポートしているため、CIビルドバージョンに使用される理由です。これは、機能ランタイムが更新されると切り替えられます