Skip to content

Commit 349161f

Browse files
committed
feat(cli): Adding more data to Github issue link
1 parent 4d14115 commit 349161f

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

templates/cli/index.js.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ program
3737
})
3838
.on("option:report", () => {
3939
cliConfig.report = true;
40+
cliConfig.reportData = { data: this };
4041
})
4142
.showSuggestionAfterError()
4243
{% if sdk.test != "true" %}

templates/cli/lib/parser.js.twig

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ const chalk = require('chalk');
22
const commander = require('commander');
33
const Table = require('cli-table3');
44
const { description } = require('../package.json');
5+
const { globalConfig } = require("./config.js");
6+
const os = require('os');
57

68
const cliConfig = {
7-
verbose: false,
8-
json: false,
9-
report: false
9+
verbose: false,
10+
json: false,
11+
report: false,
12+
reportData: {}
1013
};
1114

1215
const parse = (data) => {
@@ -111,19 +114,40 @@ const drawJSON = (data) => {
111114
}
112115

113116
const parseError = (err) => {
114-
if(cliConfig.report) {
115-
const githubIssueUrl=`https://github.com/appwrite/appwrite/issues/new?labels=bug&template=bug.yaml&title=%F0%9F%90%9B+Bug+Report%3A+&actual-behavior=Console%20Crash%0A${encodeURIComponent('```\n'+err.stack+'\n```').replaceAll('(','').replaceAll(')','')}`
117+
if (cliConfig.report) {
118+
(async () => {
119+
let appwriteVersion = 'unknown';
120+
const isCloud = globalConfig.getEndpoint().includes('cloud.appwrite.io') ? 'Yes' : 'No';
121+
122+
try {
123+
const res = await fetch(`${globalConfig.getEndpoint()}/health/version`);
124+
const json = await res.json();
125+
appwriteVersion = json.version;
126+
} catch {
127+
}
116128

117-
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}\n`);
118-
}
129+
const version = '0.16.0';
130+
const stepsToReproduce = encodeURIComponent(`Running \`appwrite ${cliConfig.reportData.data.args}\` using CLI ${version}`);
131+
const yourEnvironment = encodeURI(`CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`)
132+
133+
const stack = encodeURIComponent('```\n' + err.stack + '\n```').replaceAll('(', '').replaceAll(')', '');
134+
135+
const githubIssueUrl = `https://github.com/appwrite/appwrite/issues/new?labels=bug&template=bug.yaml&title=%F0%9F%90%9B+Bug+Report%3A+CLI+error:+${encodeURI(err.message)}&actual-behavior=CLI%20Error:%0A${stack}&steps-to-reproduce=${stepsToReproduce}&environment=${yourEnvironment}`;
119136

120-
if(cliConfig.verbose) {
121-
console.error(err);
122-
} else {
123-
error(err.message);
137+
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}\n`);
138+
139+
process.exit(1);
140+
})()
141+
}
142+
else {
143+
if (cliConfig.verbose) {
144+
console.error(err);
145+
} else {
146+
error(err.message);
147+
}
148+
process.exit(1);
124149
}
125150

126-
process.exit(1)
127151
}
128152

129153
const actionRunner = (fn) => {

0 commit comments

Comments
 (0)