appwrite-utils-cli 1.2.6 → 1.2.8
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/dist/config/yamlConfig.d.ts +6 -0
- package/dist/config/yamlConfig.js +127 -1
- package/dist/migrations/comprehensiveTransfer.d.ts +25 -1
- package/dist/migrations/comprehensiveTransfer.js +298 -34
- package/dist/shared/schemaGenerator.d.ts +2 -0
- package/dist/shared/schemaGenerator.js +31 -2
- package/package.json +1 -1
- package/src/config/yamlConfig.ts +130 -1
- package/src/migrations/comprehensiveTransfer.ts +481 -45
- package/src/shared/schemaGenerator.ts +35 -2
- package/src/utils/yamlConverter.ts +2 -1
package/src/config/yamlConfig.ts
CHANGED
@@ -216,7 +216,7 @@ export const convertYamlToAppwriteConfig = (yamlConfig: YamlConfig): AppwriteCon
|
|
216
216
|
templateBranch: func.templateBranch || "",
|
217
217
|
specification: func.specification || "s-0.5vcpu-512mb",
|
218
218
|
})),
|
219
|
-
collections: [],
|
219
|
+
collections: [], // Note: Collections are managed separately in YAML configs via individual collection files
|
220
220
|
};
|
221
221
|
|
222
222
|
return appwriteConfig;
|
@@ -427,6 +427,135 @@ export const generateYamlConfigTemplate = (outputPath: string) => {
|
|
427
427
|
fs.writeFileSync(outputPath, finalContent, "utf8");
|
428
428
|
};
|
429
429
|
|
430
|
+
/**
|
431
|
+
* Converts AppwriteConfig back to YAML format and writes to file
|
432
|
+
* @param configPath Path to the YAML config file
|
433
|
+
* @param config The AppwriteConfig to convert and save
|
434
|
+
*/
|
435
|
+
export const writeYamlConfig = async (configPath: string, config: AppwriteConfig): Promise<void> => {
|
436
|
+
try {
|
437
|
+
// Convert AppwriteConfig back to YAML format
|
438
|
+
const yamlConfig: YamlConfig = {
|
439
|
+
appwrite: {
|
440
|
+
endpoint: config.appwriteEndpoint,
|
441
|
+
project: config.appwriteProject,
|
442
|
+
key: config.appwriteKey,
|
443
|
+
},
|
444
|
+
logging: {
|
445
|
+
enabled: config.logging?.enabled || false,
|
446
|
+
level: config.logging?.level || "info",
|
447
|
+
directory: config.logging?.logDirectory,
|
448
|
+
console: config.logging?.console || false,
|
449
|
+
},
|
450
|
+
backups: {
|
451
|
+
enabled: config.enableBackups !== false,
|
452
|
+
interval: config.backupInterval || 3600,
|
453
|
+
retention: config.backupRetention || 30,
|
454
|
+
cleanup: config.enableBackupCleanup !== false,
|
455
|
+
},
|
456
|
+
data: {
|
457
|
+
enableMockData: config.enableMockData || false,
|
458
|
+
documentBucketId: config.documentBucketId || "documents",
|
459
|
+
usersCollectionName: config.usersCollectionName || "Members",
|
460
|
+
importDirectory: config.schemaConfig?.importDirectory || "importData",
|
461
|
+
},
|
462
|
+
schemas: {
|
463
|
+
outputDirectory: config.schemaConfig?.outputDirectory || "schemas",
|
464
|
+
yamlSchemaDirectory: config.schemaConfig?.yamlSchemaDirectory || ".yaml_schemas",
|
465
|
+
},
|
466
|
+
migrations: {
|
467
|
+
enabled: config.useMigrations !== false,
|
468
|
+
},
|
469
|
+
databases: config.databases?.map(db => ({
|
470
|
+
id: db.$id,
|
471
|
+
name: db.name,
|
472
|
+
bucket: db.bucket ? {
|
473
|
+
id: db.bucket.$id,
|
474
|
+
name: db.bucket.name,
|
475
|
+
permissions: db.bucket.permissions || [],
|
476
|
+
fileSecurity: db.bucket.fileSecurity,
|
477
|
+
enabled: db.bucket.enabled,
|
478
|
+
maximumFileSize: db.bucket.maximumFileSize,
|
479
|
+
allowedFileExtensions: db.bucket.allowedFileExtensions,
|
480
|
+
compression: db.bucket.compression as "none" | "gzip" | "zstd",
|
481
|
+
encryption: db.bucket.encryption,
|
482
|
+
antivirus: db.bucket.antivirus,
|
483
|
+
} : undefined,
|
484
|
+
})) || [],
|
485
|
+
buckets: config.buckets?.map(bucket => ({
|
486
|
+
id: bucket.$id,
|
487
|
+
name: bucket.name,
|
488
|
+
permissions: bucket.permissions || [],
|
489
|
+
fileSecurity: bucket.fileSecurity,
|
490
|
+
enabled: bucket.enabled,
|
491
|
+
maximumFileSize: bucket.maximumFileSize,
|
492
|
+
allowedFileExtensions: bucket.allowedFileExtensions,
|
493
|
+
compression: bucket.compression as "none" | "gzip" | "zstd",
|
494
|
+
encryption: bucket.encryption,
|
495
|
+
antivirus: bucket.antivirus,
|
496
|
+
})) || [],
|
497
|
+
functions: config.functions?.map(func => ({
|
498
|
+
id: func.$id,
|
499
|
+
name: func.name,
|
500
|
+
runtime: func.runtime,
|
501
|
+
execute: func.execute,
|
502
|
+
events: func.events,
|
503
|
+
schedule: func.schedule,
|
504
|
+
timeout: func.timeout,
|
505
|
+
enabled: func.enabled,
|
506
|
+
logging: func.logging,
|
507
|
+
entrypoint: func.entrypoint,
|
508
|
+
commands: func.commands,
|
509
|
+
scopes: func.scopes,
|
510
|
+
installationId: func.installationId,
|
511
|
+
providerRepositoryId: func.providerRepositoryId,
|
512
|
+
providerBranch: func.providerBranch,
|
513
|
+
providerSilentMode: func.providerSilentMode,
|
514
|
+
providerRootDirectory: func.providerRootDirectory,
|
515
|
+
templateRepository: func.templateRepository,
|
516
|
+
templateOwner: func.templateOwner,
|
517
|
+
templateRootDirectory: func.templateRootDirectory,
|
518
|
+
// templateBranch: func.templateBranch, // Not available in AppwriteFunction type
|
519
|
+
specification: func.specification,
|
520
|
+
})) || [],
|
521
|
+
};
|
522
|
+
|
523
|
+
// Write YAML config
|
524
|
+
const yamlContent = yaml.dump(yamlConfig, {
|
525
|
+
indent: 2,
|
526
|
+
lineWidth: 120,
|
527
|
+
sortKeys: false,
|
528
|
+
});
|
529
|
+
|
530
|
+
// Preserve schema reference if it exists
|
531
|
+
let finalContent = yamlContent;
|
532
|
+
if (fs.existsSync(configPath)) {
|
533
|
+
const existingContent = fs.readFileSync(configPath, "utf8");
|
534
|
+
const lines = existingContent.split('\n');
|
535
|
+
const schemaLine = lines.find(line => line.startsWith('# yaml-language-server:'));
|
536
|
+
const commentLine = lines.find(line => line.startsWith('# Appwrite Project Configuration'));
|
537
|
+
|
538
|
+
if (schemaLine) {
|
539
|
+
finalContent = schemaLine + '\n';
|
540
|
+
if (commentLine) {
|
541
|
+
finalContent += commentLine + '\n';
|
542
|
+
}
|
543
|
+
finalContent += yamlContent;
|
544
|
+
}
|
545
|
+
} else {
|
546
|
+
// Add schema reference for new files
|
547
|
+
const schemaReference = "# yaml-language-server: $schema=./.yaml_schemas/appwrite-config.schema.json\n";
|
548
|
+
finalContent = schemaReference + "# Appwrite Project Configuration\n" + yamlContent;
|
549
|
+
}
|
550
|
+
|
551
|
+
fs.writeFileSync(configPath, finalContent, "utf8");
|
552
|
+
console.log(`✅ Updated YAML configuration at ${configPath}`);
|
553
|
+
} catch (error) {
|
554
|
+
console.error("❌ Error writing YAML config:", error instanceof Error ? error.message : error);
|
555
|
+
throw error;
|
556
|
+
}
|
557
|
+
};
|
558
|
+
|
430
559
|
/**
|
431
560
|
* Adds a new function to the YAML config file
|
432
561
|
* @param configPath Path to the YAML config file
|