Skip to content

Commit 3b04fe8

Browse files
committed
Merge branch 'refs/heads/feat-console-flow' into feat-multiple-accounts-and-instances
2 parents 3621c3c + 81ded63 commit 3b04fe8

File tree

6 files changed

+43
-53
lines changed

6 files changed

+43
-53
lines changed

templates/cli/index.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ program
3535
.option("-f,--force", "Flag to confirm all warnings")
3636
.option("-a,--all", "Flag to push all resources")
3737
.option("--id [id...]", "Flag to pass list of ids for a giving action")
38-
.option("--report", "Enable reporting when cli is crashing")
38+
.option("--report", "Enable reporting in case of CLI errors")
3939
.on("option:json", () => {
4040
cliConfig.json = true;
4141
})

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ const pullProject = async () => {
4747

4848
})
4949

50-
localConfig.setProject(response.$id, response.name);
51-
localConfig.setProjectSettings(response);
50+
localConfig.setProject(response.$id, response.name, response);
5251

5352
success();
5453
} catch (e) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,18 +587,18 @@ const pushProject = async () => {
587587
const projectId = localConfig.getProject().projectId;
588588
const projectName = localConfig.getProject().projectName;
589589

590-
log('Updating project name');
590+
log(`Updating project ${projectName} ( ${projectId} )`);
591591

592592
await projectsUpdate({
593593
projectId,
594594
name: projectName,
595595
parseOutput: false
596596
});
597597

598-
const settings = localConfig.getProjectSettings();
598+
const settings = localConfig.getProject().projectSettings;
599599

600600
if (settings.services) {
601-
log('Updating services status');
601+
log('Updating service statuses');
602602
for (let [service, status] of Object.entries(settings.services)) {
603603
await projectsUpdateServiceStatus({
604604
projectId,
@@ -611,7 +611,7 @@ const pushProject = async () => {
611611

612612
if (settings.auth) {
613613
if (settings.auth.security) {
614-
log('Updating Auth security settings');
614+
log('Updating auth security settings');
615615
await projectsUpdateAuthDuration({ projectId, duration: settings.auth.security.duration, parseOutput: false });
616616
await projectsUpdateAuthLimit({ projectId, limit: settings.auth.security.limit, parseOutput: false });
617617
await projectsUpdateAuthSessionsLimit({ projectId, limit: settings.auth.security.sessionsLimit, parseOutput: false });
@@ -621,7 +621,7 @@ const pushProject = async () => {
621621
}
622622

623623
if (settings.auth.methods) {
624-
log('Updating Auth available login methods');
624+
log('Updating auth login methods');
625625

626626
for (let [method, status] of Object.entries(settings.auth.methods)) {
627627
await projectsUpdateAuthStatus({

templates/cli/lib/config.js.twig

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -329,62 +329,53 @@ class Local extends Config {
329329
return {
330330
projectId: this.get("projectId"),
331331
projectName: this.get("projectName"),
332+
projectSettings: this.get('projectSettings')
332333
};
333334
}
334335

335-
setProject(projectId, projectName) {
336+
setProject(projectId, projectName, projectSettings = {}) {
336337
this.set("projectId", projectId);
337338
this.set("projectName", projectName);
338-
}
339-
340-
341-
getProjectSettings() {
342-
if (!this.has("projectSettings")) {
343-
return {};
344-
}
345-
346-
return this.get('projectSettings')
347-
}
348339

349-
setProjectSettings(project) {
350340
const settings = {
351341
services: {
352-
account: project.serviceStatusForAccount,
353-
avatars: project.serviceStatusForAvatars,
354-
databases: project.serviceStatusForDatabases,
355-
locale: project.serviceStatusForLocale,
356-
health: project.serviceStatusForHealth,
357-
storage: project.serviceStatusForStorage,
358-
teams: project.serviceStatusForTeams,
359-
users: project.serviceStatusForUsers,
360-
functions: project.serviceStatusForFunctions,
361-
graphql: project.serviceStatusForGraphql,
362-
messaging: project.serviceStatusForMessaging,
342+
account: projectSettings.serviceStatusForAccount,
343+
avatars: projectSettings.serviceStatusForAvatars,
344+
databases: projectSettings.serviceStatusForDatabases,
345+
locale: projectSettings.serviceStatusForLocale,
346+
health: projectSettings.serviceStatusForHealth,
347+
storage: projectSettings.serviceStatusForStorage,
348+
teams: projectSettings.serviceStatusForTeams,
349+
users: projectSettings.serviceStatusForUsers,
350+
functions: projectSettings.serviceStatusForFunctions,
351+
graphql: projectSettings.serviceStatusForGraphql,
352+
messaging: projectSettings.serviceStatusForMessaging,
363353

364354
},
365355
auth: {
366356
methods: {
367-
jwt: project.authJWT,
368-
phone: project.authPhone,
369-
invites: project.authInvites,
370-
anonymous: project.authAnonymous,
371-
"email-otp": project.authEmailOtp,
372-
"magic-url": project.authUsersAuthMagicURL,
373-
"email-password": project.authEmailPassword
357+
jwt: projectSettings.authJWT,
358+
phone: projectSettings.authPhone,
359+
invites: projectSettings.authInvites,
360+
anonymous: projectSettings.authAnonymous,
361+
"email-otp": projectSettings.authEmailOtp,
362+
"magic-url": projectSettings.authUsersAuthMagicURL,
363+
"email-password": projectSettings.authEmailPassword
374364
},
375365
security: {
376-
duration: project.authDuration,
377-
limit: project.authLimit,
378-
sessionsLimit: project.authSessionsLimit,
379-
passwordHistory: project.authPasswordHistory,
380-
passwordDictionary: project.authPasswordDictionary,
381-
personalDataCheck: project.authPersonalDataCheck
366+
duration: projectSettings.authDuration,
367+
limit: projectSettings.authLimit,
368+
sessionsLimit: projectSettings.authSessionsLimit,
369+
passwordHistory: projectSettings.authPasswordHistory,
370+
passwordDictionary: projectSettings.authPasswordDictionary,
371+
personalDataCheck: projectSettings.authPersonalDataCheck
382372
}
383373
}
384374
};
385375

386376
this.set('projectSettings', settings)
387377
}
378+
388379
}
389380

390381
class Global extends Config {

templates/cli/lib/paginate.js.twig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ const paginate = async (action, args = {}, limit = 100, wrapper = '') => {
55

66
while (true) {
77
const offset = pageNumber * limit;
8-
const additionalQueries = [];
9-
if (args.queries) {
10-
additionalQueries.push(...args.queries);
11-
}
128
// Merge the limit and offset into the args
139
const response = await action({
1410
...args,
1511
queries: [
16-
...additionalQueries,
1712
JSON.stringify({ method: 'limit', values: [limit] }),
1813
JSON.stringify({ method: 'offset', values: [offset] })
1914
]

templates/cli/lib/parser.js.twig

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Table = require('cli-table3');
44
const { description } = require('../package.json');
55
const { globalConfig } = require("./config.js");
66
const os = require('os');
7+
const Client = require("./client");
78

89
const cliConfig = {
910
verbose: false,
@@ -120,12 +121,13 @@ const parseError = (err) => {
120121
if (cliConfig.report) {
121122
(async () => {
122123
let appwriteVersion = 'unknown';
123-
const isCloud = globalConfig.getEndpoint().includes('cloud.appwrite.io') ? 'Yes' : 'No';
124+
const endpoint = globalConfig.getEndpoint();
125+
const isCloud = endpoint.includes('cloud.appwrite.io') ? 'Yes' : 'No';
124126

125127
try {
126-
const res = await fetch(`${globalConfig.getEndpoint()}/health/version`);
127-
const json = await res.json();
128-
appwriteVersion = json.version;
128+
const client = new Client().setEndpoint(endpoint);
129+
const res = await client.call('get', '/health/version');
130+
appwriteVersion = res.version;
129131
} catch {
130132
}
131133

@@ -145,6 +147,9 @@ const parseError = (err) => {
145147

146148
log(`To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl.href}\n`);
147149

150+
151+
error('\n Stack Trace: \n');
152+
console.error(err);
148153
process.exit(1);
149154
})()
150155
} else {

0 commit comments

Comments
 (0)