appwrite-utils-cli 0.9.78 → 0.9.79
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 -0
- package/dist/interactiveCLI.d.ts +2 -0
- package/dist/interactiveCLI.js +33 -1
- package/package.json +2 -2
- package/src/interactiveCLI.ts +37 -2
package/README.md
CHANGED
@@ -61,6 +61,7 @@ Available options:
|
|
61
61
|
- `--collectionIds`: Comma-separated list of collection IDs to operate on
|
62
62
|
- `--bucketIds`: Comma-separated list of bucket IDs to operate on
|
63
63
|
- `--wipe`: Wipe data (all: everything, docs: only documents, users: only user data)
|
64
|
+
- `--wipeCollections`: Wipe collections (wipes specified collections from collectionIds -- does this non-destructively, deletes all documents)
|
64
65
|
- `--generate`: Generate TypeScript schemas from database schemas
|
65
66
|
- `--import`: Import data into your databases
|
66
67
|
- `--backup`: Perform a backup of your databases
|
@@ -124,6 +125,7 @@ This updated CLI ensures that developers have robust tools at their fingertips t
|
|
124
125
|
|
125
126
|
## Changelog
|
126
127
|
|
128
|
+
- 0.9.79: Fixed local collections not being considered for the synchronization unless all de-selected
|
127
129
|
- 0.9.78: Added colored text! And also added a lot more customization options as to what to wipe, update, etc.
|
128
130
|
- 0.9.75: Fixed attribute bug
|
129
131
|
- 0.9.72: Fixed my own null bug
|
package/dist/interactiveCLI.d.ts
CHANGED
package/dist/interactiveCLI.js
CHANGED
@@ -6,8 +6,10 @@ import { fetchAllCollections } from "./collections/methods.js";
|
|
6
6
|
import { listBuckets, createBucket } from "./storage/methods.js";
|
7
7
|
import { Databases, Storage, Client, Compression, } from "node-appwrite";
|
8
8
|
import { getClient } from "./utils/getClientFromConfig.js";
|
9
|
+
import { parseAttribute, PermissionToAppwritePermission } from "appwrite-utils";
|
9
10
|
import { ulid } from "ulidx";
|
10
11
|
import chalk from "chalk";
|
12
|
+
import { DateTime } from "luxon";
|
11
13
|
var CHOICES;
|
12
14
|
(function (CHOICES) {
|
13
15
|
CHOICES["CREATE_COLLECTION_CONFIG"] = "Create collection config file";
|
@@ -103,6 +105,8 @@ export class InteractiveCLI {
|
|
103
105
|
}
|
104
106
|
async selectDatabases(databases, message, multiSelect = true) {
|
105
107
|
const choices = databases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
|
108
|
+
const configDatabases = this.getLocalDatabases();
|
109
|
+
const allDatabases = Array.from(new Set([...databases, ...configDatabases]));
|
106
110
|
const { selectedDatabases } = await inquirer.prompt([
|
107
111
|
{
|
108
112
|
type: multiSelect ? "checkbox" : "list",
|
@@ -117,7 +121,9 @@ export class InteractiveCLI {
|
|
117
121
|
}
|
118
122
|
async selectCollections(database, databasesClient, message, multiSelect = true) {
|
119
123
|
const collections = await fetchAllCollections(database.$id, databasesClient);
|
120
|
-
const
|
124
|
+
const configCollections = this.getLocalCollections();
|
125
|
+
const allCollections = Array.from(new Set([...collections, ...configCollections]));
|
126
|
+
const choices = allCollections.map((collection) => ({
|
121
127
|
name: collection.name,
|
122
128
|
value: collection,
|
123
129
|
}));
|
@@ -581,6 +587,32 @@ export class InteractiveCLI {
|
|
581
587
|
await this.controller.transferData(transferOptions);
|
582
588
|
console.log(chalk.green("Data transfer completed."));
|
583
589
|
}
|
590
|
+
getLocalCollections() {
|
591
|
+
const configCollections = this.controller.config.collections || [];
|
592
|
+
// @ts-expect-error - appwrite invalid types
|
593
|
+
return configCollections.map(c => ({
|
594
|
+
$id: c.$id || ulid(),
|
595
|
+
$createdAt: DateTime.now().toISO(),
|
596
|
+
$updatedAt: DateTime.now().toISO(),
|
597
|
+
name: c.name,
|
598
|
+
enabled: c.enabled || true,
|
599
|
+
documentSecurity: c.documentSecurity || false,
|
600
|
+
attributes: c.attributes || [],
|
601
|
+
indexes: c.indexes || [],
|
602
|
+
$permissions: PermissionToAppwritePermission(c.$permissions) || [],
|
603
|
+
databaseId: c.databaseId,
|
604
|
+
}));
|
605
|
+
}
|
606
|
+
getLocalDatabases() {
|
607
|
+
const configDatabases = this.controller.config.databases || [];
|
608
|
+
return configDatabases.map(db => ({
|
609
|
+
$id: db.$id || ulid(),
|
610
|
+
$createdAt: DateTime.now().toISO(),
|
611
|
+
$updatedAt: DateTime.now().toISO(),
|
612
|
+
name: db.name,
|
613
|
+
enabled: true,
|
614
|
+
}));
|
615
|
+
}
|
584
616
|
async reloadConfig() {
|
585
617
|
console.log(chalk.yellow("Reloading configuration files..."));
|
586
618
|
try {
|
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.
|
4
|
+
"version": "0.9.79",
|
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.
|
34
|
+
"appwrite-utils": "^0.3.91",
|
35
35
|
"chalk": "^5.3.0",
|
36
36
|
"commander": "^12.1.0",
|
37
37
|
"inquirer": "^9.3.6",
|
package/src/interactiveCLI.ts
CHANGED
@@ -13,9 +13,10 @@ import {
|
|
13
13
|
} from "node-appwrite";
|
14
14
|
import { getClient } from "./utils/getClientFromConfig.js";
|
15
15
|
import type { TransferOptions } from "./migrations/transfer.js";
|
16
|
-
import type
|
16
|
+
import { parseAttribute, PermissionToAppwritePermission, type AppwriteConfig, type ConfigDatabases } from "appwrite-utils";
|
17
17
|
import { ulid } from "ulidx";
|
18
18
|
import chalk from "chalk";
|
19
|
+
import { DateTime } from "luxon";
|
19
20
|
|
20
21
|
enum CHOICES {
|
21
22
|
CREATE_COLLECTION_CONFIG = "Create collection config file",
|
@@ -122,6 +123,9 @@ export class InteractiveCLI {
|
|
122
123
|
multiSelect = true
|
123
124
|
): Promise<Models.Database[]> {
|
124
125
|
const choices = databases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
|
126
|
+
const configDatabases = this.getLocalDatabases();
|
127
|
+
const allDatabases = Array.from(new Set([...databases, ...configDatabases]));
|
128
|
+
|
125
129
|
|
126
130
|
const { selectedDatabases } = await inquirer.prompt([
|
127
131
|
{
|
@@ -147,7 +151,9 @@ export class InteractiveCLI {
|
|
147
151
|
database.$id,
|
148
152
|
databasesClient
|
149
153
|
);
|
150
|
-
const
|
154
|
+
const configCollections = this.getLocalCollections();
|
155
|
+
const allCollections = Array.from(new Set([...collections, ...configCollections]));
|
156
|
+
const choices = allCollections.map((collection) => ({
|
151
157
|
name: collection.name,
|
152
158
|
value: collection,
|
153
159
|
}));
|
@@ -805,6 +811,35 @@ export class InteractiveCLI {
|
|
805
811
|
console.log(chalk.green("Data transfer completed."));
|
806
812
|
}
|
807
813
|
|
814
|
+
|
815
|
+
private getLocalCollections(): Models.Collection[] {
|
816
|
+
const configCollections = this.controller!.config!.collections || [];
|
817
|
+
// @ts-expect-error - appwrite invalid types
|
818
|
+
return configCollections.map(c => ({
|
819
|
+
$id: c.$id || ulid(),
|
820
|
+
$createdAt: DateTime.now().toISO(),
|
821
|
+
$updatedAt: DateTime.now().toISO(),
|
822
|
+
name: c.name,
|
823
|
+
enabled: c.enabled || true,
|
824
|
+
documentSecurity: c.documentSecurity || false,
|
825
|
+
attributes: c.attributes || [],
|
826
|
+
indexes: c.indexes || [],
|
827
|
+
$permissions: PermissionToAppwritePermission(c.$permissions) || [],
|
828
|
+
databaseId: c.databaseId!,
|
829
|
+
}));
|
830
|
+
}
|
831
|
+
|
832
|
+
private getLocalDatabases(): Models.Database[] {
|
833
|
+
const configDatabases = this.controller!.config!.databases || [];
|
834
|
+
return configDatabases.map(db => ({
|
835
|
+
$id: db.$id || ulid(),
|
836
|
+
$createdAt: DateTime.now().toISO(),
|
837
|
+
$updatedAt: DateTime.now().toISO(),
|
838
|
+
name: db.name,
|
839
|
+
enabled: true,
|
840
|
+
}));
|
841
|
+
}
|
842
|
+
|
808
843
|
private async reloadConfig(): Promise<void> {
|
809
844
|
console.log(chalk.yellow("Reloading configuration files..."));
|
810
845
|
try {
|