react-native-custom-ota 1.0.3 → 1.0.5

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/bin/custom-ota.js +12 -3
  2. package/package.json +1 -1
package/bin/custom-ota.js CHANGED
@@ -55,7 +55,7 @@ function detectAppId() {
55
55
  try {
56
56
  const data = JSON.parse(fs.readFileSync(appJsonPath, "utf8"));
57
57
  if (data.name) return String(data.name).toLowerCase();
58
- } catch (e) {}
58
+ } catch (e) { }
59
59
  }
60
60
 
61
61
  const pkgJsonPath = path.join(root, "package.json");
@@ -63,7 +63,7 @@ function detectAppId() {
63
63
  try {
64
64
  const data = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
65
65
  if (data.name) return String(data.name).toLowerCase();
66
- } catch (e) {}
66
+ } catch (e) { }
67
67
  }
68
68
 
69
69
  return "com.otademoapp";
@@ -97,7 +97,15 @@ async function buildAndPublish(p) {
97
97
 
98
98
  const bundleFile = p === "android" ? "index.android.bundle" : "main.jsbundle";
99
99
  const bundlePath = path.join(outDir, bundleFile);
100
- const assetsDir = path.join(outDir, "assets");
100
+
101
+ // Metro bundle output:
102
+ // Android tạo drawable-xxx/ và raw/, iOS tạo assets/ bên trong thư mục chỉ định.
103
+ // Đặt assetsDir = outDir để đồng bộ cấu trúc với JSBundle offline.
104
+ const testBrokenAssets =
105
+ process.env.TEST_BROKEN_ASSETS === "true" ||
106
+ args.includes("--broken-assets");
107
+
108
+ const assetsDir = testBrokenAssets ? path.join(outDir, "assets") : outDir;
101
109
 
102
110
  // 1. Metro Bundle
103
111
  console.log(`📦 [1/3] Đang chạy Metro Bundle...`);
@@ -161,6 +169,7 @@ async function buildAndPublish(p) {
161
169
  console.log(`📡 [3/3] Đang upload lên server: ${serverUrl} (App: ${appId})...`);
162
170
  const zipBuffer = fs.readFileSync(zipPath);
163
171
  manifest.size = zipBuffer.length;
172
+ manifest.sha256 = crypto.createHash("sha256").update(zipBuffer).digest("hex");
164
173
 
165
174
  const url = new URL(`/admin/publish/${appId}/${p}/${version}`, serverUrl);
166
175
  const payload = Buffer.from(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-custom-ota",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Self-hosted OTA (Over-The-Air) update library for React Native with automatic rollback, similar to react-native-code-push",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",