appwrite-cli 0.14.0 → 0.15.0
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.
- package/.github/workflows/npm-publish.yml +1 -0
- package/README.md +158 -3
- package/install.ps1 +94 -0
- package/install.sh +1 -9
- package/lib/client.js +4 -4
- package/lib/commands/account.js +1 -1
- package/lib/commands/avatars.js +1 -1
- package/lib/commands/database.js +1 -1
- package/lib/commands/deploy.js +1 -1
- package/lib/commands/functions.js +18 -5
- package/lib/commands/health.js +1 -1
- package/lib/commands/init.js +0 -1
- package/lib/commands/locale.js +1 -1
- package/lib/commands/projects.js +1 -1
- package/lib/commands/storage.js +23 -11
- package/lib/commands/teams.js +1 -1
- package/lib/commands/users.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Appwrite Command Line SDK
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

|
|
5
5
|
[](https://travis-ci.com/appwrite/sdk-generator)
|
|
6
6
|
[](https://twitter.com/appwrite)
|
|
7
7
|
[](https://appwrite.io/discord)
|
|
@@ -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
|
-
0.
|
|
32
|
+
0.15.0
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Install using prebuilt binaries
|
|
@@ -58,9 +58,164 @@ $ 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
|
-
0.
|
|
61
|
+
0.15.0
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
## Getting Started
|
|
65
|
+
|
|
66
|
+
Before you can use the CLI, you need to login to your Appwrite account.
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
$ appwrite login
|
|
70
|
+
|
|
71
|
+
? Enter your email test@test.com
|
|
72
|
+
? Enter your password ********
|
|
73
|
+
✓ Success
|
|
74
|
+
```
|
|
75
|
+
This will also prompt you to enter your Appwrite endpoint ( default: http://localhost/v1 )
|
|
76
|
+
|
|
77
|
+
* ### Initialising your project
|
|
78
|
+
Once logged in, the CLI needs to be initialised before you can use it with your Appwrite project. You can do this with the `appwrite init project` command.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
$ appwrite init project
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The following prompt will guide you through the setup process. The `init` command also creates an `appwrite.json` file representing your Appwrite project.
|
|
85
|
+
|
|
86
|
+
The `appwrite.json` file does a lot of things.
|
|
87
|
+
* Provides context to the CLI
|
|
88
|
+
* Keeps track of all your cloud functions
|
|
89
|
+
* Keeps track of all your project's collections
|
|
90
|
+
* Helps you deploy your Appwrite project to production and more..
|
|
91
|
+
|
|
92
|
+
You can also fetch all the collections in your current project using
|
|
93
|
+
```sh
|
|
94
|
+
appwrite init collection
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The CLI also comes with a convenient `--all` flag to perform both these steps at once.
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
appwrite init --all
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
* ### Creating and deploying cloud functions
|
|
104
|
+
|
|
105
|
+
The CLI makes it extremely easy to create and deploy Appwrite's cloud functions. Initialise your new function using
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
$ appwrite init function
|
|
109
|
+
? What would you like to name your function? My Awesome Function
|
|
110
|
+
? What runtime would you like to use? Node.js (node-15.5)
|
|
111
|
+
✓ Success
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
This will create a new function `My Awesome Function` in your current Appwrite project and also create a template function for you to get started.
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
$ tree My\ Awesome\ Function
|
|
118
|
+
|
|
119
|
+
My Awesome Function
|
|
120
|
+
├── README.md
|
|
121
|
+
├── index.js
|
|
122
|
+
├── package-lock.json
|
|
123
|
+
└── package.json
|
|
124
|
+
|
|
125
|
+
0 directories, 4 files
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
You can now deploy this function using
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
$ appwrite deploy function
|
|
132
|
+
|
|
133
|
+
? Which functions would you like to deploy? My Awesome Function (61d1a4c81dfcd95bc834)
|
|
134
|
+
ℹ Info Deploying function My Awesome Function ( 61d1a4c81dfcd95bc834 )
|
|
135
|
+
✓ Success Deployed My Awesome Function ( 61d1a4c81dfcd95bc834 )
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Your function has now been deployed on your Appwrite server! As soon as the build process is finished, you can start executing the function.
|
|
139
|
+
|
|
140
|
+
* ### Deploying Collections
|
|
141
|
+
|
|
142
|
+
Similarly, you can deploy all your collections to your Appwrite server using
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
appwrite deploy collections
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The `deploy` command also comes with a convenient `--all` flag to deploy all your functions and collections at once.
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
appwrite deploy --all
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
> ### Note
|
|
155
|
+
> By default, requests to domains with self signed SSL certificates (or no certificates) are disabled. If you trust the domain, you can bypass the certificate validation using
|
|
156
|
+
```sh
|
|
157
|
+
$ appwrite client --selfSigned true
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Usage
|
|
161
|
+
|
|
162
|
+
The Appwrite CLI follows the following general syntax.
|
|
163
|
+
```sh
|
|
164
|
+
$ appwrite [COMMAND] --[OPTIONS]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
A few sample commands to get you started
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
$ appwrite users create --userId "unique()" --email hello@appwrite.io --password very_strong_password
|
|
171
|
+
$ appwrite users list
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
To create a document you can use the following command
|
|
175
|
+
```sh
|
|
176
|
+
$ appwrite database createDocument --collectionId <ID> --documentId 'unique()' --data '{ "Name": "Iron Man" }' --read role:all team:abc
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Some Gotchas
|
|
180
|
+
- `data` must be a valid JSON string where each key and value are enclosed in double quotes `"` like the example above.
|
|
181
|
+
- Some arguments like the `read` and `write` permissions are expected to be arrays. In the Appwrite CLI, array values are passed in using space as a separator like in the example above.
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
To get information about the different services available, you can use
|
|
185
|
+
```sh
|
|
186
|
+
$ appwrite -h
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
To get information about a particular service and the commands available in a service you can use
|
|
190
|
+
```sh
|
|
191
|
+
$ appwrite users // or
|
|
192
|
+
$ appwrite users --help // or
|
|
193
|
+
$ appwrite users help // or
|
|
194
|
+
$ appwrite accounts
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
To get information about a particular command and the parameters it accepts, you can use
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
$ appwrite users list --help
|
|
201
|
+
$ appwrite account get --help
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
At any point, you can view or reset the CLI configuration using the `client` service.
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
$ appwrite client --debug
|
|
208
|
+
// This will display your endpoint, projectID, API key and so on.
|
|
209
|
+
$ appwrite client --reset
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## CI mode
|
|
213
|
+
|
|
214
|
+
The Appwrite CLI can also work in a CI environment. The initialisation of the CLI works a bit differently in CI. In CI, you set your `endpoint`, `projectId` and `API Key` using
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
appwrite client --endpoint http://localhost/v1 --projectId <PROJECT_ID> --key <API KEY>
|
|
218
|
+
```
|
|
64
219
|
|
|
65
220
|
## Contribution
|
|
66
221
|
|
package/install.ps1
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
## <script src="/dist/scripts/cli-bash.js"></script>
|
|
2
|
+
## <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.16.0/themes/prism-okaidia.min.css" rel="stylesheet" />
|
|
3
|
+
## <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.16.0/components/prism-core.min.js" data-manual></script>
|
|
4
|
+
## <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.16.0/components/prism-powershell.min.js"></script>
|
|
5
|
+
## <style>body {color: #272822; background-color: #272822; font-size: 0.8em;} </style>
|
|
6
|
+
# Love open-source, dev-tooling and passionate about code as much as we do?
|
|
7
|
+
# ---
|
|
8
|
+
# We're always looking for awesome hackers like you to join our 100% remote team!
|
|
9
|
+
# Check and see if you find any relevant position @ https://appwrite.io/company/careers 👩💻 😎
|
|
10
|
+
# (and let us know you found this message...)
|
|
11
|
+
|
|
12
|
+
# This script contains hidden JS code to allow better readability and syntax highlighting
|
|
13
|
+
# You can use "View source" of this page to see the full script.
|
|
14
|
+
|
|
15
|
+
# REPO
|
|
16
|
+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.15.0/appwrite-cli-win-x64.exe"
|
|
17
|
+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.15.0/appwrite-cli-win-arm64.exe"
|
|
18
|
+
|
|
19
|
+
# Appwrite download directory
|
|
20
|
+
$APPWRITE_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath "appwrite.exe"
|
|
21
|
+
|
|
22
|
+
# Appwrite CLI location
|
|
23
|
+
$APPWRITE_INSTALL_DIR = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Appwrite"
|
|
24
|
+
|
|
25
|
+
$USER_PATH_ENV_VAR = [Environment]::GetEnvironmentVariable("PATH", "User")
|
|
26
|
+
|
|
27
|
+
function Greeting {
|
|
28
|
+
Write-Host @"
|
|
29
|
+
|
|
30
|
+
_ _ _ ___ __ _____
|
|
31
|
+
/_\ _ __ _ ____ ___ __(_) |_ ___ / __\ / / \_ \
|
|
32
|
+
//_\\| '_ \| '_ \ \ /\ / / '__| | __/ _ \ / / / / / /\/
|
|
33
|
+
/ _ \ |_) | |_) \ V V /| | | | || __/ / /___/ /___/\/ /_
|
|
34
|
+
\_/ \_/ .__/| .__/ \_/\_/ |_| |_|\__\___| \____/\____/\____/
|
|
35
|
+
|_| |_|
|
|
36
|
+
|
|
37
|
+
"@ -ForegroundColor red
|
|
38
|
+
Write-Host "Welcome to the Appwrite CLI install shield."
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
function CheckSystemInfo {
|
|
43
|
+
Write-Host "[1/4] Getting System Info ..."
|
|
44
|
+
if ((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') {
|
|
45
|
+
Write-Host "PowerShell requires an execution policy of 'RemoteSigned'."
|
|
46
|
+
Write-Host "To make this change please run:"
|
|
47
|
+
Write-Host "'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'"
|
|
48
|
+
break
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function DownloadBinary {
|
|
53
|
+
Write-Host "[2/4] Downloading Appwrite CLI binary ..."
|
|
54
|
+
Write-Host "🚦 Fetching latest version ... " -ForegroundColor green
|
|
55
|
+
|
|
56
|
+
if((Get-CimInstance Win32_operatingsystem).OSArchitecture -like '*ARM*') {
|
|
57
|
+
Invoke-WebRequest -Uri $GITHUB_arm64_URL -OutFile $APPWRITE_DOWNLOAD_DIR
|
|
58
|
+
} else {
|
|
59
|
+
Invoke-WebRequest -Uri $GITHUB_x64_URL -OutFile $APPWRITE_DOWNLOAD_DIR
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Move-Item $APPWRITE_DOWNLOAD_DIR $APPWRITE_INSTALL_DIR
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
function Install {
|
|
68
|
+
Write-Host "[3/4] Starting installation ..."
|
|
69
|
+
|
|
70
|
+
if ($USER_PATH_ENV_VAR -like '*Appwrite*') {
|
|
71
|
+
Write-Host "Skipping to add Appwrite to User Path."
|
|
72
|
+
} else {
|
|
73
|
+
[System.Environment]::SetEnvironmentVariable("PATH", $USER_PATH_ENV_VAR + ";$APPWRITE_INSTALL_DIR", "User")
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function CleanUp {
|
|
78
|
+
Write-Host "Cleaning up mess ..."
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function InstallCompleted {
|
|
82
|
+
Write-Host "[4/4] Finishing Installation ... "
|
|
83
|
+
cleanup
|
|
84
|
+
Write-Host "🤘 May the force be with you."
|
|
85
|
+
Write-Host "To get started with Appwrite CLI, please visit https://appwrite.io/docs/command-line"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
Greeting
|
|
90
|
+
CheckSystemInfo
|
|
91
|
+
DownloadBinary
|
|
92
|
+
Install
|
|
93
|
+
CleanUp
|
|
94
|
+
InstallCompleted
|
package/install.sh
CHANGED
|
@@ -97,15 +97,7 @@ printSuccess() {
|
|
|
97
97
|
downloadBinary() {
|
|
98
98
|
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
res=$(curl -L -s -H 'Accept: application/json' https://github.com/$GITHUB_REPOSITORY_NAME/releases/latest)
|
|
102
|
-
if [[ "$res" == *"error"* ]]; then
|
|
103
|
-
printf "${RED}❌ There was an error. Try again later.${NC} \n"
|
|
104
|
-
exit 1
|
|
105
|
-
fi
|
|
106
|
-
printSuccess
|
|
107
|
-
|
|
108
|
-
GITHUB_LATEST_VERSION=$( echo $res | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
|
|
100
|
+
GITHUB_LATEST_VERSION="0.15.0"
|
|
109
101
|
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
|
|
110
102
|
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
|
|
111
103
|
|
package/lib/client.js
CHANGED
|
@@ -11,9 +11,9 @@ class Client {
|
|
|
11
11
|
this.endpoint = 'https://HOSTNAME/v1';
|
|
12
12
|
this.headers = {
|
|
13
13
|
'content-type': '',
|
|
14
|
-
'x-sdk-version': 'appwrite:cli:0.
|
|
15
|
-
'User-Agent' : `AppwriteCLI/0.
|
|
16
|
-
'X-Appwrite-Response-Format' : '0.
|
|
14
|
+
'x-sdk-version': 'appwrite:cli:0.15.0',
|
|
15
|
+
'User-Agent' : `AppwriteCLI/0.15.0 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
16
|
+
'X-Appwrite-Response-Format' : '0.13.0',
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -151,7 +151,7 @@ class Client {
|
|
|
151
151
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
headers = Object.assign(this.headers, headers);
|
|
154
|
+
headers = Object.assign({}, this.headers, headers);
|
|
155
155
|
|
|
156
156
|
let contentType = headers["content-type"].toLowerCase();
|
|
157
157
|
|
package/lib/commands/account.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/lib/commands/avatars.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/lib/commands/database.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/lib/commands/deploy.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -261,7 +261,7 @@ const functionsListDeployments = async ({ functionId, search, limit, offset, cur
|
|
|
261
261
|
const functionsCreateDeployment = async ({ functionId, entrypoint, code, activate, parseOutput = true, sdk = undefined, onProgress = () => {}}) => {
|
|
262
262
|
/* @param {string} functionId */
|
|
263
263
|
/* @param {string} entrypoint */
|
|
264
|
-
/* @param {
|
|
264
|
+
/* @param {string} code */
|
|
265
265
|
/* @param {boolean} activate */
|
|
266
266
|
|
|
267
267
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
@@ -276,7 +276,14 @@ const functionsCreateDeployment = async ({ functionId, entrypoint, code, activat
|
|
|
276
276
|
let folderPath = fs.realpathSync(code);
|
|
277
277
|
if (!fs.lstatSync(folderPath).isDirectory())
|
|
278
278
|
throw new Error('The path is not a directory.');
|
|
279
|
-
|
|
279
|
+
|
|
280
|
+
await tar
|
|
281
|
+
.create({
|
|
282
|
+
gzip: true,
|
|
283
|
+
sync: true,
|
|
284
|
+
cwd: folderPath,
|
|
285
|
+
file: 'code.tar.gz'
|
|
286
|
+
}, ['./'])
|
|
280
287
|
let archivePath = fs.realpathSync('code.tar.gz')
|
|
281
288
|
if (typeof archivePath !== 'undefined') {
|
|
282
289
|
payload['code'] = archivePath;
|
|
@@ -326,7 +333,13 @@ const functionsCreateDeployment = async ({ functionId, entrypoint, code, activat
|
|
|
326
333
|
}
|
|
327
334
|
|
|
328
335
|
if (onProgress !== null) {
|
|
329
|
-
|
|
336
|
+
onProgress({
|
|
337
|
+
$id: response['$id'],
|
|
338
|
+
progress: Math.min((counter+1) * libClient.CHUNK_SIZE, size) / size * 100,
|
|
339
|
+
sizeUploaded: end+1,
|
|
340
|
+
chunksTotal: response['chunksTotal'],
|
|
341
|
+
chunksUploaded: response['chunksUploaded']
|
|
342
|
+
});
|
|
330
343
|
}
|
|
331
344
|
}
|
|
332
345
|
}
|
|
@@ -557,7 +570,7 @@ functions
|
|
|
557
570
|
|
|
558
571
|
functions
|
|
559
572
|
.command(`listRuntimes`)
|
|
560
|
-
.description(`Get a list of all runtimes that are currently active
|
|
573
|
+
.description(`Get a list of all runtimes that are currently active on your instance.`)
|
|
561
574
|
.action(actionRunner(functionsListRuntimes))
|
|
562
575
|
|
|
563
576
|
functions
|
package/lib/commands/health.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/lib/commands/init.js
CHANGED
|
@@ -100,7 +100,6 @@ const initFunction = async () => {
|
|
|
100
100
|
path: `functions/${answers.name}`,
|
|
101
101
|
entrypoint: answers.runtime.entrypoint || '',
|
|
102
102
|
execute: response.execute,
|
|
103
|
-
vars: response.vars,
|
|
104
103
|
events: response.events,
|
|
105
104
|
schedule: response.schedule,
|
|
106
105
|
timeout: response.timeout,
|
package/lib/commands/locale.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/lib/commands/projects.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/lib/commands/storage.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -269,7 +269,7 @@ const storageListFiles = async ({ bucketId, search, limit, offset, cursor, curso
|
|
|
269
269
|
const storageCreateFile = async ({ bucketId, fileId, file, read, write, parseOutput = true, sdk = undefined, onProgress = () => {}}) => {
|
|
270
270
|
/* @param {string} bucketId */
|
|
271
271
|
/* @param {string} fileId */
|
|
272
|
-
/* @param {
|
|
272
|
+
/* @param {string} file */
|
|
273
273
|
/* @param {string[]} read */
|
|
274
274
|
/* @param {string[]} write */
|
|
275
275
|
|
|
@@ -335,7 +335,13 @@ const storageCreateFile = async ({ bucketId, fileId, file, read, write, parseOut
|
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
if (onProgress !== null) {
|
|
338
|
-
|
|
338
|
+
onProgress({
|
|
339
|
+
$id: response['$id'],
|
|
340
|
+
progress: Math.min((counter+1) * libClient.CHUNK_SIZE, size) / size * 100,
|
|
341
|
+
sizeUploaded: end+1,
|
|
342
|
+
chunksTotal: response['chunksTotal'],
|
|
343
|
+
chunksUploaded: response['chunksUploaded']
|
|
344
|
+
});
|
|
339
345
|
}
|
|
340
346
|
}
|
|
341
347
|
}
|
|
@@ -440,7 +446,7 @@ const storageGetFileDownload = async ({ bucketId, fileId, parseOutput = true, sd
|
|
|
440
446
|
}
|
|
441
447
|
}
|
|
442
448
|
|
|
443
|
-
const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, parseOutput = true, sdk = undefined}) => {
|
|
449
|
+
const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, parseOutput = true, sdk = undefined, destination}) => {
|
|
444
450
|
/* @param {string} bucketId */
|
|
445
451
|
/* @param {string} fileId */
|
|
446
452
|
/* @param {number} width */
|
|
@@ -493,16 +499,21 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
493
499
|
if (typeof output !== 'undefined') {
|
|
494
500
|
payload['output'] = output;
|
|
495
501
|
}
|
|
496
|
-
|
|
497
|
-
|
|
502
|
+
payload['project'] = localConfig.getProject().projectId
|
|
503
|
+
payload['key'] = globalConfig.getKey();
|
|
504
|
+
const queryParams = new URLSearchParams(payload);
|
|
505
|
+
path = `${globalConfig.getEndpoint()}${path}?${queryParams.toString()}`;
|
|
506
|
+
|
|
507
|
+
const response = await client.call('get', path, {
|
|
498
508
|
'content-type': 'application/json',
|
|
499
|
-
}, payload);
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
509
|
+
}, payload, 'arraybuffer');
|
|
510
|
+
|
|
511
|
+
fs.writeFileSync(destination, response);
|
|
512
|
+
|
|
513
|
+
if (parseOutput) {
|
|
514
|
+
log(`File stored in ${destination}`)
|
|
503
515
|
success()
|
|
504
516
|
}
|
|
505
|
-
return response;
|
|
506
517
|
}
|
|
507
518
|
|
|
508
519
|
const storageGetFileView = async ({ bucketId, fileId, parseOutput = true, sdk = undefined, destination}) => {
|
|
@@ -699,6 +710,7 @@ storage
|
|
|
699
710
|
.option(`--rotation <rotation>`, `Preview image rotation in degrees. Pass an integer between -360 and 360.`, parseInteger)
|
|
700
711
|
.option(`--background <background>`, `Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.`)
|
|
701
712
|
.option(`--output <output>`, `Output format type (jpeg, jpg, png, gif and webp).`)
|
|
713
|
+
.requiredOption(`--destination <path>`, `output file path.`)
|
|
702
714
|
.action(actionRunner(storageGetFilePreview))
|
|
703
715
|
|
|
704
716
|
storage
|
package/lib/commands/teams.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/lib/commands/users.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const tar = require("tar");
|
|
2
3
|
const { promisify } = require('util');
|
|
3
4
|
const libClient = require('../client.js');
|
|
4
|
-
const childProcess = require('child_process');
|
|
5
5
|
const { Command } = require('commander');
|
|
6
6
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
7
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "appwrite-cli",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.15.0",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"cli-table3": "^0.6.1",
|
|
28
28
|
"commander": "^8.3.0",
|
|
29
29
|
"form-data": "^4.0.0",
|
|
30
|
-
"inquirer": "^8.2.0"
|
|
30
|
+
"inquirer": "^8.2.0",
|
|
31
|
+
"tar": "^6.1.11"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"pkg": "5.5.1"
|