bdy 1.19.7-dev → 1.19.9-dev-pipeline
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 +103 -2
- 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/create.js +45 -0
- package/distTs/src/command/pipeline/get.js +42 -0
- package/distTs/src/command/pipeline/list.js +43 -0
- package/distTs/src/command/pipeline/run/apply.js +62 -0
- package/distTs/src/command/pipeline/run/approve.js +62 -0
- package/distTs/src/command/pipeline/run/cancel.js +36 -0
- package/distTs/src/command/pipeline/run/list.js +52 -0
- package/distTs/src/command/pipeline/run/logs.js +37 -0
- package/distTs/src/command/pipeline/run/retry.js +36 -0
- package/distTs/src/command/pipeline/run/start.js +96 -0
- package/distTs/src/command/pipeline/run/status.js +35 -0
- package/distTs/src/command/pipeline/run.js +22 -125
- package/distTs/src/command/pipeline/update.js +41 -0
- package/distTs/src/command/pipeline/yaml.js +38 -0
- package/distTs/src/command/pipeline.js +23 -0
- package/distTs/src/command/project/link.js +11 -11
- 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/crawl/requests.js +141 -0
- package/distTs/src/input.js +11 -10
- package/distTs/src/output/pipeline.js +1563 -0
- package/distTs/src/output.js +149 -31
- package/distTs/src/texts.js +84 -34
- package/distTs/src/tunnel/output/interactive/tunnel.js +2 -2
- 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/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,38 @@
|
|
|
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 input_1 = __importDefault(require("../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../output"));
|
|
10
|
+
const commandPipelineYaml = (0, utils_1.newCommand)('yaml', texts_1.DESC_COMMAND_PIPELINE_YAML);
|
|
11
|
+
commandPipelineYaml.hideVersionUpdate = true;
|
|
12
|
+
commandPipelineYaml.alias('yml');
|
|
13
|
+
commandPipelineYaml.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
+
commandPipelineYaml.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
|
+
commandPipelineYaml.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
16
|
+
commandPipelineYaml.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_YML}`);
|
|
17
|
+
commandPipelineYaml.action(async (identifier, options) => {
|
|
18
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
|
+
const project = input_1.default.restApiProject(options.project);
|
|
20
|
+
const client = input_1.default.restApiTokenClient();
|
|
21
|
+
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
22
|
+
if (!data || !data.domain) {
|
|
23
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
24
|
+
}
|
|
25
|
+
if (!data.project_identifier) {
|
|
26
|
+
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
27
|
+
}
|
|
28
|
+
if (!data.pipeline_id) {
|
|
29
|
+
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
30
|
+
}
|
|
31
|
+
const result = await client.getPipelineYml(workspace, project, data.pipeline_id);
|
|
32
|
+
let yml = '';
|
|
33
|
+
if (result.yaml) {
|
|
34
|
+
yml = Buffer.from(result.yaml, 'base64').toString('utf8');
|
|
35
|
+
}
|
|
36
|
+
output_1.default.exitNormal(yml);
|
|
37
|
+
});
|
|
38
|
+
exports.default = commandPipelineYaml;
|
|
@@ -6,7 +6,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
const texts_1 = require("../texts");
|
|
8
8
|
const run_1 = __importDefault(require("./pipeline/run"));
|
|
9
|
+
const list_1 = __importDefault(require("./pipeline/list"));
|
|
10
|
+
const get_1 = __importDefault(require("./pipeline/get"));
|
|
11
|
+
const yaml_1 = __importDefault(require("./pipeline/yaml"));
|
|
12
|
+
const create_1 = __importDefault(require("./pipeline/create"));
|
|
13
|
+
const update_1 = __importDefault(require("./pipeline/update"));
|
|
9
14
|
const commandPipeline = (0, utils_1.newCommand)('pipeline', texts_1.DESC_COMMAND_PIPELINE);
|
|
10
15
|
commandPipeline.alias('pip');
|
|
11
16
|
commandPipeline.addCommand(run_1.default);
|
|
17
|
+
commandPipeline.addCommand(list_1.default);
|
|
18
|
+
commandPipeline.addCommand(get_1.default);
|
|
19
|
+
commandPipeline.addCommand(yaml_1.default);
|
|
20
|
+
commandPipeline.addCommand(create_1.default);
|
|
21
|
+
commandPipeline.addCommand(update_1.default);
|
|
22
|
+
commandPipeline.addHelpText('after', `
|
|
23
|
+
EXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_START}
|
|
24
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_STATUS}
|
|
25
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_LOGS}
|
|
26
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_CANCEL}
|
|
27
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_RETRY}
|
|
28
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_APPLY}
|
|
29
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_LIST}
|
|
30
|
+
${texts_1.EXAMPLE_PIPELINE_LIST}
|
|
31
|
+
${texts_1.EXAMPLE_PIPELINE_GET}
|
|
32
|
+
${texts_1.EXAMPLE_PIPELINE_YML}
|
|
33
|
+
${texts_1.EXAMPLE_PIPELINE_CREATE}
|
|
34
|
+
${texts_1.EXAMPLE_PIPELINE_UPDATE}`);
|
|
12
35
|
exports.default = commandPipeline;
|
|
@@ -23,7 +23,7 @@ commandProjectLink.action(async (dir, options) => {
|
|
|
23
23
|
ProjectCfg.init(path, workspace, project);
|
|
24
24
|
output_1.default.okSign();
|
|
25
25
|
output_1.default.normal(texts_1.TXT_COMMAND_PROJECT_LINK_TO, false);
|
|
26
|
-
output_1.default.
|
|
26
|
+
output_1.default.cyan(` ${url}`);
|
|
27
27
|
await initRepo(workspace, project, path, git, options);
|
|
28
28
|
tryNow();
|
|
29
29
|
output_1.default.exitNormal();
|
|
@@ -54,13 +54,13 @@ const tryNow = () => {
|
|
|
54
54
|
output_1.default.arrowSign();
|
|
55
55
|
output_1.default.label(texts_1.OPT_COMMAND_PROJECT_LINK_TRY_NOW);
|
|
56
56
|
output_1.default.dim('$ ', false);
|
|
57
|
-
output_1.default.
|
|
57
|
+
output_1.default.cyan('bdy tunnel http 3000 ', false);
|
|
58
58
|
output_1.default.muted(' Expose localhost:3000 to the internet');
|
|
59
59
|
output_1.default.dim('$ ', false);
|
|
60
|
-
output_1.default.
|
|
60
|
+
output_1.default.cyan('bdy artifact publish . ', false);
|
|
61
61
|
output_1.default.muted(' Publish an artifact from the current project');
|
|
62
62
|
output_1.default.dim('$ ', false);
|
|
63
|
-
output_1.default.
|
|
63
|
+
output_1.default.cyan('bdy sandbox create --run "npm start" ', false);
|
|
64
64
|
output_1.default.muted(' Spin up a cloud sandbox and run your app');
|
|
65
65
|
};
|
|
66
66
|
const initRepo = async (workspace, project, path, git, options) => {
|
|
@@ -89,16 +89,16 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
89
89
|
});
|
|
90
90
|
output_1.default.okSign();
|
|
91
91
|
output_1.default.normal('Remote ', false);
|
|
92
|
-
output_1.default.
|
|
92
|
+
output_1.default.cyan('origin ', false);
|
|
93
93
|
output_1.default.normal('set to ', false);
|
|
94
|
-
output_1.default.
|
|
94
|
+
output_1.default.cyan(remote);
|
|
95
95
|
}
|
|
96
96
|
else if (remotes.origin !== remote) {
|
|
97
97
|
output_1.default.yellow(texts_1.OPT_COMMAND_PROJECT_LINK_HAS_REMOTE);
|
|
98
98
|
output_1.default.normal('Current origin: ', false);
|
|
99
|
-
output_1.default.
|
|
99
|
+
output_1.default.cyan(remotes.origin);
|
|
100
100
|
output_1.default.normal('Buddy project: ', false);
|
|
101
|
-
output_1.default.
|
|
101
|
+
output_1.default.cyan(remote);
|
|
102
102
|
const opt = await output_1.default.inputMenuAdv(texts_1.OPT_COMMAND_PROJECT_LINK_SET_GIT_REMOTE, [
|
|
103
103
|
{
|
|
104
104
|
name: 'Add buddy remote',
|
|
@@ -127,9 +127,9 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
127
127
|
});
|
|
128
128
|
output_1.default.okSign();
|
|
129
129
|
output_1.default.normal('Remote ', false);
|
|
130
|
-
output_1.default.
|
|
130
|
+
output_1.default.cyan('buddy ', false);
|
|
131
131
|
output_1.default.normal('set to ', false);
|
|
132
|
-
output_1.default.
|
|
132
|
+
output_1.default.cyan(remote);
|
|
133
133
|
}
|
|
134
134
|
else if (opt === 'origin') {
|
|
135
135
|
await (0, utils_1.execLocally)(`git remote rm origin`, {
|
|
@@ -140,7 +140,7 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
140
140
|
});
|
|
141
141
|
output_1.default.okSign();
|
|
142
142
|
output_1.default.normal('Origin replaced with ', false);
|
|
143
|
-
output_1.default.
|
|
143
|
+
output_1.default.cyan(remote);
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
146
|
return;
|
|
@@ -0,0 +1,46 @@
|
|
|
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.validateOptions = validateOptions;
|
|
7
|
+
exports.checkIfMinimalOptionsAreProvided = checkIfMinimalOptionsAreProvided;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const validation_1 = require("../visual/shared/validation");
|
|
11
|
+
const optionsSchema = zod_1.z.object({
|
|
12
|
+
urls: zod_1.z.string().optional(),
|
|
13
|
+
sitemap: zod_1.z.string().optional(),
|
|
14
|
+
urlsFile: zod_1.z.string().optional(),
|
|
15
|
+
follow: zod_1.z.boolean(),
|
|
16
|
+
respectRobots: zod_1.z.boolean(),
|
|
17
|
+
ignore: zod_1.z
|
|
18
|
+
.array(zod_1.z.string().regex(/^(?:([^:]+)::)?(?:(CSS|XPATH))=(.+)$/, {
|
|
19
|
+
message: "Ignore option must follow pattern '[scope::]type=value' where type must be CSS or XPATH (scope is optional)",
|
|
20
|
+
}))
|
|
21
|
+
.optional()
|
|
22
|
+
.transform(validation_1.parseScopedSelector),
|
|
23
|
+
cookie: validation_1.cookieSchema,
|
|
24
|
+
header: validation_1.headerSchema,
|
|
25
|
+
delay: validation_1.delaySchema,
|
|
26
|
+
waitFor: validation_1.waitForSchema,
|
|
27
|
+
ignoreUrls: zod_1.z.array(zod_1.z.string()).optional(),
|
|
28
|
+
dryRun: zod_1.z.boolean().optional(),
|
|
29
|
+
});
|
|
30
|
+
function validateOptions(options) {
|
|
31
|
+
try {
|
|
32
|
+
const validatedOptions = optionsSchema.parse(options);
|
|
33
|
+
return validatedOptions;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error instanceof zod_1.ZodError) {
|
|
37
|
+
output_1.default.exitError(error.errors.map((e) => e.message).join(', '));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function checkIfMinimalOptionsAreProvided(options) {
|
|
45
|
+
return !!options.urls || !!options.sitemap || !!options.urlsFile;
|
|
46
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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 commandCapture = (0, utils_1.newCommand)('capture', texts_1.DESC_COMMAND_CAPTURE);
|
|
11
|
+
commandCapture.option('--urls <urls>', texts_1.OPTION_COMPARE_URLS);
|
|
12
|
+
commandCapture.option('--sitemap <sitemap>', texts_1.OPTION_COMPARE_SITEMAP);
|
|
13
|
+
commandCapture.option('--urlsFile <urlsFile>', texts_1.OPTION_COMPARE_URLS_FILE);
|
|
14
|
+
commandCapture.option('--dryRun', texts_1.OPTION_COMPARE_DRY_RUN);
|
|
15
|
+
commandCapture.option('--follow', texts_1.OPTION_COMPARE_FOLLOW, false);
|
|
16
|
+
commandCapture.option('--respectRobots', texts_1.OPTION_COMPARE_RESPECT_ROBOTS, false);
|
|
17
|
+
commandCapture.option('--ignoreUrls <ignoreUrls...>', texts_1.OPTION_COMPARE_IGNORE_URLS);
|
|
18
|
+
commandCapture.option('--ignore <ignores...>', texts_1.OPTION_COMPARE_IGNORE);
|
|
19
|
+
commandCapture.option('--cookie <cookies...>', texts_1.OPTION_COMPARE_COOKIE);
|
|
20
|
+
commandCapture.option('--header <headers...>', texts_1.OPTION_COMPARE_HEADER);
|
|
21
|
+
commandCapture.option('--delay <delays...>', texts_1.OPTION_COMPARE_DELAY);
|
|
22
|
+
commandCapture.option('--waitFor <waitFors...>', texts_1.OPTION_COMPARE_WAIT_FOR);
|
|
23
|
+
commandCapture.action(async (options) => {
|
|
24
|
+
const { getCiAndGitInfo, formattedCiInfo } = require('@buddy-works/ci-info');
|
|
25
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
26
|
+
const { sendCompareLinks } = require('../../visualTest/requests');
|
|
27
|
+
const { checkIfMinimalOptionsAreProvided, validateOptions } = require('./capture/validation');
|
|
28
|
+
const { createVtContext, applyToken, applyCiAndCommitInfo } = require('../../visualTest/context');
|
|
29
|
+
const validatedOptions = validateOptions(options);
|
|
30
|
+
const Input = require('../../input').default;
|
|
31
|
+
const token = await Input.vtSuiteToken();
|
|
32
|
+
if (!token) {
|
|
33
|
+
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
34
|
+
}
|
|
35
|
+
const ctx = createVtContext();
|
|
36
|
+
applyToken(ctx, token);
|
|
37
|
+
if (!checkIfMinimalOptionsAreProvided(validatedOptions)) {
|
|
38
|
+
output_1.default.exitError(texts_1.ERR_MISSING_URLS);
|
|
39
|
+
}
|
|
40
|
+
let urls = [];
|
|
41
|
+
let sitemapSource;
|
|
42
|
+
if (validatedOptions.urls) {
|
|
43
|
+
const urlsList = getUrlsFromUrlOption(validatedOptions.urls);
|
|
44
|
+
urls = urls.concat(urlsList);
|
|
45
|
+
}
|
|
46
|
+
if (validatedOptions.urlsFile) {
|
|
47
|
+
const urlsList = getUrlsFromUrlFile(validatedOptions.urlsFile);
|
|
48
|
+
urls = urls.concat(urlsList);
|
|
49
|
+
}
|
|
50
|
+
if (validatedOptions.sitemap) {
|
|
51
|
+
sitemapSource = addProtocolIfMissing(validatedOptions.sitemap);
|
|
52
|
+
}
|
|
53
|
+
const { filteredUrls, duplicates } = filterDuplicates(urls);
|
|
54
|
+
if (duplicates.length > 0) {
|
|
55
|
+
output_1.default.normal(`Detected ${duplicates.length} duplicated urls:`);
|
|
56
|
+
output_1.default.normal(duplicates.join('\n'));
|
|
57
|
+
}
|
|
58
|
+
if (validatedOptions.dryRun) {
|
|
59
|
+
output_1.default.exitSuccess(`List of urls:\n${filteredUrls.join('\n')}`);
|
|
60
|
+
}
|
|
61
|
+
else if (filteredUrls.length > 1) {
|
|
62
|
+
output_1.default.normal(`List of urls:\n${filteredUrls.join('\n')}`);
|
|
63
|
+
}
|
|
64
|
+
const ciAndGitInfo = await getCiAndGitInfo({});
|
|
65
|
+
output_1.default.normal(formattedCiInfo(ciAndGitInfo));
|
|
66
|
+
applyCiAndCommitInfo(ctx, ciAndGitInfo);
|
|
67
|
+
try {
|
|
68
|
+
const { message } = await sendCompareLinks(ctx, filteredUrls, validatedOptions, sitemapSource);
|
|
69
|
+
output_1.default.exitSuccess(message);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
output_1.default.exitError(`${error}`);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
function getUrlsFromUrlOption(urls) {
|
|
76
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
77
|
+
return urls.split(',').map((url) => addProtocolIfMissing(url).trim());
|
|
78
|
+
}
|
|
79
|
+
function getUrlsFromUrlFile(urlsFile) {
|
|
80
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
81
|
+
const urlsFromFile = (0, node_fs_1.readFileSync)(urlsFile, 'utf-8');
|
|
82
|
+
return urlsFromFile
|
|
83
|
+
.split('\n')
|
|
84
|
+
.filter((url) => url.trim().length > 0)
|
|
85
|
+
.map((url) => addProtocolIfMissing(url).trim());
|
|
86
|
+
}
|
|
87
|
+
function filterDuplicates(urls) {
|
|
88
|
+
const seen = new Set();
|
|
89
|
+
const duplicates = new Set();
|
|
90
|
+
for (const url of urls) {
|
|
91
|
+
if (seen.has(url)) {
|
|
92
|
+
duplicates.add(url);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
seen.add(url);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
filteredUrls: Array.from(seen),
|
|
100
|
+
duplicates: Array.from(duplicates),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
exports.default = commandCapture;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 commandUtLink = (0, utils_1.newCommand)('link', texts_1.DESC_COMMAND_UT_LINK);
|
|
10
|
+
commandUtLink.option('-w, --workspace <workspace>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
11
|
+
commandUtLink.option('-p, --project <project>', texts_1.OPTION_REST_API_PROJECT);
|
|
12
|
+
commandUtLink.option('-s, --suite <suite>', texts_1.OPTION_SUITE_IDENTIFIER);
|
|
13
|
+
commandUtLink.action(async (options) => {
|
|
14
|
+
const Input = require('../../../input').default;
|
|
15
|
+
const ProjectCfg = require('../../../project/cfg').default;
|
|
16
|
+
output_1.default.handleSignals();
|
|
17
|
+
const workspace = Input.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = Input.restApiProject(options.project);
|
|
19
|
+
const client = Input.restApiTokenClient(false, options.api, options.region);
|
|
20
|
+
let suiteIdentifier = options.suite;
|
|
21
|
+
if (!suiteIdentifier) {
|
|
22
|
+
const opt = await output_1.default.inputMenuAdv(texts_1.TXT_COMMAND_SUITE_SELECT, [
|
|
23
|
+
{
|
|
24
|
+
name: texts_1.TXT_COMMAND_SUITE_CREATE_NEW,
|
|
25
|
+
description: texts_1.TXT_COMMAND_SUITE_CREATE_NEW_UT_DESC,
|
|
26
|
+
value: 'new',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: texts_1.TXT_COMMAND_SUITE_LINK_EXISTING,
|
|
30
|
+
description: texts_1.TXT_COMMAND_SUITE_LINK_EXISTING_DESC,
|
|
31
|
+
value: 'existing',
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
34
|
+
if (opt === 'new') {
|
|
35
|
+
const name = await output_1.default.inputString(texts_1.TXT_COMMAND_SUITE_NAME);
|
|
36
|
+
const response = await client.createUtSuite(workspace, project, { name, identifier: name });
|
|
37
|
+
output_1.default.okSign();
|
|
38
|
+
output_1.default.normal(texts_1.TXT_COMMAND_SUITE_CREATED);
|
|
39
|
+
suiteIdentifier = response.identifier;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const result = await client.getUtSuites(workspace, project);
|
|
43
|
+
const suites = result?.suites || [];
|
|
44
|
+
if (!suites.length) {
|
|
45
|
+
output_1.default.exitError(texts_1.ERR_NO_UT_SUITES);
|
|
46
|
+
}
|
|
47
|
+
if (suites.length === 1) {
|
|
48
|
+
suiteIdentifier = suites[0].identifier;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const items = suites.map((s) => s.name || s.identifier);
|
|
52
|
+
const index = await output_1.default.inputMenu(texts_1.TXT_COMMAND_UT_LINK_SELECT, items);
|
|
53
|
+
suiteIdentifier = suites[index].identifier;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
ProjectCfg.setSuite((0, utils_1.getWorkingDir)(), 'ut', suiteIdentifier);
|
|
58
|
+
output_1.default.okSign();
|
|
59
|
+
output_1.default.exitSuccess(texts_1.TXT_COMMAND_UT_LINK_SUCCESS);
|
|
60
|
+
});
|
|
61
|
+
exports.default = commandUtLink;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 commander_1 = require("commander");
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const commandUtUpload = (0, utils_1.newCommand)('upload', texts_1.DESC_COMMAND_UT_UPLOAD);
|
|
12
|
+
commandUtUpload.argument('<glob>', texts_1.OPTION_UPLOAD_REPORT_GLOB);
|
|
13
|
+
commandUtUpload.addOption(new commander_1.Option('--format <format>', texts_1.OPTION_UPLOAD_REPORT_FORMAT)
|
|
14
|
+
.choices(['junit-xml'])
|
|
15
|
+
.makeOptionMandatory());
|
|
16
|
+
commandUtUpload.option('--dryRun', texts_1.OPTION_UPLOAD_DRY_RUN);
|
|
17
|
+
commandUtUpload.action(async (input, options) => {
|
|
18
|
+
const { getCiInfo } = require('../../../unitTest/ci');
|
|
19
|
+
const { sendUploadRequest } = require('../../../unitTest/requests');
|
|
20
|
+
const { createUtContext, applyUtToken, applyUtCiInfo } = require('../../../unitTest/context');
|
|
21
|
+
const Input = require('../../../input').default;
|
|
22
|
+
const ctx = createUtContext();
|
|
23
|
+
const token = await Input.utSuiteToken();
|
|
24
|
+
if (!token) {
|
|
25
|
+
output_1.default.exitError(texts_1.ERR_MISSING_UT_TOKEN);
|
|
26
|
+
}
|
|
27
|
+
applyUtToken(ctx, token);
|
|
28
|
+
const { glob, dryRun } = validateInputAndOptions(input, options);
|
|
29
|
+
const ciInfo = await getCiInfo();
|
|
30
|
+
applyUtCiInfo(ctx, ciInfo);
|
|
31
|
+
const { absolutePattern, files } = findFilesByGlob(glob);
|
|
32
|
+
if (files.length === 0) {
|
|
33
|
+
output_1.default.exitError(`No files matched the provided glob: ${absolutePattern}`);
|
|
34
|
+
}
|
|
35
|
+
if (dryRun) {
|
|
36
|
+
output_1.default.normal(`Found ${files.length} report file(s) using pattern: ${absolutePattern}`);
|
|
37
|
+
files.forEach((file) => {
|
|
38
|
+
output_1.default.normal(file);
|
|
39
|
+
});
|
|
40
|
+
output_1.default.exitSuccess('Dry run completed');
|
|
41
|
+
}
|
|
42
|
+
await sendUploadRequest(ctx, files);
|
|
43
|
+
output_1.default.exitSuccess('Upload completed');
|
|
44
|
+
});
|
|
45
|
+
exports.default = commandUtUpload;
|
|
46
|
+
function validateInputAndOptions(input, options) {
|
|
47
|
+
const z = require('zod');
|
|
48
|
+
const { ZodError } = require('zod');
|
|
49
|
+
const globSchema = z.string();
|
|
50
|
+
const optionsSchema = z.object({
|
|
51
|
+
format: z.enum(['junit-xml']),
|
|
52
|
+
dryRun: z.boolean().optional(),
|
|
53
|
+
});
|
|
54
|
+
try {
|
|
55
|
+
const glob = globSchema.parse(input);
|
|
56
|
+
const { format, dryRun } = optionsSchema.parse(options);
|
|
57
|
+
return {
|
|
58
|
+
glob,
|
|
59
|
+
format,
|
|
60
|
+
dryRun,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error instanceof ZodError) {
|
|
65
|
+
output_1.default.exitError(error.errors.map((e) => `${e.path}: ${e.message}`).join(', '));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function findFilesByGlob(pattern) {
|
|
73
|
+
const { fdir } = require('fdir');
|
|
74
|
+
const picomatch = require('picomatch');
|
|
75
|
+
const cwd = process.cwd();
|
|
76
|
+
const scan = picomatch.scan(pattern);
|
|
77
|
+
if (!scan.isGlob) {
|
|
78
|
+
return {
|
|
79
|
+
absolutePattern: pattern,
|
|
80
|
+
files: (0, utils_1.isFile)(pattern) ? [pattern] : [],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (node_path_1.default.isAbsolute(pattern)) {
|
|
84
|
+
const root = scan.base;
|
|
85
|
+
const files = new fdir().withFullPaths().glob(pattern).crawl(root).sync();
|
|
86
|
+
return { absolutePattern: pattern, files };
|
|
87
|
+
}
|
|
88
|
+
const preparedPattern = node_path_1.default.resolve(cwd, pattern);
|
|
89
|
+
const files = new fdir().withFullPaths().glob(preparedPattern).crawl().sync();
|
|
90
|
+
return { absolutePattern: preparedPattern, files };
|
|
91
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 upload_1 = __importDefault(require("./unit/upload"));
|
|
9
|
+
const link_1 = __importDefault(require("./unit/link"));
|
|
10
|
+
const commandUnit = (0, utils_1.newCommand)('unit', texts_1.DESC_COMMAND_UNIT);
|
|
11
|
+
commandUnit.addCommand(upload_1.default);
|
|
12
|
+
commandUnit.addCommand(link_1.default);
|
|
13
|
+
exports.default = commandUnit;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 commandVisualLink = (0, utils_1.newCommand)('link', texts_1.DESC_COMMAND_VT_LINK);
|
|
10
|
+
commandVisualLink.option('-w, --workspace <workspace>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
11
|
+
commandVisualLink.option('-p, --project <project>', texts_1.OPTION_REST_API_PROJECT);
|
|
12
|
+
commandVisualLink.option('-s, --suite <suite>', texts_1.OPTION_SUITE_IDENTIFIER);
|
|
13
|
+
commandVisualLink.action(async (options) => {
|
|
14
|
+
const Input = require('../../../input').default;
|
|
15
|
+
const ProjectCfg = require('../../../project/cfg').default;
|
|
16
|
+
output_1.default.handleSignals();
|
|
17
|
+
const workspace = Input.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = Input.restApiProject(options.project);
|
|
19
|
+
const client = Input.restApiTokenClient(false, options.api, options.region);
|
|
20
|
+
let suiteIdentifier = options.suite;
|
|
21
|
+
if (!suiteIdentifier) {
|
|
22
|
+
const opt = await output_1.default.inputMenuAdv(texts_1.TXT_COMMAND_SUITE_SELECT, [
|
|
23
|
+
{
|
|
24
|
+
name: texts_1.TXT_COMMAND_SUITE_CREATE_NEW,
|
|
25
|
+
description: texts_1.TXT_COMMAND_SUITE_CREATE_NEW_VT_DESC,
|
|
26
|
+
value: 'new',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: texts_1.TXT_COMMAND_SUITE_LINK_EXISTING,
|
|
30
|
+
description: texts_1.TXT_COMMAND_SUITE_LINK_EXISTING_DESC,
|
|
31
|
+
value: 'existing',
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
34
|
+
if (opt === 'new') {
|
|
35
|
+
const name = await output_1.default.inputString(texts_1.TXT_COMMAND_SUITE_NAME);
|
|
36
|
+
const response = await client.createVtSuite(workspace, project, { name, identifier: name });
|
|
37
|
+
output_1.default.okSign();
|
|
38
|
+
output_1.default.normal(texts_1.TXT_COMMAND_SUITE_CREATED);
|
|
39
|
+
suiteIdentifier = response.identifier;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const result = await client.getVtSuites(workspace, project);
|
|
43
|
+
const suites = result?.suites || [];
|
|
44
|
+
if (!suites.length) {
|
|
45
|
+
output_1.default.exitError(texts_1.ERR_NO_VT_SUITES);
|
|
46
|
+
}
|
|
47
|
+
if (suites.length === 1) {
|
|
48
|
+
suiteIdentifier = suites[0].identifier;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const items = suites.map((s) => s.name || s.identifier);
|
|
52
|
+
const index = await output_1.default.inputMenu(texts_1.TXT_COMMAND_VT_LINK_SELECT, items);
|
|
53
|
+
suiteIdentifier = suites[index].identifier;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
ProjectCfg.setSuite((0, utils_1.getWorkingDir)(), 'vt', suiteIdentifier);
|
|
58
|
+
output_1.default.okSign();
|
|
59
|
+
output_1.default.exitSuccess(texts_1.TXT_COMMAND_VT_LINK_SUCCESS);
|
|
60
|
+
});
|
|
61
|
+
exports.default = commandVisualLink;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 commandSessionClose = (0, utils_1.newCommand)('close', texts_1.DESC_COMMAND_SESSION_CLOSE);
|
|
10
|
+
commandSessionClose.action(async () => {
|
|
11
|
+
const { checkBuildId } = require('../../../../visualTest/validation');
|
|
12
|
+
const { closeSession } = require('../../../../visualTest/requests');
|
|
13
|
+
const { createVtContext, applyToken } = require('../../../../visualTest/context');
|
|
14
|
+
const Input = require('../../../../input').default;
|
|
15
|
+
const token = await Input.vtSuiteToken();
|
|
16
|
+
if (!token) {
|
|
17
|
+
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
18
|
+
}
|
|
19
|
+
if (!checkBuildId()) {
|
|
20
|
+
output_1.default.exitError(texts_1.ERR_MISSING_BUILD_ID);
|
|
21
|
+
}
|
|
22
|
+
const ctx = createVtContext();
|
|
23
|
+
applyToken(ctx, token);
|
|
24
|
+
try {
|
|
25
|
+
const { message } = await closeSession(ctx);
|
|
26
|
+
output_1.default.exitNormal(message);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
output_1.default.exitError(`${error}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
exports.default = commandSessionClose;
|
|
@@ -0,0 +1,86 @@
|
|
|
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 commandSessionCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_SESSION_CREATE);
|
|
10
|
+
commandSessionCreate.argument('<command>', texts_1.OPTION_EXEC_COMMAND);
|
|
11
|
+
commandSessionCreate.option('--skipDiscovery', texts_1.OPTION_EXEC_SKIP_DISCOVERY);
|
|
12
|
+
commandSessionCreate.option('--oneByOne', texts_1.OPTION_EXEC_ONE_BY_ONE);
|
|
13
|
+
commandSessionCreate.option('--parallel', texts_1.OPTION_EXEC_PARALLEL);
|
|
14
|
+
commandSessionCreate.action(async (command, options) => {
|
|
15
|
+
const which = require('which');
|
|
16
|
+
const { getCiAndGitInfo, formattedCiInfo } = require('@buddy-works/ci-info');
|
|
17
|
+
const { checkParallel } = require('../../../../visualTest/validation');
|
|
18
|
+
const { getDefaultSettings } = require('../../../../visualTest/requests');
|
|
19
|
+
const { debug, createVtContext, applyExecOptions, applyCiAndCommitInfo, applyToken } = require('../../../../visualTest/context');
|
|
20
|
+
const { createServer } = require('../../../../visualTest/server');
|
|
21
|
+
const { finishProcessingSnapshots, setDefaultSettings, showSessionLink } = require('../../../../visualTest/snapshots');
|
|
22
|
+
const { testExec } = require('../../../../visualTest/exec');
|
|
23
|
+
const { getBrowserPath } = require('../../../../visualTest/browser');
|
|
24
|
+
const Input = require('../../../../input').default;
|
|
25
|
+
const ctx = createVtContext();
|
|
26
|
+
applyExecOptions(ctx, options);
|
|
27
|
+
try {
|
|
28
|
+
const browserPath = await getBrowserPath();
|
|
29
|
+
ctx.browserPath = browserPath;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
output_1.default.exitError(`${error}`);
|
|
33
|
+
}
|
|
34
|
+
const token = await Input.vtSuiteToken();
|
|
35
|
+
if (!token) {
|
|
36
|
+
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
37
|
+
}
|
|
38
|
+
applyToken(ctx, token);
|
|
39
|
+
if (!checkParallel(ctx)) {
|
|
40
|
+
output_1.default.exitError(texts_1.ERR_MISSING_BUILD_ID);
|
|
41
|
+
}
|
|
42
|
+
const app = await createServer(ctx);
|
|
43
|
+
const [mainCommand, ...mainCommandArguments] = command.split(' ');
|
|
44
|
+
output_1.default.normal((0, texts_1.LOG_RUNNING_EXEC_COMMAND)(`${mainCommand} ${[...mainCommandArguments].join(' ')}`));
|
|
45
|
+
const resolved = await which(mainCommand, { nothrow: true });
|
|
46
|
+
if (!resolved) {
|
|
47
|
+
output_1.default.exitError((0, texts_1.ERR_MISSING_EXEC_COMMAND)(`${mainCommand} ${[...mainCommandArguments].join(' ')}`));
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
let t1, t11;
|
|
51
|
+
if (debug) {
|
|
52
|
+
t1 = performance.now();
|
|
53
|
+
}
|
|
54
|
+
const defaultSettings = await getDefaultSettings(ctx);
|
|
55
|
+
setDefaultSettings(defaultSettings);
|
|
56
|
+
const ciAndGitInfo = await getCiAndGitInfo({
|
|
57
|
+
baseBranch: defaultSettings.baseBranch,
|
|
58
|
+
logger: output_1.default.warning,
|
|
59
|
+
});
|
|
60
|
+
applyCiAndCommitInfo(ctx, ciAndGitInfo);
|
|
61
|
+
output_1.default.normal(formattedCiInfo(ciAndGitInfo));
|
|
62
|
+
if (debug) {
|
|
63
|
+
t11 = performance.now();
|
|
64
|
+
}
|
|
65
|
+
const spawnedProcessExitCode = await testExec(mainCommand, [
|
|
66
|
+
...mainCommandArguments,
|
|
67
|
+
]);
|
|
68
|
+
if (debug && t11) {
|
|
69
|
+
const t22 = performance.now();
|
|
70
|
+
output_1.default.normal((0, texts_1.DEBUG_EXEC_TEST_COMMAND)(t22 - t11));
|
|
71
|
+
}
|
|
72
|
+
await app.close();
|
|
73
|
+
await finishProcessingSnapshots(ctx, spawnedProcessExitCode);
|
|
74
|
+
showSessionLink();
|
|
75
|
+
if (debug && t1) {
|
|
76
|
+
const t2 = performance.now();
|
|
77
|
+
output_1.default.normal((0, texts_1.DEBUG_EXEC_COMMAND)(t2 - t1));
|
|
78
|
+
}
|
|
79
|
+
process.exit(spawnedProcessExitCode);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
await app.close();
|
|
83
|
+
output_1.default.exitError(`${error}`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
exports.default = commandSessionCreate;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 create_1 = __importDefault(require("./session/create"));
|
|
9
|
+
const close_1 = __importDefault(require("./session/close"));
|
|
10
|
+
const commandSession = (0, utils_1.newCommand)('session', texts_1.DESC_COMMAND_SESSION);
|
|
11
|
+
commandSession.addCommand(create_1.default);
|
|
12
|
+
commandSession.addCommand(close_1.default);
|
|
13
|
+
exports.default = commandSession;
|