Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter CLI #82

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions flutter_res/appwrite.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:appwrite/appwrite.dart';

final client = Client()
.setEndpoint('{ENDPOINT}')
.setProject('{PROJECT}');

final account = Account(client);
final databases = Databases(client);
final storage = Storage(client);

50 changes: 50 additions & 0 deletions generator/template_dart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%IMPORTS%
class %NAME% {
final String $id;
final String $createdAt;
final String $updatedAt;
final String $collectionId;
final String $databaseId;
final List<String> $permissions;

%ATTRIBUTES%

%NAME%({
required this.$id,
required this.$createdAt,
required this.$updatedAt,
required this.$collectionId,
required this.$permissions,
required this.$databaseId,
%CONSTRUCTOR_PARAMETERS%
});

factory %NAME%.fromMap(Map<String, dynamic> map) {
return %NAME%(
$id: map['\$id'],
$createdAt: map['\$createdAt'],
$updatedAt: map['\$updatedAt'],
$collectionId: map['\$collectionId'],
$permissions: List<String>.from(map['\$permissions']),
$databaseId: map['\$databaseId'],
%CONSTRUCTOR_ARGUMENTS%
);
}

Map<String, dynamic> toMap() {
return {
'\$id': $id,
'\$createdAt': $createdAt,
'\$updatedAt': $updatedAt,
'\$collectionId': $collectionId,
'\$permissions': $permissions,
'\$databaseId': $databaseId,
%MAP_FIELDS%
};
}

@override
String toString() {
return '%NAME% ' + toMap().toString();
}
}
11 changes: 11 additions & 0 deletions generator/template_ts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%IMPORTS%

export type %NAME% {
$id: string;
$collectionId: string;
$databaseId: string;
$createdAt: string;
$updatedAt: string;
$permissions: string[];
%ATTRIBUTES%
}
4 changes: 4 additions & 0 deletions index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const { projects } = require("./lib/commands/projects");
const { storage } = require("./lib/commands/storage");
const { teams } = require("./lib/commands/teams");
const { users } = require("./lib/commands/users");
const { flutter } = require("./lib/commands/flutter");
const { generate } = require("./lib/commands/generate");

program
.description(commandDescriptions['main'])
Expand Down Expand Up @@ -59,6 +61,8 @@ program
.addCommand(teams)
.addCommand(users)
.addCommand(client)
.addCommand(flutter)
.addCommand(generate)
.parse(process.argv);

process.stdout.columns = oldWidth;
Loading