bdy 1.18.8-dev → 1.18.9-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/distTs/package.json
CHANGED
|
@@ -77,12 +77,34 @@ const prepareMultipartBody = async (params) => {
|
|
|
77
77
|
}
|
|
78
78
|
return form;
|
|
79
79
|
};
|
|
80
|
+
const parseUrl = (url) => {
|
|
81
|
+
const query = {};
|
|
82
|
+
let path = url;
|
|
83
|
+
let host = '';
|
|
84
|
+
try {
|
|
85
|
+
const u = new URL(url, 'https://example.com');
|
|
86
|
+
if (u.host !== 'example.com')
|
|
87
|
+
host = u.host;
|
|
88
|
+
path = decodeURIComponent(u.pathname);
|
|
89
|
+
u.searchParams.forEach((v, k) => {
|
|
90
|
+
query[k] = v;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// do nothing
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
host,
|
|
98
|
+
path,
|
|
99
|
+
query,
|
|
100
|
+
};
|
|
101
|
+
};
|
|
80
102
|
const request = async (method, url, options) => {
|
|
81
103
|
output_1.default.handleSignals();
|
|
104
|
+
const { query, path, host } = parseUrl(url);
|
|
82
105
|
const workspace = input_1.default.restApiWorkspace(options.workspace, true);
|
|
83
106
|
const project = input_1.default.restApiProject(options.project, true);
|
|
84
|
-
const client = input_1.default.restApiTokenClient();
|
|
85
|
-
const query = {};
|
|
107
|
+
const client = input_1.default.restApiTokenClient(false, host);
|
|
86
108
|
if (options.query) {
|
|
87
109
|
options.query.forEach((q) => {
|
|
88
110
|
const s = q.split(':');
|
|
@@ -92,7 +114,7 @@ const request = async (method, url, options) => {
|
|
|
92
114
|
query[s[0]] = s[1];
|
|
93
115
|
});
|
|
94
116
|
}
|
|
95
|
-
let preparedUrl =
|
|
117
|
+
let preparedUrl = path;
|
|
96
118
|
if (workspace) {
|
|
97
119
|
preparedUrl = preparedUrl.replaceAll('{workspace_domain}', encodeURIComponent(workspace));
|
|
98
120
|
}
|
|
@@ -40,8 +40,7 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
40
40
|
const urlCode = url.searchParams.get('code');
|
|
41
41
|
if (!urlCode) {
|
|
42
42
|
res.end(texts_1.ERR_LOGIN_HTTP_FAILED);
|
|
43
|
-
|
|
44
|
-
output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_FAILED);
|
|
43
|
+
return;
|
|
45
44
|
}
|
|
46
45
|
const client = new ApiClient(new URL(`https://${api}`));
|
|
47
46
|
try {
|
package/distTs/src/output.js
CHANGED
|
@@ -401,14 +401,19 @@ class Output {
|
|
|
401
401
|
terminal.fullscreen(false);
|
|
402
402
|
terminal.hideCursor(false);
|
|
403
403
|
terminal.grabInput(false);
|
|
404
|
+
const isDebug = process.env.DEBUG === '1';
|
|
404
405
|
let msg;
|
|
405
406
|
if (err instanceof Error) {
|
|
406
407
|
msg = err.message;
|
|
407
|
-
if (
|
|
408
|
+
if (isDebug)
|
|
408
409
|
msg += `\n${err.stack}`;
|
|
409
410
|
}
|
|
410
|
-
else
|
|
411
|
+
else {
|
|
412
|
+
const e = new Error();
|
|
411
413
|
msg = err;
|
|
414
|
+
if (isDebug)
|
|
415
|
+
msg += `\n${e.stack}`;
|
|
416
|
+
}
|
|
412
417
|
terminal.red.error(`${msg}\n`);
|
|
413
418
|
process.exit(1);
|
|
414
419
|
}
|