appwrite-utils-cli 0.10.72 → 0.10.74
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 +2 -0
- package/dist/main.js +4 -0
- package/dist/migrations/transfer.js +19 -3
- package/package.json +1 -1
- package/src/main.ts +5 -0
- package/src/migrations/transfer.ts +35 -9
package/README.md
CHANGED
@@ -148,6 +148,8 @@ This updated CLI ensures that developers have robust tools at their fingertips t
|
|
148
148
|
|
149
149
|
## Changelog
|
150
150
|
|
151
|
+
- 0.10.74: Fix moving users, should update Labels now
|
152
|
+
- 0.10.73: Fix moving users, passwords should work now (from Appwrite, Argon2)
|
151
153
|
- 0.10.71: Fix create template function `__dirname`
|
152
154
|
- 0.10.70: Fixed `--transfer-users` phones
|
153
155
|
- 0.10.67: Added `--transfer-users` boolean flag to also transfer users between projects
|
package/dist/main.js
CHANGED
@@ -12,6 +12,10 @@ import { fetchAllCollections } from "./collections/methods.js";
|
|
12
12
|
import chalk from "chalk";
|
13
13
|
import { listSpecifications } from "./functions/methods.js";
|
14
14
|
const argv = yargs(hideBin(process.argv))
|
15
|
+
.option("config", {
|
16
|
+
type: "string",
|
17
|
+
description: "Appwrite Config file name",
|
18
|
+
})
|
15
19
|
.option("it", {
|
16
20
|
alias: ["interactive", "i"],
|
17
21
|
type: "boolean",
|
@@ -407,9 +407,25 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
407
407
|
const phone = user.phone
|
408
408
|
? converterFunctions.convertPhoneStringToUSInternational(user.phone)
|
409
409
|
: undefined;
|
410
|
-
|
411
|
-
|
412
|
-
|
410
|
+
if (user.hash) {
|
411
|
+
await tryAwaitWithRetry(async () => remoteUsers.createArgon2User(user.$id, user.email, user.password, // password - cannot transfer hashed passwords
|
412
|
+
user.name // phone - optional
|
413
|
+
));
|
414
|
+
if (phone) {
|
415
|
+
await tryAwaitWithRetry(async () => remoteUsers.updatePhone(user.$id, phone));
|
416
|
+
}
|
417
|
+
if (user.labels && user.labels.length > 0) {
|
418
|
+
await tryAwaitWithRetry(async () => remoteUsers.updateLabels(user.$id, user.labels));
|
419
|
+
}
|
420
|
+
}
|
421
|
+
else {
|
422
|
+
await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, // phone - optional
|
423
|
+
user.password, // password - cannot transfer hashed passwords
|
424
|
+
user.name));
|
425
|
+
if (user.labels && user.labels.length > 0) {
|
426
|
+
await tryAwaitWithRetry(async () => remoteUsers.updateLabels(user.$id, user.labels));
|
427
|
+
}
|
428
|
+
}
|
413
429
|
// Update user preferences and status
|
414
430
|
await tryAwaitWithRetry(async () => remoteUsers.updatePrefs(user.$id, user.prefs));
|
415
431
|
if (!user.emailVerification) {
|
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.74",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/main.ts
CHANGED
@@ -15,6 +15,7 @@ import chalk from "chalk";
|
|
15
15
|
import { listSpecifications } from "./functions/methods.js";
|
16
16
|
|
17
17
|
interface CliOptions {
|
18
|
+
config?: string;
|
18
19
|
it?: boolean;
|
19
20
|
dbIds?: string;
|
20
21
|
collectionIds?: string;
|
@@ -50,6 +51,10 @@ interface CliOptions {
|
|
50
51
|
type ParsedArgv = ArgumentsCamelCase<CliOptions>;
|
51
52
|
|
52
53
|
const argv = yargs(hideBin(process.argv))
|
54
|
+
.option("config", {
|
55
|
+
type: "string",
|
56
|
+
description: "Appwrite Config file name",
|
57
|
+
})
|
53
58
|
.option("it", {
|
54
59
|
alias: ["interactive", "i"],
|
55
60
|
type: "boolean",
|
@@ -815,15 +815,41 @@ export const transferUsersLocalToRemote = async (
|
|
815
815
|
? converterFunctions.convertPhoneStringToUSInternational(user.phone)
|
816
816
|
: undefined;
|
817
817
|
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
818
|
+
if (user.hash) {
|
819
|
+
await tryAwaitWithRetry(async () =>
|
820
|
+
remoteUsers.createArgon2User(
|
821
|
+
user.$id,
|
822
|
+
user.email,
|
823
|
+
user.password!, // password - cannot transfer hashed passwords
|
824
|
+
user.name // phone - optional
|
825
|
+
)
|
826
|
+
);
|
827
|
+
if (phone) {
|
828
|
+
await tryAwaitWithRetry(async () =>
|
829
|
+
remoteUsers.updatePhone(user.$id, phone)
|
830
|
+
);
|
831
|
+
}
|
832
|
+
if (user.labels && user.labels.length > 0) {
|
833
|
+
await tryAwaitWithRetry(async () =>
|
834
|
+
remoteUsers.updateLabels(user.$id, user.labels)
|
835
|
+
);
|
836
|
+
}
|
837
|
+
} else {
|
838
|
+
await tryAwaitWithRetry(async () =>
|
839
|
+
remoteUsers.create(
|
840
|
+
user.$id,
|
841
|
+
user.email,
|
842
|
+
phone, // phone - optional
|
843
|
+
user.password, // password - cannot transfer hashed passwords
|
844
|
+
user.name
|
845
|
+
)
|
846
|
+
);
|
847
|
+
if (user.labels && user.labels.length > 0) {
|
848
|
+
await tryAwaitWithRetry(async () =>
|
849
|
+
remoteUsers.updateLabels(user.$id, user.labels)
|
850
|
+
);
|
851
|
+
}
|
852
|
+
}
|
827
853
|
|
828
854
|
// Update user preferences and status
|
829
855
|
await tryAwaitWithRetry(async () =>
|