-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add Firebase Hosting and Vercel publishing support.
- Add documentation and examples for using Firebase Hosting target in `docs/zh/publishers/firebase-hosting.md` and `docs/en/publishers/firebase-hosting.md` - Implement new `AppPackagePublisherFirebaseHosting` class in `packages/flutter_app_publisher/lib/src/publishers/firebase_hosting/app_package_publisher_firebase_hosting.dart` with support for `web` platform and configuration files creation - Update instructions and fix typo in `docs/en/publishers/vercel.md` for using `vercel` target - Update imports and functions in `website/utils/rehypeExtractHeadings.ts` - Add `firebase-hosting` and `vercel` to the list of publishers in Navbar.tsx - Add new file `packages/flutter_app_publisher/lib/src/publishers/firebase_hosting/publish_firebase_hosting_config.dart` with new `PublishFirebaseHostingConfig` class and required `project-id` argument - Add `AppPackagePublisherFirebaseHosting()` to the list of publishers used in `FlutterAppPublisher` in `packages/flutter_app_publisher/lib/src/flutter_app_publisher.dart` - Add specifier for Firebase Hosting project ID in `publishArguments` map in `packages/flutter_distributor/bin/command_publish.dart` - Update parameter names in `docs/zh/publishers/vercel.md` and add new dependency to `website/package.json`: `unist-util-visit`
- Loading branch information
Showing
14 changed files
with
4,301 additions
and
3,958 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: firebase-hosting | ||
--- | ||
|
||
The firebase-hosting target publishes your web artifacts to the [firebase hosting](https://firebase.google.com/docs/hosting). | ||
|
||
## Get publishing arguments | ||
|
||
Open [https://firebase.google.com](https://firebase.google.com/) And log in | ||
|
||
### Get `project-id` | ||
|
||
Select the project you want to deploy, Open the Project Settings page and find `Project ID`. | ||
|
||
## Usage | ||
|
||
Run: | ||
|
||
``` | ||
flutter_distributor publish \ | ||
--path dist/1.0.0+1/hello_world-1.0.0+1-web \ | ||
--targets firebase-hosting \ | ||
--firebase-hosting-project-id your-project-id | ||
``` | ||
|
||
### Configure `distribute_options.yaml` | ||
|
||
```yaml | ||
output: dist/ | ||
releases: | ||
- name: dev | ||
jobs: | ||
- name: web-direct | ||
package: | ||
platform: web | ||
target: direct | ||
publish: | ||
target: firebase-hosting | ||
args: | ||
project-id: your-project-id | ||
``` | ||
Run: | ||
``` | ||
flutter_distributor release --name dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: firebase-hosting | ||
--- | ||
|
||
The firebase-hosting target publishes your web artifacts to the [firebase hosting](https://firebase.google.com/docs/hosting). | ||
|
||
## 获取发布参数 | ||
|
||
打开 [https://firebase.google.com](https://firebase.google.com/) 并登录 | ||
|
||
### 获取 `project-id` | ||
|
||
选择你要部署的项目,打开项目设置页面,并找到 `Project ID` | ||
|
||
## 用法 | ||
|
||
运行: | ||
|
||
``` | ||
flutter_distributor publish \ | ||
--path dist/1.0.0+1/hello_world-1.0.0+1-web \ | ||
--targets firebase-hosting \ | ||
--firebase-hosting-project-id your-project-id | ||
``` | ||
|
||
### 配置 `distribute_options.yaml` | ||
|
||
```yaml | ||
output: dist/ | ||
releases: | ||
- name: dev | ||
jobs: | ||
- name: web-direct | ||
package: | ||
platform: web | ||
target: direct | ||
publish: | ||
target: firebase-hosting | ||
args: | ||
project-id: your-project-id | ||
``` | ||
运行: | ||
``` | ||
flutter_distributor release --name dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...publisher/lib/src/publishers/firebase_hosting/app_package_publisher_firebase_hosting.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:app_package_publisher/app_package_publisher.dart'; | ||
import 'package:flutter_app_publisher/src/publishers/firebase_hosting/publish_firebase_hosting_config.dart'; | ||
import 'package:shell_executor/shell_executor.dart'; | ||
|
||
class AppPackagePublisherFirebaseHosting extends AppPackagePublisher { | ||
@override | ||
String get name => 'firebase-hosting'; | ||
|
||
@override | ||
List<String> get supportedPlatforms => ['web']; | ||
|
||
@override | ||
Future<PublishResult> publish( | ||
FileSystemEntity fileSystemEntity, { | ||
Map<String, String>? environment, | ||
Map<String, dynamic>? publishArguments, | ||
PublishProgressCallback? onPublishProgress, | ||
}) async { | ||
Directory directory = fileSystemEntity as Directory; | ||
|
||
PublishFirebaseHostingConfig publishConfig = | ||
PublishFirebaseHostingConfig.parse( | ||
environment, | ||
publishArguments, | ||
); | ||
|
||
try { | ||
File firebaseRcFile = File('${directory.path}/.firebaserc'); | ||
firebaseRcFile.createSync(recursive: true); | ||
firebaseRcFile.writeAsStringSync(json.encode({ | ||
'projects': {'default': publishConfig.projectId} | ||
})); | ||
File firebaseJsonFile = File('${directory.path}/firebase.json'); | ||
firebaseJsonFile.createSync(recursive: true); | ||
firebaseJsonFile.writeAsStringSync(json.encode({ | ||
'hosting': { | ||
'public': '.', | ||
'ignore': ['firebase.json'] | ||
} | ||
})); | ||
ProcessResult r = await $( | ||
'firebase', | ||
['deploy'], | ||
workingDirectory: directory.path, | ||
); | ||
|
||
String log = r.stdout.toString(); | ||
RegExpMatch? match = | ||
RegExp(r'(?<=Hosting URL: )\bhttps?:\/\/\S+\b').firstMatch(log); | ||
|
||
return PublishResult( | ||
url: match != null ? match.group(0)! : '', | ||
); | ||
} catch (error) { | ||
rethrow; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...er_app_publisher/lib/src/publishers/firebase_hosting/publish_firebase_hosting_config.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:app_package_publisher/app_package_publisher.dart'; | ||
|
||
class PublishFirebaseHostingConfig extends PublishConfig { | ||
PublishFirebaseHostingConfig({ | ||
required this.projectId, | ||
}); | ||
|
||
factory PublishFirebaseHostingConfig.parse( | ||
Map<String, String>? environment, | ||
Map<String, dynamic>? publishArguments, | ||
) { | ||
String? projectId = publishArguments?['project-id']; | ||
if ((projectId ?? '').isEmpty) { | ||
throw PublishError('Missing `project-id` config.'); | ||
} | ||
|
||
PublishFirebaseHostingConfig publishConfig = PublishFirebaseHostingConfig( | ||
projectId: projectId!, | ||
); | ||
return publishConfig; | ||
} | ||
|
||
String projectId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.