appwrite-cli 10.2.2 → 10.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.2.3
4
+
5
+ * Fix `init tables` command not working
6
+ * Improve tablesDB resource syncing during `push tables` command
7
+
3
8
  ## 10.2.2
4
9
 
5
10
  * Fix `logout` command showing duplicate sessions
package/README.md CHANGED
@@ -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
- 10.2.2
32
+ 10.2.3
33
33
  ```
34
34
 
35
35
  ### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
60
60
  Once the installation completes, you can verify your install using
61
61
  ```
62
62
  $ appwrite -v
63
- 10.2.2
63
+ 10.2.3
64
64
  ```
65
65
 
66
66
  ## Getting Started
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/10.2.2/appwrite-cli-win-x64.exe"
17
- $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.2/appwrite-cli-win-arm64.exe"
16
+ $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.3/appwrite-cli-win-x64.exe"
17
+ $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.3/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="10.2.2"
100
+ GITHUB_LATEST_VERSION="10.2.3"
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
@@ -16,8 +16,8 @@ class Client {
16
16
  'x-sdk-name': 'Command Line',
17
17
  'x-sdk-platform': 'console',
18
18
  'x-sdk-language': 'cli',
19
- 'x-sdk-version': '10.2.2',
20
- 'user-agent' : `AppwriteCLI/10.2.2 (${os.type()} ${os.version()}; ${os.arch()})`,
19
+ 'x-sdk-version': '10.2.3',
20
+ 'user-agent' : `AppwriteCLI/10.2.3 (${os.type()} ${os.version()}; ${os.arch()})`,
21
21
  'X-Appwrite-Response-Format' : '1.8.0',
22
22
  };
23
23
  }
@@ -19,6 +19,7 @@ const {
19
19
  questionsCreateBucket,
20
20
  questionsCreateMessagingTopic,
21
21
  questionsCreateCollection,
22
+ questionsCreateTable,
22
23
  questionsInitProject,
23
24
  questionsInitProjectAutopull,
24
25
  questionsInitResources,
@@ -34,10 +35,11 @@ const initResources = async () => {
34
35
  const actions = {
35
36
  function: initFunction,
36
37
  site: initSite,
37
- collection: initCollection,
38
+ table: initTable,
38
39
  bucket: initBucket,
39
40
  team: initTeam,
40
- message: initTopic
41
+ message: initTopic,
42
+ collection: initCollection
41
43
  }
42
44
 
43
45
  const answers = await inquirer.prompt(questionsInitResources[0]);
@@ -160,6 +162,40 @@ const initTeam = async () => {
160
162
  log("Next you can use 'appwrite push team' to deploy the changes.");
161
163
  };
162
164
 
165
+ const initTable = async () => {
166
+ const answers = await inquirer.prompt(questionsCreateTable)
167
+ const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';
168
+
169
+ if (!newDatabase) {
170
+ answers.databaseId = answers.database;
171
+ answers.databaseName = localConfig.getTablesDB(answers.database).name;
172
+ }
173
+
174
+ const databaseId = answers.databaseId === 'unique()' ? ID.unique() : answers.databaseId;
175
+
176
+ if (newDatabase || !localConfig.getTablesDB(answers.databaseId)) {
177
+ localConfig.addTablesDB({
178
+ $id: databaseId,
179
+ name: answers.databaseName,
180
+ enabled: true
181
+ });
182
+ }
183
+
184
+ localConfig.addTable({
185
+ $id: answers.id === 'unique()' ? ID.unique() : answers.id,
186
+ $permissions: [],
187
+ databaseId: databaseId,
188
+ name: answers.table,
189
+ enabled: true,
190
+ rowSecurity: answers.rowSecurity.toLowerCase() === 'yes',
191
+ columns: [],
192
+ indexes: [],
193
+ });
194
+
195
+ success("Initialing table");
196
+ log("Next you can use 'appwrite push table' to deploy the changes.");
197
+ };
198
+
163
199
  const initCollection = async () => {
164
200
  const answers = await inquirer.prompt(questionsCreateCollection)
165
201
  const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';
@@ -557,6 +593,12 @@ init
557
593
  .description("Init a new Appwrite collection")
558
594
  .action(actionRunner(initCollection));
559
595
 
596
+ init
597
+ .command("table")
598
+ .alias("tables")
599
+ .description("Init a new Appwrite table")
600
+ .action(actionRunner(initTable));
601
+
560
602
  init
561
603
  .command("topic")
562
604
  .alias("topics")
@@ -837,14 +837,16 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,
837
837
 
838
838
  if (!cliConfig.force) {
839
839
  if (deleting.length > 0 && !isIndex) {
840
- console.log(`${chalk.red('-------------------------------------------------------')}`);
840
+ console.log(`${chalk.red('------------------------------------------------------')}`);
841
841
  console.log(`${chalk.red('| WARNING: Attribute deletion may cause loss of data |')}`);
842
- console.log(`${chalk.red('-------------------------------------------------------')}`);
842
+ console.log(`${chalk.red('------------------------------------------------------')}`);
843
+ console.log();
843
844
  }
844
845
  if (conflicts.length > 0 && !isIndex) {
845
- console.log(`${chalk.red('---------------------------------------------------------')}`);
846
+ console.log(`${chalk.red('--------------------------------------------------------')}`);
846
847
  console.log(`${chalk.red('| WARNING: Attribute recreation may cause loss of data |')}`);
847
- console.log(`${chalk.red('---------------------------------------------------------')}`);
848
+ console.log(`${chalk.red('--------------------------------------------------------')}`);
849
+ console.log();
848
850
  }
849
851
 
850
852
  if ((await getConfirmation()) !== true) {
@@ -1725,9 +1727,10 @@ const checkAndApplyTablesDBChanges = async () => {
1725
1727
  toDelete.push(remoteDB);
1726
1728
  changes.push({
1727
1729
  id: remoteDB.$id,
1730
+ action: chalk.red('deleting'),
1728
1731
  key: 'Database',
1729
- remote: chalk.red(`${remoteDB.name} (${remoteDB.$id})`),
1730
- local: chalk.green('(deleted locally)')
1732
+ remote: remoteDB.name,
1733
+ local: '(deleted locally)'
1731
1734
  });
1732
1735
  }
1733
1736
  }
@@ -1740,9 +1743,10 @@ const checkAndApplyTablesDBChanges = async () => {
1740
1743
  toCreate.push(localDB);
1741
1744
  changes.push({
1742
1745
  id: localDB.$id,
1746
+ action: chalk.green('creating'),
1743
1747
  key: 'Database',
1744
- remote: chalk.red('(does not exist)'),
1745
- local: chalk.green(`${localDB.name} (${localDB.$id})`)
1748
+ remote: '(does not exist)',
1749
+ local: localDB.name
1746
1750
  });
1747
1751
  } else {
1748
1752
  let hasChanges = false;
@@ -1751,9 +1755,10 @@ const checkAndApplyTablesDBChanges = async () => {
1751
1755
  hasChanges = true;
1752
1756
  changes.push({
1753
1757
  id: localDB.$id,
1758
+ action: chalk.yellow('updating'),
1754
1759
  key: 'Name',
1755
- remote: chalk.red(remoteDB.name),
1756
- local: chalk.green(localDB.name)
1760
+ remote: remoteDB.name,
1761
+ local: localDB.name
1757
1762
  });
1758
1763
  }
1759
1764
 
@@ -1761,9 +1766,10 @@ const checkAndApplyTablesDBChanges = async () => {
1761
1766
  hasChanges = true;
1762
1767
  changes.push({
1763
1768
  id: localDB.$id,
1764
- key: 'Enabled?',
1765
- remote: chalk.red(remoteDB.enabled),
1766
- local: chalk.green(localDB.enabled)
1769
+ action: chalk.yellow('updating'),
1770
+ key: 'Enabled',
1771
+ remote: remoteDB.enabled,
1772
+ local: localDB.enabled
1767
1773
  });
1768
1774
  }
1769
1775
 
@@ -1774,16 +1780,19 @@ const checkAndApplyTablesDBChanges = async () => {
1774
1780
  }
1775
1781
 
1776
1782
  if (changes.length === 0) {
1783
+ console.log('No changes found in tablesDB resource');
1784
+ console.log();
1777
1785
  return { applied: false, resyncNeeded: false };
1778
1786
  }
1779
1787
 
1780
- log('Found changes in tablesDB resources:');
1788
+ log('Found changes in tablesDB resource:');
1781
1789
  drawTable(changes);
1782
1790
 
1783
1791
  if (toDelete.length > 0) {
1784
- console.log(`${chalk.red('-------------------------------------------------------------------')}`);
1792
+ console.log(`${chalk.red('------------------------------------------------------------------')}`);
1785
1793
  console.log(`${chalk.red('| WARNING: Database deletion will also delete all related tables |')}`);
1786
- console.log(`${chalk.red('-------------------------------------------------------------------')}`);
1794
+ console.log(`${chalk.red('------------------------------------------------------------------')}`);
1795
+ console.log();
1787
1796
  }
1788
1797
 
1789
1798
  if ((await getConfirmation()) !== true) {
@@ -1841,6 +1850,10 @@ const checkAndApplyTablesDBChanges = async () => {
1841
1850
  }
1842
1851
  }
1843
1852
 
1853
+ if (toDelete.length === 0){
1854
+ console.log();
1855
+ }
1856
+
1844
1857
  return { applied: true, resyncNeeded: needsResync };
1845
1858
  };
1846
1859
 
@@ -1868,6 +1881,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1868
1881
  localConfig.set('tablesDB', validTablesDBs);
1869
1882
 
1870
1883
  success('Configuration resynced successfully.');
1884
+ console.log();
1871
1885
  }
1872
1886
 
1873
1887
  if (cliConfig.all) {
package/lib/parser.js CHANGED
@@ -122,7 +122,7 @@ const parseError = (err) => {
122
122
  } catch {
123
123
  }
124
124
 
125
- const version = '10.2.2';
125
+ const version = '10.2.3';
126
126
  const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
127
127
  const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
128
128
 
package/lib/questions.js CHANGED
@@ -496,7 +496,73 @@ const questionsCreateCollection = [
496
496
  {
497
497
  type: "list",
498
498
  name: "documentSecurity",
499
- message: "Enable Document-Security for configuring permissions for individual documents",
499
+ message: "Enable document security for configuring permissions for individual documents",
500
+ choices: ["No", "Yes"]
501
+ }
502
+ ];
503
+
504
+ const questionsCreateTable = [
505
+ {
506
+ type: "list",
507
+ name: "method",
508
+ message: "What database would you like to use for your table?",
509
+ choices: ["New", "Existing"],
510
+ when: async () => {
511
+ return localConfig.getTablesDBs().length !== 0;
512
+ }
513
+ },
514
+ {
515
+ type: "search-list",
516
+ name: "database",
517
+ message: "Choose the table database",
518
+ choices: async () => {
519
+ const databases = localConfig.getTablesDBs();
520
+
521
+ let choices = databases.map((database, idx) => {
522
+ return {
523
+ name: `${database.name} (${database.$id})`,
524
+ value: database.$id
525
+ }
526
+ })
527
+
528
+ if (choices.length === 0) {
529
+ throw new Error("No databases found. Please create one in project console.")
530
+ }
531
+
532
+ return choices;
533
+ },
534
+ when: (answers) => (answers.method ?? '').toLowerCase() === 'existing'
535
+ },
536
+ {
537
+ type: "input",
538
+ name: "databaseName",
539
+ message: "What would you like to name your database?",
540
+ default: "My Awesome Database",
541
+ when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
542
+ },
543
+ {
544
+ type: "input",
545
+ name: "databaseId",
546
+ message: "What ID would you like to have for your database?",
547
+ default: "unique()",
548
+ when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
549
+ },
550
+ {
551
+ type: "input",
552
+ name: "table",
553
+ message: "What would you like to name your table?",
554
+ default: "My Awesome Table"
555
+ },
556
+ {
557
+ type: "input",
558
+ name: "id",
559
+ message: "What ID would you like to have for your table?",
560
+ default: "unique()"
561
+ },
562
+ {
563
+ type: "list",
564
+ name: "rowSecurity",
565
+ message: "Enable row security for configuring permissions for individual rows",
500
566
  choices: ["No", "Yes"]
501
567
  }
502
568
  ];
@@ -1001,6 +1067,7 @@ module.exports = {
1001
1067
  questionsCreateFunctionSelectTemplate,
1002
1068
  questionsCreateBucket,
1003
1069
  questionsCreateCollection,
1070
+ questionsCreateTable,
1004
1071
  questionsCreateMessagingTopic,
1005
1072
  questionsPullFunctions,
1006
1073
  questionsPullFunctionsCode,
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": "10.2.2",
5
+ "version": "10.2.3",
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": "10.2.2",
3
+ "version": "10.2.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/10.2.2/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.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/10.2.2/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.3/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",