@hot-updater/cli-tools 0.32.0 → 0.33.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.
Files changed (2) hide show
  1. package/dist/index.mjs +23 -3
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -30,11 +30,11 @@ import { fileURLToPath } from "node:url";
30
30
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
31
31
  import { scheduler, setImmediate as setImmediate$1, setTimeout as setTimeout$1 } from "node:timers/promises";
32
32
  import { serialize } from "node:v8";
33
- import { finished } from "node:stream/promises";
33
+ import { finished, pipeline as pipeline$1 } from "node:stream/promises";
34
34
  import { Buffer as Buffer$2 } from "node:buffer";
35
35
  import ts from "typescript";
36
36
  import { loadConfig as loadConfig$1 } from "unconfig";
37
- import { brotliDecompressSync } from "node:zlib";
37
+ import { brotliDecompressSync, createBrotliCompress as createBrotliCompress$1 } from "node:zlib";
38
38
  import { getManifestFileHash, stripBundleArtifactMetadata } from "@hot-updater/core";
39
39
  import { createUUIDv7, detectCompressionFormat } from "@hot-updater/plugin-core";
40
40
  import { transformSync } from "oxc-transform";
@@ -43089,6 +43089,21 @@ const getRelativeStorageDir = (relativePath) => {
43089
43089
  const dirname = path$1.posix.dirname(normalized);
43090
43090
  return dirname === "." ? "" : dirname;
43091
43091
  };
43092
+ const isBundleAsset = (relativePath) => /(^|\/)[^/]+\.(ios|android)\.bundle$/.test(relativePath.replace(/\\/g, "/"));
43093
+ function resolvePreparedUploadPath(rootDir, assetPath) {
43094
+ const normalizedAssetPath = assetPath.replaceAll("\\", "/");
43095
+ const outputPath = path$1.resolve(rootDir, "upload-artifacts", `${normalizedAssetPath}.br`);
43096
+ const relativePath = path$1.relative(rootDir, outputPath);
43097
+ if (relativePath.startsWith("..") || path$1.isAbsolute(relativePath) || normalizedAssetPath.startsWith("/")) throw new Error(`Invalid manifest asset path: ${assetPath}`);
43098
+ return outputPath;
43099
+ }
43100
+ async function prepareManifestAssetUploadFile({ assetPath, sourcePath, workDir }) {
43101
+ if (!isBundleAsset(assetPath)) return sourcePath;
43102
+ const uploadPath = resolvePreparedUploadPath(workDir, assetPath);
43103
+ await fs$3.mkdir(path$1.dirname(uploadPath), { recursive: true });
43104
+ await pipeline$1(createReadStream(sourcePath), createBrotliCompress$1(), createWriteStream$1(uploadPath));
43105
+ return uploadPath;
43106
+ }
43092
43107
  const replaceStorageUriLeaf = (storageUri, nextLeaf) => {
43093
43108
  const storageUrl = new URL(storageUri);
43094
43109
  const normalizedPath = storageUrl.pathname.replace(/\/+$/, "");
@@ -43247,7 +43262,12 @@ async function createCopiedBundleArchive({ bundle, config, nextBundleId, storage
43247
43262
  "files",
43248
43263
  getRelativeStorageDir(assetPath)
43249
43264
  ].filter(Boolean).join("/");
43250
- const assetUpload = await storagePlugin.profiles.node.upload(uploadKey, path$1.join(extractDir, assetPath));
43265
+ const uploadPath = await prepareManifestAssetUploadFile({
43266
+ assetPath,
43267
+ sourcePath: path$1.join(extractDir, assetPath),
43268
+ workDir
43269
+ });
43270
+ const assetUpload = await storagePlugin.profiles.node.upload(uploadKey, uploadPath);
43251
43271
  uploadedStorageUris.push(assetUpload.storageUri);
43252
43272
  }
43253
43273
  const assetBaseStorageUri = replaceStorageUriLeaf(manifestUpload.storageUri, "files");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/cli-tools",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20.19.0"
@@ -46,8 +46,8 @@
46
46
  "oxc-transform": "0.121.0",
47
47
  "typescript": "6.0.2",
48
48
  "unconfig": "7.5.0",
49
- "@hot-updater/plugin-core": "0.32.0",
50
- "@hot-updater/core": "0.32.0"
49
+ "@hot-updater/plugin-core": "0.33.0",
50
+ "@hot-updater/core": "0.33.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@clack/prompts": "1.0.1",
@@ -62,7 +62,7 @@
62
62
  "semver": "^7.6.3",
63
63
  "tar": "^7.5.1",
64
64
  "workspace-tools": "^0.36.4",
65
- "@hot-updater/test-utils": "0.32.0"
65
+ "@hot-updater/test-utils": "0.33.0"
66
66
  },
67
67
  "inlinedDependencies": {
68
68
  "@babel/code-frame": "7.29.0",