From 9de79ba5bd8cffe06821e8185bb405738dcf5f78 Mon Sep 17 00:00:00 2001
From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
Date: Thu, 13 Jan 2022 18:16:06 +0600
Subject: [PATCH] Account tools fix (#818)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
---
 dev/tool/src/index.ts      | 8 ++++++--
 server/account/src/tool.ts | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts
index fc32242c9a..4bfe8c4a03 100644
--- a/dev/tool/src/index.ts
+++ b/dev/tool/src/index.ts
@@ -14,7 +14,7 @@
 // limitations under the License.
 //
 
-import {
+import accountPlugin, {
   ACCOUNT_DB,
   assignWorkspace,
   createAccount,
@@ -25,6 +25,7 @@ import {
   listWorkspaces,
   listAccounts
 } from '@anticrm/account'
+import { setMetadata } from '@anticrm/platform'
 import { program } from 'commander'
 import { Client } from 'minio'
 import { Db, MongoClient } from 'mongodb'
@@ -69,6 +70,9 @@ if (elasticUrl === undefined) {
   process.exit(1)
 }
 
+setMetadata(accountPlugin.metadata.Endpoint, transactorUrl)
+setMetadata(accountPlugin.metadata.Transactor, transactorUrl)
+
 const minio = new Client({
   endPoint: minioEndpoint,
   port: 9000,
@@ -93,7 +97,7 @@ program
   .description('create user and corresponding account in master database')
   .requiredOption('-p, --password <password>', 'user password')
   .requiredOption('-f, --first <first>', 'first name')
-  .requiredOption('-l, --last <last>', 'first name')
+  .requiredOption('-l, --last <last>', 'last name')
   .action(async (email: string, cmd) => {
     return await withDatabase(mongodbUri, async (db) => {
       console.log(`creating account ${cmd.first as string} ${cmd.last as string} (${email})...`)
diff --git a/server/account/src/tool.ts b/server/account/src/tool.ts
index d1396a3632..46b8b4dd47 100644
--- a/server/account/src/tool.ts
+++ b/server/account/src/tool.ts
@@ -76,6 +76,8 @@ export async function initWorkspace (transactorUrl: string, dbName: string): Pro
     const connection = await connect(transactorUrl, dbName)
     try {
       await createDeps(connection)
+    } catch (e) {
+      console.log(e)
     } finally {
       await connection.close()
     }