appwrite-utils-cli 1.6.0 ā 1.6.1
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.
@@ -14,8 +14,9 @@ export const databaseCommands = {
|
|
14
14
|
MessageFormatter.warning("No databases selected. Skipping database sync.", { prefix: "Database" });
|
15
15
|
return;
|
16
16
|
}
|
17
|
-
const collections = await cli.selectCollectionsAndTables(databases[0], cli.controller.database, chalk.blue("Select local collections/tables to push:"), true,
|
18
|
-
true //
|
17
|
+
const collections = await cli.selectCollectionsAndTables(databases[0], cli.controller.database, chalk.blue("Select local collections/tables to push:"), true, // multiSelect
|
18
|
+
true // prefer local
|
19
|
+
// shouldFilterByDatabase removed - user will be prompted interactively
|
19
20
|
);
|
20
21
|
const { syncFunctions } = await inquirer.prompt([
|
21
22
|
{
|
package/dist/interactiveCLI.js
CHANGED
@@ -341,26 +341,54 @@ export class InteractiveCLI {
|
|
341
341
|
const configCollections = this.getLocalCollections();
|
342
342
|
const collectionsCount = configCollections.filter(c => !c._isFromTablesDir).length;
|
343
343
|
const tablesCount = configCollections.filter(c => c._isFromTablesDir).length;
|
344
|
+
const totalCount = collectionsCount + tablesCount;
|
344
345
|
// Provide context about what's available
|
345
346
|
if (collectionsCount > 0 && tablesCount > 0) {
|
346
|
-
MessageFormatter.info(`\nš
|
347
|
+
MessageFormatter.info(`\nš ${totalCount} total items available:`, { prefix: "Collections" });
|
347
348
|
MessageFormatter.info(` Collections: ${collectionsCount} (from collections/ folder)`, { prefix: "Collections" });
|
348
349
|
MessageFormatter.info(` Tables: ${tablesCount} (from tables/ folder)`, { prefix: "Collections" });
|
349
|
-
|
350
|
+
}
|
351
|
+
else if (collectionsCount > 0) {
|
352
|
+
MessageFormatter.info(`š ${collectionsCount} collections available from collections/ folder`, { prefix: "Collections" });
|
353
|
+
}
|
354
|
+
else if (tablesCount > 0) {
|
355
|
+
MessageFormatter.info(`š ${tablesCount} tables available from tables/ folder`, { prefix: "Collections" });
|
356
|
+
}
|
357
|
+
// Ask user if they want to filter by database or show all
|
358
|
+
const { filterChoice } = await inquirer.prompt([
|
359
|
+
{
|
360
|
+
type: "list",
|
361
|
+
name: "filterChoice",
|
362
|
+
message: chalk.blue("How would you like to view collections/tables?"),
|
363
|
+
choices: [
|
364
|
+
{
|
365
|
+
name: `Show all available collections/tables (${totalCount} total) - You can push any collection to any database`,
|
366
|
+
value: "all"
|
367
|
+
},
|
368
|
+
{
|
369
|
+
name: `Filter by database "${database.name}" - Show only related collections/tables`,
|
370
|
+
value: "filter"
|
371
|
+
}
|
372
|
+
],
|
373
|
+
default: "all"
|
374
|
+
}
|
375
|
+
]);
|
376
|
+
// User's choice overrides the parameter
|
377
|
+
const userWantsFiltering = filterChoice === "filter";
|
378
|
+
// Show appropriate informational message
|
379
|
+
if (userWantsFiltering) {
|
380
|
+
MessageFormatter.info(`ā¹ļø Showing collections/tables related to database "${database.name}"`, { prefix: "Collections" });
|
381
|
+
if (tablesCount > 0) {
|
350
382
|
const filteredTables = configCollections.filter(c => c._isFromTablesDir && (!c.databaseId || c.databaseId === database.$id)).length;
|
351
383
|
if (filteredTables !== tablesCount) {
|
352
|
-
MessageFormatter.
|
384
|
+
MessageFormatter.info(` ${filteredTables}/${tablesCount} tables match this database`, { prefix: "Collections" });
|
353
385
|
}
|
354
386
|
}
|
355
|
-
MessageFormatter.info('', { prefix: "Collections" });
|
356
387
|
}
|
357
|
-
else
|
358
|
-
MessageFormatter.info(
|
359
|
-
}
|
360
|
-
else if (tablesCount > 0) {
|
361
|
-
MessageFormatter.info(`š ${tablesCount} tables available from tables/ folder\n`, { prefix: "Collections" });
|
388
|
+
else {
|
389
|
+
MessageFormatter.info(`ā¹ļø Showing all available collections/tables - you can push any collection to any database\n`, { prefix: "Collections" });
|
362
390
|
}
|
363
|
-
return this.selectCollections(database, databasesClient, message, multiSelect, preferLocal,
|
391
|
+
return this.selectCollections(database, databasesClient, message, multiSelect, preferLocal, userWantsFiltering);
|
364
392
|
}
|
365
393
|
getTemplateDefaults(template) {
|
366
394
|
const defaults = {
|
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.6.
|
4
|
+
"version": "1.6.1",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
@@ -27,9 +27,9 @@ export const databaseCommands = {
|
|
27
27
|
databases[0],
|
28
28
|
(cli as any).controller!.database!,
|
29
29
|
chalk.blue("Select local collections/tables to push:"),
|
30
|
-
true,
|
31
|
-
true
|
32
|
-
|
30
|
+
true, // multiSelect
|
31
|
+
true // prefer local
|
32
|
+
// shouldFilterByDatabase removed - user will be prompted interactively
|
33
33
|
);
|
34
34
|
|
35
35
|
const { syncFunctions } = await inquirer.prompt([
|
package/src/interactiveCLI.ts
CHANGED
@@ -436,29 +436,58 @@ export class InteractiveCLI {
|
|
436
436
|
const configCollections = this.getLocalCollections();
|
437
437
|
const collectionsCount = configCollections.filter(c => !c._isFromTablesDir).length;
|
438
438
|
const tablesCount = configCollections.filter(c => c._isFromTablesDir).length;
|
439
|
+
const totalCount = collectionsCount + tablesCount;
|
439
440
|
|
440
441
|
// Provide context about what's available
|
441
442
|
if (collectionsCount > 0 && tablesCount > 0) {
|
442
|
-
MessageFormatter.info(`\nš
|
443
|
+
MessageFormatter.info(`\nš ${totalCount} total items available:`, { prefix: "Collections" });
|
443
444
|
MessageFormatter.info(` Collections: ${collectionsCount} (from collections/ folder)`, { prefix: "Collections" });
|
444
445
|
MessageFormatter.info(` Tables: ${tablesCount} (from tables/ folder)`, { prefix: "Collections" });
|
446
|
+
} else if (collectionsCount > 0) {
|
447
|
+
MessageFormatter.info(`š ${collectionsCount} collections available from collections/ folder`, { prefix: "Collections" });
|
448
|
+
} else if (tablesCount > 0) {
|
449
|
+
MessageFormatter.info(`š ${tablesCount} tables available from tables/ folder`, { prefix: "Collections" });
|
450
|
+
}
|
451
|
+
|
452
|
+
// Ask user if they want to filter by database or show all
|
453
|
+
const { filterChoice } = await inquirer.prompt([
|
454
|
+
{
|
455
|
+
type: "list",
|
456
|
+
name: "filterChoice",
|
457
|
+
message: chalk.blue("How would you like to view collections/tables?"),
|
458
|
+
choices: [
|
459
|
+
{
|
460
|
+
name: `Show all available collections/tables (${totalCount} total) - You can push any collection to any database`,
|
461
|
+
value: "all"
|
462
|
+
},
|
463
|
+
{
|
464
|
+
name: `Filter by database "${database.name}" - Show only related collections/tables`,
|
465
|
+
value: "filter"
|
466
|
+
}
|
467
|
+
],
|
468
|
+
default: "all"
|
469
|
+
}
|
470
|
+
]);
|
445
471
|
|
446
|
-
|
472
|
+
// User's choice overrides the parameter
|
473
|
+
const userWantsFiltering = filterChoice === "filter";
|
474
|
+
|
475
|
+
// Show appropriate informational message
|
476
|
+
if (userWantsFiltering) {
|
477
|
+
MessageFormatter.info(`ā¹ļø Showing collections/tables related to database "${database.name}"`, { prefix: "Collections" });
|
478
|
+
if (tablesCount > 0) {
|
447
479
|
const filteredTables = configCollections.filter(c =>
|
448
480
|
c._isFromTablesDir && (!c.databaseId || c.databaseId === database.$id)
|
449
481
|
).length;
|
450
482
|
if (filteredTables !== tablesCount) {
|
451
|
-
MessageFormatter.
|
483
|
+
MessageFormatter.info(` ${filteredTables}/${tablesCount} tables match this database`, { prefix: "Collections" });
|
452
484
|
}
|
453
485
|
}
|
454
|
-
|
455
|
-
|
456
|
-
MessageFormatter.info(`š ${collectionsCount} collections available from collections/ folder\n`, { prefix: "Collections" });
|
457
|
-
} else if (tablesCount > 0) {
|
458
|
-
MessageFormatter.info(`š ${tablesCount} tables available from tables/ folder\n`, { prefix: "Collections" });
|
486
|
+
} else {
|
487
|
+
MessageFormatter.info(`ā¹ļø Showing all available collections/tables - you can push any collection to any database\n`, { prefix: "Collections" });
|
459
488
|
}
|
460
489
|
|
461
|
-
return this.selectCollections(database, databasesClient, message, multiSelect, preferLocal,
|
490
|
+
return this.selectCollections(database, databasesClient, message, multiSelect, preferLocal, userWantsFiltering);
|
462
491
|
}
|
463
492
|
|
464
493
|
private getTemplateDefaults(template: string) {
|