@embeddable.com/sdk-core 4.1.12 → 4.2.0-next.0

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/lib/index.esm.js CHANGED
@@ -25,7 +25,7 @@ import require$$4 from 'https';
25
25
  import require$$0$1 from 'url';
26
26
  import require$$2$1, { createReadStream } from 'fs';
27
27
  import axios from 'axios';
28
- import archiver from 'archiver';
28
+ import yazl from 'yazl';
29
29
  import { select } from '@inquirer/prompts';
30
30
  import open from 'open';
31
31
  import * as http from 'node:http';
@@ -21500,28 +21500,35 @@ async function buildArchive(config) {
21500
21500
  }
21501
21501
  async function archive(args) {
21502
21502
  const { ctx, filesList, isDev } = args;
21503
- const output = fsSync.createWriteStream(ctx.client.archiveFile);
21504
- const archive = archiver.create("zip", {
21505
- zlib: { level: 9 },
21506
- });
21507
- archive.pipe(output);
21503
+ const zip = new yazl.ZipFile();
21508
21504
  if (!isDev) {
21509
- archive.directory(ctx.client.buildDir, false);
21505
+ addDirectoryToZip(zip, ctx.client.buildDir);
21510
21506
  // NOTE: for backward compatibility, keep the file name as global.css
21511
- archive.file(ctx.client.customCanvasCss, {
21512
- name: "global.css",
21513
- });
21507
+ if (fsSync.existsSync(ctx.client.customCanvasCss)) {
21508
+ zip.addFile(ctx.client.customCanvasCss, "global.css", { compress: true });
21509
+ }
21514
21510
  }
21515
- for (const fileData of filesList) {
21516
- archive.file(fileData[1], {
21517
- name: fileData[0],
21518
- });
21511
+ for (const [name, filePath] of filesList) {
21512
+ zip.addFile(filePath, name, { compress: true });
21519
21513
  }
21520
- await archive.finalize();
21521
- return new Promise((resolve, _reject) => {
21522
- output.on("close", () => resolve());
21514
+ zip.end();
21515
+ return new Promise((resolve, reject) => {
21516
+ const output = fsSync.createWriteStream(ctx.client.archiveFile);
21517
+ zip.outputStream.pipe(output);
21518
+ output.on("close", resolve);
21519
+ output.on("error", reject);
21523
21520
  });
21524
21521
  }
21522
+ function addDirectoryToZip(zip, dir) {
21523
+ const entries = fsSync.readdirSync(dir, { recursive: true });
21524
+ for (const entry of entries) {
21525
+ const relativePath = String(entry);
21526
+ const fullPath = path.join(dir, relativePath);
21527
+ if (fsSync.statSync(fullPath).isFile()) {
21528
+ zip.addFile(fullPath, relativePath, { compress: true });
21529
+ }
21530
+ }
21531
+ }
21525
21532
  async function createFormData(filePath, metadata) {
21526
21533
  const { FormData, Blob } = await import('formdata-node');
21527
21534
  const { fileFromPath } = await Promise.resolve().then(function () { return fileFromPath$1; });