appwrite-cli 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/Formula/appwrite.rb +1 -1
  2. package/LICENSE.md +2 -2
  3. package/README.md +4 -4
  4. package/docs/examples/account/create-phone-session.md +1 -1
  5. package/docs/examples/account/get-logs.md +2 -0
  6. package/docs/examples/account/get-sessions.md +1 -0
  7. package/docs/examples/account/update-phone.md +1 -1
  8. package/docs/examples/functions/create-build.md +4 -0
  9. package/docs/examples/graphql/mutation.md +2 -0
  10. package/docs/examples/graphql/query.md +2 -0
  11. package/docs/examples/locale/get-continents.md +1 -0
  12. package/docs/examples/locale/get-countries-e-u.md +1 -0
  13. package/docs/examples/locale/get-countries-phones.md +1 -0
  14. package/docs/examples/locale/get-countries.md +1 -0
  15. package/docs/examples/locale/get-currencies.md +1 -0
  16. package/docs/examples/locale/get-languages.md +1 -0
  17. package/docs/examples/projects/create.md +1 -0
  18. package/docs/examples/projects/update-auth-duration.md +3 -0
  19. package/docs/examples/projects/update-auth-sessions-limit.md +3 -0
  20. package/docs/examples/projects/update-o-auth2.md +1 -0
  21. package/docs/examples/teams/get-memberships.md +4 -0
  22. package/docs/examples/users/get-logs.md +3 -0
  23. package/docs/examples/users/get-memberships.md +2 -0
  24. package/docs/examples/users/get-sessions.md +2 -0
  25. package/docs/examples/users/update-phone.md +1 -1
  26. package/index.js +14 -1
  27. package/install.ps1 +2 -2
  28. package/install.sh +1 -1
  29. package/lib/client.js +2 -2
  30. package/lib/commands/account.js +10 -8
  31. package/lib/commands/avatars.js +3 -1
  32. package/lib/commands/databases.js +12 -10
  33. package/lib/commands/deploy.js +86 -1
  34. package/lib/commands/functions.js +9 -7
  35. package/lib/commands/generic.js +9 -0
  36. package/lib/commands/graphql.js +85 -0
  37. package/lib/commands/health.js +3 -1
  38. package/lib/commands/init.js +27 -1
  39. package/lib/commands/locale.js +3 -1
  40. package/lib/commands/projects.js +85 -5
  41. package/lib/commands/storage.js +10 -8
  42. package/lib/commands/teams.js +5 -3
  43. package/lib/commands/users.js +11 -9
  44. package/lib/config.js +39 -0
  45. package/lib/parser.js +1 -0
  46. package/lib/questions.js +27 -0
  47. package/package.json +1 -1
@@ -4,7 +4,7 @@ class Appwrite < Formula
4
4
  desc "CLI is a Node based command-line tool for Appwrite API"
5
5
  homepage "https://appwrite.io"
6
6
  license "BSD-3-Clause"
7
- head "https://github.com/appwrite/sdk-for-cli.git", branch: "main"
7
+ head "https://github.com/appwrite/sdk-for-cli.git", branch: "master"
8
8
 
9
9
  depends_on "node"
10
10
 
package/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors.
1
+ Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification,
7
7
 
8
8
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
9
 
10
- 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Appwrite Command Line SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.0.0-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.2.1-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
8
8
 
9
- **This SDK is compatible with Appwrite server version 1.0.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
9
+ **This SDK is compatible with Appwrite server version 1.2.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
10
10
 
11
11
  Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Command Line SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
12
12
 
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
29
29
 
30
30
  ```sh
31
31
  $ appwrite -v
32
- 1.1.1
32
+ 1.2.1
33
33
  ```
34
34
 
35
35
  ### Install using prebuilt binaries
@@ -58,7 +58,7 @@ $ iwr -useb https://appwrite.io/cli/install.ps1 | iex
58
58
  Once the installation completes, you can verify your install using
59
59
  ```
60
60
  $ appwrite -v
61
- 1.1.1
61
+ 1.2.1
62
62
  ```
63
63
 
64
64
  ## Getting Started
@@ -1,3 +1,3 @@
1
1
  appwrite account createPhoneSession \
2
2
  --userId [USER_ID] \
3
- --phone ''
3
+ --phone +12065550100
@@ -0,0 +1,2 @@
1
+ appwrite account getLogs \
2
+
@@ -0,0 +1 @@
1
+ appwrite account getSessions
@@ -1,3 +1,3 @@
1
1
  appwrite account updatePhone \
2
- --phone '' \
2
+ --phone +12065550100 \
3
3
  --password password
@@ -0,0 +1,4 @@
1
+ appwrite functions createBuild \
2
+ --functionId [FUNCTION_ID] \
3
+ --deploymentId [DEPLOYMENT_ID] \
4
+ --buildId [BUILD_ID]
@@ -0,0 +1,2 @@
1
+ appwrite graphql mutation \
2
+ --query '{ "key": "value" }'
@@ -0,0 +1,2 @@
1
+ appwrite graphql query \
2
+ --query '{ "key": "value" }'
@@ -0,0 +1 @@
1
+ appwrite locale getContinents
@@ -0,0 +1 @@
1
+ appwrite locale getCountriesEU
@@ -0,0 +1 @@
1
+ appwrite locale getCountriesPhones
@@ -0,0 +1 @@
1
+ appwrite locale getCountries
@@ -0,0 +1 @@
1
+ appwrite locale getCurrencies
@@ -0,0 +1 @@
1
+ appwrite locale getLanguages
@@ -11,3 +11,4 @@ appwrite projects create \
11
11
 
12
12
 
13
13
 
14
+
@@ -0,0 +1,3 @@
1
+ appwrite projects updateAuthDuration \
2
+ --projectId [PROJECT_ID] \
3
+ --duration 0
@@ -0,0 +1,3 @@
1
+ appwrite projects updateAuthSessionsLimit \
2
+ --projectId [PROJECT_ID] \
3
+ --limit 1
@@ -3,3 +3,4 @@ appwrite projects updateOAuth2 \
3
3
  --provider amazon \
4
4
 
5
5
 
6
+
@@ -0,0 +1,4 @@
1
+ appwrite teams getMemberships \
2
+ --teamId [TEAM_ID] \
3
+
4
+
@@ -0,0 +1,3 @@
1
+ appwrite users getLogs \
2
+ --userId [USER_ID] \
3
+
@@ -0,0 +1,2 @@
1
+ appwrite users getMemberships \
2
+ --userId [USER_ID]
@@ -0,0 +1,2 @@
1
+ appwrite users getSessions \
2
+ --userId [USER_ID]
@@ -1,3 +1,3 @@
1
1
  appwrite users updatePhone \
2
2
  --userId [USER_ID] \
3
- --number ''
3
+ --number +12065550100
package/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  #! /usr/bin/env node
2
+
3
+ /** Required to set max width of the help commands */
4
+ const oldWidth = process.stdout.columns
5
+ process.stdout.columns = 100
6
+ /** ---------------------------------------------- */
7
+
2
8
  const program = require("commander");
3
9
  const chalk = require("chalk");
4
10
  const { version } = require("./package.json");
@@ -11,6 +17,7 @@ const { account } = require("./lib/commands/account");
11
17
  const { avatars } = require("./lib/commands/avatars");
12
18
  const { databases } = require("./lib/commands/databases");
13
19
  const { functions } = require("./lib/commands/functions");
20
+ const { graphql } = require("./lib/commands/graphql");
14
21
  const { health } = require("./lib/commands/health");
15
22
  const { locale } = require("./lib/commands/locale");
16
23
  const { projects } = require("./lib/commands/projects");
@@ -20,6 +27,10 @@ const { users } = require("./lib/commands/users");
20
27
 
21
28
  program
22
29
  .description(commandDescriptions['main'])
30
+ .configureHelp({
31
+ helpWidth: process.stdout.columns || 80,
32
+ sortSubcommands: true
33
+ })
23
34
  .version(version, "-v, --version")
24
35
  .option("--verbose", "Show complete error log")
25
36
  .option("--json", "Output in JSON format")
@@ -38,6 +49,7 @@ program
38
49
  .addCommand(avatars)
39
50
  .addCommand(databases)
40
51
  .addCommand(functions)
52
+ .addCommand(graphql)
41
53
  .addCommand(health)
42
54
  .addCommand(locale)
43
55
  .addCommand(projects)
@@ -46,4 +58,5 @@ program
46
58
  .addCommand(users)
47
59
  .addCommand(client)
48
60
  .parse(process.argv);
49
-
61
+
62
+ process.stdout.columns = oldWidth;
package/install.ps1 CHANGED
@@ -13,8 +13,8 @@
13
13
  # You can use "View source" of this page to see the full script.
14
14
 
15
15
  # REPO
16
- $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.1.1/appwrite-cli-win-x64.exe"
17
- $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.1.1/appwrite-cli-win-arm64.exe"
16
+ $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.2.1/appwrite-cli-win-x64.exe"
17
+ $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.2.1/appwrite-cli-win-arm64.exe"
18
18
 
19
19
  $APPWRITE_BINARY_NAME = "appwrite.exe"
20
20
 
package/install.sh CHANGED
@@ -97,7 +97,7 @@ printSuccess() {
97
97
  downloadBinary() {
98
98
  echo "[2/4] Downloading executable for $OS ($ARCH) ..."
99
99
 
100
- GITHUB_LATEST_VERSION="1.1.1"
100
+ GITHUB_LATEST_VERSION="1.2.1"
101
101
  GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102
102
  GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103
103
 
package/lib/client.js CHANGED
@@ -15,8 +15,8 @@ class Client {
15
15
  'x-sdk-name': 'Command Line',
16
16
  'x-sdk-platform': 'console',
17
17
  'x-sdk-language': 'cli',
18
- 'x-sdk-version': '1.1.1',
19
- 'user-agent' : `AppwriteCLI/1.1.1 (${os.type()} ${os.version()}; ${os.arch()})`,
18
+ 'x-sdk-version': '1.2.1',
19
+ 'user-agent' : `AppwriteCLI/1.2.1 (${os.type()} ${os.version()}; ${os.arch()})`,
20
20
  'X-Appwrite-Response-Format' : '1.0.0',
21
21
  };
22
22
  }
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
11
  const { localConfig, globalConfig } = require("../config");
12
12
 
13
- const account = new Command("account").description(commandDescriptions['account'])
13
+ const account = new Command("account").description(commandDescriptions['account']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
14
16
 
15
17
  const accountGet = async ({ parseOutput = true, sdk = undefined}) => {
16
18
 
@@ -740,7 +742,7 @@ account
740
742
  account
741
743
  .command(`create`)
742
744
  .description(`Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](/docs/client/account#accountCreateVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](/docs/client/account#accountCreateSession).`)
743
- .requiredOption(`--userId <userId>`, `Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
745
+ .requiredOption(`--userId <userId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
744
746
  .requiredOption(`--email <email>`, `User email.`)
745
747
  .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
746
748
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
@@ -828,15 +830,15 @@ account
828
830
 
829
831
  account
830
832
  .command(`createEmailSession`)
831
- .description(`Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.`)
833
+ .description(`Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits).`)
832
834
  .requiredOption(`--email <email>`, `User email.`)
833
835
  .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
834
836
  .action(actionRunner(accountCreateEmailSession))
835
837
 
836
838
  account
837
839
  .command(`createMagicURLSession`)
838
- .description(`Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.`)
839
- .requiredOption(`--userId <userId>`, `Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
840
+ .description(`Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits).`)
841
+ .requiredOption(`--userId <userId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
840
842
  .requiredOption(`--email <email>`, `User email.`)
841
843
  .option(`--url <url>`, `URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
842
844
  .action(actionRunner(accountCreateMagicURLSession))
@@ -850,7 +852,7 @@ account
850
852
 
851
853
  account
852
854
  .command(`createOAuth2Session`)
853
- .description(`Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.. `)
855
+ .description(`Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). `)
854
856
  .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom.`)
855
857
  .option(`--success <success>`, `URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
856
858
  .option(`--failure <failure>`, `URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
@@ -859,8 +861,8 @@ account
859
861
 
860
862
  account
861
863
  .command(`createPhoneSession`)
862
- .description(`Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.`)
863
- .requiredOption(`--userId <userId>`, `Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
864
+ .description(`Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits).`)
865
+ .requiredOption(`--userId <userId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
864
866
  .requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
865
867
  .action(actionRunner(accountCreatePhoneSession))
866
868
 
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
11
  const { localConfig, globalConfig } = require("../config");
12
12
 
13
- const avatars = new Command("avatars").description(commandDescriptions['avatars'])
13
+ const avatars = new Command("avatars").description(commandDescriptions['avatars']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
14
16
 
15
17
  const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
16
18
  /* @param {string} code */
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
11
  const { localConfig, globalConfig } = require("../config");
12
12
 
13
- const databases = new Command("databases").description(commandDescriptions['databases'])
13
+ const databases = new Command("databases").description(commandDescriptions['databases']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
14
16
 
15
17
  const databasesList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
16
18
  /* @param {string[]} queries */
@@ -1125,7 +1127,7 @@ databases
1125
1127
  databases
1126
1128
  .command(`create`)
1127
1129
  .description(`Create a new Database. `)
1128
- .requiredOption(`--databaseId <databaseId>`, `Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
1130
+ .requiredOption(`--databaseId <databaseId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
1129
1131
  .requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
1130
1132
  .action(actionRunner(databasesCreate))
1131
1133
 
@@ -1145,7 +1147,7 @@ databases
1145
1147
  .command(`update`)
1146
1148
  .description(`Update a database by its unique ID.`)
1147
1149
  .requiredOption(`--databaseId <databaseId>`, `Database ID.`)
1148
- .requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
1150
+ .requiredOption(`--name <name>`, `Database name. Max length: 128 chars.`)
1149
1151
  .action(actionRunner(databasesUpdate))
1150
1152
 
1151
1153
  databases
@@ -1166,9 +1168,9 @@ databases
1166
1168
  .command(`createCollection`)
1167
1169
  .description(`Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console.`)
1168
1170
  .requiredOption(`--databaseId <databaseId>`, `Database ID.`)
1169
- .requiredOption(`--collectionId <collectionId>`, `Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
1171
+ .requiredOption(`--collectionId <collectionId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
1170
1172
  .requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
1171
- .option(`--permissions <permissions...>`, `An array of permissions strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
1173
+ .option(`--permissions <permissions...>`, `An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
1172
1174
  .option(`--documentSecurity <documentSecurity>`, `Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions).`, parseBool)
1173
1175
  .action(actionRunner(databasesCreateCollection))
1174
1176
 
@@ -1185,7 +1187,7 @@ databases
1185
1187
  .requiredOption(`--databaseId <databaseId>`, `Database ID.`)
1186
1188
  .requiredOption(`--collectionId <collectionId>`, `Collection ID.`)
1187
1189
  .requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
1188
- .option(`--permissions <permissions...>`, `An array of permission strings. By default the current permission are inherited. [Learn more about permissions](/docs/permissions).`)
1190
+ .option(`--permissions <permissions...>`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
1189
1191
  .option(`--documentSecurity <documentSecurity>`, `Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions).`, parseBool)
1190
1192
  .option(`--enabled <enabled>`, `Is collection enabled?`, parseBool)
1191
1193
  .action(actionRunner(databasesUpdateCollection))
@@ -1327,7 +1329,7 @@ databases
1327
1329
 
1328
1330
  databases
1329
1331
  .command(`listDocuments`)
1330
- .description(`Get a list of all the user's documents in a given collection. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of documents belonging to the provided collectionId. [Learn more about different API modes](/docs/admin).`)
1332
+ .description(`Get a list of all the user's documents in a given collection. You can use the query params to filter your results.`)
1331
1333
  .requiredOption(`--databaseId <databaseId>`, `Database ID.`)
1332
1334
  .requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).`)
1333
1335
  .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long.`)
@@ -1338,9 +1340,9 @@ databases
1338
1340
  .description(`Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console.`)
1339
1341
  .requiredOption(`--databaseId <databaseId>`, `Database ID.`)
1340
1342
  .requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.`)
1341
- .requiredOption(`--documentId <documentId>`, `Document ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
1343
+ .requiredOption(`--documentId <documentId>`, `Document ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
1342
1344
  .requiredOption(`--data <data>`, `Document data as JSON object.`)
1343
- .option(`--permissions <permissions...>`, `An array of permissions strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions).`)
1345
+ .option(`--permissions <permissions...>`, `An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions).`)
1344
1346
  .action(actionRunner(databasesCreateDocument))
1345
1347
 
1346
1348
  databases
@@ -1358,7 +1360,7 @@ databases
1358
1360
  .requiredOption(`--collectionId <collectionId>`, `Collection ID.`)
1359
1361
  .requiredOption(`--documentId <documentId>`, `Document ID.`)
1360
1362
  .option(`--data <data>`, `Document data as JSON object. Include only attribute and value pairs to be updated.`)
1361
- .option(`--permissions <permissions...>`, `An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
1363
+ .option(`--permissions <permissions...>`, `An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
1362
1364
  .action(actionRunner(databasesUpdateDocument))
1363
1365
 
1364
1366
  databases
@@ -2,7 +2,7 @@ const inquirer = require("inquirer");
2
2
  const JSONbig = require("json-bigint")({ storeAsString: false });
3
3
  const { Command } = require("commander");
4
4
  const { localConfig } = require("../config");
5
- const { questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections, questionsConfirmDeployCollections } = require("../questions");
5
+ const { questionsDeployTeams, questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections, questionsConfirmDeployCollections } = require("../questions");
6
6
  const { actionRunner, success, log, error, commandDescriptions } = require("../parser");
7
7
  const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsUpdateDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
8
8
  const {
@@ -25,6 +25,11 @@ const {
25
25
  databasesListIndexes,
26
26
  databasesDeleteIndex
27
27
  } = require("./databases");
28
+ const {
29
+ teamsGet,
30
+ teamsUpdate,
31
+ teamsCreate
32
+ } = require("./teams");
28
33
 
29
34
  const POOL_DEBOUNCE = 2000; // in milliseconds
30
35
  const POOL_MAX_DEBOUNCES = 30;
@@ -138,6 +143,9 @@ const awaitPools = {
138
143
 
139
144
  const deploy = new Command("deploy")
140
145
  .description(commandDescriptions['deploy'])
146
+ .configureHelp({
147
+ helpWidth: process.stdout.columns || 80
148
+ })
141
149
  .action(actionRunner(async (_options, command) => {
142
150
  command.help()
143
151
  }));
@@ -593,6 +601,76 @@ const deployCollection = async ({ all, yes } = {}) => {
593
601
  }
594
602
  }
595
603
 
604
+ const deployTeam = async ({ all, yes } = {}) => {
605
+ let response = {};
606
+
607
+ let teamIds = [];
608
+ const configTeams = localConfig.getTeams();
609
+
610
+ if(all) {
611
+ if (configTeams.length === 0) {
612
+ throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
613
+ }
614
+ teamIds.push(...configTeams.map((t) => t.$id));
615
+ }
616
+
617
+ if(teamIds.length === 0) {
618
+ let answers = await inquirer.prompt(questionsDeployTeams[0])
619
+ teamIds.push(...answers.teams);
620
+ }
621
+
622
+ let teams = [];
623
+
624
+ for(const teamId of teamIds) {
625
+ const idTeams = configTeams.filter((t) => t.$id === teamId);
626
+ teams.push(...idTeams);
627
+ }
628
+
629
+ for (let team of teams) {
630
+ log(`Deploying team ${team.name} ( ${team['$id']} )`)
631
+
632
+ try {
633
+ response = await teamsGet({
634
+ teamId: team['$id'],
635
+ parseOutput: false,
636
+ })
637
+ log(`Team ${team.name} ( ${team['$id']} ) already exists.`);
638
+
639
+ if(!yes) {
640
+ answers = await inquirer.prompt(questionsDeployTeams[1])
641
+ if (answers.override !== "YES") {
642
+ log(`Received "${answers.override}". Skipping ${team.name} ( ${team['$id']} )`);
643
+ continue;
644
+ }
645
+ }
646
+
647
+ log(`Updating team ...`)
648
+
649
+ await teamsUpdate({
650
+ teamId: team['$id'],
651
+ name: team.name,
652
+ parseOutput: false
653
+ });
654
+
655
+ success(`Deployed ${team.name} ( ${team['$id']} )`);
656
+ } catch (e) {
657
+ if (e.code == 404) {
658
+ log(`Team ${team.name} does not exist in the project. Creating ... `);
659
+
660
+ response = await teamsCreate({
661
+ teamId: team['$id'],
662
+ name: team.name,
663
+ parseOutput: false
664
+ })
665
+
666
+ success(`Deployed ${team.name} ( ${team['$id']} )`);
667
+ } else {
668
+ throw e;
669
+ }
670
+ }
671
+ }
672
+ }
673
+
596
674
  deploy
597
675
  .command("function")
598
676
  .description("Deploy functions in the current directory.")
@@ -608,6 +686,13 @@ deploy
608
686
  .option(`--yes`, `Flag to confirm all warnings`)
609
687
  .action(actionRunner(deployCollection));
610
688
 
689
+ deploy
690
+ .command("team")
691
+ .description("Deploy teams in the current project.")
692
+ .option(`--all`, `Flag to deploy all teams`)
693
+ .option(`--yes`, `Flag to confirm all warnings`)
694
+ .action(actionRunner(deployTeam));
695
+
611
696
  module.exports = {
612
697
  deploy
613
698
  }
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
11
  const { localConfig, globalConfig } = require("../config");
12
12
 
13
- const functions = new Command("functions").description(commandDescriptions['functions'])
13
+ const functions = new Command("functions").description(commandDescriptions['functions']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
14
16
 
15
17
  const functionsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
16
18
  /* @param {string[]} queries */
@@ -426,7 +428,7 @@ const functionsDeleteDeployment = async ({ functionId, deploymentId, parseOutput
426
428
  return response;
427
429
  }
428
430
 
429
- const functionsRetryBuild = async ({ functionId, deploymentId, buildId, parseOutput = true, sdk = undefined}) => {
431
+ const functionsCreateBuild = async ({ functionId, deploymentId, buildId, parseOutput = true, sdk = undefined}) => {
430
432
  /* @param {string} functionId */
431
433
  /* @param {string} deploymentId */
432
434
  /* @param {string} buildId */
@@ -675,7 +677,7 @@ functions
675
677
  functions
676
678
  .command(`create`)
677
679
  .description(`Create a new function. You can pass a list of [permissions](/docs/permissions) to allow different project users or team with access to execute the function using the client API.`)
678
- .requiredOption(`--functionId <functionId>`, `Function ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
680
+ .requiredOption(`--functionId <functionId>`, `Function ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
679
681
  .requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
680
682
  .requiredOption(`--execute <execute...>`, `An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long.`)
681
683
  .requiredOption(`--runtime <runtime>`, `Execution runtime.`)
@@ -759,16 +761,16 @@ functions
759
761
  .action(actionRunner(functionsDeleteDeployment))
760
762
 
761
763
  functions
762
- .command(`retryBuild`)
764
+ .command(`createBuild`)
763
765
  .description(``)
764
766
  .requiredOption(`--functionId <functionId>`, `Function ID.`)
765
767
  .requiredOption(`--deploymentId <deploymentId>`, `Deployment ID.`)
766
768
  .requiredOption(`--buildId <buildId>`, `Build unique ID.`)
767
- .action(actionRunner(functionsRetryBuild))
769
+ .action(actionRunner(functionsCreateBuild))
768
770
 
769
771
  functions
770
772
  .command(`listExecutions`)
771
- .description(`Get a list of all the current user function execution logs. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's executions. [Learn more about different API modes](/docs/admin).`)
773
+ .description(`Get a list of all the current user function execution logs. You can use the query params to filter your results.`)
772
774
  .requiredOption(`--functionId <functionId>`, `Function ID.`)
773
775
  .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, duration`)
774
776
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
@@ -848,7 +850,7 @@ module.exports = {
848
850
  functionsGetDeployment,
849
851
  functionsUpdateDeployment,
850
852
  functionsDeleteDeployment,
851
- functionsRetryBuild,
853
+ functionsCreateBuild,
852
854
  functionsListExecutions,
853
855
  functionsCreateExecution,
854
856
  functionsGetExecution,
@@ -9,6 +9,9 @@ const { accountCreateEmailSession, accountDeleteSession } = require("./account")
9
9
 
10
10
  const login = new Command("login")
11
11
  .description(commandDescriptions['login'])
12
+ .configureHelp({
13
+ helpWidth: process.stdout.columns || 80
14
+ })
12
15
  .action(actionRunner(async () => {
13
16
  const answers = await inquirer.prompt(questionsLogin)
14
17
 
@@ -26,6 +29,9 @@ const login = new Command("login")
26
29
 
27
30
  const logout = new Command("logout")
28
31
  .description(commandDescriptions['logout'])
32
+ .configureHelp({
33
+ helpWidth: process.stdout.columns || 80
34
+ })
29
35
  .action(actionRunner(async () => {
30
36
  let client = await sdkForConsole();
31
37
 
@@ -41,6 +47,9 @@ const logout = new Command("logout")
41
47
 
42
48
  const client = new Command("client")
43
49
  .description(commandDescriptions['client'])
50
+ .configureHelp({
51
+ helpWidth: process.stdout.columns || 80
52
+ })
44
53
  .option("--selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
45
54
  .option("--endpoint <endpoint>", "Set your Appwrite server endpoint")
46
55
  .option("--projectId <projectId>", "Set your Appwrite project ID")