-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat multiple accounts and instances #851
Feat multiple accounts and instances #851
Conversation
Changing multiple account selection to the login command and making it interactive multiple-accounts-interactive.mp4 |
Interactive multiple account logout multiple-accounts-logout-interactive.mp4 |
appwrite login appwrite logout |
Feat general improvements
Feat function init improvments
Feat arg project init
templates/cli/lib/sdks.js.twig
Outdated
@@ -99,4 +99,5 @@ const sdkForProject = async () => { | |||
module.exports = { | |||
sdkForConsole, | |||
sdkForProject, | |||
questionGetEndpoint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets move all questions to questions.js file only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 5-28 has declared the array questionGetEndpoint
when: (answers) => answers.method === 'select' | ||
}, | ||
]; | ||
const questionGetEndpoint = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems we already have questionGetEndpoint
here. We have to remove it from sdks.js
} | ||
} | ||
|
||
const leftLogins = globalConfig.getLogins(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this method be called getSessions() ?
…nces' into feat-multiple-accounts-and-instances # Conflicts: # templates/cli/lib/commands/push.js.twig # templates/cli/lib/config.js.twig
|
||
client.setCookie(globalConfig.getCookie()); | ||
globalConfig.addLogin(id, {}); | ||
globalConfig.setCurrentLogin(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globalConfig.setCurrentLogin(id); | |
globalConfig.setCurrentSession(id); |
@@ -53,6 +79,8 @@ const loginCommand = async () => { | |||
parseOutput: false | |||
}); | |||
} else { | |||
globalConfig.removeLogin(id); | |||
globalConfig.setCurrentLogin(oldCurrent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globalConfig.setCurrentLogin(oldCurrent); | |
globalConfig.setCurrentSession(oldCurrent); |
return; | ||
} | ||
if (logins.length === 1) { | ||
await singleLogout(current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also singleLogout is not a very good name. Lets just call it deleteSession
or logout
templates/cli/lib/config.js.twig
Outdated
getCurrentLogin() { | ||
if (!this.has(Global.PREFERENCE_CURRENT)) { | ||
return ""; | ||
} | ||
return this.get(Global.PREFERENCE_CURRENT); | ||
} | ||
|
||
setCurrentLogin(endpoint) { | ||
this.set(Global.PREFERENCE_CURRENT, endpoint); | ||
} | ||
|
||
getLoginIds() { | ||
return Object.keys(this.data).filter((key) => !Global.IGNORE_ATTRIBUTES.includes(key)); | ||
} | ||
|
||
getLogins() { | ||
const logins = Object.keys(this.data).filter((key) => !Global.IGNORE_ATTRIBUTES.includes(key)) | ||
|
||
return logins.map((login) => { | ||
|
||
return { | ||
id: login, | ||
endpoint: this.data[login][Global.PREFERENCE_ENDPOINT], | ||
email: this.data[login][Global.PREFERENCE_EMAIL] | ||
} | ||
}) | ||
} | ||
|
||
addLogin(login, data) { | ||
this.set(login, data); | ||
} | ||
|
||
removeLogin(login, data) { | ||
this.delete(login); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets refactor all these method names to use Session / Session
And deleteSession / logout
templates/cli/lib/config.js.twig
Outdated
this.set(Global.PREFERENCE_CURRENT, endpoint); | ||
} | ||
|
||
getLoginIds() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be getSessionIds() ?
} | ||
} | ||
|
||
const leftLogins = globalConfig.getSessions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const leftLogins = globalConfig.getSessions(); | |
const sessions = globalConfig.getSessions(); |
helpWidth: process.stdout.columns || 80 | ||
}) | ||
.action(actionRunner(async () => { | ||
const logins = globalConfig.getSessions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const logins = globalConfig.getSessions(); | |
const sessions = globalConfig.getSessions(); |
What does this PR do?
prefs.json
scheme.--self-hosted
flag.appwrite login migrate
appwrite login list
appwrite login change --account-id
Test Plan
multiple-accounts.mp4