appwrite-cli 1.0.0 → 1.1.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.
- package/README.md +4 -4
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/deploy.js +60 -16
- package/lib/commands/init.js +1 -1
- package/lib/questions.js +7 -2
- package/package.json +1 -1
- package/appwrite.json +0 -4
- package/docs/examples/account/get-logs.md +0 -2
- package/docs/examples/account/get-sessions.md +0 -1
- package/docs/examples/locale/get-continents.md +0 -1
- package/docs/examples/locale/get-countries-e-u.md +0 -1
- package/docs/examples/locale/get-countries-phones.md +0 -1
- package/docs/examples/locale/get-countries.md +0 -1
- package/docs/examples/locale/get-currencies.md +0 -1
- package/docs/examples/locale/get-languages.md +0 -1
- package/docs/examples/teams/get-memberships.md +0 -4
- package/docs/examples/users/get-logs.md +0 -3
- package/docs/examples/users/get-memberships.md +0 -2
- package/docs/examples/users/get-sessions.md +0 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://twitter.com/appwrite)
|
|
7
7
|
[](https://appwrite.io/discord)
|
|
8
8
|
|
|
9
|
-
**This SDK is compatible with Appwrite server version 1.0.
|
|
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).**
|
|
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.
|
|
32
|
+
1.1.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.
|
|
61
|
+
1.1.1
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## Getting Started
|
|
@@ -161,7 +161,7 @@ $ appwrite users list
|
|
|
161
161
|
|
|
162
162
|
To create a document you can use the following command
|
|
163
163
|
```sh
|
|
164
|
-
$ appwrite database createDocument --collectionId <ID> --documentId 'unique()' --data '{ "Name": "Iron Man" }' --read
|
|
164
|
+
$ appwrite database createDocument --collectionId <ID> --documentId 'unique()' --data '{ "Name": "Iron Man" }' --permissions 'read("any")' 'read("team:abc")'
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
### Some Gotchas
|
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.
|
|
17
|
-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.
|
|
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"
|
|
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.
|
|
100
|
+
GITHUB_LATEST_VERSION="1.1.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.
|
|
19
|
-
'user-agent' : `AppwriteCLI/1.
|
|
18
|
+
'x-sdk-version': '1.1.1',
|
|
19
|
+
'user-agent' : `AppwriteCLI/1.1.1 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
20
20
|
'X-Appwrite-Response-Format' : '1.0.0',
|
|
21
21
|
};
|
|
22
22
|
}
|
package/lib/commands/deploy.js
CHANGED
|
@@ -2,9 +2,9 @@ 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 } = require("../questions");
|
|
5
|
+
const { questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections, questionsConfirmDeployCollections } = require("../questions");
|
|
6
6
|
const { actionRunner, success, log, error, commandDescriptions } = require("../parser");
|
|
7
|
-
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsUpdateDeployment } = require('./functions');
|
|
7
|
+
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsUpdateDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
|
|
8
8
|
const {
|
|
9
9
|
databasesGet,
|
|
10
10
|
databasesCreate,
|
|
@@ -39,7 +39,7 @@ const awaitPools = {
|
|
|
39
39
|
const { attributes: remoteAttributes } = await databasesListAttributes({
|
|
40
40
|
databaseId,
|
|
41
41
|
collectionId,
|
|
42
|
-
|
|
42
|
+
queries: [ 'limit(100)' ],
|
|
43
43
|
parseOutput: false
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -59,7 +59,7 @@ const awaitPools = {
|
|
|
59
59
|
const { indexes: remoteIndexes } = await databasesListIndexes({
|
|
60
60
|
databaseId,
|
|
61
61
|
collectionId,
|
|
62
|
-
|
|
62
|
+
queries: [ 'limit(100)' ],
|
|
63
63
|
parseOutput: false
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -79,7 +79,7 @@ const awaitPools = {
|
|
|
79
79
|
const { attributes: remoteAttributes } = await databasesListAttributes({
|
|
80
80
|
databaseId,
|
|
81
81
|
collectionId,
|
|
82
|
-
|
|
82
|
+
queries: [ 'limit(100)' ],
|
|
83
83
|
parseOutput: false
|
|
84
84
|
});
|
|
85
85
|
|
|
@@ -111,7 +111,7 @@ const awaitPools = {
|
|
|
111
111
|
const { indexes: remoteIndexes } = await databasesListIndexes({
|
|
112
112
|
databaseId,
|
|
113
113
|
collectionId,
|
|
114
|
-
|
|
114
|
+
queries: [ 'limit(100)' ],
|
|
115
115
|
parseOutput: false
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -142,7 +142,7 @@ const deploy = new Command("deploy")
|
|
|
142
142
|
command.help()
|
|
143
143
|
}));
|
|
144
144
|
|
|
145
|
-
const deployFunction = async ({ functionId, all } = {}) => {
|
|
145
|
+
const deployFunction = async ({ functionId, all, yes } = {}) => {
|
|
146
146
|
let response = {};
|
|
147
147
|
|
|
148
148
|
const functionIds = [];
|
|
@@ -160,7 +160,7 @@ const deployFunction = async ({ functionId, all } = {}) => {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
if(functionIds.length <= 0) {
|
|
163
|
-
const answers = await inquirer.prompt(questionsDeployFunctions);
|
|
163
|
+
const answers = await inquirer.prompt(questionsDeployFunctions[0]);
|
|
164
164
|
functionIds.push(...answers.functions);
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -188,6 +188,46 @@ const deployFunction = async ({ functionId, all } = {}) => {
|
|
|
188
188
|
throw new Error(`Runtime missmatch! (local=${func.runtime},remote=${response.runtime}) Please delete remote function or update your appwrite.json`);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
if(func.variables) {
|
|
192
|
+
// Delete existing variables
|
|
193
|
+
|
|
194
|
+
// TODO: Pagination?
|
|
195
|
+
const { variables: remoteVariables } = await functionsListVariables({
|
|
196
|
+
functionId: func['$id'],
|
|
197
|
+
queries: [ 'limit(100)' ],
|
|
198
|
+
parseOutput: false
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if(remoteVariables.length > 0) {
|
|
202
|
+
if(!yes) {
|
|
203
|
+
const variableAnswers = await inquirer.prompt(questionsDeployFunctions[1])
|
|
204
|
+
|
|
205
|
+
if (variableAnswers.override !== "YES") {
|
|
206
|
+
log(`Received "${variableAnswers.override}". Skipping ${func.name} ( ${func['$id']} )`);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
await Promise.all(remoteVariables.map(async remoteVariable => {
|
|
212
|
+
await functionsDeleteVariable({
|
|
213
|
+
functionId: func['$id'],
|
|
214
|
+
variableId: remoteVariable['$id'],
|
|
215
|
+
parseOutput: false
|
|
216
|
+
});
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Deploy local variables
|
|
221
|
+
await Promise.all(Object.keys(func.variables).map(async localVariableKey => {
|
|
222
|
+
await functionsCreateVariable({
|
|
223
|
+
functionId: func['$id'],
|
|
224
|
+
key: localVariableKey,
|
|
225
|
+
value: func.variables[localVariableKey],
|
|
226
|
+
parseOutput: false
|
|
227
|
+
});
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
|
|
191
231
|
response = await functionsUpdate({
|
|
192
232
|
functionId: func['$id'],
|
|
193
233
|
name: func.name,
|
|
@@ -359,7 +399,7 @@ const createAttribute = async (databaseId, collectionId, attribute) => {
|
|
|
359
399
|
}
|
|
360
400
|
}
|
|
361
401
|
|
|
362
|
-
const deployCollection = async ({ all } = {}) => {
|
|
402
|
+
const deployCollection = async ({ all, yes } = {}) => {
|
|
363
403
|
let response = {};
|
|
364
404
|
|
|
365
405
|
let collectionIds = [];
|
|
@@ -413,10 +453,12 @@ const deployCollection = async ({ all } = {}) => {
|
|
|
413
453
|
})
|
|
414
454
|
log(`Collection ${collection.name} ( ${collection['$id']} ) already exists.`);
|
|
415
455
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
456
|
+
if(!yes) {
|
|
457
|
+
answers = await inquirer.prompt(questionsDeployCollections[1])
|
|
458
|
+
if (answers.override !== "YES") {
|
|
459
|
+
log(`Received "${answers.override}". Skipping ${collection.name} ( ${collection['$id']} )`);
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
420
462
|
}
|
|
421
463
|
|
|
422
464
|
log(`Updating attributes ... `);
|
|
@@ -425,7 +467,7 @@ const deployCollection = async ({ all } = {}) => {
|
|
|
425
467
|
const { indexes: remoteIndexes } = await databasesListIndexes({
|
|
426
468
|
databaseId,
|
|
427
469
|
collectionId: collection['$id'],
|
|
428
|
-
|
|
470
|
+
queries: [ 'limit(100)' ],
|
|
429
471
|
parseOutput: false
|
|
430
472
|
});
|
|
431
473
|
|
|
@@ -447,7 +489,7 @@ const deployCollection = async ({ all } = {}) => {
|
|
|
447
489
|
const { attributes: remoteAttributes } = await databasesListAttributes({
|
|
448
490
|
databaseId,
|
|
449
491
|
collectionId: collection['$id'],
|
|
450
|
-
|
|
492
|
+
queries: [ 'limit(100)' ],
|
|
451
493
|
parseOutput: false
|
|
452
494
|
});
|
|
453
495
|
|
|
@@ -505,7 +547,7 @@ const deployCollection = async ({ all } = {}) => {
|
|
|
505
547
|
collectionId: collection['$id'],
|
|
506
548
|
name: collection.name,
|
|
507
549
|
documentSecurity: collection.documentSecurity,
|
|
508
|
-
|
|
550
|
+
permissions: collection['$permissions'],
|
|
509
551
|
parseOutput: false
|
|
510
552
|
})
|
|
511
553
|
|
|
@@ -556,12 +598,14 @@ deploy
|
|
|
556
598
|
.description("Deploy functions in the current directory.")
|
|
557
599
|
.option(`--functionId <functionId>`, `Function ID`)
|
|
558
600
|
.option(`--all`, `Flag to deploy all functions`)
|
|
601
|
+
.option(`--yes`, `Flag to confirm all warnings`)
|
|
559
602
|
.action(actionRunner(deployFunction));
|
|
560
603
|
|
|
561
604
|
deploy
|
|
562
605
|
.command("collection")
|
|
563
606
|
.description("Deploy collections in the current project.")
|
|
564
607
|
.option(`--all`, `Flag to deploy all functions`)
|
|
608
|
+
.option(`--yes`, `Flag to confirm all warnings`)
|
|
565
609
|
.action(actionRunner(deployCollection));
|
|
566
610
|
|
|
567
611
|
module.exports = {
|
package/lib/commands/init.js
CHANGED
package/lib/questions.js
CHANGED
|
@@ -113,7 +113,7 @@ const questionsInitProject = [
|
|
|
113
113
|
type: "input",
|
|
114
114
|
name: "id",
|
|
115
115
|
message: "What ID would you like to have for your project?",
|
|
116
|
-
default: "
|
|
116
|
+
default: "unique()",
|
|
117
117
|
when(answers) {
|
|
118
118
|
return answers.start == "new";
|
|
119
119
|
},
|
|
@@ -251,7 +251,12 @@ const questionsDeployFunctions = [
|
|
|
251
251
|
})
|
|
252
252
|
return choices;
|
|
253
253
|
}
|
|
254
|
-
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
type: "input",
|
|
257
|
+
name: "override",
|
|
258
|
+
message: 'Are you sure you want to override this function\'s variables? This can lead to loss of secrets! Type "YES" to confirm.'
|
|
259
|
+
},
|
|
255
260
|
]
|
|
256
261
|
|
|
257
262
|
const questionsDeployCollections = [
|
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": "1.
|
|
5
|
+
"version": "1.1.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
package/appwrite.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite account getSessions
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite locale getContinents
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite locale getCountriesEU
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite locale getCountriesPhones
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite locale getCountries
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite locale getCurrencies
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite locale getLanguages
|