appwrite-utils-cli 0.9.79 → 0.9.81

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 CHANGED
@@ -125,6 +125,7 @@ This updated CLI ensures that developers have robust tools at their fingertips t
125
125
 
126
126
  ## Changelog
127
127
 
128
+ - 0.9.80: Fixed collections not being unique between local and remote
128
129
  - 0.9.79: Fixed local collections not being considered for the synchronization unless all de-selected
129
130
  - 0.9.78: Added colored text! And also added a lot more customization options as to what to wipe, update, etc.
130
131
  - 0.9.75: Fixed attribute bug
@@ -44,9 +44,9 @@ export class InteractiveCLI {
44
44
  choices: Object.values(CHOICES),
45
45
  },
46
46
  ]);
47
- await this.initControllerIfNeeded();
48
47
  switch (action) {
49
48
  case CHOICES.CREATE_COLLECTION_CONFIG:
49
+ await this.initControllerIfNeeded();
50
50
  await this.createCollectionConfig();
51
51
  break;
52
52
  case CHOICES.SETUP_DIRS_FILES:
@@ -106,13 +106,15 @@ export class InteractiveCLI {
106
106
  async selectDatabases(databases, message, multiSelect = true) {
107
107
  const choices = databases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
108
108
  const configDatabases = this.getLocalDatabases();
109
- const allDatabases = Array.from(new Set([...databases, ...configDatabases]));
109
+ const dbNames = databases.map((db) => db.name).concat(configDatabases.map((db) => db.name));
110
+ const allDbNamesUnique = Array.from(new Set(dbNames));
111
+ const allDatabases = allDbNamesUnique.map((name) => configDatabases.find((db) => db.name === name) ?? databases.find((db) => db.name === name)).filter((v) => v !== undefined).sort((a, b) => a.name.localeCompare(b.name));
110
112
  const { selectedDatabases } = await inquirer.prompt([
111
113
  {
112
114
  type: multiSelect ? "checkbox" : "list",
113
115
  name: "selectedDatabases",
114
116
  message: chalk.blue(message),
115
- choices,
117
+ choices: allDatabases,
116
118
  loop: false,
117
119
  pageSize: 10,
118
120
  },
@@ -122,7 +124,9 @@ export class InteractiveCLI {
122
124
  async selectCollections(database, databasesClient, message, multiSelect = true) {
123
125
  const collections = await fetchAllCollections(database.$id, databasesClient);
124
126
  const configCollections = this.getLocalCollections();
125
- const allCollections = Array.from(new Set([...collections, ...configCollections]));
127
+ const collectionNames = collections.map((c) => c.name).concat(configCollections.map((c) => c.name));
128
+ const allCollectionNamesUnique = Array.from(new Set(collectionNames));
129
+ const allCollections = allCollectionNamesUnique.map((name) => configCollections.find((c) => c.name === name) ?? collections.find((c) => c.name === name)).filter((v) => v !== undefined);
126
130
  const choices = allCollections.map((collection) => ({
127
131
  name: collection.name,
128
132
  value: collection,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "appwrite-utils-cli",
3
3
  "description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
4
- "version": "0.9.79",
4
+ "version": "0.9.81",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@types/inquirer": "^9.0.7",
34
- "appwrite-utils": "^0.3.91",
34
+ "appwrite-utils": "^0.3.94",
35
35
  "chalk": "^5.3.0",
36
36
  "commander": "^12.1.0",
37
37
  "inquirer": "^9.3.6",
@@ -55,10 +55,9 @@ export class InteractiveCLI {
55
55
  },
56
56
  ]);
57
57
 
58
- await this.initControllerIfNeeded();
59
-
60
58
  switch (action) {
61
59
  case CHOICES.CREATE_COLLECTION_CONFIG:
60
+ await this.initControllerIfNeeded();
62
61
  await this.createCollectionConfig();
63
62
  break;
64
63
  case CHOICES.SETUP_DIRS_FILES:
@@ -124,7 +123,9 @@ export class InteractiveCLI {
124
123
  ): Promise<Models.Database[]> {
125
124
  const choices = databases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
126
125
  const configDatabases = this.getLocalDatabases();
127
- const allDatabases = Array.from(new Set([...databases, ...configDatabases]));
126
+ const dbNames = databases.map((db) => db.name).concat(configDatabases.map((db) => db.name));
127
+ const allDbNamesUnique = Array.from(new Set(dbNames));
128
+ const allDatabases = allDbNamesUnique.map((name) => configDatabases.find((db) => db.name === name) ?? databases.find((db) => db.name === name)).filter((v) => v !== undefined).sort((a, b) => a.name.localeCompare(b.name));
128
129
 
129
130
 
130
131
  const { selectedDatabases } = await inquirer.prompt([
@@ -132,7 +133,7 @@ export class InteractiveCLI {
132
133
  type: multiSelect ? "checkbox" : "list",
133
134
  name: "selectedDatabases",
134
135
  message: chalk.blue(message),
135
- choices,
136
+ choices: allDatabases,
136
137
  loop: false,
137
138
  pageSize: 10,
138
139
  },
@@ -152,7 +153,9 @@ export class InteractiveCLI {
152
153
  databasesClient
153
154
  );
154
155
  const configCollections = this.getLocalCollections();
155
- const allCollections = Array.from(new Set([...collections, ...configCollections]));
156
+ const collectionNames = collections.map((c) => c.name).concat(configCollections.map((c) => c.name));
157
+ const allCollectionNamesUnique = Array.from(new Set(collectionNames));
158
+ const allCollections = allCollectionNamesUnique.map((name) => configCollections.find((c) => c.name === name) ?? collections.find((c) => c.name === name)).filter((v) => v !== undefined);
156
159
  const choices = allCollections.map((collection) => ({
157
160
  name: collection.name,
158
161
  value: collection,