appwrite-cli 0.15.0 → 0.17.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/.github/workflows/npm-publish.yml +0 -1
- package/README.md +4 -4
- package/docs/examples/account/update-status.md +1 -0
- package/docs/examples/teams/list-logs.md +4 -0
- package/docs/examples/users/get-memberships.md +2 -0
- package/install.ps1 +9 -5
- package/install.sh +1 -1
- package/lib/client.js +6 -7
- package/lib/commands/account.js +32 -29
- package/lib/commands/avatars.js +13 -10
- package/lib/commands/database.js +15 -12
- package/lib/commands/deploy.js +5 -4
- package/lib/commands/functions.js +66 -41
- package/lib/commands/generic.js +11 -4
- package/lib/commands/health.js +4 -24
- package/lib/commands/init.js +1 -0
- package/lib/commands/locale.js +4 -1
- package/lib/commands/projects.js +8 -5
- package/lib/commands/storage.js +50 -36
- package/lib/commands/teams.js +44 -4
- package/lib/commands/users.js +32 -4
- package/lib/config.js +6 -4
- package/lib/questions.js +44 -3
- package/lib/sdks.js +17 -1
- package/lib/utils.js +19 -0
- package/package.json +8 -6
package/lib/config.js
CHANGED
|
@@ -2,6 +2,7 @@ const os = require('os');
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const _path = require("path");
|
|
4
4
|
const process = require("process");
|
|
5
|
+
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
5
6
|
|
|
6
7
|
class Config {
|
|
7
8
|
constructor(path) {
|
|
@@ -11,7 +12,8 @@ class Config {
|
|
|
11
12
|
|
|
12
13
|
read() {
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
+
const file = fs.readFileSync(this.path).toString();
|
|
16
|
+
this.data = JSONbig.parse(file);
|
|
15
17
|
} catch (e) {
|
|
16
18
|
// console.log(`${this.path} not found. Empty data`);
|
|
17
19
|
this.data = {};
|
|
@@ -23,7 +25,7 @@ class Config {
|
|
|
23
25
|
if (!fs.existsSync(dir)){
|
|
24
26
|
fs.mkdirSync(dir, { recursive: true });
|
|
25
27
|
}
|
|
26
|
-
fs.writeFileSync(this.path,
|
|
28
|
+
fs.writeFileSync(this.path, JSONbig.stringify(this.data, null, 4));
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
get(key) {
|
|
@@ -46,7 +48,7 @@ class Config {
|
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
has(key) {
|
|
49
|
-
return this.data
|
|
51
|
+
return this.data[key] !== undefined;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
keys() {
|
|
@@ -58,7 +60,7 @@ class Config {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
toString() {
|
|
61
|
-
return
|
|
63
|
+
return JSONbig.stringify(this.data, null, 4);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|
package/lib/questions.js
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
const { localConfig } = require('./config');
|
|
2
2
|
const { projectsList } = require('./commands/projects');
|
|
3
3
|
const { functionsListRuntimes } = require('./commands/functions');
|
|
4
|
+
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
5
|
+
|
|
6
|
+
const getIgnores = (runtime) => {
|
|
7
|
+
const languge = runtime.split('-')[0];
|
|
8
|
+
|
|
9
|
+
switch (languge) {
|
|
10
|
+
case 'cpp':
|
|
11
|
+
return ['build', 'CMakeFiles', 'CMakeCaches.txt'];
|
|
12
|
+
case 'dart':
|
|
13
|
+
return ['.packages', '.dart_tool'];
|
|
14
|
+
case 'deno':
|
|
15
|
+
return [];
|
|
16
|
+
case 'dotnet':
|
|
17
|
+
return ['bin', 'obj', '.nuget'];
|
|
18
|
+
case 'java':
|
|
19
|
+
case 'kotlin':
|
|
20
|
+
return ['build'];
|
|
21
|
+
case 'node':
|
|
22
|
+
return ['node_modules', '.npm'];
|
|
23
|
+
case 'php':
|
|
24
|
+
return ['vendor'];
|
|
25
|
+
case 'python':
|
|
26
|
+
return ['__pypackages__'];
|
|
27
|
+
case 'ruby':
|
|
28
|
+
return ['vendor'];
|
|
29
|
+
case 'rust':
|
|
30
|
+
return ['target', 'debug', '*.rs.bk', '*.pdb'];
|
|
31
|
+
case 'swift':
|
|
32
|
+
return ['.build', '.swiftpm'];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return undefined;
|
|
36
|
+
};
|
|
4
37
|
|
|
5
38
|
const getEntrypoint = (runtime) => {
|
|
6
39
|
const languge = runtime.split('-')[0];
|
|
@@ -22,6 +55,14 @@ const getEntrypoint = (runtime) => {
|
|
|
22
55
|
return 'main.rs';
|
|
23
56
|
case 'swift':
|
|
24
57
|
return 'Sources/swift-5.5/main.swift';
|
|
58
|
+
case 'cpp':
|
|
59
|
+
return 'src/index.cc';
|
|
60
|
+
case 'dotnet':
|
|
61
|
+
return 'src/Index.cs';
|
|
62
|
+
case 'java':
|
|
63
|
+
return 'src/Index.java';
|
|
64
|
+
case 'kotlin':
|
|
65
|
+
return 'src/Index.kt';
|
|
25
66
|
}
|
|
26
67
|
|
|
27
68
|
return undefined;
|
|
@@ -117,7 +158,7 @@ const questionsInitFunction = [
|
|
|
117
158
|
let choices = runtimes.map((runtime, idx) => {
|
|
118
159
|
return {
|
|
119
160
|
name: `${runtime.name} (${runtime['$id']})`,
|
|
120
|
-
value: { id: runtime['$id'], entrypoint: getEntrypoint(runtime['$id'])}
|
|
161
|
+
value: { id: runtime['$id'], entrypoint: getEntrypoint(runtime['$id']), ignore: getIgnores(runtime['$id'])},
|
|
121
162
|
}
|
|
122
163
|
})
|
|
123
164
|
return choices;
|
|
@@ -164,7 +205,7 @@ const questionsDeployFunctions = [
|
|
|
164
205
|
let choices = functions.map((func, idx) => {
|
|
165
206
|
return {
|
|
166
207
|
name: `${func.name} (${func['$id']})`,
|
|
167
|
-
value: func
|
|
208
|
+
value: JSONbig.stringify(func)
|
|
168
209
|
}
|
|
169
210
|
})
|
|
170
211
|
return choices;
|
|
@@ -185,7 +226,7 @@ const questionsDeployCollections = [
|
|
|
185
226
|
let choices = collections.map((collection, idx) => {
|
|
186
227
|
return {
|
|
187
228
|
name: `${collection.name} (${collection['$id']})`,
|
|
188
|
-
value: collection
|
|
229
|
+
value: JSONbig.stringify(collection)
|
|
189
230
|
}
|
|
190
231
|
})
|
|
191
232
|
return choices;
|
package/lib/sdks.js
CHANGED
|
@@ -7,7 +7,23 @@ const questionGetEndpoint = [
|
|
|
7
7
|
type: "input",
|
|
8
8
|
name: "endpoint",
|
|
9
9
|
message: "Enter the endpoint of your Appwrite server",
|
|
10
|
-
default: "http://localhost/v1"
|
|
10
|
+
default: "http://localhost/v1",
|
|
11
|
+
async validate(value) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return "Please enter a valid endpoint.";
|
|
14
|
+
}
|
|
15
|
+
let client = new Client().setEndpoint(value);
|
|
16
|
+
try {
|
|
17
|
+
let response = await client.call('get', '/health/version');
|
|
18
|
+
if (response.version) {
|
|
19
|
+
return true;
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error();
|
|
22
|
+
}
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return "Invalid endpoint or your Appwrite server is not running as expected.";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
11
27
|
}
|
|
12
28
|
]
|
|
13
29
|
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
function getAllFiles(folder) {
|
|
5
|
+
const files = [];
|
|
6
|
+
for(const pathDir of fs.readdirSync(folder)) {
|
|
7
|
+
const pathAbsolute = path.join(folder, pathDir);
|
|
8
|
+
if (fs.statSync(pathAbsolute).isDirectory()) {
|
|
9
|
+
files.push(...getAllFiles(pathAbsolute));
|
|
10
|
+
} else {
|
|
11
|
+
files.push(pathAbsolute);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return files;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
getAllFiles
|
|
19
|
+
};
|
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.17.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
|
@@ -22,13 +22,15 @@
|
|
|
22
22
|
"windows-arm64": "pkg -t node16-win-arm64 -o build/appwrite-cli-win-arm64.exe package.json"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"axios": "^0.
|
|
25
|
+
"axios": "^0.27.2",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
|
-
"cli-table3": "^0.6.
|
|
28
|
-
"commander": "^
|
|
27
|
+
"cli-table3": "^0.6.2",
|
|
28
|
+
"commander": "^9.2.0",
|
|
29
29
|
"form-data": "^4.0.0",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"json-bigint": "^1.0.0",
|
|
31
|
+
"inquirer": "^8.2.4",
|
|
32
|
+
"tar": "^6.1.11",
|
|
33
|
+
"ignore": "^5.2.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"pkg": "5.5.1"
|