Skip to content

Commit e4483bb

Browse files
committed
Merge branch 'refs/heads/feat-report-error' into feat-cli-sudo
# Conflicts: # templates/cli/index.js.twig
2 parents acdb9fc + 3d2646a commit e4483bb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

templates/cli/index.js.twig

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

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)