bdy 1.18.9-dev-commands-changes-869c3r8yn → 1.18.9-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/command/project/get.js +18 -0
- package/distTs/src/command/project/set.js +31 -0
- package/distTs/src/command/sandbox/get/yaml.js +30 -0
- package/distTs/src/command/scrape/validation.js +15 -21
- package/distTs/src/command/scrape.js +15 -14
- package/distTs/src/command/ut/upload.js +16 -48
- package/distTs/src/command/vt/close.js +5 -5
- package/distTs/src/command/vt/compare.js +18 -15
- package/distTs/src/command/vt/exec.js +28 -28
- package/distTs/src/command/vt/installBrowser.js +2 -2
- package/distTs/src/command/vt/scrape.js +193 -0
- package/distTs/src/command/vt/storybook.js +14 -14
- package/distTs/src/index.js +6 -4
- package/distTs/src/texts.js +37 -39
- package/distTs/src/visualTest/requests.js +1 -1
- package/package.json +1 -1
- package/distTs/src/command/crawl/validation.js +0 -151
- package/distTs/src/command/crawl.js +0 -144
- package/distTs/src/command/tests/capture/validation.js +0 -59
- package/distTs/src/command/tests/capture.js +0 -100
- package/distTs/src/command/tests/unit/upload.js +0 -86
- package/distTs/src/command/tests/unit.js +0 -11
- package/distTs/src/command/tests/visual/session/close.js +0 -27
- package/distTs/src/command/tests/visual/session/create.js +0 -82
- package/distTs/src/command/tests/visual/session.js +0 -13
- package/distTs/src/command/tests/visual/setup.js +0 -20
- package/distTs/src/command/tests/visual/shared/validation.js +0 -118
- package/distTs/src/command/tests/visual/upload.js +0 -138
- package/distTs/src/command/tests/visual.js +0 -15
- package/distTs/src/command/tests.js +0 -15
- package/distTs/src/types/crawl.js +0 -2
package/distTs/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
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_1 = __importDefault(require("../../tunnel/cfg"));
|
|
7
|
+
const output_1 = __importDefault(require("../../output"));
|
|
8
|
+
const texts_1 = require("../../texts");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
const commandProjectGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_PROJECT_GET);
|
|
11
|
+
commandProjectGet.action(async () => {
|
|
12
|
+
const project = cfg_1.default.getProject();
|
|
13
|
+
if (!project) {
|
|
14
|
+
output_1.default.exitError(texts_1.TXT_PROJECT_NONE);
|
|
15
|
+
}
|
|
16
|
+
output_1.default.exitNormal(project);
|
|
17
|
+
});
|
|
18
|
+
exports.default = commandProjectGet;
|
|
@@ -0,0 +1,31 @@
|
|
|
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_1 = __importDefault(require("../../tunnel/cfg"));
|
|
7
|
+
const output_1 = __importDefault(require("../../output"));
|
|
8
|
+
const texts_1 = require("../../texts");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
const input_1 = __importDefault(require("../../input"));
|
|
11
|
+
const commandProjectSet = (0, utils_1.newCommand)('set', texts_1.DESC_COMMAND_PROJECT_SET);
|
|
12
|
+
commandProjectSet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandProjectSet.argument('[project]', texts_1.ARG_COMMAND_PROJECT_NAME);
|
|
14
|
+
commandProjectSet.action(async (project, options) => {
|
|
15
|
+
output_1.default.handleSignals();
|
|
16
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
|
+
const client = input_1.default.restApiTokenClient();
|
|
18
|
+
if (project) {
|
|
19
|
+
await client.getProject(workspace, project);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const response = await client.getProjects(workspace);
|
|
23
|
+
project = await output_1.default.selectProject(response.projects);
|
|
24
|
+
}
|
|
25
|
+
cfg_1.default.setProject(project);
|
|
26
|
+
if (!project)
|
|
27
|
+
output_1.default.exitSuccess(texts_1.TXT_PROJECT_SET_CLEARED);
|
|
28
|
+
else
|
|
29
|
+
output_1.default.exitSuccess((0, texts_1.TXT_PROJECT_SET_SUCCESS)(project));
|
|
30
|
+
});
|
|
31
|
+
exports.default = commandProjectSet;
|
|
@@ -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_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 commandSandboxGetYaml = (0, utils_1.newCommand)('yaml', texts_1.DESC_COMMAND_SANDBOX_GET_YAML);
|
|
11
|
+
commandSandboxGetYaml.hideVersionUpdate = true;
|
|
12
|
+
commandSandboxGetYaml.alias('yml');
|
|
13
|
+
commandSandboxGetYaml.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
+
commandSandboxGetYaml.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
|
+
commandSandboxGetYaml.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
16
|
+
commandSandboxGetYaml.action(async (identifier, options) => {
|
|
17
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = input_1.default.restApiProject(options.project);
|
|
19
|
+
const client = input_1.default.restApiTokenClient();
|
|
20
|
+
let result = await client.listSandboxes(workspace, project);
|
|
21
|
+
const sandboxes = result.sandboxes || [];
|
|
22
|
+
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
+
if (!found) {
|
|
24
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
|
+
}
|
|
26
|
+
const sandboxId = found.id;
|
|
27
|
+
result = await client.getSandboxYaml(workspace, sandboxId);
|
|
28
|
+
output_1.default.exitNormal(Buffer.from(result.yaml, 'base64').toString('utf8'));
|
|
29
|
+
});
|
|
30
|
+
exports.default = commandSandboxGetYaml;
|
|
@@ -103,30 +103,24 @@ function validateInputAndOptions(input, options) {
|
|
|
103
103
|
let parsedDevices;
|
|
104
104
|
if (rawDevices) {
|
|
105
105
|
try {
|
|
106
|
-
const
|
|
107
|
-
.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.transform((data) => ({
|
|
121
|
-
viewport: data.viewport,
|
|
122
|
-
screen: data.screen ?? data.viewport,
|
|
123
|
-
devicePixelRatio: data.devicePixelRatio ?? 1,
|
|
124
|
-
isMobile: data.isMobile ?? false,
|
|
125
|
-
})));
|
|
106
|
+
const dimensionSchema = zod_1.z
|
|
107
|
+
.string()
|
|
108
|
+
.regex(/^\d+x\d+$/, 'Must be in format "widthxheight"')
|
|
109
|
+
.transform((val) => {
|
|
110
|
+
const [width, height] = val.split('x').map(Number);
|
|
111
|
+
return { width, height };
|
|
112
|
+
});
|
|
113
|
+
const deviceSchema = zod_1.z.array(zod_1.z.object({
|
|
114
|
+
name: zod_1.z.string().optional(),
|
|
115
|
+
viewport: dimensionSchema,
|
|
116
|
+
screen: dimensionSchema,
|
|
117
|
+
devicePixelRatio: zod_1.z.number().positive(),
|
|
118
|
+
isMobile: zod_1.z.boolean(),
|
|
119
|
+
}));
|
|
126
120
|
parsedDevices = deviceSchema.parse(JSON.parse(rawDevices));
|
|
127
121
|
}
|
|
128
122
|
catch {
|
|
129
|
-
output_1.default.exitError('Invalid --devices value. Use JSON array, e.g. --devices \'[{"viewport":
|
|
123
|
+
output_1.default.exitError('Invalid --devices value. Use JSON array, e.g. --devices \'[{"viewport":"1920x1080","screen":"1920x1080","devicePixelRatio":1,"isMobile":false}]\'');
|
|
130
124
|
}
|
|
131
125
|
}
|
|
132
126
|
return {
|
|
@@ -6,18 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
8
|
const texts_1 = require("../texts");
|
|
9
|
-
const validation_1 = require("../visualTest/validation");
|
|
10
9
|
const output_1 = __importDefault(require("../output"));
|
|
11
|
-
const requests_1 = require("../visualTest/requests");
|
|
12
10
|
const node_zlib_1 = require("node:zlib");
|
|
13
|
-
const tar_stream_1 = __importDefault(require("tar-stream"));
|
|
14
11
|
const promises_1 = require("node:stream/promises");
|
|
15
12
|
const node_fs_1 = require("node:fs");
|
|
16
13
|
const node_path_1 = __importDefault(require("node:path"));
|
|
17
14
|
const promises_2 = require("node:fs/promises");
|
|
18
|
-
const context_1 = require("../visualTest/context");
|
|
19
|
-
const ci_info_1 = require("@buddy-works/ci-info");
|
|
20
|
-
const validation_2 = require("./scrape/validation");
|
|
21
15
|
const commandScrape = (0, utils_1.newCommand)('scrape', texts_1.DESC_COMMAND_VT_SCRAPE);
|
|
22
16
|
commandScrape.argument('[url]', texts_1.OPTION_SCRAPE_URL);
|
|
23
17
|
commandScrape.option('--follow', texts_1.OPTION_SCRAPE_FOLLOW, false);
|
|
@@ -47,22 +41,28 @@ commandScrape.option('--localStorage <items...>', texts_1.OPTION_SCRAPE_LOCAL_ST
|
|
|
47
41
|
commandScrape.option('--delay <delay>', texts_1.OPTION_SCRAPE_DELAY, '0');
|
|
48
42
|
commandScrape.option('--outputDir <dir>', texts_1.OPTION_SCRAPE_OUTPUT_DIR, '.');
|
|
49
43
|
commandScrape.action(async (inputUrl, options) => {
|
|
50
|
-
|
|
44
|
+
const { checkToken } = require('../visualTest/validation');
|
|
45
|
+
const { downloadScrapPackage, sendScrap } = require('../visualTest/requests');
|
|
46
|
+
const { setCiAndCommitInfo } = require('../visualTest/context');
|
|
47
|
+
const { validateInputAndOptions } = require('./scrape/validation');
|
|
48
|
+
const { getCiAndGitInfo } = require('@buddy-works/ci-info');
|
|
49
|
+
const tar = require('tar-stream');
|
|
50
|
+
if (!checkToken('scrape')) {
|
|
51
51
|
output_1.default.exitError(texts_1.ERR_MISSING_SCRAPE_TOKEN);
|
|
52
52
|
}
|
|
53
|
-
const { url, follow, respectRobots, outputTypes, outputDir, fullPage, colorScheme, browsers, devices, cookies, requestHeaders, delay, waitForSelectors, localStorage, } =
|
|
53
|
+
const { url, follow, respectRobots, outputTypes, outputDir, fullPage, colorScheme, browsers, devices, cookies, requestHeaders, delay, waitForSelectors, localStorage, } = validateInputAndOptions(inputUrl, options);
|
|
54
54
|
try {
|
|
55
|
-
const ciAndGitInfo = await
|
|
56
|
-
|
|
57
|
-
const { buildId } = await
|
|
55
|
+
const ciAndGitInfo = await getCiAndGitInfo({});
|
|
56
|
+
setCiAndCommitInfo(ciAndGitInfo);
|
|
57
|
+
const { buildId } = await sendScrap(url, follow, respectRobots, outputTypes, fullPage, colorScheme, browsers, devices, cookies, requestHeaders, delay, waitForSelectors, localStorage);
|
|
58
58
|
const status = await watchSessionStatus(buildId);
|
|
59
59
|
if (!status.ok) {
|
|
60
60
|
output_1.default.exitError(`Scrape session failed: ${status.error}`);
|
|
61
61
|
}
|
|
62
62
|
output_1.default.normal('Downloading scrape package');
|
|
63
|
-
const scrapPackageStream = await
|
|
63
|
+
const scrapPackageStream = await downloadScrapPackage(buildId);
|
|
64
64
|
const brotliDecompressor = (0, node_zlib_1.createBrotliDecompress)();
|
|
65
|
-
const unpack =
|
|
65
|
+
const unpack = tar.extract();
|
|
66
66
|
unpack.on('entry', async (header, stream, next) => {
|
|
67
67
|
const currentDir = process.cwd();
|
|
68
68
|
const preparedOutputDir = outputDir.startsWith('.')
|
|
@@ -94,8 +94,9 @@ commandScrape.action(async (inputUrl, options) => {
|
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
async function watchSessionStatus(buildId) {
|
|
97
|
+
const { connectToScrapSession } = require('../visualTest/requests');
|
|
97
98
|
return new Promise((resolve) => {
|
|
98
|
-
const eventSource =
|
|
99
|
+
const eventSource = connectToScrapSession(buildId);
|
|
99
100
|
eventSource.addEventListener('SESSION_STATUS', (event) => {
|
|
100
101
|
const data = JSON.parse(event.data);
|
|
101
102
|
if (data.status === 'STARTED') {
|
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
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
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -40,12 +7,7 @@ const utils_1 = require("../../utils");
|
|
|
40
7
|
const texts_1 = require("../../texts");
|
|
41
8
|
const output_1 = __importDefault(require("../../output"));
|
|
42
9
|
const commander_1 = require("commander");
|
|
43
|
-
const zod_1 = __importStar(require("zod"));
|
|
44
|
-
const fdir_1 = require("fdir");
|
|
45
|
-
const picomatch_1 = __importDefault(require("picomatch"));
|
|
46
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
47
|
-
const ci_1 = require("../../unitTest/ci");
|
|
48
|
-
const requests_1 = require("../../unitTest/requests");
|
|
49
11
|
const token = process.env.BUDDY_UT_TOKEN || '';
|
|
50
12
|
const commandUtUpload = (0, utils_1.newCommand)('upload', texts_1.DESC_COMMAND_UT_UPLOAD);
|
|
51
13
|
commandUtUpload.argument('<glob>', texts_1.OPTION_UPLOAD_REPORT_GLOB);
|
|
@@ -54,11 +16,13 @@ commandUtUpload.addOption(new commander_1.Option('--format <format>', texts_1.OP
|
|
|
54
16
|
.makeOptionMandatory());
|
|
55
17
|
commandUtUpload.option('--dryRun', texts_1.OPTION_UPLOAD_DRY_RUN);
|
|
56
18
|
commandUtUpload.action(async (input, options) => {
|
|
19
|
+
const { getCiInfo } = require('../../unitTest/ci');
|
|
20
|
+
const { sendUploadRequest } = require('../../unitTest/requests');
|
|
57
21
|
if (!token) {
|
|
58
22
|
output_1.default.exitError(texts_1.ERR_MISSING_UT_TOKEN);
|
|
59
23
|
}
|
|
60
24
|
const { glob, dryRun } = validateInputAndOptions(input, options);
|
|
61
|
-
const ciInfo = await
|
|
25
|
+
const ciInfo = await getCiInfo();
|
|
62
26
|
const { absolutePattern, files } = findFilesByGlob(glob);
|
|
63
27
|
if (files.length === 0) {
|
|
64
28
|
output_1.default.exitError(`No files matched the provided glob: ${absolutePattern}`);
|
|
@@ -70,15 +34,17 @@ commandUtUpload.action(async (input, options) => {
|
|
|
70
34
|
});
|
|
71
35
|
output_1.default.exitSuccess('Dry run completed');
|
|
72
36
|
}
|
|
73
|
-
await
|
|
37
|
+
await sendUploadRequest(files, ciInfo);
|
|
74
38
|
output_1.default.exitSuccess('Upload completed');
|
|
75
39
|
});
|
|
76
40
|
exports.default = commandUtUpload;
|
|
77
41
|
function validateInputAndOptions(input, options) {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
42
|
+
const z = require('zod');
|
|
43
|
+
const { ZodError } = require('zod');
|
|
44
|
+
const globSchema = z.string();
|
|
45
|
+
const optionsSchema = z.object({
|
|
46
|
+
format: z.enum(['junit-xml']),
|
|
47
|
+
dryRun: z.boolean().optional(),
|
|
82
48
|
});
|
|
83
49
|
try {
|
|
84
50
|
const glob = globSchema.parse(input);
|
|
@@ -90,7 +56,7 @@ function validateInputAndOptions(input, options) {
|
|
|
90
56
|
};
|
|
91
57
|
}
|
|
92
58
|
catch (error) {
|
|
93
|
-
if (error instanceof
|
|
59
|
+
if (error instanceof ZodError) {
|
|
94
60
|
output_1.default.exitError(error.errors.map((e) => `${e.path}: ${e.message}`).join(', '));
|
|
95
61
|
}
|
|
96
62
|
else {
|
|
@@ -99,8 +65,10 @@ function validateInputAndOptions(input, options) {
|
|
|
99
65
|
}
|
|
100
66
|
}
|
|
101
67
|
function findFilesByGlob(pattern) {
|
|
68
|
+
const { fdir } = require('fdir');
|
|
69
|
+
const picomatch = require('picomatch');
|
|
102
70
|
const cwd = process.cwd();
|
|
103
|
-
const scan =
|
|
71
|
+
const scan = picomatch.scan(pattern);
|
|
104
72
|
if (!scan.isGlob) {
|
|
105
73
|
return {
|
|
106
74
|
absolutePattern: pattern,
|
|
@@ -109,10 +77,10 @@ function findFilesByGlob(pattern) {
|
|
|
109
77
|
}
|
|
110
78
|
if (node_path_1.default.isAbsolute(pattern)) {
|
|
111
79
|
const root = scan.base;
|
|
112
|
-
const files = new
|
|
80
|
+
const files = new fdir().withFullPaths().glob(pattern).crawl(root).sync();
|
|
113
81
|
return { absolutePattern: pattern, files };
|
|
114
82
|
}
|
|
115
83
|
const preparedPattern = node_path_1.default.resolve(cwd, pattern);
|
|
116
|
-
const files = new
|
|
84
|
+
const files = new fdir().withFullPaths().glob(preparedPattern).crawl().sync();
|
|
117
85
|
return { absolutePattern: preparedPattern, files };
|
|
118
86
|
}
|
|
@@ -5,19 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const validation_1 = require("../../visualTest/validation");
|
|
9
|
-
const requests_1 = require("../../visualTest/requests");
|
|
10
8
|
const output_1 = __importDefault(require("../../output"));
|
|
11
9
|
const commandVtClose = (0, utils_1.newCommand)('close', texts_1.DESC_COMMAND_VT_CLOSE);
|
|
12
10
|
commandVtClose.action(async () => {
|
|
13
|
-
|
|
11
|
+
const { checkBuildId, checkToken } = require('../../visualTest/validation');
|
|
12
|
+
const { closeSession } = require('../../visualTest/requests');
|
|
13
|
+
if (!checkToken('vt')) {
|
|
14
14
|
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
15
15
|
}
|
|
16
|
-
if (!
|
|
16
|
+
if (!checkBuildId()) {
|
|
17
17
|
output_1.default.exitError(texts_1.ERR_MISSING_BUILD_ID);
|
|
18
18
|
}
|
|
19
19
|
try {
|
|
20
|
-
const { message } = await
|
|
20
|
+
const { message } = await closeSession();
|
|
21
21
|
output_1.default.exitNormal(message);
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
@@ -5,14 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const validation_1 = require("../../visualTest/validation");
|
|
9
8
|
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const linkUtils_1 = require("../../visualTest/linkUtils");
|
|
11
9
|
const node_fs_1 = require("node:fs");
|
|
12
|
-
const requests_1 = require("../../visualTest/requests");
|
|
13
|
-
const validation_2 = require("./compare/validation");
|
|
14
|
-
const context_1 = require("../../visualTest/context");
|
|
15
|
-
const ci_info_1 = require("@buddy-works/ci-info");
|
|
16
10
|
const commandVtCompare = (0, utils_1.newCommand)('compare', texts_1.DESC_COMMAND_VT_COMPARE);
|
|
17
11
|
commandVtCompare.option('--urls <urls>', texts_1.OPTION_COMPARE_URLS);
|
|
18
12
|
commandVtCompare.option('--sitemap <sitemap>', texts_1.OPTION_COMPARE_SITEMAP);
|
|
@@ -27,11 +21,17 @@ commandVtCompare.option('--header <headers...>', texts_1.OPTION_COMPARE_HEADER);
|
|
|
27
21
|
commandVtCompare.option('--delay <delays...>', texts_1.OPTION_COMPARE_DELAY);
|
|
28
22
|
commandVtCompare.option('--waitFor <waitFors...>', texts_1.OPTION_COMPARE_WAIT_FOR);
|
|
29
23
|
commandVtCompare.action(async (options) => {
|
|
30
|
-
const
|
|
31
|
-
|
|
24
|
+
const { getCiAndGitInfo, formattedCiInfo } = require('@buddy-works/ci-info');
|
|
25
|
+
const { checkToken } = require('../../visualTest/validation');
|
|
26
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
27
|
+
const { sendCompareLinks } = require('../../visualTest/requests');
|
|
28
|
+
const { checkIfMinimalOptionsAreProvided, validateOptions } = require('./compare/validation');
|
|
29
|
+
const { setCiAndCommitInfo } = require('../../visualTest/context');
|
|
30
|
+
const validatedOptions = validateOptions(options);
|
|
31
|
+
if (!checkToken('vt')) {
|
|
32
32
|
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
33
33
|
}
|
|
34
|
-
if (!
|
|
34
|
+
if (!checkIfMinimalOptionsAreProvided(validatedOptions)) {
|
|
35
35
|
output_1.default.exitError(texts_1.ERR_MISSING_URLS);
|
|
36
36
|
}
|
|
37
37
|
let urls = [];
|
|
@@ -45,7 +45,7 @@ commandVtCompare.action(async (options) => {
|
|
|
45
45
|
urls = urls.concat(urlsList);
|
|
46
46
|
}
|
|
47
47
|
if (validatedOptions.sitemap) {
|
|
48
|
-
sitemapSource =
|
|
48
|
+
sitemapSource = addProtocolIfMissing(validatedOptions.sitemap);
|
|
49
49
|
}
|
|
50
50
|
const { filteredUrls, duplicates } = filterDuplicates(urls);
|
|
51
51
|
if (duplicates.length > 0) {
|
|
@@ -58,10 +58,11 @@ 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
|
|
62
|
-
|
|
61
|
+
const ciAndGitInfo = await getCiAndGitInfo({});
|
|
62
|
+
output_1.default.normal(formattedCiInfo(ciAndGitInfo));
|
|
63
|
+
setCiAndCommitInfo(ciAndGitInfo);
|
|
63
64
|
try {
|
|
64
|
-
const { message } = await
|
|
65
|
+
const { message } = await sendCompareLinks(filteredUrls, validatedOptions, sitemapSource);
|
|
65
66
|
output_1.default.exitSuccess(message);
|
|
66
67
|
}
|
|
67
68
|
catch (error) {
|
|
@@ -69,14 +70,16 @@ commandVtCompare.action(async (options) => {
|
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
function getUrlsFromUrlOption(urls) {
|
|
72
|
-
|
|
73
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
74
|
+
return urls.split(',').map((url) => addProtocolIfMissing(url).trim());
|
|
73
75
|
}
|
|
74
76
|
function getUrlsFromUrlFile(urlsFile) {
|
|
77
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
75
78
|
const urlsFromFile = (0, node_fs_1.readFileSync)(urlsFile, 'utf-8');
|
|
76
79
|
return urlsFromFile
|
|
77
80
|
.split('\n')
|
|
78
81
|
.filter((url) => url.trim().length > 0)
|
|
79
|
-
.map((url) =>
|
|
82
|
+
.map((url) => addProtocolIfMissing(url).trim());
|
|
80
83
|
}
|
|
81
84
|
function filterDuplicates(urls) {
|
|
82
85
|
const seen = new Set();
|
|
@@ -5,70 +5,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const validation_1 = require("../../visualTest/validation");
|
|
9
|
-
const requests_1 = require("../../visualTest/requests");
|
|
10
8
|
const output_1 = __importDefault(require("../../output"));
|
|
11
|
-
const context_1 = require("../../visualTest/context");
|
|
12
|
-
const server_1 = require("../../visualTest/server");
|
|
13
|
-
const which_1 = __importDefault(require("which"));
|
|
14
|
-
const snapshots_1 = require("../../visualTest/snapshots");
|
|
15
|
-
const exec_1 = require("../../visualTest/exec");
|
|
16
|
-
const browser_1 = require("../../visualTest/browser");
|
|
17
|
-
const ci_info_1 = require("@buddy-works/ci-info");
|
|
18
9
|
const commandVtExec = (0, utils_1.newCommand)('exec', texts_1.DESC_COMMAND_VT_EXEC);
|
|
19
10
|
commandVtExec.argument('<command>', texts_1.OPTION_EXEC_COMMAND);
|
|
20
11
|
commandVtExec.option('--skipDiscovery', texts_1.OPTION_EXEC_SKIP_DISCOVERY);
|
|
21
12
|
commandVtExec.option('--oneByOne', texts_1.OPTION_EXEC_ONE_BY_ONE);
|
|
22
13
|
commandVtExec.option('--parallel', texts_1.OPTION_EXEC_PARALLEL);
|
|
23
14
|
commandVtExec.action(async (command, options) => {
|
|
24
|
-
|
|
15
|
+
const which = require('which');
|
|
16
|
+
const { getCiAndGitInfo, formattedCiInfo } = require('@buddy-works/ci-info');
|
|
17
|
+
const { checkParallel, checkToken } = require('../../visualTest/validation');
|
|
18
|
+
const { getDefaultSettings } = require('../../visualTest/requests');
|
|
19
|
+
const { debug, setBrowserPath, setCiAndCommitInfo, setExecOptions } = 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
|
+
setExecOptions(options);
|
|
25
25
|
try {
|
|
26
|
-
const browserPath = await
|
|
27
|
-
|
|
26
|
+
const browserPath = await getBrowserPath();
|
|
27
|
+
setBrowserPath(browserPath);
|
|
28
28
|
}
|
|
29
29
|
catch (error) {
|
|
30
30
|
output_1.default.exitError(`${error}`);
|
|
31
31
|
}
|
|
32
|
-
if (!
|
|
32
|
+
if (!checkToken('vt')) {
|
|
33
33
|
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
34
34
|
}
|
|
35
|
-
if (!
|
|
35
|
+
if (!checkParallel()) {
|
|
36
36
|
output_1.default.exitError(texts_1.ERR_MISSING_BUILD_ID);
|
|
37
37
|
}
|
|
38
|
-
const app = await
|
|
38
|
+
const app = await createServer();
|
|
39
39
|
const [mainCommand, ...mainCommandArguments] = command.split(' ');
|
|
40
40
|
output_1.default.normal((0, texts_1.LOG_RUNNING_EXEC_COMMAND)(`${mainCommand} ${[...mainCommandArguments].join(' ')}`));
|
|
41
|
-
const resolved = await (
|
|
41
|
+
const resolved = await which(mainCommand, { nothrow: true });
|
|
42
42
|
if (!resolved) {
|
|
43
43
|
output_1.default.exitError((0, texts_1.ERR_MISSING_EXEC_COMMAND)(`${mainCommand} ${[...mainCommandArguments].join(' ')}`));
|
|
44
44
|
}
|
|
45
45
|
try {
|
|
46
46
|
let t1, t11;
|
|
47
|
-
if (
|
|
47
|
+
if (debug) {
|
|
48
48
|
t1 = performance.now();
|
|
49
49
|
}
|
|
50
|
-
const defaultSettings = await
|
|
51
|
-
|
|
52
|
-
const ciAndGitInfo = await
|
|
50
|
+
const defaultSettings = await getDefaultSettings();
|
|
51
|
+
setDefaultSettings(defaultSettings);
|
|
52
|
+
const ciAndGitInfo = await getCiAndGitInfo({
|
|
53
53
|
baseBranch: defaultSettings.baseBranch,
|
|
54
54
|
logger: output_1.default.warning,
|
|
55
55
|
});
|
|
56
|
-
|
|
57
|
-
output_1.default.normal(
|
|
58
|
-
if (
|
|
56
|
+
setCiAndCommitInfo(ciAndGitInfo);
|
|
57
|
+
output_1.default.normal(formattedCiInfo(ciAndGitInfo));
|
|
58
|
+
if (debug) {
|
|
59
59
|
t11 = performance.now();
|
|
60
60
|
}
|
|
61
|
-
const spawnedProcessExitCode = await
|
|
61
|
+
const spawnedProcessExitCode = await testExec(mainCommand, [
|
|
62
62
|
...mainCommandArguments,
|
|
63
63
|
]);
|
|
64
|
-
if (
|
|
64
|
+
if (debug && t11) {
|
|
65
65
|
const t22 = performance.now();
|
|
66
66
|
output_1.default.normal((0, texts_1.DEBUG_EXEC_TEST_COMMAND)(t22 - t11));
|
|
67
67
|
}
|
|
68
68
|
await app.close();
|
|
69
|
-
await
|
|
70
|
-
|
|
71
|
-
if (
|
|
69
|
+
await finishProcessingSnapshots(spawnedProcessExitCode);
|
|
70
|
+
showSessionLink();
|
|
71
|
+
if (debug && t1) {
|
|
72
72
|
const t2 = performance.now();
|
|
73
73
|
output_1.default.normal((0, texts_1.DEBUG_EXEC_COMMAND)(t2 - t1));
|
|
74
74
|
}
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const browser_1 = require("../../visualTest/browser");
|
|
10
9
|
const commandVtInstallBrowser = (0, utils_1.newCommand)('install-browser', texts_1.DESC_COMMAND_VT_INSTALL_BROWSER);
|
|
11
10
|
commandVtInstallBrowser.action(async () => {
|
|
12
11
|
try {
|
|
13
|
-
|
|
12
|
+
const { installBrowser } = require('../../visualTest/browser');
|
|
13
|
+
await installBrowser();
|
|
14
14
|
output_1.default.exitNormal('');
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|