@supersdk/supercli 0.2.1-staging.21 → 0.3.0-staging.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/cli.js +4 -2
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/add.js +519 -0
  4. package/dist/commands/add.js.map +1 -0
  5. package/dist/commands/init.js +234 -0
  6. package/dist/commands/init.js.map +1 -0
  7. package/dist/commands/publishSite.js +354 -71
  8. package/dist/commands/publishSite.js.map +1 -1
  9. package/dist/config/appConfig.js +160 -45
  10. package/dist/config/appConfig.js.map +1 -1
  11. package/dist/publish/siteConfig.js +278 -63
  12. package/dist/publish/siteConfig.js.map +1 -1
  13. package/dist/template/README.md +144 -85
  14. package/dist/template/android/app/build.gradle.kts +0 -3
  15. package/dist/template/android/app/src/main/java/com/supersdk/simple/EnvironmentStore.java +41 -0
  16. package/dist/template/android/app/src/main/java/com/supersdk/simple/MainActivity.java +57 -4
  17. package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +3 -1
  18. package/dist/template/android/gradle/supersdk-config-reader.gradle +5 -3
  19. package/dist/template/android/supersdk-default.config.json +4 -3
  20. package/dist/template/ios/Sources/App/EnvironmentStore.swift +35 -0
  21. package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +2 -1
  22. package/dist/template/ios/Sources/App/SimpleSDKProbe.swift +15 -0
  23. package/dist/template/ios/Sources/App/SimpleViewController.swift +52 -8
  24. package/dist/template/ios/Tests/SimpleAppTests/SimpleSDKInitializationTests.swift +12 -1
  25. package/dist/template/scripts/android_snapshot_canary.py +17 -8
  26. package/dist/template/scripts/build_android.sh +36 -9
  27. package/dist/template/scripts/build_ios.sh +63 -24
  28. package/dist/template/scripts/build_site.sh +43 -0
  29. package/dist/template/scripts/lib/workspace.sh +43 -0
  30. package/dist/template/scripts/serve_web.py +26 -9
  31. package/dist/template/scripts/super_build_orchestrator.py +49 -28
  32. package/dist/template/scripts/supersdk_template.py +759 -240
  33. package/dist/template/scripts/web_package.py +44 -20
  34. package/dist/template/super_build.sh +40 -12
  35. package/dist/template/supersdk.json +25 -13
  36. package/dist/template/template_manifest.json +25 -0
  37. package/dist/template/web/src/css/style.css +28 -0
  38. package/dist/template/web/src/index.html +8 -0
  39. package/dist/template/web/src/js/app.js +92 -19
  40. package/dist/workspace/config.js +440 -0
  41. package/dist/workspace/config.js.map +1 -0
  42. package/dist/workspace/identity.js +106 -0
  43. package/dist/workspace/identity.js.map +1 -0
  44. package/dist/workspace/interactive.js +96 -0
  45. package/dist/workspace/interactive.js.map +1 -0
  46. package/dist/workspace/template.js +357 -0
  47. package/dist/workspace/template.js.map +1 -0
  48. package/package.json +1 -1
  49. package/dist/commands/createApp.js +0 -448
  50. package/dist/commands/createApp.js.map +0 -1
  51. package/dist/createApp/copyTemplate.js +0 -561
  52. package/dist/createApp/copyTemplate.js.map +0 -1
  53. package/dist/template/scripts/build_web.sh +0 -12
@@ -10,9 +10,17 @@ import threading
10
10
  from dataclasses import dataclass
11
11
  from pathlib import Path
12
12
 
13
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
14
+ import supersdk_template
13
15
 
14
- PLATFORMS = ("android", "ios", "web")
16
+
17
+ PROJECT_TYPES = supersdk_template.PROJECT_TYPES
18
+ # 🔴 站点没有 skip 模式:它是 success 或 failed。这条常量必须跟着类型改名走 ——
19
+ # 留着旧的 "web" 会让每个 site 构建都被 SKIP 扫描,任何以 SKIP_ 开头的日志行都会
20
+ # 把它判成 skipped,而退出码仍然是 0(静默的状态漂移,比直接失败危险得多)。
21
+ NO_SKIP_MODE_TYPES = ("site",)
15
22
  SUMMARY_PREFIX = "SUPERSDK_BUILD_SUMMARY_JSON="
23
+ SUMMARY_SCHEMA_VERSION = 2
16
24
  DEFAULT_TIMEOUT_SECONDS = 1800.0
17
25
  REASON_LIMIT = 500
18
26
  TRUNCATION_MARKER = "...(truncated)"
@@ -64,14 +72,18 @@ class BoundedLineBuffer:
64
72
  return [*self.head_lines, f"...({hidden_count} lines omitted)...\n", *self.tail_lines]
65
73
 
66
74
 
67
- def selected_platforms(platform):
68
- return list(PLATFORMS) if platform == "all" else [platform]
75
+ def selected_projects(config, platform, project):
76
+ """把「构建哪些项目」这件事交还给引擎,编排器不自己解析 supersdk.json。"""
77
+ normalized = supersdk_template.load_and_validate(config, platform, project)
78
+ supersdk_template.require_selection(normalized, platform, project)
79
+ return [{"type": item["type"], "dir": item["dir"]} for item in normalized["projects"]]
69
80
 
70
81
 
71
- def helper_command(root, platform, config):
72
- script = Path(root) / "scripts" / f"build_{platform}.sh"
73
- command = [str(script), "--build"]
74
- if platform == "android":
82
+ def helper_command(root, project, config):
83
+ script = Path(root) / "scripts" / f"build_{project['type']}.sh"
84
+ command = [str(script), "--build", "--project", project["dir"]]
85
+ # 只有 android 需要根配置:它的 snapshot canary 在 managed config 缺席时会回退去读根配置。
86
+ if project["type"] == "android":
75
87
  command.extend(["--config", str(config)])
76
88
  return command
77
89
 
@@ -266,29 +278,32 @@ def cap_reason(reason):
266
278
  return reason[: REASON_LIMIT - len(TRUNCATION_MARKER)] + TRUNCATION_MARKER
267
279
 
268
280
 
269
- def classify_result(platform, command, exit_code, output, launch_or_timeout_reason=None):
281
+ def classify_result(project, command, exit_code, output, launch_or_timeout_reason=None):
270
282
  command_payload = [str(item) for item in command]
271
283
  if launch_or_timeout_reason is not None:
272
- return platform_result(platform, "failed", exit_code, cap_reason(launch_or_timeout_reason), command_payload)
284
+ return platform_result(project, "failed", exit_code, cap_reason(launch_or_timeout_reason), command_payload)
273
285
 
274
286
  if exit_code != 0:
275
287
  excerpt = output_excerpt(output)
276
288
  reason = f"exit_code={exit_code}"
277
289
  if excerpt:
278
290
  reason = f"{reason}; {excerpt}"
279
- return platform_result(platform, "failed", exit_code, cap_reason(reason), command_payload)
291
+ return platform_result(project, "failed", exit_code, cap_reason(reason), command_payload)
280
292
 
281
- if platform != "web":
293
+ if project["type"] not in NO_SKIP_MODE_TYPES:
282
294
  marker = first_skip_line(output)
283
295
  if marker is not None:
284
- return platform_result(platform, "skipped", exit_code, cap_reason(marker), command_payload)
296
+ return platform_result(project, "skipped", exit_code, cap_reason(marker), command_payload)
285
297
 
286
- return platform_result(platform, "success", exit_code, "", command_payload)
298
+ return platform_result(project, "success", exit_code, "", command_payload)
287
299
 
288
300
 
289
- def platform_result(platform, status, exit_code, reason, command):
301
+ def platform_result(project, status, exit_code, reason, command):
290
302
  return {
291
- "platform": platform,
303
+ "platform": project["type"],
304
+ # 一个工作空间可以有多个同类型项目(比如两个 site)。没有 dir,两条摘要记录
305
+ # 长得一模一样,谁失败了根本读不出来。
306
+ "dir": project["dir"],
292
307
  "status": status,
293
308
  "exit_code": int(exit_code),
294
309
  "reason": reason,
@@ -306,7 +321,7 @@ def aggregate_summary(results):
306
321
  overall_status = "success"
307
322
  exit_code = 1 if overall_status == "failed" else 0
308
323
  return {
309
- "schema_version": 1,
324
+ "schema_version": SUMMARY_SCHEMA_VERSION,
310
325
  "overall_status": overall_status,
311
326
  "overall_exit_code": exit_code,
312
327
  "platforms": results,
@@ -324,15 +339,14 @@ def command_payload(command):
324
339
  return [str(part) for part in command] if command else ["<command-unavailable>"]
325
340
 
326
341
 
327
- def run_all(root, platform, config):
342
+ def run_all(root, projects, config):
328
343
  timeout = helper_timeout_seconds()
329
344
  results = []
330
- platforms = selected_platforms(platform)
331
- for index, item in enumerate(platforms):
345
+ for index, item in enumerate(projects):
332
346
  command = []
333
347
  try:
334
348
  command = helper_command(root, item, config)
335
- exit_code, output, launch_or_timeout_reason = run_helper(command, item, timeout)
349
+ exit_code, output, launch_or_timeout_reason = run_helper(command, item["type"], timeout)
336
350
  results.append(classify_result(item, command, exit_code, output, launch_or_timeout_reason))
337
351
  except Exception as exc:
338
352
  results.append(
@@ -344,7 +358,7 @@ def run_all(root, platform, config):
344
358
  command_payload(command),
345
359
  )
346
360
  )
347
- for remaining in platforms[index + 1 :]:
361
+ for remaining in projects[index + 1 :]:
348
362
  remaining_command = []
349
363
  try:
350
364
  remaining_command = helper_command(root, remaining, config)
@@ -355,7 +369,7 @@ def run_all(root, platform, config):
355
369
  remaining,
356
370
  "failed",
357
371
  1,
358
- cap_reason(f"not run after internal orchestrator error in {item}: {exc}"),
372
+ cap_reason(f"not run after internal orchestrator error in {item['dir']}: {exc}"),
359
373
  command_payload(remaining_command),
360
374
  )
361
375
  )
@@ -363,9 +377,9 @@ def run_all(root, platform, config):
363
377
  return aggregate_summary(results)
364
378
 
365
379
 
366
- def fallback_internal_summary(platform, root, config, exc):
380
+ def fallback_internal_summary(projects, root, config, exc):
367
381
  results = []
368
- for index, item in enumerate(selected_platforms(platform)):
382
+ for index, item in enumerate(projects):
369
383
  try:
370
384
  command = helper_command(root, item, config)
371
385
  except Exception:
@@ -376,18 +390,25 @@ def fallback_internal_summary(platform, root, config, exc):
376
390
 
377
391
 
378
392
  def main(argv=None):
379
- parser = argparse.ArgumentParser(description="Run SuperSDK template platform builds and emit one root summary")
393
+ parser = argparse.ArgumentParser(description="Run SuperSDK workspace project builds and emit one root summary")
380
394
  parser.add_argument("--root", required=True)
381
- parser.add_argument("--platform", choices=["all", *PLATFORMS], required=True)
395
+ parser.add_argument("--platform", choices=["all", *PROJECT_TYPES], default="all")
396
+ parser.add_argument("--project", default=None)
382
397
  parser.add_argument("--config", required=True)
383
398
  args = parser.parse_args(argv)
384
399
 
385
400
  root = Path(args.root).resolve()
386
401
  config = Path(args.config).resolve()
387
402
  try:
388
- summary = run_all(root, args.platform, config)
403
+ projects = selected_projects(config, args.platform, args.project)
404
+ except supersdk_template.ConfigError as exc:
405
+ # 配置错误发生在编排开始**之前**:按契约,这种情况不发摘要。
406
+ print(str(exc), file=sys.stderr)
407
+ return 1
408
+ try:
409
+ summary = run_all(root, projects, config)
389
410
  except Exception as exc:
390
- summary = fallback_internal_summary(args.platform, root, config, exc)
411
+ summary = fallback_internal_summary(projects, root, config, exc)
391
412
  try:
392
413
  emit_summary(summary)
393
414
  except Exception as exc: