bdy 1.18.5-dev → 1.18.6-dev
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/agent/manager.js +20 -18
- package/distTs/src/autocomplete.js +10 -5
- package/distTs/src/command/agent/debug.js +6 -6
- package/distTs/src/command/agent/disable.js +2 -2
- package/distTs/src/command/agent/enable.js +2 -2
- package/distTs/src/command/agent/install.js +31 -26
- package/distTs/src/command/agent/proxy/disable.js +2 -2
- package/distTs/src/command/agent/proxy/enable.js +2 -2
- package/distTs/src/command/agent/proxy/status.js +2 -2
- package/distTs/src/command/agent/restart.js +6 -6
- package/distTs/src/command/agent/run.js +3 -3
- package/distTs/src/command/agent/start.js +7 -7
- package/distTs/src/command/agent/stop.js +6 -6
- package/distTs/src/command/agent/tags/get.js +2 -2
- package/distTs/src/command/agent/tags/set.js +2 -2
- package/distTs/src/command/agent/target/disable.js +2 -2
- package/distTs/src/command/agent/target/enable.js +2 -2
- package/distTs/src/command/agent/target/status.js +2 -2
- package/distTs/src/command/agent/tunnel/disable.js +2 -2
- package/distTs/src/command/agent/tunnel/enable.js +2 -2
- package/distTs/src/command/agent/tunnel/http.js +7 -7
- package/distTs/src/command/agent/tunnel/list.js +2 -2
- package/distTs/src/command/agent/tunnel/remove.js +2 -2
- package/distTs/src/command/agent/tunnel/start.js +5 -5
- package/distTs/src/command/agent/tunnel/status.js +4 -4
- package/distTs/src/command/agent/tunnel/tcp.js +7 -7
- package/distTs/src/command/agent/tunnel/tls.js +7 -7
- package/distTs/src/command/agent/uninstall.js +12 -12
- package/distTs/src/command/agent/update.js +9 -9
- package/distTs/src/command/api/info.js +2 -1
- package/distTs/src/command/api/list.js +2 -1
- package/distTs/src/command/api/request.js +2 -2
- package/distTs/src/command/login.js +8 -6
- package/distTs/src/command/package/create.js +2 -2
- package/distTs/src/command/package/download.js +5 -37
- package/distTs/src/command/package/publish.js +7 -6
- package/distTs/src/command/pre.js +5 -5
- package/distTs/src/command/project/link.js +4 -3
- package/distTs/src/command/sandbox/cp.js +7 -39
- package/distTs/src/command/sandbox/create.js +2 -2
- package/distTs/src/command/sandbox/snapshot/create.js +2 -2
- package/distTs/src/command/scrape.js +15 -14
- package/distTs/src/command/tunnel/http.js +8 -8
- package/distTs/src/command/tunnel/start.js +9 -9
- package/distTs/src/command/tunnel/tcp.js +8 -8
- package/distTs/src/command/tunnel/tls.js +8 -8
- 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 -16
- package/distTs/src/command/vt/exec.js +28 -28
- package/distTs/src/command/vt/installBrowser.js +2 -2
- package/distTs/src/command/vt/storybook.js +14 -14
- package/distTs/src/input.js +8 -7
- package/distTs/src/logger.js +3 -3
- package/distTs/src/openapi.js +24 -0
- package/distTs/src/output.js +21 -16
- package/distTs/src/sshKeygen.js +9 -0
- package/distTs/src/tunnel/cfg.js +17 -20
- package/distTs/src/tunnel/tunnel.js +2 -1
- package/distTs/src/utils.js +1 -27
- package/package.json +1 -1
|
@@ -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').default;
|
|
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,11 +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
|
-
output_1.default.normal(
|
|
63
|
-
|
|
61
|
+
const ciAndGitInfo = await getCiAndGitInfo({});
|
|
62
|
+
output_1.default.normal(formattedCiInfo(ciAndGitInfo));
|
|
63
|
+
setCiAndCommitInfo(ciAndGitInfo);
|
|
64
64
|
try {
|
|
65
|
-
const { message } = await
|
|
65
|
+
const { message } = await sendCompareLinks(filteredUrls, validatedOptions, sitemapSource);
|
|
66
66
|
output_1.default.exitSuccess(message);
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
@@ -70,14 +70,16 @@ commandVtCompare.action(async (options) => {
|
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
function getUrlsFromUrlOption(urls) {
|
|
73
|
-
|
|
73
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
74
|
+
return urls.split(',').map((url) => addProtocolIfMissing(url).trim());
|
|
74
75
|
}
|
|
75
76
|
function getUrlsFromUrlFile(urlsFile) {
|
|
77
|
+
const { addProtocolIfMissing } = require('../../visualTest/linkUtils');
|
|
76
78
|
const urlsFromFile = (0, node_fs_1.readFileSync)(urlsFile, 'utf-8');
|
|
77
79
|
return urlsFromFile
|
|
78
80
|
.split('\n')
|
|
79
81
|
.filter((url) => url.trim().length > 0)
|
|
80
|
-
.map((url) =>
|
|
82
|
+
.map((url) => addProtocolIfMissing(url).trim());
|
|
81
83
|
}
|
|
82
84
|
function filterDuplicates(urls) {
|
|
83
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) {
|
|
@@ -5,19 +5,18 @@ 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 snapshots_1 = require("../../visualTest/snapshots");
|
|
12
|
-
const context_1 = require("../../visualTest/context");
|
|
13
9
|
const node_fs_1 = require("node:fs");
|
|
14
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
-
const ci_info_1 = require("@buddy-works/ci-info");
|
|
16
|
-
const tar_stream_1 = __importDefault(require("tar-stream"));
|
|
17
11
|
const node_zlib_1 = require("node:zlib");
|
|
18
12
|
const commandVtStorybook = (0, utils_1.newCommand)('storybook', texts_1.DESC_COMMAND_VT_STORYBOOK);
|
|
19
13
|
commandVtStorybook.action(async () => {
|
|
20
|
-
|
|
14
|
+
const { getCiAndGitInfo, formattedCiInfo } = require('@buddy-works/ci-info');
|
|
15
|
+
const { checkToken } = require('../../visualTest/validation');
|
|
16
|
+
const { getDefaultSettings, sendStorybook } = require('../../visualTest/requests');
|
|
17
|
+
const { setDefaultSettings } = require('../../visualTest/snapshots');
|
|
18
|
+
const { setCiAndCommitInfo } = require('../../visualTest/context');
|
|
19
|
+
if (!checkToken('vt')) {
|
|
21
20
|
output_1.default.exitError(texts_1.ERR_MISSING_VT_TOKEN);
|
|
22
21
|
}
|
|
23
22
|
const currentDirectoryFiles = getCurrentDirectoryFiles();
|
|
@@ -27,17 +26,17 @@ commandVtStorybook.action(async () => {
|
|
|
27
26
|
const storybookStoriesIndex = getStorybookStoriesIndex(currentDirectoryFiles);
|
|
28
27
|
const storiesList = getStoriesList(storybookStoriesIndex);
|
|
29
28
|
const storybookSnapshots = getStorybookSnapshots(storiesList);
|
|
30
|
-
const defaultSettings = await
|
|
31
|
-
|
|
32
|
-
const ciAndGitInfo = await
|
|
29
|
+
const defaultSettings = await getDefaultSettings();
|
|
30
|
+
setDefaultSettings(defaultSettings);
|
|
31
|
+
const ciAndGitInfo = await getCiAndGitInfo({
|
|
33
32
|
baseBranch: defaultSettings.baseBranch,
|
|
34
33
|
logger: output_1.default.warning,
|
|
35
34
|
});
|
|
36
|
-
|
|
37
|
-
output_1.default.normal(
|
|
35
|
+
setCiAndCommitInfo(ciAndGitInfo);
|
|
36
|
+
output_1.default.normal(formattedCiInfo(ciAndGitInfo));
|
|
38
37
|
try {
|
|
39
38
|
const compressedStorybookDirectory = await createCompressedStorybookDirectory(currentDirectoryFiles);
|
|
40
|
-
const { message } = await
|
|
39
|
+
const { message } = await sendStorybook(storybookSnapshots, compressedStorybookDirectory);
|
|
41
40
|
output_1.default.exitSuccess(message);
|
|
42
41
|
}
|
|
43
42
|
catch (error) {
|
|
@@ -57,6 +56,7 @@ function getCurrentDirectoryFiles() {
|
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
58
|
async function createCompressedStorybookDirectory(files) {
|
|
59
|
+
const tar = require('tar-stream');
|
|
60
60
|
const cwd = process.cwd();
|
|
61
61
|
const chunks = [];
|
|
62
62
|
return new Promise((resolve, reject) => {
|
|
@@ -72,7 +72,7 @@ async function createCompressedStorybookDirectory(files) {
|
|
|
72
72
|
resolve(Buffer.concat(chunks));
|
|
73
73
|
});
|
|
74
74
|
compressStream.on('error', reject);
|
|
75
|
-
const packStream =
|
|
75
|
+
const packStream = tar.pack();
|
|
76
76
|
packStream.pipe(compressStream);
|
|
77
77
|
let filesProcessed = 0;
|
|
78
78
|
for (const file of files) {
|
package/distTs/src/input.js
CHANGED
|
@@ -42,14 +42,11 @@ const punycode_1 = __importDefault(require("punycode/"));
|
|
|
42
42
|
const node_fs_1 = __importStar(require("node:fs"));
|
|
43
43
|
const tls_1 = __importDefault(require("tls"));
|
|
44
44
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
45
|
-
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
46
45
|
const utils_1 = require("./utils");
|
|
47
46
|
const texts_1 = require("./texts");
|
|
48
47
|
const tunnel_1 = require("./types/tunnel");
|
|
49
48
|
const node_path_1 = __importStar(require("node:path"));
|
|
50
49
|
const cfg_1 = __importDefault(require("./tunnel/cfg"));
|
|
51
|
-
const cfg_2 = __importDefault(require("./project/cfg"));
|
|
52
|
-
const client_1 = __importDefault(require("./api/client"));
|
|
53
50
|
class Input {
|
|
54
51
|
static timeout(timeout) {
|
|
55
52
|
const t = parseInt(timeout, 10);
|
|
@@ -336,9 +333,10 @@ class Input {
|
|
|
336
333
|
return result;
|
|
337
334
|
}
|
|
338
335
|
static restApiTokenClient(allowNoToken = false, api = '', region = '', token = '') {
|
|
336
|
+
const ApiClient = require('./api/client').default;
|
|
339
337
|
const baseUrl = this.restApiBaseUrl(api, region);
|
|
340
338
|
const { token: t, refreshToken, clientId, clientToken, clientSecret, } = this.restApiToken(allowNoToken, token);
|
|
341
|
-
return new
|
|
339
|
+
return new ApiClient(baseUrl, t, refreshToken, clientId, clientSecret, clientToken);
|
|
342
340
|
}
|
|
343
341
|
static packageType(type) {
|
|
344
342
|
if (!type)
|
|
@@ -478,11 +476,12 @@ class Input {
|
|
|
478
476
|
return p;
|
|
479
477
|
}
|
|
480
478
|
static restApiWorkspace(workspace, allowNull) {
|
|
479
|
+
const ProjectCfg = require('./project/cfg').default;
|
|
481
480
|
let w = process.env.BUDDY_WORKSPACE;
|
|
482
481
|
if (workspace)
|
|
483
482
|
w = workspace;
|
|
484
483
|
if (!w)
|
|
485
|
-
w =
|
|
484
|
+
w = ProjectCfg.getWorkspace();
|
|
486
485
|
if (!w)
|
|
487
486
|
w = cfg_1.default.getWorkspace();
|
|
488
487
|
if (!w) {
|
|
@@ -647,11 +646,12 @@ class Input {
|
|
|
647
646
|
return null;
|
|
648
647
|
}
|
|
649
648
|
static restApiProject(project, allowNull) {
|
|
649
|
+
const ProjectCfg = require('./project/cfg').default;
|
|
650
650
|
let p = process.env.BUDDY_PROJECT;
|
|
651
651
|
if (project)
|
|
652
652
|
p = project;
|
|
653
653
|
if (!p)
|
|
654
|
-
p =
|
|
654
|
+
p = ProjectCfg.getProject();
|
|
655
655
|
if (!p) {
|
|
656
656
|
if (allowNull)
|
|
657
657
|
return null;
|
|
@@ -728,7 +728,8 @@ class Input {
|
|
|
728
728
|
}
|
|
729
729
|
if (!token)
|
|
730
730
|
throw new Error(texts_1.ERR_TOKEN_NOT_PROVIDED);
|
|
731
|
-
const
|
|
731
|
+
const { decode } = require('jsonwebtoken');
|
|
732
|
+
const d = decode(token);
|
|
732
733
|
if (d === null) {
|
|
733
734
|
throw new Error(texts_1.ERR_WRONG_TOKEN);
|
|
734
735
|
}
|
package/distTs/src/logger.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const pino_1 = __importDefault(require("pino"));
|
|
7
6
|
const path_1 = require("path");
|
|
8
7
|
const fs_1 = __importDefault(require("fs"));
|
|
9
8
|
const utils_1 = require("./utils");
|
|
@@ -48,7 +47,8 @@ class Logger {
|
|
|
48
47
|
catch {
|
|
49
48
|
// do nothing
|
|
50
49
|
}
|
|
51
|
-
|
|
50
|
+
const pino = require('pino');
|
|
51
|
+
this.p = pino({
|
|
52
52
|
level: this.debugOn ? 'debug' : 'info',
|
|
53
53
|
timestamp: () => `, "time": "${new Date().toISOString()}"`,
|
|
54
54
|
formatters: {
|
|
@@ -57,7 +57,7 @@ class Logger {
|
|
|
57
57
|
level: label.toUpperCase(),
|
|
58
58
|
}),
|
|
59
59
|
},
|
|
60
|
-
},
|
|
60
|
+
}, pino.destination(this.logStream));
|
|
61
61
|
this.checkLogSize();
|
|
62
62
|
this.ts = setInterval(() => {
|
|
63
63
|
this.checkLogSize();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchOpenApiSchema = fetchOpenApiSchema;
|
|
4
|
+
const bundle_1 = require("@scalar/json-magic/bundle");
|
|
5
|
+
const node_1 = require("@scalar/json-magic/bundle/plugins/node");
|
|
6
|
+
const openapi_parser_1 = require("@scalar/openapi-parser");
|
|
7
|
+
const texts_1 = require("./texts");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
async function fetchOpenApiSchema(baseUrl) {
|
|
10
|
+
try {
|
|
11
|
+
const url = (0, utils_1.getOpenApiEndpointByApiBaseUrl)(baseUrl);
|
|
12
|
+
const data = await (0, bundle_1.bundle)(url, {
|
|
13
|
+
plugins: [(0, node_1.readFiles)(), (0, node_1.fetchUrls)(), (0, node_1.parseYaml)(), (0, node_1.parseJson)()],
|
|
14
|
+
treeShake: true,
|
|
15
|
+
});
|
|
16
|
+
const { schema } = await (0, openapi_parser_1.dereference)(data);
|
|
17
|
+
if (schema)
|
|
18
|
+
return schema;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// do nothing
|
|
22
|
+
}
|
|
23
|
+
throw new Error(texts_1.ERR_SCHEMA_FETCH_FAILED);
|
|
24
|
+
}
|
package/distTs/src/output.js
CHANGED
|
@@ -5,16 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
const termkit_no_lazy_require_1 = __importDefault(require("terminal-kit/lib/termkit-no-lazy-require"));
|
|
8
|
-
const tunnel_1 = __importDefault(require("./tunnel/output/
|
|
9
|
-
const tunnel_2 = __importDefault(require("./tunnel/output/noninteractive/tunnel"));
|
|
10
|
-
const tunnel_3 = __importDefault(require("./tunnel/output/noninteractive/config/tunnel"));
|
|
8
|
+
const tunnel_1 = __importDefault(require("./tunnel/output/noninteractive/tunnel"));
|
|
9
|
+
const tunnel_2 = __importDefault(require("./tunnel/output/noninteractive/config/tunnel"));
|
|
11
10
|
const tunnels_1 = __importDefault(require("./tunnel/output/noninteractive/config/tunnels"));
|
|
12
11
|
const texts_1 = require("./texts");
|
|
13
12
|
const tunnels_2 = __importDefault(require("./tunnel/output/noninteractive/agent/tunnels"));
|
|
14
|
-
const context_1 = require("./visualTest/context");
|
|
15
13
|
const utils_1 = require("./utils");
|
|
16
14
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
-
const prompts_1 = __importDefault(require("@inquirer/prompts"));
|
|
18
15
|
const terminal = termkit_no_lazy_require_1.default.terminal;
|
|
19
16
|
class Output {
|
|
20
17
|
static s;
|
|
@@ -127,12 +124,14 @@ class Output {
|
|
|
127
124
|
this.normal(this.getCyanColor(txt), newLine);
|
|
128
125
|
}
|
|
129
126
|
static debug(txt) {
|
|
130
|
-
|
|
127
|
+
const { debug } = require('./visualTest/context');
|
|
128
|
+
if (debug) {
|
|
131
129
|
this.normal(txt);
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
static async debugAction(text, action) {
|
|
135
|
-
|
|
133
|
+
const { debug } = require('./visualTest/context');
|
|
134
|
+
if (debug) {
|
|
136
135
|
const t1 = performance.now();
|
|
137
136
|
const result = await action;
|
|
138
137
|
const t2 = performance.now();
|
|
@@ -170,12 +169,13 @@ class Output {
|
|
|
170
169
|
}
|
|
171
170
|
static tunnelInteractive(tunnel) {
|
|
172
171
|
this.killSpinner();
|
|
173
|
-
const
|
|
172
|
+
const OutputInteractiveTunnel = require('./tunnel/output/interactive/tunnel').default;
|
|
173
|
+
const oi = new OutputInteractiveTunnel(terminal, tunnel);
|
|
174
174
|
oi.start();
|
|
175
175
|
}
|
|
176
176
|
static tunnelNonInteractive(tunnel) {
|
|
177
177
|
this.killSpinner();
|
|
178
|
-
const on = new
|
|
178
|
+
const on = new tunnel_1.default(terminal, tunnel);
|
|
179
179
|
on.start();
|
|
180
180
|
}
|
|
181
181
|
static newCliVersion(version) {
|
|
@@ -231,7 +231,7 @@ class Output {
|
|
|
231
231
|
on.start(this);
|
|
232
232
|
}
|
|
233
233
|
static configTunnel(tunnel) {
|
|
234
|
-
const on = new
|
|
234
|
+
const on = new tunnel_2.default(terminal, tunnel);
|
|
235
235
|
on.start(this);
|
|
236
236
|
}
|
|
237
237
|
static handleSignals() {
|
|
@@ -247,7 +247,8 @@ class Output {
|
|
|
247
247
|
}
|
|
248
248
|
static async confirm(message = 'Are you sure?') {
|
|
249
249
|
if (this.isStdInTTY()) {
|
|
250
|
-
|
|
250
|
+
const prompts = require('@inquirer/prompts');
|
|
251
|
+
return await prompts.confirm({
|
|
251
252
|
message,
|
|
252
253
|
theme: this.getInquirerTheme(),
|
|
253
254
|
default: false,
|
|
@@ -260,7 +261,8 @@ class Output {
|
|
|
260
261
|
}
|
|
261
262
|
static async inputString(message, def) {
|
|
262
263
|
if (this.isStdInTTY()) {
|
|
263
|
-
|
|
264
|
+
const prompts = require('@inquirer/prompts');
|
|
265
|
+
return await prompts.input({
|
|
264
266
|
message,
|
|
265
267
|
default: def,
|
|
266
268
|
theme: this.getInquirerTheme(),
|
|
@@ -276,8 +278,9 @@ class Output {
|
|
|
276
278
|
return '';
|
|
277
279
|
}
|
|
278
280
|
static async inputMenuAdv(message, items) {
|
|
281
|
+
const prompts = require('@inquirer/prompts');
|
|
279
282
|
if (this.isStdInTTY()) {
|
|
280
|
-
return await
|
|
283
|
+
return await prompts.select({
|
|
281
284
|
message,
|
|
282
285
|
theme: this.getInquirerTheme(),
|
|
283
286
|
loop: false,
|
|
@@ -287,7 +290,7 @@ class Output {
|
|
|
287
290
|
else {
|
|
288
291
|
this.cyan('? ', false);
|
|
289
292
|
this.normal(message, false);
|
|
290
|
-
const item = items.find((item) => !
|
|
293
|
+
const item = items.find((item) => !prompts.Separator.isSeparator(item) && !item.disabled);
|
|
291
294
|
if (item && item.name && item.value) {
|
|
292
295
|
this.cyan(` ${item.name}`);
|
|
293
296
|
return item.value;
|
|
@@ -315,7 +318,8 @@ class Output {
|
|
|
315
318
|
return this.getDimColor(`${domain} (Unavailable)`);
|
|
316
319
|
}
|
|
317
320
|
static createMenuSeparator(text) {
|
|
318
|
-
|
|
321
|
+
const prompts = require('@inquirer/prompts');
|
|
322
|
+
return new prompts.Separator(text);
|
|
319
323
|
}
|
|
320
324
|
static createMenuItem(name, value, description, disabled) {
|
|
321
325
|
const item = {
|
|
@@ -330,7 +334,8 @@ class Output {
|
|
|
330
334
|
}
|
|
331
335
|
static async inputMenu(message, items) {
|
|
332
336
|
if (this.isStdInTTY()) {
|
|
333
|
-
|
|
337
|
+
const prompts = require('@inquirer/prompts');
|
|
338
|
+
return await prompts.select({
|
|
334
339
|
message,
|
|
335
340
|
theme: this.getInquirerTheme(),
|
|
336
341
|
loop: false,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSshHostKey = void 0;
|
|
4
|
+
const createSshHostKey = () => {
|
|
5
|
+
const Ssh2 = require('ssh2');
|
|
6
|
+
const keys = Ssh2.utils.generateKeyPairSync('ed25519', {});
|
|
7
|
+
return keys.private;
|
|
8
|
+
};
|
|
9
|
+
exports.createSshHostKey = createSshHostKey;
|