> firebase projects:list
✔ Preparing the list of your Firebase projects
┌─────────────────────────┬─────────────────────────┬────────────────┬──────────────────────┐
│ Project Display Name │ Project ID │ Project Number │ Resource Location ID │
├─────────────────────────┼─────────────────────────┼────────────────┼──────────────────────┤
│ shopping-list │ shopping-list-xxxxx │ xxxxxxxxxxxx │ asia-northeast1 │
└─────────────────────────┴─────────────────────────┴────────────────┴──────────────────────┘
2-3. Firebase hostingの設定を行う
①今回はホスティングも合わせて行っていきます。 以下のコマンドを実行し、質問に答えていきます。
> firebase init hosting
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
C:\xxxxx\shopping_list
【準備はOKですかー!?】
? Are you ready to proceed? Yes
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
【既に作成されているFirebaseプロジェクトを利用しますか?】
? Please select an option: Use an existing project
? Select a default Firebase project for this directory: shopping-list-366bc (shopping-list)
i Using project shopping-list-366bc (shopping-list)
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
【publicディレクトリはどのような構成にしますか?】
? What do you want to use as your public directory? build/web
【SPAにしますか?】
? Configure as a single-page app (rewrite all urls to /index.html)? No
【GitHubを使用して自動ビルドとデプロイを設定しますか?】
? Set up automatic builds and deploys with GitHub? Yes
+ Wrote build/web/404.html
+ Wrote build/web/index.html
i Didn't detect a .git folder. Assuming C:\xxxxx\shopping_list is the project root.
i Authorizing with GitHub to upload your service account to a GitHub repository's secrets store.
Visit this URL on this device to log in:
Waiting for authentication...
+ Success! Logged into GitHub as i-tanaka730
【どのGitHubリポジトリにGitHubワークフローを設定しますか?】
? For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository) i-tanaka730/shopping_list
+ Created service account github-action-477706712 with Firebase Hosting admin permissions.
+ Uploaded service account JSON to GitHub as secret FIREBASE_SERVICE_ACCOUNT_SHOPPING_LIST_366BC.
i You can manage your secrets at https://github.com/i-tanaka730/shopping_list/settings/secrets.
【デプロイの前にビルドスクリプトを実行するようにワークフローを設定しますか?】
? Set up the workflow to run a build script before every deploy? Yes
【すべてのデプロイの前にどのスクリプトを実行する必要がありますか?(何故か2回指定せんとあかんかった)】
? What script should be run before every deploy? (npm ci && npm run build) flutter build web
? What script should be run before every deploy? flutter build web
+ Created workflow file C:\xxxxx\shopping_list\.github/workflows/firebase-hosting-pull-request.yml
【PRがマージされたときに、自動でプロインしますか?】
PRがマージされたときに、サイトのライブチャネルへの自動展開を設定しますか?
? Set up automatic deployment to your site's live channel when a PR is merged? Yes
【GitHubブランチの名前は何ですか?】
? What is the name of the GitHub branch associated with your site's live channel? main
+ Created workflow file C:\xxxxx\shopping_list\.github/workflows/firebase-hosting-merge.yml
i Action required: Visit this URL to revoke authorization for the Firebase CLI GitHub OAuth App:
i Action required: Push any new workflow file(s) to your repo
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
+ Firebase initialization complete!
<!DOCTYPE html><html><head>
...
</head><body><script>...if('serviceWorker'innavigator){...}else{// Service workers not supported. Just drop the<script>tag.loadMainDartJs();}</script><scriptsrc="https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js"></script><scriptsrc="https://www.gstatic.com/firebasejs/8.10.1/firebase-analytics.js"></script><scriptsrc="https://www.gstatic.com/firebasejs/8.10.1/firebase-firestore.js"></script><script>constfirebaseConfig={apiKey:"xxxxx",authDomain:"xxxxx",projectId:"xxxxx",storageBucket:"xxxxx",messagingSenderId:"xxxxx",appId:"xxxxx",measurementId:"xxxxx"};firebase.initializeApp(firebaseConfig);firebase.analytics();</script>
import'package:flutter/material.dart';import'package:cloud_firestore/cloud_firestore.dart';import'package:firebase_core/firebase_core.dart';voidmain()async{WidgetsFlutterBinding.ensureInitialized();awaitFirebase.initializeApp();runApp(constMyApp());}classMyAppextendsStatelessWidget{constMyApp({Key?key}):super(key:key);@overrideWidgetbuild(BuildContextcontext){returnMaterialApp(title:'Flutter Demo',theme:ThemeData(primarySwatch:Colors.blue,),home:constMyHomePage(title:'Flutter Demo Home Page'),);}}classMyHomePageextendsStatefulWidget{constMyHomePage({Key?key,requiredthis.title}):super(key:key);finalStringtitle;@overrideState<MyHomePage>createState()=>_MyHomePageState();}class_MyHomePageStateextendsState<MyHomePage>{int_counter=0;@overridevoidinitState(){super.initState();load();}voidload()async{awaitFirebaseFirestore.instance.collection('CollectionTest').doc('DocumentTest').get().then((DocumentSnapshotsnapshot){varcount=snapshot.get('count');debugPrint(count.toString());setState((){_counter=countasint;});});}void_incrementCounter()async{setState((){_counter++;});awaitFirebaseFirestore.instance.collection('CollectionTest').doc('DocumentTest').set({'count':_counter});}@overrideWidgetbuild(BuildContextcontext){returnScaffold(appBar:AppBar(title:Text(widget.title),),body:Center(child:Column(mainAxisAlignment:MainAxisAlignment.center,children:<Widget>[constText('You have pushed the button this many times:',),Text('$_counter',style:Theme.of(context).textTheme.headline4,),],),),floatingActionButton:FloatingActionButton(onPressed:_incrementCounter,tooltip:'Increment',child:constIcon(Icons.add),),);}}
コメント