bdy 1.15.7-dev-package → 1.16.2-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.
Files changed (47) hide show
  1. package/distTs/package.json +1 -1
  2. package/distTs/src/agent/agent.js +28 -56
  3. package/distTs/src/agent/linux.js +22 -23
  4. package/distTs/src/agent/manager.js +12 -105
  5. package/distTs/src/agent/osx.js +22 -27
  6. package/distTs/src/agent/socket/client.js +4 -4
  7. package/distTs/src/agent/system.js +89 -21
  8. package/distTs/src/agent/windows.js +21 -32
  9. package/distTs/src/api/client.js +25 -101
  10. package/distTs/src/command/agent/debug.js +10 -3
  11. package/distTs/src/command/agent/disable.js +6 -6
  12. package/distTs/src/command/agent/enable.js +6 -6
  13. package/distTs/src/command/agent/install.js +109 -27
  14. package/distTs/src/command/agent/restart.js +21 -11
  15. package/distTs/src/command/agent/run.js +1 -1
  16. package/distTs/src/command/agent/standalone/kill.js +22 -0
  17. package/distTs/src/command/agent/standalone.js +136 -0
  18. package/distTs/src/command/agent/start.js +19 -12
  19. package/distTs/src/command/agent/status.js +44 -17
  20. package/distTs/src/command/agent/stop.js +20 -13
  21. package/distTs/src/command/agent/target/disable.js +6 -6
  22. package/distTs/src/command/agent/target/enable.js +6 -6
  23. package/distTs/src/command/agent/target/status.js +6 -6
  24. package/distTs/src/command/agent/tunnel/http.js +6 -6
  25. package/distTs/src/command/agent/tunnel/list.js +6 -6
  26. package/distTs/src/command/agent/tunnel/remove.js +6 -6
  27. package/distTs/src/command/agent/tunnel/start.js +7 -7
  28. package/distTs/src/command/agent/tunnel/status.js +6 -6
  29. package/distTs/src/command/agent/tunnel/tcp.js +6 -6
  30. package/distTs/src/command/agent/tunnel/tls.js +6 -6
  31. package/distTs/src/command/agent/uninstall.js +2 -2
  32. package/distTs/src/command/agent/update.js +19 -17
  33. package/distTs/src/command/agent/version.js +3 -5
  34. package/distTs/src/command/agent.js +0 -4
  35. package/distTs/src/command/pipeline/run.js +3 -3
  36. package/distTs/src/command/pre.js +10 -2
  37. package/distTs/src/command/vt/scrap.js +193 -0
  38. package/distTs/src/index.js +0 -2
  39. package/distTs/src/input.js +1 -24
  40. package/distTs/src/output.js +16 -4
  41. package/distTs/src/texts.js +22 -85
  42. package/distTs/src/tunnel/api/agent.js +0 -9
  43. package/distTs/src/types/tunnel.js +0 -3
  44. package/package.json +1 -1
  45. package/distTs/src/command/package/download.js +0 -259
  46. package/distTs/src/command/package/publish.js +0 -231
  47. package/distTs/src/command/package.js +0 -14
@@ -1,231 +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 fflate_1 = __importDefault(require("fflate"));
13
- const fs_1 = __importDefault(require("fs"));
14
- const path_1 = require("path");
15
- const uuid_1 = require("uuid");
16
- const commandPackagePublish = (0, utils_1.newCommand)('publish', texts_1.DESC_COMMAND_PACKAGE_PUBLISH);
17
- commandPackagePublish.alias('pub');
18
- commandPackagePublish.option('-t, --token <token>', texts_1.OPTION_REST_API_TOKEN);
19
- commandPackagePublish.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
20
- commandPackagePublish.option('--region <region>', texts_1.OPTION_REST_API_REGION);
21
- commandPackagePublish.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
22
- commandPackagePublish.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
23
- commandPackagePublish.option('-c, --create', texts_1.OPTION_PACKAGE_PUBLISH_CREATE);
24
- commandPackagePublish.option('-f, --force', texts_1.OPTION_PACKAGE_PUBLISH_OVERWRITE_VERSION);
25
- commandPackagePublish.argument('<identifier>', texts_1.OPTION_PACKAGE_ID);
26
- commandPackagePublish.argument('<directory>', texts_1.OPTION_PACKAGE_PUBLISH_PATH);
27
- commandPackagePublish.action(async (id, path, options) => {
28
- let dirPath = input_1.default.resolvePath(path);
29
- const token = input_1.default.restApiToken(options.token);
30
- const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
31
- const workspace = input_1.default.restApiWorkspace(options.workspace);
32
- const project = input_1.default.restApiProject(options.project, true);
33
- // eslint-disable-next-line prefer-const
34
- let { identifier, version } = input_1.default.packageSplitIdentifier(id);
35
- if (!version)
36
- version = (0, uuid_1.v4)();
37
- const client = new client_1.default(baseUrl, token);
38
- const data = await client.getPackageVersionByIdentifier(workspace, project, identifier, version);
39
- if (!data || !data.domain) {
40
- output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
41
- }
42
- if (project && !data.project_identifier) {
43
- output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
44
- }
45
- let packageId = data.pkg_id;
46
- if (!packageId) {
47
- if (options.create) {
48
- const d = await client.postPackage(workspace, project, identifier);
49
- packageId = d.id;
50
- }
51
- else {
52
- output_1.default.exitError(texts_1.ERR_PACKAGE_PUBLISH_NOT_FOUND);
53
- }
54
- }
55
- let packageVersionId = data.pkg_version_id;
56
- let url;
57
- if (packageVersionId && !options.force) {
58
- output_1.default.exitError(texts_1.ERR_PACKAGE_VERSION_EXISTS);
59
- }
60
- if (!packageVersionId) {
61
- const d = await client.postPackageVersion(workspace, packageId, version);
62
- url = d.version_url;
63
- packageVersionId = d.id;
64
- }
65
- else {
66
- const d = await client.getPackageVersion(workspace, packageId, packageVersionId);
67
- url = d.version_url;
68
- }
69
- output_1.default.normal(texts_1.TXT_PACKAGE_SCANNING_DIR, false);
70
- const stat = fs_1.default.statSync(dirPath);
71
- let entries;
72
- if (stat.isDirectory()) {
73
- entries = fs_1.default.readdirSync(dirPath, {
74
- withFileTypes: true,
75
- recursive: true,
76
- });
77
- }
78
- else {
79
- const parentPath = (0, path_1.dirname)(dirPath);
80
- entries = [
81
- {
82
- isDirectory: () => stat.isDirectory(),
83
- isFile: () => stat.isFile(),
84
- isBlockDevice: () => stat.isBlockDevice(),
85
- isCharacterDevice: () => stat.isCharacterDevice(),
86
- isFIFO: () => stat.isFIFO(),
87
- isSocket: () => stat.isSocket(),
88
- isSymbolicLink: () => stat.isSymbolicLink(),
89
- name: (0, path_1.basename)(dirPath),
90
- parentPath,
91
- path: parentPath,
92
- },
93
- ];
94
- dirPath = parentPath;
95
- }
96
- if (!entries.length) {
97
- output_1.default.normal(texts_1.TXT_PACKAGE_NO_ENTRIES_FOUND);
98
- output_1.default.exitSuccess((0, texts_1.TXT_PACKAGE_PUBLISHED)(url));
99
- }
100
- else if (entries.length === 1) {
101
- output_1.default.normal(texts_1.TXT_PACKAGE_ONE_ENTRY_FOUND);
102
- }
103
- else {
104
- output_1.default.normal((0, texts_1.TXT_PACKAGE_ENTRIES_FOUND)(entries.length));
105
- }
106
- output_1.default.normal((0, texts_1.TXT_PACKAGE_ZIP_ENTRIES)(0));
107
- const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${(0, uuid_1.v4)()}.zip`);
108
- const clearZip = () => {
109
- try {
110
- fs_1.default.rmSync(zipPath);
111
- }
112
- catch {
113
- // do nothing
114
- }
115
- };
116
- let blob;
117
- try {
118
- let proc = 0;
119
- await createZip(dirPath, zipPath, entries, () => {
120
- proc += 1;
121
- output_1.default.clearPreviousLine();
122
- output_1.default.normal((0, texts_1.TXT_PACKAGE_ZIP_ENTRIES)(proc));
123
- });
124
- output_1.default.clearPreviousLine();
125
- output_1.default.normal(texts_1.TXT_PACKAGE_ZIPPED);
126
- blob = await fs_1.default.openAsBlob(zipPath);
127
- }
128
- catch (err) {
129
- logger_1.default.error(err);
130
- clearZip();
131
- output_1.default.exitError(texts_1.ERR_SWW);
132
- }
133
- try {
134
- output_1.default.normal(texts_1.TXT_PACKAGE_UPLOADING);
135
- await client.postPackageVersionZip(workspace, packageId, packageVersionId, blob);
136
- output_1.default.clearPreviousLine();
137
- output_1.default.normal(texts_1.TXT_PACKAGE_UPLOADED);
138
- clearZip();
139
- output_1.default.exitSuccess((0, texts_1.TXT_PACKAGE_PUBLISHED)(url));
140
- }
141
- catch (err) {
142
- clearZip();
143
- logger_1.default.error(err);
144
- output_1.default.exitError(err);
145
- }
146
- });
147
- const addEntryToZip = (dirPath, zip, entry) => {
148
- return new Promise((resolve, reject) => {
149
- const isDir = entry.isDirectory();
150
- let name = (0, path_1.join)(entry.parentPath.replace(dirPath, ''), entry.name);
151
- if (isDir)
152
- name += '/';
153
- const file = new fflate_1.default.AsyncZipDeflate(name, {
154
- level: 9,
155
- });
156
- zip.add(file);
157
- if (isDir) {
158
- file.push(new Uint8Array(0), true);
159
- resolve();
160
- return;
161
- }
162
- const fullPath = (0, path_1.join)(entry.parentPath, entry.name);
163
- const rs = fs_1.default.createReadStream(fullPath);
164
- const finish = (err) => {
165
- try {
166
- rs.removeAllListeners();
167
- rs.close();
168
- }
169
- catch {
170
- // do nothing
171
- }
172
- if (err)
173
- reject(err);
174
- else
175
- resolve();
176
- };
177
- rs.on('data', (chunk) => {
178
- file.push(chunk, false);
179
- });
180
- rs.on('error', (err) => {
181
- finish(err);
182
- });
183
- rs.on('end', () => {
184
- file.push(new Uint8Array(0), true);
185
- finish();
186
- });
187
- });
188
- };
189
- const addEntriesToZip = async (dirPath, zip, entries, onEntry) => {
190
- for (let i = 0; i < entries.length; i += 1) {
191
- await addEntryToZip(dirPath, zip, entries[i]);
192
- onEntry();
193
- }
194
- };
195
- const createZip = (dirPath, zipPath, entries, onEntry) => {
196
- return new Promise((resolve, reject) => {
197
- const ws = fs_1.default.createWriteStream(zipPath);
198
- let wasError = false;
199
- const zip = new fflate_1.default.Zip((err, data, final) => {
200
- if (wasError) {
201
- // do nothing
202
- }
203
- else if (err) {
204
- wasError = true;
205
- ws.close();
206
- reject(err);
207
- }
208
- else {
209
- ws.write(data);
210
- if (final) {
211
- ws.close((err) => {
212
- if (err)
213
- reject(err);
214
- else
215
- resolve();
216
- });
217
- }
218
- }
219
- });
220
- addEntriesToZip(dirPath, zip, entries, onEntry)
221
- .then(() => {
222
- zip.end();
223
- })
224
- .catch((err) => {
225
- ws.close(() => {
226
- reject(err);
227
- });
228
- });
229
- });
230
- };
231
- exports.default = commandPackagePublish;
@@ -1,14 +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 publish_1 = __importDefault(require("./package/publish"));
9
- const download_1 = __importDefault(require("./package/download"));
10
- const commandPackage = (0, utils_1.newCommand)('package', texts_1.DESC_COMMAND_PACKAGE);
11
- commandPackage.alias('pkg');
12
- commandPackage.addCommand(publish_1.default);
13
- commandPackage.addCommand(download_1.default);
14
- exports.default = commandPackage;