bdy 1.18.4-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/api/client.js +48 -0
- 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/app/list.js +35 -0
- package/distTs/src/command/sandbox/app/logs.js +43 -0
- package/distTs/src/command/sandbox/app/start.js +27 -0
- package/distTs/src/command/sandbox/app/status.js +35 -0
- package/distTs/src/command/sandbox/app/stop.js +27 -0
- package/distTs/src/command/sandbox/app.js +25 -0
- package/distTs/src/command/sandbox/cp.js +7 -39
- package/distTs/src/command/sandbox/create.js +22 -12
- package/distTs/src/command/sandbox/logs.js +26 -0
- package/distTs/src/command/sandbox/snapshot/create.js +2 -2
- package/distTs/src/command/sandbox/update.js +14 -0
- package/distTs/src/command/sandbox.js +4 -0
- 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/texts.js +42 -8
- package/distTs/src/tunnel/cfg.js +17 -20
- package/distTs/src/tunnel/tunnel.js +2 -1
- package/distTs/src/utils.js +9 -28
- package/package.json +1 -1
|
@@ -5,9 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const cfg_1 = __importDefault(require("../tunnel/cfg"));
|
|
7
7
|
const output_1 = __importDefault(require("../output"));
|
|
8
|
-
const client_1 = __importDefault(require("../api/client"));
|
|
9
8
|
const node_http_1 = __importDefault(require("node:http"));
|
|
10
|
-
const open_1 = __importDefault(require("open"));
|
|
11
9
|
const texts_1 = require("../texts");
|
|
12
10
|
const utils_1 = require("../utils");
|
|
13
11
|
const input_1 = __importDefault(require("../input"));
|
|
@@ -34,6 +32,8 @@ const OAUTH_CLIENT_APP_SCOPES = [
|
|
|
34
32
|
'UNIT_TEST_MANAGE',
|
|
35
33
|
];
|
|
36
34
|
async function oauthServer(api, clientId, clientSecret) {
|
|
35
|
+
const ApiClient = require('../api/client').default;
|
|
36
|
+
const open = require('open');
|
|
37
37
|
return new Promise((resolve, reject) => {
|
|
38
38
|
const s = node_http_1.default.createServer(async (req, res) => {
|
|
39
39
|
const url = new URL(req.url || '', `http://${OAUTH_CLIENT_APP_HOST}`);
|
|
@@ -44,7 +44,7 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
44
44
|
reject(new Error(texts_1.ERR_LOGIN_HTTP_FAILED));
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
const client = new
|
|
47
|
+
const client = new ApiClient(new URL(`https://${api}`));
|
|
48
48
|
try {
|
|
49
49
|
const response = await client.exchangeAppToken(urlCode, clientId, clientSecret, OAUTH_CLIENT_APP_REDIRECT_URL);
|
|
50
50
|
res.end(texts_1.ERR_LOGIN_HTTP_SUCCESS);
|
|
@@ -67,11 +67,12 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
67
67
|
});
|
|
68
68
|
s.listen(OAUTH_CLIENT_APP_PORT, OAUTH_CLIENT_APP_HOST);
|
|
69
69
|
const url = `https://${api}/oauth2/authorize?type=web_server&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(OAUTH_CLIENT_APP_REDIRECT_URL)}&response_type=code&scope=${encodeURIComponent(OAUTH_CLIENT_APP_SCOPES.join(' '))}`;
|
|
70
|
-
(
|
|
70
|
+
open(url);
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
async function getOrCreateApp(api) {
|
|
74
|
-
const
|
|
74
|
+
const ApiClient = require('../api/client').default;
|
|
75
|
+
const client = new ApiClient(new URL(`https://${api}`));
|
|
75
76
|
let clientId = cfg_1.default.getApiClientId();
|
|
76
77
|
let clientSecret = cfg_1.default.getApiClientSecret();
|
|
77
78
|
let clientToken = cfg_1.default.getApiClientToken();
|
|
@@ -113,9 +114,10 @@ async function authorizeOAuth(api) {
|
|
|
113
114
|
return { token, refreshToken, clientId, clientSecret, clientToken };
|
|
114
115
|
}
|
|
115
116
|
async function authorizeToken(api, token, refreshToken, clientId, clientSecret, clientToken, workspace) {
|
|
117
|
+
const ApiClient = require('../api/client').default;
|
|
116
118
|
cfg_1.default.setApiToken(token);
|
|
117
119
|
cfg_1.default.setApiRefreshToken(refreshToken);
|
|
118
|
-
const client = new
|
|
120
|
+
const client = new ApiClient(new URL(`https://${api}`), token, refreshToken, clientId, clientSecret, clientToken);
|
|
119
121
|
const w = await client.getWorkspaces();
|
|
120
122
|
if (!w.workspaces?.length) {
|
|
121
123
|
output_1.default.exitError(texts_1.ERR_LOGIN_NO_WORKSPACES);
|
|
@@ -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 human_id_1 = __importDefault(require("human-id"));
|
|
11
10
|
const commandPackageCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_PACKAGE_CREATE);
|
|
12
11
|
commandPackageCreate.alias('add');
|
|
13
12
|
commandPackageCreate.option('-i, --identifier <identifier>', texts_1.OPT_COMMAND_PACKAGE_CREATE_IDENTIFIER);
|
|
@@ -19,6 +18,7 @@ commandPackageCreate.option('-a, --auth <user:pass>', texts_1.OPTION_HTTP_AUTH);
|
|
|
19
18
|
commandPackageCreate.argument('[name]', texts_1.OPT_COMMAND_PACKAGE_NAME);
|
|
20
19
|
commandPackageCreate.addHelpText('after', texts_1.EXAMPLE_PACKAGE_CREATE);
|
|
21
20
|
commandPackageCreate.action(async (name, options) => {
|
|
21
|
+
const humanId = require('human-id').default;
|
|
22
22
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
23
23
|
const project = input_1.default.restApiProject(options.project, true);
|
|
24
24
|
const client = input_1.default.restApiTokenClient();
|
|
@@ -28,7 +28,7 @@ commandPackageCreate.action(async (name, options) => {
|
|
|
28
28
|
if (options.identifier)
|
|
29
29
|
name = options.identifier;
|
|
30
30
|
else
|
|
31
|
-
name = (
|
|
31
|
+
name = humanId({ separator: '-', capitalize: false });
|
|
32
32
|
}
|
|
33
33
|
const data = {
|
|
34
34
|
name,
|
|
@@ -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) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const commandSandboxAppList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_APP_LIST);
|
|
11
|
+
commandSandboxAppList.alias('ls');
|
|
12
|
+
commandSandboxAppList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandSandboxAppList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandSandboxAppList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
15
|
+
commandSandboxAppList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_LIST}`);
|
|
16
|
+
commandSandboxAppList.action(async (identifier, options) => {
|
|
17
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = input_1.default.restApiProject(options.project);
|
|
19
|
+
const client = input_1.default.restApiTokenClient();
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
23
|
+
}
|
|
24
|
+
const { apps } = await client.getSandbox(workspace, sandbox_id);
|
|
25
|
+
const table = [['ID', 'COMMAND', 'STATUS']];
|
|
26
|
+
for (const app of apps) {
|
|
27
|
+
let command = app.command;
|
|
28
|
+
if (command.length > 20)
|
|
29
|
+
command = `${command.substring(0, 20)}...`;
|
|
30
|
+
table.push([app.id, command, app.app_status]);
|
|
31
|
+
}
|
|
32
|
+
output_1.default.table(table);
|
|
33
|
+
output_1.default.exitNormal();
|
|
34
|
+
});
|
|
35
|
+
exports.default = commandSandboxAppList;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const commandSandboxAppLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_SANDBOX_APP_LOGS);
|
|
11
|
+
commandSandboxAppLogs.hideVersionUpdate = true;
|
|
12
|
+
commandSandboxAppLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandSandboxAppLogs.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandSandboxAppLogs.option('-l, --limit <lines>', texts_1.OPTION_SANDBOX_LOGS_LIMIT);
|
|
15
|
+
commandSandboxAppLogs.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
16
|
+
commandSandboxAppLogs.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
|
|
17
|
+
commandSandboxAppLogs.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_LOGS}`);
|
|
18
|
+
const fetchLogsWithLimit = async (client, workspace, sandboxId, appId, limit) => {
|
|
19
|
+
let c = null;
|
|
20
|
+
let l = [];
|
|
21
|
+
do {
|
|
22
|
+
const { cursor, logs } = await client.getSandboxAppLogs(workspace, sandboxId, appId, c);
|
|
23
|
+
l = l.concat(logs);
|
|
24
|
+
if (l.length > limit)
|
|
25
|
+
return l.slice(0, limit).join('\n');
|
|
26
|
+
if (!cursor || !logs.length)
|
|
27
|
+
return l.join('\n');
|
|
28
|
+
c = cursor;
|
|
29
|
+
} while (c != null);
|
|
30
|
+
return l.join('\n');
|
|
31
|
+
};
|
|
32
|
+
commandSandboxAppLogs.action(async (identifier, appId, options) => {
|
|
33
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
34
|
+
const project = input_1.default.restApiProject(options.project);
|
|
35
|
+
const client = input_1.default.restApiTokenClient();
|
|
36
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
37
|
+
if (!sandbox_id) {
|
|
38
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
39
|
+
}
|
|
40
|
+
const logs = await fetchLogsWithLimit(client, workspace, sandbox_id, appId, options.limit || 100);
|
|
41
|
+
output_1.default.exitNormal(logs);
|
|
42
|
+
});
|
|
43
|
+
exports.default = commandSandboxAppLogs;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const commandSandboxAppStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_SANDBOX_APP_START);
|
|
11
|
+
commandSandboxAppStart.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
|
+
commandSandboxAppStart.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
+
commandSandboxAppStart.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
14
|
+
commandSandboxAppStart.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
|
|
15
|
+
commandSandboxAppStart.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_START}`);
|
|
16
|
+
commandSandboxAppStart.action(async (identifier, appId, options) => {
|
|
17
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = input_1.default.restApiProject(options.project);
|
|
19
|
+
const client = input_1.default.restApiTokenClient();
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
23
|
+
}
|
|
24
|
+
await client.startSandboxApp(workspace, sandbox_id, appId);
|
|
25
|
+
output_1.default.exitSuccess(texts_1.TXT_SANDBOX_APP_STARTED);
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandSandboxAppStart;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const commandSandboxAppStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_APP_STATUS);
|
|
11
|
+
commandSandboxAppStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
|
+
commandSandboxAppStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
+
commandSandboxAppStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
14
|
+
commandSandboxAppStatus.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
|
|
15
|
+
commandSandboxAppStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_STATUS}`);
|
|
16
|
+
commandSandboxAppStatus.action(async (identifier, appId, options) => {
|
|
17
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = input_1.default.restApiProject(options.project);
|
|
19
|
+
const client = input_1.default.restApiTokenClient();
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
23
|
+
}
|
|
24
|
+
const { apps, } = await client.getSandbox(workspace, sandbox_id);
|
|
25
|
+
const app = (apps || []).find((app) => app.id === appId);
|
|
26
|
+
if (!app) {
|
|
27
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_APP_NOT_FOUND);
|
|
28
|
+
}
|
|
29
|
+
output_1.default.object({
|
|
30
|
+
Command: app.command,
|
|
31
|
+
Status: app.app_status,
|
|
32
|
+
});
|
|
33
|
+
output_1.default.exitNormal();
|
|
34
|
+
});
|
|
35
|
+
exports.default = commandSandboxAppStatus;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const commandSandboxAppStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_SANDBOX_APP_STOP);
|
|
11
|
+
commandSandboxAppStop.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
|
+
commandSandboxAppStop.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
+
commandSandboxAppStop.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
14
|
+
commandSandboxAppStop.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
|
|
15
|
+
commandSandboxAppStop.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_STOP}`);
|
|
16
|
+
commandSandboxAppStop.action(async (identifier, appId, options) => {
|
|
17
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = input_1.default.restApiProject(options.project);
|
|
19
|
+
const client = input_1.default.restApiTokenClient();
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
23
|
+
}
|
|
24
|
+
await client.stopSandboxApp(workspace, sandbox_id, appId);
|
|
25
|
+
output_1.default.exitSuccess(texts_1.TXT_SANDBOX_APP_STOPPED);
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandSandboxAppStop;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 list_1 = __importDefault(require("./app/list"));
|
|
9
|
+
const logs_1 = __importDefault(require("./app/logs"));
|
|
10
|
+
const status_1 = __importDefault(require("./app/status"));
|
|
11
|
+
const stop_1 = __importDefault(require("./app/stop"));
|
|
12
|
+
const start_1 = __importDefault(require("./app/start"));
|
|
13
|
+
const commandSandboxApp = (0, utils_1.newCommand)('app', texts_1.DESC_COMMAND_SANDBOX_APP);
|
|
14
|
+
commandSandboxApp.addCommand(list_1.default);
|
|
15
|
+
commandSandboxApp.addCommand(logs_1.default);
|
|
16
|
+
commandSandboxApp.addCommand(status_1.default);
|
|
17
|
+
commandSandboxApp.addCommand(stop_1.default);
|
|
18
|
+
commandSandboxApp.addCommand(start_1.default);
|
|
19
|
+
commandSandboxApp.addHelpText('after', `
|
|
20
|
+
EXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_LIST}
|
|
21
|
+
${texts_1.EXAMPLE_SANDBOX_APP_LOGS}
|
|
22
|
+
${texts_1.EXAMPLE_SANDBOX_APP_STATUS}
|
|
23
|
+
${texts_1.EXAMPLE_SANDBOX_APP_STOP}
|
|
24
|
+
${texts_1.EXAMPLE_SANDBOX_APP_START}`);
|
|
25
|
+
exports.default = commandSandboxApp;
|
|
@@ -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));
|