ShadowHunter222 commited on
Commit
1440402
·
verified ·
1 Parent(s): 35e2ca2

Upload 3 files

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -2
  2. app.py +18 -14
Dockerfile CHANGED
@@ -9,8 +9,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
9
  wget unzip git python3 python3-pip curl ca-certificates \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Node 20
13
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
14
  apt-get install -y nodejs && node -v && npm -v
15
 
16
  # Extra JDKs for era coverage (11 = legacy AGP7, 21 = modern Cap7+/AGP9-era).
 
9
  wget unzip git python3 python3-pip curl ca-certificates \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Node 22 (Cap8 CLI requires Node 22+; npm 10 ships with it)
13
+ RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
14
  apt-get install -y nodejs && node -v && npm -v
15
 
16
  # Extra JDKs for era coverage (11 = legacy AGP7, 21 = modern Cap7+/AGP9-era).
app.py CHANGED
@@ -655,9 +655,9 @@ def _sanitize_app_config(cfg: dict | None) -> dict:
655
  version_name = str(cfg.get("versionName", "1.0")).strip() or "1.0"
656
  version_name = version_name[:20].replace('"', '').replace("'", "")
657
  version_code = _int(cfg.get("versionCode", 1), 1, 1, 2100000000)
658
- # minSdk floor 22 = Capacitor merger requirement (android library declares 22;
659
  # anything lower fails manifest merge now that we write it for real — see 3f).
660
- min_sdk = _int(cfg.get("minSdk", 22), 22, 22, 36)
661
  target_sdk = _int(cfg.get("targetSdk", 36), 36, 16, 36)
662
  compile_sdk = _int(cfg.get("compileSdk", 36), 36, 16, 36)
663
  # ensure compile >= target >= min
@@ -876,18 +876,18 @@ def _patch_pure_web_android(android_dir: Path, cfg: dict, log_fn):
876
  # (app/build.gradle only references rootProject.ext.* with no bare digits,
877
  # so patching it alone silently no-ops — UI SDK choices never landed).
878
  # Generated wrapper only — user-owned projects never reach this function.
879
- # minSdk floor 22 = Capacitor merger requirement (lower cannot build).
880
  try:
881
  vf = android_dir / "variables.gradle"
882
  if vf.exists():
883
  vtxt = vf.read_text(encoding="utf-8", errors="ignore")
884
  vorig = vtxt
885
- vtxt = re.sub(r"minSdkVersion\s*=?\s*\d+", f"minSdkVersion = {max(22, cfg['minSdk'])}", vtxt)
886
  vtxt = re.sub(r"targetSdkVersion\s*=?\s*\d+", f"targetSdkVersion = {cfg['targetSdk']}", vtxt)
887
  vtxt = re.sub(r"compileSdkVersion\s*=?\s*\d+", f"compileSdkVersion = {cfg['compileSdk']}", vtxt)
888
  if vtxt != vorig:
889
  vf.write_text(vtxt, encoding="utf-8")
890
- log_fn(f"Patched variables.gradle -> minSdk {max(22, cfg['minSdk'])} targetSdk {cfg['targetSdk']} compileSdk {cfg['compileSdk']}")
891
  except Exception as e:
892
  log_fn(f"variables.gradle patch warning: {e}")
893
  # 4. AndroidManifest package fallback (older templates) - ensure package attr matches
@@ -1170,11 +1170,11 @@ async def run_build(job_id: str, build_id: str, task: str, signing: dict, app_co
1170
  "version": "1.0.0",
1171
  "private": True,
1172
  "dependencies": {
1173
- "@capacitor/core": "^6.2.0",
1174
- "@capacitor/android": "^6.2.0"
1175
  },
1176
  "devDependencies": {
1177
- "@capacitor/cli": "^6.2.0"
1178
  }
1179
  }
1180
  pkg.write_text(json.dumps(pkg_data, indent=2))
@@ -1188,11 +1188,11 @@ async def run_build(job_id: str, build_id: str, task: str, signing: dict, app_co
1188
  else:
1189
  log("npm install done")
1190
  await asyncio.sleep(0) # yield to WS loop
1191
- # Device kit (batched, Cap6 scaffold): folder picking + device save.
1192
  # Safe: work copy only, --no-save, single npm call, log-and-continue.
1193
  try:
1194
  from capacitor_plugins import ensure_device_kit, cli_bin_ok
1195
- await ensure_device_kit(build_dir, 6, log, _run_cmd)
1196
  if not cli_bin_ok(build_dir):
1197
  log("WARNING: Capacitor CLI binary missing after install — cap init may fail, check npm log above")
1198
  except Exception as e:
@@ -1316,12 +1316,16 @@ async def run_build(job_id: str, build_id: str, task: str, signing: dict, app_co
1316
  await asyncio.sleep(0)
1317
  # --- ensure Capacitor platform deps (work copy only, version-pinned to core major) ---
1318
  try:
1319
- pin = cap_major if cap_major else 6
1320
  need = []
1321
  if not (work_base / "node_modules" / "@capacitor" / "cli").exists():
1322
  need.append(f"@capacitor/cli@{pin}")
1323
  if not (work_base / "node_modules" / "@capacitor" / "android").exists():
1324
  need.append(f"@capacitor/android@{pin}")
 
 
 
 
1325
  if need:
1326
  log(f"Installing missing Capacitor packages: {' '.join(need)}")
1327
  # Saved (not --no-save) into the WORK-COPY package.json on purpose:
@@ -1402,11 +1406,11 @@ async def run_build(job_id: str, build_id: str, task: str, signing: dict, app_co
1402
  # Work copy only, --no-save, log-and-continue; re-verifies CLI after.
1403
  try:
1404
  from capacitor_plugins import ensure_device_kit as _edk
1405
- await _edk(work_base, cap_major if cap_major else 6, log, _run_cmd)
1406
  if not cli_bin_ok(work_base):
1407
  log("WARNING: CLI binary missing after device kit — reinstalling platform packages")
1408
- _pin = cap_major if cap_major else 6
1409
- await _run_cmd(["npm", "install", "--no-audit", "--no-fund", "--silent", f"@capacitor/cli@{_pin}", f"@capacitor/android@{_pin}"], cwd=work_base, timeout=300)
1410
  except Exception as e:
1411
  log(f"Device kit note: {e}")
1412
  try:
 
655
  version_name = str(cfg.get("versionName", "1.0")).strip() or "1.0"
656
  version_name = version_name[:20].replace('"', '').replace("'", "")
657
  version_code = _int(cfg.get("versionCode", 1), 1, 1, 2100000000)
658
+ # minSdk floor 24 = Cap8 merger requirement (android library declares 24;
659
  # anything lower fails manifest merge now that we write it for real — see 3f).
660
+ min_sdk = _int(cfg.get("minSdk", 24), 24, 24, 36)
661
  target_sdk = _int(cfg.get("targetSdk", 36), 36, 16, 36)
662
  compile_sdk = _int(cfg.get("compileSdk", 36), 36, 16, 36)
663
  # ensure compile >= target >= min
 
876
  # (app/build.gradle only references rootProject.ext.* with no bare digits,
877
  # so patching it alone silently no-ops — UI SDK choices never landed).
878
  # Generated wrapper only — user-owned projects never reach this function.
879
+ # minSdk floor 24 = Cap8 merger requirement (lower cannot build).
880
  try:
881
  vf = android_dir / "variables.gradle"
882
  if vf.exists():
883
  vtxt = vf.read_text(encoding="utf-8", errors="ignore")
884
  vorig = vtxt
885
+ vtxt = re.sub(r"minSdkVersion\s*=?\s*\d+", f"minSdkVersion = {max(24, cfg['minSdk'])}", vtxt)
886
  vtxt = re.sub(r"targetSdkVersion\s*=?\s*\d+", f"targetSdkVersion = {cfg['targetSdk']}", vtxt)
887
  vtxt = re.sub(r"compileSdkVersion\s*=?\s*\d+", f"compileSdkVersion = {cfg['compileSdk']}", vtxt)
888
  if vtxt != vorig:
889
  vf.write_text(vtxt, encoding="utf-8")
890
+ log_fn(f"Patched variables.gradle -> minSdk {max(24, cfg['minSdk'])} targetSdk {cfg['targetSdk']} compileSdk {cfg['compileSdk']}")
891
  except Exception as e:
892
  log_fn(f"variables.gradle patch warning: {e}")
893
  # 4. AndroidManifest package fallback (older templates) - ensure package attr matches
 
1170
  "version": "1.0.0",
1171
  "private": True,
1172
  "dependencies": {
1173
+ "@capacitor/core": "^8.0.0",
1174
+ "@capacitor/android": "^8.0.0"
1175
  },
1176
  "devDependencies": {
1177
+ "@capacitor/cli": "^8.0.0"
1178
  }
1179
  }
1180
  pkg.write_text(json.dumps(pkg_data, indent=2))
 
1188
  else:
1189
  log("npm install done")
1190
  await asyncio.sleep(0) # yield to WS loop
1191
+ # Device kit (batched, Cap8 scaffold): folder picking + device save.
1192
  # Safe: work copy only, --no-save, single npm call, log-and-continue.
1193
  try:
1194
  from capacitor_plugins import ensure_device_kit, cli_bin_ok
1195
+ await ensure_device_kit(build_dir, 8, log, _run_cmd)
1196
  if not cli_bin_ok(build_dir):
1197
  log("WARNING: Capacitor CLI binary missing after install — cap init may fail, check npm log above")
1198
  except Exception as e:
 
1316
  await asyncio.sleep(0)
1317
  # --- ensure Capacitor platform deps (work copy only, version-pinned to core major) ---
1318
  try:
1319
+ pin = cap_major if cap_major else 8
1320
  need = []
1321
  if not (work_base / "node_modules" / "@capacitor" / "cli").exists():
1322
  need.append(f"@capacitor/cli@{pin}")
1323
  if not (work_base / "node_modules" / "@capacitor" / "android").exists():
1324
  need.append(f"@capacitor/android@{pin}")
1325
+ # core alongside cli/android so plugin peers resolve and bundler
1326
+ # imports work; saved into the work copy (prune-safe, see note below).
1327
+ if not (work_base / "node_modules" / "@capacitor" / "core").exists():
1328
+ need.append(f"@capacitor/core@{pin}")
1329
  if need:
1330
  log(f"Installing missing Capacitor packages: {' '.join(need)}")
1331
  # Saved (not --no-save) into the WORK-COPY package.json on purpose:
 
1406
  # Work copy only, --no-save, log-and-continue; re-verifies CLI after.
1407
  try:
1408
  from capacitor_plugins import ensure_device_kit as _edk
1409
+ await _edk(work_base, cap_major if cap_major else 8, log, _run_cmd)
1410
  if not cli_bin_ok(work_base):
1411
  log("WARNING: CLI binary missing after device kit — reinstalling platform packages")
1412
+ _pin = cap_major if cap_major else 8
1413
+ await _run_cmd(["npm", "install", "--no-audit", "--no-fund", "--silent", f"@capacitor/cli@{_pin}", f"@capacitor/android@{_pin}", f"@capacitor/core@{_pin}"], cwd=work_base, timeout=300)
1414
  except Exception as e:
1415
  log(f"Device kit note: {e}")
1416
  try: