Skip to content

Commit 170774b

Browse files
author
埃博拉酱
committed
Stabilize debug terminal packaging and install diagnostics
Keep Android resource post-processing compatible with the current Cordova Android output while preserving the existing Android 14 build path. Remove the allow-any-origin flag from the bundled terminal startup script for the current runtime validation build. Add detailed bundled AXS copy failure logging so LAN debug output shows the exact asset-copy error instead of a generic fallback message.
1 parent 5084651 commit 170774b

File tree

4 files changed

+69
-13
lines changed

4 files changed

+69
-13
lines changed

hooks/post-process.js

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,61 @@ if (
2121
if (fs.existsSync(androidGradleFilePath)) fs.unlinkSync(androidGradleFilePath);
2222
fs.copyFileSync(gradleFilePath, androidGradleFilePath);
2323

24-
deleteDirRecursively(resPath, [
25-
path.join('values', 'strings.xml'),
26-
path.join('values', 'colors.xml'),
27-
path.join('values', 'styles.xml'),
28-
'anim',
29-
'xml',
30-
]);
31-
copyDirRecursively(localResPath, resPath);
24+
const preservedRes = collectPreservedAndroidRes(resPath);
25+
deleteDirRecursively(resPath, preservedRes);
26+
27+
const localResSkip = collectLocalResourceSkipList(resPath);
28+
29+
copyDirRecursively(localResPath, resPath, localResSkip);
3230
enableLegacyJni();
3331
enableStaticContext();
3432
patchTargetSdkVersion();
3533

3634

35+
function collectPreservedAndroidRes(androidResPath) {
36+
const preserved = [
37+
path.join('values', 'styles.xml'),
38+
'anim',
39+
'xml',
40+
];
41+
42+
const optionalEntries = [
43+
path.join('values', 'strings.xml'),
44+
path.join('values', 'colors.xml'),
45+
path.join('values', 'themes.xml'),
46+
path.join('values', 'cdv_strings.xml'),
47+
path.join('values', 'cdv_colors.xml'),
48+
path.join('values', 'cdv_themes.xml'),
49+
'values-night',
50+
'values-night-v34',
51+
'values-v34',
52+
];
53+
54+
for (const entry of optionalEntries) {
55+
if (fs.existsSync(path.join(androidResPath, entry))) {
56+
preserved.push(entry);
57+
}
58+
}
59+
60+
return preserved;
61+
}
62+
63+
function collectLocalResourceSkipList(androidResPath) {
64+
const skip = [];
65+
66+
// Cordova Android 15+ provides splash/theme defaults in cdv_* resources.
67+
// Keep using local colors/themes on older layouts where those files do not exist.
68+
if (fs.existsSync(path.join(androidResPath, 'values', 'cdv_colors.xml'))) {
69+
skip.push(path.join('values', 'colors.xml'));
70+
}
71+
if (fs.existsSync(path.join(androidResPath, 'values', 'cdv_themes.xml'))) {
72+
skip.push(path.join('values', 'themes.xml'));
73+
}
74+
75+
return skip;
76+
}
77+
78+
3779
function getTmpDir() {
3880
const tmpdirEnv = process.env.TMPDIR;
3981

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/terminal/scripts/init-alpine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ chmod +x "$PREFIX/alpine/initrc"
278278
# to happen inside axs itself, where the HTTP request is handled. Until axs gains
279279
# per-origin CORS or an equivalent auth gate, keep this stopgap so terminal
280280
# startup and localhost readiness probes remain functional.
281-
"$PREFIX/axs" --allow-any-origin -c "bash --rcfile /initrc -i"
281+
"$PREFIX/axs" -c "bash --rcfile /initrc -i"
282282

283283
else
284284
exec "$@"

src/plugins/terminal/www/Terminal.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
const Executor = require("./Executor");
22

3+
function formatAxsAssetError(error) {
4+
if (!error) return "unknown error";
5+
if (typeof error === "string") return error;
6+
if (error instanceof Error) {
7+
return error.stack || error.message || String(error);
8+
}
9+
try {
10+
return JSON.stringify(error);
11+
} catch (_) {
12+
return String(error);
13+
}
14+
}
15+
316
const Terminal = {
417
/**
518
* In debug builds, overwrite the axs binary from bundled assets to ensure
@@ -16,6 +29,7 @@ const Terminal = {
1629
});
1730
return true;
1831
} catch (e) {
32+
console.warn("Failed to refresh bundled AXS from assets:", formatAxsAssetError(e));
1933
return false;
2034
}
2135
},
@@ -258,7 +272,7 @@ const Terminal = {
258272
copiedFromAsset = true;
259273
logger("✅ Bundled AXS copied from assets");
260274
} catch (assetError) {
261-
logger("⚠️ Asset copy failed, will download instead");
275+
logger(`⚠️ Asset copy failed, will download instead: ${formatAxsAssetError(assetError)}`);
262276
}
263277
}
264278

0 commit comments

Comments
 (0)