@hot-updater/bare 1.0.0-rc.37 → 1.0.0-rc.39
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/dist/index.cjs +0 -110
- package/dist/index.mjs +0 -110
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
enumerable: true
|
|
23
23
|
}) : target, mod));
|
|
24
24
|
//#endregion
|
|
25
|
-
let crypto = require("crypto");
|
|
26
25
|
let fs_promises = require("fs/promises");
|
|
27
26
|
fs_promises = __toESM(fs_promises, 1);
|
|
28
27
|
let path = require("path");
|
|
@@ -6375,111 +6374,12 @@ async function compileHermes({ cwd, sourcemap, inputJsFile }) {
|
|
|
6375
6374
|
}
|
|
6376
6375
|
//#endregion
|
|
6377
6376
|
//#region src/bare.ts
|
|
6378
|
-
const BARE_BUILD_CACHE_VERSION = 1;
|
|
6379
|
-
function hashText(value) {
|
|
6380
|
-
return (0, crypto.createHash)("sha256").update(value).digest("hex");
|
|
6381
|
-
}
|
|
6382
|
-
async function pathExists(filePath) {
|
|
6383
|
-
try {
|
|
6384
|
-
await fs_promises.default.access(filePath);
|
|
6385
|
-
return true;
|
|
6386
|
-
} catch {
|
|
6387
|
-
return false;
|
|
6388
|
-
}
|
|
6389
|
-
}
|
|
6390
|
-
function resolveCacheRoot(cwd) {
|
|
6391
|
-
const cacheDir = process.env.HOT_UPDATER_BARE_BUILD_CACHE_DIR?.trim();
|
|
6392
|
-
if (!cacheDir) return null;
|
|
6393
|
-
return path.default.resolve(cwd, cacheDir);
|
|
6394
|
-
}
|
|
6395
|
-
function resolveCacheKey({ enableHermes, entryFile, platform, resetCache, sourcemap }) {
|
|
6396
|
-
const inputKey = process.env.HOT_UPDATER_BARE_BUILD_CACHE_KEY?.trim();
|
|
6397
|
-
if (!inputKey) return null;
|
|
6398
|
-
return hashText(JSON.stringify({
|
|
6399
|
-
cacheVersion: BARE_BUILD_CACHE_VERSION,
|
|
6400
|
-
enableHermes,
|
|
6401
|
-
entryFile,
|
|
6402
|
-
inputKey,
|
|
6403
|
-
platform,
|
|
6404
|
-
resetCache,
|
|
6405
|
-
sourcemap
|
|
6406
|
-
}));
|
|
6407
|
-
}
|
|
6408
|
-
function resolveCachePaths({ cwd, enableHermes, entryFile, platform, resetCache, sourcemap }) {
|
|
6409
|
-
const root = resolveCacheRoot(cwd);
|
|
6410
|
-
const key = resolveCacheKey({
|
|
6411
|
-
enableHermes,
|
|
6412
|
-
entryFile,
|
|
6413
|
-
platform,
|
|
6414
|
-
resetCache,
|
|
6415
|
-
sourcemap
|
|
6416
|
-
});
|
|
6417
|
-
if (!root || !key) return null;
|
|
6418
|
-
const entryDir = path.default.join(root, key);
|
|
6419
|
-
return {
|
|
6420
|
-
entryDir,
|
|
6421
|
-
filesDir: path.default.join(entryDir, "files"),
|
|
6422
|
-
key,
|
|
6423
|
-
manifestPath: path.default.join(entryDir, "manifest.json"),
|
|
6424
|
-
root
|
|
6425
|
-
};
|
|
6426
|
-
}
|
|
6427
|
-
async function restoreBundleBuildFromCache({ buildPath, cachePaths }) {
|
|
6428
|
-
if (!await pathExists(cachePaths.manifestPath)) return null;
|
|
6429
|
-
try {
|
|
6430
|
-
const metadata = JSON.parse(await fs_promises.default.readFile(cachePaths.manifestPath, "utf8"));
|
|
6431
|
-
await fs_promises.default.cp(cachePaths.filesDir, buildPath, { recursive: true });
|
|
6432
|
-
_hot_updater_cli_tools.log.normal(`[bare] reused build cache ${cachePaths.key.slice(0, 12)}\n`);
|
|
6433
|
-
return { stdout: typeof metadata.stdout === "string" ? metadata.stdout : null };
|
|
6434
|
-
} catch {
|
|
6435
|
-
return null;
|
|
6436
|
-
}
|
|
6437
|
-
}
|
|
6438
|
-
async function saveBundleBuildToCache({ buildPath, cachePaths, stdout }) {
|
|
6439
|
-
if (await pathExists(cachePaths.manifestPath)) return;
|
|
6440
|
-
const tempDir = path.default.join(cachePaths.root, `${cachePaths.key}.${process.pid}.${Date.now()}.tmp`);
|
|
6441
|
-
await fs_promises.default.rm(tempDir, {
|
|
6442
|
-
recursive: true,
|
|
6443
|
-
force: true
|
|
6444
|
-
});
|
|
6445
|
-
await fs_promises.default.mkdir(path.default.dirname(tempDir), { recursive: true });
|
|
6446
|
-
await fs_promises.default.cp(buildPath, path.default.join(tempDir, "files"), { recursive: true });
|
|
6447
|
-
await fs_promises.default.writeFile(path.default.join(tempDir, "manifest.json"), `${JSON.stringify({
|
|
6448
|
-
cacheVersion: BARE_BUILD_CACHE_VERSION,
|
|
6449
|
-
stdout
|
|
6450
|
-
})}\n`);
|
|
6451
|
-
try {
|
|
6452
|
-
await fs_promises.default.rename(tempDir, cachePaths.entryDir);
|
|
6453
|
-
_hot_updater_cli_tools.log.normal(`[bare] saved build cache ${cachePaths.key.slice(0, 12)}\n`);
|
|
6454
|
-
} catch {
|
|
6455
|
-
await fs_promises.default.rm(tempDir, {
|
|
6456
|
-
recursive: true,
|
|
6457
|
-
force: true
|
|
6458
|
-
});
|
|
6459
|
-
}
|
|
6460
|
-
}
|
|
6461
6377
|
const runBundle = async ({ entryFile, cwd, platform, buildPath, sourcemap, enableHermes, resetCache }) => {
|
|
6462
6378
|
const reactNativePath = require.resolve("react-native/package.json", { paths: [cwd] });
|
|
6463
6379
|
const cliPath = path.default.join(path.default.dirname(reactNativePath), "cli.js");
|
|
6464
6380
|
const filename = `index.${platform}`;
|
|
6465
6381
|
const bundleOutput = path.default.join(buildPath, `${filename}.bundle`);
|
|
6466
6382
|
const bundleId = (0, uuidv7.uuidv7)();
|
|
6467
|
-
const cachePaths = resolveCachePaths({
|
|
6468
|
-
cwd,
|
|
6469
|
-
enableHermes,
|
|
6470
|
-
entryFile,
|
|
6471
|
-
platform,
|
|
6472
|
-
resetCache,
|
|
6473
|
-
sourcemap
|
|
6474
|
-
});
|
|
6475
|
-
const cached = cachePaths ? await restoreBundleBuildFromCache({
|
|
6476
|
-
buildPath,
|
|
6477
|
-
cachePaths
|
|
6478
|
-
}) : null;
|
|
6479
|
-
if (cached) return {
|
|
6480
|
-
bundleId,
|
|
6481
|
-
stdout: cached.stdout
|
|
6482
|
-
};
|
|
6483
6383
|
const args = [
|
|
6484
6384
|
"bundle",
|
|
6485
6385
|
"--assets-dest",
|
|
@@ -6512,21 +6412,11 @@ const runBundle = async ({ entryFile, cwd, platform, buildPath, sourcemap, enabl
|
|
|
6512
6412
|
inputJsFile: bundleOutput,
|
|
6513
6413
|
sourcemap
|
|
6514
6414
|
});
|
|
6515
|
-
if (cachePaths) await saveBundleBuildToCache({
|
|
6516
|
-
buildPath,
|
|
6517
|
-
cachePaths,
|
|
6518
|
-
stdout: hermesVersion
|
|
6519
|
-
});
|
|
6520
6415
|
return {
|
|
6521
6416
|
bundleId,
|
|
6522
6417
|
stdout: hermesVersion
|
|
6523
6418
|
};
|
|
6524
6419
|
}
|
|
6525
|
-
if (cachePaths) await saveBundleBuildToCache({
|
|
6526
|
-
buildPath,
|
|
6527
|
-
cachePaths,
|
|
6528
|
-
stdout: null
|
|
6529
|
-
});
|
|
6530
6420
|
return {
|
|
6531
6421
|
bundleId,
|
|
6532
6422
|
stdout: null
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { createHash } from "crypto";
|
|
3
2
|
import fs from "fs/promises";
|
|
4
3
|
import path from "path";
|
|
5
4
|
import { getReactNativeMetadatas, log } from "@hot-updater/cli-tools";
|
|
@@ -6369,111 +6368,12 @@ async function compileHermes({ cwd, sourcemap, inputJsFile }) {
|
|
|
6369
6368
|
}
|
|
6370
6369
|
//#endregion
|
|
6371
6370
|
//#region src/bare.ts
|
|
6372
|
-
const BARE_BUILD_CACHE_VERSION = 1;
|
|
6373
|
-
function hashText(value) {
|
|
6374
|
-
return createHash("sha256").update(value).digest("hex");
|
|
6375
|
-
}
|
|
6376
|
-
async function pathExists(filePath) {
|
|
6377
|
-
try {
|
|
6378
|
-
await fs.access(filePath);
|
|
6379
|
-
return true;
|
|
6380
|
-
} catch {
|
|
6381
|
-
return false;
|
|
6382
|
-
}
|
|
6383
|
-
}
|
|
6384
|
-
function resolveCacheRoot(cwd) {
|
|
6385
|
-
const cacheDir = process.env.HOT_UPDATER_BARE_BUILD_CACHE_DIR?.trim();
|
|
6386
|
-
if (!cacheDir) return null;
|
|
6387
|
-
return path.resolve(cwd, cacheDir);
|
|
6388
|
-
}
|
|
6389
|
-
function resolveCacheKey({ enableHermes, entryFile, platform, resetCache, sourcemap }) {
|
|
6390
|
-
const inputKey = process.env.HOT_UPDATER_BARE_BUILD_CACHE_KEY?.trim();
|
|
6391
|
-
if (!inputKey) return null;
|
|
6392
|
-
return hashText(JSON.stringify({
|
|
6393
|
-
cacheVersion: BARE_BUILD_CACHE_VERSION,
|
|
6394
|
-
enableHermes,
|
|
6395
|
-
entryFile,
|
|
6396
|
-
inputKey,
|
|
6397
|
-
platform,
|
|
6398
|
-
resetCache,
|
|
6399
|
-
sourcemap
|
|
6400
|
-
}));
|
|
6401
|
-
}
|
|
6402
|
-
function resolveCachePaths({ cwd, enableHermes, entryFile, platform, resetCache, sourcemap }) {
|
|
6403
|
-
const root = resolveCacheRoot(cwd);
|
|
6404
|
-
const key = resolveCacheKey({
|
|
6405
|
-
enableHermes,
|
|
6406
|
-
entryFile,
|
|
6407
|
-
platform,
|
|
6408
|
-
resetCache,
|
|
6409
|
-
sourcemap
|
|
6410
|
-
});
|
|
6411
|
-
if (!root || !key) return null;
|
|
6412
|
-
const entryDir = path.join(root, key);
|
|
6413
|
-
return {
|
|
6414
|
-
entryDir,
|
|
6415
|
-
filesDir: path.join(entryDir, "files"),
|
|
6416
|
-
key,
|
|
6417
|
-
manifestPath: path.join(entryDir, "manifest.json"),
|
|
6418
|
-
root
|
|
6419
|
-
};
|
|
6420
|
-
}
|
|
6421
|
-
async function restoreBundleBuildFromCache({ buildPath, cachePaths }) {
|
|
6422
|
-
if (!await pathExists(cachePaths.manifestPath)) return null;
|
|
6423
|
-
try {
|
|
6424
|
-
const metadata = JSON.parse(await fs.readFile(cachePaths.manifestPath, "utf8"));
|
|
6425
|
-
await fs.cp(cachePaths.filesDir, buildPath, { recursive: true });
|
|
6426
|
-
log.normal(`[bare] reused build cache ${cachePaths.key.slice(0, 12)}\n`);
|
|
6427
|
-
return { stdout: typeof metadata.stdout === "string" ? metadata.stdout : null };
|
|
6428
|
-
} catch {
|
|
6429
|
-
return null;
|
|
6430
|
-
}
|
|
6431
|
-
}
|
|
6432
|
-
async function saveBundleBuildToCache({ buildPath, cachePaths, stdout }) {
|
|
6433
|
-
if (await pathExists(cachePaths.manifestPath)) return;
|
|
6434
|
-
const tempDir = path.join(cachePaths.root, `${cachePaths.key}.${process.pid}.${Date.now()}.tmp`);
|
|
6435
|
-
await fs.rm(tempDir, {
|
|
6436
|
-
recursive: true,
|
|
6437
|
-
force: true
|
|
6438
|
-
});
|
|
6439
|
-
await fs.mkdir(path.dirname(tempDir), { recursive: true });
|
|
6440
|
-
await fs.cp(buildPath, path.join(tempDir, "files"), { recursive: true });
|
|
6441
|
-
await fs.writeFile(path.join(tempDir, "manifest.json"), `${JSON.stringify({
|
|
6442
|
-
cacheVersion: BARE_BUILD_CACHE_VERSION,
|
|
6443
|
-
stdout
|
|
6444
|
-
})}\n`);
|
|
6445
|
-
try {
|
|
6446
|
-
await fs.rename(tempDir, cachePaths.entryDir);
|
|
6447
|
-
log.normal(`[bare] saved build cache ${cachePaths.key.slice(0, 12)}\n`);
|
|
6448
|
-
} catch {
|
|
6449
|
-
await fs.rm(tempDir, {
|
|
6450
|
-
recursive: true,
|
|
6451
|
-
force: true
|
|
6452
|
-
});
|
|
6453
|
-
}
|
|
6454
|
-
}
|
|
6455
6371
|
const runBundle = async ({ entryFile, cwd, platform, buildPath, sourcemap, enableHermes, resetCache }) => {
|
|
6456
6372
|
const reactNativePath = __require.resolve("react-native/package.json", { paths: [cwd] });
|
|
6457
6373
|
const cliPath = path.join(path.dirname(reactNativePath), "cli.js");
|
|
6458
6374
|
const filename = `index.${platform}`;
|
|
6459
6375
|
const bundleOutput = path.join(buildPath, `${filename}.bundle`);
|
|
6460
6376
|
const bundleId = uuidv7();
|
|
6461
|
-
const cachePaths = resolveCachePaths({
|
|
6462
|
-
cwd,
|
|
6463
|
-
enableHermes,
|
|
6464
|
-
entryFile,
|
|
6465
|
-
platform,
|
|
6466
|
-
resetCache,
|
|
6467
|
-
sourcemap
|
|
6468
|
-
});
|
|
6469
|
-
const cached = cachePaths ? await restoreBundleBuildFromCache({
|
|
6470
|
-
buildPath,
|
|
6471
|
-
cachePaths
|
|
6472
|
-
}) : null;
|
|
6473
|
-
if (cached) return {
|
|
6474
|
-
bundleId,
|
|
6475
|
-
stdout: cached.stdout
|
|
6476
|
-
};
|
|
6477
6377
|
const args = [
|
|
6478
6378
|
"bundle",
|
|
6479
6379
|
"--assets-dest",
|
|
@@ -6506,21 +6406,11 @@ const runBundle = async ({ entryFile, cwd, platform, buildPath, sourcemap, enabl
|
|
|
6506
6406
|
inputJsFile: bundleOutput,
|
|
6507
6407
|
sourcemap
|
|
6508
6408
|
});
|
|
6509
|
-
if (cachePaths) await saveBundleBuildToCache({
|
|
6510
|
-
buildPath,
|
|
6511
|
-
cachePaths,
|
|
6512
|
-
stdout: hermesVersion
|
|
6513
|
-
});
|
|
6514
6409
|
return {
|
|
6515
6410
|
bundleId,
|
|
6516
6411
|
stdout: hermesVersion
|
|
6517
6412
|
};
|
|
6518
6413
|
}
|
|
6519
|
-
if (cachePaths) await saveBundleBuildToCache({
|
|
6520
|
-
buildPath,
|
|
6521
|
-
cachePaths,
|
|
6522
|
-
stdout: null
|
|
6523
|
-
});
|
|
6524
6414
|
return {
|
|
6525
6415
|
bundleId,
|
|
6526
6416
|
stdout: null
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/bare",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.39",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"uuidv7": "^1.0.2",
|
|
28
|
-
"@hot-updater/cli-tools": "1.0.0-rc.
|
|
29
|
-
"@hot-updater/plugin-core": "1.0.0-rc.
|
|
28
|
+
"@hot-updater/cli-tools": "1.0.0-rc.39",
|
|
29
|
+
"@hot-updater/plugin-core": "1.0.0-rc.39"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^20",
|