healkite 0.1.2 → 0.3.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/dist/healkite.mjs +1255 -28
- package/package.json +4 -4
package/dist/healkite.mjs
CHANGED
|
@@ -8,8 +8,9 @@ var __export = (target, all) => {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// src/main.ts
|
|
11
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
11
12
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
12
|
-
import { join as
|
|
13
|
+
import { join as join6, resolve as resolve2 } from "node:path";
|
|
13
14
|
|
|
14
15
|
// ../core/src/ids.ts
|
|
15
16
|
var ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
@@ -19833,6 +19834,12 @@ var paths = {
|
|
|
19833
19834
|
assertHex(sha256, "sha256");
|
|
19834
19835
|
return `p/${sha256}.hkp`;
|
|
19835
19836
|
},
|
|
19837
|
+
/** Module manifest (per-team module releases: Re.Pack chunks / federated modules) — short TTL, purged on publish. */
|
|
19838
|
+
modules(channelKey, platform, runtimeVersion) {
|
|
19839
|
+
assertSegment(channelKey, "channelKey");
|
|
19840
|
+
assertSegment(runtimeVersion, "runtimeVersion");
|
|
19841
|
+
return `m/${channelKey}/${platform}/${runtimeVersion}.modules.json`;
|
|
19842
|
+
},
|
|
19836
19843
|
/** Individual asset (campaigns, icons, lazy assets) — content-addressed, immutable. */
|
|
19837
19844
|
asset(sha256) {
|
|
19838
19845
|
assertHex(sha256, "sha256");
|
|
@@ -19930,6 +19937,34 @@ function patchSigningMessage(fromSha256, toSha256, patchSha256) {
|
|
|
19930
19937
|
}
|
|
19931
19938
|
return new TextEncoder().encode(`healkite-patch:v1:${fromSha256}:${toSha256}:${patchSha256}`);
|
|
19932
19939
|
}
|
|
19940
|
+
function fromBase64(b64) {
|
|
19941
|
+
const bin = atob(b64);
|
|
19942
|
+
const out = new Uint8Array(bin.length);
|
|
19943
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
19944
|
+
return out;
|
|
19945
|
+
}
|
|
19946
|
+
async function importPublicKey(spkiBase64) {
|
|
19947
|
+
return crypto.subtle.importKey("spki", fromBase64(spkiBase64), { name: "ECDSA", namedCurve: "P-256" }, false, [
|
|
19948
|
+
"verify"
|
|
19949
|
+
]);
|
|
19950
|
+
}
|
|
19951
|
+
async function verifyMessage(publicKeySpkiBase64, message, signatureBase64) {
|
|
19952
|
+
try {
|
|
19953
|
+
const key = await importPublicKey(publicKeySpkiBase64);
|
|
19954
|
+
const sig = fromBase64(signatureBase64);
|
|
19955
|
+
if (sig.byteLength !== 64) return false;
|
|
19956
|
+
return await crypto.subtle.verify({ name: "ECDSA", hash: "SHA-256" }, key, sig, message);
|
|
19957
|
+
} catch {
|
|
19958
|
+
return false;
|
|
19959
|
+
}
|
|
19960
|
+
}
|
|
19961
|
+
async function verifyManifestSignature(publicKeySpkiBase64, payload, signatureBase64) {
|
|
19962
|
+
try {
|
|
19963
|
+
return await verifyMessage(publicKeySpkiBase64, new TextEncoder().encode(payload), signatureBase64);
|
|
19964
|
+
} catch {
|
|
19965
|
+
return false;
|
|
19966
|
+
}
|
|
19967
|
+
}
|
|
19933
19968
|
|
|
19934
19969
|
// ../protocol/src/hkp.ts
|
|
19935
19970
|
var HKP_MAGIC = "HKP1";
|
|
@@ -19961,20 +19996,108 @@ function validateHkpHeader(value) {
|
|
|
19961
19996
|
return h;
|
|
19962
19997
|
}
|
|
19963
19998
|
|
|
19999
|
+
// ../protocol/src/debug.ts
|
|
20000
|
+
var Logpoint = external_exports.object({
|
|
20001
|
+
id: external_exports.string().regex(/^lp[0-9]{1,3}$/),
|
|
20002
|
+
/** Path from the project root, e.g. src/screens/CartScreen.tsx */
|
|
20003
|
+
file: external_exports.string().min(1).max(300).regex(/^[A-Za-z0-9_@+\-./ ]+$/).refine((f) => !f.split("/").includes("..") && !f.startsWith("/"), "file must be a path inside the project"),
|
|
20004
|
+
line: external_exports.number().int().min(1).max(1e6),
|
|
20005
|
+
/** JavaScript expressions evaluated at that line, e.g. cart.items.length */
|
|
20006
|
+
expressions: external_exports.array(external_exports.string().min(1).max(200).regex(/^[^\n\r]+$/)).min(1).max(10)
|
|
20007
|
+
});
|
|
20008
|
+
var DebugLogBatch = external_exports.object({
|
|
20009
|
+
channel: external_exports.string().max(128),
|
|
20010
|
+
deviceId: external_exports.string().max(128),
|
|
20011
|
+
sessionId: external_exports.string().max(64),
|
|
20012
|
+
logs: external_exports.array(
|
|
20013
|
+
external_exports.object({
|
|
20014
|
+
t: external_exports.number().int(),
|
|
20015
|
+
lp: external_exports.string().max(16),
|
|
20016
|
+
data: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
20017
|
+
})
|
|
20018
|
+
).min(1).max(50)
|
|
20019
|
+
});
|
|
20020
|
+
var MAX_DEBUG_LOG_BYTES = 64 * 1024;
|
|
20021
|
+
var ReleaseChange = external_exports.object({
|
|
20022
|
+
sha: external_exports.string().regex(/^[0-9a-f]{40}$/),
|
|
20023
|
+
pr: external_exports.number().int().positive().nullable(),
|
|
20024
|
+
title: external_exports.string().max(300),
|
|
20025
|
+
author: external_exports.string().max(100).nullable().optional(),
|
|
20026
|
+
/** Merge commits are reverted against their first parent. */
|
|
20027
|
+
merge: external_exports.boolean().optional(),
|
|
20028
|
+
files: external_exports.array(external_exports.string().max(300)).max(500),
|
|
20029
|
+
/** For merge commits: the pull request's own commits (blame hits on these belong to the PR). */
|
|
20030
|
+
commits: external_exports.array(external_exports.string().regex(/^[0-9a-f]{40}$/)).max(500).optional()
|
|
20031
|
+
});
|
|
20032
|
+
var ReleaseSource = external_exports.object({
|
|
20033
|
+
commit: external_exports.string().regex(/^[0-9a-f]{40}$/),
|
|
20034
|
+
baseCommit: external_exports.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
20035
|
+
branch: external_exports.string().max(200).nullable().optional(),
|
|
20036
|
+
/** owner/name on GitHub, when known. */
|
|
20037
|
+
repo: external_exports.string().max(200).nullable().optional(),
|
|
20038
|
+
changes: external_exports.array(ReleaseChange).max(300)
|
|
20039
|
+
});
|
|
20040
|
+
var Suspect = external_exports.object({
|
|
20041
|
+
sha: external_exports.string().regex(/^[0-9a-f]{40}$/),
|
|
20042
|
+
pr: external_exports.number().int().positive().nullable(),
|
|
20043
|
+
title: external_exports.string().max(300),
|
|
20044
|
+
/** Share of the weighted evidence (0..1). */
|
|
20045
|
+
share: external_exports.number().min(0).max(1),
|
|
20046
|
+
evidence: external_exports.array(
|
|
20047
|
+
external_exports.object({
|
|
20048
|
+
file: external_exports.string().max(300),
|
|
20049
|
+
line: external_exports.number().int().nonnegative(),
|
|
20050
|
+
message: external_exports.string().max(300),
|
|
20051
|
+
count: external_exports.number().int().nonnegative(),
|
|
20052
|
+
/** blame: the failing line was changed by this commit; file: the commit changed a file in the stack. */
|
|
20053
|
+
how: external_exports.enum(["blame", "file"])
|
|
20054
|
+
})
|
|
20055
|
+
).max(20)
|
|
20056
|
+
});
|
|
20057
|
+
function parseStack(stack) {
|
|
20058
|
+
const frames = [];
|
|
20059
|
+
for (const raw of stack.split("\n")) {
|
|
20060
|
+
const l = raw.trim();
|
|
20061
|
+
if (!l) continue;
|
|
20062
|
+
let m = /^at (?:(.+?) )?\(?(?:address at )?(.+?):(\d+):(\d+)\)?$/.exec(l);
|
|
20063
|
+
if (m) {
|
|
20064
|
+
frames.push({ fn: m[1] && m[1] !== "anonymous" ? m[1] : null, file: m[2], line: Number(m[3]), column: Number(m[4]) });
|
|
20065
|
+
continue;
|
|
20066
|
+
}
|
|
20067
|
+
m = /^(?:(.*?)@)?(.+?):(\d+):(\d+)$/.exec(l);
|
|
20068
|
+
if (m && !l.startsWith("at ")) frames.push({ fn: m[1] || null, file: m[2], line: Number(m[3]), column: Number(m[4]) });
|
|
20069
|
+
}
|
|
20070
|
+
return frames;
|
|
20071
|
+
}
|
|
20072
|
+
|
|
20073
|
+
// ../protocol/src/provenance.ts
|
|
20074
|
+
var PROVENANCE_AUDIENCE = "healkite";
|
|
20075
|
+
var ProvenancePolicy = external_exports.object({
|
|
20076
|
+
required: external_exports.boolean(),
|
|
20077
|
+
/** owner/name */
|
|
20078
|
+
repo: external_exports.string().regex(/^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/),
|
|
20079
|
+
/** Workflow files allowed to publish, e.g. [".github/workflows/release.yml"]. Empty = any in the repo. */
|
|
20080
|
+
workflows: external_exports.array(external_exports.string().regex(/^\.github\/workflows\/[A-Za-z0-9_.-]+\.ya?ml$/)).max(10).default([]),
|
|
20081
|
+
/** Git refs allowed to publish, e.g. ["refs/heads/main"]. Empty = any. */
|
|
20082
|
+
refs: external_exports.array(external_exports.string().regex(/^refs\/(heads|tags)\/[A-Za-z0-9_./*-]{1,200}$/)).max(10).default([]),
|
|
20083
|
+
/** Approvals (other than the author) the commit's pull request needs. 0 = not checked. */
|
|
20084
|
+
minApprovals: external_exports.number().int().min(0).max(5).default(0)
|
|
20085
|
+
});
|
|
20086
|
+
|
|
19964
20087
|
// ../core/src/publish-release.ts
|
|
19965
|
-
async function publishRelease(
|
|
19966
|
-
const clock =
|
|
19967
|
-
const ids =
|
|
20088
|
+
async function publishRelease(deps2, input2) {
|
|
20089
|
+
const clock = deps2.clock ?? systemClock;
|
|
20090
|
+
const ids = deps2.ids ?? defaultIds;
|
|
19968
20091
|
const bundleKey = paths.bundle(input2.sha256);
|
|
19969
20092
|
const manifestKey = paths.manifest(input2.channel, input2.platform, input2.runtimeVersion);
|
|
19970
|
-
const existing = await
|
|
20093
|
+
const existing = await deps2.blobs.head(bundleKey);
|
|
19971
20094
|
if (!existing) {
|
|
19972
|
-
await
|
|
20095
|
+
await deps2.blobs.put(bundleKey, input2.hkb, {
|
|
19973
20096
|
contentType: "application/vnd.healkite.hkb",
|
|
19974
20097
|
cacheControl: cacheControl.immutable
|
|
19975
20098
|
});
|
|
19976
20099
|
}
|
|
19977
|
-
const previous = await readManifest(
|
|
20100
|
+
const previous = await readManifest(deps2.blobs, manifestKey);
|
|
19978
20101
|
const now = clock.now();
|
|
19979
20102
|
const releaseId = ids.id("rel");
|
|
19980
20103
|
const label = input2.label ?? nextLabel(previous?.release?.label);
|
|
@@ -20009,11 +20132,11 @@ async function publishRelease(deps, input2) {
|
|
|
20009
20132
|
eventSampleRate: previous?.eventSampleRate ?? 1
|
|
20010
20133
|
};
|
|
20011
20134
|
const manifest = ManifestV1.parse(candidate);
|
|
20012
|
-
await
|
|
20135
|
+
await deps2.blobs.put(manifestKey, JSON.stringify(manifest), {
|
|
20013
20136
|
contentType: "application/json",
|
|
20014
20137
|
cacheControl: cacheControl.manifest
|
|
20015
20138
|
});
|
|
20016
|
-
await
|
|
20139
|
+
await deps2.cdn?.purge([joinUrl(deps2.cdnBaseUrl, manifestKey)]);
|
|
20017
20140
|
return { releaseId, bundleKey, manifestKey, manifest, uploaded: !existing };
|
|
20018
20141
|
}
|
|
20019
20142
|
async function readManifest(blobs, key) {
|
|
@@ -20027,10 +20150,10 @@ function nextLabel(previous) {
|
|
|
20027
20150
|
}
|
|
20028
20151
|
|
|
20029
20152
|
// ../core/src/rollback.ts
|
|
20030
|
-
async function rollbackToEmbedded(
|
|
20031
|
-
const clock =
|
|
20153
|
+
async function rollbackToEmbedded(deps2, input2) {
|
|
20154
|
+
const clock = deps2.clock ?? systemClock;
|
|
20032
20155
|
const manifestKey = paths.manifest(input2.channel, input2.platform, input2.runtimeVersion);
|
|
20033
|
-
const previous = await readManifest(
|
|
20156
|
+
const previous = await readManifest(deps2.blobs, manifestKey);
|
|
20034
20157
|
const manifest = ManifestV1.parse({
|
|
20035
20158
|
...previous ?? {
|
|
20036
20159
|
protocolVersion: 1,
|
|
@@ -20042,11 +20165,11 @@ async function rollbackToEmbedded(deps, input2) {
|
|
|
20042
20165
|
release: null,
|
|
20043
20166
|
rollout: void 0
|
|
20044
20167
|
});
|
|
20045
|
-
await
|
|
20168
|
+
await deps2.blobs.put(manifestKey, JSON.stringify(manifest), {
|
|
20046
20169
|
contentType: "application/json",
|
|
20047
20170
|
cacheControl: cacheControl.manifest
|
|
20048
20171
|
});
|
|
20049
|
-
await
|
|
20172
|
+
await deps2.cdn?.purge([joinUrl(deps2.cdnBaseUrl, manifestKey)]);
|
|
20050
20173
|
return { manifestKey, previousLabel: previous?.release?.label ?? null };
|
|
20051
20174
|
}
|
|
20052
20175
|
|
|
@@ -23611,6 +23734,12 @@ async function buildBundle(opts) {
|
|
|
23611
23734
|
await mkdir3(opts.outDir, { recursive: true });
|
|
23612
23735
|
const entry = ENTRY_NAME[opts.platform];
|
|
23613
23736
|
const bundlePath = join3(opts.outDir, entry);
|
|
23737
|
+
const mapsDir = `${opts.outDir}.maps`;
|
|
23738
|
+
const metroMap = join3(mapsDir, `${entry}.metro.map`);
|
|
23739
|
+
if (opts.sourcemap) {
|
|
23740
|
+
await rm2(mapsDir, { recursive: true, force: true });
|
|
23741
|
+
await mkdir3(mapsDir, { recursive: true });
|
|
23742
|
+
}
|
|
23614
23743
|
const expo = isExpoProject(opts.projectDir);
|
|
23615
23744
|
const entryArgs = expo && !existsSync(join3(opts.projectDir, opts.entryFile)) ? [] : ["--entry-file", opts.entryFile];
|
|
23616
23745
|
opts.log(`Bundling ${opts.platform} JS with ${expo ? "Expo (export:embed)" : "Metro"}\u2026`);
|
|
@@ -23629,18 +23758,37 @@ async function buildBundle(opts) {
|
|
|
23629
23758
|
bundlePath,
|
|
23630
23759
|
"--assets-dest",
|
|
23631
23760
|
opts.outDir,
|
|
23632
|
-
"--reset-cache"
|
|
23761
|
+
"--reset-cache",
|
|
23762
|
+
...opts.sourcemap ? ["--sourcemap-output", metroMap] : []
|
|
23633
23763
|
],
|
|
23634
|
-
opts.projectDir
|
|
23764
|
+
opts.projectDir,
|
|
23765
|
+
opts.env
|
|
23635
23766
|
);
|
|
23636
23767
|
if (opts.hermes) {
|
|
23637
23768
|
const hermesc = findHermesc(opts.projectDir);
|
|
23638
23769
|
opts.log(`Compiling to Hermes bytecode (${hermesc})\u2026`);
|
|
23639
23770
|
const hbc = `${bundlePath}.hbc`;
|
|
23640
|
-
await run(hermesc, ["-emit-binary", "-O", "-max-diagnostic-width=80", "-out", hbc, bundlePath], opts.projectDir);
|
|
23771
|
+
await run(hermesc, ["-emit-binary", "-O", "-max-diagnostic-width=80", ...opts.sourcemap ? ["-output-source-map"] : [], "-out", hbc, bundlePath], opts.projectDir);
|
|
23641
23772
|
await rename2(hbc, bundlePath);
|
|
23773
|
+
if (opts.sourcemap) {
|
|
23774
|
+
const hbcMap = `${hbc}.map`;
|
|
23775
|
+
const composed = join3(mapsDir, `${entry}.map`);
|
|
23776
|
+
const composer = findComposer(opts.projectDir);
|
|
23777
|
+
if (composer && existsSync(hbcMap)) {
|
|
23778
|
+
await run("node", [composer, metroMap, hbcMap, "-o", composed], opts.projectDir);
|
|
23779
|
+
await rm2(hbcMap, { force: true });
|
|
23780
|
+
return { dir: opts.outDir, entry, sourcemap: composed };
|
|
23781
|
+
}
|
|
23782
|
+
await rm2(hbcMap, { force: true });
|
|
23783
|
+
opts.log("Couldn't compose the Hermes source map (react-native/scripts/compose-source-maps.js not found); using function names only.");
|
|
23784
|
+
return { dir: opts.outDir, entry };
|
|
23785
|
+
}
|
|
23642
23786
|
}
|
|
23643
|
-
return { dir: opts.outDir, entry };
|
|
23787
|
+
return { dir: opts.outDir, entry, ...opts.sourcemap ? { sourcemap: metroMap } : {} };
|
|
23788
|
+
}
|
|
23789
|
+
function findComposer(projectDir) {
|
|
23790
|
+
const roots = [projectDir, join3(projectDir, ".."), join3(projectDir, "../..")];
|
|
23791
|
+
return roots.map((r) => join3(r, "node_modules/react-native/scripts/compose-source-maps.js")).find((p) => existsSync(p)) ?? null;
|
|
23644
23792
|
}
|
|
23645
23793
|
function findHermesc(projectDir) {
|
|
23646
23794
|
const os = process.platform === "darwin" ? "osx-bin" : process.platform === "win32" ? "win64-bin" : "linux64-bin";
|
|
@@ -23658,9 +23806,9 @@ Pass --no-hermes for JSC apps.`);
|
|
|
23658
23806
|
}
|
|
23659
23807
|
return found;
|
|
23660
23808
|
}
|
|
23661
|
-
function run(cmd, args, cwd) {
|
|
23809
|
+
function run(cmd, args, cwd, env) {
|
|
23662
23810
|
return new Promise((resolve3, reject) => {
|
|
23663
|
-
const child = spawn(cmd, args, { cwd, stdio: "inherit", env: process.env });
|
|
23811
|
+
const child = spawn(cmd, args, { cwd, stdio: "inherit", env: env ? { ...process.env, ...env } : process.env });
|
|
23664
23812
|
child.on("error", reject);
|
|
23665
23813
|
child.on(
|
|
23666
23814
|
"exit",
|
|
@@ -24152,6 +24300,698 @@ async function buildPatches(opts) {
|
|
|
24152
24300
|
return out;
|
|
24153
24301
|
}
|
|
24154
24302
|
|
|
24303
|
+
// src/lib/sourcemap.ts
|
|
24304
|
+
var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
24305
|
+
var B64_INDEX = new Map([...B64].map((c, i) => [c, i]));
|
|
24306
|
+
function decodeVlq(segment) {
|
|
24307
|
+
const out = [];
|
|
24308
|
+
let value = 0;
|
|
24309
|
+
let shift = 0;
|
|
24310
|
+
for (const ch of segment) {
|
|
24311
|
+
const digit = B64_INDEX.get(ch);
|
|
24312
|
+
if (digit === void 0) throw new Error(`invalid base64 VLQ character ${ch}`);
|
|
24313
|
+
value += (digit & 31) << shift;
|
|
24314
|
+
if (digit & 32) shift += 5;
|
|
24315
|
+
else {
|
|
24316
|
+
out.push(value & 1 ? -(value >>> 1) : value >>> 1);
|
|
24317
|
+
value = 0;
|
|
24318
|
+
shift = 0;
|
|
24319
|
+
}
|
|
24320
|
+
}
|
|
24321
|
+
return out;
|
|
24322
|
+
}
|
|
24323
|
+
var SourceMap = class _SourceMap {
|
|
24324
|
+
lines = [];
|
|
24325
|
+
sources;
|
|
24326
|
+
sections = null;
|
|
24327
|
+
constructor(raw) {
|
|
24328
|
+
const map2 = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
24329
|
+
if (map2.sections) {
|
|
24330
|
+
this.sources = [];
|
|
24331
|
+
this.sections = map2.sections.map((s) => ({ line: s.offset.line, column: s.offset.column, map: new _SourceMap(s.map) }));
|
|
24332
|
+
return;
|
|
24333
|
+
}
|
|
24334
|
+
const root = map2.sourceRoot ? map2.sourceRoot.replace(/\/?$/, "/") : "";
|
|
24335
|
+
this.sources = map2.sources.map((s) => root && !/^([a-z]+:|\/)/.test(s) ? root + s : s);
|
|
24336
|
+
let source = 0;
|
|
24337
|
+
let origLine = 0;
|
|
24338
|
+
let origCol = 0;
|
|
24339
|
+
const mappings = map2.mappings ?? "";
|
|
24340
|
+
for (const lineText of mappings.split(";")) {
|
|
24341
|
+
const segs = [];
|
|
24342
|
+
let col = 0;
|
|
24343
|
+
if (lineText) {
|
|
24344
|
+
for (const segText of lineText.split(",")) {
|
|
24345
|
+
const f = decodeVlq(segText);
|
|
24346
|
+
col += f[0] ?? 0;
|
|
24347
|
+
if (f.length >= 4) {
|
|
24348
|
+
source += f[1];
|
|
24349
|
+
origLine += f[2];
|
|
24350
|
+
origCol += f[3];
|
|
24351
|
+
segs.push({ col, source, line: origLine });
|
|
24352
|
+
}
|
|
24353
|
+
}
|
|
24354
|
+
}
|
|
24355
|
+
this.lines.push(segs);
|
|
24356
|
+
}
|
|
24357
|
+
}
|
|
24358
|
+
/** line is 1-based, column 0-based (as in stack traces from Hermes: "1:20481" means bytecode offset 20481). */
|
|
24359
|
+
lookup(line, column) {
|
|
24360
|
+
if (this.sections) {
|
|
24361
|
+
let hit = null;
|
|
24362
|
+
for (const s2 of this.sections) {
|
|
24363
|
+
if (s2.line + 1 < line || s2.line + 1 === line && s2.column <= column) hit = s2;
|
|
24364
|
+
}
|
|
24365
|
+
if (!hit) return null;
|
|
24366
|
+
return hit.map.lookup(line - hit.line, line - 1 === hit.line ? column - hit.column : column);
|
|
24367
|
+
}
|
|
24368
|
+
const segs = this.lines[line - 1];
|
|
24369
|
+
if (!segs?.length) return null;
|
|
24370
|
+
let lo = 0;
|
|
24371
|
+
let hi = segs.length - 1;
|
|
24372
|
+
let best = -1;
|
|
24373
|
+
while (lo <= hi) {
|
|
24374
|
+
const mid = lo + hi >> 1;
|
|
24375
|
+
if (segs[mid].col <= column) {
|
|
24376
|
+
best = mid;
|
|
24377
|
+
lo = mid + 1;
|
|
24378
|
+
} else hi = mid - 1;
|
|
24379
|
+
}
|
|
24380
|
+
if (best < 0) return null;
|
|
24381
|
+
const s = segs[best];
|
|
24382
|
+
const source = this.sources[s.source];
|
|
24383
|
+
return source === void 0 ? null : { source, line: s.line + 1 };
|
|
24384
|
+
}
|
|
24385
|
+
};
|
|
24386
|
+
function projectRelative(source, projectDir) {
|
|
24387
|
+
let s = source.replace(/^webpack:\/\/\/?|^file:\/\//, "");
|
|
24388
|
+
const root = projectDir.replace(/\/+$/, "");
|
|
24389
|
+
if (s.startsWith(`${root}/`)) s = s.slice(root.length + 1);
|
|
24390
|
+
s = s.replace(/^(\.\/)+/, "");
|
|
24391
|
+
if (s.startsWith("/") || s.startsWith("..") || s.includes("node_modules/") || s.startsWith("__prelude__") || s.includes("\0")) return null;
|
|
24392
|
+
return s;
|
|
24393
|
+
}
|
|
24394
|
+
|
|
24395
|
+
// src/lib/blame.ts
|
|
24396
|
+
var FRAMES = 8;
|
|
24397
|
+
var FILE_WEIGHT = 0.3;
|
|
24398
|
+
var NAME_WEIGHT = 0.15;
|
|
24399
|
+
async function findSuspects(errors, changes, deps2) {
|
|
24400
|
+
const owner = /* @__PURE__ */ new Map();
|
|
24401
|
+
for (const c of changes) {
|
|
24402
|
+
owner.set(c.sha, c);
|
|
24403
|
+
for (const sha of c.commits ?? []) owner.set(sha, c);
|
|
24404
|
+
}
|
|
24405
|
+
const score = /* @__PURE__ */ new Map();
|
|
24406
|
+
const evidence = /* @__PURE__ */ new Map();
|
|
24407
|
+
const add = (c, w, e) => {
|
|
24408
|
+
score.set(c.sha, (score.get(c.sha) ?? 0) + w);
|
|
24409
|
+
const list = evidence.get(c.sha) ?? [];
|
|
24410
|
+
const same = list.find((x) => x.file === e.file && x.line === e.line && x.message === e.message);
|
|
24411
|
+
if (same) same.count = Math.max(same.count, e.count);
|
|
24412
|
+
else if (list.length < 20) list.push(e);
|
|
24413
|
+
evidence.set(c.sha, list);
|
|
24414
|
+
};
|
|
24415
|
+
const blameCache = /* @__PURE__ */ new Map();
|
|
24416
|
+
let mapped = 0;
|
|
24417
|
+
for (const err of errors) {
|
|
24418
|
+
if (!err.stack) continue;
|
|
24419
|
+
const errWeight = err.count * (err.isNew ? 1 : 0.25);
|
|
24420
|
+
const frames = parseStack(err.stack).slice(0, FRAMES);
|
|
24421
|
+
for (const [i, f] of frames.entries()) {
|
|
24422
|
+
const w = errWeight / (i + 1) ** 2;
|
|
24423
|
+
let file2 = null;
|
|
24424
|
+
let line = 0;
|
|
24425
|
+
const pos = deps2.map?.lookup(f.line, f.column) ?? null;
|
|
24426
|
+
if (pos) {
|
|
24427
|
+
file2 = projectRelative(pos.source, deps2.projectDir);
|
|
24428
|
+
line = pos.line;
|
|
24429
|
+
} else if (!/\.(jsbundle|bundle)$/.test(f.file)) {
|
|
24430
|
+
file2 = projectRelative(f.file, deps2.projectDir);
|
|
24431
|
+
line = f.line;
|
|
24432
|
+
}
|
|
24433
|
+
const message = err.message.slice(0, 300);
|
|
24434
|
+
if (file2) {
|
|
24435
|
+
mapped++;
|
|
24436
|
+
const key = `${file2}:${line}`;
|
|
24437
|
+
if (!blameCache.has(key)) blameCache.set(key, deps2.blame(file2, line));
|
|
24438
|
+
const sha = await blameCache.get(key);
|
|
24439
|
+
const blamed = sha ? owner.get(sha) : void 0;
|
|
24440
|
+
if (blamed) {
|
|
24441
|
+
add(blamed, w, { file: file2, line, message, count: err.count, how: "blame" });
|
|
24442
|
+
continue;
|
|
24443
|
+
}
|
|
24444
|
+
for (const c of changes) if (c.files.includes(file2)) add(c, w * FILE_WEIGHT, { file: file2, line, message, count: err.count, how: "file" });
|
|
24445
|
+
} else if (f.fn && /^[A-Za-z_$][\w$]{2,}$/.test(f.fn)) {
|
|
24446
|
+
const fn = f.fn;
|
|
24447
|
+
for (const c of changes) {
|
|
24448
|
+
const hit = c.files.find((p) => (p.split("/").pop() ?? "").replace(/\.[jt]sx?$/, "") === fn);
|
|
24449
|
+
if (hit) add(c, w * NAME_WEIGHT, { file: hit, line: 0, message, count: err.count, how: "file" });
|
|
24450
|
+
}
|
|
24451
|
+
}
|
|
24452
|
+
}
|
|
24453
|
+
}
|
|
24454
|
+
const total = [...score.values()].reduce((a, b) => a + b, 0);
|
|
24455
|
+
const suspects = [...score.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5).map(([sha, s]) => {
|
|
24456
|
+
const c = owner.get(sha);
|
|
24457
|
+
return { sha, pr: c.pr, title: c.title, share: total ? Math.round(s / total * 100) / 100 : 0, evidence: (evidence.get(sha) ?? []).sort((a, b) => b.count - a.count) };
|
|
24458
|
+
});
|
|
24459
|
+
return { suspects, summary: summarize(suspects, errors), mapped };
|
|
24460
|
+
}
|
|
24461
|
+
function summarize(suspects, errors) {
|
|
24462
|
+
const fresh = errors.filter((e2) => e2.isNew);
|
|
24463
|
+
if (!fresh.length) return "No new errors on this release. If it was stopped by a business metric (for example checkouts), review the changes below.";
|
|
24464
|
+
const top = suspects[0];
|
|
24465
|
+
if (!top) return `${fresh.length} new error${fresh.length === 1 ? "" : "s"}, but none point at code changed in this release. The cause may be data, a dependency or native code.`;
|
|
24466
|
+
const name = top.pr ? `PR #${top.pr} \u201C${top.title}\u201D` : `Commit ${top.sha.slice(0, 7)} \u201C${top.title}\u201D`;
|
|
24467
|
+
const e = top.evidence[0];
|
|
24468
|
+
const where = e ? e.how === "blame" ? `changed ${e.file}:${e.line}, where` : `touched ${e.file}, which appears in the stack of` : "matches";
|
|
24469
|
+
const n = e?.count ?? 0;
|
|
24470
|
+
return `${name} ${where} ${n} crash${n === 1 ? "" : "es"} ${e ? `(${e.message.slice(0, 120)})` : ""} happen${n === 1 ? "s" : ""}. ${Math.round(top.share * 100)}% of the evidence points at it.`.replace(/\s+/g, " ").trim();
|
|
24471
|
+
}
|
|
24472
|
+
|
|
24473
|
+
// src/lib/git.ts
|
|
24474
|
+
import { execFile } from "node:child_process";
|
|
24475
|
+
import { promisify } from "node:util";
|
|
24476
|
+
var exec = promisify(execFile);
|
|
24477
|
+
async function git(cwd, args, opts = {}) {
|
|
24478
|
+
try {
|
|
24479
|
+
const { stdout } = await exec("git", args, { cwd, maxBuffer: 64 * 1024 * 1024 });
|
|
24480
|
+
return stdout;
|
|
24481
|
+
} catch (e) {
|
|
24482
|
+
if (opts.allowFail) return "";
|
|
24483
|
+
const err = e;
|
|
24484
|
+
throw new Error(`git ${args[0]} failed: ${(err.stderr || err.message).trim().split("\n").slice(-3).join(" ")}`);
|
|
24485
|
+
}
|
|
24486
|
+
}
|
|
24487
|
+
async function gitOk(cwd, args) {
|
|
24488
|
+
return exec("git", args, { cwd }).then(
|
|
24489
|
+
() => true,
|
|
24490
|
+
() => false
|
|
24491
|
+
);
|
|
24492
|
+
}
|
|
24493
|
+
async function isGitRepo(cwd) {
|
|
24494
|
+
return (await git(cwd, ["rev-parse", "--is-inside-work-tree"], { allowFail: true })).trim() === "true";
|
|
24495
|
+
}
|
|
24496
|
+
async function headCommit(cwd) {
|
|
24497
|
+
return (await git(cwd, ["rev-parse", "HEAD"])).trim();
|
|
24498
|
+
}
|
|
24499
|
+
async function hasCommit(cwd, sha) {
|
|
24500
|
+
return (await git(cwd, ["cat-file", "-t", sha], { allowFail: true })).trim() === "commit";
|
|
24501
|
+
}
|
|
24502
|
+
async function githubRepo(cwd) {
|
|
24503
|
+
const url2 = (await git(cwd, ["remote", "get-url", "origin"], { allowFail: true })).trim();
|
|
24504
|
+
const m = /github\.com[:/]([^/]+\/[^/]+?)(?:\.git)?$/.exec(url2);
|
|
24505
|
+
return m ? m[1] : null;
|
|
24506
|
+
}
|
|
24507
|
+
function prNumber(subject) {
|
|
24508
|
+
const m = /^Merge pull request #(\d+)/.exec(subject) ?? /\(#(\d+)\)\s*$/.exec(subject);
|
|
24509
|
+
return m ? Number(m[1]) : null;
|
|
24510
|
+
}
|
|
24511
|
+
async function releaseSource(cwd, baseCommit, log2) {
|
|
24512
|
+
if (!await isGitRepo(cwd)) return null;
|
|
24513
|
+
const commit = await headCommit(cwd);
|
|
24514
|
+
const branch = (await git(cwd, ["rev-parse", "--abbrev-ref", "HEAD"], { allowFail: true })).trim() || null;
|
|
24515
|
+
const repo = await githubRepo(cwd);
|
|
24516
|
+
let base = baseCommit;
|
|
24517
|
+
if (base && !await hasCommit(cwd, base)) {
|
|
24518
|
+
log2(`The previous release's commit ${base.slice(0, 8)} isn't in this clone (shallow checkout?). Use fetch-depth: 0 in CI so Healkite can list this release's changes.`);
|
|
24519
|
+
base = null;
|
|
24520
|
+
}
|
|
24521
|
+
let changes = [];
|
|
24522
|
+
if (base && base !== commit) {
|
|
24523
|
+
const ancestor = await exec("git", ["merge-base", "--is-ancestor", base, commit], { cwd }).then(
|
|
24524
|
+
() => true,
|
|
24525
|
+
() => false
|
|
24526
|
+
);
|
|
24527
|
+
if (!ancestor) log2(`The previous release (${base.slice(0, 8)}) isn't an ancestor of HEAD; listing changes since the branches split.`);
|
|
24528
|
+
const from = ancestor ? base : (await git(cwd, ["merge-base", base, commit])).trim();
|
|
24529
|
+
changes = await changesBetween(cwd, from, commit);
|
|
24530
|
+
}
|
|
24531
|
+
return { commit, baseCommit: base, branch: branch === "HEAD" ? null : branch, repo, changes };
|
|
24532
|
+
}
|
|
24533
|
+
async function changesBetween(cwd, from, to) {
|
|
24534
|
+
const SEP = "";
|
|
24535
|
+
const END = "";
|
|
24536
|
+
const out = await git(cwd, ["log", "--first-parent", `--format=%H${SEP}%P${SEP}%an${SEP}%s${SEP}%b${END}`, "-n", "300", `${from}..${to}`]);
|
|
24537
|
+
const changes = [];
|
|
24538
|
+
for (const rec of out.split(END)) {
|
|
24539
|
+
const t = rec.replace(/^\n+/, "");
|
|
24540
|
+
if (!t.trim()) continue;
|
|
24541
|
+
const [sha, parents, author, subject, body] = t.split(SEP);
|
|
24542
|
+
const ps = parents.trim().split(" ").filter(Boolean);
|
|
24543
|
+
const merge2 = ps.length > 1;
|
|
24544
|
+
const pr = prNumber(subject);
|
|
24545
|
+
const title = (merge2 && pr ? body.trim().split("\n")[0] : subject) || subject;
|
|
24546
|
+
const files = ps[0] ? (await git(cwd, ["diff", "--name-only", ps[0], sha])).split("\n").filter(Boolean).slice(0, 500) : [];
|
|
24547
|
+
const commits = merge2 && ps[1] ? (await git(cwd, ["rev-list", "-n", "500", `${ps[0]}..${ps[1]}`])).split("\n").filter(Boolean) : void 0;
|
|
24548
|
+
changes.push({ sha, pr, title: title.slice(0, 300), author: author.slice(0, 100) || null, merge: merge2 || void 0, files, ...commits ? { commits } : {} });
|
|
24549
|
+
}
|
|
24550
|
+
return changes;
|
|
24551
|
+
}
|
|
24552
|
+
async function blameLine(cwd, commit, file2, line) {
|
|
24553
|
+
const out = await git(cwd, ["blame", "-L", `${line},${line}`, "--porcelain", commit, "--", file2], { allowFail: true });
|
|
24554
|
+
const sha = out.split(" ")[0] ?? "";
|
|
24555
|
+
return /^[0-9a-f]{40}$/.test(sha) ? sha : null;
|
|
24556
|
+
}
|
|
24557
|
+
async function isClean(cwd) {
|
|
24558
|
+
return (await git(cwd, ["status", "--porcelain", "--untracked-files=no"])).trim() === "";
|
|
24559
|
+
}
|
|
24560
|
+
|
|
24561
|
+
// src/lib/projectview.ts
|
|
24562
|
+
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
24563
|
+
import { join as join5, relative as relative3 } from "node:path";
|
|
24564
|
+
var SKIP = /* @__PURE__ */ new Set(["node_modules", "Pods", "build", ".gradle", "DerivedData", ".git", ".healkite", "dist", ".expo"]);
|
|
24565
|
+
function fsProject(root) {
|
|
24566
|
+
return {
|
|
24567
|
+
read(p) {
|
|
24568
|
+
try {
|
|
24569
|
+
return readFileSync2(join5(root, p), "utf8");
|
|
24570
|
+
} catch {
|
|
24571
|
+
return null;
|
|
24572
|
+
}
|
|
24573
|
+
},
|
|
24574
|
+
find(dir, name, maxDepth = 3) {
|
|
24575
|
+
const out = [];
|
|
24576
|
+
const walk2 = (abs, depth) => {
|
|
24577
|
+
let entries;
|
|
24578
|
+
try {
|
|
24579
|
+
entries = readdirSync(abs);
|
|
24580
|
+
} catch {
|
|
24581
|
+
return;
|
|
24582
|
+
}
|
|
24583
|
+
for (const e of entries) {
|
|
24584
|
+
if (SKIP.has(e)) continue;
|
|
24585
|
+
const full = join5(abs, e);
|
|
24586
|
+
let st;
|
|
24587
|
+
try {
|
|
24588
|
+
st = statSync(full);
|
|
24589
|
+
} catch {
|
|
24590
|
+
continue;
|
|
24591
|
+
}
|
|
24592
|
+
if (st.isDirectory()) {
|
|
24593
|
+
if (depth < maxDepth) walk2(full, depth + 1);
|
|
24594
|
+
} else if (name.test(e)) out.push(relative3(root, full));
|
|
24595
|
+
}
|
|
24596
|
+
};
|
|
24597
|
+
walk2(join5(root, dir), 0);
|
|
24598
|
+
return out.sort();
|
|
24599
|
+
},
|
|
24600
|
+
hasNativeCode(pkg) {
|
|
24601
|
+
const base = [root, join5(root, ".."), join5(root, "../..")].map((r) => join5(r, "node_modules", pkg)).find((p) => existsSync3(p));
|
|
24602
|
+
if (!base) return false;
|
|
24603
|
+
if (["android", "ios"].some((d) => existsSync3(join5(base, d)))) return true;
|
|
24604
|
+
if (existsSync3(join5(base, "expo-module.config.json"))) return true;
|
|
24605
|
+
try {
|
|
24606
|
+
return readdirSync(base).some((f) => f.endsWith(".podspec"));
|
|
24607
|
+
} catch {
|
|
24608
|
+
return false;
|
|
24609
|
+
}
|
|
24610
|
+
}
|
|
24611
|
+
};
|
|
24612
|
+
}
|
|
24613
|
+
function appSources(root, limit = 3e3) {
|
|
24614
|
+
const out = [];
|
|
24615
|
+
const walk2 = (abs) => {
|
|
24616
|
+
if (out.length >= limit) return;
|
|
24617
|
+
let entries;
|
|
24618
|
+
try {
|
|
24619
|
+
entries = readdirSync(abs);
|
|
24620
|
+
} catch {
|
|
24621
|
+
return;
|
|
24622
|
+
}
|
|
24623
|
+
for (const e of entries) {
|
|
24624
|
+
if (SKIP.has(e) || e === "ios" || e === "android" || e.startsWith(".") || e === "__tests__") continue;
|
|
24625
|
+
const full = join5(abs, e);
|
|
24626
|
+
let st;
|
|
24627
|
+
try {
|
|
24628
|
+
st = statSync(full);
|
|
24629
|
+
} catch {
|
|
24630
|
+
continue;
|
|
24631
|
+
}
|
|
24632
|
+
if (st.isDirectory()) walk2(full);
|
|
24633
|
+
else if (/\.(m|c)?[jt]sx?$/.test(e) && !/\.(test|spec)\.|\.d\.ts$/.test(e) && st.size < 4e5) out.push({ path: relative3(root, full), text: readFileSync2(full, "utf8") });
|
|
24634
|
+
}
|
|
24635
|
+
};
|
|
24636
|
+
walk2(root);
|
|
24637
|
+
return out;
|
|
24638
|
+
}
|
|
24639
|
+
async function changesSince(projectDir, base) {
|
|
24640
|
+
const prefix = (await git(projectDir, ["rev-parse", "--show-prefix"])).trim();
|
|
24641
|
+
const strip = (p) => prefix && p.startsWith(prefix) ? p.slice(prefix.length) : p;
|
|
24642
|
+
const status = await git(projectDir, ["diff", "--name-status", "--no-renames", base, "--", "."]);
|
|
24643
|
+
const changes = [];
|
|
24644
|
+
for (const line of status.split("\n").filter(Boolean)) {
|
|
24645
|
+
const [s, p] = line.split(" ");
|
|
24646
|
+
changes.push({ path: strip(p), status: s[0] ?? "M", added: [] });
|
|
24647
|
+
}
|
|
24648
|
+
const untracked = await git(projectDir, ["ls-files", "--others", "--exclude-standard", "--", "."], { allowFail: true });
|
|
24649
|
+
for (const p of untracked.split("\n").filter(Boolean)) {
|
|
24650
|
+
const text = existsSync3(join5(projectDir, p)) && /\.(m|c)?[jt]sx?$/.test(p) ? readFileSync2(join5(projectDir, p), "utf8") : "";
|
|
24651
|
+
changes.push({ path: p, status: "A", added: text ? text.split("\n").slice(0, 2e3) : [] });
|
|
24652
|
+
}
|
|
24653
|
+
const js = changes.filter((c) => /\.(m|c)?[jt]sx?$/.test(c.path) && c.status !== "D" && !c.path.includes("node_modules/") && !c.added.length);
|
|
24654
|
+
if (js.length) {
|
|
24655
|
+
const diff = await git(projectDir, ["diff", "-U0", "--no-renames", base, "--", ...js.slice(0, 500).map((c) => c.path)]);
|
|
24656
|
+
let current;
|
|
24657
|
+
for (const line of diff.split("\n")) {
|
|
24658
|
+
const m = /^\+\+\+ b\/(.+)$/.exec(line);
|
|
24659
|
+
if (m) current = js.find((c) => c.path === strip(m[1]));
|
|
24660
|
+
else if (current && line.startsWith("+") && !line.startsWith("+++")) current.added.push(line.slice(1));
|
|
24661
|
+
}
|
|
24662
|
+
}
|
|
24663
|
+
return changes;
|
|
24664
|
+
}
|
|
24665
|
+
async function fileAt(projectDir, rev, path2) {
|
|
24666
|
+
const prefix = (await git(projectDir, ["rev-parse", "--show-prefix"], { allowFail: true })).trim();
|
|
24667
|
+
const out = await git(projectDir, ["show", `${rev}:${prefix}${path2}`], { allowFail: true });
|
|
24668
|
+
return out || null;
|
|
24669
|
+
}
|
|
24670
|
+
var fileNow = (projectDir, path2) => existsSync3(join5(projectDir, path2)) ? readFileSync2(join5(projectDir, path2), "utf8") : null;
|
|
24671
|
+
|
|
24672
|
+
// src/lib/storecheck.ts
|
|
24673
|
+
var SEVERITY_ORDER = { blocker: 0, high: 1, medium: 2, info: 3 };
|
|
24674
|
+
var sortFindings = (f) => [...f].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] || a.id.localeCompare(b.id));
|
|
24675
|
+
var IOS_PURPOSE = [
|
|
24676
|
+
{ pkgs: ["react-native-vision-camera", "expo-camera", "react-native-camera-kit", "react-native-camera"], keys: ["NSCameraUsageDescription"], what: "the camera" },
|
|
24677
|
+
{ pkgs: ["react-native-image-picker", "expo-image-picker", "react-native-image-crop-picker"], keys: ["NSPhotoLibraryUsageDescription", "NSCameraUsageDescription"], what: "photos and the camera" },
|
|
24678
|
+
{ pkgs: ["@react-native-camera-roll/camera-roll", "expo-media-library"], keys: ["NSPhotoLibraryUsageDescription"], what: "the photo library" },
|
|
24679
|
+
{ pkgs: ["@react-native-community/geolocation", "react-native-geolocation-service", "expo-location", "react-native-background-geolocation"], keys: ["NSLocationWhenInUseUsageDescription"], what: "location" },
|
|
24680
|
+
{ pkgs: ["react-native-contacts", "expo-contacts"], keys: ["NSContactsUsageDescription"], what: "contacts" },
|
|
24681
|
+
{ pkgs: ["react-native-calendar-events", "expo-calendar"], keys: ["NSCalendarsFullAccessUsageDescription|NSCalendarsUsageDescription"], what: "calendars" },
|
|
24682
|
+
{ pkgs: ["@react-native-voice/voice"], keys: ["NSMicrophoneUsageDescription", "NSSpeechRecognitionUsageDescription"], what: "the microphone and speech recognition" },
|
|
24683
|
+
{ pkgs: ["react-native-audio-recorder-player", "react-native-audio-record", "expo-audio"], keys: ["NSMicrophoneUsageDescription"], what: "the microphone" },
|
|
24684
|
+
{ pkgs: ["react-native-ble-plx", "react-native-ble-manager"], keys: ["NSBluetoothAlwaysUsageDescription"], what: "Bluetooth" },
|
|
24685
|
+
{ pkgs: ["react-native-biometrics", "expo-local-authentication", "react-native-touch-id", "react-native-keychain"], keys: ["NSFaceIDUsageDescription"], what: "Face ID" },
|
|
24686
|
+
{ pkgs: ["react-native-tracking-transparency", "expo-tracking-transparency"], keys: ["NSUserTrackingUsageDescription"], what: "tracking (App Tracking Transparency)" },
|
|
24687
|
+
{ pkgs: ["react-native-health"], keys: ["NSHealthShareUsageDescription"], what: "HealthKit" },
|
|
24688
|
+
{ pkgs: ["expo-sensors"], keys: ["NSMotionUsageDescription"], what: "motion data" }
|
|
24689
|
+
];
|
|
24690
|
+
var TRACKING_SDKS = ["react-native-appsflyer", "react-native-adjust", "react-native-fbsdk-next", "react-native-google-mobile-ads", "react-native-branch", "@singular-apps/react-native-singular"];
|
|
24691
|
+
var THIRD_PARTY_LOGIN = ["@react-native-google-signin/google-signin", "react-native-fbsdk-next", "@react-native-seoul/kakao-login", "react-native-line-sdk"];
|
|
24692
|
+
var APPLE_LOGIN = ["@invertase/react-native-apple-authentication", "expo-apple-authentication"];
|
|
24693
|
+
var PAYMENT_SDKS = ["@stripe/stripe-react-native", "react-native-razorpay", "react-native-paypal", "react-native-braintree-dropin-ui", "react-native-cashfree-pg-sdk", "paytm_allinone_react-native", "@juspay-tech/react-native-hyperswitch"];
|
|
24694
|
+
var IAP_SDKS = ["react-native-iap", "react-native-purchases", "expo-in-app-purchases", "@adapty/react-native-sdk", "react-native-qonversion"];
|
|
24695
|
+
var ANDROID_RESTRICTED = {
|
|
24696
|
+
READ_SMS: { severity: "high", title: "SMS permission", detail: "Google Play only allows SMS permissions for the default SMS app or approved exceptions, with a Permissions Declaration Form.", fix: "Remove it, or use the SMS Retriever / SMS User Consent API for one-time codes." },
|
|
24697
|
+
RECEIVE_SMS: { severity: "high", title: "SMS permission", detail: "Restricted to default SMS handlers and approved exceptions.", fix: "Use the SMS Retriever API for OTP codes." },
|
|
24698
|
+
SEND_SMS: { severity: "high", title: "SMS permission", detail: "Restricted to default SMS handlers and approved exceptions.", fix: "Open the SMS app with an intent instead." },
|
|
24699
|
+
READ_CALL_LOG: { severity: "high", title: "Call log permission", detail: "Restricted to default phone/assistant apps and approved exceptions.", fix: "Remove it unless your app is a dialer." },
|
|
24700
|
+
WRITE_CALL_LOG: { severity: "high", title: "Call log permission", detail: "Restricted to default phone apps.", fix: "Remove it." },
|
|
24701
|
+
PROCESS_OUTGOING_CALLS: { severity: "high", title: "Call permission", detail: "Restricted to default phone apps.", fix: "Remove it." },
|
|
24702
|
+
QUERY_ALL_PACKAGES: { severity: "high", title: "Package visibility", detail: "Only apps that must see all installed apps (e.g. launchers, antivirus) may use it; others are rejected.", fix: "Declare the specific apps you need in <queries> instead." },
|
|
24703
|
+
MANAGE_EXTERNAL_STORAGE: { severity: "high", title: "All files access", detail: "Allowed only for file managers, backup and similar apps, after a declaration.", fix: "Use scoped storage or the Storage Access Framework." },
|
|
24704
|
+
ACCESS_BACKGROUND_LOCATION: { severity: "high", title: "Background location", detail: "Needs a declaration in Play Console, a video of the feature, and in-app disclosure before asking.", fix: "Use foreground location unless background tracking is your core feature." },
|
|
24705
|
+
REQUEST_INSTALL_PACKAGES: { severity: "high", title: "Installing other apps", detail: "Allowed only when installing apps is a core purpose of your app.", fix: "Remove it." },
|
|
24706
|
+
READ_MEDIA_IMAGES: { severity: "medium", title: "Photo access", detail: "Google Play's photo and video permissions policy allows broad photo access only when it's core to the app; others must use the system photo picker.", fix: "Use the Android photo picker (no permission needed)." },
|
|
24707
|
+
READ_MEDIA_VIDEO: { severity: "medium", title: "Video access", detail: "Same policy as photos: broad access only for core use.", fix: "Use the Android photo picker." },
|
|
24708
|
+
USE_EXACT_ALARM: { severity: "medium", title: "Exact alarms", detail: "USE_EXACT_ALARM is only for alarm clock and calendar apps.", fix: "Use SCHEDULE_EXACT_ALARM (user-granted) or inexact alarms." },
|
|
24709
|
+
SYSTEM_ALERT_WINDOW: { severity: "medium", title: "Draw over other apps", detail: "Reviewed closely; needs a clear user-facing reason.", fix: "Remove it if the app doesn't draw overlays." },
|
|
24710
|
+
BIND_ACCESSIBILITY_SERVICE: { severity: "high", title: "Accessibility service", detail: "Google Play's AccessibilityService API policy needs a declaration and in-app disclosure.", fix: "Remove it unless it's an accessibility tool." }
|
|
24711
|
+
};
|
|
24712
|
+
function deps(pkg) {
|
|
24713
|
+
return new Set(Object.keys({ ...pkg?.dependencies }));
|
|
24714
|
+
}
|
|
24715
|
+
function parseJson(text) {
|
|
24716
|
+
if (!text) return null;
|
|
24717
|
+
try {
|
|
24718
|
+
return JSON.parse(text);
|
|
24719
|
+
} catch {
|
|
24720
|
+
return null;
|
|
24721
|
+
}
|
|
24722
|
+
}
|
|
24723
|
+
function plistStrings(xml) {
|
|
24724
|
+
const out = /* @__PURE__ */ new Map();
|
|
24725
|
+
for (const m of xml.matchAll(/<key>([^<]+)<\/key>\s*<string>([^<]*)<\/string>/g)) out.set(m[1].trim(), m[2].trim());
|
|
24726
|
+
return out;
|
|
24727
|
+
}
|
|
24728
|
+
function plistArray(xml, key) {
|
|
24729
|
+
const m = new RegExp(`<key>${key}</key>\\s*<array>([\\s\\S]*?)</array>`).exec(xml);
|
|
24730
|
+
return m ? [...m[1].matchAll(/<string>([^<]*)<\/string>/g)].map((x) => x[1].trim()) : [];
|
|
24731
|
+
}
|
|
24732
|
+
function androidPermissions(manifest) {
|
|
24733
|
+
return [...manifest.matchAll(/<uses-permission(?:-sdk-23)?\s+[^>]*android:name="([^"]+)"/g)].map((m) => m[1].replace(/^android\.permission\./, ""));
|
|
24734
|
+
}
|
|
24735
|
+
function targetSdk(gradleFiles) {
|
|
24736
|
+
for (const g of gradleFiles) {
|
|
24737
|
+
const m = /targetSdk(?:Version)?\s*=?\s*(\d{2})\b/.exec(g);
|
|
24738
|
+
if (m) return Number(m[1]);
|
|
24739
|
+
}
|
|
24740
|
+
return null;
|
|
24741
|
+
}
|
|
24742
|
+
var PLACEHOLDER = /^(|todo|tbd|test|xxx|description|usage description|\$\([A-Z_]+\))$/i;
|
|
24743
|
+
function scanProject(view, sources) {
|
|
24744
|
+
const findings = [];
|
|
24745
|
+
const add = (f) => findings.push(f);
|
|
24746
|
+
const pkg = parseJson(view.read("package.json"));
|
|
24747
|
+
const d = deps(pkg);
|
|
24748
|
+
const expo = d.has("expo");
|
|
24749
|
+
const has = (list) => list.filter((p) => d.has(p));
|
|
24750
|
+
const plistPath = view.find("ios", /^Info\.plist$/, 2).find((p) => !/Tests?\//.test(p) && !/Pods\//.test(p)) ?? null;
|
|
24751
|
+
const plist = plistPath ? view.read(plistPath) : null;
|
|
24752
|
+
const strings = plist ? plistStrings(plist) : /* @__PURE__ */ new Map();
|
|
24753
|
+
if (plist) {
|
|
24754
|
+
for (const rule of IOS_PURPOSE) {
|
|
24755
|
+
const used = has(rule.pkgs);
|
|
24756
|
+
if (!used.length) continue;
|
|
24757
|
+
for (const alt of rule.keys) {
|
|
24758
|
+
const keys2 = alt.split("|");
|
|
24759
|
+
const present = keys2.find((k) => strings.has(k));
|
|
24760
|
+
if (!present) {
|
|
24761
|
+
add({
|
|
24762
|
+
id: `ios.purpose.${keys2[0]}`,
|
|
24763
|
+
store: "apple",
|
|
24764
|
+
severity: "blocker",
|
|
24765
|
+
title: `Missing ${keys2[0]}`,
|
|
24766
|
+
detail: `${used.join(", ")} uses ${rule.what}. Without a purpose string the app crashes when it asks, and App Review rejects it.`,
|
|
24767
|
+
guideline: "5.1.1",
|
|
24768
|
+
file: plistPath,
|
|
24769
|
+
fix: `Add <key>${keys2[0]}</key><string>Why your app needs ${rule.what}, in plain words</string> to Info.plist.`
|
|
24770
|
+
});
|
|
24771
|
+
} else if (PLACEHOLDER.test(strings.get(present))) {
|
|
24772
|
+
add({
|
|
24773
|
+
id: `ios.purpose.vague.${present}`,
|
|
24774
|
+
store: "apple",
|
|
24775
|
+
severity: "high",
|
|
24776
|
+
title: `${present} is empty or a placeholder`,
|
|
24777
|
+
detail: "Apple rejects purpose strings that don't explain why the app needs access.",
|
|
24778
|
+
guideline: "5.1.1",
|
|
24779
|
+
file: plistPath,
|
|
24780
|
+
fix: "Write a specific sentence, e.g. \u201CScan receipts to add them to your expenses.\u201D"
|
|
24781
|
+
});
|
|
24782
|
+
}
|
|
24783
|
+
}
|
|
24784
|
+
}
|
|
24785
|
+
for (const [key, value] of strings) {
|
|
24786
|
+
if (/UsageDescription$/.test(key) && PLACEHOLDER.test(value) && !findings.some((f) => f.id === `ios.purpose.vague.${key}`)) {
|
|
24787
|
+
add({
|
|
24788
|
+
id: `ios.purpose.vague.${key}`,
|
|
24789
|
+
store: "apple",
|
|
24790
|
+
severity: "medium",
|
|
24791
|
+
title: `${key} is empty or a placeholder`,
|
|
24792
|
+
detail: "If the app (or an SDK in it) ever asks for this permission, Apple rejects a purpose string that doesn't explain why.",
|
|
24793
|
+
guideline: "5.1.1",
|
|
24794
|
+
file: plistPath,
|
|
24795
|
+
fix: "Write the specific reason, or remove the key if nothing in the app asks for it."
|
|
24796
|
+
});
|
|
24797
|
+
}
|
|
24798
|
+
}
|
|
24799
|
+
const tracking = has(TRACKING_SDKS);
|
|
24800
|
+
if (tracking.length && !strings.has("NSUserTrackingUsageDescription")) {
|
|
24801
|
+
add({
|
|
24802
|
+
id: "ios.att",
|
|
24803
|
+
store: "apple",
|
|
24804
|
+
severity: "high",
|
|
24805
|
+
title: "Tracking SDKs without App Tracking Transparency",
|
|
24806
|
+
detail: `${tracking.join(", ")} can track users across apps. If they use the advertising identifier, Apple requires the ATT prompt and NSUserTrackingUsageDescription.`,
|
|
24807
|
+
guideline: "5.1.2",
|
|
24808
|
+
file: plistPath,
|
|
24809
|
+
fix: "Ask with react-native-tracking-transparency before starting these SDKs, or configure them not to track."
|
|
24810
|
+
});
|
|
24811
|
+
}
|
|
24812
|
+
const modes = plistArray(plist, "UIBackgroundModes");
|
|
24813
|
+
if (modes.includes("location") && !strings.has("NSLocationAlwaysAndWhenInUseUsageDescription")) {
|
|
24814
|
+
add({ id: "ios.background-location", store: "apple", severity: "high", title: "Background location without the \u201CAlways\u201D purpose string", detail: "UIBackgroundModes has location, but NSLocationAlwaysAndWhenInUseUsageDescription is missing.", guideline: "2.5.4 / 5.1.1", file: plistPath, fix: "Add the purpose string, or remove the location background mode if you don't track in the background." });
|
|
24815
|
+
}
|
|
24816
|
+
if (modes.includes("audio") && !has(["react-native-track-player", "react-native-video", "expo-av", "expo-audio", "react-native-sound"]).length) {
|
|
24817
|
+
add({ id: "ios.background-audio", store: "apple", severity: "medium", title: "Background audio mode without an audio player", detail: "Apple rejects background modes the app doesn't need.", guideline: "2.5.4", file: plistPath, fix: "Remove the audio background mode unless the app plays audio in the background." });
|
|
24818
|
+
}
|
|
24819
|
+
if (!strings.has("ITSAppUsesNonExemptEncryption") && !/ITSAppUsesNonExemptEncryption/.test(plist)) {
|
|
24820
|
+
add({ id: "ios.encryption", store: "apple", severity: "info", title: "Export compliance not declared", detail: "Without ITSAppUsesNonExemptEncryption, App Store Connect asks about encryption on every upload.", file: plistPath, fix: "Add <key>ITSAppUsesNonExemptEncryption</key><false/> if you only use HTTPS and system crypto." });
|
|
24821
|
+
}
|
|
24822
|
+
const manifests = view.find("ios", /^PrivacyInfo\.xcprivacy$/, 3);
|
|
24823
|
+
if (!manifests.length) {
|
|
24824
|
+
add({ id: "ios.privacy-manifest", store: "apple", severity: "blocker", title: "No privacy manifest", detail: "Apps must include PrivacyInfo.xcprivacy declaring why they use required-reason APIs (React Native itself uses some). Uploads without it are rejected.", guideline: "ITMS-91053", fix: "Add ios/<App>/PrivacyInfo.xcprivacy (the React Native template includes one) and list the APIs your app and SDKs use." });
|
|
24825
|
+
} else if (!manifests.some((m) => /NSPrivacyAccessedAPITypes/.test(view.read(m) ?? ""))) {
|
|
24826
|
+
add({ id: "ios.privacy-manifest.empty", store: "apple", severity: "high", title: "Privacy manifest declares no API reasons", detail: "React Native uses UserDefaults, file timestamps and system boot time; these need declared reasons.", guideline: "ITMS-91053", file: manifests[0], fix: "Add NSPrivacyAccessedAPITypes entries for each required-reason API." });
|
|
24827
|
+
}
|
|
24828
|
+
}
|
|
24829
|
+
const thirdPartyLogin = has(THIRD_PARTY_LOGIN);
|
|
24830
|
+
if (thirdPartyLogin.length && !has(APPLE_LOGIN).length) {
|
|
24831
|
+
add({
|
|
24832
|
+
id: "ios.login",
|
|
24833
|
+
store: "apple",
|
|
24834
|
+
severity: "high",
|
|
24835
|
+
title: "Third-party login without an equivalent option",
|
|
24836
|
+
detail: `${thirdPartyLogin.join(", ")} found. Apps that offer third-party login must also offer a login that limits data collection, such as Sign in with Apple.`,
|
|
24837
|
+
guideline: "4.8",
|
|
24838
|
+
fix: "Add Sign in with Apple (@invertase/react-native-apple-authentication or expo-apple-authentication)."
|
|
24839
|
+
});
|
|
24840
|
+
}
|
|
24841
|
+
const payments = has(PAYMENT_SDKS);
|
|
24842
|
+
if (payments.length && !has(IAP_SDKS).length) {
|
|
24843
|
+
add({
|
|
24844
|
+
id: "ios.payments",
|
|
24845
|
+
store: "apple",
|
|
24846
|
+
severity: "medium",
|
|
24847
|
+
title: "Card payments without in-app purchase",
|
|
24848
|
+
detail: `${payments.join(", ")} found and no in-app purchase library. That's fine for physical goods and services; digital content, subscriptions and features must use in-app purchase.`,
|
|
24849
|
+
guideline: "3.1.1",
|
|
24850
|
+
fix: "If you sell digital content, use react-native-iap or RevenueCat on iOS."
|
|
24851
|
+
});
|
|
24852
|
+
}
|
|
24853
|
+
const code = sources.map((s) => s.text).join("\n");
|
|
24854
|
+
const signsUp = /\b(sign\s?up|signUp|create\s?account|createAccount|register(User|Account)?)\b/i.test(code);
|
|
24855
|
+
const deletes = /\b(delete\s?(my\s)?account|deleteAccount|delete_account|account\s?deletion|close\s?account)\b/i.test(code);
|
|
24856
|
+
if (signsUp && !deletes) {
|
|
24857
|
+
add({
|
|
24858
|
+
id: "both.account-deletion",
|
|
24859
|
+
store: "both",
|
|
24860
|
+
severity: "high",
|
|
24861
|
+
title: "Account creation without account deletion",
|
|
24862
|
+
detail: "The app lets people create an account, but no way to delete it was found. Apple requires deletion inside the app; Google Play requires it in the app and on the web.",
|
|
24863
|
+
guideline: "Apple 5.1.1(v) \xB7 Google Play User Data policy",
|
|
24864
|
+
fix: "Add \u201CDelete account\u201D in settings and a web page for deletion requests."
|
|
24865
|
+
});
|
|
24866
|
+
}
|
|
24867
|
+
if (/\b(eval\s*\(|new\s+Function\s*\()/.test(code)) {
|
|
24868
|
+
add({ id: "both.dynamic-code", store: "apple", severity: "info", title: "Runs code from strings (eval / new Function)", detail: "Code that downloads and runs other code is reviewed closely; over-the-air JavaScript is allowed only within the reviewed app's purpose.", guideline: "2.5.2" });
|
|
24869
|
+
}
|
|
24870
|
+
const manifestPath = view.read("android/app/src/main/AndroidManifest.xml") ? "android/app/src/main/AndroidManifest.xml" : null;
|
|
24871
|
+
const manifest = manifestPath ? view.read(manifestPath) : null;
|
|
24872
|
+
const expoConfig = parseJson(view.read("app.json"));
|
|
24873
|
+
const perms = manifest ? androidPermissions(manifest) : (expoConfig?.expo?.android?.permissions ?? []).map((p) => p.replace(/^android\.permission\./, ""));
|
|
24874
|
+
for (const p of perms) {
|
|
24875
|
+
const rule = ANDROID_RESTRICTED[p];
|
|
24876
|
+
if (rule) add({ id: `android.permission.${p}`, store: "google", severity: rule.severity, title: `${rule.title} (${p})`, detail: rule.detail, guideline: "Google Play permissions policy", file: manifestPath ?? "app.json", fix: rule.fix });
|
|
24877
|
+
}
|
|
24878
|
+
if (manifest && /usesCleartextTraffic="true"/.test(manifest)) {
|
|
24879
|
+
add({ id: "android.cleartext", store: "google", severity: "medium", title: "Cleartext (http://) traffic allowed", detail: "Not a policy rejection, but Google Play's pre-launch report and security reviews flag it.", file: manifestPath, fix: "Use HTTPS, or allow cleartext only for debug builds." });
|
|
24880
|
+
}
|
|
24881
|
+
const gradle = ["android/build.gradle", "android/app/build.gradle", "android/app/build.gradle.kts", "android/build.gradle.kts"].map((p) => view.read(p)).filter((x) => !!x);
|
|
24882
|
+
const sdk = targetSdk(gradle);
|
|
24883
|
+
if (sdk !== null && sdk < 35) {
|
|
24884
|
+
add({ id: "android.target-sdk", store: "google", severity: "blocker", title: `targetSdk ${sdk} is too old`, detail: "Google Play requires new apps and updates to target Android 15 (API 35) or higher since 31 August 2025, and raises the level every year.", guideline: "Google Play target API level requirement", file: "android/build.gradle", fix: "Set targetSdkVersion to 35 or higher (36 recommended) and test the behaviour changes." });
|
|
24885
|
+
} else if (sdk !== null && sdk < 36) {
|
|
24886
|
+
add({ id: "android.target-sdk.next", store: "google", severity: "medium", title: `targetSdk ${sdk}: the yearly requirement moves up`, detail: "Google Play raises the required target API level every August. Check Play Console for the current deadline.", file: "android/build.gradle", fix: "Plan the move to API 36." });
|
|
24887
|
+
}
|
|
24888
|
+
if (d.has("react-native-google-mobile-ads") && manifest && !/com\.google\.android\.gms\.ads\.APPLICATION_ID/.test(manifest) && !expo) {
|
|
24889
|
+
add({ id: "android.ads-id", store: "google", severity: "high", title: "AdMob app ID missing", detail: "react-native-google-mobile-ads needs com.google.android.gms.ads.APPLICATION_ID in the manifest; the app crashes at start without it.", file: manifestPath, fix: "Set your AdMob app ID in app.json (react-native-google-mobile-ads) and rebuild." });
|
|
24890
|
+
}
|
|
24891
|
+
return { findings: sortFindings(findings), checked: { ios: !!plist, android: !!manifest || !!expoConfig?.expo, expo, sources: sources.length } };
|
|
24892
|
+
}
|
|
24893
|
+
var NATIVE_PATH = /^(ios|android)\/|(^|\/)(Podfile(\.lock)?|Gemfile(\.lock)?|.*\.podspec)$/;
|
|
24894
|
+
var JS_FILE = /\.(m|c)?[jt]sx?$/;
|
|
24895
|
+
var SCREEN_PATH = /(^|\/)(screens?|pages|views)\/|(^|\/)app\/(?!.*_layout)[^/]+\.[jt]sx$/i;
|
|
24896
|
+
function scanOta(input2) {
|
|
24897
|
+
const findings = [];
|
|
24898
|
+
const add = (f) => findings.push(f);
|
|
24899
|
+
const native = input2.changes.filter((c) => NATIVE_PATH.test(c.path));
|
|
24900
|
+
if (native.length) {
|
|
24901
|
+
add({
|
|
24902
|
+
id: "ota.native-files",
|
|
24903
|
+
store: "both",
|
|
24904
|
+
severity: "blocker",
|
|
24905
|
+
title: "Native code changed",
|
|
24906
|
+
detail: `${native.length} native file(s) changed (${native.slice(0, 4).map((c) => c.path).join(", ")}${native.length > 4 ? "\u2026" : ""}). Over-the-air updates only carry JavaScript and assets; JavaScript that relies on these changes will crash on the store build users have.`,
|
|
24907
|
+
fix: "Ship a store build for this, or move the native change to a separate branch."
|
|
24908
|
+
});
|
|
24909
|
+
}
|
|
24910
|
+
const before = deps(parseJson(input2.pkgBefore));
|
|
24911
|
+
const beforeVersions = parseJson(input2.pkgBefore)?.dependencies ?? {};
|
|
24912
|
+
const afterVersions = parseJson(input2.pkgAfter)?.dependencies ?? {};
|
|
24913
|
+
const nativeDeps = Object.keys(afterVersions).filter((p) => (!before.has(p) || beforeVersions[p] !== afterVersions[p]) && input2.view.hasNativeCode(p));
|
|
24914
|
+
if (nativeDeps.length) {
|
|
24915
|
+
add({
|
|
24916
|
+
id: "ota.native-deps",
|
|
24917
|
+
store: "both",
|
|
24918
|
+
severity: "blocker",
|
|
24919
|
+
title: "Dependencies with native code added or upgraded",
|
|
24920
|
+
detail: `${nativeDeps.join(", ")}: the store build users have doesn't contain this native code, so the update would crash or misbehave.`,
|
|
24921
|
+
fix: "Ship a store build with these dependencies first, then OTA updates that use them."
|
|
24922
|
+
});
|
|
24923
|
+
}
|
|
24924
|
+
if (input2.appJsonBefore !== void 0 && input2.appJsonAfter !== void 0 && input2.appJsonBefore !== input2.appJsonAfter) {
|
|
24925
|
+
const strip = (t) => {
|
|
24926
|
+
const j = parseJson(t ?? null)?.expo ?? {};
|
|
24927
|
+
const { plugins, ios, android, permissions, name, scheme } = j;
|
|
24928
|
+
return JSON.stringify({ plugins, ios, android, permissions, name, scheme });
|
|
24929
|
+
};
|
|
24930
|
+
if (strip(input2.appJsonBefore) !== strip(input2.appJsonAfter)) {
|
|
24931
|
+
add({ id: "ota.expo-native-config", store: "both", severity: "blocker", title: "Native app config changed (app.json)", detail: "Plugins, permissions, name or platform settings in app.json only take effect in a new store build.", fix: "Ship a store build for these settings." });
|
|
24932
|
+
}
|
|
24933
|
+
}
|
|
24934
|
+
const jsAdded = input2.changes.filter((c) => JS_FILE.test(c.path) && !c.path.includes("node_modules/"));
|
|
24935
|
+
const lines = jsAdded.flatMap((c) => c.added.map((l) => ({ path: c.path, l })));
|
|
24936
|
+
const firstHit = (re) => lines.find((x) => re.test(x.l));
|
|
24937
|
+
const plistPath = input2.view.find("ios", /^Info\.plist$/, 2).find((p) => !/Tests?\//.test(p)) ?? null;
|
|
24938
|
+
const strings = plistPath ? plistStrings(input2.view.read(plistPath) ?? "") : null;
|
|
24939
|
+
const manifest = input2.view.read("android/app/src/main/AndroidManifest.xml");
|
|
24940
|
+
const declared = manifest ? new Set(androidPermissions(manifest)) : null;
|
|
24941
|
+
for (const x of lines) {
|
|
24942
|
+
for (const m of x.l.matchAll(/PERMISSIONS\.(?:ANDROID\.|)([A-Z_]{3,})/g)) {
|
|
24943
|
+
const p = m[1];
|
|
24944
|
+
if (declared && !declared.has(p) && !/^(IOS)$/.test(p)) {
|
|
24945
|
+
add({ id: `ota.android-permission.${p}`, store: "google", severity: "blocker", title: `Asks for ${p}, which the app doesn't declare`, detail: `${x.path} requests ${p}, but AndroidManifest.xml doesn't list it. The request fails on the store build.`, file: x.path, fix: "Add the permission in a store build first." });
|
|
24946
|
+
}
|
|
24947
|
+
}
|
|
24948
|
+
for (const m of x.l.matchAll(/PERMISSIONS\.IOS\.([A-Z_]+)/g)) {
|
|
24949
|
+
const key = { CAMERA: "NSCameraUsageDescription", MICROPHONE: "NSMicrophoneUsageDescription", PHOTO_LIBRARY: "NSPhotoLibraryUsageDescription", CONTACTS: "NSContactsUsageDescription", LOCATION_WHEN_IN_USE: "NSLocationWhenInUseUsageDescription", LOCATION_ALWAYS: "NSLocationAlwaysAndWhenInUseUsageDescription", FACE_ID: "NSFaceIDUsageDescription", APP_TRACKING_TRANSPARENCY: "NSUserTrackingUsageDescription", BLUETOOTH: "NSBluetoothAlwaysUsageDescription", CALENDARS: "NSCalendarsUsageDescription" }[m[1]];
|
|
24950
|
+
if (key && strings && !strings.has(key)) {
|
|
24951
|
+
add({ id: `ota.ios-permission.${key}`, store: "apple", severity: "blocker", title: `Asks for ${m[1].toLowerCase().replace(/_/g, " ")} without ${key}`, detail: `${x.path} requests it, but the store build's Info.plist has no ${key}. iOS terminates the app when it asks.`, file: x.path, fix: "Add the purpose string in a store build first." });
|
|
24952
|
+
}
|
|
24953
|
+
}
|
|
24954
|
+
}
|
|
24955
|
+
const pay = firstHit(/(@stripe\/stripe-react-native|react-native-razorpay|checkout\.stripe\.com|buy\.stripe\.com|razorpay\.com\/payment|paypal\.com\/checkout|initPaymentSheet|presentPaymentSheet)/);
|
|
24956
|
+
if (pay) {
|
|
24957
|
+
add({
|
|
24958
|
+
id: "ota.payments",
|
|
24959
|
+
store: "apple",
|
|
24960
|
+
severity: "medium",
|
|
24961
|
+
title: "Adds or changes a card or web payment flow",
|
|
24962
|
+
detail: `${pay.path}: Apple requires in-app purchase for digital goods, subscriptions and features. A new external payment flow shipped over the air, without review, is a common reason for removal.`,
|
|
24963
|
+
guideline: "3.1.1 / 3.3.1(B)",
|
|
24964
|
+
file: pay.path,
|
|
24965
|
+
fix: "Fine for physical goods and services. For digital content, use in-app purchase or ship this in a reviewed store build."
|
|
24966
|
+
});
|
|
24967
|
+
}
|
|
24968
|
+
const dyn = firstHit(/\b(eval\s*\(|new\s+Function\s*\(|injectedJavaScript\s*=\s*\{?\s*await|injectJavaScript\(\s*(await|remote|fetched))/);
|
|
24969
|
+
if (dyn) {
|
|
24970
|
+
add({ id: "ota.dynamic-code", store: "apple", severity: "medium", title: "Runs code from strings", detail: `${dyn.path}: code that downloads and runs further code goes beyond what reviewed OTA updates may do.`, guideline: "2.5.2", file: dyn.path, fix: "Remove eval/new Function, or ship it in a store build." });
|
|
24971
|
+
}
|
|
24972
|
+
const newScreens = input2.changes.filter((c) => c.status === "A" && JS_FILE.test(c.path) && SCREEN_PATH.test(c.path));
|
|
24973
|
+
const newRoutes = lines.filter((x) => /<(Stack|Tab|Drawer)\.Screen\b|createStackNavigator|name=["'][A-Z]\w+["']\s+component=/.test(x.l)).length;
|
|
24974
|
+
if (newScreens.length >= 3 || newRoutes >= 3) {
|
|
24975
|
+
add({
|
|
24976
|
+
id: "ota.new-features",
|
|
24977
|
+
store: "apple",
|
|
24978
|
+
severity: "medium",
|
|
24979
|
+
title: `Adds ${Math.max(newScreens.length, newRoutes)} new screens`,
|
|
24980
|
+
detail: "Apple allows OTA updates that fix bugs and improve features without changing the app's primary purpose. A set of new screens may count as a new feature that should go through review.",
|
|
24981
|
+
guideline: "3.3.1(B) \xB7 2.3.1",
|
|
24982
|
+
fix: "If this is a new feature area, include it in a store build; keep OTA for fixes and small changes."
|
|
24983
|
+
});
|
|
24984
|
+
}
|
|
24985
|
+
const hidden = firstHit(/\b(isReviewer|inReview|appReviewMode|hideFromReview|REVIEW_MODE)\b/);
|
|
24986
|
+
if (hidden) {
|
|
24987
|
+
add({ id: "ota.hidden-features", store: "both", severity: "blocker", title: "Behaves differently for app reviewers", detail: `${hidden.path}: hiding features from App Review is a reason for removal from the store and the developer program.`, guideline: "Apple 2.3.1 \xB7 Google Play Deceptive Behavior", file: hidden.path, fix: "Remove the review-specific code path." });
|
|
24988
|
+
}
|
|
24989
|
+
const sorted = sortFindings(findings);
|
|
24990
|
+
const verdict = sorted.some((f) => f.severity === "blocker") ? "blocked" : sorted.some((f) => f.severity === "high" || f.severity === "medium") ? "risky" : "safe";
|
|
24991
|
+
const summary = verdict === "safe" ? "Safe to ship over the air: JavaScript and asset changes only, nothing the stores restrict." : verdict === "blocked" ? `Don't ship this over the air: ${sorted.find((f) => f.severity === "blocker").title.toLowerCase()}.` : `Review before shipping: ${sorted.filter((f) => f.severity !== "info").map((f) => f.title.toLowerCase()).join("; ")}.`;
|
|
24992
|
+
return { verdict, findings: sorted, summary };
|
|
24993
|
+
}
|
|
24994
|
+
|
|
24155
24995
|
// ../../node_modules/aws4fetch/dist/aws4fetch.esm.mjs
|
|
24156
24996
|
/**
|
|
24157
24997
|
* @license MIT <https://opensource.org/licenses/MIT>
|
|
@@ -24594,7 +25434,7 @@ async function api() {
|
|
|
24594
25434
|
if (!config2) throw new Error("Not logged in. Run `healkite login --api-url <url> --token <hk_\u2026>` or set HEALKITE_API_URL/HEALKITE_TOKEN.");
|
|
24595
25435
|
return new ApiClient(config2);
|
|
24596
25436
|
}
|
|
24597
|
-
var program2 = new Command().name("healkite").description("Self-healing over-the-air updates for React Native").version("0.
|
|
25437
|
+
var program2 = new Command().name("healkite").description("Self-healing over-the-air updates for React Native").version("0.3.0");
|
|
24598
25438
|
program2.command("login").description("Save API credentials to ~/.healkite/config.json").requiredOption("--api-url <url>", "Healkite API URL, e.g. https://api.healkite.com").requiredOption("--token <token>", "access key (hk_\u2026)").action(async (o) => {
|
|
24599
25439
|
const client = new ApiClient({ apiUrl: o.apiUrl, token: o.token });
|
|
24600
25440
|
await client.request("GET", "/v1/apps");
|
|
@@ -24696,7 +25536,7 @@ channels.command("create").argument("<name>").requiredOption("--app <appId>").ac
|
|
|
24696
25536
|
log(`Created channel ${name}. Put this key in your app config (HealkiteChannel / healkite_channel):`);
|
|
24697
25537
|
console.log(ch.key);
|
|
24698
25538
|
});
|
|
24699
|
-
program2.command("release").description("Bundle the app's JS + assets and publish it to a channel").addOption(platformOption()).requiredOption("-c, --channel <key>", "channel key").requiredOption("-r, --runtime-version <version>", "binary/runtime version this bundle targets").option("--project <dir>", "React Native project directory", ".").option("--entry-file <file>", "JS entry file", "index.js").option("--no-hermes", "skip Hermes bytecode compilation (JSC apps)").option("--rollout <pct>", "percentage of devices (1-100)", pct).option("--mandatory", "mark the update as mandatory", false).option("-d, --description <text>", "release notes").option("--sign <pem>", "sign with this private key (or set HEALKITE_SIGNING_KEY / HEALKITE_SIGNING_KEY_PATH)").option("--patch-from <n>", "diff against the last N distinct bundles on this target (0 disables)", "3").option("--guarded", "Guarded Release: start small, auto-advance when healthy, auto-halt on crashes").option("--guard-steps <list>", "rollout steps, e.g. 1,10,50,100").option("--guard-soak <duration>", "time per step, e.g. 30m, 2h, 0s").option("--guard-min-installs <n>", "installs needed per step before advancing").option("--guard-metric <event:maxDropPct...>", "halt if trackEvent(event) per session drops > maxDropPct % vs previous release, e.g. checkout_success:20").option("--at <time>", 'go live later: +2h, "2026-11-20 00:00" (local time) or an ISO time').option("--until <time>", "campaign end: the release turns itself off and devices go back to the previous one").option("--device <id...>", "only these devices get it (support fixes, testers); everyone else is untouched").option("--hotfix", "instant hotfix: mandatory + silent push so devices update now (needs Firebase connected)").option("--push", "silent push so devices check now (not mandatory)").option("--experiment <name>", "A/B experiment: compare this release (--rollout %) with what everyone else runs").option("--metric <event...>", "with --experiment: trackEvent names to compare per session (first = primary)").option("--max-size <size>", "fail before uploading if the bundle is bigger, e.g. 2MB").option("--max-growth <pct>", "fail before uploading if the bundle grew more than this % vs the previous release").option("--out <dir>", "local mode: write to a CDN directory instead of the API").action(async (o) => void await releaseAction(o));
|
|
25539
|
+
program2.command("release").description("Bundle the app's JS + assets and publish it to a channel").addOption(platformOption()).requiredOption("-c, --channel <key>", "channel key").requiredOption("-r, --runtime-version <version>", "binary/runtime version this bundle targets").option("--project <dir>", "React Native project directory", ".").option("--entry-file <file>", "JS entry file", "index.js").option("--no-hermes", "skip Hermes bytecode compilation (JSC apps)").option("--rollout <pct>", "percentage of devices (1-100)", pct).option("--mandatory", "mark the update as mandatory", false).option("-d, --description <text>", "release notes").option("--sign <pem>", "sign with this private key (or set HEALKITE_SIGNING_KEY / HEALKITE_SIGNING_KEY_PATH)").option("--patch-from <n>", "diff against the last N distinct bundles on this target (0 disables)", "3").option("--guarded", "Guarded Release: start small, auto-advance when healthy, auto-halt on crashes").option("--guard-steps <list>", "rollout steps, e.g. 1,10,50,100").option("--guard-soak <duration>", "time per step, e.g. 30m, 2h, 0s").option("--guard-min-installs <n>", "installs needed per step before advancing").option("--guard-max-startup <pct>", "halt if the median app start gets more than this % slower than the previous release, e.g. 20").option("--guard-metric <event:maxDropPct...>", "halt if trackEvent(event) per session drops > maxDropPct % vs previous release, e.g. checkout_success:20").option("--at <time>", 'go live later: +2h, "2026-11-20 00:00" (local time) or an ISO time').option("--until <time>", "campaign end: the release turns itself off and devices go back to the previous one").option("--device <id...>", "only these devices get it (support fixes, testers); everyone else is untouched").option("--hotfix", "instant hotfix: mandatory + silent push so devices update now (needs Firebase connected)").option("--live", "live patch: like --hotfix, and apps reload at a safe moment keeping the state they registered (screen, cart, forms)").option("--push", "silent push so devices check now (not mandatory)").option("--experiment <name>", "A/B experiment: compare this release (--rollout %) with what everyone else runs").option("--metric <event...>", "with --experiment: trackEvent names to compare per session (first = primary)").option("--max-size <size>", "fail before uploading if the bundle is bigger, e.g. 2MB").option("--max-growth <pct>", "fail before uploading if the bundle grew more than this % vs the previous release").option("--out <dir>", "local mode: write to a CDN directory instead of the API").option("--no-store-check", "skip the OTA store-rules check").option("--no-startup-profile", "don't measure start-up time on devices").option("--force", "publish even when the store check says it can't ship over the air").action(async (o) => void await releaseAction(o));
|
|
24700
25540
|
var codepush = program2.command("codepush").description("CodePush / App Center-compatible commands for migrating scripts and CI (a deployment is a Healkite channel)");
|
|
24701
25541
|
async function cpApp(nameOrId) {
|
|
24702
25542
|
const { apps: apps2 } = await (await api()).request("GET", "/v1/summary");
|
|
@@ -24852,7 +25692,7 @@ program2.command("size").description("Build the bundle and check its size agains
|
|
|
24852
25692
|
projectDir,
|
|
24853
25693
|
platform: o.platform,
|
|
24854
25694
|
entryFile: o.entryFile,
|
|
24855
|
-
outDir:
|
|
25695
|
+
outDir: join6(projectDir, ".healkite/build", o.platform),
|
|
24856
25696
|
hermes: o.hermes,
|
|
24857
25697
|
log: o.json ? () => {
|
|
24858
25698
|
} : log
|
|
@@ -24956,6 +25796,7 @@ function guardOptions(o) {
|
|
|
24956
25796
|
if (o.guardSteps) g.steps = String(o.guardSteps).split(",").map((x) => Number(x.trim()));
|
|
24957
25797
|
if (o.guardSoak) g.soakSeconds = parseDuration(String(o.guardSoak));
|
|
24958
25798
|
if (o.guardMinInstalls) g.minInstalls = Number(o.guardMinInstalls);
|
|
25799
|
+
if (o.guardMaxStartup) g.maxStartupRegressionPct = Number(o.guardMaxStartup);
|
|
24959
25800
|
if (Array.isArray(o.guardMetric) && o.guardMetric.length) {
|
|
24960
25801
|
g.metrics = o.guardMetric.map((spec) => {
|
|
24961
25802
|
const [event, pct2] = spec.split(":");
|
|
@@ -25044,6 +25885,344 @@ program2.command("inspect").description("Verify and list the contents of an .hkb
|
|
|
25044
25885
|
}
|
|
25045
25886
|
log(`${files.size} files verified`);
|
|
25046
25887
|
});
|
|
25888
|
+
var ICON = { blocker: "\x1B[31m\u2718 BLOCKER\x1B[0m", high: "\x1B[31m\u25B2 HIGH\x1B[0m", medium: "\x1B[33m\u25CF MEDIUM\x1B[0m", info: "\x1B[2m\xB7 info\x1B[0m" };
|
|
25889
|
+
var STORE = { apple: "App Store", google: "Google Play", both: "Both stores" };
|
|
25890
|
+
function printFindings(findings) {
|
|
25891
|
+
for (const f of findings) {
|
|
25892
|
+
console.log(`
|
|
25893
|
+
${ICON[f.severity]} ${f.title} \x1B[2m(${STORE[f.store]}${f.guideline ? ` \xB7 ${f.guideline}` : ""})\x1B[0m`);
|
|
25894
|
+
console.log(` ${f.detail}`);
|
|
25895
|
+
if (f.file) console.log(` \x1B[2m${f.file}\x1B[0m`);
|
|
25896
|
+
if (f.fix) console.log(` \u2192 ${f.fix}`);
|
|
25897
|
+
}
|
|
25898
|
+
}
|
|
25899
|
+
program2.command("store-check").description("Find what could get your next App Store / Google Play build rejected (permissions, purpose strings, privacy manifest, login, payments, account deletion, target SDK\u2026)").option("--project <dir>", "React Native project directory", ".").option("--json", "print findings as JSON (for CI)").option("--fail-on <level>", "exit with an error at this severity or worse: blocker | high | medium", "blocker").action(async (o) => {
|
|
25900
|
+
const projectDir = resolve2(o.project);
|
|
25901
|
+
const r = scanProject(fsProject(projectDir), appSources(projectDir));
|
|
25902
|
+
if (o.json) console.log(JSON.stringify(r, null, 2));
|
|
25903
|
+
else {
|
|
25904
|
+
log(`Checked ${[r.checked.ios && "iOS", r.checked.android && "Android"].filter(Boolean).join(" and ") || "the project"} (${r.checked.sources} source files)${r.checked.expo ? ", Expo" : ""}`);
|
|
25905
|
+
if (!r.findings.length) log("No store rejection risks found.");
|
|
25906
|
+
printFindings(r.findings);
|
|
25907
|
+
const n = (s) => r.findings.filter((f) => f.severity === s).length;
|
|
25908
|
+
console.log(`
|
|
25909
|
+
${n("blocker")} blocker \xB7 ${n("high")} high \xB7 ${n("medium")} medium \xB7 ${n("info")} info`);
|
|
25910
|
+
}
|
|
25911
|
+
const order = ["blocker", "high", "medium"];
|
|
25912
|
+
const limit = order.indexOf(o.failOn);
|
|
25913
|
+
if (limit >= 0 && r.findings.some((f) => order.indexOf(f.severity) >= 0 && order.indexOf(f.severity) <= limit)) process.exitCode = 1;
|
|
25914
|
+
});
|
|
25915
|
+
program2.command("ota-check").description("Check whether changes can ship over the air: native changes, missing permissions, payments, new features (store rules for OTA)").option("--project <dir>", "React Native project directory", ".").option("--base <ref>", "compare with this commit or branch (default: what the channel's devices run, with -c/-p/-r)").option("-c, --channel <key>", "channel key (to compare with the live release)").addOption(new Option("-p, --platform <platform>").choices([...PLATFORMS])).option("-r, --runtime-version <version>", "app version").option("--json", "print the result as JSON").action(async (o) => {
|
|
25916
|
+
const projectDir = resolve2(o.project);
|
|
25917
|
+
let base = o.base;
|
|
25918
|
+
if (!base && o.channel && o.platform && o.runtimeVersion) base = await liveCommit(o.channel, o.platform, o.runtimeVersion) ?? void 0;
|
|
25919
|
+
if (!base) throw new Error("pass --base <ref>, or -c/-p/-r so Healkite compares with the release devices run");
|
|
25920
|
+
const r = await otaCheck(projectDir, base);
|
|
25921
|
+
if (o.json) return console.log(JSON.stringify(r, null, 2));
|
|
25922
|
+
log(r.summary);
|
|
25923
|
+
printFindings(r.findings);
|
|
25924
|
+
if (r.verdict === "blocked") process.exitCode = 1;
|
|
25925
|
+
});
|
|
25926
|
+
async function liveCommit(channel, platform, runtimeVersion) {
|
|
25927
|
+
const client = await api();
|
|
25928
|
+
const q = new URLSearchParams({ platform, runtimeVersion, limit: "20" });
|
|
25929
|
+
const { releases } = await client.request("GET", `/v1/channels/${channel}/releases?${q}`);
|
|
25930
|
+
const live = releases.find((r) => r.status === "active" && !r.audience);
|
|
25931
|
+
if (!live) return null;
|
|
25932
|
+
return (await client.request("GET", `/v1/releases/${live.id}/source`).catch(() => ({ source: null }))).source?.commit ?? null;
|
|
25933
|
+
}
|
|
25934
|
+
async function otaCheck(projectDir, base) {
|
|
25935
|
+
const view = fsProject(projectDir);
|
|
25936
|
+
return scanOta({
|
|
25937
|
+
changes: await changesSince(projectDir, base),
|
|
25938
|
+
pkgBefore: await fileAt(projectDir, base, "package.json"),
|
|
25939
|
+
pkgAfter: fileNow(projectDir, "package.json"),
|
|
25940
|
+
appJsonBefore: await fileAt(projectDir, base, "app.json"),
|
|
25941
|
+
appJsonAfter: fileNow(projectDir, "app.json"),
|
|
25942
|
+
view
|
|
25943
|
+
});
|
|
25944
|
+
}
|
|
25945
|
+
program2.command("startup").description("App start time on real devices for a release, vs the previous one, and the modules that take the time").argument("<release>", "release id").option("--json", "print as JSON").action(async (releaseId, o) => {
|
|
25946
|
+
const client = await api();
|
|
25947
|
+
const v = await client.request("GET", `/v1/releases/${releaseId}/startup`);
|
|
25948
|
+
if (o.json) return console.log(JSON.stringify(v, null, 2));
|
|
25949
|
+
const s = (ms) => ms === null ? "\u2013" : `${(ms / 1e3).toFixed(2)} s`;
|
|
25950
|
+
if (!v.release.samples) return log("No start-up samples yet. Devices send them on 1 in 5 launches once the build has the Babel plugin.");
|
|
25951
|
+
log(`${v.release.label}: median ${s(v.release.p50)} \xB7 p75 ${s(v.release.p75)} \xB7 p90 ${s(v.release.p90)} (${v.release.samples} launches)`);
|
|
25952
|
+
if (v.previous?.p50 && v.release.p50) {
|
|
25953
|
+
const d = (v.release.p50 - v.previous.p50) / v.previous.p50 * 100;
|
|
25954
|
+
log(`${v.previous.label}: median ${s(v.previous.p50)} \u2192 ${d >= 0 ? "+" : ""}${d.toFixed(0)}%`);
|
|
25955
|
+
}
|
|
25956
|
+
console.log("\nWhere start-up time goes (average per launch, own work only):");
|
|
25957
|
+
for (const m of v.modules.slice(0, 15)) {
|
|
25958
|
+
const was = m.isNew ? " \x1B[33mnew\x1B[0m" : m.previousAvgMs !== null && m.avgMs > m.previousAvgMs * 1.2 + 2 ? ` \x1B[33mwas ${m.previousAvgMs} ms\x1B[0m` : "";
|
|
25959
|
+
console.log(` ${String(m.avgMs).padStart(7)} ms ${m.path}${was}`);
|
|
25960
|
+
}
|
|
25961
|
+
console.log("\nTo speed it up: move work out of module top level (do it when first used), and import heavy packages where they're needed, not in App.tsx.");
|
|
25962
|
+
});
|
|
25963
|
+
var moduleCmd = program2.command("module").description("Independent releases per team: ship a module (Re.Pack chunk or federated remote) on its own");
|
|
25964
|
+
moduleCmd.command("release").description("Publish one module's scripts (from its Re.Pack output folder) with its own rollout or guard").argument("<name>", "module name, e.g. payments").requiredOption("--dir <dir>", "folder with this module's built scripts (Re.Pack output), e.g. build/outputs/android/remotes/payments").addOption(platformOption()).requiredOption("-c, --channel <key>", "channel key").requiredOption("-r, --runtime-version <version>", "app version the module is built for").option("--rollout <pct>", "percentage of devices (1-100)", pct).option("--guarded", "roll out 1% \u2192 10% \u2192 50% \u2192 100% and stop on load failures or errors in the module").option("-d, --description <text>", "release notes").action(async (name, o) => {
|
|
25965
|
+
const client = await api();
|
|
25966
|
+
const dir = resolve2(o.dir);
|
|
25967
|
+
const { readdir: readdir3, stat: stat2 } = await import("node:fs/promises");
|
|
25968
|
+
const { createHash: createHash2 } = await import("node:crypto");
|
|
25969
|
+
const files = {};
|
|
25970
|
+
const walk2 = async (d, prefix) => {
|
|
25971
|
+
for (const e of await readdir3(d)) {
|
|
25972
|
+
const full = join6(d, e);
|
|
25973
|
+
if ((await stat2(full)).isDirectory()) await walk2(full, `${prefix}${e}/`);
|
|
25974
|
+
else if (!e.endsWith(".map")) {
|
|
25975
|
+
const bytes = new Uint8Array(await readFile5(full));
|
|
25976
|
+
const sha256 = createHash2("sha256").update(bytes).digest("hex");
|
|
25977
|
+
await client.uploadBlob(bytes, sha256, "asset");
|
|
25978
|
+
files[`${prefix}${e}`] = { sha256, size: bytes.byteLength };
|
|
25979
|
+
}
|
|
25980
|
+
}
|
|
25981
|
+
};
|
|
25982
|
+
await walk2(dir, "");
|
|
25983
|
+
if (!Object.keys(files).length) throw new Error(`no scripts in ${dir}`);
|
|
25984
|
+
log(`Uploaded ${Object.keys(files).length} file(s) for ${name}`);
|
|
25985
|
+
const r = await client.request("POST", "/v1/modules/releases", {
|
|
25986
|
+
channelKey: o.channel,
|
|
25987
|
+
platform: o.platform,
|
|
25988
|
+
runtimeVersion: o.runtimeVersion,
|
|
25989
|
+
module: name,
|
|
25990
|
+
files,
|
|
25991
|
+
description: o.description,
|
|
25992
|
+
rolloutPct: o.rollout,
|
|
25993
|
+
guard: o.guarded || void 0
|
|
25994
|
+
});
|
|
25995
|
+
log(`Released ${r.label} (${r.id}) to ${r.rolloutPct}% of devices${o.guarded ? ", guarded" : ""}. Other modules are unchanged.`);
|
|
25996
|
+
});
|
|
25997
|
+
moduleCmd.command("list").description("Module releases of an app").requiredOption("--app <id>", "app id").action(async (o) => {
|
|
25998
|
+
const client = await api();
|
|
25999
|
+
const { releases } = await client.request(
|
|
26000
|
+
"GET",
|
|
26001
|
+
`/v1/apps/${o.app}/modules`
|
|
26002
|
+
);
|
|
26003
|
+
for (const r of releases) {
|
|
26004
|
+
console.log(`${r.label.padEnd(24)} ${r.platform}/${r.runtimeVersion} ${String(r.rolloutPct).padStart(3)}% ${r.status}${r.guard ? ` \xB7 guard ${r.guard.state}${r.guard.reason ? ` (${r.guard.reason})` : ""}` : ""} ${r.id}`);
|
|
26005
|
+
}
|
|
26006
|
+
});
|
|
26007
|
+
var debugCmd = program2.command("debug").description("Production debugging: logpoint builds for chosen devices");
|
|
26008
|
+
debugCmd.command("build").description("Build the release those devices run with the session's logpoints and send it to them only (run in CI or locally)").argument("<session>", "debug session id (dbg_\u2026), from the dashboard").option("--project <dir>", "React Native project directory", ".").option("--entry-file <file>", "JS entry file", "index.js").option("--no-hermes", "skip Hermes bytecode compilation (JSC apps)").option("--sign <pem>", "sign with this private key (or HEALKITE_SIGNING_KEY)").action(async (sessionId, o) => {
|
|
26009
|
+
const client = await api();
|
|
26010
|
+
const projectDir = resolve2(o.project);
|
|
26011
|
+
const spec = await client.request("GET", `/v1/debug-sessions/${sessionId}/spec`);
|
|
26012
|
+
const fail = async (message) => {
|
|
26013
|
+
await client.request("POST", `/v1/debug-sessions/${sessionId}/status`, { status: "failed", error: message }).catch(() => {
|
|
26014
|
+
});
|
|
26015
|
+
throw new Error(message);
|
|
26016
|
+
};
|
|
26017
|
+
if (!await hasLogpointPlugin(projectDir)) {
|
|
26018
|
+
await fail('Add the Healkite Babel plugin once: in babel.config.js, plugins: ["react-native-healkite/babel"]. It does nothing in normal builds.');
|
|
26019
|
+
}
|
|
26020
|
+
if (spec.baseCommit && await isGitRepo(projectDir)) {
|
|
26021
|
+
const head = await headCommit(projectDir);
|
|
26022
|
+
if (head !== spec.baseCommit) log(`Note: building ${head.slice(0, 8)}, but the devices run ${spec.baseCommit.slice(0, 8)}. Check out that commit so line numbers match.`);
|
|
26023
|
+
}
|
|
26024
|
+
for (const lp of spec.logpoints) {
|
|
26025
|
+
if (!existsSync4(join6(projectDir, lp.file))) await fail(`${lp.file} doesn't exist in this checkout`);
|
|
26026
|
+
}
|
|
26027
|
+
await client.request("POST", `/v1/debug-sessions/${sessionId}/status`, { status: "building" });
|
|
26028
|
+
log(`Debug session ${sessionId}: ${spec.logpoints.length} logpoint(s) for ${spec.devices.length} device(s)`);
|
|
26029
|
+
try {
|
|
26030
|
+
const rel = await releaseAction({
|
|
26031
|
+
platform: spec.platform,
|
|
26032
|
+
channel: spec.channelKey,
|
|
26033
|
+
runtimeVersion: spec.runtimeVersion,
|
|
26034
|
+
project: o.project,
|
|
26035
|
+
entryFile: o.entryFile,
|
|
26036
|
+
hermes: o.hermes,
|
|
26037
|
+
sign: o.sign,
|
|
26038
|
+
patchFrom: "3",
|
|
26039
|
+
device: spec.devices,
|
|
26040
|
+
until: new Date(spec.expiresAt).toISOString(),
|
|
26041
|
+
description: `Debug session ${sessionId} (${spec.logpoints.map((l) => `${l.file}:${l.line}`).join(", ")})`.slice(0, 2e3),
|
|
26042
|
+
skipSource: true,
|
|
26043
|
+
buildEnv: { HEALKITE_LOGPOINTS: JSON.stringify({ sessionId, logpoints: spec.logpoints }), HEALKITE_PROJECT_ROOT: projectDir }
|
|
26044
|
+
});
|
|
26045
|
+
if (!rel) throw new Error("nothing was published");
|
|
26046
|
+
await client.request("POST", `/v1/debug-sessions/${sessionId}/attach`, { releaseId: rel.id });
|
|
26047
|
+
log(`Live. The devices get it on their next launch; values appear in the dashboard and with \`healkite debug logs ${sessionId} --follow\`.`);
|
|
26048
|
+
log(`It turns itself off at ${new Date(spec.expiresAt).toLocaleString()} (or when you end the session).`);
|
|
26049
|
+
} catch (e) {
|
|
26050
|
+
await fail(e.message.slice(0, 400));
|
|
26051
|
+
}
|
|
26052
|
+
});
|
|
26053
|
+
debugCmd.command("logs").description("Print the values captured by a debug session").argument("<session>", "debug session id").option("-f, --follow", "keep printing new values").action(async (sessionId, o) => {
|
|
26054
|
+
const client = await api();
|
|
26055
|
+
let after = null;
|
|
26056
|
+
for (; ; ) {
|
|
26057
|
+
const r = await client.request(
|
|
26058
|
+
"GET",
|
|
26059
|
+
`/v1/debug-sessions/${sessionId}${after ? `?after=${after}` : ""}`
|
|
26060
|
+
);
|
|
26061
|
+
const where = new Map(r.session.logpoints.map((l) => [l.id, `${l.file}:${l.line}`]));
|
|
26062
|
+
for (const l of r.logs) {
|
|
26063
|
+
console.log(`${new Date(l.ts).toLocaleTimeString()} ${l.deviceId.slice(0, 8)} ${where.get(l.logpointId) ?? l.logpointId} ${l.data}`);
|
|
26064
|
+
after = l.id;
|
|
26065
|
+
}
|
|
26066
|
+
if (!o.follow || r.session.status === "ended" || r.session.status === "failed") break;
|
|
26067
|
+
await new Promise((res) => setTimeout(res, 3e3));
|
|
26068
|
+
}
|
|
26069
|
+
});
|
|
26070
|
+
async function hasLogpointPlugin(projectDir) {
|
|
26071
|
+
for (const f of ["babel.config.js", "babel.config.cjs", "babel.config.mjs", "babel.config.json", ".babelrc", ".babelrc.js", "package.json"]) {
|
|
26072
|
+
const p = join6(projectDir, f);
|
|
26073
|
+
if (existsSync4(p) && (await readFile5(p, "utf8")).includes("react-native-healkite/babel")) return true;
|
|
26074
|
+
}
|
|
26075
|
+
return false;
|
|
26076
|
+
}
|
|
26077
|
+
program2.command("blame").description("Find the change that broke a release: symbolicate its new errors and git-blame the failing lines (run at the release's commit)").argument("<release>", "release id").option("--project <dir>", "React Native project directory", ".").option("--entry-file <file>", "JS entry file", "index.js").option("--no-hermes", "skip Hermes bytecode compilation (JSC apps)").option("--sourcemap <file>", "use this source map instead of rebuilding the release").option("--no-build", "don't rebuild for a source map (match function names only)").option("--json", "print the result as JSON").action(async (releaseId, o) => {
|
|
26078
|
+
const client = await api();
|
|
26079
|
+
const projectDir = resolve2(o.project);
|
|
26080
|
+
const report = (body) => client.request("POST", `/v1/releases/${releaseId}/culprit`, body);
|
|
26081
|
+
try {
|
|
26082
|
+
const [{ source }, { release, errors }] = await Promise.all([
|
|
26083
|
+
client.request("GET", `/v1/releases/${releaseId}/source`),
|
|
26084
|
+
client.request(
|
|
26085
|
+
"GET",
|
|
26086
|
+
`/v1/releases/${releaseId}/errors`
|
|
26087
|
+
)
|
|
26088
|
+
]);
|
|
26089
|
+
if (!source) throw new Error("this release has no git source; publish releases with the Healkite CLI from a git checkout");
|
|
26090
|
+
if (!await isGitRepo(projectDir)) throw new Error("run this inside the app's git checkout");
|
|
26091
|
+
const head = await headCommit(projectDir);
|
|
26092
|
+
if (head !== source.commit) log(`Note: HEAD is ${head.slice(0, 8)}; the release was built from ${source.commit.slice(0, 8)}. Line numbers are blamed at the release commit.`);
|
|
26093
|
+
let map2 = null;
|
|
26094
|
+
if (o.sourcemap) map2 = new SourceMap(await readFile5(o.sourcemap, "utf8"));
|
|
26095
|
+
else if (o.build && errors.some((e) => e.stack)) {
|
|
26096
|
+
log("Rebuilding the release with a source map\u2026");
|
|
26097
|
+
const built = await buildBundle({
|
|
26098
|
+
projectDir,
|
|
26099
|
+
platform: release.platform,
|
|
26100
|
+
entryFile: o.entryFile,
|
|
26101
|
+
outDir: join6(projectDir, ".healkite/blame", release.platform),
|
|
26102
|
+
hermes: o.hermes,
|
|
26103
|
+
sourcemap: true,
|
|
26104
|
+
log
|
|
26105
|
+
});
|
|
26106
|
+
const packed = await packDirectory(built);
|
|
26107
|
+
if (packed.sha256 !== release.bundleSha256) log("The rebuilt bundle differs from the released one (different dependencies or build settings); mapping may be approximate.");
|
|
26108
|
+
if (built.sourcemap) map2 = new SourceMap(await readFile5(built.sourcemap, "utf8"));
|
|
26109
|
+
}
|
|
26110
|
+
const result = await findSuspects(errors, source.changes, {
|
|
26111
|
+
map: map2,
|
|
26112
|
+
projectDir,
|
|
26113
|
+
blame: (file2, line) => blameLine(projectDir, source.commit, file2, line)
|
|
26114
|
+
});
|
|
26115
|
+
await report({ suspects: result.suspects, summary: result.summary });
|
|
26116
|
+
if (o.json) console.log(JSON.stringify(result));
|
|
26117
|
+
else {
|
|
26118
|
+
log(result.summary);
|
|
26119
|
+
for (const s of result.suspects) log(` ${Math.round(s.share * 100)}% ${s.pr ? `#${s.pr}` : s.sha.slice(0, 7)} ${s.title}`);
|
|
26120
|
+
}
|
|
26121
|
+
} catch (e) {
|
|
26122
|
+
await report({ error: e.message }).catch(() => {
|
|
26123
|
+
});
|
|
26124
|
+
throw e;
|
|
26125
|
+
}
|
|
26126
|
+
});
|
|
26127
|
+
var jobOptions = (cmd) => cmd.option("--project <dir>", "React Native project directory", ".").option("--entry-file <file>", "JS entry file", "index.js").option("--no-hermes", "skip Hermes bytecode compilation (JSC apps)").option("--sign <pem>", "sign with this private key (or HEALKITE_SIGNING_KEY)").option("--no-push", "don't push the branch (or open a pull request)");
|
|
26128
|
+
jobOptions(
|
|
26129
|
+
program2.command("revert").description("Roll back one change of a release: revert it at the release's commit, publish a guarded release, push a branch").argument("<job>", "rollback job id (rvt_\u2026), from the dashboard")
|
|
26130
|
+
).action((jobId, o) => runChangeJob(jobId, o));
|
|
26131
|
+
jobOptions(
|
|
26132
|
+
program2.command("backport").description("Apply one change to an older app version still in use: cherry-pick it onto that version's release and publish it guarded").argument("<job>", "backport job id (bpt_\u2026), from the dashboard")
|
|
26133
|
+
).action((jobId, o) => runChangeJob(jobId, o));
|
|
26134
|
+
async function runChangeJob(jobId, o) {
|
|
26135
|
+
const client = await api();
|
|
26136
|
+
const projectDir = resolve2(o.project);
|
|
26137
|
+
const spec = await client.request("GET", `/v1/reverts/${jobId}`);
|
|
26138
|
+
const update = (body) => client.request("PATCH", `/v1/reverts/${jobId}`, body);
|
|
26139
|
+
const backport = spec.job.kind === "backport";
|
|
26140
|
+
try {
|
|
26141
|
+
if (!spec.commit || !spec.change) throw new Error(backport ? "the older version's release has no git source" : "the release's git source is missing");
|
|
26142
|
+
if (!await isGitRepo(projectDir)) throw new Error("run this inside the app's git checkout");
|
|
26143
|
+
if (!await isClean(projectDir)) throw new Error("the working tree has uncommitted changes");
|
|
26144
|
+
await update({ status: "building" });
|
|
26145
|
+
const name = spec.change.pr ? `PR #${spec.change.pr}` : `commit ${spec.change.sha.slice(0, 7)}`;
|
|
26146
|
+
log(
|
|
26147
|
+
backport ? `Backporting ${name} (\u201C${spec.change.title}\u201D) to app version ${spec.release.runtimeVersion} (${spec.release.label})` : `Rolling back ${name} (\u201C${spec.change.title}\u201D) from ${spec.release.label}`
|
|
26148
|
+
);
|
|
26149
|
+
await git(projectDir, ["checkout", "--detach", spec.commit]);
|
|
26150
|
+
const hasIdentity = (await git(projectDir, ["config", "user.email"], { allowFail: true })).trim() !== "";
|
|
26151
|
+
const ident = hasIdentity ? [] : ["-c", "user.name=Healkite", "-c", "user.email=bot@healkite.com"];
|
|
26152
|
+
const pick2 = backport ? ["cherry-pick", "-x"] : ["revert", "--no-edit"];
|
|
26153
|
+
try {
|
|
26154
|
+
await git(projectDir, [...ident, ...pick2, ...spec.change.merge ? ["-m", "1"] : [], spec.change.sha]);
|
|
26155
|
+
} catch {
|
|
26156
|
+
const conflicted = (await git(projectDir, ["diff", "--name-only", "--diff-filter=U"], { allowFail: true })).split("\n").filter(Boolean);
|
|
26157
|
+
await git(projectDir, [backport ? "cherry-pick" : "revert", "--abort"], { allowFail: true });
|
|
26158
|
+
throw new Error(
|
|
26159
|
+
backport ? `${name} doesn't apply cleanly to app version ${spec.release.runtimeVersion}: that code has changed since (${conflicted.slice(0, 5).join(", ") || "conflict"}). Fix that version by hand.` : `${name} can't be reverted cleanly: later changes in ${spec.release.label} touch the same lines (${conflicted.slice(0, 5).join(", ") || "conflict"}). Roll back the whole release instead.`
|
|
26160
|
+
);
|
|
26161
|
+
}
|
|
26162
|
+
const rel = await releaseAction({
|
|
26163
|
+
platform: spec.release.platform,
|
|
26164
|
+
channel: spec.release.channelKey,
|
|
26165
|
+
runtimeVersion: spec.release.runtimeVersion,
|
|
26166
|
+
project: o.project,
|
|
26167
|
+
entryFile: o.entryFile,
|
|
26168
|
+
hermes: o.hermes,
|
|
26169
|
+
sign: o.sign,
|
|
26170
|
+
patchFrom: "3",
|
|
26171
|
+
guarded: true,
|
|
26172
|
+
// Same guard (steps and business metrics) as the release the change came from.
|
|
26173
|
+
guardConfig: spec.guard ?? void 0,
|
|
26174
|
+
description: (backport ? `${spec.release.label} + ${name} from ${spec.from?.label ?? "a newer release"}: ${spec.change.title}` : `${spec.release.label} without ${name}: ${spec.change.title}`).slice(0, 2e3)
|
|
26175
|
+
});
|
|
26176
|
+
if (!rel) throw new Error("nothing was published");
|
|
26177
|
+
let branch;
|
|
26178
|
+
let pullRequestUrl;
|
|
26179
|
+
if (o.push) {
|
|
26180
|
+
const what = spec.change.pr ? `pr-${spec.change.pr}` : spec.change.sha.slice(0, 7);
|
|
26181
|
+
branch = backport ? `healkite/backport-${what}-to-${spec.release.runtimeVersion}-${jobId.slice(-6)}` : `healkite/revert-${what}-${jobId.slice(-6)}`;
|
|
26182
|
+
if (await gitOk(projectDir, ["push", "origin", `HEAD:refs/heads/${branch}`])) {
|
|
26183
|
+
log(`Pushed ${branch}`);
|
|
26184
|
+
if (!backport) {
|
|
26185
|
+
pullRequestUrl = await openPullRequest(projectDir, branch, `Revert ${name}: ${spec.change.title}`, `Healkite rolled back ${name} from ${spec.release.label} and shipped the rest as ${rel.label} (guarded).
|
|
26186
|
+
|
|
26187
|
+
Merge this so the next release doesn't bring it back.`) ?? void 0;
|
|
26188
|
+
if (pullRequestUrl) log(`Pull request: ${pullRequestUrl}`);
|
|
26189
|
+
}
|
|
26190
|
+
}
|
|
26191
|
+
}
|
|
26192
|
+
await update({ status: "published", newReleaseId: rel.id, branch, pullRequestUrl });
|
|
26193
|
+
log(backport ? `Published ${rel.label} to app version ${spec.release.runtimeVersion}, guarded.` : `Published ${rel.label}: ${spec.release.label} without ${name}, as a guarded release.`);
|
|
26194
|
+
} catch (e) {
|
|
26195
|
+
await update({ status: "failed", error: e.message.slice(0, 450) }).catch(() => {
|
|
26196
|
+
});
|
|
26197
|
+
throw e;
|
|
26198
|
+
}
|
|
26199
|
+
}
|
|
26200
|
+
program2.command("provenance").description("Show and verify where a release was built (repository, commit, CI run, PR approvals)").argument("<release>", "release id").option("--json", "print the signed statement and signature").action(async (releaseId, o) => {
|
|
26201
|
+
const client = await api();
|
|
26202
|
+
const { provenance: p } = await client.request(
|
|
26203
|
+
"GET",
|
|
26204
|
+
`/v1/releases/${releaseId}/provenance`
|
|
26205
|
+
);
|
|
26206
|
+
if (!p) throw new Error("this release has no build provenance (it wasn't published from GitHub Actions with id-token: write)");
|
|
26207
|
+
const { manifestPublicKey } = await client.request("GET", "/v1/config");
|
|
26208
|
+
const ok = !!(p.signature && manifestPublicKey && await verifyManifestSignature(manifestPublicKey, p.raw, p.signature));
|
|
26209
|
+
if (o.json) return console.log(JSON.stringify({ statement: JSON.parse(p.raw), signature: p.signature, publicKey: manifestPublicKey, verified: ok }, null, 2));
|
|
26210
|
+
const s = JSON.parse(p.raw);
|
|
26211
|
+
log(`${ok ? "\u2714 Signature valid" : "\u2718 Signature NOT valid"} (server key ${manifestPublicKey?.slice(-12) ?? "missing"})`);
|
|
26212
|
+
log(`${s.release.label} \xB7 bundle ${s.bundle.sha256.slice(0, 12)}\u2026`);
|
|
26213
|
+
log(`Built from ${s.source.repo}@${s.source.commit.slice(0, 8)} (${s.source.ref}) by ${s.build.workflow}, run ${s.build.runUrl}`);
|
|
26214
|
+
log(s.review ? `PR #${s.review.pr}, approved by ${s.review.approvedBy.join(", ") || "nobody"}${s.review.mergedBy ? `, merged by ${s.review.mergedBy}` : ""}` : "No pull request review recorded");
|
|
26215
|
+
if (!ok) process.exitCode = 1;
|
|
26216
|
+
});
|
|
26217
|
+
async function openPullRequest(cwd, branch, title, body) {
|
|
26218
|
+
const { execFile: execFile2 } = await import("node:child_process");
|
|
26219
|
+
return new Promise((res) => {
|
|
26220
|
+
execFile2("gh", ["pr", "create", "--head", branch, "--title", title, "--body", body], { cwd }, (err, stdout) => {
|
|
26221
|
+
const url2 = stdout?.trim().split("\n").pop() ?? "";
|
|
26222
|
+
res(!err && /^https:\/\/github\.com\//.test(url2) ? url2 : null);
|
|
26223
|
+
});
|
|
26224
|
+
});
|
|
26225
|
+
}
|
|
25047
26226
|
program2.parseAsync().catch((err) => {
|
|
25048
26227
|
console.error(`\x1B[31mhealkite\x1B[0m ${err instanceof Error ? err.message : String(err)}`);
|
|
25049
26228
|
process.exit(1);
|
|
@@ -25056,20 +26235,27 @@ async function releaseAction(o) {
|
|
|
25056
26235
|
const maxSize = o.maxSize ? parseSize(o.maxSize) : void 0;
|
|
25057
26236
|
const maxGrowthPct = o.maxGrowth !== void 0 ? parsePercent(o.maxGrowth) : void 0;
|
|
25058
26237
|
const signingKey = await loadSigningKey(o.sign);
|
|
26238
|
+
const profileEnv = !o.buildEnv && o.startupProfile !== false && await hasLogpointPlugin(projectDir) ? {
|
|
26239
|
+
HEALKITE_STARTUP_PROFILE: "1",
|
|
26240
|
+
HEALKITE_PROJECT_ROOT: projectDir,
|
|
26241
|
+
...existsSync4(join6(projectDir, o.entryFile ?? "index.js")) ? { HEALKITE_ENTRY: join6(projectDir, o.entryFile ?? "index.js") } : {}
|
|
26242
|
+
} : {};
|
|
26243
|
+
if (profileEnv.HEALKITE_STARTUP_PROFILE) log("Start-up profiling on (devices report start time and the slowest modules)");
|
|
25059
26244
|
const built = await buildBundle({
|
|
25060
26245
|
projectDir,
|
|
25061
26246
|
platform: o.platform,
|
|
25062
26247
|
entryFile: o.entryFile,
|
|
25063
|
-
outDir:
|
|
26248
|
+
outDir: join6(projectDir, ".healkite/build", o.platform),
|
|
25064
26249
|
hermes: o.hermes,
|
|
25065
|
-
log
|
|
26250
|
+
log,
|
|
26251
|
+
env: o.buildEnv ?? (Object.keys(profileEnv).length ? profileEnv : void 0)
|
|
25066
26252
|
});
|
|
25067
26253
|
const packed = await packDirectory(built);
|
|
25068
26254
|
log(`Packed ${packed.index.files.length} files \u2192 ${(packed.hkb.byteLength / 1024).toFixed(1)} KB (sha256 ${packed.sha256.slice(0, 12)}\u2026)`);
|
|
25069
26255
|
const signature = signingKey ? signBundle(signingKey, packed.sha256) : void 0;
|
|
25070
26256
|
if (signature) log("Signed bundle (ECDSA P-256)");
|
|
25071
26257
|
const patchFrom = Math.max(0, Number(o.patchFrom) || 0);
|
|
25072
|
-
const guard = guardOptions(o);
|
|
26258
|
+
const guard = o.guardConfig ?? guardOptions(o);
|
|
25073
26259
|
if (guard && o.out) throw new Error("--guarded needs the API (it is driven by the server)");
|
|
25074
26260
|
if (guard && o.rollout !== void 0) throw new Error("use either --rollout or --guarded");
|
|
25075
26261
|
if (o.out) {
|
|
@@ -25146,16 +26332,45 @@ async function releaseAction(o) {
|
|
|
25146
26332
|
});
|
|
25147
26333
|
for (const p of patchList) await client.uploadBlob(p.hkp, p.sha256, "patch");
|
|
25148
26334
|
}
|
|
26335
|
+
let source = null;
|
|
26336
|
+
if (!o.skipSource) {
|
|
26337
|
+
try {
|
|
26338
|
+
const prev = latest ? (await client.request("GET", `/v1/releases/${latest.id}/source`).catch(() => ({ source: null }))).source : null;
|
|
26339
|
+
source = await releaseSource(projectDir, prev?.commit ?? null, log);
|
|
26340
|
+
if (source) log(`Source: ${source.commit.slice(0, 8)}${source.changes.length ? `, ${source.changes.length} change${source.changes.length === 1 ? "" : "s"} since ${latest?.label}` : ""}`);
|
|
26341
|
+
} catch (e) {
|
|
26342
|
+
log(`Couldn't read git history (${e.message}); publishing without it.`);
|
|
26343
|
+
}
|
|
26344
|
+
}
|
|
26345
|
+
let review = null;
|
|
26346
|
+
if (!o.skipSource && source?.baseCommit && !o.noStoreCheck && o.storeCheck !== false) {
|
|
26347
|
+
try {
|
|
26348
|
+
review = await otaCheck(projectDir, source.baseCommit);
|
|
26349
|
+
log(`Store check: ${review.summary}`);
|
|
26350
|
+
for (const f of review.findings.filter((x) => x.severity !== "info")) log(` ${f.severity.toUpperCase()}: ${f.title}`);
|
|
26351
|
+
if (review.verdict === "blocked" && !o.force) {
|
|
26352
|
+
throw new Error("This update can't safely ship over the air (see above). Ship a store build, or pass --force if you're sure.");
|
|
26353
|
+
}
|
|
26354
|
+
} catch (e) {
|
|
26355
|
+
if (e.message.startsWith("This update can't")) throw e;
|
|
26356
|
+
log(`Store check skipped (${e.message})`);
|
|
26357
|
+
}
|
|
26358
|
+
}
|
|
26359
|
+
const githubOidcToken = await githubOidc();
|
|
26360
|
+
if (githubOidcToken) log("Build provenance: GitHub Actions identity attached");
|
|
25149
26361
|
const release = await client.request("POST", "/v1/releases", {
|
|
26362
|
+
provenance: githubOidcToken ? { githubOidcToken } : void 0,
|
|
26363
|
+
review: review ? { verdict: review.verdict, summary: review.summary, findings: review.findings } : void 0,
|
|
26364
|
+
source: source ?? void 0,
|
|
25150
26365
|
channelKey: o.channel,
|
|
25151
26366
|
platform: o.platform,
|
|
25152
26367
|
runtimeVersion: o.runtimeVersion,
|
|
25153
26368
|
sha256: packed.sha256,
|
|
25154
26369
|
size: packed.hkb.byteLength,
|
|
25155
26370
|
description: o.description,
|
|
25156
|
-
mandatory: o.mandatory || o.hotfix,
|
|
26371
|
+
mandatory: o.mandatory || o.hotfix || o.live,
|
|
25157
26372
|
rolloutPct: o.rollout,
|
|
25158
|
-
push: o.hotfix || o.push || void 0,
|
|
26373
|
+
push: o.hotfix || o.live || o.push || void 0,
|
|
25159
26374
|
signature,
|
|
25160
26375
|
patches: patchList.map(({ fromSha256, sha256, size, signature: patchSig }) => ({ fromSha256, sha256, size, signature: patchSig })),
|
|
25161
26376
|
guard,
|
|
@@ -25175,3 +26390,15 @@ async function releaseAction(o) {
|
|
|
25175
26390
|
if (guard) log(`Guarded: it will advance on its own when healthy and roll back on crashes. Watch with \`healkite guard ${release.id}\``);
|
|
25176
26391
|
return { id: release.id, label: release.label };
|
|
25177
26392
|
}
|
|
26393
|
+
async function githubOidc() {
|
|
26394
|
+
const url2 = process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
|
|
26395
|
+
const token = process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
|
|
26396
|
+
if (!url2 || !token) return null;
|
|
26397
|
+
try {
|
|
26398
|
+
const res = await fetch(`${url2}${url2.includes("?") ? "&" : "?"}audience=${PROVENANCE_AUDIENCE}`, { headers: { authorization: `Bearer ${token}` } });
|
|
26399
|
+
if (!res.ok) return null;
|
|
26400
|
+
return (await res.json()).value ?? null;
|
|
26401
|
+
} catch {
|
|
26402
|
+
return null;
|
|
26403
|
+
}
|
|
26404
|
+
}
|