appwrite-utils-cli 0.10.2 → 0.10.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 +1 -0
- package/dist/interactiveCLI.js +30 -12
- package/package.json +1 -1
- package/src/interactiveCLI.ts +48 -19
package/README.md
CHANGED
@@ -147,6 +147,7 @@ This updated CLI ensures that developers have robust tools at their fingertips t
|
|
147
147
|
|
148
148
|
## Changelog
|
149
149
|
|
150
|
+
- 0.10.03: Fixed `syncDb` to push the configurations properly, accidentally hurt it during `synchronizeConfigurations`
|
150
151
|
- 0.10.02: Updated `wipeCollection` to handle errors gracefully
|
151
152
|
- 0.10.01: Fixed `predeployCommands` to work
|
152
153
|
- 0.10.001: Updated `deployFunction` to not updateConfig if it's already present
|
package/dist/interactiveCLI.js
CHANGED
@@ -718,28 +718,46 @@ export class InteractiveCLI {
|
|
718
718
|
}, bucketId.length > 0 ? bucketId : ulid());
|
719
719
|
}
|
720
720
|
async syncDb() {
|
721
|
-
console.log(chalk.
|
722
|
-
const
|
723
|
-
|
724
|
-
|
721
|
+
console.log(chalk.blue("Pushing local configuration to Appwrite..."));
|
722
|
+
const databases = await this.selectDatabases(this.getLocalDatabases(), chalk.blue("Select local databases to push:"), true);
|
723
|
+
if (!databases.length) {
|
724
|
+
console.log(chalk.yellow("No databases selected. Skipping database sync."));
|
725
|
+
return;
|
726
|
+
}
|
727
|
+
const collections = await this.selectCollections(databases[0], this.controller.database, chalk.blue("Select local collections to push:"), true, true // prefer local
|
725
728
|
);
|
726
|
-
const
|
729
|
+
const { syncFunctions } = await inquirer.prompt([
|
727
730
|
{
|
728
731
|
type: "confirm",
|
729
732
|
name: "syncFunctions",
|
730
|
-
message: "Do you want to
|
733
|
+
message: "Do you want to push local functions to remote?",
|
731
734
|
default: false,
|
732
735
|
},
|
733
736
|
]);
|
734
|
-
|
735
|
-
|
736
|
-
);
|
737
|
+
try {
|
738
|
+
// First sync databases and collections
|
737
739
|
await this.controller.syncDb(databases, collections);
|
738
|
-
|
739
|
-
|
740
|
+
console.log(chalk.green("Database and collections pushed successfully"));
|
741
|
+
// Then handle functions if requested
|
742
|
+
if (syncFunctions && this.controller.config?.functions?.length) {
|
743
|
+
const functions = await this.selectFunctions(chalk.blue("Select local functions to push:"), true, true // prefer local
|
744
|
+
);
|
745
|
+
for (const func of functions) {
|
746
|
+
try {
|
747
|
+
await this.controller.deployFunction(func.name);
|
748
|
+
console.log(chalk.green(`Function ${func.name} deployed successfully`));
|
749
|
+
}
|
750
|
+
catch (error) {
|
751
|
+
console.error(chalk.red(`Failed to deploy function ${func.name}:`), error);
|
752
|
+
}
|
753
|
+
}
|
740
754
|
}
|
755
|
+
console.log(chalk.green("Local configuration push completed successfully!"));
|
756
|
+
}
|
757
|
+
catch (error) {
|
758
|
+
console.error(chalk.red("Failed to push local configuration:"), error);
|
759
|
+
throw error;
|
741
760
|
}
|
742
|
-
console.log(chalk.green("Database sync completed."));
|
743
761
|
}
|
744
762
|
async synchronizeConfigurations() {
|
745
763
|
console.log(chalk.blue("Synchronizing configurations..."));
|
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.10.
|
4
|
+
"version": "0.10.03",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/interactiveCLI.ts
CHANGED
@@ -977,44 +977,73 @@ export class InteractiveCLI {
|
|
977
977
|
}
|
978
978
|
|
979
979
|
private async syncDb(): Promise<void> {
|
980
|
-
console.log(chalk.
|
981
|
-
|
980
|
+
console.log(chalk.blue("Pushing local configuration to Appwrite..."));
|
981
|
+
|
982
982
|
const databases = await this.selectDatabases(
|
983
|
-
|
984
|
-
chalk.blue("Select databases to
|
983
|
+
this.getLocalDatabases(),
|
984
|
+
chalk.blue("Select local databases to push:"),
|
985
985
|
true
|
986
986
|
);
|
987
|
+
|
988
|
+
if (!databases.length) {
|
989
|
+
console.log(
|
990
|
+
chalk.yellow("No databases selected. Skipping database sync.")
|
991
|
+
);
|
992
|
+
return;
|
993
|
+
}
|
994
|
+
|
987
995
|
const collections = await this.selectCollections(
|
988
996
|
databases[0],
|
989
997
|
this.controller!.database!,
|
990
|
-
chalk.blue("Select collections to
|
998
|
+
chalk.blue("Select local collections to push:"),
|
991
999
|
true,
|
992
1000
|
true // prefer local
|
993
1001
|
);
|
994
|
-
|
1002
|
+
|
1003
|
+
const { syncFunctions } = await inquirer.prompt([
|
995
1004
|
{
|
996
1005
|
type: "confirm",
|
997
1006
|
name: "syncFunctions",
|
998
|
-
message: "Do you want to
|
1007
|
+
message: "Do you want to push local functions to remote?",
|
999
1008
|
default: false,
|
1000
1009
|
},
|
1001
1010
|
]);
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
true,
|
1006
|
-
true // prefer local
|
1007
|
-
);
|
1011
|
+
|
1012
|
+
try {
|
1013
|
+
// First sync databases and collections
|
1008
1014
|
await this.controller!.syncDb(databases, collections);
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1015
|
+
console.log(chalk.green("Database and collections pushed successfully"));
|
1016
|
+
|
1017
|
+
// Then handle functions if requested
|
1018
|
+
if (syncFunctions && this.controller!.config?.functions?.length) {
|
1019
|
+
const functions = await this.selectFunctions(
|
1020
|
+
chalk.blue("Select local functions to push:"),
|
1021
|
+
true,
|
1022
|
+
true // prefer local
|
1014
1023
|
);
|
1024
|
+
|
1025
|
+
for (const func of functions) {
|
1026
|
+
try {
|
1027
|
+
await this.controller!.deployFunction(func.name);
|
1028
|
+
console.log(
|
1029
|
+
chalk.green(`Function ${func.name} deployed successfully`)
|
1030
|
+
);
|
1031
|
+
} catch (error) {
|
1032
|
+
console.error(
|
1033
|
+
chalk.red(`Failed to deploy function ${func.name}:`),
|
1034
|
+
error
|
1035
|
+
);
|
1036
|
+
}
|
1037
|
+
}
|
1015
1038
|
}
|
1039
|
+
|
1040
|
+
console.log(
|
1041
|
+
chalk.green("Local configuration push completed successfully!")
|
1042
|
+
);
|
1043
|
+
} catch (error) {
|
1044
|
+
console.error(chalk.red("Failed to push local configuration:"), error);
|
1045
|
+
throw error;
|
1016
1046
|
}
|
1017
|
-
console.log(chalk.green("Database sync completed."));
|
1018
1047
|
}
|
1019
1048
|
|
1020
1049
|
private async synchronizeConfigurations(): Promise<void> {
|