bdy 1.18.31-dev → 1.18.31-dev-commands-changes-869c3r8yn
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 +83 -0
- package/distTs/src/command/crawl/link.js +61 -0
- package/distTs/src/command/crawl/run.js +147 -0
- package/distTs/src/command/crawl/validation.js +154 -0
- package/distTs/src/command/crawl.js +13 -0
- package/distTs/src/command/pipeline/run/start.js +101 -0
- package/distTs/src/command/pipeline/run/status.js +34 -0
- package/distTs/src/command/tests/capture/validation.js +46 -0
- package/distTs/src/command/tests/capture.js +103 -0
- package/distTs/src/command/tests/unit/link.js +61 -0
- package/distTs/src/command/tests/unit/upload.js +91 -0
- package/distTs/src/command/tests/unit.js +13 -0
- package/distTs/src/command/tests/visual/link.js +61 -0
- package/distTs/src/command/tests/visual/session/close.js +32 -0
- package/distTs/src/command/tests/visual/session/create.js +86 -0
- package/distTs/src/command/tests/visual/session.js +13 -0
- package/distTs/src/command/tests/visual/setup.js +20 -0
- package/distTs/src/command/tests/visual/shared/validation.js +145 -0
- package/distTs/src/command/tests/visual/upload.js +141 -0
- package/distTs/src/command/tests/visual.js +17 -0
- package/distTs/src/command/tests.js +15 -0
- package/distTs/src/command/whoami.js +12 -0
- package/distTs/src/crawl/requests.js +141 -0
- package/distTs/src/index.js +4 -6
- package/distTs/src/input.js +78 -0
- package/distTs/src/output/pipeline.js +915 -0
- package/distTs/src/project/cfg.js +39 -0
- package/distTs/src/texts.js +68 -41
- package/distTs/src/types/crawl.js +2 -0
- package/distTs/src/types/pipeline.js +424 -0
- package/distTs/src/unitTest/context.js +26 -0
- package/distTs/src/unitTest/requests.js +23 -10
- package/distTs/src/visualTest/context.js +42 -31
- package/distTs/src/visualTest/requests.js +39 -139
- package/distTs/src/visualTest/resources.js +40 -38
- package/distTs/src/visualTest/server.js +2 -2
- package/distTs/src/visualTest/snapshots.js +18 -17
- package/distTs/src/visualTest/validation.js +2 -10
- package/package.json +1 -1
- package/distTs/src/command/project/get.js +0 -18
- package/distTs/src/command/project/set.js +0 -31
- package/distTs/src/command/sandbox/get/yaml.js +0 -30
- package/distTs/src/command/vt/scrape.js +0 -193
|
@@ -0,0 +1,141 @@
|
|
|
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 node_fs_1 = require("node:fs");
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const node_zlib_1 = require("node:zlib");
|
|
12
|
+
const commandVisualUpload = (0, utils_1.newCommand)('upload', texts_1.DESC_COMMAND_VISUAL_UPLOAD);
|
|
13
|
+
commandVisualUpload.action(async () => {
|
|
14
|
+
const { getCiAndGitInfo, formattedCiInfo } = require('@buddy-works/ci-info');
|
|
15
|
+
const { getDefaultSettings, sendStorybook } = require('../../../visualTest/requests');
|
|
16
|
+
const { setDefaultSettings } = require('../../../visualTest/snapshots');
|
|
17
|
+
const { createVtContext, applyToken, applyCiAndCommitInfo } = require('../../../visualTest/context');
|
|
18
|
+
const Input = require('../../../input').default;
|
|
19
|
+
const ctx = createVtContext();
|
|
20
|
+
const token = await Input.vtSuiteToken();
|
|
21
|
+
if (!token) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
23
|
+
}
|
|
24
|
+
applyToken(ctx, token);
|
|
25
|
+
const currentDirectoryFiles = getCurrentDirectoryFiles();
|
|
26
|
+
if (!isStorybookDirectory(currentDirectoryFiles)) {
|
|
27
|
+
output_1.default.exitError(texts_1.ERR_WRONG_STORYBOOK_DIRECTORY);
|
|
28
|
+
}
|
|
29
|
+
const storybookStoriesIndex = getStorybookStoriesIndex(currentDirectoryFiles);
|
|
30
|
+
const storiesList = getStoriesList(storybookStoriesIndex);
|
|
31
|
+
const storybookSnapshots = getStorybookSnapshots(storiesList);
|
|
32
|
+
const defaultSettings = await getDefaultSettings(ctx);
|
|
33
|
+
setDefaultSettings(defaultSettings);
|
|
34
|
+
const ciAndGitInfo = await getCiAndGitInfo({
|
|
35
|
+
baseBranch: defaultSettings.baseBranch,
|
|
36
|
+
logger: output_1.default.warning,
|
|
37
|
+
});
|
|
38
|
+
applyCiAndCommitInfo(ctx, ciAndGitInfo);
|
|
39
|
+
output_1.default.normal(formattedCiInfo(ciAndGitInfo));
|
|
40
|
+
try {
|
|
41
|
+
const compressedStorybookDirectory = await createCompressedStorybookDirectory(currentDirectoryFiles);
|
|
42
|
+
const { message } = await sendStorybook(ctx, storybookSnapshots, compressedStorybookDirectory);
|
|
43
|
+
output_1.default.exitSuccess(message);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
output_1.default.exitError(`${error}`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
function getCurrentDirectoryFiles() {
|
|
50
|
+
const cwd = process.cwd();
|
|
51
|
+
const filesAndDirectories = (0, node_fs_1.readdirSync)(cwd, {
|
|
52
|
+
encoding: 'utf8',
|
|
53
|
+
recursive: true,
|
|
54
|
+
});
|
|
55
|
+
return filesAndDirectories.filter((file) => {
|
|
56
|
+
const elementPath = node_path_1.default.join(cwd, file);
|
|
57
|
+
const stats = (0, node_fs_1.statSync)(elementPath);
|
|
58
|
+
return stats.isFile();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async function createCompressedStorybookDirectory(files) {
|
|
62
|
+
const tar = require('tar-stream');
|
|
63
|
+
const cwd = process.cwd();
|
|
64
|
+
const chunks = [];
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const compressStream = (0, node_zlib_1.createBrotliCompress)({
|
|
67
|
+
params: {
|
|
68
|
+
[node_zlib_1.constants.BROTLI_PARAM_QUALITY]: 6,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
compressStream.on('data', (chunk) => {
|
|
72
|
+
chunks.push(chunk);
|
|
73
|
+
});
|
|
74
|
+
compressStream.on('end', () => {
|
|
75
|
+
resolve(Buffer.concat(chunks));
|
|
76
|
+
});
|
|
77
|
+
compressStream.on('error', reject);
|
|
78
|
+
const packStream = tar.pack();
|
|
79
|
+
packStream.pipe(compressStream);
|
|
80
|
+
let filesProcessed = 0;
|
|
81
|
+
for (const file of files) {
|
|
82
|
+
const filePath = node_path_1.default.join(cwd, file);
|
|
83
|
+
const stats = (0, node_fs_1.statSync)(filePath);
|
|
84
|
+
const entry = packStream.entry({
|
|
85
|
+
name: file,
|
|
86
|
+
size: stats.size,
|
|
87
|
+
}, (error) => {
|
|
88
|
+
if (error) {
|
|
89
|
+
reject(error);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
filesProcessed += 1;
|
|
93
|
+
if (filesProcessed === files.length) {
|
|
94
|
+
packStream.finalize();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const fileStream = (0, node_fs_1.createReadStream)(filePath);
|
|
99
|
+
fileStream.pipe(entry);
|
|
100
|
+
fileStream.on('error', reject);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function isStorybookDirectory(files) {
|
|
105
|
+
return (files.length > 0 &&
|
|
106
|
+
files.includes('index.html') &&
|
|
107
|
+
files.includes('iframe.html'));
|
|
108
|
+
}
|
|
109
|
+
function getStorybookStoriesIndex(files) {
|
|
110
|
+
const indexFiles = files.find((file) => file === 'index.json');
|
|
111
|
+
if (indexFiles) {
|
|
112
|
+
return indexFiles;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return output_1.default.exitError(texts_1.ERR_MISSING_STORYBOOK_INDEX_FILE);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function getStoriesList(storybookStoriesIndex) {
|
|
119
|
+
const storiesListFile = (0, node_fs_1.readFileSync)(storybookStoriesIndex);
|
|
120
|
+
try {
|
|
121
|
+
const json = JSON.parse(storiesListFile.toString());
|
|
122
|
+
if (![4, 5].includes(json.v)) {
|
|
123
|
+
output_1.default.exitError(texts_1.ERR_UNSUPPORTED_STORYBOOK);
|
|
124
|
+
}
|
|
125
|
+
return json;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
output_1.default.exitError(texts_1.ERR_PARSING_STORIES);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function getStorybookSnapshots(storiesList) {
|
|
132
|
+
const stories = Object.entries(storiesList.entries)
|
|
133
|
+
.filter(([, value]) => value.type === 'story')
|
|
134
|
+
.map(([key, value]) => ({
|
|
135
|
+
id: key,
|
|
136
|
+
name: `${value.title}/${value.name}`,
|
|
137
|
+
}));
|
|
138
|
+
output_1.default.normal((0, texts_1.TXT_STORIES_AMOUNT)(stories.length));
|
|
139
|
+
return stories;
|
|
140
|
+
}
|
|
141
|
+
exports.default = commandVisualUpload;
|
|
@@ -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 utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const setup_1 = __importDefault(require("./visual/setup"));
|
|
9
|
+
const upload_1 = __importDefault(require("./visual/upload"));
|
|
10
|
+
const session_1 = __importDefault(require("./visual/session"));
|
|
11
|
+
const link_1 = __importDefault(require("./visual/link"));
|
|
12
|
+
const commandVisual = (0, utils_1.newCommand)('visual', texts_1.DESC_COMMAND_VISUAL);
|
|
13
|
+
commandVisual.addCommand(setup_1.default);
|
|
14
|
+
commandVisual.addCommand(upload_1.default);
|
|
15
|
+
commandVisual.addCommand(session_1.default);
|
|
16
|
+
commandVisual.addCommand(link_1.default);
|
|
17
|
+
exports.default = commandVisual;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 unit_1 = __importDefault(require("./tests/unit"));
|
|
9
|
+
const visual_1 = __importDefault(require("./tests/visual"));
|
|
10
|
+
const capture_1 = __importDefault(require("./tests/capture"));
|
|
11
|
+
const commandTests = (0, utils_1.newCommand)('tests', texts_1.DESC_COMMAND_TESTS);
|
|
12
|
+
commandTests.addCommand(unit_1.default);
|
|
13
|
+
commandTests.addCommand(visual_1.default);
|
|
14
|
+
commandTests.addCommand(capture_1.default);
|
|
15
|
+
exports.default = commandTests;
|
|
@@ -30,6 +30,18 @@ commandWhoami.action(async () => {
|
|
|
30
30
|
if (localProject) {
|
|
31
31
|
output_1.default.normal(`Project: ${localProject}`);
|
|
32
32
|
}
|
|
33
|
+
const vtSuite = cfg_2.default.getVtSuite();
|
|
34
|
+
const utSuite = cfg_2.default.getUtSuite();
|
|
35
|
+
const crawlSuite = cfg_2.default.getCrawlSuite();
|
|
36
|
+
if (vtSuite) {
|
|
37
|
+
output_1.default.normal(`Visual test suite: ${vtSuite}`);
|
|
38
|
+
}
|
|
39
|
+
if (utSuite) {
|
|
40
|
+
output_1.default.normal(`Unit test suite: ${utSuite}`);
|
|
41
|
+
}
|
|
42
|
+
if (crawlSuite) {
|
|
43
|
+
output_1.default.normal(`Crawl suite: ${crawlSuite}`);
|
|
44
|
+
}
|
|
33
45
|
output_1.default.exitNormal();
|
|
34
46
|
});
|
|
35
47
|
exports.default = commandWhoami;
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
exports.sendCrawl = sendCrawl;
|
|
7
|
+
exports.downloadCrawlPackage = downloadCrawlPackage;
|
|
8
|
+
exports.connectToCrawlSession = connectToCrawlSession;
|
|
9
|
+
const context_1 = require("../visualTest/context");
|
|
10
|
+
const undici_1 = require("undici");
|
|
11
|
+
const output_1 = __importDefault(require("../output"));
|
|
12
|
+
const texts_1 = require("../texts");
|
|
13
|
+
const eventsource_1 = require("eventsource");
|
|
14
|
+
const customServiceUrl = process.env.BUDDY_CRAWL_SERVICE_URL;
|
|
15
|
+
function checkIfIsDevToken(token) {
|
|
16
|
+
const tokenParts = token.split('_');
|
|
17
|
+
return tokenParts.length === 5;
|
|
18
|
+
}
|
|
19
|
+
function getServiceUrl(token) {
|
|
20
|
+
if (customServiceUrl) {
|
|
21
|
+
return customServiceUrl;
|
|
22
|
+
}
|
|
23
|
+
const tokenParts = token.split('_');
|
|
24
|
+
const isDevToken = checkIfIsDevToken(token);
|
|
25
|
+
const devServiceUrl = Buffer.from(tokenParts[3], 'base64url').toString('utf-8');
|
|
26
|
+
if (isDevToken) {
|
|
27
|
+
if (devServiceUrl.includes('local.io')) {
|
|
28
|
+
throw new Error('Use BUDDY_CRAWL_SERVICE_URL to set the service URL in this environment');
|
|
29
|
+
}
|
|
30
|
+
return devServiceUrl;
|
|
31
|
+
}
|
|
32
|
+
if (token.startsWith('bud_crawl_eu')) {
|
|
33
|
+
return 'https://vt.eu.buddy.works';
|
|
34
|
+
}
|
|
35
|
+
if (token.startsWith('bud_crawl_asia')) {
|
|
36
|
+
return 'https://vt.asia.buddy.works';
|
|
37
|
+
}
|
|
38
|
+
return 'https://vt.buddy.works';
|
|
39
|
+
}
|
|
40
|
+
async function sendCrawl(ctx, url, follow, respectRobots, outputTypes, colorScheme, browsers, devices, cookies, requestHeaders, delays, waitForSelectors, localStorage) {
|
|
41
|
+
const payload = {
|
|
42
|
+
url,
|
|
43
|
+
follow,
|
|
44
|
+
respectRobots,
|
|
45
|
+
outputTypes,
|
|
46
|
+
colorScheme,
|
|
47
|
+
browsers,
|
|
48
|
+
devices,
|
|
49
|
+
cookies,
|
|
50
|
+
requestHeaders,
|
|
51
|
+
delays,
|
|
52
|
+
waitForSelectors,
|
|
53
|
+
localStorage,
|
|
54
|
+
pipelineId: ctx.pipelineId,
|
|
55
|
+
pipelineName: ctx.pipelineName,
|
|
56
|
+
executionId: ctx.executionId,
|
|
57
|
+
actionId: ctx.actionId,
|
|
58
|
+
invokerId: ctx.invokerId,
|
|
59
|
+
ci: ctx.ci,
|
|
60
|
+
executionUrl: ctx.executionUrl,
|
|
61
|
+
};
|
|
62
|
+
const [message, response] = await sendRequest({
|
|
63
|
+
path: '/crawl',
|
|
64
|
+
token: ctx.token,
|
|
65
|
+
payload,
|
|
66
|
+
});
|
|
67
|
+
if (message) {
|
|
68
|
+
throw new Error(message);
|
|
69
|
+
}
|
|
70
|
+
if (!response) {
|
|
71
|
+
throw new Error(texts_1.ERR_INVALID_CRAWL_RESPONSE);
|
|
72
|
+
}
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
async function downloadCrawlPackage(ctx, buildId) {
|
|
76
|
+
const [message, response] = await sendRequest({
|
|
77
|
+
path: '/download',
|
|
78
|
+
token: ctx.token,
|
|
79
|
+
payload: { token: ctx.token, buildId },
|
|
80
|
+
});
|
|
81
|
+
if (message) {
|
|
82
|
+
throw new Error(message);
|
|
83
|
+
}
|
|
84
|
+
if (!response) {
|
|
85
|
+
throw new Error(texts_1.ERR_INVALID_DOWNLOAD_RESPONSE);
|
|
86
|
+
}
|
|
87
|
+
return response;
|
|
88
|
+
}
|
|
89
|
+
function connectToCrawlSession(ctx, buildId) {
|
|
90
|
+
return new eventsource_1.EventSource(`${getServiceUrl(ctx.token)}/sse`, {
|
|
91
|
+
fetch: (url, options) => {
|
|
92
|
+
return (0, undici_1.fetch)(url, {
|
|
93
|
+
...options,
|
|
94
|
+
headers: {
|
|
95
|
+
...options?.headers,
|
|
96
|
+
'x-token': ctx.token,
|
|
97
|
+
'x-cli-version': context_1.cliVersion,
|
|
98
|
+
'x-build-id': buildId,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async function sendRequest({ path, token, payload, }) {
|
|
105
|
+
const fullUrl = new URL(path, getServiceUrl(token));
|
|
106
|
+
output_1.default.debug((0, texts_1.LOG_SENDING_REQUEST)(fullUrl.toString()));
|
|
107
|
+
const init = {
|
|
108
|
+
method: 'GET',
|
|
109
|
+
redirect: 'follow',
|
|
110
|
+
headers: {
|
|
111
|
+
'X-CLI-VERSION': context_1.cliVersion,
|
|
112
|
+
'X-TOKEN': token,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
if (payload) {
|
|
116
|
+
init.method = 'POST';
|
|
117
|
+
init.headers = {
|
|
118
|
+
'Content-Type': 'application/json',
|
|
119
|
+
'X-TOKEN': token,
|
|
120
|
+
'X-CLI-VERSION': context_1.cliVersion,
|
|
121
|
+
};
|
|
122
|
+
init.body = JSON.stringify(payload);
|
|
123
|
+
}
|
|
124
|
+
const response = await (0, undici_1.fetch)(fullUrl, init);
|
|
125
|
+
const contentType = response.headers.get('content-type');
|
|
126
|
+
if (contentType && contentType.includes('application/json')) {
|
|
127
|
+
try {
|
|
128
|
+
const json = (await response.json());
|
|
129
|
+
return [undefined, json];
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
throw new Error(texts_1.ERR_INVALID_JSON);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (contentType && contentType.includes('application/octet-stream')) {
|
|
136
|
+
const buffer = response.body;
|
|
137
|
+
return [undefined, buffer];
|
|
138
|
+
}
|
|
139
|
+
const text = await response.text();
|
|
140
|
+
return [text, undefined];
|
|
141
|
+
}
|
package/distTs/src/index.js
CHANGED
|
@@ -11,9 +11,8 @@ const pre_1 = __importDefault(require("./command/pre"));
|
|
|
11
11
|
const stream_1 = __importDefault(require("stream"));
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
13
|
const texts_1 = require("./texts");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const ut_1 = __importDefault(require("./command/ut"));
|
|
14
|
+
const crawl_1 = __importDefault(require("./command/crawl"));
|
|
15
|
+
const tests_1 = __importDefault(require("./command/tests"));
|
|
17
16
|
const tunnel_1 = __importDefault(require("./command/tunnel"));
|
|
18
17
|
const pipeline_1 = __importDefault(require("./command/pipeline"));
|
|
19
18
|
const sandbox_1 = __importDefault(require("./command/sandbox"));
|
|
@@ -41,9 +40,8 @@ program.addCommand(tunnel_1.default);
|
|
|
41
40
|
if (!(0, utils_1.isDocker)())
|
|
42
41
|
program.addCommand(agent_1.default);
|
|
43
42
|
program.addCommand(version_1.default);
|
|
44
|
-
program.addCommand(
|
|
45
|
-
program.addCommand(
|
|
46
|
-
program.addCommand(ut_1.default);
|
|
43
|
+
program.addCommand(crawl_1.default);
|
|
44
|
+
program.addCommand(tests_1.default);
|
|
47
45
|
program.addCommand(pipeline_1.default);
|
|
48
46
|
program.addCommand(package_1.default);
|
|
49
47
|
program.addCommand(sandbox_1.default);
|
package/distTs/src/input.js
CHANGED
|
@@ -743,6 +743,84 @@ class Input {
|
|
|
743
743
|
host: d.host,
|
|
744
744
|
};
|
|
745
745
|
}
|
|
746
|
+
static async resolveSuiteId(client, workspace, project, identifier, type) {
|
|
747
|
+
const paramKey = type === 'vt' ? 'visual_test_suite'
|
|
748
|
+
: type === 'crawl' ? 'crawl_suite'
|
|
749
|
+
: 'unit_test_suite';
|
|
750
|
+
const responseKey = type === 'vt' ? 'visual_test_suite_id'
|
|
751
|
+
: type === 'crawl' ? 'crawl_suite_id'
|
|
752
|
+
: 'unit_test_suite_id';
|
|
753
|
+
try {
|
|
754
|
+
const result = await client.resolveIdentifiers(workspace, {
|
|
755
|
+
project,
|
|
756
|
+
[paramKey]: identifier,
|
|
757
|
+
});
|
|
758
|
+
return result?.[responseKey] ? String(result[responseKey]) : null;
|
|
759
|
+
}
|
|
760
|
+
catch {
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
static async vtSuiteToken() {
|
|
765
|
+
const envToken = process.env.BUDDY_VT_TOKEN;
|
|
766
|
+
if (envToken)
|
|
767
|
+
return envToken;
|
|
768
|
+
const ProjectCfg = require('./project/cfg').default;
|
|
769
|
+
const suiteIdentifier = ProjectCfg.getVtSuite();
|
|
770
|
+
if (suiteIdentifier && (cfg_1.default.getApiToken() || process.env.BUDDY_TOKEN)) {
|
|
771
|
+
const workspace = Input.restApiWorkspace('', true);
|
|
772
|
+
const project = Input.restApiProject('', true);
|
|
773
|
+
if (workspace && project) {
|
|
774
|
+
const client = Input.restApiTokenClient();
|
|
775
|
+
const suiteId = await Input.resolveSuiteId(client, workspace, project, suiteIdentifier, 'vt');
|
|
776
|
+
if (!suiteId)
|
|
777
|
+
return '';
|
|
778
|
+
const result = await client.getVtSuiteToken(workspace, project, suiteId);
|
|
779
|
+
return String(result?.token || '');
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return '';
|
|
783
|
+
}
|
|
784
|
+
static async crawlSuiteToken() {
|
|
785
|
+
const envToken = process.env.BUDDY_CRAWL_TOKEN;
|
|
786
|
+
if (envToken)
|
|
787
|
+
return envToken;
|
|
788
|
+
const ProjectCfg = require('./project/cfg').default;
|
|
789
|
+
const suiteIdentifier = ProjectCfg.getCrawlSuite();
|
|
790
|
+
if (suiteIdentifier && (cfg_1.default.getApiToken() || process.env.BUDDY_TOKEN)) {
|
|
791
|
+
const workspace = Input.restApiWorkspace('', true);
|
|
792
|
+
const project = Input.restApiProject('', true);
|
|
793
|
+
if (workspace && project) {
|
|
794
|
+
const client = Input.restApiTokenClient();
|
|
795
|
+
const suiteId = await Input.resolveSuiteId(client, workspace, project, suiteIdentifier, 'crawl');
|
|
796
|
+
if (!suiteId)
|
|
797
|
+
return '';
|
|
798
|
+
const result = await client.getCrawlSuiteToken(workspace, project, suiteId);
|
|
799
|
+
return String(result?.token || '');
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return '';
|
|
803
|
+
}
|
|
804
|
+
static async utSuiteToken() {
|
|
805
|
+
const envToken = process.env.BUDDY_UT_TOKEN;
|
|
806
|
+
if (envToken)
|
|
807
|
+
return envToken;
|
|
808
|
+
const ProjectCfg = require('./project/cfg').default;
|
|
809
|
+
const suiteIdentifier = ProjectCfg.getUtSuite();
|
|
810
|
+
if (suiteIdentifier && (cfg_1.default.getApiToken() || process.env.BUDDY_TOKEN)) {
|
|
811
|
+
const workspace = Input.restApiWorkspace('', true);
|
|
812
|
+
const project = Input.restApiProject('', true);
|
|
813
|
+
if (workspace && project) {
|
|
814
|
+
const client = Input.restApiTokenClient();
|
|
815
|
+
const suiteId = await Input.resolveSuiteId(client, workspace, project, suiteIdentifier, 'ut');
|
|
816
|
+
if (!suiteId)
|
|
817
|
+
return '';
|
|
818
|
+
const result = await client.getUtSuiteToken(workspace, project, suiteId);
|
|
819
|
+
return String(result?.token || '');
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return '';
|
|
823
|
+
}
|
|
746
824
|
static keyCert(keyPath, certPath) {
|
|
747
825
|
let key;
|
|
748
826
|
let cert;
|