appwrite-cli 6.0.0-rc.1 → 6.0.0-rc.2

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/lib/config.js CHANGED
@@ -4,6 +4,38 @@ const _path = require("path");
4
4
  const process = require("process");
5
5
  const JSONbig = require("json-bigint")({ storeAsString: false });
6
6
 
7
+ const KeysFunction = ["path", "$id", "execute", "name", "enabled", "logging", "runtime", "scopes", "events", "schedule", "timeout", "entrypoint", "commands"];
8
+ const KeysDatabase = ["$id", "name", "enabled"];
9
+ const KeysCollection = ["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"];
10
+ const KeysStorage = ["$id", "$permissions", "fileSecurity", "name", "enabled", "maximumFileSize", "allowedFileExtensions", "compression", "encryption", "antivirus"];
11
+ const KeyTopics = ["$id", "name", "subscribe"];
12
+ const KeyAttributes = ["key", "type", "required", "array", "size", "default"];
13
+ const KeyIndexes = ["key", "type", "status", "attributes", "orders"];
14
+
15
+ function whitelistKeys(value, keys, nestedKeys = []) {
16
+ if(Array.isArray(value)) {
17
+ const newValue = [];
18
+
19
+ for(const item of value) {
20
+ newValue.push(whitelistKeys(item, keys, nestedKeys));
21
+ }
22
+
23
+ return newValue;
24
+ }
25
+
26
+ const newValue = {};
27
+ Object.keys(value).forEach((key) => {
28
+ if(keys.includes(key)) {
29
+ if(nestedKeys[key]) {
30
+ newValue[key] = whitelistKeys(value[key], nestedKeys[key]);
31
+ } else {
32
+ newValue[key] = value[key];
33
+ }
34
+ }
35
+ });
36
+ return newValue;
37
+ }
38
+
7
39
  class Config {
8
40
  constructor(path) {
9
41
  this.path = path;
@@ -94,6 +126,8 @@ class Local extends Config {
94
126
  }
95
127
 
96
128
  addFunction(props) {
129
+ props = whitelistKeys(props, KeysFunction);
130
+
97
131
  if (!this.has("functions")) {
98
132
  this.set("functions", []);
99
133
  }
@@ -101,21 +135,6 @@ class Local extends Config {
101
135
  let functions = this.get("functions");
102
136
  for (let i = 0; i < functions.length; i++) {
103
137
  if (functions[i]['$id'] == props['$id']) {
104
- return;
105
- }
106
- }
107
- functions.push(props);
108
- this.set("functions", functions);
109
- }
110
-
111
- updateFunction(id, props) {
112
- if (!this.has("functions")) {
113
- return;
114
- }
115
-
116
- let functions = this.get("functions");
117
- for (let i = 0; i < functions.length; i++) {
118
- if (functions[i]['$id'] == id) {
119
138
  functions[i] = {
120
139
  ...functions[i],
121
140
  ...props
@@ -124,6 +143,9 @@ class Local extends Config {
124
143
  return;
125
144
  }
126
145
  }
146
+
147
+ functions.push(props);
148
+ this.set("functions", functions);
127
149
  }
128
150
 
129
151
  getCollections() {
@@ -149,6 +171,11 @@ class Local extends Config {
149
171
  }
150
172
 
151
173
  addCollection(props) {
174
+ props = whitelistKeys(props, KeysCollection, {
175
+ attributes: KeyAttributes,
176
+ indexes: KeyIndexes
177
+ });
178
+
152
179
  if (!this.has("collections")) {
153
180
  this.set("collections", []);
154
181
  }
@@ -188,6 +215,8 @@ class Local extends Config {
188
215
  }
189
216
 
190
217
  addBucket(props) {
218
+ props = whitelistKeys(props, KeysStorage);
219
+
191
220
  if (!this.has("buckets")) {
192
221
  this.set("buckets", []);
193
222
  }
@@ -227,6 +256,8 @@ class Local extends Config {
227
256
  }
228
257
 
229
258
  addMessagingTopic(props) {
259
+ props = whitelistKeys(props, KeyTopics);
260
+
230
261
  if (!this.has("topics")) {
231
262
  this.set("topics", []);
232
263
  }
@@ -266,6 +297,8 @@ class Local extends Config {
266
297
  }
267
298
 
268
299
  addDatabase(props) {
300
+ props = whitelistKeys(props, KeysDatabase);
301
+
269
302
  if (!this.has("databases")) {
270
303
  this.set("databases", []);
271
304
  }
@@ -329,7 +362,7 @@ class Local extends Config {
329
362
  return {
330
363
  projectId: this.get("projectId"),
331
364
  projectName: this.get("projectName"),
332
- projectSettings: this.get('projectSettings')
365
+ projectSettings: this.get('settings')
333
366
  };
334
367
  }
335
368
 
@@ -357,7 +390,6 @@ class Local extends Config {
357
390
  functions: projectSettings.serviceStatusForFunctions,
358
391
  graphql: projectSettings.serviceStatusForGraphql,
359
392
  messaging: projectSettings.serviceStatusForMessaging,
360
-
361
393
  },
362
394
  auth: {
363
395
  methods: {
@@ -380,7 +412,7 @@ class Local extends Config {
380
412
  }
381
413
  };
382
414
 
383
- this.set('projectSettings', settings)
415
+ this.set('settings', settings)
384
416
  }
385
417
 
386
418
  }
@@ -520,7 +552,7 @@ class Global extends Config {
520
552
  const current = this.getCurrentSession();
521
553
 
522
554
  if (current) {
523
- const config = this.get(current);
555
+ const config = this.get(current) ?? {};
524
556
 
525
557
  return config[key] !== undefined;
526
558
  }
@@ -530,7 +562,7 @@ class Global extends Config {
530
562
  const current = this.getCurrentSession();
531
563
 
532
564
  if (current) {
533
- const config = this.get(current);
565
+ const config = this.get(current) ?? {};
534
566
 
535
567
  return config[key];
536
568
  }
@@ -1,15 +1,12 @@
1
+ const chalk = require('chalk');
1
2
  const childProcess = require('child_process');
2
3
  const { localConfig } = require("../config");
3
4
  const path = require('path');
4
5
  const fs = require('fs');
5
- const { log,success } = require("../parser");
6
+ const { log, success, hint } = require("../parser");
6
7
  const { openRuntimesVersion, systemTools } = require("./utils");
7
- const ID = require("../id");
8
-
9
- const activeDockerIds = {};
10
8
 
11
9
  async function dockerStop(id) {
12
- delete activeDockerIds[id];
13
10
  const stopProcess = childProcess.spawn('docker', ['rm', '--force', id], {
14
11
  stdio: 'pipe',
15
12
  });
@@ -18,20 +15,42 @@ async function dockerStop(id) {
18
15
  }
19
16
 
20
17
  async function dockerPull(func) {
21
- log('Pulling Docker image of function runtime ...');
22
-
23
18
  const runtimeChunks = func.runtime.split("-");
24
19
  const runtimeVersion = runtimeChunks.pop();
25
20
  const runtimeName = runtimeChunks.join("-");
26
21
  const imageName = `openruntimes/${runtimeName}:${openRuntimesVersion}-${runtimeVersion}`;
27
22
 
28
- const pullProcess = childProcess.spawn('docker', ['pull', imageName], {
23
+ const checkProcess = childProcess.spawn('docker', ['images', '--format', 'json', imageName], {
29
24
  stdio: 'pipe',
30
25
  pwd: path.join(process.cwd(), func.path)
31
26
  });
32
27
 
33
- pullProcess.stderr.on('data', (data) => {
34
- process.stderr.write(`\n${data}$ `);
28
+ let hasImage = false;
29
+
30
+ checkProcess.stdout.on('data', (data) => {
31
+ if(data) {
32
+ hasImage = false;
33
+ }
34
+ });
35
+
36
+ checkProcess.stderr.on('data', (data) => {
37
+ if(data) {
38
+ hasImage = false;
39
+ }
40
+ });
41
+
42
+ await new Promise((res) => { checkProcess.on('close', res) });
43
+
44
+ if(hasImage) {
45
+ return;
46
+ }
47
+
48
+ log('Pulling Docker image ...');
49
+ hint('This may take a few minutes, but we only need to do this once.');
50
+
51
+ const pullProcess = childProcess.spawn('docker', ['pull', imageName], {
52
+ stdio: 'pipe',
53
+ pwd: path.join(process.cwd(), func.path)
35
54
  });
36
55
 
37
56
  await new Promise((res) => { pullProcess.on('close', res) });
@@ -47,7 +66,7 @@ async function dockerBuild(func, variables) {
47
66
 
48
67
  const functionDir = path.join(process.cwd(), func.path);
49
68
 
50
- const id = ID.unique();
69
+ const id = func.$id;
51
70
 
52
71
  const params = [ 'run' ];
53
72
  params.push('--name', id);
@@ -55,6 +74,7 @@ async function dockerBuild(func, variables) {
55
74
  params.push('-e', 'APPWRITE_ENV=development');
56
75
  params.push('-e', 'OPEN_RUNTIMES_ENV=development');
57
76
  params.push('-e', 'OPEN_RUNTIMES_SECRET=');
77
+ params.push('-l', 'appwrite-env=dev');
58
78
  params.push('-e', `OPEN_RUNTIMES_ENTRYPOINT=${func.entrypoint}`);
59
79
 
60
80
  for(const k of Object.keys(variables)) {
@@ -69,11 +89,11 @@ async function dockerBuild(func, variables) {
69
89
  });
70
90
 
71
91
  buildProcess.stdout.on('data', (data) => {
72
- process.stdout.write(`\n${data}`);
92
+ process.stdout.write(chalk.blackBright(`${data}\n`));
73
93
  });
74
94
 
75
95
  buildProcess.stderr.on('data', (data) => {
76
- process.stderr.write(`\n${data}`);
96
+ process.stderr.write(chalk.blackBright(`${data}\n`));
77
97
  });
78
98
 
79
99
  await new Promise((res) => { buildProcess.on('close', res) });
@@ -91,14 +111,7 @@ async function dockerBuild(func, variables) {
91
111
 
92
112
  await new Promise((res) => { copyProcess.on('close', res) });
93
113
 
94
- const cleanupProcess = childProcess.spawn('docker', ['rm', '--force', id], {
95
- stdio: 'pipe',
96
- pwd: functionDir
97
- });
98
-
99
- await new Promise((res) => { cleanupProcess.on('close', res) });
100
-
101
- delete activeDockerIds[id];
114
+ await dockerStop(id);
102
115
 
103
116
  const tempPath = path.join(process.cwd(), func.path, 'code.tar.gz');
104
117
  if (fs.existsSync(tempPath)) {
@@ -107,15 +120,6 @@ async function dockerBuild(func, variables) {
107
120
  }
108
121
 
109
122
  async function dockerStart(func, variables, port) {
110
- log('Starting function using Docker ...');
111
-
112
- log("Permissions, events, CRON and timeouts dont apply when running locally.");
113
-
114
- log('💡 Hint: Function automatically restarts when you edit your code.');
115
-
116
- success(`Visit http://localhost:${port}/ to execute your function.`);
117
-
118
-
119
123
  const runtimeChunks = func.runtime.split("-");
120
124
  const runtimeVersion = runtimeChunks.pop();
121
125
  const runtimeName = runtimeChunks.join("-");
@@ -125,13 +129,14 @@ async function dockerStart(func, variables, port) {
125
129
 
126
130
  const functionDir = path.join(process.cwd(), func.path);
127
131
 
128
- const id = ID.unique();
132
+ const id = func.$id;
129
133
 
130
134
  const params = [ 'run' ];
131
135
  params.push('--rm');
132
136
  params.push('-d');
133
137
  params.push('--name', id);
134
138
  params.push('-p', `${port}:3000`);
139
+ params.push('-l', 'appwrite-env=dev');
135
140
  params.push('-e', 'APPWRITE_ENV=development');
136
141
  params.push('-e', 'OPEN_RUNTIMES_ENV=development');
137
142
  params.push('-e', 'OPEN_RUNTIMES_SECRET=');
@@ -150,11 +155,11 @@ async function dockerStart(func, variables, port) {
150
155
  pwd: functionDir
151
156
  });
152
157
 
153
- activeDockerIds[id] = true;
158
+ success(`Visit http://localhost:${port}/ to execute your function.`);
154
159
  }
155
160
 
156
161
  async function dockerCleanup() {
157
- await dockerStop();
162
+ await dockerStopActive();
158
163
 
159
164
  const functions = localConfig.getFunctions();
160
165
  for(const func of functions) {
@@ -171,17 +176,40 @@ async function dockerCleanup() {
171
176
  }
172
177
 
173
178
  async function dockerStopActive() {
174
- const ids = Object.keys(activeDockerIds);
175
- for await (const id of ids) {
179
+ const listProcess = childProcess.spawn('docker', ['ps', '-a', '-q', '--filter', 'label=appwrite-env=dev'], {
180
+ stdio: 'pipe',
181
+ });
182
+
183
+ const ids = [];
184
+ function handleOutput(data) {
185
+ const list = data.toString().split('\n');
186
+ for(const id of list) {
187
+ if(id && !id.includes(' ')) {
188
+ ids.push(id);
189
+ }
190
+ }
191
+ }
192
+
193
+ listProcess.stdout.on('data', (data) => {
194
+ handleOutput(data);
195
+ });
196
+
197
+ listProcess.stderr.on('data', (data) => {
198
+ handleOutput(data);
199
+ });
200
+
201
+ await new Promise((res) => { listProcess.on('close', res) });
202
+
203
+ for(const id of ids) {
176
204
  await dockerStop(id);
177
205
  }
178
206
  }
179
207
 
180
208
  module.exports = {
181
- dockerStop,
182
209
  dockerPull,
183
210
  dockerBuild,
184
211
  dockerStart,
185
212
  dockerCleanup,
186
213
  dockerStopActive,
214
+ dockerStop,
187
215
  }
@@ -2,8 +2,7 @@ const EventEmitter = require('node:events');
2
2
  const { projectsCreateJWT } = require('../commands/projects');
3
3
  const { localConfig } = require("../config");
4
4
 
5
-
6
- const openRuntimesVersion = 'v3';
5
+ const openRuntimesVersion = 'v4';
7
6
 
8
7
  const runtimeNames = {
9
8
  'node': 'Node.js',
@@ -17,7 +16,8 @@ const runtimeNames = {
17
16
  'java': 'Java',
18
17
  'swift': 'Swift',
19
18
  'kotlin': 'Kotlin',
20
- 'bun': 'Bun'
19
+ 'bun': 'Bun',
20
+ 'go': 'Go',
21
21
  };
22
22
 
23
23
  const systemTools = {
@@ -81,6 +81,11 @@ const systemTools = {
81
81
  startCommand: "bun src/server.ts",
82
82
  dependencyFiles: [ "package.json", "package-lock.json", "bun.lockb" ]
83
83
  },
84
+ 'go': {
85
+ isCompiled: true,
86
+ startCommand: "src/function/server",
87
+ dependencyFiles: [ ]
88
+ },
84
89
  };
85
90
 
86
91
  const JwtManager = {
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.1';
134
+ const version = '6.0.0-rc.2';
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 logged in user.`,
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 undefined;
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: 'Project', value: 'project' },
219
- { name: 'Functions', value: 'functions' },
220
- { name: 'Collections', value: 'collections' },
221
- { name: 'Buckets', value: 'buckets' },
222
- { name: 'Teams', value: 'teams' },
223
- { name: 'Topics', value: 'messages' }
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
  ]
@@ -283,8 +293,23 @@ const questionsCreateFunction = [
283
293
  }
284
294
  })
285
295
  return choices;
286
- }
287
- }
296
+ },
297
+ },
298
+ {
299
+ type: "list",
300
+ name: "template",
301
+ message: "How would you like to start your function code?",
302
+ choices: [
303
+ {
304
+ name: `Start from scratch ${chalk.blackBright(`(starter)`)}`,
305
+ value: "starter"
306
+ },
307
+ {
308
+ name: "Pick a template",
309
+ value: "custom"
310
+ }
311
+ ]
312
+ },
288
313
  ];
289
314
 
290
315
  const questionsCreateFunctionSelectTemplate = (templates) => {
@@ -451,12 +476,12 @@ const questionsLogin = [
451
476
  {
452
477
  type: "list",
453
478
  name: "method",
454
- message: "You're already logged in, what you like to do?",
479
+ message: "What you like to do?",
455
480
  choices: [
456
- { name: 'Login to a different account', value: 'login' },
457
- { name: 'Change to a different existed account', value: 'select' }
481
+ { name: 'Login to an account', value: 'login' },
482
+ { name: 'Switch to an account', value: 'select' }
458
483
  ],
459
- when: () => globalConfig.getCurrentSession() !== ''
484
+ when: () => globalConfig.getSessions().length >= 2
460
485
  },
461
486
  {
462
487
  type: "input",
@@ -570,12 +595,12 @@ const questionsPushResources = [
570
595
  name: "resource",
571
596
  message: "Which resources would you like to push?",
572
597
  choices: [
573
- { name: 'Project', value: 'project' },
574
- { name: 'Functions', value: 'functions' },
575
- { name: 'Collections', value: 'collections' },
576
- { name: 'Buckets', value: 'buckets' },
577
- { name: 'Teams', value: 'teams' },
578
- { name: 'Topics', value: 'messages' }
598
+ { name: `Settings ${chalk.blackBright(`(Project)`)}`, value: 'settings' },
599
+ { name: `Functions ${chalk.blackBright(`(Deployment)`)}`, value: 'functions' },
600
+ { name: `Collections ${chalk.blackBright(`(Databases)`)}`, value: 'collections' },
601
+ { name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: 'buckets' },
602
+ { name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: 'teams' },
603
+ { name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: 'messages' }
579
604
  ]
580
605
  }
581
606
  ];
@@ -605,7 +630,7 @@ const questionsPushFunctions = [
605
630
  let functions = localConfig.getFunctions();
606
631
  checkDeployConditions(localConfig)
607
632
  if (functions.length === 0) {
608
- throw new Error("No functions found in the current directory Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
633
+ 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
634
  }
610
635
  let choices = functions.map((func, idx) => {
611
636
  return {
@@ -794,7 +819,7 @@ const questionsRunFunctions = [
794
819
  choices: () => {
795
820
  let functions = localConfig.getFunctions();
796
821
  if (functions.length === 0) {
797
- throw new Error("No functions found in the current directory. Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
822
+ 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
823
  }
799
824
  let choices = functions.map((func, idx) => {
800
825
  return {
@@ -809,6 +834,7 @@ const questionsRunFunctions = [
809
834
 
810
835
  module.exports = {
811
836
  questionsInitProject,
837
+ questionsInitProjectAutopull,
812
838
  questionsCreateFunction,
813
839
  questionsCreateFunctionSelectTemplate,
814
840
  questionsCreateBucket,
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,12 +29,6 @@ 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
33
  throw new Error("Project is not set. Please run `appwrite init` to initialize the current directory with an Appwrite project.");
72
34
  }
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.1",
5
+ "version": "6.0.0-rc.2",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
- "version": "6.0.0-rc.1",
3
+ "version": "6.0.0-rc.2",
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.1/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.2/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.1/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.2/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",