bdy 1.14.10-dev-package → 1.14.10-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 +8 -2
- package/distTs/src/agent/system.js +26 -4
- package/distTs/src/api/client.js +25 -102
- package/distTs/src/command/agent/install.js +18 -1
- package/distTs/src/command/agent/run.js +1 -1
- package/distTs/src/command/agent/uninstall.js +6 -0
- package/distTs/src/command/pipeline/run.js +3 -3
- package/distTs/src/command/vt/scrap.js +193 -0
- package/distTs/src/index.js +0 -2
- package/distTs/src/input.js +1 -19
- package/distTs/src/output.js +2 -5
- package/distTs/src/texts.js +12 -60
- package/distTs/src/tunnel/server/ssh.js +9 -0
- package/package.json +1 -1
- package/distTs/src/command/package/download.js +0 -259
- package/distTs/src/command/package/publish.js +0 -229
- package/distTs/src/command/package.js +0 -14
package/distTs/src/texts.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ERR_SWW_AGENT_UPDATING = exports.ERR_SWW_AGENT_DISABLING = exports.ERR_SWW_AGENT_ENABLING = exports.ERR_AGENT_NOT_FOUND = exports.ERR_AGENT_NOT_RUNNING = exports.ERR_AGENT_NOT_ENABLED = exports.ERR_TUNNEL_NOT_FOUND = exports.ERR_WHITELIST_IS_NOT_VALID = exports.ERR_USER_AGENT_IS_NOT_VALID = exports.ERR_BA_IS_NOT_VALID = exports.ERR_BA_LOGIN_NOT_PROVIDED = exports.ERR_BA_PASSWORD_NOT_PROVIDED = exports.ERR_CB_THRESHOLD_IS_NOT_VALID = exports.ERR_CERT_PATH_IS_NOT_VALID = exports.ERR_KEY_PATH_IS_NOT_VALID = exports.ERR_CA_PATH_IS_NOT_VALID = exports.ERR_WRONG_CA = exports.ERR_WRONG_KEY_CERT = exports.ERR_NAME_WITHOUT_ASTERISK = exports.ERR_PORT_IS_NOT_VALID = exports.ERR_REGION_IS_NOT_VALID = exports.ERR_PATH_IS_NOT_DIRECTORY = exports.ERR_DIRECTORY_DOES_NOT_EXISTS = exports.ERR_TERMINATE_IS_NOT_VALID = exports.ERR_TIMEOUT_IS_NOT_VALID = exports.ERR_TYPE_IS_NOT_VALID = exports.ERR_TARGET_IS_NOT_VALID = exports.ERR_SAVING_AGENT_CONFIG = exports.ERR_AGENT_NOT_REGISTERED = exports.ERR_RUN_PIPELINE_WRONG_VARIABLE = exports.ERR_RUN_PIPELINE_WRONG_ACTION = exports.ERR_RUN_PIPELINE_WRONG_DELAY = exports.ERR_RUN_PIPELINE_WRONG_PRIORITY = exports.ERR_RUN_PIPELINE_WAIT_TIMEOUT = exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.DEBUG_WAIT_FOR_IDLE_TIMEOUT = exports.DEBUG_WAIT_FOR_IDLE = exports.DEBUG_RESOURCE_DISCOVERY_TIMEOUT = exports.DEBUG_AUTO_WIDTH = exports.DEBUG_AUTO_SCROLL = exports.DEBUG_RESOURCE_SCRAPPING_URL = exports.DEBUG_SNAPSHOT_PROCESSING = exports.DEBUG_SNAPSHOTS_PROCESSING = exports.DEBUG_EXEC_COMMAND = exports.DEBUG_EXEC_TEST_COMMAND = exports.LOG_INSTALLED_BROWSER = exports.LOG_SESSION_LINK = exports.LOG_SENDING_DATA = exports.LOG_SENDING_REQUEST = exports.LOG_PROCESSING_SNAPSHOTS = exports.LOG_RUNNING_EXEC_COMMAND = exports.LOG_TUNNEL_SSH_STREAM = exports.LOG_TUNNEL_TLS_AGENT_STREAM = exports.LOG_TUNNEL_TLS_REGION_STREAM = exports.LOG_TUNNEL_TLS_TARGET_STREAM = exports.LOG_TUNNEL_HTTP2_STREAM = exports.LOG_TUNNEL_HTTP1_STREAM = exports.LOG_TUNNEL_TCP_STREAM = exports.LOG_TUNNEL_HTTP_WRONG_USER_AGENTS = exports.LOG_TUNNEL_HTTP_CIRCUIT_BREAKER_OPEN = exports.LOG_TUNNEL_HTTP_RATE_LIMIT = exports.LOG_TUNNEL_HTTP_WRON_AUTH = exports.LOG_TUNNEL_IDENTIFIED = exports.LOG_TUNNEL_DISCONNECTED = exports.LOG_TUNNEL_FAILED = exports.LOG_TUNNEL_CONNECTED = exports.LOG_AGENT_STARTED = exports.LOG_AGENT_SERVER_STARTED = exports.LOG_ERROR_STARTING_AGENT_SERVER = exports.LOG_SSH_CONNECTION = exports.LOG_WRONG_STREAM = void 0;
|
|
3
|
+
exports.ERR_FAILED_TO_CONNECT = exports.ERR_TUNNEL_ALREADY_EXISTS = exports.ERR_AGENT_NOT_SUPPORTED = exports.ERR_AGENT_ADMIN_RIGHTS = exports.ERR_AGENT_ENABLE = exports.ERR_SWW_AGENT_UPDATING = exports.ERR_SWW_AGENT_DISABLING = exports.ERR_SWW_AGENT_ENABLING = exports.ERR_AGENT_NOT_FOUND = exports.ERR_AGENT_NOT_RUNNING = exports.ERR_AGENT_NOT_ENABLED = exports.ERR_TUNNEL_NOT_FOUND = exports.ERR_WHITELIST_IS_NOT_VALID = exports.ERR_USER_AGENT_IS_NOT_VALID = exports.ERR_BA_IS_NOT_VALID = exports.ERR_BA_LOGIN_NOT_PROVIDED = exports.ERR_BA_PASSWORD_NOT_PROVIDED = exports.ERR_CB_THRESHOLD_IS_NOT_VALID = exports.ERR_CERT_PATH_IS_NOT_VALID = exports.ERR_KEY_PATH_IS_NOT_VALID = exports.ERR_CA_PATH_IS_NOT_VALID = exports.ERR_WRONG_CA = exports.ERR_WRONG_KEY_CERT = exports.ERR_NAME_WITHOUT_ASTERISK = exports.ERR_PORT_IS_NOT_VALID = exports.ERR_REGION_IS_NOT_VALID = exports.ERR_PATH_IS_NOT_DIRECTORY = exports.ERR_DIRECTORY_DOES_NOT_EXISTS = exports.ERR_TERMINATE_IS_NOT_VALID = exports.ERR_TIMEOUT_IS_NOT_VALID = exports.ERR_TYPE_IS_NOT_VALID = exports.ERR_TARGET_IS_NOT_VALID = exports.ERR_SAVING_AGENT_CONFIG = exports.ERR_AGENT_NOT_REGISTERED = exports.ERR_RUN_PIPELINE_WRONG_VARIABLE = exports.ERR_RUN_PIPELINE_WRONG_ACTION = exports.ERR_RUN_PIPELINE_WRONG_DELAY = exports.ERR_RUN_PIPELINE_WRONG_PRIORITY = exports.ERR_RUN_PIPELINE_WAIT_TIMEOUT = exports.ERR_RUN_PIPELINE_NOT_FOUND = exports.ERR_RUN_PIPELINE_PROJECT_NOT_FOUND = exports.ERR_RUN_PIPELINE_WORKSPACE_NOT_FOUND = exports.ERR_REST_API_PROJECT = exports.ERR_REST_API_WORKSPACE = exports.ERR_REST_API_URL = exports.ERR_REST_API_TOKEN = exports.ERR_REST_API_RATE_LIMIT = exports.ERR_REST_API_RESOURCE_NOT_FOUND = exports.ERR_REST_API_WRONG_TOKEN = exports.ERR_REST_API_GENERAL_ERROR = void 0;
|
|
4
|
+
exports.TXT_AGENT_IS_ENABLED_AND_STARTED = exports.TXT_AGENT_RESTARTED = exports.TXT_AGENT_DEBUG_OFF = exports.TXT_AGENT_DEBUG_ON = exports.TXT_AGENT_STARTED = exports.TXT_AGENT_STOPPED = exports.WARN_BROWSER_VERSION = exports.ERR_RESOURCE_DISCOVERY = exports.ERR_NO_SNAPSHOTS_TO_SEND = exports.ERR_INVALID_SNAPSHOT = exports.ERR_TEST_EXECUTION = exports.ERR_INVALID_JSON = exports.ERR_INVALID_DOWNLOAD_RESPONSE = exports.ERR_INVALID_SCRAPE_RESPONSE = exports.ERR_INVALID_COMPARE_LINKS_RESPONSE = exports.ERR_INVALID_STORYBOOK_RESPONSE = exports.ERR_INVALID_DEFAULT_SETTINGS_RESPONSE = exports.ERR_INVALID_CLOSE_SESSION_RESPONSE = exports.ERR_INVALID_SNAPSHOTS_RESPONSE = exports.ERR_INVALID_SNAPSHOT_RESPONSE = exports.ERR_MISSING_URLS = exports.ERR_RESOURCE_NOT_FOUND = exports.ERR_MISSING_EXEC_COMMAND = exports.ERR_PARSING_STORIES = exports.ERR_UNSUPPORTED_STORYBOOK = exports.ERR_MISSING_STORYBOOK_INDEX_FILE = exports.ERR_WRONG_STORYBOOK_DIRECTORY = exports.ERR_MISSING_BUILD_ID = exports.ERR_MISSING_UT_TOKEN = exports.ERR_MISSING_VT_TOKEN = exports.ERR_CONFIG_CORRUPTED = exports.ERR_WRONG_TOKEN = exports.ERR_TOKEN_NOT_PROVIDED = exports.ERR_CANT_CREATE_DIR_IN_HOME = exports.ERR_CONNECTION_ERROR = exports.ERR_CONNECTION_TIMEOUT = exports.ERR_WRONG_STREAM = exports.ERR_WRONG_HANDSHAKE = exports.ERR_FETCH_VERSION = exports.ERR_SWW = exports.ERR_NOT_FOUND = exports.ERR_FAILED_TO_CONNECT_TO_AGENT = exports.ERR_TUNNEL_REMOVED = exports.ERR_TUNNELS_DISABLED = exports.ERR_AGENT_LIMIT_REACHED = exports.ERR_TUNNEL_TARGET_INVALID = exports.ERR_WORKSPACE_FLAGGED = exports.ERR_TUNNEL_LIMIT_REACHED = exports.ERR_DOMAIN_RESTRICTED = exports.ERR_AGENT_REMOVED = void 0;
|
|
5
|
+
exports.DESC_COMMAND_AGENT_STATUS = exports.DESC_COMMAND_AGENT_RESTART = exports.DESC_COMMAND_AGENT_ENABLE = exports.DESC_COMMAND_AGENT_DEBUG = exports.DESC_COMMAND_AGENT_DISABLE = exports.DESC_COMMAND_AGENT_START = exports.DESC_COMMAND_AGENT_INSTALL = exports.DESC_COMMAND_AGENT_UNINSTALL = exports.DESC_COMMAND_AGENT_TUNNEL_REMOVE = exports.DESC_COMMAND_AGENT_TUNNEL_STATUS = exports.DESC_COMMAND_AGENT_TUNNEL_LIST = exports.DESC_COMMAND_CONFIG_SET = exports.DESC_COMMAND_CONFIG_REMOVE = exports.DESC_COMMAND_CONFIG_GET = exports.DESC_COMMAND_CONFIG_ADD = exports.DESC_COMMAND_CONFIG_SET_WHITELIST = exports.DESC_COMMAND_CONFIG_SET_TOKEN = exports.DESC_COMMAND_CONFIG_SET_TIMEOUT = exports.DESC_COMMAND_CONFIG_SET_REGION = exports.DESC_COMMAND_CONFIG_REMOVE_TUNNEL = exports.DESC_COMMAND_CONFIG_GET_WHITELIST = exports.DESC_COMMAND_CONFIG_GET_TUNNELS = exports.DESC_COMMAND_CONFIG_GET_TUNNEL = exports.DESC_COMMAND_CONFIG_GET_TOKEN = exports.DESC_COMMAND_CONFIG_GET_TIMEOUT = exports.DESC_COMMAND_CONFIG_GET_REGION = exports.DESC_COMMAND_CONFIG_ADD_TLS = exports.DESC_COMMAND_CONFIG_ADD_TCP = exports.DESC_COMMAND_CONFIG_ADD_HTTP = exports.AGENT_FETCH_RETRY = exports.NO_TUNNELS_STARTED = exports.TXT_TUNNEL_ADDED = exports.TXT_TUNNEL_REMOVED = exports.TXT_REGION_SAVED = exports.TXT_TIMEOUT_SAVED = exports.TXT_TOKEN_REMOVED = exports.TXT_TOKEN_SAVED = exports.TXT_WHITELIST_SAVED = exports.TXT_TUNNEL_STOPPED = exports.TXT_TUNNEL_STARTED = exports.TXT_AGENT_DISABLED = exports.TXT_AGENT_ALREADY_ENABLED = exports.TXT_AGENT_UPDATED = exports.TXT_AGENT_ENABLED = exports.TXT_AGENT_TARGET_DISABLED = exports.TXT_AGENT_TARGET_ENABLED = exports.TXT_AGENT_IS_DISABLED = exports.TXT_AGENT_IS_ENABLED_AND_HAVE_TROUBLES = exports.TXT_AGENT_IS_ENABLED_AND_INITIALIZING = exports.TXT_AGENT_IS_ENABLED_AND_STOPPED = void 0;
|
|
6
|
+
exports.OPTION_PIPELINE_RUN_REVISION = exports.OPTION_PIPELINE_RUN_TAG = exports.OPTION_PIPELINE_RUN_BRANCH = exports.OPTION_REST_API_REGION = exports.OPTION_REST_API_ENDPOINT = exports.OPTION_DEFAULT_REGION = exports.OPTION_REGION = exports.TXT_PIPELINE_RUN_FINISH_FAILED = exports.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY = exports.TXT_STORIES_AMOUNT = exports.TXT_PIPELINE_RUN_STILL_WAITING = exports.TXT_PIPELINE_RUN_WAIT = exports.TXT_PIPELINE_RUN_SUCCESS = exports.TXT_OPENING_TUNNEL = exports.TXT_UPDATING_AGENT = exports.TXT_ENABLING_AGENT = exports.TXT_DISABLING_AGENT = exports.TXT_NEW_AGENT_VERSION = exports.TXT_NEW_CLI_VERSION = exports.TXT_NEW_CLI_DOCKER_VERSION = exports.OPTION_UPLOAD_DRY_RUN = exports.OPTION_UPLOAD_REPORT_FORMAT = exports.OPTION_UPLOAD_REPORT_GLOB = exports.DESC_COMMAND_UT_UPLOAD = exports.DESC_COMMAND_UT = exports.DESC_COMMAND_VT_INSTALL_BROWSER = exports.DESC_COMMAND_VT_EXEC = exports.DESC_COMMAND_VT_SCRAPE = exports.DESC_COMMAND_VT_COMPARE = exports.DESC_COMMAND_VT_STORYBOOK = exports.DESC_COMMAND_VT_CLOSE = exports.DESC_COMMAND_VT = exports.DESC_COMMAND_PIPELINE_RUN = exports.DESC_COMMAND_PIPELINE = exports.DESC_PROGRAM = exports.DESC_COMMAND_TLS = exports.DESC_COMMAND_TCP = exports.DESC_COMMAND_START = exports.DESC_COMMAND_TUNNEL = exports.DESC_COMMAND_AGENT = exports.DESC_COMMAND_HTTP = exports.DESC_COMMAND_CONFIG = exports.DESC_COMMAND_AGENT_VERSION = exports.DESC_COMMAND_AGENT_UPDATE = exports.DESC_COMMAND_AGENT_TARGET = exports.DESC_COMMAND_AGENT_TUNNEL = exports.DESC_COMMAND_AGENT_STOP = exports.DESC_COMMAND_AGENT_TARGET_DISABLE = exports.DESC_COMMAND_AGENT_TARGET_ENABLE = exports.DESC_COMMAND_AGENT_TARGET_STATUS = void 0;
|
|
7
|
+
exports.OPTION_COMPARE_FOLLOW = exports.OPTION_EXEC_PARALLEL = exports.OPTION_EXEC_ONE_BY_ONE = exports.OPTION_EXEC_SKIP_DISCOVERY = exports.OPTION_EXEC_COMMAND = exports.OPTION_AGENT_DEBUG = exports.OPTION_AGENT_PORT = exports.OPTION_AGENT_TARGET = exports.OPTION_PASS = exports.OPTION_USER = exports.OPTION_AGENT_TOKEN = exports.OPTION_AGENT_START = exports.OPTION_AGENT_ID = exports.OPTION_ID = exports.OPTION_NAME = exports.OPTION_TARGET = exports.OPTION_TLS_TERMINATE = exports.OPTION_TLS_CA = exports.OPTION_TLS_CERT = exports.OPTION_TLS_KEY = exports.OPTION_HTTP_CIRCUIT_BREAKER = exports.OPTION_HTTP_COMPRESSION = exports.OPTION_HTTP_2 = exports.OPTION_HTTP_VERIFY = exports.OPTION_HTTP_LOG = exports.OPTION_HTTP_AUTH_BUDDY = exports.OPTION_HTTP_AUTH = exports.OPTION_HTTP_HOST = exports.OPTION_FORCE = exports.OPTION_TOKEN = exports.OPTION_TIMEOUT = exports.OPTION_FOLLOW = exports.OPTION_SERVE = exports.OPTION_HEADER_USER_AGENT = exports.OPTION_RESPONSE_HEADER = exports.OPTION_HEADER = exports.OPTION_WHITELIST = exports.OPTION_REST_API_PROJECT = exports.OPTION_REST_API_WORKSPACE = exports.OPTION_PIPELINE_RUN_WAIT = exports.OPTION_PIPELINE_RUN_ACTION = exports.OPTION_REST_API_TOKEN = exports.OPTION_PIPELINE_RUN_ARGUMENT = exports.OPTION_PIPELINE_RUN_DELAY = exports.OPTION_PIPELINE_RUN_VAR = exports.OPTION_PIPELINE_RUN_PRIORITY = exports.OPTION_PIPELINE_RUN_CLEAR_CACHE = exports.OPTION_PIPELINE_RUN_REFRESH = exports.OPTION_PIPELINE_RUN_COMMENT = exports.OPTION_PIPELINE_RUN_PULL_REQUEST = void 0;
|
|
8
|
+
exports.LOG_REGISTERING_TUNNEL = exports.LOG_GETTING_AGENT = exports.LOG_UNREGISTERING_AGENT = exports.LOG_REGION_DETECTED = exports.LOG_AGENT_REGISTERED = exports.LOG_SOCKET_DISCONNECTED = exports.LOG_SOCKET_CONNECTED = exports.LOG_AGENT_NSSM_CLEARING = exports.LOG_AGENT_NSSM_EXTRACTING = exports.LOG_AGENT_NSSM_DOWNLOADING = exports.LOG_AGENT_ENABLED = exports.LOG_AGENT_STARTING_SYSTEM = exports.LOG_AGENT_STOPPING_SYSTEM = exports.LOG_AGENT_ENABLING_SYSTEM = exports.LOG_AGENT_SYSTEM_SERVICE_CONFIG = exports.LOG_AGENT_EXTRACTING_ARCHIVE = exports.LOG_AGENT_DOWNLOADING_ARCHIVE = exports.LOG_AGENT_SYSTEM_DIR = exports.LOG_ERROR_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_ERROR_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_ERROR_SAVING_AGENT_CONFIG = exports.LOG_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_SAVING_AGENT_CONFIG = exports.LOG_REGISTERING_AGENT = exports.OPTION_SCRAPE_OUTPUT_DIR = exports.OPTION_SCRAPE_DELAY = exports.OPTION_SCRAPE_DARK_MODE = exports.OPTION_SCRAPE_WAIT_FOR_ELEMENT = exports.OPTION_SCRAPE_DEVICE_PIXEL_RATIO = exports.OPTION_SCRAPE_VIEWPORT = exports.OPTION_SCRAPE_BROWSER = exports.OPTION_SCRAPE_XPATH_SELECTOR = exports.OPTION_SCRAPE_CSS_SELECTOR = exports.OPTION_SCRAPE_FULL_PAGE = exports.OPTION_SCRAPE_QUALITY = exports.OPTION_SCRAPE_OUTPUT_TYPE = exports.OPTION_SCRAPE_FOLLOW = exports.OPTION_SCRAPE_URL = exports.OPTION_COMPARE_WAIT_FOR = exports.OPTION_COMPARE_DELAY = exports.OPTION_COMPARE_HEADER = exports.OPTION_COMPARE_COOKIE = exports.OPTION_COMPARE_IGNORE = exports.OPTION_COMPARE_IGNORE_URLS = exports.OPTION_COMPARE_DRY_RUN = exports.OPTION_COMPARE_URLS_FILE = exports.OPTION_COMPARE_SITEMAP = exports.OPTION_COMPARE_URLS = exports.OPTION_COMPARE_RESPECT_ROBOTS = void 0;
|
|
9
|
+
exports.DEBUG_WAIT_FOR_IDLE_TIMEOUT = exports.DEBUG_WAIT_FOR_IDLE = exports.DEBUG_RESOURCE_DISCOVERY_TIMEOUT = exports.DEBUG_AUTO_WIDTH = exports.DEBUG_AUTO_SCROLL = exports.DEBUG_RESOURCE_SCRAPPING_URL = exports.DEBUG_SNAPSHOT_PROCESSING = exports.DEBUG_SNAPSHOTS_PROCESSING = exports.DEBUG_EXEC_COMMAND = exports.DEBUG_EXEC_TEST_COMMAND = exports.LOG_INSTALLED_BROWSER = exports.LOG_SESSION_LINK = exports.LOG_SENDING_DATA = exports.LOG_SENDING_REQUEST = exports.LOG_PROCESSING_SNAPSHOTS = exports.LOG_RUNNING_EXEC_COMMAND = exports.LOG_TUNNEL_SSH_STREAM = exports.LOG_TUNNEL_TLS_AGENT_STREAM = exports.LOG_TUNNEL_TLS_REGION_STREAM = exports.LOG_TUNNEL_TLS_TARGET_STREAM = exports.LOG_TUNNEL_HTTP2_STREAM = exports.LOG_TUNNEL_HTTP1_STREAM = exports.LOG_TUNNEL_TCP_STREAM = exports.LOG_TUNNEL_HTTP_WRONG_USER_AGENTS = exports.LOG_TUNNEL_HTTP_CIRCUIT_BREAKER_OPEN = exports.LOG_TUNNEL_HTTP_RATE_LIMIT = exports.LOG_TUNNEL_HTTP_WRON_AUTH = exports.LOG_TUNNEL_IDENTIFIED = exports.LOG_TUNNEL_DISCONNECTED = exports.LOG_TUNNEL_FAILED = exports.LOG_TUNNEL_CONNECTED = exports.LOG_AGENT_STARTED = exports.LOG_AGENT_SERVER_STARTED = exports.LOG_ERROR_STARTING_AGENT_SERVER = exports.LOG_SSH_CONNECTION = exports.LOG_WRONG_STREAM = exports.LOG_DETECTED_STREAM = exports.LOG_HTTP2_REQUEST = exports.LOG_HTTP2_CONNECTION = exports.LOG_HTTP1_REQUEST = exports.LOG_HTTP1_CONNECTION = exports.LOG_ERROR = exports.LOG_STOPPING_TUNNEL = exports.LOG_STARTING_TUNNEL = exports.LOG_ENABLING_AGENT_TARGET = exports.LOG_DISABLING_AGENT_TARGET = exports.LOG_REMOVING_TUNNEL = exports.LOG_TUNNEL_REGISTERED = exports.LOG_ERROR_WHILE_REFRESHING_AGENT = void 0;
|
|
11
10
|
const utils_1 = require("./utils");
|
|
12
11
|
exports.ERR_REST_API_GENERAL_ERROR = 'Something went wrong';
|
|
13
12
|
exports.ERR_REST_API_WRONG_TOKEN = 'Valid token with proper scopes is required';
|
|
@@ -15,16 +14,11 @@ exports.ERR_REST_API_RESOURCE_NOT_FOUND = 'Resource not found';
|
|
|
15
14
|
exports.ERR_REST_API_RATE_LIMIT = 'Rate limit exceeded';
|
|
16
15
|
exports.ERR_REST_API_TOKEN = 'Personal access token is required (--token)';
|
|
17
16
|
exports.ERR_REST_API_URL = 'Valid rest api endpoint is required (--api)';
|
|
18
|
-
exports.ERR_PATH_NOT_EXISTS = 'path not exists';
|
|
19
17
|
exports.ERR_REST_API_WORKSPACE = 'Workspace domain is required (--workspace)';
|
|
20
18
|
exports.ERR_REST_API_PROJECT = 'Project name is required (--project)';
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.ERR_PACKAGE_DOWNLOAD_NOT_FOUND = 'Package not found';
|
|
25
|
-
exports.ERR_PACKAGE_PUBLISH_NOT_FOUND = 'Package not found. Change package name or use --create to create one';
|
|
26
|
-
exports.ERR_PACKAGE_VERSION_EXISTS = 'Package version exists. Change version name or use --force flag';
|
|
27
|
-
exports.ERR_PACKAGE_VERSION_NOT_FOUND = 'Package version not found';
|
|
19
|
+
exports.ERR_RUN_PIPELINE_WORKSPACE_NOT_FOUND = 'Workspace not found';
|
|
20
|
+
exports.ERR_RUN_PIPELINE_PROJECT_NOT_FOUND = 'Project not found';
|
|
21
|
+
exports.ERR_RUN_PIPELINE_NOT_FOUND = 'Pipeline not found';
|
|
28
22
|
exports.ERR_RUN_PIPELINE_WAIT_TIMEOUT = 'Timeout waiting for run to finish';
|
|
29
23
|
exports.ERR_RUN_PIPELINE_WRONG_PRIORITY = 'Priority has wrong value. Possible: LOW, NORMAL, HIGH';
|
|
30
24
|
exports.ERR_RUN_PIPELINE_WRONG_DELAY = 'Delay must be a valid date format: 2016-11-18T12:38:16.000Z or 30s, 10m, 3h10m30s';
|
|
@@ -95,16 +89,6 @@ exports.ERR_TUNNEL_REMOVED = 'Tunnel removed';
|
|
|
95
89
|
exports.ERR_FAILED_TO_CONNECT_TO_AGENT = 'Failed connecting to agent';
|
|
96
90
|
exports.ERR_NOT_FOUND = 'Not found';
|
|
97
91
|
exports.ERR_SWW = 'Something went wrong';
|
|
98
|
-
const ERR_PACKAGE_DOWNLOAD_MKDIR = (dirPath) => `Error while creating directory ${dirPath}`;
|
|
99
|
-
exports.ERR_PACKAGE_DOWNLOAD_MKDIR = ERR_PACKAGE_DOWNLOAD_MKDIR;
|
|
100
|
-
const ERR_PACKAGE_DOWNLOAD_READDIR = (dirPath) => `Error while reading directory ${dirPath}`;
|
|
101
|
-
exports.ERR_PACKAGE_DOWNLOAD_READDIR = ERR_PACKAGE_DOWNLOAD_READDIR;
|
|
102
|
-
const ERR_PACKAGE_DOWNLOAD_IS_FILE = (dirPath) => `Path ${dirPath} is not a directory. Change path or use --replace flag`;
|
|
103
|
-
exports.ERR_PACKAGE_DOWNLOAD_IS_FILE = ERR_PACKAGE_DOWNLOAD_IS_FILE;
|
|
104
|
-
const ERR_PACKAGE_DOWNLOAD_NOT_EMPTY_DIR = (dirPath) => `Directory ${dirPath} is not empty. Use --merge or --replace flags`;
|
|
105
|
-
exports.ERR_PACKAGE_DOWNLOAD_NOT_EMPTY_DIR = ERR_PACKAGE_DOWNLOAD_NOT_EMPTY_DIR;
|
|
106
|
-
const ERR_PACKAGE_DOWNLOAD_REPLACE = (dirPath) => `Error while replacing directory ${dirPath}`;
|
|
107
|
-
exports.ERR_PACKAGE_DOWNLOAD_REPLACE = ERR_PACKAGE_DOWNLOAD_REPLACE;
|
|
108
92
|
exports.ERR_FETCH_VERSION = 'Failed to fetch version';
|
|
109
93
|
exports.ERR_WRONG_HANDSHAKE = 'Wrong handshake data';
|
|
110
94
|
exports.ERR_WRONG_STREAM = 'Wrong stream type';
|
|
@@ -218,10 +202,7 @@ exports.DESC_COMMAND_TCP = 'Starts a tunnel which forwards all TCP traffic on a
|
|
|
218
202
|
exports.DESC_COMMAND_TLS = 'Starts a tunnel listening for TLS traffic on port 443 with a specific hostname.';
|
|
219
203
|
exports.DESC_PROGRAM = 'Buddy exposes local networked services behinds NATs and firewalls to the public internet over a secure tunnel. Share local websites, build/test webhook consumers, and self-host personal services.';
|
|
220
204
|
exports.DESC_COMMAND_PIPELINE = 'Commands to interact with the pipeline service';
|
|
221
|
-
exports.
|
|
222
|
-
exports.DESC_COMMAND_PACKAGE_PUBLISH = 'Publish package. Required scopes: PACKAGE_READ, PACKAGE_WRITE, PACKAGE_MANAGE';
|
|
223
|
-
exports.DESC_COMMAND_PACKAGE_DOWNLOAD = 'Download package. Required scopes: PACKAGE_READ';
|
|
224
|
-
exports.DESC_COMMAND_PIPELINE_RUN = 'Run pipeline. Required scopes: EXECUTION_INFO, EXECUTION_RUN';
|
|
205
|
+
exports.DESC_COMMAND_PIPELINE_RUN = 'Run pipeline. Required scopes: WORKSPACE, EXECUTION_RUN';
|
|
225
206
|
exports.DESC_COMMAND_VT = 'Commands to interact with the visual test service';
|
|
226
207
|
exports.DESC_COMMAND_VT_CLOSE = 'Close visual test session.';
|
|
227
208
|
exports.DESC_COMMAND_VT_STORYBOOK = 'Create visual test session from storybook';
|
|
@@ -255,26 +236,6 @@ const TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY = (runUrl) => `Run finished successfu
|
|
|
255
236
|
exports.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY = TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY;
|
|
256
237
|
const TXT_PIPELINE_RUN_FINISH_FAILED = (status, runUrl) => `Run finished with status ${status}: ${runUrl}`;
|
|
257
238
|
exports.TXT_PIPELINE_RUN_FINISH_FAILED = TXT_PIPELINE_RUN_FINISH_FAILED;
|
|
258
|
-
exports.TXT_PACKAGE_SCANNING_DIR = 'Scanning...';
|
|
259
|
-
exports.TXT_PACKAGE_NO_ENTRIES_FOUND = 'no entries found';
|
|
260
|
-
exports.TXT_PACKAGE_ONE_ENTRY_FOUND = '1 entry found';
|
|
261
|
-
const TXT_PACKAGE_ZIP_ENTRIES = (count) => `Archiving...${count}`;
|
|
262
|
-
exports.TXT_PACKAGE_ZIP_ENTRIES = TXT_PACKAGE_ZIP_ENTRIES;
|
|
263
|
-
exports.TXT_PACKAGE_ZIPPED = `Archiving...Done`;
|
|
264
|
-
exports.TXT_PACKAGE_UPLOADING = 'Uploading...';
|
|
265
|
-
exports.TXT_PACKAGE_UPLOADED = 'Uploading...Done';
|
|
266
|
-
const TXT_PACKAGE_ENTRIES_FOUND = (count) => `${count} entries found`;
|
|
267
|
-
exports.TXT_PACKAGE_ENTRIES_FOUND = TXT_PACKAGE_ENTRIES_FOUND;
|
|
268
|
-
const TXT_PACKAGE_PUBLISHED = (versionUrl) => `Package published: ${versionUrl}`;
|
|
269
|
-
exports.TXT_PACKAGE_PUBLISHED = TXT_PACKAGE_PUBLISHED;
|
|
270
|
-
const TXT_PACKAGE_DOWNLOADED = (version, dirPath) => `Package version '${version}' downloaded to ${dirPath}`;
|
|
271
|
-
exports.TXT_PACKAGE_DOWNLOADED = TXT_PACKAGE_DOWNLOADED;
|
|
272
|
-
exports.TXT_PACKAGE_DOWNLOADING_ZIP = 'Downloading...';
|
|
273
|
-
exports.TXT_PACKAGE_DOWNLOADED_ZIP = 'Downloading...Done';
|
|
274
|
-
exports.TXT_PACKAGE_UNZIPPING = 'Unzipping...';
|
|
275
|
-
exports.TXT_PACKAGE_UNZIPPED = 'Unzipping...Done';
|
|
276
|
-
const TXT_PACKAGE_UNZIPPING_COUNT = (count) => `Unzipping...${count}`;
|
|
277
|
-
exports.TXT_PACKAGE_UNZIPPING_COUNT = TXT_PACKAGE_UNZIPPING_COUNT;
|
|
278
239
|
exports.OPTION_REGION = 'override default region ("eu", "us")';
|
|
279
240
|
exports.OPTION_DEFAULT_REGION = 'default region ("eu", "us")';
|
|
280
241
|
exports.OPTION_REST_API_ENDPOINT = 'override default base url (api.buddy.works) and region. You can use env variable: BUDDY_API_ENDPOINT.';
|
|
@@ -289,16 +250,7 @@ exports.OPTION_PIPELINE_RUN_CLEAR_CACHE = 'clear cache before running the pipeli
|
|
|
289
250
|
exports.OPTION_PIPELINE_RUN_PRIORITY = 'run priority. Can be one of "LOW", "NORMAL" or "HIGH". Default is "NORMAL"';
|
|
290
251
|
exports.OPTION_PIPELINE_RUN_VAR = 'variable key:value. Can be passed multiple times to pass multiple variables';
|
|
291
252
|
exports.OPTION_PIPELINE_RUN_DELAY = 'the date when the execution should be run. Should be set in the format: 2016-11-18T12:38:16.000Z or 30s, 10m, 3h10m30s';
|
|
292
|
-
exports.OPTION_PIPELINE_RUN_ARGUMENT = 'human-readable ID of
|
|
293
|
-
exports.OPTION_PACKAGE_PUBLISH_PATH = 'path to the directory or file';
|
|
294
|
-
exports.OPTION_PACKAGE_DOWNLOAD_PATH = 'path to the directory or file';
|
|
295
|
-
exports.OPTION_PACKAGE_ID = 'human-readable ID of the package';
|
|
296
|
-
exports.OPTION_PACKAGE_PUBLISH_CREATE = 'create package if not exists';
|
|
297
|
-
exports.OPTION_PACKAGE_PUBLISH_VERSION = 'version name to publish';
|
|
298
|
-
exports.OPTION_PACKAGE_DOWNLOAD_VERSION = 'version name to download. If omitted latest version will be fetched';
|
|
299
|
-
exports.OPTION_PACKAGE_PUBLISH_OVERWRITE_VERSION = 'allow overwriting existing version';
|
|
300
|
-
exports.OPTION_PACKAGE_DOWNLOAD_MERGE = 'merge contents of the directory with package';
|
|
301
|
-
exports.OPTION_PACKAGE_DOWNLOAD_REPLACE = 'replace contents of the directory with package';
|
|
253
|
+
exports.OPTION_PIPELINE_RUN_ARGUMENT = 'human-readable ID of pipeline';
|
|
302
254
|
exports.OPTION_REST_API_TOKEN = 'personal access token. You can use env variable: BUDDY_TOKEN';
|
|
303
255
|
exports.OPTION_PIPELINE_RUN_ACTION = "action ID to be run in this execution. If not sent, it will be run in accordance with the pipeline's definition. Can be passed multiple times to select multiple actions";
|
|
304
256
|
exports.OPTION_PIPELINE_RUN_WAIT = 'wait for run to finish';
|
|
@@ -162,7 +162,16 @@ class ServerSsh extends events_1.default {
|
|
|
162
162
|
const opts = {};
|
|
163
163
|
if (env)
|
|
164
164
|
opts.env = env;
|
|
165
|
+
logger_1.default.info('exec');
|
|
166
|
+
logger_1.default.info(command);
|
|
167
|
+
logger_1.default.info(opts);
|
|
165
168
|
(0, child_process_1.exec)(command, opts, (err, stdout, stderr) => {
|
|
169
|
+
logger_1.default.info('err');
|
|
170
|
+
logger_1.default.info(err);
|
|
171
|
+
logger_1.default.info('stdout');
|
|
172
|
+
logger_1.default.info(stdout);
|
|
173
|
+
logger_1.default.info('stderr');
|
|
174
|
+
logger_1.default.info(stderr);
|
|
166
175
|
if (stream) {
|
|
167
176
|
stream.stderr.write(stderr);
|
|
168
177
|
stream.write(stdout);
|
package/package.json
CHANGED
|
@@ -1,259 +0,0 @@
|
|
|
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 client_1 = __importDefault(require("../../api/client"));
|
|
10
|
-
const output_1 = __importDefault(require("../../output"));
|
|
11
|
-
const logger_1 = __importDefault(require("../../logger"));
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const uuid_1 = require("uuid");
|
|
14
|
-
const fs_1 = __importDefault(require("fs"));
|
|
15
|
-
const promises_1 = __importDefault(require("stream/promises"));
|
|
16
|
-
const fflate_1 = require("fflate");
|
|
17
|
-
const commandPackageDownload = (0, utils_1.newCommand)('download', texts_1.DESC_COMMAND_PACKAGE_DOWNLOAD);
|
|
18
|
-
commandPackageDownload.alias('dd');
|
|
19
|
-
commandPackageDownload.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
|
|
20
|
-
commandPackageDownload.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
|
|
21
|
-
commandPackageDownload.option('--region <region>', texts_1.OPTION_REST_API_REGION);
|
|
22
|
-
commandPackageDownload.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
23
|
-
commandPackageDownload.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
24
|
-
commandPackageDownload.option('-v, --version <version>', texts_1.OPTION_PACKAGE_DOWNLOAD_VERSION);
|
|
25
|
-
commandPackageDownload.option('-m, --merge', texts_1.OPTION_PACKAGE_DOWNLOAD_MERGE);
|
|
26
|
-
commandPackageDownload.option('-r, --replace', texts_1.OPTION_PACKAGE_DOWNLOAD_REPLACE);
|
|
27
|
-
commandPackageDownload.argument('<identifier>', texts_1.OPTION_PACKAGE_ID);
|
|
28
|
-
commandPackageDownload.argument('<directory>', texts_1.OPTION_PACKAGE_DOWNLOAD_PATH);
|
|
29
|
-
commandPackageDownload.action(async (identifier, path, options) => {
|
|
30
|
-
const token = input_1.default.restApiToken(options.token);
|
|
31
|
-
const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
|
|
32
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
33
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
34
|
-
const client = new client_1.default(baseUrl, token);
|
|
35
|
-
let version = options.version;
|
|
36
|
-
const data = await client.getPackageVersionByIdentifier(workspace, project, identifier, version);
|
|
37
|
-
if (!data || !data.domain) {
|
|
38
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
39
|
-
}
|
|
40
|
-
if (project && !data.project_identifier) {
|
|
41
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
42
|
-
}
|
|
43
|
-
const packageId = data.pkg_id;
|
|
44
|
-
if (!packageId) {
|
|
45
|
-
output_1.default.exitError(texts_1.ERR_PACKAGE_DOWNLOAD_NOT_FOUND);
|
|
46
|
-
}
|
|
47
|
-
let versionId = data.pkg_version_id;
|
|
48
|
-
if (version && !versionId) {
|
|
49
|
-
output_1.default.exitError(texts_1.ERR_PACKAGE_VERSION_NOT_FOUND);
|
|
50
|
-
}
|
|
51
|
-
if (!version || !versionId) {
|
|
52
|
-
const v = await client.getPackageLatest(workspace, packageId);
|
|
53
|
-
if (!v) {
|
|
54
|
-
output_1.default.exitError(texts_1.ERR_PACKAGE_VERSION_NOT_FOUND);
|
|
55
|
-
}
|
|
56
|
-
version = v.version;
|
|
57
|
-
versionId = v.id;
|
|
58
|
-
}
|
|
59
|
-
const dirPath = (0, path_1.resolve)(path);
|
|
60
|
-
const exists = fs_1.default.existsSync(dirPath);
|
|
61
|
-
if (!exists) {
|
|
62
|
-
try {
|
|
63
|
-
fs_1.default.mkdirSync(dirPath, {
|
|
64
|
-
recursive: true,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
logger_1.default.error(err);
|
|
69
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_MKDIR)(dirPath));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else if (options.replace) {
|
|
73
|
-
try {
|
|
74
|
-
fs_1.default.rmSync(dirPath, {
|
|
75
|
-
recursive: true,
|
|
76
|
-
force: true,
|
|
77
|
-
});
|
|
78
|
-
fs_1.default.mkdirSync(dirPath, {
|
|
79
|
-
recursive: true,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
logger_1.default.error(err);
|
|
84
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_REPLACE)(dirPath));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
const stat = fs_1.default.statSync(dirPath);
|
|
89
|
-
if (!stat.isDirectory()) {
|
|
90
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_IS_FILE)(dirPath));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
logger_1.default.error(err);
|
|
95
|
-
output_1.default.exitError(texts_1.ERR_SWW);
|
|
96
|
-
}
|
|
97
|
-
let empty = true;
|
|
98
|
-
try {
|
|
99
|
-
const entries = fs_1.default.readdirSync(dirPath);
|
|
100
|
-
empty = !entries.length;
|
|
101
|
-
}
|
|
102
|
-
catch (err) {
|
|
103
|
-
logger_1.default.error(err);
|
|
104
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_READDIR)(dirPath));
|
|
105
|
-
}
|
|
106
|
-
if (!empty && !options.merge) {
|
|
107
|
-
output_1.default.exitError((0, texts_1.ERR_PACKAGE_DOWNLOAD_NOT_EMPTY_DIR)(dirPath));
|
|
108
|
-
}
|
|
109
|
-
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${(0, uuid_1.v4)()}.zip`);
|
|
110
|
-
const clearZip = () => {
|
|
111
|
-
try {
|
|
112
|
-
fs_1.default.rmSync(zipPath);
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
// do nothing
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_DOWNLOADING_ZIP);
|
|
119
|
-
const body = await client.downloadPackageVersion(workspace, packageId, versionId);
|
|
120
|
-
try {
|
|
121
|
-
await promises_1.default.pipeline(body, fs_1.default.createWriteStream(zipPath));
|
|
122
|
-
output_1.default.clearPreviousLine();
|
|
123
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_DOWNLOADED_ZIP);
|
|
124
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_UNZIPPING);
|
|
125
|
-
let count = 0;
|
|
126
|
-
await unzip(dirPath, zipPath, () => {
|
|
127
|
-
count += 1;
|
|
128
|
-
output_1.default.clearPreviousLine();
|
|
129
|
-
output_1.default.normal((0, texts_1.TXT_PACKAGE_UNZIPPING_COUNT)(count));
|
|
130
|
-
});
|
|
131
|
-
clearZip();
|
|
132
|
-
output_1.default.clearPreviousLine();
|
|
133
|
-
output_1.default.normal(texts_1.TXT_PACKAGE_UNZIPPED);
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
logger_1.default.error(err);
|
|
137
|
-
clearZip();
|
|
138
|
-
output_1.default.exitError(texts_1.ERR_SWW);
|
|
139
|
-
}
|
|
140
|
-
output_1.default.exitSuccess((0, texts_1.TXT_PACKAGE_DOWNLOADED)(version, dirPath));
|
|
141
|
-
});
|
|
142
|
-
const unzip = (dirPath, zipPath, onFile) => {
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
let _startedFiles = 0;
|
|
145
|
-
let _finishedFiles = 0;
|
|
146
|
-
let _finishedStream = false;
|
|
147
|
-
let _finishedError = null;
|
|
148
|
-
let _calledResolve = false;
|
|
149
|
-
const rs = fs_1.default.createReadStream(zipPath);
|
|
150
|
-
const _finish = () => {
|
|
151
|
-
if (_finishedError || _finishedStream) {
|
|
152
|
-
try {
|
|
153
|
-
rs.removeAllListeners();
|
|
154
|
-
rs.close();
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
// do nothing
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (_calledResolve)
|
|
161
|
-
return;
|
|
162
|
-
if (_finishedError) {
|
|
163
|
-
_calledResolve = true;
|
|
164
|
-
reject(_finishedError);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (_finishedStream && _startedFiles === _finishedFiles) {
|
|
168
|
-
_calledResolve = true;
|
|
169
|
-
resolve();
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
const finishFile = (err, fws) => {
|
|
173
|
-
if (!_finishedError && err)
|
|
174
|
-
_finishedError = err;
|
|
175
|
-
_finishedFiles += 1;
|
|
176
|
-
if (fws) {
|
|
177
|
-
try {
|
|
178
|
-
fws.removeAllListeners();
|
|
179
|
-
fws.close();
|
|
180
|
-
}
|
|
181
|
-
catch {
|
|
182
|
-
// do nothing
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
onFile();
|
|
186
|
-
_finish();
|
|
187
|
-
};
|
|
188
|
-
const finishStream = (err) => {
|
|
189
|
-
if (!_finishedError && err)
|
|
190
|
-
_finishedError = err;
|
|
191
|
-
_finishedStream = true;
|
|
192
|
-
_finish();
|
|
193
|
-
};
|
|
194
|
-
const unzip = new fflate_1.Unzip(async (file) => {
|
|
195
|
-
if (_finishedError)
|
|
196
|
-
return;
|
|
197
|
-
_startedFiles += 1;
|
|
198
|
-
const fullPath = (0, path_1.join)(dirPath, file.name);
|
|
199
|
-
const parentPath = (0, path_1.dirname)(fullPath);
|
|
200
|
-
let fws;
|
|
201
|
-
try {
|
|
202
|
-
await fs_1.default.promises.rm(fullPath, {
|
|
203
|
-
recursive: true,
|
|
204
|
-
force: true,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
catch {
|
|
208
|
-
// do nothing
|
|
209
|
-
}
|
|
210
|
-
try {
|
|
211
|
-
if (fullPath.endsWith('/')) {
|
|
212
|
-
await fs_1.default.promises.mkdir(fullPath, {
|
|
213
|
-
recursive: true,
|
|
214
|
-
});
|
|
215
|
-
finishFile();
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
await fs_1.default.promises.mkdir(parentPath, {
|
|
219
|
-
recursive: true,
|
|
220
|
-
});
|
|
221
|
-
fws = fs_1.default.createWriteStream(fullPath, {
|
|
222
|
-
flags: 'w',
|
|
223
|
-
});
|
|
224
|
-
fws.on('error', (err) => {
|
|
225
|
-
finishFile(err, fws);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
catch (err) {
|
|
229
|
-
finishFile(err, fws);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
file.ondata = (err, data, final) => {
|
|
233
|
-
if (_finishedError)
|
|
234
|
-
return;
|
|
235
|
-
if (err)
|
|
236
|
-
finishFile(err, fws);
|
|
237
|
-
else {
|
|
238
|
-
if (fws)
|
|
239
|
-
fws.write(data);
|
|
240
|
-
if (final)
|
|
241
|
-
finishFile(null, fws);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
file.start();
|
|
245
|
-
});
|
|
246
|
-
unzip.register(fflate_1.AsyncUnzipInflate);
|
|
247
|
-
rs.on('data', (chunk) => {
|
|
248
|
-
unzip.push(chunk, false);
|
|
249
|
-
});
|
|
250
|
-
rs.on('error', (err) => {
|
|
251
|
-
finishStream(err);
|
|
252
|
-
});
|
|
253
|
-
rs.on('end', () => {
|
|
254
|
-
unzip.push(new Uint8Array(0), true);
|
|
255
|
-
finishStream();
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
};
|
|
259
|
-
exports.default = commandPackageDownload;
|