appwrite-cli 6.0.0-rc.1 → 6.0.0-rc.3
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 +2 -2
- package/index.js +2 -1
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +4 -4
- package/lib/commands/generic.js +17 -5
- package/lib/commands/init.js +26 -15
- package/lib/commands/pull.js +147 -68
- package/lib/commands/push.js +74 -150
- package/lib/commands/run.js +53 -45
- package/lib/config.js +73 -20
- package/lib/emulation/docker.js +70 -62
- package/lib/emulation/utils.js +15 -6
- package/lib/parser.js +16 -6
- package/lib/questions.js +56 -21
- package/lib/sdks.js +1 -39
- package/package.json +1 -1
- package/scoop/appwrite.json +3 -3
package/lib/parser.js
CHANGED
|
@@ -131,7 +131,7 @@ const parseError = (err) => {
|
|
|
131
131
|
} catch {
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const version = '6.0.0-rc.
|
|
134
|
+
const version = '6.0.0-rc.3';
|
|
135
135
|
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
|
|
136
136
|
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`;
|
|
137
137
|
|
|
@@ -189,15 +189,23 @@ const parseBool = (value) => {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
const log = (message) => {
|
|
192
|
-
console.log(`${chalk.cyan.bold("ℹ Info")} ${chalk.cyan(message ?? "")}`);
|
|
192
|
+
console.log(`${chalk.cyan.bold("ℹ Info:")} ${chalk.cyan(message ?? "")}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const warn = (message) => {
|
|
196
|
+
console.log(`${chalk.yellow.bold("ℹ Warning:")} ${chalk.yellow(message ?? "")}`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const hint = (message) => {
|
|
200
|
+
console.log(`${chalk.cyan.bold("♥ Hint:")} ${chalk.cyan(message ?? "")}`);
|
|
193
201
|
}
|
|
194
202
|
|
|
195
203
|
const success = (message) => {
|
|
196
|
-
console.log(`${chalk.green.bold("✓ Success")} ${chalk.green(message ?? "")}`);
|
|
204
|
+
console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(message ?? "")}`);
|
|
197
205
|
}
|
|
198
206
|
|
|
199
207
|
const error = (message) => {
|
|
200
|
-
console.error(`${chalk.red.bold("✗ Error")} ${chalk.red(message ?? "")}`);
|
|
208
|
+
console.error(`${chalk.red.bold("✗ Error:")} ${chalk.red(message ?? "")}`);
|
|
201
209
|
}
|
|
202
210
|
|
|
203
211
|
const logo = "\n _ _ _ ___ __ _____\n \/_\\ _ __ _ ____ ___ __(_) |_ ___ \/ __\\ \/ \/ \\_ \\\n \/\/_\\\\| '_ \\| '_ \\ \\ \/\\ \/ \/ '__| | __\/ _ \\ \/ \/ \/ \/ \/ \/\\\/\n \/ _ \\ |_) | |_) \\ V V \/| | | | || __\/ \/ \/___\/ \/___\/\\\/ \/_\n \\_\/ \\_\/ .__\/| .__\/ \\_\/\\_\/ |_| |_|\\__\\___| \\____\/\\____\/\\____\/\n |_| |_|\n\n";
|
|
@@ -221,8 +229,8 @@ const commandDescriptions = {
|
|
|
221
229
|
"client": `The client command allows you to configure your CLI`,
|
|
222
230
|
"login": `The login command allows you to authenticate and manage a user account.`,
|
|
223
231
|
"logout": `The logout command allows you to logout of your Appwrite account.`,
|
|
224
|
-
"whoami": `The whoami command gives information about the currently
|
|
225
|
-
"register": `Outputs the link to create an Appwrite account
|
|
232
|
+
"whoami": `The whoami command gives information about the currently signed in user.`,
|
|
233
|
+
"register": `Outputs the link to create an Appwrite account.`,
|
|
226
234
|
"console" : `The console command allows gives you access to the APIs used by the Appwrite console.`,
|
|
227
235
|
"assistant": `The assistant command allows you to interact with the Appwrite Assistant AI`,
|
|
228
236
|
"messaging": `The messaging command allows you to send messages.`,
|
|
@@ -240,6 +248,8 @@ module.exports = {
|
|
|
240
248
|
parseInteger,
|
|
241
249
|
parseBool,
|
|
242
250
|
log,
|
|
251
|
+
warn,
|
|
252
|
+
hint,
|
|
243
253
|
success,
|
|
244
254
|
error,
|
|
245
255
|
commandDescriptions,
|
package/lib/questions.js
CHANGED
|
@@ -46,7 +46,7 @@ const getIgnores = (runtime) => {
|
|
|
46
46
|
return ['.build', '.swiftpm'];
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return [];
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const getEntrypoint = (runtime) => {
|
|
@@ -80,6 +80,8 @@ const getEntrypoint = (runtime) => {
|
|
|
80
80
|
return 'src/Main.java';
|
|
81
81
|
case 'kotlin':
|
|
82
82
|
return 'src/Main.kt';
|
|
83
|
+
case 'go':
|
|
84
|
+
return 'main.go';
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
return undefined;
|
|
@@ -209,18 +211,26 @@ const questionsInitProject = [
|
|
|
209
211
|
when: (answer) => answer.start === 'existing'
|
|
210
212
|
}
|
|
211
213
|
];
|
|
214
|
+
const questionsInitProjectAutopull = [
|
|
215
|
+
{
|
|
216
|
+
type: "confirm",
|
|
217
|
+
name: "autopull",
|
|
218
|
+
message:
|
|
219
|
+
`Would you like to pull all resources from project you just linked?`
|
|
220
|
+
},
|
|
221
|
+
];
|
|
212
222
|
const questionsPullResources = [
|
|
213
223
|
{
|
|
214
224
|
type: "list",
|
|
215
225
|
name: "resource",
|
|
216
226
|
message: "Which resources would you like to pull?",
|
|
217
227
|
choices: [
|
|
218
|
-
{ name:
|
|
219
|
-
{ name:
|
|
220
|
-
{ name:
|
|
221
|
-
{ name:
|
|
222
|
-
{ name:
|
|
223
|
-
{ name:
|
|
228
|
+
{ name: `Settings ${chalk.blackBright(`(Project)`)}`, value: 'settings' },
|
|
229
|
+
{ name: `Functions ${chalk.blackBright(`(Deployment)`)}`, value: 'functions' },
|
|
230
|
+
{ name: `Collections ${chalk.blackBright(`(Databases)`)}`, value: 'collections' },
|
|
231
|
+
{ name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: 'buckets' },
|
|
232
|
+
{ name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: 'teams' },
|
|
233
|
+
{ name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: 'messages' }
|
|
224
234
|
]
|
|
225
235
|
}
|
|
226
236
|
]
|
|
@@ -248,6 +258,14 @@ const questionsPullFunctions = [
|
|
|
248
258
|
}
|
|
249
259
|
];
|
|
250
260
|
|
|
261
|
+
const questionsPullFunctionsCode = [
|
|
262
|
+
{
|
|
263
|
+
type: "confirm",
|
|
264
|
+
name: "override",
|
|
265
|
+
message: "Do you want to pull source code of active deployment?"
|
|
266
|
+
},
|
|
267
|
+
];
|
|
268
|
+
|
|
251
269
|
const questionsCreateFunction = [
|
|
252
270
|
{
|
|
253
271
|
type: "input",
|
|
@@ -283,8 +301,23 @@ const questionsCreateFunction = [
|
|
|
283
301
|
}
|
|
284
302
|
})
|
|
285
303
|
return choices;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
type: "list",
|
|
308
|
+
name: "template",
|
|
309
|
+
message: "How would you like to start your function code?",
|
|
310
|
+
choices: [
|
|
311
|
+
{
|
|
312
|
+
name: `Start from scratch ${chalk.blackBright(`(starter)`)}`,
|
|
313
|
+
value: "starter"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
name: "Pick a template",
|
|
317
|
+
value: "custom"
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
},
|
|
288
321
|
];
|
|
289
322
|
|
|
290
323
|
const questionsCreateFunctionSelectTemplate = (templates) => {
|
|
@@ -451,12 +484,12 @@ const questionsLogin = [
|
|
|
451
484
|
{
|
|
452
485
|
type: "list",
|
|
453
486
|
name: "method",
|
|
454
|
-
message: "
|
|
487
|
+
message: "What you like to do?",
|
|
455
488
|
choices: [
|
|
456
|
-
{ name: 'Login to
|
|
457
|
-
{ name: '
|
|
489
|
+
{ name: 'Login to an account', value: 'login' },
|
|
490
|
+
{ name: 'Switch to an account', value: 'select' }
|
|
458
491
|
],
|
|
459
|
-
when: () => globalConfig.
|
|
492
|
+
when: () => globalConfig.getSessions().length >= 2
|
|
460
493
|
},
|
|
461
494
|
{
|
|
462
495
|
type: "input",
|
|
@@ -570,12 +603,12 @@ const questionsPushResources = [
|
|
|
570
603
|
name: "resource",
|
|
571
604
|
message: "Which resources would you like to push?",
|
|
572
605
|
choices: [
|
|
573
|
-
{ name:
|
|
574
|
-
{ name:
|
|
575
|
-
{ name:
|
|
576
|
-
{ name:
|
|
577
|
-
{ name:
|
|
578
|
-
{ name:
|
|
606
|
+
{ name: `Settings ${chalk.blackBright(`(Project)`)}`, value: 'settings' },
|
|
607
|
+
{ name: `Functions ${chalk.blackBright(`(Deployment)`)}`, value: 'functions' },
|
|
608
|
+
{ name: `Collections ${chalk.blackBright(`(Databases)`)}`, value: 'collections' },
|
|
609
|
+
{ name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: 'buckets' },
|
|
610
|
+
{ name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: 'teams' },
|
|
611
|
+
{ name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: 'messages' }
|
|
579
612
|
]
|
|
580
613
|
}
|
|
581
614
|
];
|
|
@@ -605,7 +638,7 @@ const questionsPushFunctions = [
|
|
|
605
638
|
let functions = localConfig.getFunctions();
|
|
606
639
|
checkDeployConditions(localConfig)
|
|
607
640
|
if (functions.length === 0) {
|
|
608
|
-
throw new Error("No functions found
|
|
641
|
+
throw new Error("No functions found Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
|
|
609
642
|
}
|
|
610
643
|
let choices = functions.map((func, idx) => {
|
|
611
644
|
return {
|
|
@@ -794,7 +827,7 @@ const questionsRunFunctions = [
|
|
|
794
827
|
choices: () => {
|
|
795
828
|
let functions = localConfig.getFunctions();
|
|
796
829
|
if (functions.length === 0) {
|
|
797
|
-
throw new Error("No functions found
|
|
830
|
+
throw new Error("No functions found. Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
|
|
798
831
|
}
|
|
799
832
|
let choices = functions.map((func, idx) => {
|
|
800
833
|
return {
|
|
@@ -809,12 +842,14 @@ const questionsRunFunctions = [
|
|
|
809
842
|
|
|
810
843
|
module.exports = {
|
|
811
844
|
questionsInitProject,
|
|
845
|
+
questionsInitProjectAutopull,
|
|
812
846
|
questionsCreateFunction,
|
|
813
847
|
questionsCreateFunctionSelectTemplate,
|
|
814
848
|
questionsCreateBucket,
|
|
815
849
|
questionsCreateCollection,
|
|
816
850
|
questionsCreateMessagingTopic,
|
|
817
851
|
questionsPullFunctions,
|
|
852
|
+
questionsPullFunctionsCode,
|
|
818
853
|
questionsLogin,
|
|
819
854
|
questionsPullResources,
|
|
820
855
|
questionsLogout,
|
package/lib/sdks.js
CHANGED
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
const inquirer = require("inquirer");
|
|
2
1
|
const Client = require("./client");
|
|
3
2
|
const { globalConfig, localConfig } = require("./config");
|
|
4
3
|
|
|
5
|
-
const questionGetEndpoint = [
|
|
6
|
-
{
|
|
7
|
-
type: "input",
|
|
8
|
-
name: "endpoint",
|
|
9
|
-
message: "Enter the endpoint of your Appwrite server",
|
|
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
|
-
}
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
|
|
30
4
|
const sdkForConsole = async (requiresAuth = true) => {
|
|
31
5
|
let client = new Client();
|
|
32
6
|
let endpoint = globalConfig.getEndpoint();
|
|
33
7
|
let cookie = globalConfig.getCookie()
|
|
34
8
|
let selfSigned = globalConfig.getSelfSigned()
|
|
35
9
|
|
|
36
|
-
if (!endpoint) {
|
|
37
|
-
const answers = await inquirer.prompt(questionGetEndpoint)
|
|
38
|
-
endpoint = answers.endpoint;
|
|
39
|
-
globalConfig.setEndpoint(endpoint);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
10
|
if (requiresAuth && cookie === "") {
|
|
43
11
|
throw new Error("Session not found. Please run `appwrite login` to create a session");
|
|
44
12
|
}
|
|
@@ -61,14 +29,8 @@ const sdkForProject = async () => {
|
|
|
61
29
|
let cookie = globalConfig.getCookie()
|
|
62
30
|
let selfSigned = globalConfig.getSelfSigned()
|
|
63
31
|
|
|
64
|
-
if (!endpoint) {
|
|
65
|
-
const answers = await inquirer.prompt(questionGetEndpoint)
|
|
66
|
-
endpoint = answers.endpoint;
|
|
67
|
-
globalConfig.setEndpoint(endpoint);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
32
|
if (!project) {
|
|
71
|
-
throw new Error("Project is not set. Please run `appwrite init` to initialize the current directory with an Appwrite project.");
|
|
33
|
+
throw new Error("Project is not set. Please run `appwrite init project` to initialize the current directory with an Appwrite project.");
|
|
72
34
|
}
|
|
73
35
|
|
|
74
36
|
client
|
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": "6.0.0-rc.
|
|
5
|
+
"version": "6.0.0-rc.3",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
package/scoop/appwrite.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.3",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.3/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.3/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|