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
|
};
|
|
@@ -42,10 +9,8 @@ const input_1 = __importDefault(require("../../input"));
|
|
|
42
9
|
const output_1 = __importDefault(require("../../output"));
|
|
43
10
|
const logger_1 = __importDefault(require("../../logger"));
|
|
44
11
|
const path_1 = require("path");
|
|
45
|
-
const uuid_1 = require("uuid");
|
|
46
12
|
const fs_1 = __importDefault(require("fs"));
|
|
47
13
|
const promises_1 = __importDefault(require("node:stream/promises"));
|
|
48
|
-
const unzipper_1 = __importStar(require("../../unzipper"));
|
|
49
14
|
const commandPackageDownload = (0, utils_1.newCommand)('download', texts_1.DESC_COMMAND_PACKAGE_DOWNLOAD);
|
|
50
15
|
commandPackageDownload.alias('dd');
|
|
51
16
|
commandPackageDownload.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
@@ -56,6 +21,9 @@ commandPackageDownload.argument('<identifier>', texts_1.OPTION_PACKAGE_ID);
|
|
|
56
21
|
commandPackageDownload.argument('<directory>', texts_1.OPTION_PACKAGE_DOWNLOAD_PATH);
|
|
57
22
|
commandPackageDownload.addHelpText('after', texts_1.EXAMPLE_PACKAGE_DOWNLOAD);
|
|
58
23
|
commandPackageDownload.action(async (id, path, options) => {
|
|
24
|
+
const { v4 } = require('uuid');
|
|
25
|
+
const ArchiverExtract = require('../../unzipper').default;
|
|
26
|
+
const { UNZIPPER_FORMAT } = require('../../unzipper');
|
|
59
27
|
const client = input_1.default.restApiTokenClient();
|
|
60
28
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
61
29
|
const project = input_1.default.restApiProject(options.project, true);
|
|
@@ -134,7 +102,7 @@ commandPackageDownload.action(async (id, path, options) => {
|
|
|
134
102
|
if (!empty && !options.merge) {
|
|
135
103
|
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_NOT_EMPTY_DIR)(dirPath));
|
|
136
104
|
}
|
|
137
|
-
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${
|
|
105
|
+
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${v4()}.zip`);
|
|
138
106
|
const clearZip = () => {
|
|
139
107
|
try {
|
|
140
108
|
fs_1.default.rmSync(zipPath);
|
|
@@ -151,7 +119,7 @@ commandPackageDownload.action(async (id, path, options) => {
|
|
|
151
119
|
output_1.default.normal(texts_1.TXT_PACKAGE_DOWNLOADED_ZIP);
|
|
152
120
|
output_1.default.normal(texts_1.TXT_PACKAGE_UNZIPPING);
|
|
153
121
|
let count = 0;
|
|
154
|
-
await
|
|
122
|
+
await ArchiverExtract.extract(UNZIPPER_FORMAT.ZIP, zipPath, dirPath, async () => {
|
|
155
123
|
count += 1;
|
|
156
124
|
output_1.default.clearPreviousLine();
|
|
157
125
|
output_1.default.normal((0, texts_1.TXT_PACKAGE_UNZIPPING_COUNT)(count));
|
|
@@ -8,10 +8,8 @@ const texts_1 = require("../../texts");
|
|
|
8
8
|
const input_1 = __importDefault(require("../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
10
|
const logger_1 = __importDefault(require("../../logger"));
|
|
11
|
-
const fflate_1 = __importDefault(require("fflate"));
|
|
12
11
|
const fs_1 = __importDefault(require("fs"));
|
|
13
12
|
const path_1 = require("path");
|
|
14
|
-
const uuid_1 = require("uuid");
|
|
15
13
|
const commandPackagePublish = (0, utils_1.newCommand)('publish', texts_1.DESC_COMMAND_PACKAGE_PUBLISH);
|
|
16
14
|
commandPackagePublish.alias('pub');
|
|
17
15
|
commandPackagePublish.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
@@ -22,13 +20,14 @@ commandPackagePublish.argument('<identifier>', texts_1.OPTION_PACKAGE_ID);
|
|
|
22
20
|
commandPackagePublish.argument('<directory>', texts_1.OPTION_PACKAGE_PUBLISH_PATH);
|
|
23
21
|
commandPackagePublish.addHelpText('after', texts_1.EXAMPLE_PACKAGE_PUBLISH);
|
|
24
22
|
commandPackagePublish.action(async (id, path, options) => {
|
|
23
|
+
const { v4 } = require('uuid');
|
|
25
24
|
let dirPath = input_1.default.resolvePath(path);
|
|
26
25
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
27
26
|
const project = input_1.default.restApiProject(options.project, true);
|
|
28
27
|
// eslint-disable-next-line prefer-const
|
|
29
28
|
let { identifier, version } = input_1.default.packageSplitIdentifier(id);
|
|
30
29
|
if (!version)
|
|
31
|
-
version =
|
|
30
|
+
version = v4();
|
|
32
31
|
const client = input_1.default.restApiTokenClient();
|
|
33
32
|
const data = await client.getPackageVersionByIdentifier(workspace, project, identifier, version);
|
|
34
33
|
if (!data || !data.domain) {
|
|
@@ -113,7 +112,7 @@ commandPackagePublish.action(async (id, path, options) => {
|
|
|
113
112
|
output_1.default.normal((0, texts_1.TXT_PACKAGE_ENTRIES_FOUND)(entries.length));
|
|
114
113
|
}
|
|
115
114
|
output_1.default.normal((0, texts_1.TXT_PACKAGE_ZIP_ENTRIES)(0));
|
|
116
|
-
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${
|
|
115
|
+
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${v4()}.zip`);
|
|
117
116
|
const clearZip = () => {
|
|
118
117
|
try {
|
|
119
118
|
fs_1.default.rmSync(zipPath);
|
|
@@ -154,6 +153,7 @@ commandPackagePublish.action(async (id, path, options) => {
|
|
|
154
153
|
}
|
|
155
154
|
});
|
|
156
155
|
const addEntryToZip = (dirPath, zip, entry) => {
|
|
156
|
+
const fflate = require('fflate');
|
|
157
157
|
return new Promise((resolve, reject) => {
|
|
158
158
|
const isDir = entry.isDirectory();
|
|
159
159
|
let name = (0, path_1.join)(entry.parentPath.replace(dirPath, ''), entry.name);
|
|
@@ -161,7 +161,7 @@ const addEntryToZip = (dirPath, zip, entry) => {
|
|
|
161
161
|
name += '/';
|
|
162
162
|
else
|
|
163
163
|
name = name.replace(/^\//, '');
|
|
164
|
-
const file = new
|
|
164
|
+
const file = new fflate.ZipDeflate(name, {
|
|
165
165
|
level: 3,
|
|
166
166
|
});
|
|
167
167
|
zip.add(file);
|
|
@@ -204,10 +204,11 @@ const addEntriesToZip = async (dirPath, zip, entries, onEntry) => {
|
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
206
|
const createZip = (dirPath, zipPath, entries, onEntry) => {
|
|
207
|
+
const fflate = require('fflate');
|
|
207
208
|
return new Promise((resolve, reject) => {
|
|
208
209
|
const ws = fs_1.default.createWriteStream(zipPath);
|
|
209
210
|
let wasError = false;
|
|
210
|
-
const zip = new
|
|
211
|
+
const zip = new fflate.Zip((err, data, final) => {
|
|
211
212
|
if (wasError) {
|
|
212
213
|
// do nothing
|
|
213
214
|
}
|
|
@@ -5,9 +5,9 @@ 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 output_1 = __importDefault(require("../output"));
|
|
8
|
-
const manager_1 = __importDefault(require("../agent/manager"));
|
|
9
|
-
const agent_1 = __importDefault(require("../tunnel/api/agent"));
|
|
10
8
|
const commandPre = async (_, command) => {
|
|
9
|
+
const AgentManager = require('../agent/manager').default;
|
|
10
|
+
const ApiAgent = require('../tunnel/api/agent').default;
|
|
11
11
|
command.agentStatus = null;
|
|
12
12
|
command.agentStandalone = false;
|
|
13
13
|
command.agentInstalled = false;
|
|
@@ -15,14 +15,14 @@ const commandPre = async (_, command) => {
|
|
|
15
15
|
command.agentId = '';
|
|
16
16
|
try {
|
|
17
17
|
if (!(0, utils_1.isDocker)()) {
|
|
18
|
-
const hasConfig =
|
|
18
|
+
const hasConfig = AgentManager.system.hasSystemConfig();
|
|
19
19
|
if (hasConfig) {
|
|
20
20
|
command.agentInstalled = true;
|
|
21
|
-
const json =
|
|
21
|
+
const json = AgentManager.system.loadSystemConfig();
|
|
22
22
|
command.agentStandalone = !!json.standalone; // nie zawsze to jest bool
|
|
23
23
|
command.agentId = json.id;
|
|
24
24
|
command.agentPort = json.port;
|
|
25
|
-
const api = new
|
|
25
|
+
const api = new ApiAgent(json.port);
|
|
26
26
|
command.agentStatus = await api.fetchStatus();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -7,7 +7,6 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const input_1 = __importDefault(require("../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const cfg_1 = __importDefault(require("../../project/cfg"));
|
|
11
10
|
const node_path_1 = require("node:path");
|
|
12
11
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
12
|
const commandProjectLink = (0, utils_1.newCommand)('link', texts_1.DESC_COMMAND_PROJECT_LINK);
|
|
@@ -17,10 +16,11 @@ commandProjectLink.option('-g, --git', texts_1.OPT_COMMAND_PROJECT_LINK_GIT);
|
|
|
17
16
|
commandProjectLink.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
17
|
commandProjectLink.argument('[directory]', texts_1.OPT_COMMAND_PROJECT_LINK_DIRECTORY);
|
|
19
18
|
commandProjectLink.action(async (dir, options) => {
|
|
19
|
+
const ProjectCfg = require('../../project/cfg').default;
|
|
20
20
|
output_1.default.handleSignals();
|
|
21
21
|
const { path, git } = await checkPath(dir, options);
|
|
22
22
|
const { workspace, project, url } = await createOrGetProject(path, 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
26
|
output_1.default.light(` ${url}`);
|
|
@@ -154,6 +154,7 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
154
154
|
});
|
|
155
155
|
};
|
|
156
156
|
const checkPath = async (dir, options) => {
|
|
157
|
+
const ProjectCfg = require('../../project/cfg').default;
|
|
157
158
|
if (!dir)
|
|
158
159
|
dir = './';
|
|
159
160
|
const path = (0, node_path_1.resolve)(dir);
|
|
@@ -173,7 +174,7 @@ const checkPath = async (dir, options) => {
|
|
|
173
174
|
output_1.default.exitError((0, texts_1.ERR_COMMAND_PROJECT_LINK_DIR_CREATE)(path));
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
|
-
if (
|
|
177
|
+
if (ProjectCfg.exists(path)) {
|
|
177
178
|
output_1.default.yellow(texts_1.TXT_COMMAND_PROJECT_LINK_DIR_LINKED);
|
|
178
179
|
let relink = options.relink;
|
|
179
180
|
if (!relink) {
|
|
@@ -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,9 @@ const utils_1 = require("../../utils");
|
|
|
40
7
|
const texts_1 = require("../../texts");
|
|
41
8
|
const output_1 = __importDefault(require("../../output"));
|
|
42
9
|
const input_1 = __importDefault(require("../../input"));
|
|
43
|
-
const fdir_1 = require("fdir");
|
|
44
10
|
const path_1 = require("path");
|
|
45
11
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
46
|
-
const uuid_1 = require("uuid");
|
|
47
12
|
const promises_1 = __importDefault(require("node:stream/promises"));
|
|
48
|
-
const unzipper_1 = __importStar(require("../../unzipper"));
|
|
49
13
|
const commandSandboxCp = (0, utils_1.newCommand)('cp', texts_1.DESC_COMMAND_SANDBOX_CP);
|
|
50
14
|
commandSandboxCp.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
51
15
|
commandSandboxCp.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
@@ -55,6 +19,7 @@ commandSandboxCp.argument('<source>', texts_1.OPTION_SANDBOX_CP_SOURCE);
|
|
|
55
19
|
commandSandboxCp.argument('<destination>', texts_1.OPTION_SANDBOX_CP_DEST);
|
|
56
20
|
commandSandboxCp.addHelpText('after', texts_1.EXAMPLE_SANDBOX_CP);
|
|
57
21
|
const upload = async (client, workspace, project, source, destination) => {
|
|
22
|
+
const { fdir } = require('fdir');
|
|
58
23
|
const { sourcePath, sourceStats } = input_1.default.restApiSandboxUploadSourcePath(source);
|
|
59
24
|
const { identifier, remotePath, isRemoteDir } = input_1.default.restApiSandboxUploadDestinationPath(destination);
|
|
60
25
|
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
@@ -71,7 +36,7 @@ const upload = async (client, workspace, project, source, destination) => {
|
|
|
71
36
|
}
|
|
72
37
|
else if (sourceStats.isDirectory()) {
|
|
73
38
|
// Directory copy - get all files recursively
|
|
74
|
-
const files = new
|
|
39
|
+
const files = new fdir()
|
|
75
40
|
.withFullPaths()
|
|
76
41
|
.crawl(sourcePath)
|
|
77
42
|
.sync();
|
|
@@ -97,6 +62,9 @@ const upload = async (client, workspace, project, source, destination) => {
|
|
|
97
62
|
}
|
|
98
63
|
};
|
|
99
64
|
const download = async (client, workspace, project, source, destination, merge, replace) => {
|
|
65
|
+
const { v4 } = require('uuid');
|
|
66
|
+
const ArchiverExtract = require('../../unzipper').default;
|
|
67
|
+
const { UNZIPPER_FORMAT } = require('../../unzipper');
|
|
100
68
|
const { destPath, isDestPathDir } = input_1.default.restApiSandboxDownloadDestinationPath(destination, merge, replace);
|
|
101
69
|
const { sourcePath, identifier } = input_1.default.restApiSandboxDownloadSourcePath(source);
|
|
102
70
|
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
@@ -116,7 +84,7 @@ const download = async (client, workspace, project, source, destination, merge,
|
|
|
116
84
|
}
|
|
117
85
|
else {
|
|
118
86
|
const destDirPath = isDestPathDir ? (0, path_1.join)(destPath, name) : destPath;
|
|
119
|
-
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${
|
|
87
|
+
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${v4()}.tar.gz`);
|
|
120
88
|
const clearZip = () => {
|
|
121
89
|
try {
|
|
122
90
|
node_fs_1.default.rmSync(zipPath);
|
|
@@ -131,7 +99,7 @@ const download = async (client, workspace, project, source, destination, merge,
|
|
|
131
99
|
output_1.default.normal(texts_1.TXT_SANDBOX_CP_DOWNLOAD_DONE);
|
|
132
100
|
output_1.default.normal(texts_1.TXT_SANDBOX_UNZIP);
|
|
133
101
|
let count = 0;
|
|
134
|
-
await
|
|
102
|
+
await ArchiverExtract.extract(UNZIPPER_FORMAT.TAR_GZ, zipPath, destDirPath, async () => {
|
|
135
103
|
count += 1;
|
|
136
104
|
output_1.default.clearPreviousLine();
|
|
137
105
|
output_1.default.normal((0, texts_1.TXT_SANDBOX_UNZIPPING_COUNT)(count));
|
|
@@ -7,7 +7,6 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
9
|
const input_1 = __importDefault(require("../../input"));
|
|
10
|
-
const human_id_1 = __importDefault(require("human-id"));
|
|
11
10
|
const VALID_RESOURCES = [
|
|
12
11
|
'1x2',
|
|
13
12
|
'2x4',
|
|
@@ -41,6 +40,7 @@ commandSandboxCreate.option('--wait-for-configured [seconds]', texts_1.OPTION_SA
|
|
|
41
40
|
commandSandboxCreate.option('--wait-for-apps [seconds]', texts_1.OPTION_SANDBOX_WAIT_APPS);
|
|
42
41
|
commandSandboxCreate.addHelpText('after', texts_1.EXAMPLE_SANDBOX_CREATE);
|
|
43
42
|
commandSandboxCreate.action(async (options) => {
|
|
43
|
+
const humanId = require('human-id').default;
|
|
44
44
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
45
45
|
const project = input_1.default.restApiProject(options.project);
|
|
46
46
|
const client = input_1.default.restApiTokenClient();
|
|
@@ -58,7 +58,7 @@ commandSandboxCreate.action(async (options) => {
|
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
60
|
const timestamp = Date.now().toString(36);
|
|
61
|
-
const baseName = (
|
|
61
|
+
const baseName = humanId({ separator: '-', capitalize: false });
|
|
62
62
|
const defaultIdentifier = `${baseName}-${timestamp}`;
|
|
63
63
|
const body = {
|
|
64
64
|
name: options.name || options.identifier || baseName,
|
|
@@ -7,7 +7,6 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
9
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
-
const human_id_1 = __importDefault(require("human-id"));
|
|
11
10
|
const commandSandboxSnapshotCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_CREATE);
|
|
12
11
|
commandSandboxSnapshotCreate.alias('add');
|
|
13
12
|
commandSandboxSnapshotCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
@@ -17,6 +16,7 @@ commandSandboxSnapshotCreate.argument('<identifier>', texts_1.OPTION_SANDBOX_IDE
|
|
|
17
16
|
commandSandboxSnapshotCreate.option('--wait [seconds]', texts_1.OPTION_SANDBOX_WAIT);
|
|
18
17
|
commandSandboxSnapshotCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_SNAPSHOT_CREATE}`);
|
|
19
18
|
commandSandboxSnapshotCreate.action(async (identifier, options) => {
|
|
19
|
+
const humanId = require('human-id').default;
|
|
20
20
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
21
21
|
const project = input_1.default.restApiProject(options.project);
|
|
22
22
|
const client = input_1.default.restApiTokenClient();
|
|
@@ -24,7 +24,7 @@ commandSandboxSnapshotCreate.action(async (identifier, options) => {
|
|
|
24
24
|
if (!sandbox_id) {
|
|
25
25
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
26
26
|
}
|
|
27
|
-
const defaultName = 'snapshot-' + (
|
|
27
|
+
const defaultName = 'snapshot-' + humanId({ separator: '-', capitalize: false });
|
|
28
28
|
const snapshotName = options.name || defaultName;
|
|
29
29
|
const body = {
|
|
30
30
|
name: snapshotName,
|
|
@@ -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') {
|
|
@@ -4,12 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
|
-
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
8
7
|
const output_1 = __importDefault(require("../../output"));
|
|
9
8
|
const texts_1 = require("../../texts");
|
|
10
|
-
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
11
9
|
const tunnel_1 = require("../../types/tunnel");
|
|
12
|
-
const input_1 = __importDefault(require("../../input"));
|
|
13
10
|
const commandHttp = (0, utils_1.getBasicCommandHttp)();
|
|
14
11
|
commandHttp.description(texts_1.DESC_COMMAND_HTTP);
|
|
15
12
|
commandHttp.option('-s, --serve <directory>', texts_1.OPTION_SERVE);
|
|
@@ -17,15 +14,18 @@ commandHttp.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
|
17
14
|
commandHttp.argument('[protocol://host:port]', texts_1.OPTION_TARGET);
|
|
18
15
|
commandHttp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(false)}`);
|
|
19
16
|
commandHttp.action(async (target, options) => {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
17
|
+
const ApiBuddy = require('../../tunnel/api/buddy').default;
|
|
18
|
+
const Input = require('../../input').default;
|
|
19
|
+
const Cfg = require('../../tunnel/cfg').default;
|
|
20
|
+
const { host, token } = await Input.tunnelToken(options.token);
|
|
21
|
+
const prepared = await Cfg.prepareTunnel(tunnel_1.TUNNEL_TYPE.HTTP, target, options, true);
|
|
22
22
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
23
|
-
const agent = await
|
|
24
|
-
|
|
23
|
+
const agent = await ApiBuddy.register(false, false, true, false, host, token, [], (region) => {
|
|
24
|
+
Cfg.setRegionIfNotSet(region);
|
|
25
25
|
});
|
|
26
26
|
await agent.start();
|
|
27
27
|
agent.startRefreshingConfiguration();
|
|
28
|
-
const tunnel = await
|
|
28
|
+
const tunnel = await ApiBuddy.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
29
29
|
agent.addTunnel(tunnel);
|
|
30
30
|
output_1.default.tunnel(tunnel);
|
|
31
31
|
});
|
|
@@ -3,29 +3,29 @@ 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 cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
7
6
|
const output_1 = __importDefault(require("../../output"));
|
|
8
7
|
const texts_1 = require("../../texts");
|
|
9
|
-
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
10
8
|
const utils_1 = require("../../utils");
|
|
11
|
-
const input_1 = __importDefault(require("../../input"));
|
|
12
9
|
const commandStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_START);
|
|
13
10
|
commandStart.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
14
11
|
commandStart.argument('<name>', texts_1.OPTION_NAME);
|
|
15
12
|
commandStart.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TUNNEL_START}`);
|
|
16
13
|
commandStart.action(async (name, options) => {
|
|
17
|
-
|
|
14
|
+
const ApiBuddy = require('../../tunnel/api/buddy').default;
|
|
15
|
+
const Input = require('../../input').default;
|
|
16
|
+
const Cfg = require('../../tunnel/cfg').default;
|
|
17
|
+
if (!Cfg.hasTunnel(name)) {
|
|
18
18
|
output_1.default.exitError((0, texts_1.ERR_TUNNEL_NOT_FOUND)(name));
|
|
19
19
|
}
|
|
20
|
-
const { token, host } = await
|
|
21
|
-
const prepared =
|
|
20
|
+
const { token, host } = await Input.tunnelToken(options.token);
|
|
21
|
+
const prepared = Cfg.getTunnel(name);
|
|
22
22
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
23
|
-
const agent = await
|
|
24
|
-
|
|
23
|
+
const agent = await ApiBuddy.register(false, false, true, false, host, token, [], (region) => {
|
|
24
|
+
Cfg.setRegionIfNotSet(region);
|
|
25
25
|
});
|
|
26
26
|
await agent.start();
|
|
27
27
|
agent.startRefreshingConfiguration();
|
|
28
|
-
const tunnel = await
|
|
28
|
+
const tunnel = await ApiBuddy.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
29
29
|
agent.addTunnel(tunnel);
|
|
30
30
|
output_1.default.tunnel(tunnel);
|
|
31
31
|
});
|
|
@@ -4,27 +4,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
|
-
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
8
7
|
const output_1 = __importDefault(require("../../output"));
|
|
9
8
|
const texts_1 = require("../../texts");
|
|
10
|
-
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
11
9
|
const tunnel_1 = require("../../types/tunnel");
|
|
12
|
-
const input_1 = __importDefault(require("../../input"));
|
|
13
10
|
const commandTcp = (0, utils_1.getBasicCommandTcp)();
|
|
14
11
|
commandTcp.description(texts_1.DESC_COMMAND_TCP);
|
|
15
12
|
commandTcp.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
16
13
|
commandTcp.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
17
14
|
commandTcp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TCP)(false)}`);
|
|
18
15
|
commandTcp.action(async (target, options) => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
16
|
+
const ApiBuddy = require('../../tunnel/api/buddy').default;
|
|
17
|
+
const Input = require('../../input').default;
|
|
18
|
+
const Cfg = require('../../tunnel/cfg').default;
|
|
19
|
+
const { host, token } = await Input.tunnelToken(options.token);
|
|
20
|
+
const prepared = await Cfg.prepareTunnel(tunnel_1.TUNNEL_TYPE.TCP, target, options, true);
|
|
21
21
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
22
|
-
const agent = await
|
|
23
|
-
|
|
22
|
+
const agent = await ApiBuddy.register(false, false, true, false, host, token, [], (region) => {
|
|
23
|
+
Cfg.setRegionIfNotSet(region);
|
|
24
24
|
});
|
|
25
25
|
await agent.start();
|
|
26
26
|
agent.startRefreshingConfiguration();
|
|
27
|
-
const tunnel = await
|
|
27
|
+
const tunnel = await ApiBuddy.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
28
28
|
agent.addTunnel(tunnel);
|
|
29
29
|
output_1.default.tunnel(tunnel);
|
|
30
30
|
});
|
|
@@ -4,27 +4,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
|
-
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
8
7
|
const output_1 = __importDefault(require("../../output"));
|
|
9
8
|
const texts_1 = require("../../texts");
|
|
10
|
-
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
11
9
|
const tunnel_1 = require("../../types/tunnel");
|
|
12
|
-
const input_1 = __importDefault(require("../../input"));
|
|
13
10
|
const commandTls = (0, utils_1.getBasicCommandTls)();
|
|
14
11
|
commandTls.description(texts_1.DESC_COMMAND_TLS);
|
|
15
12
|
commandTls.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
16
13
|
commandTls.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
17
14
|
commandTls.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TLS)(false)}`);
|
|
18
15
|
commandTls.action(async (target, options) => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
16
|
+
const ApiBuddy = require('../../tunnel/api/buddy').default;
|
|
17
|
+
const Input = require('../../input').default;
|
|
18
|
+
const Cfg = require('../../tunnel/cfg').default;
|
|
19
|
+
const { token, host } = await Input.tunnelToken(options.token);
|
|
20
|
+
const prepared = await Cfg.prepareTunnel(tunnel_1.TUNNEL_TYPE.TLS, target, options, true);
|
|
21
21
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
22
|
-
const agent = await
|
|
23
|
-
|
|
22
|
+
const agent = await ApiBuddy.register(false, false, true, false, host, token, [], (region) => {
|
|
23
|
+
Cfg.setRegionIfNotSet(region);
|
|
24
24
|
});
|
|
25
25
|
await agent.start();
|
|
26
26
|
agent.startRefreshingConfiguration();
|
|
27
|
-
const tunnel = await
|
|
27
|
+
const tunnel = await ApiBuddy.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
28
28
|
agent.addTunnel(tunnel);
|
|
29
29
|
output_1.default.tunnel(tunnel);
|
|
30
30
|
});
|