bdy 1.12.8 → 1.12.9-dev-pipeline-run
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 +1 -1
- package/distTs/src/api/client.js +112 -0
- package/distTs/src/command/pipeline/run.js +136 -0
- package/distTs/src/command/pipeline.js +12 -0
- package/distTs/src/format.js +19 -0
- package/distTs/src/index.js +2 -0
- package/distTs/src/input.js +132 -0
- package/distTs/src/output.js +6 -0
- package/distTs/src/texts.js +57 -7
- package/distTs/src/utils.js +6 -0
- package/package.json +1 -1
- package/distTs/src/agent.js +0 -302
- package/distTs/src/api/agent.js +0 -99
- package/distTs/src/api/buddy.js +0 -139
- package/distTs/src/api/socket.js +0 -159
- package/distTs/src/cfg.js +0 -234
- package/distTs/src/command/config.js +0 -17
- package/distTs/src/command/http.js +0 -30
- package/distTs/src/command/start.js +0 -28
- package/distTs/src/command/tcp.js +0 -30
- package/distTs/src/command/tls.js +0 -30
- package/distTs/src/output/interactive/tunnel.js +0 -860
- package/distTs/src/output/noninteractive/agent/tunnels.js +0 -43
- package/distTs/src/output/noninteractive/config/tunnel.js +0 -65
- package/distTs/src/output/noninteractive/config/tunnels.js +0 -18
- package/distTs/src/output/noninteractive/tunnel.js +0 -59
- package/distTs/src/server/cert.js +0 -52
- package/distTs/src/server/http1.js +0 -75
- package/distTs/src/server/http2.js +0 -78
- package/distTs/src/server/sftp.js +0 -497
- package/distTs/src/server/ssh.js +0 -446
- package/distTs/src/server/tls.js +0 -41
- package/distTs/src/ssh/client.js +0 -197
- package/distTs/src/tunnel/html/503.html +0 -338
- package/distTs/src/tunnel.js +0 -656
package/distTs/package.json
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const undici_1 = require("undici");
|
|
7
|
+
const texts_1 = require("../texts");
|
|
8
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
9
|
+
class ApiClient {
|
|
10
|
+
client;
|
|
11
|
+
token;
|
|
12
|
+
baseUrl;
|
|
13
|
+
constructor(baseUrl, token) {
|
|
14
|
+
this.baseUrl = baseUrl;
|
|
15
|
+
this.token = token;
|
|
16
|
+
this.client = new undici_1.Client(baseUrl, {
|
|
17
|
+
connect: {
|
|
18
|
+
rejectUnauthorized: false,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async request(method, path, body, parseResponseBody = false) {
|
|
23
|
+
const headers = {
|
|
24
|
+
authorization: `Bearer ${this.token}`,
|
|
25
|
+
};
|
|
26
|
+
let bodyParsed = undefined;
|
|
27
|
+
if (body) {
|
|
28
|
+
headers['content-type'] = 'application/json; charset=utf-8';
|
|
29
|
+
bodyParsed = JSON.stringify(body);
|
|
30
|
+
}
|
|
31
|
+
const opts = {
|
|
32
|
+
method,
|
|
33
|
+
path,
|
|
34
|
+
headers,
|
|
35
|
+
body: bodyParsed,
|
|
36
|
+
};
|
|
37
|
+
let status;
|
|
38
|
+
let responseBody;
|
|
39
|
+
logger_1.default.debug(`REST API ${method} ${this.baseUrl.protocol}//${this.baseUrl.host}${path}`);
|
|
40
|
+
logger_1.default.debug(headers);
|
|
41
|
+
logger_1.default.debug(body);
|
|
42
|
+
try {
|
|
43
|
+
const r = await this.client.request(opts);
|
|
44
|
+
status = r.statusCode;
|
|
45
|
+
responseBody = r.body;
|
|
46
|
+
logger_1.default.debug(`REST API RESPONSE STATUS: ${status}`);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
logger_1.default.debug('REST API RESPONSE ERROR');
|
|
50
|
+
logger_1.default.debug(err);
|
|
51
|
+
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
52
|
+
}
|
|
53
|
+
if (status === 404) {
|
|
54
|
+
throw new Error(texts_1.ERR_REST_API_RESOURCE_NOT_FOUND);
|
|
55
|
+
}
|
|
56
|
+
if (status === 401) {
|
|
57
|
+
throw new Error(texts_1.ERR_REST_API_WRONG_TOKEN);
|
|
58
|
+
}
|
|
59
|
+
if (status === 403) {
|
|
60
|
+
throw new Error(texts_1.ERR_REST_API_RATE_LIMIT);
|
|
61
|
+
}
|
|
62
|
+
if (status === 400) {
|
|
63
|
+
let json;
|
|
64
|
+
try {
|
|
65
|
+
json = await responseBody.json();
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
logger_1.default.debug('REST API PARSED RESPONSE ERROR:');
|
|
69
|
+
logger_1.default.debug(err);
|
|
70
|
+
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
71
|
+
// do nothing
|
|
72
|
+
}
|
|
73
|
+
logger_1.default.debug('REST API PARSED RESPONSE:');
|
|
74
|
+
logger_1.default.debug(json);
|
|
75
|
+
if (json.errors && json.errors[0] && json.errors[0].message) {
|
|
76
|
+
throw new Error(json.errors[0].message);
|
|
77
|
+
}
|
|
78
|
+
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
79
|
+
}
|
|
80
|
+
if (status === 200) {
|
|
81
|
+
if (parseResponseBody) {
|
|
82
|
+
try {
|
|
83
|
+
const b = await responseBody.json();
|
|
84
|
+
logger_1.default.debug('REST API PARSED RESPONSE:');
|
|
85
|
+
logger_1.default.debug(b);
|
|
86
|
+
return b;
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
logger_1.default.debug('REST API PARSED RESPONSE ERROR:');
|
|
90
|
+
logger_1.default.debug(err);
|
|
91
|
+
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async getPipelineByIdentifier(workspace, project, identifier) {
|
|
103
|
+
return await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/identifiers?project=${encodeURIComponent(project)}&pipeline=${encodeURIComponent(identifier)}`, null, true);
|
|
104
|
+
}
|
|
105
|
+
async getPipelineRun(workspace, project, pipelineId, executionId) {
|
|
106
|
+
return await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(executionId)}`, null, true);
|
|
107
|
+
}
|
|
108
|
+
async postPipelineRun(workspace, project, pipelineId, body) {
|
|
109
|
+
return await this.request('POST', `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions`, body, true);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.default = ApiClient;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
10
|
+
const client_1 = __importDefault(require("../../api/client"));
|
|
11
|
+
const format_1 = __importDefault(require("../../format"));
|
|
12
|
+
const commandPipelineRun = (0, utils_1.newCommand)('run', texts_1.DESC_COMMAND_PIPELINE_RUN);
|
|
13
|
+
commandPipelineRun.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
|
|
14
|
+
commandPipelineRun.option('--base-url <url>', texts_1.OPTION_REST_API_BASE_URL);
|
|
15
|
+
commandPipelineRun.option('--region <region>', texts_1.OPTION_REST_API_REGION);
|
|
16
|
+
commandPipelineRun.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
17
|
+
commandPipelineRun.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
|
+
commandPipelineRun.option('-b, --branch <branch>', texts_1.OPTION_PIPELINE_RUN_BRANCH);
|
|
19
|
+
commandPipelineRun.option('-t, --tag <tag>', texts_1.OPTION_PIPELINE_RUN_TAG);
|
|
20
|
+
commandPipelineRun.option('-pr, --pull-request <pull request>', texts_1.OPTION_PIPELINE_RUN_PULL_REQUEST);
|
|
21
|
+
commandPipelineRun.option('-r, --revision <revision>', texts_1.OPTION_PIPELINE_RUN_REVISION);
|
|
22
|
+
commandPipelineRun.option('--comment <comment>', texts_1.OPTION_PIPELINE_RUN_COMMENT);
|
|
23
|
+
commandPipelineRun.option('-f, --refresh', texts_1.OPTION_PIPELINE_RUN_REFRESH);
|
|
24
|
+
commandPipelineRun.option('-c, --clear-cache', texts_1.OPTION_PIPELINE_RUN_CLEAR_CACHE);
|
|
25
|
+
commandPipelineRun.option('--priority <priority>', texts_1.OPTION_PIPELINE_RUN_PRIORITY);
|
|
26
|
+
commandPipelineRun.option('-v, --variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
|
|
27
|
+
commandPipelineRun.option('-ve, --variable-encrypted <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
|
|
28
|
+
commandPipelineRun.option('--delay <date>', texts_1.OPTION_PIPELINE_RUN_DELAY);
|
|
29
|
+
commandPipelineRun.option('--action <actions...>', texts_1.OPTION_PIPELINE_RUN_ACTION);
|
|
30
|
+
commandPipelineRun.option('--wait', texts_1.OPTION_PIPELINE_RUN_WAIT);
|
|
31
|
+
commandPipelineRun.option('--wait-time <minutes>', texts_1.OPTION_PIPELINE_RUN_WAIT_TIMEOUT);
|
|
32
|
+
commandPipelineRun.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
|
|
33
|
+
commandPipelineRun.action(async (identifier, options) => {
|
|
34
|
+
const token = input_1.default.restApiToken(options.token);
|
|
35
|
+
const baseUrl = input_1.default.restApiBaseUrl(options.baseUrl, options.region);
|
|
36
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
37
|
+
const project = input_1.default.restApiProject(options.project);
|
|
38
|
+
const client = new client_1.default(baseUrl, token);
|
|
39
|
+
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
40
|
+
if (!data || !data.domain) {
|
|
41
|
+
output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_WORKSPACE_NOT_FOUND);
|
|
42
|
+
}
|
|
43
|
+
if (!data.project_identifier) {
|
|
44
|
+
output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_PROJECT_NOT_FOUND);
|
|
45
|
+
}
|
|
46
|
+
if (!data.pipeline_id) {
|
|
47
|
+
output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_NOT_FOUND);
|
|
48
|
+
}
|
|
49
|
+
const body = {};
|
|
50
|
+
if (options.branch) {
|
|
51
|
+
body.branch = {
|
|
52
|
+
name: options.branch,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (options.tag) {
|
|
56
|
+
body.tag = {
|
|
57
|
+
name: options.tag,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (options.pullRequest) {
|
|
61
|
+
body.pull_request = {
|
|
62
|
+
name: `pull/${options.pullRequest}`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (options.revision) {
|
|
66
|
+
body.to_revision = {
|
|
67
|
+
revision: options.revision,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (options.comment) {
|
|
71
|
+
body.comment = options.comment;
|
|
72
|
+
}
|
|
73
|
+
if (options.refresh) {
|
|
74
|
+
body.refresh = true;
|
|
75
|
+
}
|
|
76
|
+
if (options.clearCache) {
|
|
77
|
+
body.clear_cache = true;
|
|
78
|
+
}
|
|
79
|
+
const priority = input_1.default.pipelineRunPriority(options.priority);
|
|
80
|
+
if (priority) {
|
|
81
|
+
body.priority = priority;
|
|
82
|
+
}
|
|
83
|
+
body.variables = [];
|
|
84
|
+
if (options.variable) {
|
|
85
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variable, false));
|
|
86
|
+
}
|
|
87
|
+
if (options.variableEncrypted) {
|
|
88
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variableEncrypted, true));
|
|
89
|
+
}
|
|
90
|
+
const delay = input_1.default.pipelineRunDelay(options.delay);
|
|
91
|
+
if (delay) {
|
|
92
|
+
body.delay_until = delay;
|
|
93
|
+
}
|
|
94
|
+
const actions = input_1.default.pipelineRunAction(options.action);
|
|
95
|
+
if (actions) {
|
|
96
|
+
body.actions_to_run = actions;
|
|
97
|
+
}
|
|
98
|
+
const result = await client.postPipelineRun(workspace, project, data.pipeline_id, body);
|
|
99
|
+
if (options.wait) {
|
|
100
|
+
const minutes = input_1.default.pipelineRunWaitTime(options.waitTime);
|
|
101
|
+
const start = Date.now();
|
|
102
|
+
output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_WAIT)(minutes));
|
|
103
|
+
let fetchCounter = 1;
|
|
104
|
+
const ts1 = setTimeout(() => {
|
|
105
|
+
output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_WAIT_TIMEOUT);
|
|
106
|
+
}, minutes * 60 * 1000);
|
|
107
|
+
const ts2 = setInterval(async () => {
|
|
108
|
+
output_1.default.clearPreviousLine();
|
|
109
|
+
output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_STILL_WAITING)(formatWaitTime(start)));
|
|
110
|
+
if (fetchCounter >= 3) {
|
|
111
|
+
const pip = await client.getPipelineRun(workspace, project, data.pipeline_id, result.id);
|
|
112
|
+
if (!['INPROGRESS', 'ENQUEUED', 'TERMINATING'].includes(pip.status)) {
|
|
113
|
+
clearTimeout(ts1);
|
|
114
|
+
clearInterval(ts2);
|
|
115
|
+
output_1.default.clearPreviousLine();
|
|
116
|
+
if (pip.status === 'SUCCESSFUL') {
|
|
117
|
+
output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY)(result.html_url));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
output_1.default.exitError((0, texts_1.TXT_PIPELINE_RUN_FINISH_FAILED)(pip.status, result.html_url));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
fetchCounter = 0;
|
|
124
|
+
}
|
|
125
|
+
fetchCounter += 1;
|
|
126
|
+
}, 1000);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_SUCCESS)(result.html_url));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
const formatWaitTime = (start) => {
|
|
133
|
+
const elapsed = Math.floor((Date.now() - start) / 1000);
|
|
134
|
+
return format_1.default.pipelineRunWaitTime(elapsed);
|
|
135
|
+
};
|
|
136
|
+
exports.default = commandPipelineRun;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const texts_1 = require("../texts");
|
|
8
|
+
const run_1 = __importDefault(require("./pipeline/run"));
|
|
9
|
+
const commandPipeline = (0, utils_1.newCommand)('pipeline', texts_1.DESC_COMMAND_PIPELINE);
|
|
10
|
+
commandPipeline.alias('pip');
|
|
11
|
+
commandPipeline.addCommand(run_1.default);
|
|
12
|
+
exports.default = commandPipeline;
|
package/distTs/src/format.js
CHANGED
|
@@ -128,6 +128,25 @@ class Format {
|
|
|
128
128
|
entry += ':443';
|
|
129
129
|
return entry;
|
|
130
130
|
}
|
|
131
|
+
static pipelineRunWaitTime(elapsedSeconds) {
|
|
132
|
+
const hours = Math.floor(elapsedSeconds / 60 / 60);
|
|
133
|
+
const minutes = Math.floor(elapsedSeconds / 60) - hours * 60;
|
|
134
|
+
const seconds = elapsedSeconds - hours * 60 * 60 - minutes * 60;
|
|
135
|
+
const hoursF = `${hours}h`;
|
|
136
|
+
let minutesF = '';
|
|
137
|
+
if (minutes < 10)
|
|
138
|
+
minutesF += '0';
|
|
139
|
+
minutesF += `${minutes}m`;
|
|
140
|
+
let secondsF = '';
|
|
141
|
+
if (seconds < 10)
|
|
142
|
+
secondsF += '0';
|
|
143
|
+
secondsF += `${seconds}s`;
|
|
144
|
+
if (hours > 0)
|
|
145
|
+
return `${hoursF}${minutesF}${secondsF}`;
|
|
146
|
+
if (minutes > 0)
|
|
147
|
+
return `${minutesF}${secondsF}`;
|
|
148
|
+
return secondsF;
|
|
149
|
+
}
|
|
131
150
|
static target(type, target) {
|
|
132
151
|
if (type === tunnel_1.TUNNEL_TYPE.HTTP) {
|
|
133
152
|
let port = '80';
|
package/distTs/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const texts_1 = require("./texts");
|
|
|
14
14
|
const vt_1 = __importDefault(require("./command/vt"));
|
|
15
15
|
const ut_1 = __importDefault(require("./command/ut"));
|
|
16
16
|
const tunnel_1 = __importDefault(require("./command/tunnel"));
|
|
17
|
+
const pipeline_1 = __importDefault(require("./command/pipeline"));
|
|
17
18
|
stream_1.default.setDefaultHighWaterMark(false, 67108864);
|
|
18
19
|
process.title = 'bdy';
|
|
19
20
|
process.on('uncaughtException', (err) => {
|
|
@@ -31,4 +32,5 @@ if (!(0, utils_1.isDocker)())
|
|
|
31
32
|
program.addCommand(version_1.default);
|
|
32
33
|
program.addCommand(vt_1.default);
|
|
33
34
|
program.addCommand(ut_1.default);
|
|
35
|
+
program.addCommand(pipeline_1.default);
|
|
34
36
|
program.parse();
|
package/distTs/src/input.js
CHANGED
|
@@ -215,6 +215,138 @@ class Input {
|
|
|
215
215
|
}
|
|
216
216
|
return type;
|
|
217
217
|
}
|
|
218
|
+
static restApiToken(token) {
|
|
219
|
+
let t = process.env.BUDDY_TOKEN;
|
|
220
|
+
if (token)
|
|
221
|
+
t = token;
|
|
222
|
+
if (!t) {
|
|
223
|
+
output_1.default.exitError(texts_1.ERR_REST_API_TOKEN);
|
|
224
|
+
}
|
|
225
|
+
return t;
|
|
226
|
+
}
|
|
227
|
+
static pipelineRunPriority(priority) {
|
|
228
|
+
if (!priority)
|
|
229
|
+
return null;
|
|
230
|
+
if (['LOW', 'NORMAL', 'HIGH'].includes(priority))
|
|
231
|
+
return priority;
|
|
232
|
+
output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_WRONG_PRIORITY);
|
|
233
|
+
}
|
|
234
|
+
static pipelineRunAction(actions) {
|
|
235
|
+
if (!actions.length)
|
|
236
|
+
return null;
|
|
237
|
+
const list = [];
|
|
238
|
+
actions.forEach((str) => {
|
|
239
|
+
try {
|
|
240
|
+
const id = parseInt(str, 10);
|
|
241
|
+
if (!isNaN(id)) {
|
|
242
|
+
list.push(id);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
// do nothing
|
|
248
|
+
}
|
|
249
|
+
output_1.default.exitError((0, texts_1.ERR_RUN_PIPELINE_WRONG_ACTION)(str));
|
|
250
|
+
});
|
|
251
|
+
return list;
|
|
252
|
+
}
|
|
253
|
+
static pipelineRunDelay(delay) {
|
|
254
|
+
if (!delay)
|
|
255
|
+
return null;
|
|
256
|
+
try {
|
|
257
|
+
let d = new Date(delay);
|
|
258
|
+
if (!isNaN(d.getTime())) {
|
|
259
|
+
return d.toISOString();
|
|
260
|
+
}
|
|
261
|
+
let h = 0;
|
|
262
|
+
let m = 0;
|
|
263
|
+
let s = 0;
|
|
264
|
+
const rh = delay.match(/(\d+)h/);
|
|
265
|
+
if (rh)
|
|
266
|
+
h = parseInt(rh[1], 10);
|
|
267
|
+
const rm = delay.match(/(\d+)m/);
|
|
268
|
+
if (rm)
|
|
269
|
+
m = parseInt(rm[1], 10);
|
|
270
|
+
const rs = delay.match(/(\d+)s/);
|
|
271
|
+
if (rs)
|
|
272
|
+
s = parseInt(rs[1], 10);
|
|
273
|
+
if (h || m || s) {
|
|
274
|
+
d = new Date();
|
|
275
|
+
d.setTime(d.getTime() + ((h * 60 + m) * 60 + s) * 1000);
|
|
276
|
+
return d.toISOString();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
// do nothing
|
|
281
|
+
}
|
|
282
|
+
output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_WRONG_DELAY);
|
|
283
|
+
}
|
|
284
|
+
static pipelineRunVariable(variable, encrypted) {
|
|
285
|
+
const list = [];
|
|
286
|
+
variable.forEach((v) => {
|
|
287
|
+
const s = v.split(':');
|
|
288
|
+
if (s.length < 2) {
|
|
289
|
+
output_1.default.exitError((0, texts_1.ERR_RUN_PIPELINE_WRONG_VARIABLE)(v));
|
|
290
|
+
}
|
|
291
|
+
list.push({
|
|
292
|
+
key: s.shift() || '',
|
|
293
|
+
value: s.join(':'),
|
|
294
|
+
encrypted,
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
return list;
|
|
298
|
+
}
|
|
299
|
+
static restApiBaseUrl(baseUrl, region) {
|
|
300
|
+
let u = process.env.BUDDY_BASE_URL;
|
|
301
|
+
if (baseUrl)
|
|
302
|
+
u = baseUrl;
|
|
303
|
+
if (!u) {
|
|
304
|
+
let r = process.env.BUDDY_REGION;
|
|
305
|
+
if (region)
|
|
306
|
+
r = region;
|
|
307
|
+
if (r === 'eu')
|
|
308
|
+
u = 'api.eu.buddy.works';
|
|
309
|
+
else if (r === 'us')
|
|
310
|
+
u = 'api.buddy.works';
|
|
311
|
+
}
|
|
312
|
+
if (!u)
|
|
313
|
+
u = 'api.buddy.works';
|
|
314
|
+
u = u.replace(/^https?:\/\//g, '');
|
|
315
|
+
try {
|
|
316
|
+
return new URL(`https://${u}`);
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
output_1.default.exitError(texts_1.ERR_REST_API_URL);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
static pipelineRunWaitTime(time) {
|
|
323
|
+
let t = Number.parseInt(time, 10);
|
|
324
|
+
if (!t)
|
|
325
|
+
t = 30;
|
|
326
|
+
else if (t < 0)
|
|
327
|
+
t = 1;
|
|
328
|
+
else if (t > 1000)
|
|
329
|
+
t = 1000;
|
|
330
|
+
return t;
|
|
331
|
+
}
|
|
332
|
+
static restApiWorkspace(workspace) {
|
|
333
|
+
let w = process.env.BUDDY_WORKSPACE;
|
|
334
|
+
if (workspace)
|
|
335
|
+
w = workspace;
|
|
336
|
+
if (!w) {
|
|
337
|
+
output_1.default.exitError(texts_1.ERR_REST_API_WORKSPACE);
|
|
338
|
+
}
|
|
339
|
+
return w;
|
|
340
|
+
}
|
|
341
|
+
static restApiProject(project) {
|
|
342
|
+
let p = process.env.BUDDY_PROJECT;
|
|
343
|
+
if (project)
|
|
344
|
+
p = project;
|
|
345
|
+
if (!p) {
|
|
346
|
+
output_1.default.exitError(texts_1.ERR_REST_API_PROJECT);
|
|
347
|
+
}
|
|
348
|
+
return p;
|
|
349
|
+
}
|
|
218
350
|
static name(name) {
|
|
219
351
|
if (name.includes('*')) {
|
|
220
352
|
output_1.default.exitError(texts_1.ERR_NAME_WITHOUT_ASTERISK);
|
package/distTs/src/output.js
CHANGED
|
@@ -63,6 +63,12 @@ class Output {
|
|
|
63
63
|
terminal.left();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
static clearPreviousLine() {
|
|
67
|
+
if (terminal.isTTY) {
|
|
68
|
+
terminal.previousLine();
|
|
69
|
+
terminal.eraseLine();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
66
72
|
static async spinner(txt) {
|
|
67
73
|
if (!this.s && terminal.isTTY) {
|
|
68
74
|
this.s = await terminal.spinner();
|
package/distTs/src/texts.js
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
3
|
+
exports.ERR_FAILED_TO_CONNECT = exports.ERR_TUNNEL_ALREADY_EXISTS = exports.ERR_AGENT_NOT_SUPPORTED = exports.ERR_AGENT_ADMIN_RIGHTS = exports.ERR_AGENT_ENABLE = exports.ERR_SWW_AGENT_UPDATING = exports.ERR_SWW_AGENT_DISABLING = exports.ERR_SWW_AGENT_ENABLING = exports.ERR_AGENT_NOT_FOUND = exports.ERR_AGENT_NOT_RUNNING = exports.ERR_AGENT_NOT_ENABLED = exports.ERR_TUNNEL_NOT_FOUND = exports.ERR_WHITELIST_IS_NOT_VALID = exports.ERR_USER_AGENT_IS_NOT_VALID = exports.ERR_BA_IS_NOT_VALID = exports.ERR_BA_LOGIN_NOT_PROVIDED = exports.ERR_BA_PASSWORD_NOT_PROVIDED = exports.ERR_CB_THRESHOLD_IS_NOT_VALID = exports.ERR_CERT_PATH_IS_NOT_VALID = exports.ERR_KEY_PATH_IS_NOT_VALID = exports.ERR_CA_PATH_IS_NOT_VALID = exports.ERR_WRONG_CA = exports.ERR_WRONG_KEY_CERT = exports.ERR_NAME_WITHOUT_ASTERISK = exports.ERR_PORT_IS_NOT_VALID = exports.ERR_REGION_IS_NOT_VALID = exports.ERR_PATH_IS_NOT_DIRECTORY = exports.ERR_DIRECTORY_DOES_NOT_EXISTS = exports.ERR_TERMINATE_IS_NOT_VALID = exports.ERR_TIMEOUT_IS_NOT_VALID = exports.ERR_TYPE_IS_NOT_VALID = exports.ERR_TARGET_IS_NOT_VALID = exports.ERR_SAVING_AGENT_CONFIG = exports.ERR_AGENT_NOT_REGISTERED = exports.ERR_RUN_PIPELINE_WRONG_VARIABLE = exports.ERR_RUN_PIPELINE_WRONG_ACTION = exports.ERR_RUN_PIPELINE_WRONG_DELAY = exports.ERR_RUN_PIPELINE_WRONG_PRIORITY = exports.ERR_RUN_PIPELINE_WAIT_TIMEOUT = exports.ERR_RUN_PIPELINE_NOT_FOUND = exports.ERR_RUN_PIPELINE_PROJECT_NOT_FOUND = exports.ERR_RUN_PIPELINE_WORKSPACE_NOT_FOUND = exports.ERR_REST_API_PROJECT = exports.ERR_REST_API_WORKSPACE = exports.ERR_REST_API_URL = exports.ERR_REST_API_TOKEN = exports.ERR_REST_API_RATE_LIMIT = exports.ERR_REST_API_RESOURCE_NOT_FOUND = exports.ERR_REST_API_WRONG_TOKEN = exports.ERR_REST_API_GENERAL_ERROR = void 0;
|
|
4
|
+
exports.ERR_HEAD_BRANCH_NOT_DEFINED = exports.ERR_BASE_BRANCH_NOT_DEFINED = exports.ERR_INVALID_COMMIT_HASH = exports.ERR_GETTING_COMMIT_HASH = exports.ERR_INVALID_BRANCH_NAME = exports.ERR_GETTING_BRANCH_NAME = exports.ERR_MISSING_HEAD_COMMIT_IN_FILE = exports.ERR_READING_FILE_WITH_HEAD_COMMIT = exports.ERR_MISSING_FILE_WITH_HEAD_COMMIT = exports.ERR_GITHUB_EVENT_PATH_NOT_FOUND = exports.ERR_TEST_EXECUTION = exports.ERR_INVALID_JSON = exports.ERR_INVALID_DOWNLOAD_RESPONSE = exports.ERR_INVALID_SCRAP_RESPONSE = exports.ERR_INVALID_COMPARE_LINKS_RESPONSE = exports.ERR_INVALID_STORYBOOK_RESPONSE = exports.ERR_INVALID_DEFAULT_SETTINGS_RESPONSE = exports.ERR_INVALID_CLOSE_SESSION_RESPONSE = exports.ERR_INVALID_SNAPSHOTS_RESPONSE = exports.ERR_INVALID_SNAPSHOT_RESPONSE = exports.ERR_MISSING_URLS = exports.ERR_RESOURCE_NOT_FOUND = exports.ERR_MISSING_EXEC_COMMAND = exports.ERR_PARSING_STORIES = exports.ERR_UNSUPPORTED_STORYBOOK = exports.ERR_MISSING_STORYBOOK_INDEX_FILE = exports.ERR_WRONG_STORYBOOK_DIRECTORY = exports.ERR_MISSING_BUILD_ID = exports.ERR_MISSING_UT_TOKEN = exports.ERR_MISSING_VT_TOKEN = exports.ERR_CONFIG_CORRUPTED = exports.ERR_WRONG_TOKEN = exports.ERR_TOKEN_NOT_PROVIDED = exports.ERR_CANT_CREATE_DIR_IN_HOME = exports.ERR_CONNECTION_ERROR = exports.ERR_CONNECTION_TIMEOUT = exports.ERR_WRONG_STREAM = exports.ERR_WRONG_HANDSHAKE = exports.ERR_FETCH_VERSION = exports.ERR_SWW = exports.ERR_NOT_FOUND = exports.ERR_FAILED_TO_CONNECT_TO_AGENT = exports.ERR_TUNNEL_REMOVED = exports.ERR_TUNNELS_DISABLED = exports.ERR_AGENT_LIMIT_REACHED = exports.ERR_TUNNEL_TARGET_INVALID = exports.ERR_WORKSPACE_FLAGGED = exports.ERR_TUNNEL_LIMIT_REACHED = exports.ERR_DOMAIN_RESTRICTED = exports.ERR_AGENT_REMOVED = void 0;
|
|
5
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_LIST = exports.DESC_COMMAND_CONFIG_SET = exports.DESC_COMMAND_CONFIG_REMOVE = exports.DESC_COMMAND_CONFIG_GET = exports.DESC_COMMAND_CONFIG_ADD = exports.DESC_COMMAND_CONFIG_SET_WHITELIST = exports.DESC_COMMAND_CONFIG_SET_TOKEN = exports.DESC_COMMAND_CONFIG_SET_TIMEOUT = exports.DESC_COMMAND_CONFIG_SET_REGION = exports.DESC_COMMAND_CONFIG_REMOVE_TUNNEL = exports.DESC_COMMAND_CONFIG_GET_WHITELIST = exports.DESC_COMMAND_CONFIG_GET_TUNNELS = exports.DESC_COMMAND_CONFIG_GET_TUNNEL = exports.DESC_COMMAND_CONFIG_GET_TOKEN = exports.DESC_COMMAND_CONFIG_GET_TIMEOUT = exports.DESC_COMMAND_CONFIG_GET_REGION = exports.DESC_COMMAND_CONFIG_ADD_TLS = exports.DESC_COMMAND_CONFIG_ADD_TCP = exports.DESC_COMMAND_CONFIG_ADD_HTTP = exports.AGENT_FETCH_RETRY = exports.NO_TUNNELS_STARTED = exports.TXT_TUNNEL_ADDED = exports.TXT_TUNNEL_REMOVED = exports.TXT_REGION_SAVED = exports.TXT_TIMEOUT_SAVED = exports.TXT_TOKEN_REMOVED = exports.TXT_TOKEN_SAVED = exports.TXT_WHITELIST_SAVED = exports.TXT_TUNNEL_STOPPED = exports.TXT_TUNNEL_STARTED = exports.TXT_AGENT_DISABLED = exports.TXT_AGENT_ALREADY_ENABLED = exports.TXT_AGENT_UPDATED = exports.TXT_AGENT_ENABLED = exports.TXT_AGENT_TARGET_DISABLED = exports.TXT_AGENT_TARGET_ENABLED = exports.TXT_AGENT_IS_DISABLED = exports.TXT_AGENT_IS_ENABLED_AND_HAVE_TROUBLES = exports.TXT_AGENT_IS_ENABLED_AND_INITIALIZING = exports.TXT_AGENT_IS_ENABLED_AND_STOPPED = exports.TXT_AGENT_IS_ENABLED_AND_STARTED = exports.TXT_AGENT_RESTARTED = exports.TXT_AGENT_STARTED = exports.TXT_AGENT_STOPPED = exports.WARN_BROWSER_VERSION = exports.ERR_RESOURCE_DISCOVERY = exports.ERR_NO_SNAPSHOTS_TO_SEND = exports.ERR_INVALID_SNAPSHOT = exports.ERR_GETTING_COMMIT_DETAILS = exports.ERR_GETTING_BASE_COMMIT = void 0;
|
|
6
|
+
exports.TXT_STORIES_AMOUNT = exports.TXT_PIPELINE_RUN_STILL_WAITING = exports.TXT_PIPELINE_RUN_WAIT = exports.TXT_PIPELINE_RUN_SUCCESS = exports.TXT_OPENING_TUNNEL = exports.TXT_UPDATING_AGENT = exports.TXT_ENABLING_AGENT = exports.TXT_DISABLING_AGENT = exports.TXT_NEW_AGENT_VERSION = exports.TXT_NEW_CLI_VERSION = exports.TXT_NEW_CLI_DOCKER_VERSION = exports.OPTION_UPLOAD_DRY_RUN = exports.OPTION_UPLOAD_REPORT_FORMAT = exports.OPTION_UPLOAD_REPORT_GLOB = exports.DESC_COMMAND_UT_UPLOAD = exports.DESC_COMMAND_UT = exports.DESC_COMMAND_VT_INSTALL_BROWSER = exports.DESC_COMMAND_VT_EXEC = exports.DESC_COMMAND_VT_SCRAP = exports.DESC_COMMAND_VT_COMPARE = exports.DESC_COMMAND_VT_STORYBOOK = exports.DESC_COMMAND_VT_CLOSE = exports.DESC_COMMAND_VT = exports.DESC_COMMAND_PIPELINE_RUN = exports.DESC_COMMAND_PIPELINE = exports.DESC_PROGRAM = exports.DESC_COMMAND_TLS = exports.DESC_COMMAND_TCP = exports.DESC_COMMAND_START = exports.DESC_COMMAND_TUNNEL = exports.DESC_COMMAND_AGENT = exports.DESC_COMMAND_HTTP = exports.DESC_COMMAND_CONFIG = exports.DESC_COMMAND_AGENT_VERSION = exports.DESC_COMMAND_AGENT_UPDATE = exports.DESC_COMMAND_AGENT_TARGET = exports.DESC_COMMAND_AGENT_TUNNEL = exports.DESC_COMMAND_AGENT_STOP = exports.DESC_COMMAND_AGENT_TARGET_DISABLE = exports.DESC_COMMAND_AGENT_TARGET_ENABLE = exports.DESC_COMMAND_AGENT_TARGET_STATUS = exports.DESC_COMMAND_AGENT_STATUS = exports.DESC_COMMAND_AGENT_RESTART = exports.DESC_COMMAND_AGENT_ENABLE = exports.DESC_COMMAND_AGENT_DISABLE = exports.DESC_COMMAND_AGENT_START = exports.DESC_COMMAND_AGENT_INSTALL = exports.DESC_COMMAND_AGENT_UNINSTALL = exports.DESC_COMMAND_AGENT_TUNNEL_REMOVE = exports.DESC_COMMAND_AGENT_TUNNEL_STATUS = void 0;
|
|
7
|
+
exports.OPTION_AGENT_START = exports.OPTION_AGENT_ID = exports.OPTION_ID = exports.OPTION_NAME = exports.OPTION_TARGET = exports.OPTION_TLS_TERMINATE = exports.OPTION_TLS_CA = exports.OPTION_TLS_CERT = exports.OPTION_TLS_KEY = exports.OPTION_HTTP_CIRCUIT_BREAKER = exports.OPTION_HTTP_COMPRESSION = exports.OPTION_HTTP_2 = exports.OPTION_HTTP_VERIFY = exports.OPTION_HTTP_LOG = exports.OPTION_HTTP_AUTH_BUDDY = exports.OPTION_HTTP_AUTH = exports.OPTION_HTTP_HOST = exports.OPTION_FORCE = exports.OPTION_TOKEN = exports.OPTION_TIMEOUT = exports.OPTION_FOLLOW = exports.OPTION_SERVE = exports.OPTION_HEADER_USER_AGENT = exports.OPTION_RESPONSE_HEADER = exports.OPTION_HEADER = exports.OPTION_WHITELIST = exports.OPTION_REST_API_PROJECT = exports.OPTION_REST_API_WORKSPACE = exports.OPTION_PIPELINE_RUN_WAIT_TIMEOUT = exports.OPTION_PIPELINE_RUN_WAIT = exports.OPTION_PIPELINE_RUN_ACTION = exports.OPTION_REST_API_TOKEN = exports.OPTION_PIPELINE_RUN_ARGUMENT = exports.OPTION_PIPELINE_RUN_DELAY = exports.OPTION_PIPELINE_RUN_VAR = exports.OPTION_PIPELINE_RUN_PRIORITY = exports.OPTION_PIPELINE_RUN_CLEAR_CACHE = exports.OPTION_PIPELINE_RUN_REFRESH = exports.OPTION_PIPELINE_RUN_COMMENT = exports.OPTION_PIPELINE_RUN_PULL_REQUEST = exports.OPTION_PIPELINE_RUN_REVISION = exports.OPTION_PIPELINE_RUN_TAG = exports.OPTION_PIPELINE_RUN_BRANCH = exports.OPTION_REST_API_REGION = exports.OPTION_REST_API_BASE_URL = exports.OPTION_DEFAULT_REGION = exports.OPTION_REGION = exports.TXT_CI_INFO = exports.TXT_PIPELINE_RUN_FINISH_FAILED = exports.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY = void 0;
|
|
8
|
+
exports.LOG_AGENT_STARTING_SYSTEM = exports.LOG_AGENT_STOPPING_SYSTEM = exports.LOG_AGENT_ENABLING_SYSTEM = exports.LOG_AGENT_SYSTEM_SERVICE_CONFIG = exports.LOG_AGENT_EXTRACTING_ARCHIVE = exports.LOG_AGENT_DOWNLOADING_ARCHIVE = exports.LOG_AGENT_SYSTEM_DIR = exports.LOG_ERROR_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_ERROR_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_ERROR_SAVING_AGENT_CONFIG = exports.LOG_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_SAVING_AGENT_CONFIG = exports.LOG_REGISTERING_AGENT = exports.OPTION_SCRAP_OUTPUT_DIR = exports.OPTION_SCRAP_DELAY = exports.OPTION_SCRAP_DARK_MODE = exports.OPTION_SCRAP_WAIT_FOR_ELEMENT = exports.OPTION_SCRAP_DEVICE_PIXEL_RATIO = exports.OPTION_SCRAP_VIEWPORT = exports.OPTION_SCRAP_BROWSER = exports.OPTION_SCRAP_XPATH_SELECTOR = exports.OPTION_SCRAP_CSS_SELECTOR = exports.OPTION_SCRAP_FULL_PAGE = exports.OPTION_SCRAP_QUALITY = exports.OPTION_SCRAP_OUTPUT_TYPE = exports.OPTION_SCRAP_FOLLOW = exports.OPTION_SCRAP_URL = exports.OPTION_COMPARE_WAIT_FOR = exports.OPTION_COMPARE_DELAY = exports.OPTION_COMPARE_HEADER = exports.OPTION_COMPARE_COOKIE = exports.OPTION_COMPARE_IGNORE = exports.OPTION_COMPARE_IGNORE_URLS = exports.OPTION_COMPARE_DRY_RUN = exports.OPTION_COMPARE_URLS_FILE = exports.OPTION_COMPARE_SITEMAP = exports.OPTION_COMPARE_URLS = exports.OPTION_COMPARE_RESPECT_ROBOTS = exports.OPTION_COMPARE_FOLLOW = exports.OPTION_EXEC_PARALLEL = exports.OPTION_EXEC_ONE_BY_ONE = exports.OPTION_EXEC_SKIP_DISCOVERY = exports.OPTION_EXEC_COMMAND = exports.OPTION_AGENT_DEBUG = exports.OPTION_AGENT_PORT = exports.OPTION_AGENT_TARGET = exports.OPTION_PASS = exports.OPTION_USER = exports.OPTION_AGENT_TOKEN = void 0;
|
|
9
|
+
exports.LOG_SESSION_LINK = exports.LOG_SENDING_DATA = exports.LOG_SENDING_REQUEST = exports.LOG_PROCESSING_SNAPSHOTS = exports.LOG_RUNNING_EXEC_COMMAND = exports.LOG_TUNNEL_SSH_STREAM = exports.LOG_TUNNEL_TLS_AGENT_STREAM = exports.LOG_TUNNEL_TLS_REGION_STREAM = exports.LOG_TUNNEL_TLS_TARGET_STREAM = exports.LOG_TUNNEL_HTTP2_STREAM = exports.LOG_TUNNEL_HTTP1_STREAM = exports.LOG_TUNNEL_TCP_STREAM = exports.LOG_TUNNEL_HTTP_WRONG_USER_AGENTS = exports.LOG_TUNNEL_HTTP_CIRCUIT_BREAKER_OPEN = exports.LOG_TUNNEL_HTTP_RATE_LIMIT = exports.LOG_TUNNEL_HTTP_WRON_AUTH = exports.LOG_TUNNEL_IDENTIFIED = exports.LOG_TUNNEL_DISCONNECTED = exports.LOG_TUNNEL_FAILED = exports.LOG_TUNNEL_CONNECTED = exports.LOG_AGENT_STARTED = exports.LOG_AGENT_SERVER_STARTED = exports.LOG_ERROR_STARTING_AGENT_SERVER = exports.LOG_REQUEST = exports.LOG_SSH_CONNECTION = exports.LOG_WRONG_STREAM = exports.LOG_DETECTED_STREAM = exports.LOG_HTTP2_REQUEST = exports.LOG_HTTP2_CONNECTION = exports.LOG_HTTP1_REQUEST = exports.LOG_HTTP1_CONNECTION = exports.LOG_ERROR = exports.LOG_STOPPING_TUNNEL = exports.LOG_STARTING_TUNNEL = exports.LOG_ENABLING_AGENT_TARGET = exports.LOG_DISABLING_AGENT_TARGET = exports.LOG_REMOVING_TUNNEL = exports.LOG_TUNNEL_REGISTERED = exports.LOG_ERROR_WHILE_REFRESHING_AGENT = exports.LOG_REGISTERING_TUNNEL = exports.LOG_GETTING_AGENT = exports.LOG_UNREGISTERING_AGENT = exports.LOG_REGION_DETECTED = exports.LOG_AGENT_REGISTERED = exports.LOG_SOCKET_DISCONNECTED = exports.LOG_SOCKET_CONNECTED = exports.LOG_AGENT_NSSM_CLEARING = exports.LOG_AGENT_NSSM_EXTRACTING = exports.LOG_AGENT_NSSM_DOWNLOADING = exports.LOG_AGENT_ENABLED = void 0;
|
|
10
|
+
exports.DEBUG_WAIT_FOR_IDLE_TIMEOUT = exports.DEBUG_WAIT_FOR_IDLE = exports.DEBUG_RESOURCE_DISCOVERY_TIMEOUT = exports.DEBUG_AUTO_WIDTH = exports.DEBUG_AUTO_SCROLL = exports.DEBUG_RESOURCE_SCRAPPING_URL = exports.DEBUG_SNAPSHOT_PROCESSING = exports.DEBUG_SNAPSHOTS_PROCESSING = exports.DEBUG_EXEC_COMMAND = exports.DEBUG_EXEC_TEST_COMMAND = exports.LOG_INSTALLED_BROWSER = void 0;
|
|
10
11
|
const ciInfo_1 = require("./types/ciInfo");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
13
|
+
exports.ERR_REST_API_GENERAL_ERROR = 'Something went wrong';
|
|
14
|
+
exports.ERR_REST_API_WRONG_TOKEN = 'Valid token with proper scopes is required';
|
|
15
|
+
exports.ERR_REST_API_RESOURCE_NOT_FOUND = 'Resource not found';
|
|
16
|
+
exports.ERR_REST_API_RATE_LIMIT = 'Rate limit exceeded';
|
|
17
|
+
exports.ERR_REST_API_TOKEN = 'Personal access token is required (--token)';
|
|
18
|
+
exports.ERR_REST_API_URL = 'Valid rest api endpoint is required (--base-url)';
|
|
19
|
+
exports.ERR_REST_API_WORKSPACE = 'Workspace domain is required (--workspace)';
|
|
20
|
+
exports.ERR_REST_API_PROJECT = 'Project name is required (--project)';
|
|
21
|
+
exports.ERR_RUN_PIPELINE_WORKSPACE_NOT_FOUND = 'Workspace not found';
|
|
22
|
+
exports.ERR_RUN_PIPELINE_PROJECT_NOT_FOUND = 'Project not found';
|
|
23
|
+
exports.ERR_RUN_PIPELINE_NOT_FOUND = 'Pipeline not found';
|
|
24
|
+
exports.ERR_RUN_PIPELINE_WAIT_TIMEOUT = 'Timeout waiting for run to finish';
|
|
25
|
+
exports.ERR_RUN_PIPELINE_WRONG_PRIORITY = 'Priority has wrong value. Possible: LOW, NORMAL, HIGH';
|
|
26
|
+
exports.ERR_RUN_PIPELINE_WRONG_DELAY = 'Delay must be a valid date format: 2016-11-18T12:38:16.000Z or 30s, 10m, 3h10m30s';
|
|
27
|
+
const ERR_RUN_PIPELINE_WRONG_ACTION = (str) => `Action id has wrong value: ${str}`;
|
|
28
|
+
exports.ERR_RUN_PIPELINE_WRONG_ACTION = ERR_RUN_PIPELINE_WRONG_ACTION;
|
|
29
|
+
const ERR_RUN_PIPELINE_WRONG_VARIABLE = (v) => `Variable has wrong format: ${v}`;
|
|
30
|
+
exports.ERR_RUN_PIPELINE_WRONG_VARIABLE = ERR_RUN_PIPELINE_WRONG_VARIABLE;
|
|
12
31
|
exports.ERR_AGENT_NOT_REGISTERED = 'Agent not registered. Exiting.';
|
|
13
32
|
exports.ERR_SAVING_AGENT_CONFIG = 'Failed saving agent config. Exiting.';
|
|
14
33
|
const ERR_TARGET_IS_NOT_VALID = (target) => `Target '${target}' invalid`;
|
|
@@ -200,6 +219,8 @@ exports.DESC_COMMAND_START = 'Starts tunnel from the configuration file.';
|
|
|
200
219
|
exports.DESC_COMMAND_TCP = 'Starts a tunnel which forwards all TCP traffic on a public port to a local address. This is extremely useful for exposing services that run non-HTTP traffic (ssh, sip, rdp, game servers, etc).';
|
|
201
220
|
exports.DESC_COMMAND_TLS = 'Starts a tunnel listening for TLS traffic on port 443 with a specific hostname.';
|
|
202
221
|
exports.DESC_PROGRAM = 'Buddy exposes local networked services behinds NATs and firewalls to the public internet over a secure tunnel. Share local websites, build/test webhook consumers, and self-host personal services.';
|
|
222
|
+
exports.DESC_COMMAND_PIPELINE = 'Commands to interact with the pipeline service';
|
|
223
|
+
exports.DESC_COMMAND_PIPELINE_RUN = 'Run pipeline. Token scopes: WORKSPACE, EXECUTION_RUN';
|
|
203
224
|
exports.DESC_COMMAND_VT = 'Commands to interact with the visual test service';
|
|
204
225
|
exports.DESC_COMMAND_VT_CLOSE = 'Close visual test session.';
|
|
205
226
|
exports.DESC_COMMAND_VT_STORYBOOK = 'Create visual test session from storybook';
|
|
@@ -221,8 +242,18 @@ exports.TXT_DISABLING_AGENT = 'Uninstalling agent...';
|
|
|
221
242
|
exports.TXT_ENABLING_AGENT = 'Installing agent...';
|
|
222
243
|
exports.TXT_UPDATING_AGENT = 'Updating agent...';
|
|
223
244
|
exports.TXT_OPENING_TUNNEL = 'Opening tunnel...';
|
|
245
|
+
const TXT_PIPELINE_RUN_SUCCESS = (runUrl) => `Run started: ${runUrl}`;
|
|
246
|
+
exports.TXT_PIPELINE_RUN_SUCCESS = TXT_PIPELINE_RUN_SUCCESS;
|
|
247
|
+
const TXT_PIPELINE_RUN_WAIT = (minutes) => `Waiting for ${minutes}m to finish run`;
|
|
248
|
+
exports.TXT_PIPELINE_RUN_WAIT = TXT_PIPELINE_RUN_WAIT;
|
|
249
|
+
const TXT_PIPELINE_RUN_STILL_WAITING = (waitTime) => `Still waiting...${waitTime}`;
|
|
250
|
+
exports.TXT_PIPELINE_RUN_STILL_WAITING = TXT_PIPELINE_RUN_STILL_WAITING;
|
|
224
251
|
const TXT_STORIES_AMOUNT = (amount) => `Found ${amount} stories`;
|
|
225
252
|
exports.TXT_STORIES_AMOUNT = TXT_STORIES_AMOUNT;
|
|
253
|
+
const TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY = (runUrl) => `Run finished successfully: ${runUrl}`;
|
|
254
|
+
exports.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY = TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY;
|
|
255
|
+
const TXT_PIPELINE_RUN_FINISH_FAILED = (status, runUrl) => `Run finished with status ${status}: ${runUrl}`;
|
|
256
|
+
exports.TXT_PIPELINE_RUN_FINISH_FAILED = TXT_PIPELINE_RUN_FINISH_FAILED;
|
|
226
257
|
const TXT_CI_INFO = (ciInfo) => {
|
|
227
258
|
let result = '';
|
|
228
259
|
if (ciInfo.ci !== ciInfo_1.CI.NONE) {
|
|
@@ -248,6 +279,25 @@ const TXT_CI_INFO = (ciInfo) => {
|
|
|
248
279
|
exports.TXT_CI_INFO = TXT_CI_INFO;
|
|
249
280
|
exports.OPTION_REGION = 'override default region ("eu", "us")';
|
|
250
281
|
exports.OPTION_DEFAULT_REGION = 'default region ("eu", "us")';
|
|
282
|
+
exports.OPTION_REST_API_BASE_URL = 'override default base url (api.buddy.works) and region. You can use env variable: BUDDY_BASE_URL.';
|
|
283
|
+
exports.OPTION_REST_API_REGION = 'override default region ("eu", "us"). You can use env variable: BUDDY_REGION. ';
|
|
284
|
+
exports.OPTION_PIPELINE_RUN_BRANCH = 'repository branch name';
|
|
285
|
+
exports.OPTION_PIPELINE_RUN_TAG = 'repository tag name';
|
|
286
|
+
exports.OPTION_PIPELINE_RUN_REVISION = 'repository revision';
|
|
287
|
+
exports.OPTION_PIPELINE_RUN_PULL_REQUEST = 'repository pull request id';
|
|
288
|
+
exports.OPTION_PIPELINE_RUN_COMMENT = 'run comment';
|
|
289
|
+
exports.OPTION_PIPELINE_RUN_REFRESH = 'deploy from scratch';
|
|
290
|
+
exports.OPTION_PIPELINE_RUN_CLEAR_CACHE = 'clear cache before running the pipeline';
|
|
291
|
+
exports.OPTION_PIPELINE_RUN_PRIORITY = 'run priority. Can be one of "LOW", "NORMAL" or "HIGH". Default is "NORMAL"';
|
|
292
|
+
exports.OPTION_PIPELINE_RUN_VAR = 'variable key:value. Can be passed multiple times to pass multiple variables';
|
|
293
|
+
exports.OPTION_PIPELINE_RUN_DELAY = 'the date when the execution should be run. Should be set in the format: 2016-11-18T12:38:16.000Z';
|
|
294
|
+
exports.OPTION_PIPELINE_RUN_ARGUMENT = 'pipeline identifier';
|
|
295
|
+
exports.OPTION_REST_API_TOKEN = 'personal access token. You can use env variable: BUDDY_TOKEN';
|
|
296
|
+
exports.OPTION_PIPELINE_RUN_ACTION = "action ID to be run in this execution. If not sent, it will be run in accordance with the pipeline's definition. Can be passed multiple times to select multiple actions";
|
|
297
|
+
exports.OPTION_PIPELINE_RUN_WAIT = 'wait for run to finish';
|
|
298
|
+
exports.OPTION_PIPELINE_RUN_WAIT_TIMEOUT = 'how long to wait for run to finish in minutes. Default: 30';
|
|
299
|
+
exports.OPTION_REST_API_WORKSPACE = 'workspace domain. You can use env variable: BUDDY_WORKSPACE';
|
|
300
|
+
exports.OPTION_REST_API_PROJECT = 'project name (url handle). You can use env variable: BUDDY_PROJECT';
|
|
251
301
|
exports.OPTION_WHITELIST = 'whitelist provided IP CIDRs. Use "*" to allow all';
|
|
252
302
|
exports.OPTION_HEADER = 'header key:value to add to the request';
|
|
253
303
|
exports.OPTION_RESPONSE_HEADER = 'header key:value to add to the response';
|
package/distTs/src/utils.js
CHANGED
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.getBasicCommandTls = exports.getBasicCommandHttp = exports.getBasicCommandTcp = exports.createSshHostKey = exports.getRealTargetHost = exports.isWindows = exports.isLinux = exports.isOsx = exports.isDocker = exports.sleep = exports.getLatestVersion = exports.getVersionEnv = exports.getVersionWithoutEnv = exports.getVersion = exports.getHomeDirectory = exports.newCommand = exports.formatHelp = exports.getPlatform = exports.getHostname = exports.isStringRegExp = exports.getRootDir = exports.TARGET_ONLY_PORT_REGEX = exports.TARGET_HTTP_REGEX = exports.TARGET_TCP_TLS_REGEX = exports.ApiErrorTunnelsDisabled = exports.ApiErrorWorkspaceFlagged = exports.ApiErrorTunnelLimitReached = exports.ApiErrorAgentLimitReached = exports.ApiErrorDomainRestricted = exports.ApiErrorTargetInvalid = exports.ApiErrorWrongToken = exports.ApiErrorFailedToConnect = exports.ApiErrorAgentNotFound = exports.SUGGESTED_BROWSER_VERSION = exports.DEFAULT_TIMEOUT = exports.TUNNEL_HTTP_CB_MIN_REQUESTS = exports.TUNNEL_HTTP_CB_WINDOW = exports.TUNNEL_MAX_REQUEST_SIZE_TO_SYNC = exports.TUNNEL_HTTP_LOG_MAX_REQUESTS = exports.TUNNEL_HTTP_LOG_MAX_BODY = exports.TUNNEL_HTTP_RATE_WINDOW = exports.TUNNEL_HTTP_RATE_LIMIT = void 0;
|
|
30
30
|
exports.apiErrorCodeToClass = apiErrorCodeToClass;
|
|
31
31
|
exports.isFile = isFile;
|
|
32
|
+
exports.asyncWait = asyncWait;
|
|
32
33
|
const node_path_1 = __importStar(require("node:path"));
|
|
33
34
|
const node_fs_1 = require("node:fs");
|
|
34
35
|
const texts_1 = require("./texts");
|
|
@@ -376,3 +377,8 @@ function isFile(path) {
|
|
|
376
377
|
return false;
|
|
377
378
|
}
|
|
378
379
|
}
|
|
380
|
+
async function asyncWait(ms) {
|
|
381
|
+
return new Promise((resolve) => {
|
|
382
|
+
setTimeout(resolve, ms);
|
|
383
|
+
});
|
|
384
|
+
}
|