bdy 1.16.39-dev → 1.17.3-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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.16.39-dev",
4
+ "version": "1.17.3-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -39,7 +39,7 @@
39
39
  "fflate": "0.8.2",
40
40
  "human-id": "^4.1.3",
41
41
  "isbinaryfile": "5.0.2",
42
- "jsonwebtoken": "9.0.2",
42
+ "jsonwebtoken": "9.0.3",
43
43
  "mime-db": "1.52.0",
44
44
  "mime-types": "2.1.35",
45
45
  "netmask": "2.0.2",
@@ -54,6 +54,7 @@
54
54
  "socket.io-client": "4.7.5",
55
55
  "ssh2": "1.15.0",
56
56
  "tar-stream": "3.1.7",
57
+ "unzipper": "0.12.3",
57
58
  "terminal-kit": "3.1.1",
58
59
  "undici": "6.23.0",
59
60
  "uuid": "10.0.0",
@@ -62,16 +63,15 @@
62
63
  "zod": "3.24.2"
63
64
  },
64
65
  "devDependencies": {
65
- "@eslint/js": "9.13.0",
66
+ "@eslint/js": "9.39.2",
66
67
  "@rollup/plugin-commonjs": "28.0.1",
67
68
  "@rollup/plugin-json": "6.1.0",
68
69
  "@rollup/plugin-node-resolve": "15.3.0",
69
70
  "@rollup/plugin-replace": "6.0.1",
70
- "@stylistic/eslint-plugin-js": "2.9.0",
71
+ "@stylistic/eslint-plugin": "4.4.1",
71
72
  "@types/basic-auth": "1.1.8",
72
73
  "@types/content-disposition": "0.5.4",
73
74
  "@types/cross-spawn": "6.0.6",
74
- "@types/eslint__js": "8.42.3",
75
75
  "@types/jsonwebtoken": "9.0.2",
76
76
  "@types/mime-db": "1.43.6",
77
77
  "@types/mime-types": "2.1.4",
@@ -82,18 +82,19 @@
82
82
  "@types/punycode": "2.1.4",
83
83
  "@types/range-parser": "1.2.1",
84
84
  "@types/ssh2": "1.15.5",
85
- "@types/tar-stream": "3.1.3",
85
+ "@types/tar-stream": "3.1.4",
86
86
  "@types/terminal-kit": "2.5.6",
87
87
  "@types/uuid": "10.0.0",
88
88
  "@types/which": "3.0.4",
89
89
  "@types/ws": "8.18.0",
90
- "eslint": "9.13.0",
91
- "eslint-config-prettier": "9.1.0",
90
+ "@types/unzipper": "0.10.11",
91
+ "eslint": "9.39.2",
92
+ "eslint-config-prettier": "9.1.2",
92
93
  "globals": "15.11.0",
93
94
  "prettier": "3.3.3",
94
95
  "rollup": "4.24.2",
95
96
  "rollup-plugin-natives": "0.7.8",
96
97
  "typescript": "5.9.3",
97
- "typescript-eslint": "8.11.0"
98
+ "typescript-eslint": "8.54.0"
98
99
  }
99
100
  }
@@ -7,6 +7,7 @@ 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 logger_1 = __importDefault(require("../../logger"));
10
11
  var SCHEMA_TYPE;
11
12
  (function (SCHEMA_TYPE) {
12
13
  SCHEMA_TYPE["OBJECT"] = "object";
@@ -221,24 +222,22 @@ const outputMediaType = (mediaType, mediaTypeObject, schemaParamName, userSchema
221
222
  }
222
223
  }
223
224
  output_1.default.gray(` media type contains ${schemas.length} schemas:`);
224
- if (mappings.length > 0) {
225
- mappings.forEach((name, index) => {
226
- outputTextWithPadding(name, 1, false);
227
- const schema = schemas[index];
228
- if (schema) {
229
- if (schema.deprecated)
230
- output_1.default.gray(` (deprecated)`, false);
231
- const desc = schema['x-name'] || schema.title || schema.description;
232
- if (desc)
233
- output_1.default.gray(` - ${desc}`, false);
234
- }
235
- output_1.default.normal('');
236
- });
237
- outputTextWithPadding(`pass --${schemaParamName} with type to view it`);
238
- }
239
- else {
240
- outputTextWithPadding(`pass --${schemaParamName} with number from 1 to ${schemas.length} to view it`);
225
+ for (let i = 1; i <= schemas.length; i += 1) {
226
+ const mapping = mappings[i - 1];
227
+ const name = mapping ? `${i}: ${mapping}` : `${i}`;
228
+ outputTextWithPadding(name, 1, false);
229
+ const schema = schemas[i - 1];
230
+ logger_1.default.info(schema);
231
+ if (schema) {
232
+ if (schema.deprecated)
233
+ output_1.default.gray(` (deprecated)`, false);
234
+ const desc = schema['x-name'] || schema.title || schema.description;
235
+ if (desc)
236
+ output_1.default.gray(` - ${desc}`, false);
237
+ }
238
+ output_1.default.normal('');
241
239
  }
240
+ outputTextWithPadding(`pass --${schemaParamName} with number or type to view it`);
242
241
  }
243
242
  }
244
243
  else {
@@ -1,4 +1,37 @@
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
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -12,6 +45,7 @@ const path_1 = require("path");
12
45
  const uuid_1 = require("uuid");
13
46
  const fs_1 = __importDefault(require("fs"));
14
47
  const promises_1 = __importDefault(require("node:stream/promises"));
48
+ const unzipper_1 = __importStar(require("../../unzipper"));
15
49
  const commandPackageDownload = (0, utils_1.newCommand)('download', texts_1.DESC_COMMAND_PACKAGE_DOWNLOAD);
16
50
  commandPackageDownload.alias('dd');
17
51
  commandPackageDownload.option('-t, --token <token>', texts_1.OPTION_REST_API_TOKEN);
@@ -120,7 +154,7 @@ commandPackageDownload.action(async (id, path, options) => {
120
154
  output_1.default.normal(texts_1.TXT_PACKAGE_DOWNLOADED_ZIP);
121
155
  output_1.default.normal(texts_1.TXT_PACKAGE_UNZIPPING);
122
156
  let count = 0;
123
- await (0, utils_1.unzipFile)(dirPath, zipPath, () => {
157
+ await unzipper_1.default.extract(unzipper_1.UNZIPPER_FORMAT.ZIP, zipPath, dirPath, async () => {
124
158
  count += 1;
125
159
  output_1.default.clearPreviousLine();
126
160
  output_1.default.normal((0, texts_1.TXT_PACKAGE_UNZIPPING_COUNT)(count));
@@ -101,7 +101,6 @@ commandPackagePublish.action(async (id, path, options) => {
101
101
  isSymbolicLink: () => stat.isSymbolicLink(),
102
102
  name: (0, path_1.basename)(dirPath),
103
103
  parentPath,
104
- path: parentPath,
105
104
  },
106
105
  ];
107
106
  dirPath = parentPath;
@@ -1,4 +1,37 @@
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
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -12,6 +45,7 @@ const path_1 = require("path");
12
45
  const node_fs_1 = __importDefault(require("node:fs"));
13
46
  const uuid_1 = require("uuid");
14
47
  const promises_1 = __importDefault(require("node:stream/promises"));
48
+ const unzipper_1 = __importStar(require("../../unzipper"));
15
49
  const commandSandboxCp = (0, utils_1.newCommand)('cp', texts_1.DESC_COMMAND_SANDBOX_CP);
16
50
  commandSandboxCp.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
17
51
  commandSandboxCp.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
@@ -50,7 +84,9 @@ const upload = async (client, workspace, project, source, destination) => {
50
84
  output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(0));
51
85
  }
52
86
  output_1.default.normal('');
53
- const baseRemoteDir = isRemoteDir ? (0, path_1.join)(remotePath, (0, path_1.basename)(sourcePath)) : remotePath;
87
+ const baseRemoteDir = isRemoteDir
88
+ ? (0, path_1.join)(remotePath, (0, path_1.basename)(sourcePath))
89
+ : remotePath;
54
90
  for (let i = 0; i < files.length; i++) {
55
91
  const localFile = files[i];
56
92
  const relativePath = (0, path_1.relative)(sourcePath, localFile);
@@ -102,7 +138,7 @@ const download = async (client, workspace, project, source, destination, merge,
102
138
  output_1.default.normal(texts_1.TXT_SANDBOX_CP_DOWNLOAD_DONE);
103
139
  output_1.default.normal(texts_1.TXT_SANDBOX_UNZIP);
104
140
  let count = 0;
105
- await (0, utils_1.untarGz)(destDirPath, zipPath, () => {
141
+ await unzipper_1.default.extract(unzipper_1.UNZIPPER_FORMAT.TAR_GZ, zipPath, destDirPath, async () => {
106
142
  count += 1;
107
143
  output_1.default.clearPreviousLine();
108
144
  output_1.default.normal((0, texts_1.TXT_SANDBOX_UNZIPPING_COUNT)(count));
@@ -342,8 +342,9 @@ class ServerSftp {
342
342
  async rmdir(reqId, path) {
343
343
  const s = this.debugStart(`SFTP want to remove directory ${path}`);
344
344
  try {
345
- await promises_1.default.rmdir(path, {
345
+ await promises_1.default.rm(path, {
346
346
  recursive: true,
347
+ force: true
347
348
  });
348
349
  this.sftp.status(reqId, STATUS_CODE.OK);
349
350
  this.debugEnd('SFTP remove directory succeed', s);
@@ -0,0 +1,182 @@
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
+ exports.UNZIPPER_FORMAT = exports.UNZIPPER_ENTRY_TYPE = void 0;
7
+ const unzipper_1 = __importDefault(require("unzipper"));
8
+ const tar_stream_1 = __importDefault(require("tar-stream"));
9
+ const node_zlib_1 = __importDefault(require("node:zlib"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const node_stream_1 = require("node:stream");
12
+ const node_fs_1 = __importDefault(require("node:fs"));
13
+ var UNZIPPER_ENTRY_TYPE;
14
+ (function (UNZIPPER_ENTRY_TYPE) {
15
+ UNZIPPER_ENTRY_TYPE["DIRECTORY"] = "Directory";
16
+ UNZIPPER_ENTRY_TYPE["FILE"] = "File";
17
+ })(UNZIPPER_ENTRY_TYPE || (exports.UNZIPPER_ENTRY_TYPE = UNZIPPER_ENTRY_TYPE = {}));
18
+ var UNZIPPER_FORMAT;
19
+ (function (UNZIPPER_FORMAT) {
20
+ UNZIPPER_FORMAT["ZIP"] = "ZIP";
21
+ UNZIPPER_FORMAT["TAR_GZ"] = "TAR.GZ";
22
+ UNZIPPER_FORMAT["TAR_BR"] = "TAR.BR";
23
+ })(UNZIPPER_FORMAT || (exports.UNZIPPER_FORMAT = UNZIPPER_FORMAT = {}));
24
+ const extractZipPathEntry = async (inPath, outPath, onEntry) => {
25
+ const dir = await unzipper_1.default.Open.file(inPath);
26
+ for (let i = 0; i < dir.files.length; i += 1) {
27
+ const entry = dir.files[i];
28
+ const name = entry.path;
29
+ const type = entry.type;
30
+ if (onEntry) {
31
+ await onEntry(name, type);
32
+ }
33
+ const fullPath = node_path_1.default.join(outPath, name);
34
+ if (type === UNZIPPER_ENTRY_TYPE.DIRECTORY) {
35
+ await removePath(fullPath);
36
+ await createDirectory(fullPath);
37
+ }
38
+ else if (type === UNZIPPER_ENTRY_TYPE.FILE) {
39
+ const parentPath = node_path_1.default.resolve(fullPath, '..');
40
+ await createDirectory(parentPath);
41
+ await removePath(fullPath);
42
+ await writeStream(fullPath, entry.stream());
43
+ }
44
+ }
45
+ };
46
+ const streamFromString = (str) => {
47
+ const s = new node_stream_1.Readable();
48
+ s.push(str);
49
+ s.push(null);
50
+ return s;
51
+ };
52
+ const writeStream = async (fullPath, stream) => {
53
+ await node_fs_1.default.promises.writeFile(fullPath, stream);
54
+ };
55
+ const removePath = async (fullPath) => {
56
+ await node_fs_1.default.promises.rm(fullPath, {
57
+ recursive: true,
58
+ force: true,
59
+ });
60
+ };
61
+ const createDirectory = async (fullPath) => {
62
+ await node_fs_1.default.promises.mkdir(fullPath, {
63
+ recursive: true,
64
+ });
65
+ };
66
+ const extractTarStream = (stream, middle, outPath, onEntry) => {
67
+ return new Promise((resolve, reject) => {
68
+ const extract = tar_stream_1.default.extract();
69
+ const closeStream = (err) => {
70
+ if (err)
71
+ reject(err);
72
+ else
73
+ resolve();
74
+ resolve = () => {
75
+ };
76
+ reject = () => {
77
+ };
78
+ if (stream) {
79
+ try {
80
+ stream.removeAllListeners();
81
+ stream.destroy();
82
+ }
83
+ catch {
84
+ // do nothing
85
+ }
86
+ }
87
+ if (middle) {
88
+ try {
89
+ middle.removeAllListeners();
90
+ middle.close();
91
+ }
92
+ catch {
93
+ // do nothing
94
+ }
95
+ }
96
+ if (extract) {
97
+ try {
98
+ extract.removeAllListeners();
99
+ extract.destroy();
100
+ }
101
+ catch {
102
+ // do nothing
103
+ }
104
+ }
105
+ };
106
+ extract.on('entry', async (header, stream, next) => {
107
+ let name;
108
+ let type;
109
+ let str;
110
+ if (header && header.type === 'directory') {
111
+ type = UNZIPPER_ENTRY_TYPE.DIRECTORY;
112
+ name = header.name;
113
+ stream.resume();
114
+ }
115
+ else if (header && header.type === 'file') {
116
+ type = UNZIPPER_ENTRY_TYPE.FILE;
117
+ name = header.name;
118
+ str = stream;
119
+ }
120
+ else if (header && header.type === 'symlink' && header.linkname) {
121
+ type = UNZIPPER_ENTRY_TYPE.FILE;
122
+ name = header.name;
123
+ stream.resume();
124
+ str = streamFromString(header.linkname);
125
+ }
126
+ else {
127
+ stream.resume();
128
+ next();
129
+ return;
130
+ }
131
+ if (onEntry) {
132
+ await onEntry(name, type);
133
+ }
134
+ const fullPath = node_path_1.default.join(outPath, name);
135
+ if (type === UNZIPPER_ENTRY_TYPE.DIRECTORY) {
136
+ await removePath(fullPath);
137
+ await createDirectory(fullPath);
138
+ }
139
+ else if (type === UNZIPPER_ENTRY_TYPE.FILE && str) {
140
+ const parentPath = node_path_1.default.resolve(fullPath, '..');
141
+ await createDirectory(parentPath);
142
+ await removePath(fullPath);
143
+ await writeStream(fullPath, stream);
144
+ }
145
+ next();
146
+ });
147
+ extract.on('error', (err) => {
148
+ closeStream(err);
149
+ });
150
+ extract.on('finish', () => {
151
+ closeStream();
152
+ });
153
+ middle.on('error', (err) => {
154
+ extract.emit('error', err);
155
+ });
156
+ stream.on('error', (err) => {
157
+ extract.emit('error', err);
158
+ });
159
+ stream.pipe(middle).pipe(extract);
160
+ });
161
+ };
162
+ const extractTarGzPathEntry = async (inPath, outPath, onEntry) => {
163
+ return await extractTarStream(node_fs_1.default.createReadStream(inPath), node_zlib_1.default.createGunzip(), outPath, onEntry);
164
+ };
165
+ const extractTarBrPathEntry = async (inPath, outPath, onEntry) => {
166
+ return await extractTarStream(node_fs_1.default.createReadStream(inPath), node_zlib_1.default.createBrotliDecompress(), outPath, onEntry);
167
+ };
168
+ class ArchiverExtract {
169
+ static async extract(format, inPath, outPath, onEntry) {
170
+ if (format === UNZIPPER_FORMAT.ZIP) {
171
+ return await extractZipPathEntry(inPath, outPath, onEntry);
172
+ }
173
+ if (format === UNZIPPER_FORMAT.TAR_GZ) {
174
+ return await extractTarGzPathEntry(inPath, outPath, onEntry);
175
+ }
176
+ if (format === UNZIPPER_FORMAT.TAR_BR) {
177
+ return await extractTarBrPathEntry(inPath, outPath, onEntry);
178
+ }
179
+ throw new Error('Wrong extract format');
180
+ }
181
+ }
182
+ exports.default = ArchiverExtract;
@@ -43,23 +43,19 @@ exports.isFile = isFile;
43
43
  exports.getAppWorkspaceUrl = getAppWorkspaceUrl;
44
44
  exports.getAppWorkspaceSettingsUrl = getAppWorkspaceSettingsUrl;
45
45
  exports.getAppUrl = getAppUrl;
46
- exports.untarGz = untarGz;
47
- exports.unzipFile = unzipFile;
48
46
  exports.getDockerRegistryHostByApiBaseUrl = getDockerRegistryHostByApiBaseUrl;
49
47
  exports.fetchOpenApiSchema = fetchOpenApiSchema;
50
48
  exports.openApiPrepareUrl = openApiPrepareUrl;
51
49
  exports.getOpenApiEndpointByApiBaseUrl = getOpenApiEndpointByApiBaseUrl;
52
50
  exports.getAppHostByApiBaseUrl = getAppHostByApiBaseUrl;
53
51
  const node_path_1 = __importDefault(require("node:path"));
54
- const node_fs_1 = __importStar(require("node:fs"));
52
+ const node_fs_1 = require("node:fs");
55
53
  const texts_1 = require("./texts");
56
54
  const ssh2_1 = __importDefault(require("ssh2"));
57
55
  const node_sea_1 = require("node:sea");
58
56
  const commander_1 = require("commander");
59
57
  const node_os_1 = __importStar(require("node:os"));
60
58
  const node_child_process_1 = require("node:child_process");
61
- const fflate_1 = require("fflate");
62
- const tar_stream_1 = __importDefault(require("tar-stream"));
63
59
  const bundle_1 = require("@scalar/json-magic/bundle");
64
60
  const node_1 = require("@scalar/json-magic/bundle/plugins/node");
65
61
  const openapi_parser_1 = require("@scalar/openapi-parser");
@@ -580,278 +576,6 @@ function getAppWorkspaceSettingsUrl(baseUrl, workspace) {
580
576
  function getAppUrl(baseUrl, path) {
581
577
  return `https://${getAppHostByApiBaseUrl(baseUrl)}${path}`;
582
578
  }
583
- function untarGz(dirPath, tarGzPath, onFile) {
584
- return new Promise((resolve, reject) => {
585
- let _startedFiles = 0;
586
- let _finishedFiles = 0;
587
- let _finishedStream = false;
588
- let _finishedError = null;
589
- let _calledResolve = false;
590
- const rs = node_fs_1.default.createReadStream(tarGzPath);
591
- const extract = tar_stream_1.default.extract();
592
- const _finish = () => {
593
- if (_finishedError || _finishedStream) {
594
- try {
595
- rs.removeAllListeners();
596
- rs.close();
597
- }
598
- catch {
599
- // do nothing
600
- }
601
- }
602
- if (_calledResolve)
603
- return;
604
- if (_finishedError) {
605
- _calledResolve = true;
606
- reject(_finishedError);
607
- return;
608
- }
609
- if (_finishedStream && _startedFiles === _finishedFiles) {
610
- _calledResolve = true;
611
- resolve();
612
- }
613
- };
614
- const finishFile = (err, fws) => {
615
- if (!_finishedError && err)
616
- _finishedError = err;
617
- const complete = () => {
618
- _finishedFiles += 1;
619
- onFile();
620
- _finish();
621
- };
622
- if (fws) {
623
- fws.once('finish', () => {
624
- fws.removeAllListeners();
625
- complete();
626
- });
627
- fws.end();
628
- }
629
- else {
630
- complete();
631
- }
632
- };
633
- const finishStream = (err) => {
634
- if (!_finishedError && err)
635
- _finishedError = err;
636
- _finishedStream = true;
637
- _finish();
638
- };
639
- extract.on('entry', async (header, stream, next) => {
640
- if (_finishedError) {
641
- stream.resume();
642
- next();
643
- return;
644
- }
645
- _startedFiles += 1;
646
- const fullPath = node_path_1.default.join(dirPath, header.name);
647
- const parentPath = node_path_1.default.dirname(fullPath);
648
- let fws;
649
- try {
650
- await node_fs_1.default.promises.rm(fullPath, {
651
- recursive: true,
652
- force: true,
653
- });
654
- }
655
- catch {
656
- // do nothing
657
- }
658
- try {
659
- if (header.type === 'directory') {
660
- await node_fs_1.default.promises.mkdir(fullPath, {
661
- recursive: true,
662
- });
663
- stream.resume();
664
- finishFile();
665
- next();
666
- return;
667
- }
668
- await node_fs_1.default.promises.mkdir(parentPath, {
669
- recursive: true,
670
- });
671
- fws = node_fs_1.default.createWriteStream(fullPath, {
672
- flags: 'w',
673
- });
674
- fws.on('error', (err) => {
675
- finishFile(err, fws);
676
- });
677
- }
678
- catch (err) {
679
- stream.resume();
680
- finishFile(err, fws);
681
- next();
682
- return;
683
- }
684
- stream.on('data', (chunk) => {
685
- if (_finishedError)
686
- return;
687
- if (fws) {
688
- fws.write(chunk);
689
- }
690
- });
691
- stream.on('end', () => {
692
- finishFile(null, fws);
693
- next();
694
- });
695
- stream.on('error', (err) => {
696
- finishFile(err, fws);
697
- next();
698
- });
699
- });
700
- extract.on('finish', () => {
701
- finishStream();
702
- });
703
- extract.on('error', (err) => {
704
- finishStream(err);
705
- });
706
- const gunzip = new fflate_1.Gunzip((data, final) => {
707
- if (_finishedError)
708
- return;
709
- extract.write(Buffer.from(data));
710
- if (final) {
711
- extract.end();
712
- }
713
- });
714
- rs.on('data', (chunk) => {
715
- try {
716
- gunzip.push(chunk, false);
717
- }
718
- catch (err) {
719
- finishStream(err);
720
- }
721
- });
722
- rs.on('error', (err) => {
723
- finishStream(err);
724
- });
725
- rs.on('end', () => {
726
- try {
727
- gunzip.push(new Uint8Array(0), true);
728
- }
729
- catch (err) {
730
- finishStream(err);
731
- }
732
- });
733
- });
734
- }
735
- function unzipFile(dirPath, zipPath, onFile) {
736
- return new Promise((resolve, reject) => {
737
- let _startedFiles = 0;
738
- let _finishedFiles = 0;
739
- let _finishedStream = false;
740
- let _finishedError = null;
741
- let _calledResolve = false;
742
- const rs = node_fs_1.default.createReadStream(zipPath);
743
- const _finish = () => {
744
- if (_finishedError || _finishedStream) {
745
- try {
746
- rs.removeAllListeners();
747
- rs.close();
748
- }
749
- catch {
750
- // do nothing
751
- }
752
- }
753
- if (_calledResolve)
754
- return;
755
- if (_finishedError) {
756
- _calledResolve = true;
757
- reject(_finishedError);
758
- return;
759
- }
760
- if (_finishedStream && _startedFiles === _finishedFiles) {
761
- _calledResolve = true;
762
- resolve();
763
- }
764
- };
765
- const finishFile = (err, fws) => {
766
- if (!_finishedError && err)
767
- _finishedError = err;
768
- const complete = () => {
769
- _finishedFiles += 1;
770
- onFile();
771
- _finish();
772
- };
773
- if (fws) {
774
- fws.once('finish', () => {
775
- fws.removeAllListeners();
776
- complete();
777
- });
778
- fws.end();
779
- }
780
- else {
781
- complete();
782
- }
783
- };
784
- const finishStream = (err) => {
785
- if (!_finishedError && err)
786
- _finishedError = err;
787
- _finishedStream = true;
788
- _finish();
789
- };
790
- const unzip = new fflate_1.Unzip(async (file) => {
791
- if (_finishedError)
792
- return;
793
- _startedFiles += 1;
794
- const fullPath = node_path_1.default.join(dirPath, file.name);
795
- const parentPath = node_path_1.default.dirname(fullPath);
796
- let fws;
797
- try {
798
- await node_fs_1.default.promises.rm(fullPath, {
799
- recursive: true,
800
- force: true,
801
- });
802
- }
803
- catch {
804
- // do nothing
805
- }
806
- try {
807
- if (fullPath.endsWith('/')) {
808
- await node_fs_1.default.promises.mkdir(fullPath, {
809
- recursive: true,
810
- });
811
- finishFile();
812
- return;
813
- }
814
- await node_fs_1.default.promises.mkdir(parentPath, {
815
- recursive: true,
816
- });
817
- fws = node_fs_1.default.createWriteStream(fullPath, {
818
- flags: 'w',
819
- });
820
- fws.on('error', (err) => {
821
- finishFile(err, fws);
822
- });
823
- }
824
- catch (err) {
825
- finishFile(err, fws);
826
- return;
827
- }
828
- file.ondata = (err, data, final) => {
829
- if (_finishedError)
830
- return;
831
- if (err)
832
- finishFile(err, fws);
833
- else {
834
- if (fws)
835
- fws.write(data);
836
- if (final)
837
- finishFile(null, fws);
838
- }
839
- };
840
- file.start();
841
- });
842
- unzip.register(fflate_1.AsyncUnzipInflate);
843
- rs.on('data', (chunk) => {
844
- unzip.push(chunk, false);
845
- });
846
- rs.on('error', (err) => {
847
- finishStream(err);
848
- });
849
- rs.on('end', () => {
850
- unzip.push(new Uint8Array(0), true);
851
- finishStream();
852
- });
853
- });
854
- }
855
579
  function getDockerRegistryHostByApiBaseUrl(baseUrl) {
856
580
  if (baseUrl.hostname.includes('api.buddy.works')) {
857
581
  return 'container-pkg.buddy.works';
@@ -38,7 +38,12 @@ function setCiAndCommitInfo(ciInfo) {
38
38
  exports.pullRequestNumber = ciInfo.pullRequestNumber;
39
39
  exports.commit = ciInfo.commit;
40
40
  exports.baseCommit = ciInfo.baseCommit;
41
- exports.commitDetails = ciInfo.commitDetails;
41
+ exports.commitDetails = ciInfo.commitDetails
42
+ ? {
43
+ ...ciInfo.commitDetails,
44
+ message: ciInfo.commitDetails.message?.slice(0, 250),
45
+ }
46
+ : undefined;
42
47
  if (ciInfo.ci === ci_info_1.CI.BUDDY) {
43
48
  exports.pipelineId = ciInfo.pipelineId;
44
49
  exports.actionId = ciInfo.actionId;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.16.39-dev",
4
+ "version": "1.17.3-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -39,7 +39,7 @@
39
39
  "fflate": "0.8.2",
40
40
  "human-id": "^4.1.3",
41
41
  "isbinaryfile": "5.0.2",
42
- "jsonwebtoken": "9.0.2",
42
+ "jsonwebtoken": "9.0.3",
43
43
  "mime-db": "1.52.0",
44
44
  "mime-types": "2.1.35",
45
45
  "netmask": "2.0.2",
@@ -54,6 +54,7 @@
54
54
  "socket.io-client": "4.7.5",
55
55
  "ssh2": "1.15.0",
56
56
  "tar-stream": "3.1.7",
57
+ "unzipper": "0.12.3",
57
58
  "terminal-kit": "3.1.1",
58
59
  "undici": "6.23.0",
59
60
  "uuid": "10.0.0",
@@ -62,16 +63,15 @@
62
63
  "zod": "3.24.2"
63
64
  },
64
65
  "devDependencies": {
65
- "@eslint/js": "9.13.0",
66
+ "@eslint/js": "9.39.2",
66
67
  "@rollup/plugin-commonjs": "28.0.1",
67
68
  "@rollup/plugin-json": "6.1.0",
68
69
  "@rollup/plugin-node-resolve": "15.3.0",
69
70
  "@rollup/plugin-replace": "6.0.1",
70
- "@stylistic/eslint-plugin-js": "2.9.0",
71
+ "@stylistic/eslint-plugin": "4.4.1",
71
72
  "@types/basic-auth": "1.1.8",
72
73
  "@types/content-disposition": "0.5.4",
73
74
  "@types/cross-spawn": "6.0.6",
74
- "@types/eslint__js": "8.42.3",
75
75
  "@types/jsonwebtoken": "9.0.2",
76
76
  "@types/mime-db": "1.43.6",
77
77
  "@types/mime-types": "2.1.4",
@@ -82,18 +82,19 @@
82
82
  "@types/punycode": "2.1.4",
83
83
  "@types/range-parser": "1.2.1",
84
84
  "@types/ssh2": "1.15.5",
85
- "@types/tar-stream": "3.1.3",
85
+ "@types/tar-stream": "3.1.4",
86
86
  "@types/terminal-kit": "2.5.6",
87
87
  "@types/uuid": "10.0.0",
88
88
  "@types/which": "3.0.4",
89
89
  "@types/ws": "8.18.0",
90
- "eslint": "9.13.0",
91
- "eslint-config-prettier": "9.1.0",
90
+ "@types/unzipper": "0.10.11",
91
+ "eslint": "9.39.2",
92
+ "eslint-config-prettier": "9.1.2",
92
93
  "globals": "15.11.0",
93
94
  "prettier": "3.3.3",
94
95
  "rollup": "4.24.2",
95
96
  "rollup-plugin-natives": "0.7.8",
96
97
  "typescript": "5.9.3",
97
- "typescript-eslint": "8.11.0"
98
+ "typescript-eslint": "8.54.0"
98
99
  }
99
100
  }