bdy 1.25.14-dev → 1.25.15-beta

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.25.14-dev",
4
+ "version": "1.25.15-beta",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://buddy.works/docs/cli",
@@ -69,6 +69,9 @@ const cliError_1 = __importStar(require("./cliError"));
69
69
  const node_fs_1 = __importStar(require("node:fs"));
70
70
  const texts_1 = require("./texts");
71
71
  const node_sea_1 = require("node:sea");
72
+ const node_zlib_1 = __importDefault(require("node:zlib"));
73
+ const node_stream_1 = require("node:stream");
74
+ const promises_1 = require("node:stream/promises");
72
75
  const cliCommand_1 = __importDefault(require("./cliCommand"));
73
76
  const node_os_1 = __importStar(require("node:os"));
74
77
  const node_child_process_1 = require("node:child_process");
@@ -1344,56 +1347,45 @@ const OIDC_ISSUERS = new Set(APP_HOST_OIDC_ISSUERS.map(([, issuer]) => issuer));
1344
1347
  function isKnownOidcIssuer(issuer) {
1345
1348
  return OIDC_ISSUERS.has(issuer);
1346
1349
  }
1347
- const addEntryToZip = (dirPath, zip, entry) => {
1348
- const fflate = require('fflate');
1349
- return new Promise((resolve, reject) => {
1350
- const isDir = entry.isDirectory();
1351
- // A zip entry name is always a relative POSIX path: on Windows path.join builds it with
1352
- // backslashes, and anything below the root keeps the separator the strip above left behind
1353
- let name = node_path_1.default
1354
- .join(entry.parentPath.replace(dirPath, ''), entry.name)
1355
- .split(node_path_1.default.sep)
1356
- .join('/')
1357
- .replace(/^\/+/, '');
1358
- if (isDir)
1359
- name += '/';
1360
- const file = new fflate.ZipDeflate(name, {
1361
- level: 3,
1362
- });
1363
- zip.add(file);
1364
- if (isDir) {
1365
- file.push(new Uint8Array(0), true);
1366
- resolve();
1367
- return;
1368
- }
1369
- const fullPath = node_path_1.default.join(entry.parentPath, entry.name);
1370
- const rs = node_fs_1.default.createReadStream(fullPath);
1371
- const finish = (err) => {
1372
- try {
1373
- rs.removeAllListeners();
1374
- rs.close();
1375
- }
1376
- catch {
1377
- // do nothing
1378
- }
1379
- if (err)
1380
- reject(err);
1381
- else
1382
- resolve();
1383
- };
1384
- rs.on('data', (chunk) => {
1385
- // Always a Buffer here - no encoding is set on the stream - but the event is typed for
1386
- // the ones that do set one, and a string would reach fflate as something it cannot zip
1387
- file.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk, false);
1388
- });
1389
- rs.on('error', (err) => {
1390
- finish(err);
1391
- });
1392
- rs.on('end', () => {
1393
- file.push(new Uint8Array(0), true);
1394
- finish();
1395
- });
1396
- });
1350
+ const addEntryToZip = async (dirPath, zip, entry) => {
1351
+ const isDir = entry.isDirectory();
1352
+ // A zip entry name is always a relative POSIX path: on Windows path.join builds it with
1353
+ // backslashes, and anything below the root keeps the separator the strip above left behind
1354
+ let name = node_path_1.default
1355
+ .join(entry.parentPath.replace(dirPath, ''), entry.name)
1356
+ .split(node_path_1.default.sep)
1357
+ .join('/')
1358
+ .replace(/^\/+/, '');
1359
+ if (isDir)
1360
+ name += '/';
1361
+ // fflate only writes the zip framing here - the entry data is deflated by node's zlib. fflate's
1362
+ // streaming Deflate (0.8.3, fflate#260 / fflate#282) emits back-references past the start of some
1363
+ // inputs (font files, for one), and the file server then rejects the whole archive with
1364
+ // "invalid distance too far back"
1365
+ const file = {
1366
+ filename: name,
1367
+ size: 0,
1368
+ crc: 0,
1369
+ compression: isDir ? 0 : 8,
1370
+ };
1371
+ zip.add(file);
1372
+ if (isDir) {
1373
+ file.ondata(null, new Uint8Array(0), true);
1374
+ return;
1375
+ }
1376
+ await (0, promises_1.pipeline)(node_fs_1.default.createReadStream(node_path_1.default.join(entry.parentPath, entry.name)), new node_stream_1.Transform({
1377
+ transform(chunk, _encoding, callback) {
1378
+ file.crc = node_zlib_1.default.crc32(chunk, file.crc);
1379
+ file.size += chunk.length;
1380
+ callback(null, chunk);
1381
+ },
1382
+ }), node_zlib_1.default.createDeflateRaw({ level: 3 }), new node_stream_1.Writable({
1383
+ write(chunk, _encoding, callback) {
1384
+ file.ondata(null, chunk, false);
1385
+ callback();
1386
+ },
1387
+ }));
1388
+ file.ondata(null, new Uint8Array(0), true);
1397
1389
  };
1398
1390
  const addEntriesToZip = async (dirPath, zip, entries, onEntry) => {
1399
1391
  for (let i = 0; i < entries.length; i += 1) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.25.14-dev",
4
+ "version": "1.25.15-beta",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://buddy.works/docs/cli",