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

Flutter CLI #82

wants to merge 21 commits into from

Conversation

lohanidamodar
Copy link
Member

@lohanidamodar lohanidamodar commented May 8, 2023

What does this PR do?

  • Adds a Flutter command to Appwrite CLI
    • appwrite flutter configure command is used to setup Flutter project, link with appwrite project, add platforms and add and initialize Appwrite SDK
    • appwrite flutter generate is used to generate Dart classes for all the database collections in the project

Giving it a try

As it is still under development, if you would like to give it a try please use the following command to install (You will need Node and NPM installed)

npm install -g https://github.com/appwrite/sdk-for-cli#feat-flutter

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@stnguyen90 stnguyen90 self-requested a review May 17, 2023 14:27
Comment on lines 15 to 17
const appwriteFile = 'aW1wb3J0ICdwYWNrYWdlOmFwcHdyaXRlL2FwcHdyaXRlLmRhcnQnOwoKZmluYWwgY2xpZW50ID0gQ2xpZW50KCkKICAuc2V0RW5kcG9pbnQoJ3tFTkRQT0lOVH0nKQogIC5zZXRQcm9qZWN0KCd7UFJPSkVDVH0nKTsKCmZpbmFsIGFjY291bnQgPSBBY2NvdW50KGNsaWVudCk7CmZpbmFsIGRhdGFiYXNlcyA9IERhdGFiYXNlcyhjbGllbnQpOwpmaW5hbCBzdG9yYWdlID0gU3RvcmFnZShjbGllbnQpOwoK';

const modelTemplate = 'JUlNUE9SVFMlCmNsYXNzICVOQU1FJSB7CiAgZmluYWwgU3RyaW5nICRpZDsKICBmaW5hbCBTdHJpbmcgJGNyZWF0ZWRBdDsKICBmaW5hbCBTdHJpbmcgJHVwZGF0ZWR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wZGF0ZWRBdCc6ICR1cGRhdGVkQXQsCiAgICAgICdcJGNvbGxlY3Rpb25JZCc6ICRjb2xsZWN0aW9uSWQsCiAgICAgICdcJHBlcm1pc3Npb25zJzogJHBlcm1pc3Npb25zLAogICAgICAnXCRkYXRhYmFzZUlkJzogJGRhdGFiYXNlSWQsCiAgICAgICVNQVBfRklFTERTJQogICAgfTsKICB9CgogIEBvdmVycmlkZQogIFN0cmluZyB0b1N0cmluZygpIHsKICAgIHJldHVybiAnJU5BTUUlICcgKyB0b01hcCgpLnRvU3RyaW5nKCk7CiAgfQp9';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to include the raw templates by themselves to be more transparent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that, I felt this was better than managing multiple files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that, I felt this was better than managing multiple files?
Updated to use files instead.

Comment on lines 163 to 168
.replaceAll('%NAME%', name)
.replace('%IMPORTS%', imports)
.replace('%ATTRIBUTES%', properties)
.replace('%CONSTRUCTOR_PARAMETERS%', constructorParams)
.replace('%CONSTRUCTOR_ARGUMENTS%', constructorArgs)
.replace('%MAP_FIELDS%', mapFields);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do this with a map and a loop instead to make it more extensible?

if (!answers.project) process.exit(1)

let project = {};
if (answers.start == "new") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use === everywhere applicable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants