@supersdk/supercli 0.2.1-staging.20 → 0.3.0-staging.22
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/api/consoleClient.js +17 -12
- package/dist/api/consoleClient.js.map +1 -1
- package/dist/auth/browserAuth.js +42 -44
- package/dist/auth/browserAuth.js.map +1 -1
- package/dist/auth/tokenAuth.js +46 -0
- package/dist/auth/tokenAuth.js.map +1 -0
- package/dist/cli.js +70 -8
- package/dist/cli.js.map +1 -1
- package/dist/commands/accounts.js +89 -31
- package/dist/commands/accounts.js.map +1 -1
- package/dist/commands/add.js +519 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/init.js +234 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.js +75 -48
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +20 -25
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/publishSite.js +491 -149
- package/dist/commands/publishSite.js.map +1 -1
- package/dist/commands/switchaccount.js +36 -24
- package/dist/commands/switchaccount.js.map +1 -1
- package/dist/config/appConfig.js +160 -45
- package/dist/config/appConfig.js.map +1 -1
- package/dist/config/environments.js +17 -1
- package/dist/config/environments.js.map +1 -1
- package/dist/exit/exitCodes.js +55 -0
- package/dist/exit/exitCodes.js.map +1 -0
- package/dist/output/envelope.js +104 -0
- package/dist/output/envelope.js.map +1 -0
- package/dist/output/resultPrinter.js +70 -0
- package/dist/output/resultPrinter.js.map +1 -0
- package/dist/publish/siteClient.js +14 -4
- package/dist/publish/siteClient.js.map +1 -1
- package/dist/publish/siteConfig.js +278 -63
- package/dist/publish/siteConfig.js.map +1 -1
- package/dist/store/accountStore.js +2 -2
- package/dist/store/accountStore.js.map +1 -1
- package/dist/store/backends/encryptedFile.js +4 -1
- package/dist/store/backends/encryptedFile.js.map +1 -1
- package/dist/store/backends/osKeyring.js +4 -8
- package/dist/store/backends/osKeyring.js.map +1 -1
- package/dist/store/credentialStore.js +22 -0
- package/dist/store/credentialStore.js.map +1 -1
- package/dist/template/README.md +144 -85
- package/dist/template/android/app/build.gradle.kts +0 -3
- package/dist/template/android/app/src/main/java/com/supersdk/simple/EnvironmentStore.java +41 -0
- package/dist/template/android/app/src/main/java/com/supersdk/simple/MainActivity.java +57 -4
- package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +3 -1
- package/dist/template/android/gradle/supersdk-config-reader.gradle +5 -3
- package/dist/template/android/supersdk-default.config.json +4 -3
- package/dist/template/ios/Sources/App/EnvironmentStore.swift +35 -0
- package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +2 -1
- package/dist/template/ios/Sources/App/SimpleSDKProbe.swift +15 -0
- package/dist/template/ios/Sources/App/SimpleViewController.swift +52 -8
- package/dist/template/ios/Tests/SimpleAppTests/SimpleSDKInitializationTests.swift +12 -1
- package/dist/template/scripts/android_snapshot_canary.py +17 -8
- package/dist/template/scripts/build_android.sh +36 -9
- package/dist/template/scripts/build_ios.sh +63 -24
- package/dist/template/scripts/build_site.sh +43 -0
- package/dist/template/scripts/lib/workspace.sh +43 -0
- package/dist/template/scripts/serve_web.py +26 -9
- package/dist/template/scripts/super_build_orchestrator.py +49 -28
- package/dist/template/scripts/supersdk_template.py +759 -240
- package/dist/template/scripts/web_package.py +44 -20
- package/dist/template/super_build.sh +40 -12
- package/dist/template/supersdk.json +25 -13
- package/dist/template/template_manifest.json +25 -0
- package/dist/template/web/src/css/style.css +28 -0
- package/dist/template/web/src/index.html +8 -0
- package/dist/template/web/src/js/app.js +92 -19
- package/dist/util/log.js +10 -1
- package/dist/util/log.js.map +1 -1
- package/dist/util/prompt.js +25 -0
- package/dist/util/prompt.js.map +1 -1
- package/dist/workspace/config.js +440 -0
- package/dist/workspace/config.js.map +1 -0
- package/dist/workspace/identity.js +106 -0
- package/dist/workspace/identity.js.map +1 -0
- package/dist/workspace/interactive.js +96 -0
- package/dist/workspace/interactive.js.map +1 -0
- package/dist/workspace/template.js +357 -0
- package/dist/workspace/template.js.map +1 -0
- package/package.json +1 -1
- package/dist/auth/refresh.js +0 -32
- package/dist/auth/refresh.js.map +0 -1
- package/dist/commands/createApp.js +0 -448
- package/dist/commands/createApp.js.map +0 -1
- package/dist/createApp/copyTemplate.js +0 -561
- package/dist/createApp/copyTemplate.js.map +0 -1
- package/dist/template/scripts/build_web.sh +0 -12
|
@@ -5,14 +5,25 @@ import http.server
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
9
|
+
import supersdk_template
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def resolve_site_dir(root, project):
|
|
13
|
+
"""站点目录来自配置,不是写死的 `web/`。"""
|
|
14
|
+
if project:
|
|
15
|
+
return project
|
|
16
|
+
return supersdk_template.resolve_single(Path(root) / supersdk_template.CONFIG_FILENAME, "site", None)
|
|
17
|
+
|
|
8
18
|
|
|
9
19
|
def main(argv=None):
|
|
10
|
-
parser = argparse.ArgumentParser(description="Serve
|
|
20
|
+
parser = argparse.ArgumentParser(description="Serve a SuperSDK site project for local HTTP debugging")
|
|
11
21
|
parser.add_argument("--root", default=Path(__file__).resolve().parents[1], type=Path)
|
|
22
|
+
parser.add_argument("--project", default=None, help="Site project directory; resolved from supersdk.json when omitted.")
|
|
12
23
|
parser.add_argument(
|
|
13
24
|
"--host",
|
|
14
25
|
default="127.0.0.1",
|
|
15
|
-
help="Bind host. The default is loopback-only; non-loopback binds expose the
|
|
26
|
+
help="Bind host. The default is loopback-only; non-loopback binds expose the workspace root.",
|
|
16
27
|
)
|
|
17
28
|
parser.add_argument("--port", default=8000, type=int)
|
|
18
29
|
parser.add_argument(
|
|
@@ -23,28 +34,34 @@ def main(argv=None):
|
|
|
23
34
|
args = parser.parse_args(argv)
|
|
24
35
|
|
|
25
36
|
root = args.root.resolve()
|
|
26
|
-
|
|
37
|
+
try:
|
|
38
|
+
site_dir = resolve_site_dir(root, args.project)
|
|
39
|
+
except supersdk_template.ConfigError as exc:
|
|
40
|
+
print(str(exc), file=sys.stderr)
|
|
41
|
+
return 1
|
|
42
|
+
|
|
43
|
+
# Prefer the built package root: only <project>/dist carries the generated
|
|
27
44
|
# supersdk-config.json that the browser fallback path reads.
|
|
28
45
|
entry = None
|
|
29
|
-
for relative in ("
|
|
46
|
+
for relative in (f"{site_dir}/dist/index.html", f"{site_dir}/src/index.html"):
|
|
30
47
|
if (root / relative).is_file():
|
|
31
48
|
entry = relative
|
|
32
49
|
break
|
|
33
50
|
if entry is None:
|
|
34
|
-
print(f"
|
|
51
|
+
print(f"{site_dir}/dist/index.html or {site_dir}/src/index.html not found under {root}", file=sys.stderr)
|
|
35
52
|
return 1
|
|
36
|
-
if entry.
|
|
53
|
+
if entry.endswith("/src/index.html"):
|
|
37
54
|
print(
|
|
38
|
-
"warning: serving unbuilt
|
|
55
|
+
f"warning: serving unbuilt {site_dir}/src; run scripts/build_site.sh --build for the browser config fallback",
|
|
39
56
|
file=sys.stderr,
|
|
40
57
|
)
|
|
41
58
|
|
|
42
59
|
remote_bind = args.host not in {"127.0.0.1", "localhost", "::1"}
|
|
43
60
|
if remote_bind and not args.allow_remote:
|
|
44
|
-
print("refusing non-loopback bind; pass --allow-remote to expose the full
|
|
61
|
+
print("refusing non-loopback bind; pass --allow-remote to expose the full workspace root", file=sys.stderr)
|
|
45
62
|
return 1
|
|
46
63
|
if remote_bind:
|
|
47
|
-
print("warning: serving the full
|
|
64
|
+
print("warning: serving the full workspace root on a non-loopback host", file=sys.stderr)
|
|
48
65
|
|
|
49
66
|
handler = functools.partial(http.server.SimpleHTTPRequestHandler, directory=str(root))
|
|
50
67
|
server = http.server.ThreadingHTTPServer((args.host, args.port), handler)
|
|
@@ -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
|
-
|
|
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
|
|
68
|
-
|
|
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,
|
|
72
|
-
script = Path(root) / "scripts" / f"build_{
|
|
73
|
-
command = [str(script), "--build"]
|
|
74
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
291
|
+
return platform_result(project, "failed", exit_code, cap_reason(reason), command_payload)
|
|
280
292
|
|
|
281
|
-
if
|
|
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(
|
|
296
|
+
return platform_result(project, "skipped", exit_code, cap_reason(marker), command_payload)
|
|
285
297
|
|
|
286
|
-
return platform_result(
|
|
298
|
+
return platform_result(project, "success", exit_code, "", command_payload)
|
|
287
299
|
|
|
288
300
|
|
|
289
|
-
def platform_result(
|
|
301
|
+
def platform_result(project, status, exit_code, reason, command):
|
|
290
302
|
return {
|
|
291
|
-
"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":
|
|
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,
|
|
342
|
+
def run_all(root, projects, config):
|
|
328
343
|
timeout = helper_timeout_seconds()
|
|
329
344
|
results = []
|
|
330
|
-
|
|
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
|
|
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(
|
|
380
|
+
def fallback_internal_summary(projects, root, config, exc):
|
|
367
381
|
results = []
|
|
368
|
-
for index, item in enumerate(
|
|
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
|
|
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", *
|
|
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
|
-
|
|
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(
|
|
411
|
+
summary = fallback_internal_summary(projects, root, config, exc)
|
|
391
412
|
try:
|
|
392
413
|
emit_summary(summary)
|
|
393
414
|
except Exception as exc:
|