appwrite-utils-cli 1.2.8 → 1.2.10

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.
@@ -236,10 +236,10 @@ export const loadYamlConfig = async (configPath) => {
236
236
  export const findYamlConfig = (startDir) => {
237
237
  // First check current directory for YAML configs
238
238
  const possiblePaths = [
239
- path.join(startDir, ".appwrite", "appwriteConfig.yaml"),
240
- path.join(startDir, ".appwrite", "appwriteConfig.yml"),
241
239
  path.join(startDir, ".appwrite", "config.yaml"),
242
240
  path.join(startDir, ".appwrite", "config.yml"),
241
+ path.join(startDir, ".appwrite", "appwriteConfig.yaml"),
242
+ path.join(startDir, ".appwrite", "appwriteConfig.yml"),
243
243
  path.join(startDir, "appwrite.yaml"),
244
244
  path.join(startDir, "appwrite.yml"),
245
245
  ];
@@ -257,6 +257,8 @@ export const findYamlConfig = (startDir) => {
257
257
  const parentDir = path.dirname(startDir);
258
258
  if (parentDir !== startDir && path.basename(parentDir) !== 'node_modules') {
259
259
  const parentPossiblePaths = [
260
+ path.join(parentDir, ".appwrite", "config.yaml"),
261
+ path.join(parentDir, ".appwrite", "config.yml"),
260
262
  path.join(parentDir, ".appwrite", "appwriteConfig.yaml"),
261
263
  path.join(parentDir, ".appwrite", "appwriteConfig.yml"),
262
264
  path.join(parentDir, "appwrite.yaml"),
@@ -325,10 +327,10 @@ const findYamlConfigRecursive = (dir, depth = 0) => {
325
327
  // Check if this is an .appwrite directory
326
328
  if (entry.name === ".appwrite") {
327
329
  const configPaths = [
328
- path.join(fullPath, "appwriteConfig.yaml"),
329
- path.join(fullPath, "appwriteConfig.yml"),
330
330
  path.join(fullPath, "config.yaml"),
331
331
  path.join(fullPath, "config.yml"),
332
+ path.join(fullPath, "appwriteConfig.yaml"),
333
+ path.join(fullPath, "appwriteConfig.yml"),
332
334
  ];
333
335
  for (const configPath of configPaths) {
334
336
  if (fs.existsSync(configPath)) {
@@ -1067,7 +1067,7 @@ export class InteractiveCLI {
1067
1067
  }
1068
1068
  // Update schemas after all changes
1069
1069
  const schemaGenerator = new SchemaGenerator(this.controller.config, this.controller.getAppwriteFolderPath());
1070
- schemaGenerator.updateConfig(this.controller.config);
1070
+ await schemaGenerator.updateConfig(this.controller.config, !this.isUsingTypeScriptConfig);
1071
1071
  }
1072
1072
  console.log(chalk.green("✨ Configurations synchronized successfully!"));
1073
1073
  }
@@ -6,7 +6,7 @@ export declare class SchemaGenerator {
6
6
  constructor(config: AppwriteConfig, appwriteFolderPath: string);
7
7
  updateYamlCollections(): void;
8
8
  updateTsSchemas(): void;
9
- updateConfig(config: AppwriteConfig): void;
9
+ updateConfig(config: AppwriteConfig, isYamlConfig?: boolean): Promise<void>;
10
10
  private updateYamlConfig;
11
11
  private updateTypeScriptConfig;
12
12
  private extractRelationships;
@@ -154,13 +154,18 @@ export class SchemaGenerator {
154
154
  console.log(`Collection schema written to ${collectionFilePath}`);
155
155
  });
156
156
  }
157
- updateConfig(config) {
158
- // Check if user is using YAML config
159
- const { findYamlConfig, writeYamlConfig } = require("../config/yamlConfig.js");
160
- const yamlConfigPath = findYamlConfig(this.appwriteFolderPath);
161
- if (yamlConfigPath) {
162
- // User has YAML config - update it and generate individual collection files
163
- this.updateYamlConfig(config, yamlConfigPath);
157
+ async updateConfig(config, isYamlConfig = false) {
158
+ if (isYamlConfig) {
159
+ // User has YAML config - find the config file and update it + generate individual collection files
160
+ const { findYamlConfig } = await import("../config/yamlConfig.js");
161
+ const yamlConfigPath = findYamlConfig(this.appwriteFolderPath);
162
+ if (yamlConfigPath) {
163
+ await this.updateYamlConfig(config, yamlConfigPath);
164
+ }
165
+ else {
166
+ console.warn("⚠️ YAML config expected but not found, falling back to TypeScript");
167
+ this.updateTypeScriptConfig(config);
168
+ }
164
169
  }
165
170
  else {
166
171
  // User has TypeScript config - update the TS file
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": "1.2.8",
4
+ "version": "1.2.10",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -248,10 +248,10 @@ export const loadYamlConfig = async (configPath: string): Promise<AppwriteConfig
248
248
  export const findYamlConfig = (startDir: string): string | null => {
249
249
  // First check current directory for YAML configs
250
250
  const possiblePaths = [
251
- path.join(startDir, ".appwrite", "appwriteConfig.yaml"),
252
- path.join(startDir, ".appwrite", "appwriteConfig.yml"),
253
251
  path.join(startDir, ".appwrite", "config.yaml"),
254
252
  path.join(startDir, ".appwrite", "config.yml"),
253
+ path.join(startDir, ".appwrite", "appwriteConfig.yaml"),
254
+ path.join(startDir, ".appwrite", "appwriteConfig.yml"),
255
255
  path.join(startDir, "appwrite.yaml"),
256
256
  path.join(startDir, "appwrite.yml"),
257
257
  ];
@@ -272,6 +272,8 @@ export const findYamlConfig = (startDir: string): string | null => {
272
272
  const parentDir = path.dirname(startDir);
273
273
  if (parentDir !== startDir && path.basename(parentDir) !== 'node_modules') {
274
274
  const parentPossiblePaths = [
275
+ path.join(parentDir, ".appwrite", "config.yaml"),
276
+ path.join(parentDir, ".appwrite", "config.yml"),
275
277
  path.join(parentDir, ".appwrite", "appwriteConfig.yaml"),
276
278
  path.join(parentDir, ".appwrite", "appwriteConfig.yml"),
277
279
  path.join(parentDir, "appwrite.yaml"),
@@ -349,10 +351,10 @@ const findYamlConfigRecursive = (dir: string, depth: number = 0): string | null
349
351
  // Check if this is an .appwrite directory
350
352
  if (entry.name === ".appwrite") {
351
353
  const configPaths = [
352
- path.join(fullPath, "appwriteConfig.yaml"),
353
- path.join(fullPath, "appwriteConfig.yml"),
354
354
  path.join(fullPath, "config.yaml"),
355
355
  path.join(fullPath, "config.yml"),
356
+ path.join(fullPath, "appwriteConfig.yaml"),
357
+ path.join(fullPath, "appwriteConfig.yml"),
356
358
  ];
357
359
 
358
360
  for (const configPath of configPaths) {
@@ -1442,7 +1442,7 @@ export class InteractiveCLI {
1442
1442
  this.controller!.config!,
1443
1443
  this.controller!.getAppwriteFolderPath()!
1444
1444
  );
1445
- schemaGenerator.updateConfig(this.controller!.config!);
1445
+ await schemaGenerator.updateConfig(this.controller!.config!, !this.isUsingTypeScriptConfig);
1446
1446
  }
1447
1447
 
1448
1448
  console.log(chalk.green("✨ Configurations synchronized successfully!"));
@@ -197,14 +197,18 @@ export class SchemaGenerator {
197
197
  });
198
198
  }
199
199
 
200
- public updateConfig(config: AppwriteConfig): void {
201
- // Check if user is using YAML config
202
- const { findYamlConfig, writeYamlConfig } = require("../config/yamlConfig.js");
203
- const yamlConfigPath = findYamlConfig(this.appwriteFolderPath);
204
-
205
- if (yamlConfigPath) {
206
- // User has YAML config - update it and generate individual collection files
207
- this.updateYamlConfig(config, yamlConfigPath);
200
+ public async updateConfig(config: AppwriteConfig, isYamlConfig: boolean = false): Promise<void> {
201
+ if (isYamlConfig) {
202
+ // User has YAML config - find the config file and update it + generate individual collection files
203
+ const { findYamlConfig } = await import("../config/yamlConfig.js");
204
+ const yamlConfigPath = findYamlConfig(this.appwriteFolderPath);
205
+
206
+ if (yamlConfigPath) {
207
+ await this.updateYamlConfig(config, yamlConfigPath);
208
+ } else {
209
+ console.warn("⚠️ YAML config expected but not found, falling back to TypeScript");
210
+ this.updateTypeScriptConfig(config);
211
+ }
208
212
  } else {
209
213
  // User has TypeScript config - update the TS file
210
214
  this.updateTypeScriptConfig(config);