appwrite-utils-cli 0.9.0 → 0.9.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 CHANGED
@@ -80,6 +80,7 @@ Available options:
80
80
  - `--remoteEndpoint`: Set the remote Appwrite endpoint for transfers
81
81
  - `--remoteProjectId`: Set the remote Appwrite project ID for transfers
82
82
  - `--remoteApiKey`: Set the remote Appwrite API key for transfers
83
+ - `--setup`: Create setup files
83
84
 
84
85
  ## Examples
85
86
 
@@ -120,3 +121,43 @@ npx appwrite-utils-cli appwrite-migrate --transfer --fromBucketId sourceBucketId
120
121
  - The CLI now supports OpenAPI generation for each attribute in the schema. Add a `description` to any attribute or collection, and it will export that schema to the `appwrite/openapi` folder.
121
122
 
122
123
  This updated CLI ensures that developers have robust tools at their fingertips to manage complex Appwrite projects effectively from the command line, with both interactive and non-interactive modes available for flexibility.
124
+
125
+ ## Changelog
126
+
127
+ - 0.9.3: Fixed deployment error && fix lack of existing `appwriteConfig.ts` file from causing error (you want to be able to setup yeah? haha)
128
+ - 0.9.2: Added changelog back, whoops
129
+ - 0.0.90: Updated README with new command-line options and fixed alias issues
130
+ - 0.0.74: Added `--backup` support, even if only one database
131
+ - 0.0.73: Fixed weird `workspace` issue
132
+ - 0.0.72: Remove `ulid` for `ulidx`, fixing compatibility issues
133
+ - 0.0.71: Slight change to file download logic after errors
134
+ - 0.0.70: Bump to `node-appwrite` version
135
+ - 0.0.69: Fixed single ID not getting replaced due to the below change =D also, `nice`
136
+ - 0.0.68: Fixed the occasional case where, when mapping ID's from old data to new, there would be an array of ID's to match against. `idMappings` now supports arrays.
137
+ - 0.0.67: Fixed `updates` in `importDef`'s update mappings overwriting postImportActions from the original
138
+ - 0.0.57: Fixed `dataLoader`'s `idMapping`'s giving me issues
139
+ - 0.0.55: Added `documentExists` check to batch creation functionality to try to prevent duplicates
140
+ - 0.0.54: Various fixes in here
141
+ - 0.0.50: Actually fixed the slight bug, it was really in the `mergeObjects`
142
+ - 0.0.49: Fixed a slight bug with `dataLoader` not mapping updates correctly with `updateMapping`
143
+ - 0.0.48: Added `--transfer`, `--fromdb <targetDatabaseId>`, `--targetdb <targetDatabaseId>`, `--transferendpoint <transferEndpoint>`, `--transferproject <transferProjectId>`, `--transferkey <transferApiKey>`. Additionally, I've added `--fromcoll <collectionId>` and `--targetcoll <collectionId>`. These allow you to do a few things. First, you can now transfer databases in the same project, and from local to a remote project. Second, you can now specify specific collections to transfer from one place to another, with all of their data. If `--fromcoll` and `--targetcoll` are ommitted, it will transfer the databases. During the database transfer, it will create any missing collections, attributes, and indices.
144
+ - 0.0.47: Minor bugfixes in many releases, too small to take note of
145
+ - 0.0.38: Lots of optimizations done to the code, added `tryAwaitWithRetry` for `fetch failed` and others like it errors (looking at you `server error`) -- this should prevent things from going sideways.
146
+ - 0.0.37: Added `documentSecurity`, `enabled`, and `$id` to the `init` collection
147
+ - 0.0.36: Made it update collections by default, sometimes you gotta do what you gotta do
148
+ - 0.0.35: Added update collection if it exists and permissions or such are different (`documentSecurity` and `enabled`), also added a check for `fetch failed` errors to retry them with recursion, not sure how well that will work out, but we're gonna try it! It will still fail after 5 tries, but hopefully that gives Appwrite some time to figure it's stuff out
149
+ - 0.0.34: Fixed the `bin` section of the package.json, apparently you can't use `node` to run it
150
+ - 0.0.33: Fixed `idMappings`, if you are importing data and use the `idMappings` functionality, you can set a `fieldToSet` based on the value of a `sourceField` in the current imported items data (whether it's in the final data or the original), in order to match another field in another collection. So if you had a store, and it had items and the items have a Region ID for instance. You can then, in your regionId of the items, setup an `idMapping` that will allow you to map the value of the `targetField` based on the value of the `targetFieldToMatch` in the `targetCollection`. Sounds complex, but it's very useful. Like psuedo-relationship resolution, without the relationships.
151
+ - 0.0.29: If you use the `description` variable in an attribute and collection, it'll add that description to the generated schemas. This assumes you have `zod-to-openpi`
152
+ - 0.0.275: THINGS ARE NOW IN TYPESCRIPT WOOHOO. No but for reaal, super happy to report that everything has been converted to TypeScript, just way too many changes, I hope you enjoy it!
153
+ - 0.0.274: Small improvement for attribute handling, rather than getting it every attribute, I check the collections attributes
154
+ - 0.0.273: Small fix for relationship attribute comparisons
155
+ - 0.0.272: That's what I get for not testing lmao, also updated logic for checking for existing attributes to take the `format` into consideration from the database (URL's are not of `type: "url"`, they are of `format: "url"`)
156
+ - 0.0.271: Small change to update attributes that are different from each other by deleting the attribute and recreating, as we cannot update most things
157
+ - 0.0.270: Fixed enums in `--sync`, added optional OpenAPI generation (in progress, almost done, but wanted to push other changes), added `--endpoint`, `--project`, `--key` as optional parameters to change the target destination (shoutout to [pingu24k](https://github.com/pingu2k4) for pointing out these bugs and suggesting those changes for endpoint customization)
158
+ - 0.0.254: Added `--sync` to synchronize your Appwrite instance with your local `appwriteConfig.yaml` and generate schemas
159
+ - 0.0.253: Added `--writeData` (or `--write-data`) to command to write the output of the import data to a file called dataLoaderOutput in your root dir
160
+ - 0.0.23: Added batching to user deletion
161
+ - 0.0.22: Converted all import processes except `postImportActions` and Relationship Resolution to the local data import, so it should be much faster.
162
+ - 0.0.6: Added `setTargetFieldFromOtherCollectionDocumentsByMatchingField` for the below, but setting a different field than the field you matched. The names are long, but at least you know what's going on lmao.
163
+ - 0.0.5: Added `setFieldFromOtherCollectionDocuments` to set an array of ID's for instance from another collection as a `postImportAction`
@@ -1,8 +1,9 @@
1
- import { UtilsController } from "./utilsController.js";
2
1
  export declare class InteractiveCLI {
2
+ private currentDir;
3
3
  private controller;
4
- constructor(currentDir?: string, utilsController?: UtilsController);
4
+ constructor(currentDir: string);
5
5
  run(): Promise<void>;
6
+ private initControllerIfNeeded;
6
7
  private selectDatabases;
7
8
  private selectCollections;
8
9
  private selectBuckets;
@@ -22,22 +22,14 @@ var CHOICES;
22
22
  CHOICES["EXIT"] = "Exit";
23
23
  })(CHOICES || (CHOICES = {}));
24
24
  export class InteractiveCLI {
25
+ currentDir;
25
26
  controller;
26
- constructor(currentDir, utilsController) {
27
- if (utilsController) {
28
- this.controller = utilsController;
29
- }
30
- else if (currentDir) {
31
- this.controller = new UtilsController(currentDir);
32
- }
33
- else {
34
- throw new Error("Current directory or utils controller is required");
35
- }
27
+ constructor(currentDir) {
28
+ this.currentDir = currentDir;
36
29
  }
37
30
  async run() {
38
31
  console.log("Welcome to Appwrite Utils CLI Tool by Zach Handley");
39
32
  console.log("For more information, visit https://github.com/zachhandley/appwrite-utils");
40
- await this.controller.init();
41
33
  while (true) {
42
34
  const { action } = await inquirer.prompt([
43
35
  {
@@ -52,30 +44,37 @@ export class InteractiveCLI {
52
44
  await this.createCollectionConfig();
53
45
  break;
54
46
  case CHOICES.SETUP_DIRS_FILES:
55
- await setupDirsFiles(false);
47
+ await setupDirsFiles(false, this.currentDir);
56
48
  break;
57
49
  case CHOICES.SETUP_DIRS_FILES_WITH_EXAMPLE_DATA:
58
- await setupDirsFiles(true);
50
+ await setupDirsFiles(true, this.currentDir);
59
51
  break;
60
52
  case CHOICES.SYNCHRONIZE_CONFIGURATIONS:
53
+ await this.initControllerIfNeeded();
61
54
  await this.synchronizeConfigurations();
62
55
  break;
63
56
  case CHOICES.SYNC_DB:
57
+ await this.initControllerIfNeeded();
64
58
  await this.syncDb();
65
59
  break;
66
60
  case CHOICES.TRANSFER_DATA:
61
+ await this.initControllerIfNeeded();
67
62
  await this.transferData();
68
63
  break;
69
64
  case CHOICES.BACKUP_DATABASE:
65
+ await this.initControllerIfNeeded();
70
66
  await this.backupDatabase();
71
67
  break;
72
68
  case CHOICES.WIPE_DATABASE:
69
+ await this.initControllerIfNeeded();
73
70
  await this.wipeDatabase();
74
71
  break;
75
72
  case CHOICES.GENERATE_SCHEMAS:
73
+ await this.initControllerIfNeeded();
76
74
  await this.generateSchemas();
77
75
  break;
78
76
  case CHOICES.IMPORT_DATA:
77
+ await this.initControllerIfNeeded();
79
78
  await this.importData();
80
79
  break;
81
80
  case CHOICES.EXIT:
@@ -84,6 +83,12 @@ export class InteractiveCLI {
84
83
  }
85
84
  }
86
85
  }
86
+ async initControllerIfNeeded() {
87
+ if (!this.controller) {
88
+ this.controller = new UtilsController(this.currentDir);
89
+ await this.controller.init();
90
+ }
91
+ }
87
92
  async selectDatabases(databases, message, multiSelect = true) {
88
93
  const choices = databases.map((db) => ({ name: db.name, value: db }));
89
94
  if (multiSelect) {
package/dist/main.js CHANGED
@@ -7,124 +7,136 @@ import { UtilsController } from "./utilsController.js";
7
7
  import { Databases, Storage } from "node-appwrite";
8
8
  import { getClient } from "./utils/getClientFromConfig.js";
9
9
  const argv = yargs(hideBin(process.argv))
10
- .command("migrate", "Run Appwrite migrations", (yargs) => {
11
- return yargs
12
- .option("it", {
13
- alias: ["interactive", "i"],
14
- type: "boolean",
15
- description: "Run in interactive mode",
16
- })
17
- .option("dbIds", {
18
- type: "string",
19
- description: "Comma-separated list of database IDs to operate on",
20
- })
21
- .option("collectionIds", {
22
- alias: ["collIds"],
23
- type: "string",
24
- description: "Comma-separated list of collection IDs to operate on",
25
- })
26
- .option("bucketIds", {
27
- type: "string",
28
- description: "Comma-separated list of bucket IDs to operate on",
29
- })
30
- .option("wipe", {
31
- choices: ["all", "docs", "users"],
32
- description: "Wipe data (all: everything, docs: only documents, users: only user data)",
33
- })
34
- .option("generate", {
35
- type: "boolean",
36
- description: "Generate TypeScript schemas from database schemas",
37
- })
38
- .option("import", {
39
- type: "boolean",
40
- description: "Import data into your databases",
41
- })
42
- .option("backup", {
43
- type: "boolean",
44
- description: "Perform a backup of your databases",
45
- })
46
- .option("writeData", {
47
- type: "boolean",
48
- description: "Write converted imported data to file",
49
- })
50
- .option("push", {
51
- type: "boolean",
52
- description: "Push your local Appwrite config to your configured Appwrite Project",
53
- })
54
- .option("sync", {
55
- type: "boolean",
56
- description: "Synchronize by pulling your Appwrite config from your configured Appwrite Project",
57
- })
58
- .option("endpoint", {
59
- type: "string",
60
- description: "Set the Appwrite endpoint",
61
- })
62
- .option("projectId", {
63
- type: "string",
64
- description: "Set the Appwrite project ID",
65
- })
66
- .option("apiKey", {
67
- type: "string",
68
- description: "Set the Appwrite API key",
69
- })
70
- .option("transfer", {
71
- type: "boolean",
72
- description: "Transfer data between databases or collections",
73
- })
74
- .option("fromDbId", {
75
- alias: ["fromDb"],
76
- type: "string",
77
- description: "Set the source database ID for transfer",
78
- })
79
- .option("toDbId", {
80
- alias: ["toDb"],
81
- type: "string",
82
- description: "Set the destination database ID for transfer",
83
- })
84
- .option("fromCollectionId", {
85
- alias: ["fromCollId", "fromColl"],
86
- type: "string",
87
- description: "Set the source collection ID for transfer",
88
- })
89
- .option("toCollectionId", {
90
- alias: ["toCollId", "toColl"],
91
- type: "string",
92
- description: "Set the destination collection ID for transfer",
93
- })
94
- .option("fromBucketId", {
95
- alias: ["fromBucket"],
96
- type: "string",
97
- description: "Set the source bucket ID for transfer",
98
- })
99
- .option("toBucketId", {
100
- alias: ["toBucket"],
101
- type: "string",
102
- description: "Set the destination bucket ID for transfer",
103
- })
104
- .option("remoteEndpoint", {
105
- type: "string",
106
- description: "Set the remote Appwrite endpoint for transfers",
107
- })
108
- .option("remoteProjectId", {
109
- type: "string",
110
- description: "Set the remote Appwrite project ID for transfers",
111
- })
112
- .option("remoteApiKey", {
113
- type: "string",
114
- description: "Set the remote Appwrite API key for transfers",
115
- });
10
+ .option("it", {
11
+ alias: ["interactive", "i"],
12
+ type: "boolean",
13
+ description: "Run in interactive mode",
14
+ })
15
+ .option("dbIds", {
16
+ type: "string",
17
+ description: "Comma-separated list of database IDs to operate on",
18
+ })
19
+ .option("collectionIds", {
20
+ alias: ["collIds"],
21
+ type: "string",
22
+ description: "Comma-separated list of collection IDs to operate on",
23
+ })
24
+ .option("bucketIds", {
25
+ type: "string",
26
+ description: "Comma-separated list of bucket IDs to operate on",
27
+ })
28
+ .option("wipe", {
29
+ choices: ["all", "docs", "users"],
30
+ description: "Wipe data (all: everything, docs: only documents, users: only user data)",
31
+ })
32
+ .option("generate", {
33
+ type: "boolean",
34
+ description: "Generate TypeScript schemas from database schemas",
35
+ })
36
+ .option("import", {
37
+ type: "boolean",
38
+ description: "Import data into your databases",
39
+ })
40
+ .option("backup", {
41
+ type: "boolean",
42
+ description: "Perform a backup of your databases",
43
+ })
44
+ .option("writeData", {
45
+ type: "boolean",
46
+ description: "Write converted imported data to file",
47
+ })
48
+ .option("push", {
49
+ type: "boolean",
50
+ description: "Push your local Appwrite config to your configured Appwrite Project",
51
+ })
52
+ .option("sync", {
53
+ type: "boolean",
54
+ description: "Synchronize by pulling your Appwrite config from your configured Appwrite Project",
55
+ })
56
+ .option("endpoint", {
57
+ type: "string",
58
+ description: "Set the Appwrite endpoint",
59
+ })
60
+ .option("projectId", {
61
+ type: "string",
62
+ description: "Set the Appwrite project ID",
63
+ })
64
+ .option("apiKey", {
65
+ type: "string",
66
+ description: "Set the Appwrite API key",
67
+ })
68
+ .option("transfer", {
69
+ type: "boolean",
70
+ description: "Transfer data between databases or collections",
71
+ })
72
+ .option("fromDbId", {
73
+ alias: ["fromDb"],
74
+ type: "string",
75
+ description: "Set the source database ID for transfer",
76
+ })
77
+ .option("toDbId", {
78
+ alias: ["toDb"],
79
+ type: "string",
80
+ description: "Set the destination database ID for transfer",
81
+ })
82
+ .option("fromCollectionId", {
83
+ alias: ["fromCollId", "fromColl"],
84
+ type: "string",
85
+ description: "Set the source collection ID for transfer",
86
+ })
87
+ .option("toCollectionId", {
88
+ alias: ["toCollId", "toColl"],
89
+ type: "string",
90
+ description: "Set the destination collection ID for transfer",
91
+ })
92
+ .option("fromBucketId", {
93
+ alias: ["fromBucket"],
94
+ type: "string",
95
+ description: "Set the source bucket ID for transfer",
96
+ })
97
+ .option("toBucketId", {
98
+ alias: ["toBucket"],
99
+ type: "string",
100
+ description: "Set the destination bucket ID for transfer",
101
+ })
102
+ .option("remoteEndpoint", {
103
+ type: "string",
104
+ description: "Set the remote Appwrite endpoint for transfers",
105
+ })
106
+ .option("remoteProjectId", {
107
+ type: "string",
108
+ description: "Set the remote Appwrite project ID for transfers",
109
+ })
110
+ .option("remoteApiKey", {
111
+ type: "string",
112
+ description: "Set the remote Appwrite API key for transfers",
113
+ })
114
+ .option("setup", {
115
+ type: "boolean",
116
+ description: "Setup the project with example data",
116
117
  })
117
118
  .help()
118
119
  .parse();
119
120
  async function main() {
120
121
  const parsedArgv = (await argv);
121
- const controller = new UtilsController(process.cwd());
122
- await controller.init();
122
+ let controller;
123
123
  if (parsedArgv.it) {
124
- const cli = new InteractiveCLI(process.cwd(), controller);
124
+ try {
125
+ controller = new UtilsController(process.cwd());
126
+ await controller.init();
127
+ }
128
+ catch (error) {
129
+ // If it fails, that means there's no config, more than likely
130
+ console.log("No config found, you probably need to create the setup files");
131
+ }
132
+ const cli = new InteractiveCLI(process.cwd());
125
133
  await cli.run();
126
134
  }
127
135
  else {
136
+ if (!controller) {
137
+ controller = new UtilsController(process.cwd());
138
+ await controller.init();
139
+ }
128
140
  // Handle non-interactive mode with the new options
129
141
  const options = {
130
142
  databases: parsedArgv.dbIds
@@ -1,7 +1,7 @@
1
1
  import { tryAwaitWithRetry } from "appwrite-utils";
2
2
  import { Client, Databases, IndexType, Query, Storage, } from "node-appwrite";
3
3
  import { InputFile } from "node-appwrite/file";
4
- import { getAppwriteClient } from "src/utils/helperFunctions.js";
4
+ import { getAppwriteClient } from "../utils/helperFunctions.js";
5
5
  import { createOrUpdateAttribute } from "./attributes.js";
6
6
  import { parseAttribute } from "appwrite-utils";
7
7
  export const transferStorageLocalToLocal = async (storage, fromBucketId, toBucketId) => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -17,24 +17,24 @@ export class SchemaGenerator {
17
17
  const collections = this.config.collections;
18
18
  delete this.config.collections;
19
19
  const configPath = path.join(this.appwriteFolderPath, "appwriteConfig.ts");
20
- const configContent = `import { type AppwriteConfig } from "appwrite-utils";
21
-
22
- const appwriteConfig: AppwriteConfig = {
23
- appwriteEndpoint: "${this.config.appwriteEndpoint}",
24
- appwriteProject: "${this.config.appwriteProject}",
25
- appwriteKey: "${this.config.appwriteKey}",
26
- enableBackups: ${this.config.enableBackups},
27
- backupInterval: ${this.config.backupInterval},
28
- backupRetention: ${this.config.backupRetention},
29
- enableBackupCleanup: ${this.config.enableBackupCleanup},
30
- enableMockData: ${this.config.enableMockData},
31
- documentBucketId: "${this.config.documentBucketId}",
32
- usersCollectionName: "${this.config.usersCollectionName}",
33
- databases: ${JSON.stringify(this.config.databases)},
34
- buckets: ${JSON.stringify(this.config.buckets)},
35
- };
36
-
37
- export default appwriteConfig;
20
+ const configContent = `import { type AppwriteConfig } from "appwrite-utils";
21
+
22
+ const appwriteConfig: AppwriteConfig = {
23
+ appwriteEndpoint: "${this.config.appwriteEndpoint}",
24
+ appwriteProject: "${this.config.appwriteProject}",
25
+ appwriteKey: "${this.config.appwriteKey}",
26
+ enableBackups: ${this.config.enableBackups},
27
+ backupInterval: ${this.config.backupInterval},
28
+ backupRetention: ${this.config.backupRetention},
29
+ enableBackupCleanup: ${this.config.enableBackupCleanup},
30
+ enableMockData: ${this.config.enableMockData},
31
+ documentBucketId: "${this.config.documentBucketId}",
32
+ usersCollectionName: "${this.config.usersCollectionName}",
33
+ databases: ${JSON.stringify(this.config.databases)},
34
+ buckets: ${JSON.stringify(this.config.buckets)},
35
+ };
36
+
37
+ export default appwriteConfig;
38
38
  `;
39
39
  fs.writeFileSync(configPath, configContent, { encoding: "utf-8" });
40
40
  const collectionsFolderPath = path.join(this.appwriteFolderPath, "collections");
@@ -44,19 +44,19 @@ export class SchemaGenerator {
44
44
  collections?.forEach((collection) => {
45
45
  const { databaseId, ...collectionWithoutDbId } = collection; // Destructure to exclude databaseId
46
46
  const collectionFilePath = path.join(collectionsFolderPath, `${collection.name}.ts`);
47
- const collectionContent = `import { type CollectionCreate } from "appwrite-utils";
48
-
49
- const ${collection.name}Config: Partial<CollectionCreate> = {
50
- name: "${collection.name}",
51
- $id: "${collection.$id}",
52
- enabled: ${collection.enabled},
53
- documentSecurity: ${collection.documentSecurity},
54
- $permissions: [
47
+ const collectionContent = `import { type CollectionCreate } from "appwrite-utils";
48
+
49
+ const ${collection.name}Config: Partial<CollectionCreate> = {
50
+ name: "${collection.name}",
51
+ $id: "${collection.$id}",
52
+ enabled: ${collection.enabled},
53
+ documentSecurity: ${collection.documentSecurity},
54
+ $permissions: [
55
55
  ${collection.$permissions
56
56
  .map((permission) => `{ permission: "${permission.permission}", target: "${permission.target}" }`)
57
- .join(",\n ")}
58
- ],
59
- attributes: [
57
+ .join(",\n ")}
58
+ ],
59
+ attributes: [
60
60
  ${collection.attributes
61
61
  .map((attr) => {
62
62
  return `{ ${Object.entries(attr)
@@ -84,9 +84,9 @@ export class SchemaGenerator {
84
84
  })
85
85
  .join(", ")} }`;
86
86
  })
87
- .join(",\n ")}
88
- ],
89
- indexes: [
87
+ .join(",\n ")}
88
+ ],
89
+ indexes: [
90
90
  ${(collection.indexes?.map((index) => {
91
91
  // Map each attribute to ensure it is properly quoted
92
92
  const formattedAttributes = index.attributes.map((attr) => `"${attr}"`).join(", ") ?? "";
@@ -94,11 +94,11 @@ export class SchemaGenerator {
94
94
  ?.filter((order) => order !== null)
95
95
  .map((order) => `"${order}"`)
96
96
  .join(", ") ?? ""}] }`;
97
- }) ?? []).join(",\n ")}
98
- ]
99
- };
100
-
101
- export default ${collection.name}Config;
97
+ }) ?? []).join(",\n ")}
98
+ ]
99
+ };
100
+
101
+ export default ${collection.name}Config;
102
102
  `;
103
103
  fs.writeFileSync(collectionFilePath, collectionContent, {
104
104
  encoding: "utf-8",
@@ -1,3 +1,3 @@
1
1
  export declare const customDefinitionsFile = "import type { ConverterFunctions, ValidationRules, AfterImportActions } from \"appwrite-utils\";\n\nexport const customConverterFunctions: ConverterFunctions = {\n // Add your custom converter functions here\n}\nexport const customValidationRules: ValidationRules = {\n // Add your custom validation rules here\n}\nexport const customAfterImportActions: AfterImportActions = {\n // Add your custom after import actions here\n}";
2
2
  export declare const createEmptyCollection: (collectionName: string) => void;
3
- export declare const setupDirsFiles: (example?: boolean) => Promise<void>;
3
+ export declare const setupDirsFiles: (example?: boolean, currentDir?: string) => Promise<void>;
@@ -143,8 +143,8 @@ export default ${collectionName};`;
143
143
  const collectionFilePath = path.join(collectionsFolder, `${collectionName}.ts`);
144
144
  writeFileSync(collectionFilePath, emptyCollection);
145
145
  };
146
- export const setupDirsFiles = async (example = false) => {
147
- const basePath = process.cwd();
146
+ export const setupDirsFiles = async (example = false, currentDir) => {
147
+ const basePath = currentDir || process.cwd();
148
148
  const srcPath = path.join(basePath);
149
149
  // Check if src directory exists in the current working directory
150
150
  if (!existsSync(srcPath)) {
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "appwrite-utils-cli",
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.0",
5
- "main": "src/main.ts",
6
- "type": "module",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/zachhandley/AppwriteUtils"
10
- },
11
- "author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
12
- "keywords": [
13
- "appwrite",
14
- "cli",
15
- "utils",
16
- "migrations",
17
- "data",
18
- "database",
19
- "import",
20
- "migration",
21
- "utility"
22
- ],
23
- "bin": {
24
- "appwrite-migrate": "./dist/main.js"
25
- },
26
- "scripts": {
27
- "build": "bun run tsc",
28
- "start": "tsx --no-cache src/main.ts migrate",
29
- "deploy": "bun run build && npm publish --access public",
30
- "postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
31
- },
32
- "dependencies": {
33
- "@types/inquirer": "^9.0.7",
34
- "appwrite-utils": "^0.3.8",
35
- "commander": "^12.1.0",
36
- "inquirer": "^9.3.6",
37
- "js-yaml": "^4.1.0",
38
- "lodash": "^4.17.21",
39
- "luxon": "^3.5.0",
40
- "nanostores": "^0.10.3",
41
- "node-appwrite": "^13.0.0",
42
- "tsx": "^4.17.0",
43
- "ulidx": "^2.4.0",
44
- "winston": "^3.14.1",
45
- "zod": "^3.23.8"
46
- },
47
- "devDependencies": {
48
- "@types/js-yaml": "^4.0.9",
49
- "@types/lodash": "^4.17.7",
50
- "@types/luxon": "^3.4.2",
51
- "typescript": "^5.5.4"
52
- }
53
- }
1
+ {
2
+ "name": "appwrite-utils-cli",
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.3",
5
+ "main": "src/main.ts",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/zachhandley/AppwriteUtils"
10
+ },
11
+ "author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
12
+ "keywords": [
13
+ "appwrite",
14
+ "cli",
15
+ "utils",
16
+ "migrations",
17
+ "data",
18
+ "database",
19
+ "import",
20
+ "migration",
21
+ "utility"
22
+ ],
23
+ "bin": {
24
+ "appwrite-migrate": "./dist/main.js"
25
+ },
26
+ "scripts": {
27
+ "build": "bun run tsc",
28
+ "start": "tsx --no-cache src/main.ts",
29
+ "deploy": "bun run build && npm publish --access public",
30
+ "postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
31
+ },
32
+ "dependencies": {
33
+ "@types/inquirer": "^9.0.7",
34
+ "appwrite-utils": "^0.3.8",
35
+ "commander": "^12.1.0",
36
+ "inquirer": "^9.3.6",
37
+ "js-yaml": "^4.1.0",
38
+ "lodash": "^4.17.21",
39
+ "luxon": "^3.5.0",
40
+ "nanostores": "^0.10.3",
41
+ "node-appwrite": "^13.0.0",
42
+ "tsx": "^4.17.0",
43
+ "ulidx": "^2.4.0",
44
+ "winston": "^3.14.1",
45
+ "zod": "^3.23.8"
46
+ },
47
+ "devDependencies": {
48
+ "@types/js-yaml": "^4.0.9",
49
+ "@types/lodash": "^4.17.7",
50
+ "@types/luxon": "^3.4.2",
51
+ "typescript": "^5.5.4"
52
+ }
53
+ }