Skip to content

Commit 8420eb0

Browse files
committed
fix: reviews
1 parent 469594c commit 8420eb0

File tree

3 files changed

+4
-46
lines changed

3 files changed

+4
-46
lines changed

templates/cli/index.js.twig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { commandDescriptions, cliConfig } = require("./lib/parser");
1212
const { client } = require("./lib/commands/generic");
1313
const inquirer = require("inquirer");
1414
{% if sdk.test != "true" %}
15-
const { login, register, logout, whoami, migrate } = require("./lib/commands/generic");
15+
const { login, logout, whoami, migrate } = require("./lib/commands/generic");
1616
const { init } = require("./lib/commands/init");
1717
const { pull } = require("./lib/commands/pull");
1818
const { push } = require("./lib/commands/push");
@@ -62,7 +62,6 @@ program
6262
{% if sdk.test != "true" %}
6363
.addCommand(whoami)
6464
.addCommand(login)
65-
.addCommand(register)
6665
.addCommand(init)
6766
.addCommand(pull)
6867
.addCommand(push)

templates/cli/lib/client.js.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { fetch, FormData, Agent } = require("undici");
44
const JSONbig = require("json-bigint")({ storeAsString: false });
55
const {{spec.title | caseUcfirst}}Exception = require("./exception.js");
66
const { globalConfig } = require("./config.js");
7-
const {log} = require('./parser');
7+
const { log } = require('./parser');
88

99
class Client {
1010
CHUNK_SIZE = 5*1024*1024; // 5MB
@@ -146,7 +146,7 @@ class Client {
146146
throw new {{spec.title | caseUcfirst}}Exception(text, response.status, "", text);
147147
}
148148

149-
if(path !== '/account' && json.code === 401 && json.type ==='user_more_factors_required'){
149+
if (path !== '/account' && json.code === 401 && json.type === 'user_more_factors_required') {
150150
log('Unusable account found, removing...')
151151
const current = globalConfig.getCurrentLogin();
152152
globalConfig.setCurrentLogin('');

templates/cli/lib/commands/generic.js.twig

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,11 @@ const { globalConfig, localConfig } = require("../config");
66
const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable } = require("../parser");
77
const ID = require("../id");
88
{% if sdk.test != "true" %}
9-
const { questionsRegister, questionsRegisterWithEndpoint, questionsLogin, questionLoginWithEndpoint, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions");
9+
const { questionsLogin, questionLoginWithEndpoint, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions");
1010
const { accountCreate, accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
1111

1212
const DEFAULT_ENDPOINT = 'https://cloud.appwrite.io/v1';
1313

14-
const registerCommand = async ({ selfHosted, email, password, endpoint, name }) => {
15-
let answers;
16-
let configEndpoint = DEFAULT_ENDPOINT;
17-
18-
if (selfHosted) {
19-
answers = endpoint && email && password ? { endpoint, email, password } : await inquirer.prompt(questionsRegisterWithEndpoint);
20-
configEndpoint = answers.endpoint;
21-
} else {
22-
answers = email && password ? { email, password } : await inquirer.prompt(questionsRegister);
23-
}
24-
25-
globalConfig.setEndpoint(configEndpoint);
26-
27-
let client = await sdkForConsole(false);
28-
29-
try {
30-
await accountCreate({
31-
userId: ID.unique(),
32-
email: answers.email,
33-
password: answers.password,
34-
parseOutput: false,
35-
name: answers.name,
36-
sdk: client,
37-
})
38-
39-
success();
40-
} catch (e) {
41-
throw e;
42-
}
43-
44-
}
4514
const loginCommand = async ({ selfHosted, email, password, endpoint, mfa, code }) => {
4615
const oldCurrent = globalConfig.getCurrentLogin();
4716
let answers = {};
@@ -180,15 +149,6 @@ const login = new Command("login")
180149
})
181150
.action(actionRunner(loginCommand));
182151

183-
const register = new Command("register")
184-
.description(commandDescriptions['login'])
185-
.option(`-sh, --self-hosted`, `Flag for enabling custom endpoint for self hosted instances`)
186-
.option(`--name [name]`, `User name`)
187-
.option(`--email [email]`, `User email`)
188-
.option(`--password [password]`, `User password`)
189-
.option(`--endpoint [endpoint]`, `Appwrite endpoint for self hosted instances`)
190-
.action(actionRunner(registerCommand));
191-
192152
const singleLogout = async (accountId) => {
193153
try {
194154
let client = await sdkForConsole();
@@ -349,7 +309,6 @@ module.exports = {
349309
loginCommand,
350310
whoami,
351311
login,
352-
register,
353312
logout,
354313
{% endif %}
355314
migrate,

0 commit comments

Comments
 (0)