@supersdk/supercli 0.3.2 → 0.3.3-staging.47

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 (107) hide show
  1. package/dist/build/artifactIntegrity.js +275 -0
  2. package/dist/build/artifactIntegrity.js.map +1 -0
  3. package/dist/build/projectBuild.js +335 -0
  4. package/dist/build/projectBuild.js.map +1 -0
  5. package/dist/cli.js +20 -11
  6. package/dist/cli.js.map +1 -1
  7. package/dist/commands/add.js +111 -57
  8. package/dist/commands/add.js.map +1 -1
  9. package/dist/commands/analytics.js +15 -9
  10. package/dist/commands/analytics.js.map +1 -1
  11. package/dist/commands/build.js +533 -0
  12. package/dist/commands/build.js.map +1 -0
  13. package/dist/commands/db.js +24 -19
  14. package/dist/commands/db.js.map +1 -1
  15. package/dist/commands/deploy.js +434 -751
  16. package/dist/commands/deploy.js.map +1 -1
  17. package/dist/commands/env.js +8 -8
  18. package/dist/commands/env.js.map +1 -1
  19. package/dist/commands/image.js +31 -20
  20. package/dist/commands/image.js.map +1 -1
  21. package/dist/commands/init.js +81 -57
  22. package/dist/commands/init.js.map +1 -1
  23. package/dist/commands/logs.js +16 -7
  24. package/dist/commands/logs.js.map +1 -1
  25. package/dist/commands/publishSite.js +28 -943
  26. package/dist/commands/publishSite.js.map +1 -1
  27. package/dist/commands/register.js +84 -218
  28. package/dist/commands/register.js.map +1 -1
  29. package/dist/commands/settings.js +10 -6
  30. package/dist/commands/settings.js.map +1 -1
  31. package/dist/config/appConfig.js +48 -171
  32. package/dist/config/appConfig.js.map +1 -1
  33. package/dist/config/superConfig.js +457 -0
  34. package/dist/config/superConfig.js.map +1 -0
  35. package/dist/deploy/adapterTypes.js +3 -0
  36. package/dist/deploy/adapterTypes.js.map +1 -0
  37. package/dist/deploy/manifest.js +403 -0
  38. package/dist/deploy/manifest.js.map +1 -0
  39. package/dist/deploy/preflight.js +201 -0
  40. package/dist/deploy/preflight.js.map +1 -0
  41. package/dist/deploy/resultWriter.js +178 -0
  42. package/dist/deploy/resultWriter.js.map +1 -0
  43. package/dist/deploy/runAdapter.js +302 -0
  44. package/dist/deploy/runAdapter.js.map +1 -0
  45. package/dist/deploy/siteAdapter.js +182 -0
  46. package/dist/deploy/siteAdapter.js.map +1 -0
  47. package/dist/docker/dockerCli.js +110 -53
  48. package/dist/docker/dockerCli.js.map +1 -1
  49. package/dist/output/envelope.js +5 -1
  50. package/dist/output/envelope.js.map +1 -1
  51. package/dist/output/resultPrinter.js +3 -0
  52. package/dist/output/resultPrinter.js.map +1 -1
  53. package/dist/publish/responseClassifier.js +4 -4
  54. package/dist/publish/responseClassifier.js.map +1 -1
  55. package/dist/publish/runClient.js +11 -11
  56. package/dist/publish/runClient.js.map +1 -1
  57. package/dist/publish/siteZip.js +4 -5
  58. package/dist/publish/siteZip.js.map +1 -1
  59. package/dist/template/README.md +26 -257
  60. package/dist/template/android/app/src/main/java/com/supersdk/simple/EnvironmentStore.java +1 -1
  61. package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +2 -2
  62. package/dist/template/android/gradle/supersdk-config-reader.gradle +13 -61
  63. package/dist/template/android/scripts/build.sh +11 -0
  64. package/dist/template/android/supersdk-default.config.json +3 -2
  65. package/dist/template/ios/Sources/App/AppDelegate.swift +1 -1
  66. package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +1 -1
  67. package/dist/template/ios/project.yml +1 -1
  68. package/dist/template/ios/scripts/build.sh +19 -0
  69. package/dist/template/ios/scripts/render_project.py +60 -0
  70. package/dist/template/ios/supersdk-default.config.json +6 -0
  71. package/dist/template/service/Dockerfile +2 -0
  72. package/dist/template/service/scripts/build.sh +11 -0
  73. package/dist/template/super.json +62 -0
  74. package/dist/template/template_manifest.json +6 -9
  75. package/dist/template/web/package.json +8 -0
  76. package/dist/template/web/scripts/build.sh +8 -0
  77. package/dist/template/web/scripts/web_package.py +490 -0
  78. package/dist/template/web/src/js/app.js +2 -2
  79. package/dist/util/shell.js +3 -3
  80. package/dist/workspace/config.js +69 -183
  81. package/dist/workspace/config.js.map +1 -1
  82. package/dist/workspace/identity.js +10 -18
  83. package/dist/workspace/identity.js.map +1 -1
  84. package/dist/workspace/projectContext.js +93 -0
  85. package/dist/workspace/projectContext.js.map +1 -0
  86. package/dist/workspace/projectIdentity.js +50 -98
  87. package/dist/workspace/projectIdentity.js.map +1 -1
  88. package/dist/workspace/template.js +208 -83
  89. package/dist/workspace/template.js.map +1 -1
  90. package/package.json +4 -2
  91. package/dist/publish/siteConfig.js +0 -649
  92. package/dist/publish/siteConfig.js.map +0 -1
  93. package/dist/template/scripts/android_snapshot_canary.py +0 -145
  94. package/dist/template/scripts/build_android.sh +0 -366
  95. package/dist/template/scripts/build_ios.sh +0 -299
  96. package/dist/template/scripts/build_site.sh +0 -43
  97. package/dist/template/scripts/lib/workspace.sh +0 -43
  98. package/dist/template/scripts/serve_web.py +0 -80
  99. package/dist/template/scripts/super_build_orchestrator.py +0 -421
  100. package/dist/template/scripts/supersdk_template.py +0 -1161
  101. package/dist/template/scripts/web_host_validator.py +0 -103
  102. package/dist/template/scripts/web_package.py +0 -295
  103. package/dist/template/scripts/ws03_shared_schema_merge_guard.py +0 -73
  104. package/dist/template/super_build.sh +0 -144
  105. package/dist/template/supersdk.json +0 -35
  106. package/dist/workspace/inspect.js +0 -274
  107. package/dist/workspace/inspect.js.map +0 -1
@@ -1,103 +0,0 @@
1
- #!/usr/bin/env python3
2
- import argparse
3
- import ipaddress
4
- import re
5
- import sys
6
- from urllib.parse import urlparse
7
-
8
-
9
- HOST_DIAGNOSTIC = (
10
- "offline package host must be a deployable bare domain; "
11
- "localhost, IP literals, single-label hosts, whitespace, trailing dots, "
12
- "numeric TLDs, and non-ASCII/IDN input are not supported"
13
- )
14
-
15
-
16
- class HostValidationError(ValueError):
17
- pass
18
-
19
-
20
- def _fail():
21
- raise HostValidationError(HOST_DIAGNOSTIC)
22
-
23
-
24
- def _contains_whitespace(value):
25
- return any(ch.isspace() for ch in value)
26
-
27
-
28
- def _is_ip_literal(value):
29
- try:
30
- ipaddress.ip_address(value)
31
- return True
32
- except ValueError:
33
- return False
34
-
35
-
36
- def _validate_bare_host(host):
37
- if not host or _contains_whitespace(host):
38
- _fail()
39
- try:
40
- host.encode("ascii")
41
- except UnicodeEncodeError:
42
- _fail()
43
- if host != host.lower():
44
- host = host.lower()
45
- if host == "localhost" or _is_ip_literal(host):
46
- _fail()
47
- if host.startswith(".") or host.endswith(".") or ".." in host:
48
- _fail()
49
- if len(host) > 253:
50
- _fail()
51
-
52
- labels = host.split(".")
53
- if len(labels) < 2:
54
- _fail()
55
- label_re = re.compile(r"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$")
56
- for label in labels:
57
- if len(label) < 1 or len(label) > 63 or not label_re.fullmatch(label):
58
- _fail()
59
- if labels[-1].isdigit():
60
- _fail()
61
- if len(labels) == 4 and all(label.isdigit() for label in labels):
62
- _fail()
63
- return host
64
-
65
-
66
- def normalize_host(raw):
67
- if raw is None:
68
- _fail()
69
- if not isinstance(raw, str):
70
- _fail()
71
- if raw == "" or raw != raw.strip() or _contains_whitespace(raw):
72
- _fail()
73
- try:
74
- raw.encode("ascii")
75
- except UnicodeEncodeError:
76
- _fail()
77
-
78
- if "://" in raw:
79
- parsed = urlparse(raw)
80
- if parsed.scheme.lower() not in ("http", "https") or not parsed.hostname:
81
- _fail()
82
- host = parsed.hostname.lower()
83
- else:
84
- if ":" in raw:
85
- _fail()
86
- host = raw.lower()
87
- return _validate_bare_host(host)
88
-
89
-
90
- def main(argv=None):
91
- parser = argparse.ArgumentParser(description="Normalize a Web offline-package host")
92
- parser.add_argument("--host", required=True)
93
- args = parser.parse_args(argv)
94
- try:
95
- print(normalize_host(args.host))
96
- except HostValidationError as exc:
97
- print(f"web.host: {exc}", file=sys.stderr)
98
- return 1
99
- return 0
100
-
101
-
102
- if __name__ == "__main__":
103
- raise SystemExit(main())
@@ -1,295 +0,0 @@
1
- #!/usr/bin/env python3
2
- import argparse
3
- import hashlib
4
- import json
5
- import os
6
- import re
7
- import shutil
8
- import sys
9
- import tempfile
10
- import time
11
- import zipfile
12
- from pathlib import Path
13
-
14
- from web_host_validator import HostValidationError, normalize_host
15
-
16
-
17
- REQUIRED_ASSETS = ("index.html", "js/app.js", "js/supersdk.js", "css/style.css")
18
- EXCLUDED_ASSETS = {"__super_meta.json", ".DS_Store", "js/supersdk.provenance.json"}
19
- HEX64 = set("0123456789abcdef")
20
- VERSION_PATTERN = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
21
- INTEGRITY_PATTERN = re.compile(r"^sha512-[A-Za-z0-9+/]+={0,2}$")
22
- CONFIG_FILENAME = "supersdk.json"
23
-
24
- # `<project>/src` is authored input; `<project>/dist` is the single publishable build
25
- # output. It is what the offline zip is built from AND what `supercli publish-site <dir>`
26
- # takes: a directory with a root index.html and no build-only sidecars.
27
- # Same source tree, not identical content: the zip additionally carries the offline
28
- # manifest `__super_meta.json` at its root, which never belongs in a published site.
29
- SRC_DIRNAME = "src"
30
- DIST_DIRNAME = "dist"
31
- # Runtime config lives INSIDE the package root. The old `../.supersdk/managed/config.json`
32
- # path sat outside the zip/site root and was dropped by the publisher's dotdir rule.
33
- DIST_CONFIG_ASSET = "supersdk-config.json"
34
- DIST_EXCLUDED_ASSETS = ("js/supersdk.provenance.json", "__super_meta.json", ".DS_Store")
35
-
36
-
37
- class WebPackageError(Exception):
38
- pass
39
-
40
-
41
- def validate_version(value):
42
- if not isinstance(value, str) or not VERSION_PATTERN.fullmatch(value):
43
- raise WebPackageError("version.name: must match x.y.z")
44
- parts = value.split(".")
45
- for part in parts:
46
- if len(part) > 1 and part.startswith("0"):
47
- raise WebPackageError("version.name: must match x.y.z")
48
- minor = int(parts[1])
49
- patch = int(parts[2])
50
- if minor > 99 or patch > 99:
51
- raise WebPackageError("version.name: must match x.y.z with minor and patch <= 99")
52
- return value
53
-
54
-
55
- def validate_source(src, require_provenance=True):
56
- root = Path(src)
57
- if not root.is_dir():
58
- raise WebPackageError(f"web package source missing: {root}")
59
- for asset in REQUIRED_ASSETS:
60
- if not (root / asset).is_file():
61
- raise WebPackageError(f"web package asset missing: {asset}")
62
- if require_provenance:
63
- validate_provenance(root)
64
- return root
65
-
66
-
67
- def validate_provenance(root):
68
- provenance_path = root / "js" / "supersdk.provenance.json"
69
- vendored_path = root / "js" / "supersdk.js"
70
- if not provenance_path.is_file():
71
- raise WebPackageError("supersdk.provenance.json: missing")
72
- try:
73
- provenance = json.loads(provenance_path.read_text(encoding="utf-8"))
74
- except (OSError, json.JSONDecodeError, UnicodeDecodeError) as exc:
75
- raise WebPackageError("supersdk.provenance.json: invalid JSON") from exc
76
- expected_fields = {"package", "version", "integrity", "file", "sha256"}
77
- if not isinstance(provenance, dict) or set(provenance) != expected_fields:
78
- raise WebPackageError("supersdk.provenance.json: fields must match public artifact schema")
79
- if provenance.get("package") != "@supersdk/jssdk":
80
- raise WebPackageError("supersdk.provenance.json: package must be @supersdk/jssdk")
81
- if not isinstance(provenance.get("version"), str) or not VERSION_PATTERN.fullmatch(provenance["version"]):
82
- raise WebPackageError("supersdk.provenance.json: version must be x.y.z")
83
- if not isinstance(provenance.get("integrity"), str) or not INTEGRITY_PATTERN.fullmatch(provenance["integrity"]):
84
- raise WebPackageError("supersdk.provenance.json: integrity must be sha512 SRI")
85
- if provenance.get("file") != "dist/supersdk.js":
86
- raise WebPackageError("supersdk.provenance.json: file must be dist/supersdk.js")
87
- vendored_hash = provenance.get("sha256")
88
- if not isinstance(vendored_hash, str) or len(vendored_hash) != 64 or any(ch not in HEX64 for ch in vendored_hash):
89
- raise WebPackageError("supersdk.provenance.json: sha256 must be 64 hex")
90
- actual = hashlib.sha256(vendored_path.read_bytes()).hexdigest()
91
- if actual != vendored_hash:
92
- raise WebPackageError("supersdk.provenance.json: sha256 mismatch")
93
-
94
-
95
- def validate_inputs(src, host, version, require_provenance=True):
96
- try:
97
- normalized_host = normalize_host(host)
98
- except HostValidationError as exc:
99
- raise WebPackageError(f"web.host: {exc}") from exc
100
- normalized_version = validate_version(version)
101
- source_root = validate_source(src, require_provenance=require_provenance)
102
- return source_root, normalized_host, normalized_version
103
-
104
-
105
- def iter_package_files(root):
106
- for path in sorted(root.rglob("*")):
107
- if not path.is_file():
108
- continue
109
- rel = path.relative_to(root).as_posix()
110
- if rel in EXCLUDED_ASSETS or path.name == ".DS_Store":
111
- continue
112
- yield rel, path
113
-
114
-
115
- def copy_package_root(src):
116
- staging_parent = Path(tempfile.mkdtemp(prefix="supersdk-web-package-"))
117
- staging = staging_parent / "package"
118
- shutil.copytree(src, staging)
119
- return staging_parent, staging
120
-
121
-
122
- def write_meta(staging, version):
123
- file_map = {}
124
- for rel, path in iter_package_files(staging):
125
- file_map[rel] = {"length": path.stat().st_size}
126
- meta = {
127
- "__ver": 1,
128
- "app_version": version,
129
- "build_time": int(time.time()),
130
- "file_map": file_map,
131
- }
132
- (staging / "__super_meta.json").write_text(json.dumps(meta, separators=(",", ":")) + "\n", encoding="utf-8")
133
- return meta
134
-
135
-
136
- def zip_staging(staging, output_dir, host, version):
137
- output = Path(output_dir)
138
- output.mkdir(parents=True, exist_ok=True)
139
- temp_zip = output / f"_temp_package_{os.getpid()}_{time.time_ns()}.zip"
140
- try:
141
- with zipfile.ZipFile(temp_zip, "w", compression=zipfile.ZIP_DEFLATED) as archive:
142
- for rel, path in iter_package_files(staging):
143
- archive.write(path, rel)
144
- archive.write(staging / "__super_meta.json", "__super_meta.json")
145
- digest = hashlib.md5(temp_zip.read_bytes()).hexdigest()
146
- final_zip = output / f"{host}@{version}@{digest}.zip"
147
- if final_zip.exists():
148
- final_zip.unlink()
149
- temp_zip.replace(final_zip)
150
- return final_zip, digest
151
- finally:
152
- if temp_zip.exists():
153
- temp_zip.unlink()
154
-
155
-
156
- def build_dist(project_root, managed_config):
157
- """Render <project>/src + the managed config into the publishable <project>/dist.
158
-
159
- Built in a sibling temp dir and swapped in, so a failed build never leaves a
160
- half-written dist behind for `publish-site` to upload.
161
-
162
- `package()` then zips a copy of this same tree; the zip is not byte-identical to
163
- dist because `write_meta` adds the offline manifest `__super_meta.json` to the
164
- package root. Same source tree, one extra offline-only file.
165
- """
166
- project_root = Path(project_root)
167
- source_root = validate_source(project_root / SRC_DIRNAME)
168
- dist = project_root / DIST_DIRNAME
169
- dist.parent.mkdir(parents=True, exist_ok=True)
170
- staging_parent = Path(tempfile.mkdtemp(prefix=".supersdk-web-dist-", dir=dist.parent))
171
- staging = staging_parent / DIST_DIRNAME
172
- try:
173
- shutil.copytree(source_root, staging)
174
- for relative in DIST_EXCLUDED_ASSETS:
175
- candidate = staging / relative
176
- if candidate.is_file():
177
- candidate.unlink()
178
- (staging / DIST_CONFIG_ASSET).write_text(
179
- json.dumps(managed_config, indent=2, sort_keys=True) + "\n", encoding="utf-8"
180
- )
181
- validate_source(staging, require_provenance=False)
182
- if dist.is_symlink() or (dist.exists() and not dist.is_dir()):
183
- dist.unlink()
184
- elif dist.is_dir():
185
- shutil.rmtree(dist)
186
- os.replace(staging, dist)
187
- finally:
188
- shutil.rmtree(staging_parent, ignore_errors=True)
189
- return dist
190
-
191
-
192
- def package(src, host, version, output_dir, require_provenance=True):
193
- source_root, normalized_host, normalized_version = validate_inputs(
194
- src, host, version, require_provenance=require_provenance
195
- )
196
- staging_parent, staging = copy_package_root(source_root)
197
- try:
198
- meta = write_meta(staging, normalized_version)
199
- final_zip, digest = zip_staging(staging, output_dir, normalized_host, normalized_version)
200
- finally:
201
- shutil.rmtree(staging_parent, ignore_errors=True)
202
- return {
203
- "host": normalized_host,
204
- "version": normalized_version,
205
- "md5": digest,
206
- "zip": str(final_zip),
207
- "file_map": meta["file_map"],
208
- }
209
-
210
-
211
- def package_managed(root, project):
212
- workspace_root = Path(root)
213
- project_root = workspace_root / project
214
- config_path = project_root / ".supersdk" / "managed" / "config.json"
215
- if not config_path.is_file():
216
- raise WebPackageError(
217
- f"site managed config missing; run scripts/supersdk_template.py inject --platform site --project {project} "
218
- "or ./super_build.sh --platform site --build"
219
- )
220
- try:
221
- config = json.loads(config_path.read_text(encoding="utf-8"))
222
- except (OSError, json.JSONDecodeError, UnicodeDecodeError) as exc:
223
- raise WebPackageError("site managed config invalid") from exc
224
- # 类型名就是 managed config 里的 platform 值;这个字面量必须跟着 PROJECT_TYPES 走。
225
- if config.get("platform") != "site":
226
- raise WebPackageError("site managed config invalid")
227
- platform_config = config.get("platform_config")
228
- version = config.get("version")
229
- if not isinstance(platform_config, dict) or not isinstance(version, dict):
230
- raise WebPackageError("site managed config invalid")
231
-
232
- host = platform_config.get("host")
233
- # 🔴 offline.host 是可选的、由服务端回填的:首次发布成功后 CLI 才把服务端签发的域名
234
- # 记回配置。CLI 绝不自己拼域名,所以没有它就**跳过离线打包并显式说明原因** ——
235
- # dist 照常产出(publish-site 要的就是它),静默跳过才是不可接受的那一种。
236
- if host is None:
237
- # host 缺席不代表可以少校验:版本号照样要合法,dist 照样要产出。
238
- validate_version(version.get("name"))
239
- validate_source(project_root / SRC_DIRNAME)
240
- dist = build_dist(project_root, config)
241
- reason = (
242
- f"offline package not built for {project}: projects[].offline.host is not set. "
243
- "Publish the site once so the CLI records the server-issued host, or set it by hand in supersdk.json."
244
- )
245
- print(reason, file=sys.stderr)
246
- return {"host": None, "version": version.get("name"), "zip": None, "dist": str(dist), "offline_skipped": reason}
247
-
248
- try:
249
- # Validate host/version/source before anything is written, so a bad host cannot
250
- # leave a stale or partly-rendered dist on disk.
251
- validate_inputs(project_root / SRC_DIRNAME, host, version.get("name"))
252
- dist = build_dist(project_root, config)
253
- # 🔴 output/ 是工作空间级的,但同名 zip 会被 unlink 后 replace:两个站点
254
- # 同 host + 同 version 就会互相顶掉。按项目目录分仓,冲突从根上消失。
255
- result = package(dist, host, version.get("name"), workspace_root / "output" / project, require_provenance=False)
256
- except WebPackageError as exc:
257
- message = str(exc)
258
- if message.startswith("web.host:"):
259
- raise WebPackageError(f"offline.host (from {CONFIG_FILENAME}):{message[len('web.host:'):]}") from exc
260
- raise
261
- result["dist"] = str(dist)
262
- return result
263
-
264
-
265
- def main(argv=None):
266
- parser = argparse.ArgumentParser(description="Validate and package the SuperSDK Web template")
267
- sub = parser.add_subparsers(dest="command", required=True)
268
- for name in ("validate", "package"):
269
- cmd = sub.add_parser(name)
270
- cmd.add_argument("--src", required=True)
271
- cmd.add_argument("--host", required=True)
272
- cmd.add_argument("--version", required=True)
273
- if name == "package":
274
- cmd.add_argument("--output-dir", required=True)
275
- managed = sub.add_parser("package-managed")
276
- managed.add_argument("--root", required=True)
277
- managed.add_argument("--project", required=True)
278
- args = parser.parse_args(argv)
279
- try:
280
- if args.command == "package-managed":
281
- print(json.dumps(package_managed(args.root, args.project), sort_keys=True))
282
- else:
283
- source_root, host, version = validate_inputs(args.src, args.host, args.version)
284
- if args.command == "validate":
285
- print(json.dumps({"src": str(source_root), "host": host, "version": version}, sort_keys=True))
286
- else:
287
- print(json.dumps(package(source_root, host, version, args.output_dir), sort_keys=True))
288
- except WebPackageError as exc:
289
- print(str(exc), file=sys.stderr)
290
- return 1
291
- return 0
292
-
293
-
294
- if __name__ == "__main__":
295
- raise SystemExit(main())
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env python3
2
- import argparse
3
- import json
4
- import sys
5
-
6
-
7
- REQUIRED_FEATURE_IDS = {
8
- "SIMP-F260619163809-Android-Maven-Template",
9
- "SIMP-F260619163821-iOS-SPM-Template",
10
- "SIMP-F260619163833-Web-JSSDK-Template",
11
- }
12
- REQUIRED_GATE = "ws03-shared-managed-config-schema"
13
- SHARED_PATHS = {
14
- "supersimples/app_repo_example/scripts/supersdk_template.py",
15
- "supersimples/tests/test_template_injection.py",
16
- "supersimples/tests/test_template_config.py",
17
- }
18
-
19
-
20
- def _normalize_diff_path(path):
21
- value = str(path).strip().replace("\\", "/")
22
- while value.startswith("./"):
23
- value = value[2:]
24
- marker = "/supersimples/"
25
- if marker in value:
26
- value = "supersimples/" + value.rsplit(marker, 1)[1]
27
- return value
28
-
29
-
30
- def _touches_shared_schema(diff_paths):
31
- return any(_normalize_diff_path(path) in SHARED_PATHS for path in diff_paths)
32
-
33
-
34
- def _manifest_ok(target_branch, manifest):
35
- if not isinstance(manifest, dict):
36
- return False, "active_gates_manifest must be an object"
37
- if target_branch != "yolo/su-ws03":
38
- return False, "target_branch must be yolo/su-ws03 for shared schema changes"
39
- if manifest.get("target_branch") != "yolo/su-ws03":
40
- return False, "manifest target_branch must be yolo/su-ws03"
41
- if not REQUIRED_FEATURE_IDS.issubset(set(manifest.get("feature_ids") or [])):
42
- return False, "manifest must include all WS-03 feature ids"
43
- if REQUIRED_GATE not in set(manifest.get("gates") or []):
44
- return False, f"manifest must include {REQUIRED_GATE}"
45
- return True, "shared schema batch accepted"
46
-
47
-
48
- def evaluate_guard(diff_paths, target_branch, active_gates_manifest):
49
- paths = [_normalize_diff_path(path) for path in diff_paths]
50
- if not _touches_shared_schema(paths):
51
- return {"verdict": "accept", "reason": "no shared schema paths touched"}
52
- ok, reason = _manifest_ok(target_branch, active_gates_manifest)
53
- return {"verdict": "accept" if ok else "reject", "reason": reason}
54
-
55
-
56
- def main(argv=None):
57
- parser = argparse.ArgumentParser(description="Evaluate WS-03 shared schema merge guard inputs")
58
- parser.add_argument("--target-branch", required=True)
59
- parser.add_argument("--manifest-json", required=True)
60
- parser.add_argument("paths", nargs="*")
61
- args = parser.parse_args(argv)
62
- try:
63
- manifest = json.loads(args.manifest_json)
64
- except json.JSONDecodeError as exc:
65
- print(f"active_gates_manifest invalid JSON: {exc}", file=sys.stderr)
66
- return 1
67
- result = evaluate_guard(args.paths, args.target_branch, manifest)
68
- print(json.dumps(result, sort_keys=True))
69
- return 0 if result["verdict"] == "accept" else 1
70
-
71
-
72
- if __name__ == "__main__":
73
- raise SystemExit(main())
@@ -1,144 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
- # shellcheck source=scripts/lib/workspace.sh
6
- . "$SCRIPT_DIR/scripts/lib/workspace.sh"
7
- WORKSPACE_ROOT="$(supersdk_require_workspace_root "$SCRIPT_DIR")"
8
- PYTHON_BIN="${PYTHON_BIN:-python3}"
9
- HELPER="$WORKSPACE_ROOT/scripts/supersdk_template.py"
10
- ORCHESTRATOR="$WORKSPACE_ROOT/scripts/super_build_orchestrator.py"
11
-
12
- usage() {
13
- cat <<'EOF'
14
- Usage: ./super_build.sh [--platform all|android|ios|site] [--project DIR] [--plan|--build] [--force] [--config path]
15
-
16
- Options:
17
- --platform VALUE Project type to plan/build. Default: all.
18
- --project DIR Single project directory (as written in supersdk.json projects[].dir).
19
- --plan Validate and print the build plan. Default when no mode is set.
20
- --build Validate, inject managed config, then call project build helpers.
21
- --force Allow replacing unmanaged target files during injection.
22
- --config PATH Config file. Default: <workspace root>/supersdk.json.
23
- --help Show this help.
24
- EOF
25
- }
26
-
27
- platform="all"
28
- project=""
29
- config="$WORKSPACE_ROOT/supersdk.json"
30
- mode="plan"
31
- mode_set=false
32
- platform_set=false
33
- project_set=false
34
- config_set=false
35
- force_set=false
36
- force=false
37
-
38
- while [ "$#" -gt 0 ]; do
39
- case "$1" in
40
- --help|-h)
41
- usage
42
- exit 0
43
- ;;
44
- --platform)
45
- if [ "$platform_set" = true ]; then
46
- echo "error: --platform specified more than once" >&2
47
- exit 2
48
- fi
49
- if [ "$#" -lt 2 ]; then
50
- echo "error: --platform requires a value" >&2
51
- exit 2
52
- fi
53
- platform="$2"
54
- platform_set=true
55
- shift 2
56
- ;;
57
- --project)
58
- if [ "$project_set" = true ]; then
59
- echo "error: --project specified more than once" >&2
60
- exit 2
61
- fi
62
- if [ "$#" -lt 2 ]; then
63
- echo "error: --project requires a value" >&2
64
- exit 2
65
- fi
66
- project="$2"
67
- project_set=true
68
- shift 2
69
- ;;
70
- --config)
71
- if [ "$config_set" = true ]; then
72
- echo "error: --config specified more than once" >&2
73
- exit 2
74
- fi
75
- if [ "$#" -lt 2 ]; then
76
- echo "error: --config requires a value" >&2
77
- exit 2
78
- fi
79
- config="$2"
80
- config_set=true
81
- shift 2
82
- ;;
83
- --plan)
84
- if [ "$mode_set" = true ]; then
85
- echo "error: mode specified more than once" >&2
86
- exit 2
87
- fi
88
- mode="plan"
89
- mode_set=true
90
- shift
91
- ;;
92
- --build)
93
- if [ "$mode_set" = true ]; then
94
- echo "error: mode specified more than once" >&2
95
- exit 2
96
- fi
97
- mode="build"
98
- mode_set=true
99
- shift
100
- ;;
101
- --force)
102
- if [ "$force_set" = true ]; then
103
- echo "error: --force specified more than once" >&2
104
- exit 2
105
- fi
106
- force=true
107
- force_set=true
108
- shift
109
- ;;
110
- *)
111
- echo "error: unknown option $1" >&2
112
- exit 2
113
- ;;
114
- esac
115
- done
116
-
117
- case "$platform" in
118
- all|android|ios|site) ;;
119
- *)
120
- echo "error: invalid platform $platform" >&2
121
- exit 2
122
- ;;
123
- esac
124
-
125
- selection=(--platform "$platform")
126
- if [ "$project_set" = true ]; then
127
- selection+=(--project "$project")
128
- fi
129
-
130
- # 引擎版本比对:managed config 记录了写它的那一版引擎。模板是 vendored 进每个工作空间的,
131
- # 升级后不重新投影就会拿旧形状去喂新构建脚本。只 warn,不阻断。
132
- "$PYTHON_BIN" "$HELPER" engine-check --root "$WORKSPACE_ROOT" --config "$config" || true
133
-
134
- if [ "$mode" = "plan" ]; then
135
- exec "$PYTHON_BIN" "$HELPER" plan --root "$WORKSPACE_ROOT" --config "$config" "${selection[@]}"
136
- fi
137
-
138
- inject_args=(inject --root "$WORKSPACE_ROOT" --config "$config" "${selection[@]}")
139
- if [ "$force" = true ]; then
140
- inject_args+=(--force)
141
- fi
142
- "$PYTHON_BIN" "$HELPER" "${inject_args[@]}"
143
-
144
- exec "$PYTHON_BIN" "$ORCHESTRATOR" --root "$WORKSPACE_ROOT" --config "$config" "${selection[@]}"
@@ -1,35 +0,0 @@
1
- {
2
- "schemaVersion": 3,
3
- "spid": "demo0001",
4
- "name": "SuperSDK Simple",
5
- "version": {
6
- "name": "1.0.0",
7
- "code": 1
8
- },
9
- "sdk": {
10
- "androidVersion": "1.0.0.57-SNAPSHOT"
11
- },
12
- "projects": [
13
- {
14
- "type": "android",
15
- "dir": "android",
16
- "name": "SuperSDK Simple",
17
- "package": "com.supersdk.simple.host"
18
- },
19
- {
20
- "type": "ios",
21
- "dir": "ios",
22
- "name": "SuperSDK Simple",
23
- "bundleId": "com.supersdk.simple",
24
- "spmMode": "mock"
25
- },
26
- {
27
- "type": "site",
28
- "dir": "web",
29
- "name": "SuperSDK Simple Web",
30
- "offline": {
31
- "host": "simple.supersdk.com"
32
- }
33
- }
34
- ]
35
- }