Skip to content

Commit 31d53be

Browse files
support downloading code from commit (#20)
Co-authored-by: Anton Emelyanov <[email protected]>
1 parent 453c440 commit 31d53be

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

bin/flutterflow_cli.dart

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void main(List<String> args) async {
5353
destinationPath: parsedArguments.command!['dest'],
5454
includeAssets: parsedArguments.command!['include-assets'],
5555
branchName: parsedArguments.command!['branch-name'],
56+
commitHash: parsedArguments.command!['commit-hash'],
5657
unzipToParentFolder: parsedArguments.command!['parent-folder'],
5758
fix: parsedArguments.command!['fix'],
5859
exportAsModule: parsedArguments.command!['as-module'],
@@ -76,10 +77,22 @@ void main(List<String> args) async {
7677
ArgResults _parseArgs(List<String> args) {
7778
final exportCodeCommandParser = ArgParser()
7879
..addOption('project', abbr: 'p', help: 'Project id')
79-
..addOption('dest',
80-
abbr: 'd', help: 'Destination directory', defaultsTo: '.')
81-
..addOption('branch-name',
82-
abbr: 'b', help: '(Optional) Specify a branch name')
80+
..addOption(
81+
'dest',
82+
abbr: 'd',
83+
help: 'Destination directory',
84+
defaultsTo: '.',
85+
)
86+
..addOption(
87+
'branch-name',
88+
abbr: 'b',
89+
help: '(Optional) Specify a branch name',
90+
)
91+
..addOption(
92+
'commit-hash',
93+
abbr: 'c',
94+
help: '(Optional) Specify a commit hash',
95+
)
8396
..addFlag(
8497
'include-assets',
8598
negatable: true,

lib/src/flutterflow_api_client.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class FlutterFlowApi {
3636
required bool includeAssets,
3737
String endpoint = kDefaultEndpoint,
3838
String? branchName,
39+
String? commitHash,
3940
bool unzipToParentFolder = false,
4041
bool fix = false,
4142
bool exportAsModule = false,
@@ -49,6 +50,7 @@ class FlutterFlowApi {
4950
destinationPath: destinationPath,
5051
includeAssets: includeAssets,
5152
branchName: branchName,
53+
commitHash: commitHash,
5254
unzipToParentFolder: unzipToParentFolder,
5355
fix: fix,
5456
exportAsModule: exportAsModule,
@@ -68,6 +70,7 @@ Future<String?> exportCode({
6870
required bool exportAsModule,
6971
bool format = true,
7072
String? branchName,
73+
String? commitHash,
7174
bool exportAsDebug = false,
7275
}) async {
7376
if (exportAsDebug && exportAsModule) {
@@ -83,6 +86,7 @@ Future<String?> exportCode({
8386
endpoint: endpointUrl,
8487
projectId: projectId,
8588
branchName: branchName,
89+
commitHash: commitHash,
8690
exportAsModule: exportAsModule,
8791
includeAssets: includeAssets,
8892
format: format,
@@ -156,16 +160,16 @@ Future<dynamic> _callExport({
156160
required Uri endpoint,
157161
required String projectId,
158162
String? branchName,
163+
String? commitHash,
159164
required bool exportAsModule,
160165
required bool includeAssets,
161166
required bool format,
162167
required bool exportAsDebug,
163168
}) async {
164169
final body = jsonEncode({
165-
'project': {
166-
'path': 'projects/$projectId',
167-
},
170+
'project': {'path': 'projects/$projectId'},
168171
if (branchName != null) 'branch_name': branchName,
172+
if (commitHash != null) 'commit': {'path': 'commits/$commitHash'},
169173
'export_as_module': exportAsModule,
170174
'include_assets_map': includeAssets,
171175
'format': format,

0 commit comments

Comments
 (0)