Back

[SOLVED] Making a script to initialize project

  • 0
  • Flutter
LaurentLP
5 Dec, 2023, 13:53

Hey fellow appwriters! I am trying to make a script to initialize my Flutter/Appwrite project and I have a few questions (I am quite junior in development so pardon me if some are obviously wrong or impossible):

  • Is it possible to write a JSON file (a bit like appwrite.json) containing raw informations like database id/name, collection attributes, teams, etc., but also some initial data, like an admin user, documents, memberships, etc. and execute it to create some kind of project starter? Or do I have to manually create a project and insert my initial data in Appwrite's console?
  • If the first assumption is impossible, is it possible to write a sequence of commands that can automatize every step from project creation to initial data insertion without needing to use Appwrite's console or write Dart code? (nothing's wrong with Appwrite's console of course, I'm just trying to automatize my project initialization! πŸ˜… )
  • So now you have understood where I'm going, so if both first methods are impossible, do you have any tips on how I could do what I intend?

Thanks in advance,

LaurentLP

TL;DR
The user was able to solve their problem with the help of others. They were looking for a way to automate the project initialization process for their Flutter/Appwrite project. They wanted to know if it was possible to create a JSON file with project information and initial data to execute and create a project starter, or if there was a command sequence to automate the steps without using Appwrite's console or writing Dart code. No solution was provided in the thread, but the user was encouraged to explore the Appwrite CLI for possible solutions. Feedback was given regarding unclear syntax and error messages in the CLI.
Ernest
5 Dec, 2023, 15:34

Since you already know about appwrite.json, you're already aware of appwrite cli. The appwrite cli should be able to help you with your first approach. Unfortunately, I don't have any examples though but appwrite <command> --help should get you far.

LaurentLP
6 Dec, 2023, 14:15

Thanks for your response! Indeed I know about appwrite CLI and I will dive more into it. At first glance it seems to be satisfying

LaurentLP
13 Dec, 2023, 08:50

@Ernest Thanks to you (through this topic and others) I have been able to write my full script, so thank you again!

As feedback from this experience, I can say that the help and error messages are not so clear about the syntaxe in the command. Scopes of API keys, JSON values (like user or team prefs) and permissions for collections should maybe be explained a bit more. Also it seems that the CLI shows an error when adding a required collection attribute because the default value is not set : "βœ— Error Cannot convert undefined or null to object", but it is not possible to set a default value to a required attribute. It's not critical because attributes can be created even if the error message appears but it raises doubt.

Ernest
13 Dec, 2023, 09:08

Great, you got it working. I suggest you create issues for some of the bugs you noticed on the appwrite sdk-for-cli repo. Also, you can contribute examples to the docs. As Steven pointed out, there are some examples in the README of the repo just not on the website.

Ernest
13 Dec, 2023, 17:09

Please rename this post title as solved

D5
13 Dec, 2023, 18:35

[SOLVED] Making a script to initialize project

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more