bdy 1.18.7-dev → 1.18.9-beta
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
|
}
|
|
@@ -33,15 +33,13 @@ const OAUTH_CLIENT_APP_SCOPES = [
|
|
|
33
33
|
];
|
|
34
34
|
async function oauthServer(api, clientId, clientSecret) {
|
|
35
35
|
const ApiClient = require('../api/client').default;
|
|
36
|
-
const open = require('open');
|
|
37
|
-
return new Promise((resolve
|
|
36
|
+
const open = require('open').default;
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
38
|
const s = node_http_1.default.createServer(async (req, res) => {
|
|
39
39
|
const url = new URL(req.url || '', `http://${OAUTH_CLIENT_APP_HOST}`);
|
|
40
40
|
const urlCode = url.searchParams.get('code');
|
|
41
41
|
if (!urlCode) {
|
|
42
42
|
res.end(texts_1.ERR_LOGIN_HTTP_FAILED);
|
|
43
|
-
s.close();
|
|
44
|
-
reject(new Error(texts_1.ERR_LOGIN_HTTP_FAILED));
|
|
45
43
|
return;
|
|
46
44
|
}
|
|
47
45
|
const client = new ApiClient(new URL(`https://${api}`));
|
|
@@ -57,17 +55,17 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
57
55
|
catch {
|
|
58
56
|
res.end(texts_1.ERR_LOGIN_HTTP_FAILED);
|
|
59
57
|
s.close();
|
|
60
|
-
|
|
61
|
-
return;
|
|
58
|
+
output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_FAILED);
|
|
62
59
|
}
|
|
63
60
|
});
|
|
64
61
|
s.on('error', () => {
|
|
65
62
|
s.close();
|
|
66
|
-
|
|
63
|
+
output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN);
|
|
64
|
+
});
|
|
65
|
+
s.listen(OAUTH_CLIENT_APP_PORT, OAUTH_CLIENT_APP_HOST, () => {
|
|
66
|
+
const url = `https://${api}/oauth2/authorize?type=web_server&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(OAUTH_CLIENT_APP_REDIRECT_URL)}&response_type=code&scope=${encodeURIComponent(OAUTH_CLIENT_APP_SCOPES.join(' '))}`;
|
|
67
|
+
open(url);
|
|
67
68
|
});
|
|
68
|
-
s.listen(OAUTH_CLIENT_APP_PORT, OAUTH_CLIENT_APP_HOST);
|
|
69
|
-
const url = `https://${api}/oauth2/authorize?type=web_server&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(OAUTH_CLIENT_APP_REDIRECT_URL)}&response_type=code&scope=${encodeURIComponent(OAUTH_CLIENT_APP_SCOPES.join(' '))}`;
|
|
70
|
-
open(url);
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
71
|
async function getOrCreateApp(api) {
|
|
@@ -39,7 +39,7 @@ commandUtUpload.action(async (input, options) => {
|
|
|
39
39
|
});
|
|
40
40
|
exports.default = commandUtUpload;
|
|
41
41
|
function validateInputAndOptions(input, options) {
|
|
42
|
-
const z = require('zod')
|
|
42
|
+
const z = require('zod');
|
|
43
43
|
const { ZodError } = require('zod');
|
|
44
44
|
const globSchema = z.string();
|
|
45
45
|
const optionsSchema = z.object({
|
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
|
}
|