bdy 1.12.12-dev-pipeline-run → 1.13.0-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.
Files changed (40) hide show
  1. package/distTs/package.json +13 -12
  2. package/distTs/src/agent.js +302 -0
  3. package/distTs/src/api/agent.js +99 -0
  4. package/distTs/src/api/buddy.js +139 -0
  5. package/distTs/src/api/client.js +10 -6
  6. package/distTs/src/api/socket.js +159 -0
  7. package/distTs/src/cfg.js +234 -0
  8. package/distTs/src/command/config.js +17 -0
  9. package/distTs/src/command/http.js +30 -0
  10. package/distTs/src/command/pipeline/run.js +35 -32
  11. package/distTs/src/command/start.js +28 -0
  12. package/distTs/src/command/tcp.js +30 -0
  13. package/distTs/src/command/tls.js +30 -0
  14. package/distTs/src/command/ut/upload.js +17 -7
  15. package/distTs/src/command/vt/compare.js +2 -2
  16. package/distTs/src/command/vt/exec.js +4 -3
  17. package/distTs/src/command/vt/storybook.js +4 -3
  18. package/distTs/src/input.js +20 -10
  19. package/distTs/src/output/interactive/tunnel.js +860 -0
  20. package/distTs/src/output/noninteractive/agent/tunnels.js +43 -0
  21. package/distTs/src/output/noninteractive/config/tunnel.js +65 -0
  22. package/distTs/src/output/noninteractive/config/tunnels.js +18 -0
  23. package/distTs/src/output/noninteractive/tunnel.js +59 -0
  24. package/distTs/src/server/cert.js +52 -0
  25. package/distTs/src/server/http1.js +75 -0
  26. package/distTs/src/server/http2.js +78 -0
  27. package/distTs/src/server/sftp.js +497 -0
  28. package/distTs/src/server/ssh.js +446 -0
  29. package/distTs/src/server/tls.js +41 -0
  30. package/distTs/src/ssh/client.js +197 -0
  31. package/distTs/src/texts.js +7 -52
  32. package/distTs/src/tunnel/html/503.html +338 -0
  33. package/distTs/src/tunnel/tunnel.js +31 -13
  34. package/distTs/src/tunnel.js +656 -0
  35. package/distTs/src/unitTest/ci.js +12 -8
  36. package/distTs/src/utils.js +17 -7
  37. package/distTs/src/visualTest/context.js +4 -4
  38. package/distTs/src/visualTest/exec.js +0 -24
  39. package/distTs/src/visualTest/resources.js +18 -8
  40. package/package.json +13 -12
@@ -0,0 +1,159 @@
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 https_1 = require("https");
7
+ const events_1 = __importDefault(require("events"));
8
+ const logger_js_1 = __importDefault(require("../logger.js"));
9
+ const texts_1 = require("../texts");
10
+ const utils_1 = require("../utils");
11
+ const socket_io_client_1 = require("socket.io-client");
12
+ const MAX_REQUESTS_SYNC_WINDOW = 30000;
13
+ const MAX_REQUESTS_SYNC_IN_WINDOW = 100;
14
+ class ApiSocketClass extends events_1.default {
15
+ fetch(activate = true, action = null, disabled = null, resetFirstHeard = false, tunnels) {
16
+ this.socket.emit('fetchTunnelAgent', {
17
+ id: this.id,
18
+ token: this.token,
19
+ hostname: this.hostname,
20
+ platform: this.platform,
21
+ version: this.version,
22
+ activate,
23
+ action,
24
+ disabled,
25
+ resetFirstHeard,
26
+ tunnels,
27
+ });
28
+ }
29
+ update(activate, tunnels, force = false) {
30
+ const now = Date.now();
31
+ // nie robimy update jak byl mniej niz 5s temu
32
+ if (!force && this.lastUpdate && now - this.lastUpdate < 5000)
33
+ return;
34
+ this.lastUpdate = now;
35
+ this.socket.emit('updateTunnelAgent', {
36
+ id: this.id,
37
+ token: this.token,
38
+ hostname: this.hostname,
39
+ platform: this.platform,
40
+ version: this.version,
41
+ activate,
42
+ tunnels,
43
+ });
44
+ }
45
+ emitRequest(tunnelId, logRequest) {
46
+ this.socket.emit('tunnelRequest', {
47
+ id: this.id,
48
+ token: this.token,
49
+ tunnelId,
50
+ request: logRequest.toSocket(),
51
+ });
52
+ }
53
+ request(tunnelId, logRequest) {
54
+ if (this.tunnelRequests > MAX_REQUESTS_SYNC_IN_WINDOW)
55
+ return;
56
+ this.tunnelRequests += 1;
57
+ logRequest.once(utils_1.EVENT_TUNNEL_HTTP_NEW_RESPONSE_END, () => {
58
+ this.emitRequest(tunnelId, logRequest);
59
+ });
60
+ this.emitRequest(tunnelId, logRequest);
61
+ }
62
+ onSyncAgent(data, action) {
63
+ this.emit(utils_1.SOCKET_IO_EVENT_AGENT, data, action);
64
+ }
65
+ onSyncTunnel(data, action) {
66
+ this.emit(utils_1.SOCKET_IO_EVENT_TUNNEL, data, action);
67
+ }
68
+ onSync(data) {
69
+ try {
70
+ const json = JSON.parse(data);
71
+ if (json.payloadType === 'TunnelAgentFront')
72
+ this.onSyncAgent(json.payload, json.action);
73
+ else if (json.payloadType === 'TunnelFront')
74
+ this.onSyncTunnel(json.payload, json.action);
75
+ }
76
+ catch {
77
+ // do nothing
78
+ }
79
+ }
80
+ connect(atOnce) {
81
+ logger_js_1.default.debug('socket connect');
82
+ if (atOnce && this.socket && !this.socket.connected) {
83
+ this.socket.connect();
84
+ }
85
+ else {
86
+ setTimeout(() => {
87
+ if (this.socket && !this.socket.connected)
88
+ this.socket.connect();
89
+ }, 3000);
90
+ }
91
+ }
92
+ destroy() {
93
+ if (this.socket) {
94
+ this.socket.removeAllListeners();
95
+ this.socket.disconnect();
96
+ this.socket = null;
97
+ }
98
+ }
99
+ constructor(host, id, token) {
100
+ super();
101
+ this.id = id;
102
+ this.token = token;
103
+ this.connected = false;
104
+ this.hostname = (0, utils_1.getHostname)();
105
+ this.platform = (0, utils_1.getPlatform)();
106
+ this.version = (0, utils_1.getVersion)();
107
+ this.lastUpdate = null;
108
+ this.tunnelRequests = 0;
109
+ setInterval(() => {
110
+ this.tunnelRequests = 0;
111
+ }, MAX_REQUESTS_SYNC_WINDOW);
112
+ this.socket = (0, socket_io_client_1.io)(host, {
113
+ forceNew: true,
114
+ autoConnect: false,
115
+ autoUnref: true,
116
+ forceBase64: true,
117
+ transports: ['websocket'],
118
+ reconnection: false,
119
+ rejectUnauthorized: false,
120
+ agent: new https_1.Agent({
121
+ rejectUnauthorized: false,
122
+ }),
123
+ maxHttpBufferSize: 3e6,
124
+ extraHeaders: {
125
+ cookie: 'a=b',
126
+ },
127
+ });
128
+ this.socket.on('connect', () => {
129
+ this.connected = true;
130
+ logger_js_1.default.info(texts_1.LOG_SOCKET_CONNECTED);
131
+ this.emit(utils_1.SOCKET_IO_EVENT_CONNECTED);
132
+ this.socket.emit('joinTunnelAgent', {
133
+ id: this.id,
134
+ token: this.token,
135
+ });
136
+ });
137
+ this.socket.on('disconnect', () => {
138
+ this.connected = false;
139
+ logger_js_1.default.info(texts_1.LOG_SOCKET_DISCONNECTED);
140
+ this.emit(utils_1.SOCKET_IO_EVENT_DISCONNECTED);
141
+ this.connect();
142
+ });
143
+ this.socket.on('connect_error', () => {
144
+ logger_js_1.default.debug('socket error');
145
+ this.connect();
146
+ });
147
+ this.socket.on('fetchTunnelAgentSuccess', (data) => {
148
+ logger_js_1.default.debug('Socket fetch success');
149
+ this.emit(utils_1.SOCKET_IO_EVENT_FETCH_SUCCESS, data);
150
+ });
151
+ this.socket.on('fetchTunnelAgentFailed', (code) => {
152
+ logger_js_1.default.debug('Socket fetch failed');
153
+ this.emit(utils_1.SOCKET_IO_EVENT_FETCH_FAILED, (0, utils_1.apiErrorCodeToClass)(code, host));
154
+ });
155
+ this.socket.on('sync', (data) => this.onSync(data));
156
+ this.connect(true);
157
+ }
158
+ }
159
+ exports.default = ApiSocketClass;
@@ -0,0 +1,234 @@
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 path_1 = require("path");
7
+ const fs_1 = require("fs");
8
+ const jsonwebtoken_1 = require("jsonwebtoken");
9
+ const utils_js_1 = require("./utils.js");
10
+ const input_js_1 = __importDefault(require("./input.js"));
11
+ const texts_js_1 = require("./texts.js");
12
+ class Cfg {
13
+ constructor() {
14
+ this.dir = (0, utils_js_1.getHomeDirectory)();
15
+ this.file = (0, path_1.resolve)(this.dir, 'cfg.json');
16
+ this.json = {};
17
+ this.load();
18
+ }
19
+ createDir() {
20
+ try {
21
+ (0, fs_1.mkdirSync)(this.dir, {
22
+ recursive: true,
23
+ });
24
+ }
25
+ catch {
26
+ throw new Error((0, texts_js_1.ERR_CANT_CREATE_DIR_IN_HOME)('.bdy'));
27
+ }
28
+ try {
29
+ (0, fs_1.chmodSync)(this.dir, 0o777);
30
+ }
31
+ catch {
32
+ // do nothing
33
+ }
34
+ }
35
+ createEmptyFile() {
36
+ try {
37
+ (0, fs_1.writeFileSync)(this.file, '{}', 'utf-8');
38
+ }
39
+ catch {
40
+ throw new Error((0, texts_js_1.ERR_CANT_CREATE_DIR_IN_HOME)('.bdy/cfg.json'));
41
+ }
42
+ try {
43
+ (0, fs_1.chmodSync)(this.file, 0o666);
44
+ }
45
+ catch {
46
+ // do nothing
47
+ }
48
+ }
49
+ ensureDir() {
50
+ try {
51
+ (0, fs_1.statSync)(this.dir);
52
+ }
53
+ catch {
54
+ this.createDir();
55
+ }
56
+ }
57
+ ensureFile() {
58
+ this.ensureDir();
59
+ try {
60
+ (0, fs_1.statSync)(this.file);
61
+ }
62
+ catch {
63
+ this.createEmptyFile();
64
+ }
65
+ }
66
+ ensureTunnels() {
67
+ if (!this.json.tunnels)
68
+ this.json.tunnels = {};
69
+ }
70
+ async prepareTunnel(tunnelType, target, options, useDefaults) {
71
+ const type = input_js_1.default.type(tunnelType);
72
+ const tunnel = {
73
+ type,
74
+ target: input_js_1.default.target(target, type),
75
+ };
76
+ if (options.region !== undefined)
77
+ tunnel.region = input_js_1.default.region(options.region);
78
+ else if (useDefaults)
79
+ tunnel.region = this.getRegion();
80
+ if (options.whitelist !== undefined)
81
+ tunnel.whitelist = input_js_1.default.whitelist(options.whitelist);
82
+ else if (useDefaults)
83
+ tunnel.whitelist = this.getWhitelist();
84
+ if (options.timeout !== undefined)
85
+ tunnel.timeout = input_js_1.default.timeout(options.timeout);
86
+ else if (useDefaults)
87
+ tunnel.timeout = this.getTimeout();
88
+ if (type === utils_js_1.TUNNEL_HTTP) {
89
+ if (options.host !== undefined)
90
+ tunnel.host = options.host;
91
+ if (options.auth !== undefined) {
92
+ const { password, login } = input_js_1.default.auth(options.auth);
93
+ tunnel.login = login;
94
+ tunnel.password = password;
95
+ }
96
+ if (options.ca !== undefined)
97
+ tunnel.ca = input_js_1.default.ca(options.ca);
98
+ if (options.serve !== undefined)
99
+ tunnel.serve = input_js_1.default.serve(options.serve);
100
+ if (options.useragent !== undefined)
101
+ tunnel.useragents = input_js_1.default.useragents(options.useragent);
102
+ if (options.header !== undefined)
103
+ tunnel.headers = input_js_1.default.headers(options.header);
104
+ if (options.responseHeader !== undefined)
105
+ tunnel.responseHeaders = input_js_1.default.headers(options.responseHeader);
106
+ if (options.circuitBreaker !== undefined)
107
+ tunnel.circuitBreaker = input_js_1.default.circuitBreaker(options.circuitBreaker);
108
+ tunnel.log = !!options.log;
109
+ tunnel.verify = !!options.verify;
110
+ tunnel.http2 = !!options.http2;
111
+ tunnel.compression = !!options.compression;
112
+ }
113
+ else if (type === utils_js_1.TUNNEL_TLS) {
114
+ tunnel.terminate = input_js_1.default.terminate(options.terminate);
115
+ if (options.key !== undefined || options.cert !== undefined) {
116
+ const { key, cert } = input_js_1.default.keyCert(options.key, options.cert);
117
+ tunnel.key = key;
118
+ tunnel.cert = cert;
119
+ }
120
+ if (options.ca !== undefined)
121
+ tunnel.ca = input_js_1.default.ca(options.ca);
122
+ }
123
+ if (options.name !== undefined)
124
+ tunnel.name = input_js_1.default.name(options.name);
125
+ return tunnel;
126
+ }
127
+ async addTunnel(name, type, target, options) {
128
+ this.ensureTunnels();
129
+ this.json.tunnels[name] = await this.prepareTunnel(type, target, {
130
+ name,
131
+ ...options,
132
+ }, false);
133
+ this.save();
134
+ }
135
+ removeTunnel(name) {
136
+ this.ensureTunnels();
137
+ delete this.json.tunnels[name];
138
+ this.save();
139
+ }
140
+ getTunnels() {
141
+ this.ensureTunnels();
142
+ return this.json.tunnels;
143
+ }
144
+ hasTunnel(name) {
145
+ this.ensureTunnels();
146
+ return !!this.json.tunnels[name];
147
+ }
148
+ getTunnel(name) {
149
+ this.ensureTunnels();
150
+ return this.json.tunnels[name];
151
+ }
152
+ setToken(token) {
153
+ if (!token)
154
+ delete this.json.token;
155
+ else
156
+ this.json.token = token;
157
+ this.save();
158
+ }
159
+ setWhitelist(whitelist) {
160
+ if (!whitelist || !whitelist.length)
161
+ delete this.json.whitelist;
162
+ else
163
+ this.json.whitelist = whitelist;
164
+ this.save();
165
+ }
166
+ setTimeout(timeout) {
167
+ if (!timeout)
168
+ delete this.json.timeout;
169
+ else
170
+ this.json.timeout = timeout;
171
+ this.save();
172
+ }
173
+ getToken() {
174
+ return this.json.token || '';
175
+ }
176
+ getTokenHost() {
177
+ const token = this.getToken();
178
+ if (!token) {
179
+ throw new Error(texts_js_1.ERR_TOKEN_NOT_PROVIDED);
180
+ }
181
+ const d = (0, jsonwebtoken_1.decode)(token);
182
+ if (d === null) {
183
+ throw new Error(texts_js_1.ERR_WRONG_TOKEN);
184
+ }
185
+ if (!d.host) {
186
+ throw new Error(texts_js_1.ERR_WRONG_TOKEN);
187
+ }
188
+ return d.host;
189
+ }
190
+ getRegion() {
191
+ return (this.json.region || '').toUpperCase();
192
+ }
193
+ getTimeout() {
194
+ return this.json.timeout || utils_js_1.DEFAULT_TIMEOUT;
195
+ }
196
+ getWhitelist() {
197
+ return this.json.whitelist || [];
198
+ }
199
+ setRegion(region) {
200
+ this.json.region = region;
201
+ this.save();
202
+ }
203
+ setRegionIfNotSet(region) {
204
+ if (!this.json.region && region)
205
+ this.json.region = region.toUpperCase();
206
+ this.save();
207
+ }
208
+ load() {
209
+ this.ensureFile();
210
+ try {
211
+ const txt = (0, fs_1.readFileSync)(this.file, 'utf-8');
212
+ this.json = JSON.parse(txt);
213
+ }
214
+ catch {
215
+ throw new Error(texts_js_1.ERR_CONFIG_CORRUPTED);
216
+ }
217
+ }
218
+ save() {
219
+ this.ensureDir();
220
+ try {
221
+ (0, fs_1.writeFileSync)(this.file, JSON.stringify(this.json, null, 4), 'utf-8');
222
+ }
223
+ catch {
224
+ throw new Error((0, texts_js_1.ERR_CANT_CREATE_DIR_IN_HOME)('.bdy/cfg.json'));
225
+ }
226
+ try {
227
+ (0, fs_1.chmodSync)(this.file, 0o666);
228
+ }
229
+ catch {
230
+ // do nothing
231
+ }
232
+ }
233
+ }
234
+ exports.default = new Cfg();
@@ -0,0 +1,17 @@
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 set_js_1 = __importDefault(require("./config/set.js"));
7
+ const get_js_1 = __importDefault(require("./config/get.js"));
8
+ const add_js_1 = __importDefault(require("./config/add.js"));
9
+ const remove_js_1 = __importDefault(require("./config/remove.js"));
10
+ const texts_js_1 = require("../texts.js");
11
+ const utils_1 = require("../utils");
12
+ const commandConfig = (0, utils_1.newCommand)('config', texts_js_1.DESC_COMMAND_CONFIG);
13
+ commandConfig.addCommand(set_js_1.default);
14
+ commandConfig.addCommand(add_js_1.default);
15
+ commandConfig.addCommand(get_js_1.default);
16
+ commandConfig.addCommand(remove_js_1.default);
17
+ exports.default = commandConfig;
@@ -0,0 +1,30 @@
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_js_1 = require("../utils.js");
7
+ const cfg_js_1 = __importDefault(require("../cfg.js"));
8
+ const output_js_1 = __importDefault(require("../output.js"));
9
+ const texts_js_1 = require("../texts.js");
10
+ const buddy_js_1 = __importDefault(require("../api/buddy.js"));
11
+ const commandHttp = (0, utils_js_1.getBasicCommandHttp)();
12
+ commandHttp.description(texts_js_1.DESC_COMMAND_HTTP);
13
+ commandHttp.option('-s, --serve <directory>', texts_js_1.OPTION_SERVE);
14
+ commandHttp.option('--token <token>', texts_js_1.OPTION_TOKEN);
15
+ commandHttp.argument('[protocol://host:port]', texts_js_1.OPTION_TARGET);
16
+ commandHttp.action(async (target, options) => {
17
+ if (options.token)
18
+ cfg_js_1.default.setToken(options.token);
19
+ const prepared = await cfg_js_1.default.prepareTunnel(utils_js_1.TUNNEL_HTTP, target, options, true);
20
+ await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
21
+ const agent = await buddy_js_1.default.register(false, false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
22
+ cfg_js_1.default.setRegionIfNotSet(region);
23
+ });
24
+ await agent.start();
25
+ agent.startRefreshingConfiguration();
26
+ const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
27
+ agent.addTunnel(tunnel);
28
+ output_js_1.default.tunnel(tunnel);
29
+ });
30
+ exports.default = commandHttp;
@@ -24,12 +24,12 @@ commandPipelineRun.option('-f, --refresh', texts_1.OPTION_PIPELINE_RUN_REFRESH);
24
24
  commandPipelineRun.option('-c, --clear-cache', texts_1.OPTION_PIPELINE_RUN_CLEAR_CACHE);
25
25
  commandPipelineRun.option('--priority <priority>', texts_1.OPTION_PIPELINE_RUN_PRIORITY);
26
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);
27
+ commandPipelineRun.option('-vm, --variable-masked <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
28
28
  commandPipelineRun.option('--schedule <date>', texts_1.OPTION_PIPELINE_RUN_DELAY);
29
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);
30
+ commandPipelineRun.option('--wait [minutes]', texts_1.OPTION_PIPELINE_RUN_WAIT);
32
31
  commandPipelineRun.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
32
+ commandPipelineRun.usage('<identifier> [options]');
33
33
  commandPipelineRun.action(async (identifier, options) => {
34
34
  const token = input_1.default.restApiToken(options.token);
35
35
  const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
@@ -84,8 +84,8 @@ commandPipelineRun.action(async (identifier, options) => {
84
84
  if (options.variable) {
85
85
  body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variable, false));
86
86
  }
87
- if (options.variableEncrypted) {
88
- body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variableEncrypted, true));
87
+ if (options.variableMasked) {
88
+ body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variableMasked, true));
89
89
  }
90
90
  const delay = input_1.default.pipelineRunDelay(options.schedule);
91
91
  if (delay) {
@@ -97,38 +97,41 @@ commandPipelineRun.action(async (identifier, options) => {
97
97
  }
98
98
  const result = await client.postPipelineRun(workspace, project, data.pipeline_id, body);
99
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);
100
+ const minutes = input_1.default.pipelineRunWaitTime(options.wait);
101
+ wait(minutes, workspace, project, data.pipeline_id, result.id, result.html_url, client);
127
102
  }
128
103
  else {
129
104
  output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_SUCCESS)(result.html_url));
130
105
  }
131
106
  });
107
+ const wait = (minutes, workspace, project, pipelineId, runId, htmlUrl, client) => {
108
+ const start = Date.now();
109
+ output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_WAIT)(minutes));
110
+ let fetchCounter = 1;
111
+ const ts1 = setTimeout(() => {
112
+ output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_WAIT_TIMEOUT);
113
+ }, minutes * 60 * 1000);
114
+ const ts2 = setInterval(async () => {
115
+ output_1.default.clearPreviousLine();
116
+ output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_STILL_WAITING)(formatWaitTime(start)));
117
+ if (fetchCounter >= 3) {
118
+ const run = await client.getPipelineRun(workspace, project, pipelineId, runId);
119
+ if (!['INPROGRESS', 'ENQUEUED', 'TERMINATING'].includes(run.status)) {
120
+ clearTimeout(ts1);
121
+ clearInterval(ts2);
122
+ output_1.default.clearPreviousLine();
123
+ if (run.status === 'SUCCESSFUL') {
124
+ output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY)(htmlUrl));
125
+ }
126
+ else {
127
+ output_1.default.exitError((0, texts_1.TXT_PIPELINE_RUN_FINISH_FAILED)(run.status, htmlUrl));
128
+ }
129
+ }
130
+ fetchCounter = 0;
131
+ }
132
+ fetchCounter += 1;
133
+ }, 1000);
134
+ };
132
135
  const formatWaitTime = (start) => {
133
136
  const elapsed = Math.floor((Date.now() - start) / 1000);
134
137
  return format_1.default.pipelineRunWaitTime(elapsed);
@@ -0,0 +1,28 @@
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 cfg_js_1 = __importDefault(require("../cfg.js"));
7
+ const output_js_1 = __importDefault(require("../output.js"));
8
+ const texts_js_1 = require("../texts.js");
9
+ const buddy_js_1 = __importDefault(require("../api/buddy.js"));
10
+ const utils_1 = require("../utils");
11
+ const commandStart = (0, utils_1.newCommand)('start', texts_js_1.DESC_COMMAND_START);
12
+ commandStart.argument('<name>', texts_js_1.OPTION_NAME);
13
+ commandStart.action(async (name) => {
14
+ if (!cfg_js_1.default.hasTunnel(name)) {
15
+ output_js_1.default.exitError((0, texts_js_1.ERR_TUNNEL_NOT_FOUND)(name));
16
+ }
17
+ const prepared = cfg_js_1.default.getTunnel(name);
18
+ await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
19
+ const agent = await buddy_js_1.default.register(false, false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
20
+ cfg_js_1.default.setRegionIfNotSet(region);
21
+ });
22
+ await agent.start();
23
+ agent.startRefreshingConfiguration();
24
+ const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
25
+ agent.addTunnel(tunnel);
26
+ output_js_1.default.tunnel(tunnel);
27
+ });
28
+ exports.default = commandStart;
@@ -0,0 +1,30 @@
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_js_1 = require("../utils.js");
7
+ const cfg_js_1 = __importDefault(require("../cfg.js"));
8
+ const output_js_1 = __importDefault(require("../output.js"));
9
+ const texts_js_1 = require("../texts.js");
10
+ const utils_1 = require("../utils");
11
+ const buddy_js_1 = __importDefault(require("../api/buddy.js"));
12
+ const commandTcp = (0, utils_1.getBasicCommandTcp)();
13
+ commandTcp.description(texts_js_1.DESC_COMMAND_TCP);
14
+ commandTcp.option('--token <token>', texts_js_1.OPTION_TOKEN);
15
+ commandTcp.argument('[host:port]', texts_js_1.OPTION_TARGET);
16
+ commandTcp.action(async (target, options) => {
17
+ if (options.token)
18
+ cfg_js_1.default.setToken(options.token);
19
+ const prepared = await cfg_js_1.default.prepareTunnel(utils_js_1.TUNNEL_TCP, target, options, true);
20
+ await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
21
+ const agent = await buddy_js_1.default.register(false, false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
22
+ cfg_js_1.default.setRegionIfNotSet(region);
23
+ });
24
+ await agent.start();
25
+ agent.startRefreshingConfiguration();
26
+ const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
27
+ agent.addTunnel(tunnel);
28
+ output_js_1.default.tunnel(tunnel);
29
+ });
30
+ exports.default = commandTcp;
@@ -0,0 +1,30 @@
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_js_1 = require("../utils.js");
7
+ const cfg_js_1 = __importDefault(require("../cfg.js"));
8
+ const output_js_1 = __importDefault(require("../output.js"));
9
+ const texts_js_1 = require("../texts.js");
10
+ const utils_1 = require("../utils");
11
+ const buddy_js_1 = __importDefault(require("../api/buddy.js"));
12
+ const commandTls = (0, utils_1.getBasicCommandTls)();
13
+ commandTls.description(texts_js_1.DESC_COMMAND_TLS);
14
+ commandTls.option('--token <token>', texts_js_1.OPTION_TOKEN);
15
+ commandTls.argument('[host:port]', texts_js_1.OPTION_TARGET);
16
+ commandTls.action(async (target, options) => {
17
+ if (options.token)
18
+ cfg_js_1.default.setToken(options.token);
19
+ const prepared = await cfg_js_1.default.prepareTunnel(utils_js_1.TUNNEL_TLS, target, options, true);
20
+ await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
21
+ const agent = await buddy_js_1.default.register(false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
22
+ cfg_js_1.default.setRegionIfNotSet(region);
23
+ });
24
+ await agent.start();
25
+ agent.startRefreshingConfiguration();
26
+ const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
27
+ agent.addTunnel(tunnel);
28
+ output_js_1.default.tunnel(tunnel);
29
+ });
30
+ exports.default = commandTls;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -11,8 +11,8 @@ const linkUtils_1 = require("../../visualTest/linkUtils");
11
11
  const node_fs_1 = require("node:fs");
12
12
  const requests_1 = require("../../visualTest/requests");
13
13
  const validation_2 = require("./compare/validation");
14
- const ci_1 = require("../../visualTest/ci");
15
14
  const context_1 = require("../../visualTest/context");
15
+ const ci_info_1 = require("@buddy-works/ci-info");
16
16
  const commandVtCompare = (0, utils_1.newCommand)('compare', texts_1.DESC_COMMAND_VT_COMPARE);
17
17
  commandVtCompare.option('--urls <urls>', texts_1.OPTION_COMPARE_URLS);
18
18
  commandVtCompare.option('--sitemap <sitemap>', texts_1.OPTION_COMPARE_SITEMAP);
@@ -58,7 +58,7 @@ commandVtCompare.action(async (options) => {
58
58
  else if (filteredUrls.length > 1) {
59
59
  output_1.default.normal(`List of urls:\n${filteredUrls.join('\n')}`);
60
60
  }
61
- const ciAndGitInfo = await (0, ci_1.getCiAndGitInfo)({});
61
+ const ciAndGitInfo = await (0, ci_info_1.getCiAndGitInfo)({});
62
62
  (0, context_1.setCiAndCommitInfo)(ciAndGitInfo);
63
63
  try {
64
64
  const { message } = await (0, requests_1.sendCompareLinks)(filteredUrls, validatedOptions, sitemapSource);