appwrite-utils-cli 0.10.71 → 0.10.73

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 CHANGED
@@ -148,6 +148,7 @@ This updated CLI ensures that developers have robust tools at their fingertips t
148
148
 
149
149
  ## Changelog
150
150
 
151
+ - 0.10.73: Fix moving users, passwords should work now (from Appwrite, Argon2)
151
152
  - 0.10.71: Fix create template function `__dirname`
152
153
  - 0.10.70: Fixed `--transfer-users` phones
153
154
  - 0.10.67: Added `--transfer-users` boolean flag to also transfer users between projects
@@ -1,12 +1,9 @@
1
1
  import { AppwriteException, Client, Functions, Query, Runtime, } from "node-appwrite";
2
- import { fileURLToPath } from "node:url";
3
- import { join, dirname } from "node:path";
2
+ import { join } from "node:path";
4
3
  import fs from "node:fs";
5
4
  import {} from "appwrite-utils";
6
5
  import chalk from "chalk";
7
6
  import { extract as extractTar } from "tar";
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
7
  export const listFunctions = async (client, queries, search) => {
11
8
  const functions = new Functions(client);
12
9
  const functionsList = await functions.list(queries, search);
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",
@@ -84,7 +84,7 @@ export const transferStorageLocalToLocal = async (storage, fromBucketId, toBucke
84
84
  };
85
85
  export const transferStorageLocalToRemote = async (localStorage, endpoint, projectId, apiKey, fromBucketId, toBucketId) => {
86
86
  console.log(`Transferring files from current storage ${fromBucketId} to ${endpoint} bucket ${toBucketId}`);
87
- const client = getAppwriteClient(endpoint, apiKey, projectId);
87
+ const client = getAppwriteClient(endpoint, projectId, apiKey);
88
88
  const remoteStorage = new Storage(client);
89
89
  let numberOfFiles = 0;
90
90
  let lastFileId;
@@ -407,9 +407,19 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
407
407
  const phone = user.phone
408
408
  ? converterFunctions.convertPhoneStringToUSInternational(user.phone)
409
409
  : undefined;
410
- await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, // phone - optional
411
- user.password, // password - cannot transfer hashed passwords
412
- user.name));
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
+ }
418
+ else {
419
+ await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, // phone - optional
420
+ user.password, // password - cannot transfer hashed passwords
421
+ user.name));
422
+ }
413
423
  // Update user preferences and status
414
424
  await tryAwaitWithRetry(async () => remoteUsers.updatePrefs(user.$id, user.prefs));
415
425
  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.71",
4
+ "version": "0.10.73",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -5,8 +5,7 @@ import {
5
5
  Query,
6
6
  Runtime,
7
7
  } from "node-appwrite";
8
- import { fileURLToPath } from "node:url";
9
- import { join, dirname } from "node:path";
8
+ import { join } from "node:path";
10
9
  import fs from "node:fs";
11
10
  import {
12
11
  type AppwriteFunction,
@@ -16,9 +15,6 @@ import {
16
15
  import chalk from "chalk";
17
16
  import { extract as extractTar } from "tar";
18
17
 
19
- const __filename = fileURLToPath(import.meta.url);
20
- const __dirname = dirname(__filename);
21
-
22
18
  export const listFunctions = async (
23
19
  client: Client,
24
20
  queries?: string[],
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",
@@ -158,7 +158,7 @@ export const transferStorageLocalToRemote = async (
158
158
  console.log(
159
159
  `Transferring files from current storage ${fromBucketId} to ${endpoint} bucket ${toBucketId}`
160
160
  );
161
- const client = getAppwriteClient(endpoint, apiKey, projectId);
161
+ const client = getAppwriteClient(endpoint, projectId, apiKey);
162
162
  const remoteStorage = new Storage(client);
163
163
  let numberOfFiles = 0;
164
164
  let lastFileId: string | undefined;
@@ -815,15 +815,31 @@ export const transferUsersLocalToRemote = async (
815
815
  ? converterFunctions.convertPhoneStringToUSInternational(user.phone)
816
816
  : undefined;
817
817
 
818
- await tryAwaitWithRetry(async () =>
819
- remoteUsers.create(
820
- user.$id,
821
- user.email,
822
- phone, // phone - optional
823
- user.password, // password - cannot transfer hashed passwords
824
- user.name
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
+ } else {
833
+ await tryAwaitWithRetry(async () =>
834
+ remoteUsers.create(
835
+ user.$id,
836
+ user.email,
837
+ phone, // phone - optional
838
+ user.password, // password - cannot transfer hashed passwords
839
+ user.name
840
+ )
841
+ );
842
+ }
827
843
 
828
844
  // Update user preferences and status
829
845
  await tryAwaitWithRetry(async () =>