bdy 1.20.2-stage → 1.20.3-master
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 +0 -83
- package/distTs/src/command/login.js +6 -0
- package/distTs/src/command/whoami.js +0 -12
- package/distTs/src/index.js +6 -4
- package/distTs/src/input.js +20 -83
- package/distTs/src/project/cfg.js +0 -39
- package/distTs/src/texts.js +41 -67
- package/distTs/src/unitTest/requests.js +10 -23
- package/distTs/src/visualTest/context.js +31 -42
- package/distTs/src/visualTest/requests.js +139 -39
- package/distTs/src/visualTest/resources.js +38 -40
- package/distTs/src/visualTest/server.js +2 -2
- package/distTs/src/visualTest/snapshots.js +17 -18
- package/distTs/src/visualTest/validation.js +10 -2
- package/package.json +1 -1
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -241,72 +241,6 @@ class ApiClient {
|
|
|
241
241
|
parseResponseBody: true,
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
async getVtSuites(workspace, project) {
|
|
245
|
-
return await this.request({
|
|
246
|
-
method: 'GET',
|
|
247
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/visual-tests/suites`,
|
|
248
|
-
parseResponseBody: true,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
async getCrawlSuites(workspace, project) {
|
|
252
|
-
return await this.request({
|
|
253
|
-
method: 'GET',
|
|
254
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/crawl/suites`,
|
|
255
|
-
parseResponseBody: true,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
async getUtSuites(workspace, project) {
|
|
259
|
-
return await this.request({
|
|
260
|
-
method: 'GET',
|
|
261
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/unit-tests/suites`,
|
|
262
|
-
parseResponseBody: true,
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
async createVtSuite(workspace, project, body) {
|
|
266
|
-
return await this.request({
|
|
267
|
-
method: 'POST',
|
|
268
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/visual-tests/suites`,
|
|
269
|
-
body,
|
|
270
|
-
parseResponseBody: true,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
async createCrawlSuite(workspace, project, body) {
|
|
274
|
-
return await this.request({
|
|
275
|
-
method: 'POST',
|
|
276
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/crawl/suites`,
|
|
277
|
-
body,
|
|
278
|
-
parseResponseBody: true,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
async createUtSuite(workspace, project, body) {
|
|
282
|
-
return await this.request({
|
|
283
|
-
method: 'POST',
|
|
284
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/unit-tests/suites`,
|
|
285
|
-
body,
|
|
286
|
-
parseResponseBody: true,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
async getVtSuiteToken(workspace, project, suiteId) {
|
|
290
|
-
return await this.request({
|
|
291
|
-
method: 'GET',
|
|
292
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/visual-tests/suites/${encodeURIComponent(suiteId)}/token`,
|
|
293
|
-
parseResponseBody: true,
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
async getCrawlSuiteToken(workspace, project, suiteId) {
|
|
297
|
-
return await this.request({
|
|
298
|
-
method: 'GET',
|
|
299
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/crawl/suites/${encodeURIComponent(suiteId)}/token`,
|
|
300
|
-
parseResponseBody: true,
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
async getUtSuiteToken(workspace, project, suiteId) {
|
|
304
|
-
return await this.request({
|
|
305
|
-
method: 'GET',
|
|
306
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/unit-tests/suites/${encodeURIComponent(suiteId)}/token`,
|
|
307
|
-
parseResponseBody: true,
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
244
|
async getInvokerEmails() {
|
|
311
245
|
return await this.request({
|
|
312
246
|
method: 'GET',
|
|
@@ -754,23 +688,6 @@ class ApiClient {
|
|
|
754
688
|
parseResponseBody: true,
|
|
755
689
|
});
|
|
756
690
|
}
|
|
757
|
-
async resolveIdentifiers(workspace, params) {
|
|
758
|
-
let query = '';
|
|
759
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
760
|
-
if (value === undefined)
|
|
761
|
-
return;
|
|
762
|
-
if (!query)
|
|
763
|
-
query += '?';
|
|
764
|
-
else
|
|
765
|
-
query += '&';
|
|
766
|
-
query += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
|
767
|
-
});
|
|
768
|
-
return await this.request({
|
|
769
|
-
method: 'GET',
|
|
770
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/identifiers${query}`,
|
|
771
|
-
parseResponseBody: true,
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
691
|
async getPipelineByIdentifier(workspace, project, identifier) {
|
|
775
692
|
return await this.getResourceByIdentifier(workspace, {
|
|
776
693
|
project,
|
|
@@ -77,6 +77,12 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
77
77
|
};
|
|
78
78
|
const s = node_http_1.default.createServer(async (req, res) => {
|
|
79
79
|
res.setHeader('access-control-allow-origin', '*');
|
|
80
|
+
res.setHeader('access-control-allow-private-network', 'true');
|
|
81
|
+
if (req.method === 'OPTIONS') {
|
|
82
|
+
res.writeHead(204);
|
|
83
|
+
res.end();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
80
86
|
const url = new URL(req.url || '', `http://${OAUTH_CLIENT_APP_HOST}`);
|
|
81
87
|
const urlCode = url.searchParams.get('code');
|
|
82
88
|
const urlState = url.searchParams.get('state');
|
|
@@ -30,18 +30,6 @@ 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
|
-
}
|
|
45
33
|
output_1.default.exitNormal();
|
|
46
34
|
});
|
|
47
35
|
exports.default = commandWhoami;
|
package/distTs/src/index.js
CHANGED
|
@@ -11,8 +11,9 @@ 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
|
|
14
|
+
const vt_1 = __importDefault(require("./command/vt"));
|
|
15
|
+
const scrape_1 = __importDefault(require("./command/scrape"));
|
|
16
|
+
const ut_1 = __importDefault(require("./command/ut"));
|
|
16
17
|
const tunnel_1 = __importDefault(require("./command/tunnel"));
|
|
17
18
|
const pipeline_1 = __importDefault(require("./command/pipeline"));
|
|
18
19
|
const sandbox_1 = __importDefault(require("./command/sandbox"));
|
|
@@ -40,8 +41,9 @@ program.addCommand(tunnel_1.default);
|
|
|
40
41
|
if (!(0, utils_1.isDocker)())
|
|
41
42
|
program.addCommand(agent_1.default);
|
|
42
43
|
program.addCommand(version_1.default);
|
|
43
|
-
program.addCommand(
|
|
44
|
-
program.addCommand(
|
|
44
|
+
program.addCommand(vt_1.default);
|
|
45
|
+
program.addCommand(scrape_1.default);
|
|
46
|
+
program.addCommand(ut_1.default);
|
|
45
47
|
program.addCommand(pipeline_1.default);
|
|
46
48
|
program.addCommand(artifact_1.default);
|
|
47
49
|
program.addCommand(sandbox_1.default);
|
package/distTs/src/input.js
CHANGED
|
@@ -433,14 +433,29 @@ class Input {
|
|
|
433
433
|
}
|
|
434
434
|
static restApiBaseUrlFromToken(token) {
|
|
435
435
|
// bdy_sb_us_aHR0cHM6Ly9hcGkuc2Q1LmNvbQ_f92ml8f1p27nzo45806vczm6c78d0
|
|
436
|
+
// bdy_oa_us_bbxif8yup45555vo4cey4qvgfexrrk
|
|
436
437
|
const s = (token || '').split('_');
|
|
437
438
|
if (s.length > 1) {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
439
|
+
if (s.length === 5) {
|
|
440
|
+
const base = s[s.length - 2];
|
|
441
|
+
try {
|
|
442
|
+
return Buffer.from(base, 'base64').toString('utf8');
|
|
443
|
+
}
|
|
444
|
+
catch {
|
|
445
|
+
// do nothing
|
|
446
|
+
}
|
|
441
447
|
}
|
|
442
|
-
|
|
443
|
-
|
|
448
|
+
else if (s.length === 4) {
|
|
449
|
+
const region = s[2];
|
|
450
|
+
if (region === utils_1.REST_API_REGION.US) {
|
|
451
|
+
return utils_1.REST_API_ENDPOINT.US;
|
|
452
|
+
}
|
|
453
|
+
else if (region === utils_1.REST_API_REGION.EU) {
|
|
454
|
+
return utils_1.REST_API_ENDPOINT.EU;
|
|
455
|
+
}
|
|
456
|
+
else if (region === utils_1.REST_API_REGION.AS) {
|
|
457
|
+
return utils_1.REST_API_ENDPOINT.AS;
|
|
458
|
+
}
|
|
444
459
|
}
|
|
445
460
|
}
|
|
446
461
|
return null;
|
|
@@ -761,84 +776,6 @@ class Input {
|
|
|
761
776
|
host: d.host,
|
|
762
777
|
};
|
|
763
778
|
}
|
|
764
|
-
static async resolveSuiteId(client, workspace, project, identifier, type) {
|
|
765
|
-
const paramKey = type === 'vt' ? 'visual_test_suite'
|
|
766
|
-
: type === 'crawl' ? 'crawl_suite'
|
|
767
|
-
: 'unit_test_suite';
|
|
768
|
-
const responseKey = type === 'vt' ? 'visual_test_suite_id'
|
|
769
|
-
: type === 'crawl' ? 'crawl_suite_id'
|
|
770
|
-
: 'unit_test_suite_id';
|
|
771
|
-
try {
|
|
772
|
-
const result = await client.resolveIdentifiers(workspace, {
|
|
773
|
-
project,
|
|
774
|
-
[paramKey]: identifier,
|
|
775
|
-
});
|
|
776
|
-
return result?.[responseKey] ? String(result[responseKey]) : null;
|
|
777
|
-
}
|
|
778
|
-
catch {
|
|
779
|
-
return null;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
static async vtSuiteToken() {
|
|
783
|
-
const envToken = process.env.BUDDY_VT_TOKEN;
|
|
784
|
-
if (envToken)
|
|
785
|
-
return envToken;
|
|
786
|
-
const ProjectCfg = require('./project/cfg').default;
|
|
787
|
-
const suiteIdentifier = ProjectCfg.getVtSuite();
|
|
788
|
-
if (suiteIdentifier && (cfg_1.default.getApiToken() || process.env.BUDDY_TOKEN)) {
|
|
789
|
-
const workspace = Input.restApiWorkspace('', true);
|
|
790
|
-
const project = Input.restApiProject('', true);
|
|
791
|
-
if (workspace && project) {
|
|
792
|
-
const client = Input.restApiTokenClient();
|
|
793
|
-
const suiteId = await Input.resolveSuiteId(client, workspace, project, suiteIdentifier, 'vt');
|
|
794
|
-
if (!suiteId)
|
|
795
|
-
return '';
|
|
796
|
-
const result = await client.getVtSuiteToken(workspace, project, suiteId);
|
|
797
|
-
return String(result?.token || '');
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
return '';
|
|
801
|
-
}
|
|
802
|
-
static async crawlSuiteToken() {
|
|
803
|
-
const envToken = process.env.BUDDY_CRAWL_TOKEN;
|
|
804
|
-
if (envToken)
|
|
805
|
-
return envToken;
|
|
806
|
-
const ProjectCfg = require('./project/cfg').default;
|
|
807
|
-
const suiteIdentifier = ProjectCfg.getCrawlSuite();
|
|
808
|
-
if (suiteIdentifier && (cfg_1.default.getApiToken() || process.env.BUDDY_TOKEN)) {
|
|
809
|
-
const workspace = Input.restApiWorkspace('', true);
|
|
810
|
-
const project = Input.restApiProject('', true);
|
|
811
|
-
if (workspace && project) {
|
|
812
|
-
const client = Input.restApiTokenClient();
|
|
813
|
-
const suiteId = await Input.resolveSuiteId(client, workspace, project, suiteIdentifier, 'crawl');
|
|
814
|
-
if (!suiteId)
|
|
815
|
-
return '';
|
|
816
|
-
const result = await client.getCrawlSuiteToken(workspace, project, suiteId);
|
|
817
|
-
return String(result?.token || '');
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
return '';
|
|
821
|
-
}
|
|
822
|
-
static async utSuiteToken() {
|
|
823
|
-
const envToken = process.env.BUDDY_UT_TOKEN;
|
|
824
|
-
if (envToken)
|
|
825
|
-
return envToken;
|
|
826
|
-
const ProjectCfg = require('./project/cfg').default;
|
|
827
|
-
const suiteIdentifier = ProjectCfg.getUtSuite();
|
|
828
|
-
if (suiteIdentifier && (cfg_1.default.getApiToken() || process.env.BUDDY_TOKEN)) {
|
|
829
|
-
const workspace = Input.restApiWorkspace('', true);
|
|
830
|
-
const project = Input.restApiProject('', true);
|
|
831
|
-
if (workspace && project) {
|
|
832
|
-
const client = Input.restApiTokenClient();
|
|
833
|
-
const suiteId = await Input.resolveSuiteId(client, workspace, project, suiteIdentifier, 'ut');
|
|
834
|
-
if (!suiteId)
|
|
835
|
-
return '';
|
|
836
|
-
const result = await client.getUtSuiteToken(workspace, project, suiteId);
|
|
837
|
-
return String(result?.token || '');
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
return '';
|
|
841
|
-
}
|
|
842
779
|
static keyCert(keyPath, certPath) {
|
|
843
780
|
let key;
|
|
844
781
|
let cert;
|
|
@@ -24,9 +24,6 @@ class ProjectCfg {
|
|
|
24
24
|
get(path) {
|
|
25
25
|
let workspace = '';
|
|
26
26
|
let project = '';
|
|
27
|
-
let vtSuite = '';
|
|
28
|
-
let crawlSuite = '';
|
|
29
|
-
let utSuite = '';
|
|
30
27
|
try {
|
|
31
28
|
const str = node_fs_1.default.readFileSync(getFullPath(path), 'utf8');
|
|
32
29
|
const json = JSON.parse(str);
|
|
@@ -34,12 +31,6 @@ class ProjectCfg {
|
|
|
34
31
|
workspace = json.workspace;
|
|
35
32
|
if (json.project)
|
|
36
33
|
project = json.project;
|
|
37
|
-
if (json.vtSuite)
|
|
38
|
-
vtSuite = json.vtSuite;
|
|
39
|
-
if (json.crawlSuite)
|
|
40
|
-
crawlSuite = json.crawlSuite;
|
|
41
|
-
if (json.utSuite)
|
|
42
|
-
utSuite = json.utSuite;
|
|
43
34
|
}
|
|
44
35
|
catch {
|
|
45
36
|
// do nothing
|
|
@@ -47,26 +38,8 @@ class ProjectCfg {
|
|
|
47
38
|
return {
|
|
48
39
|
workspace,
|
|
49
40
|
project,
|
|
50
|
-
vtSuite,
|
|
51
|
-
crawlSuite,
|
|
52
|
-
utSuite,
|
|
53
41
|
};
|
|
54
42
|
}
|
|
55
|
-
setSuite(path, type, suiteIdentifier) {
|
|
56
|
-
const fullPath = getFullPath(path);
|
|
57
|
-
let json = {};
|
|
58
|
-
try {
|
|
59
|
-
const str = node_fs_1.default.readFileSync(fullPath, 'utf8');
|
|
60
|
-
json = JSON.parse(str);
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
// do nothing
|
|
64
|
-
}
|
|
65
|
-
const key = type === 'vt' ? 'vtSuite' : type === 'crawl' ? 'crawlSuite' : 'utSuite';
|
|
66
|
-
json[key] = suiteIdentifier;
|
|
67
|
-
node_fs_1.default.mkdirSync((0, node_path_1.dirname)(fullPath), { recursive: true });
|
|
68
|
-
node_fs_1.default.writeFileSync(fullPath, JSON.stringify(json), 'utf8');
|
|
69
|
-
}
|
|
70
43
|
getWorkspace() {
|
|
71
44
|
const c = this.get((0, utils_1.getWorkingDir)());
|
|
72
45
|
return c.workspace;
|
|
@@ -75,17 +48,5 @@ class ProjectCfg {
|
|
|
75
48
|
const c = this.get((0, utils_1.getWorkingDir)());
|
|
76
49
|
return c.project;
|
|
77
50
|
}
|
|
78
|
-
getVtSuite() {
|
|
79
|
-
const c = this.get((0, utils_1.getWorkingDir)());
|
|
80
|
-
return c.vtSuite;
|
|
81
|
-
}
|
|
82
|
-
getCrawlSuite() {
|
|
83
|
-
const c = this.get((0, utils_1.getWorkingDir)());
|
|
84
|
-
return c.crawlSuite;
|
|
85
|
-
}
|
|
86
|
-
getUtSuite() {
|
|
87
|
-
const c = this.get((0, utils_1.getWorkingDir)());
|
|
88
|
-
return c.utSuite;
|
|
89
|
-
}
|
|
90
51
|
}
|
|
91
52
|
exports.default = new ProjectCfg();
|