@supersdk/supercli 0.3.3-staging.45 → 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.
- package/dist/build/artifactIntegrity.js +158 -2
- package/dist/build/artifactIntegrity.js.map +1 -1
- package/dist/build/projectBuild.js +335 -0
- package/dist/build/projectBuild.js.map +1 -0
- package/dist/cli.js +0 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.js +35 -29
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/build.js +407 -105
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/init.js +22 -29
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/register.js +62 -217
- package/dist/commands/register.js.map +1 -1
- package/dist/config/appConfig.js +36 -163
- package/dist/config/appConfig.js.map +1 -1
- package/dist/config/superConfig.js +213 -185
- package/dist/config/superConfig.js.map +1 -1
- package/dist/deploy/manifest.js +189 -167
- package/dist/deploy/manifest.js.map +1 -1
- package/dist/deploy/preflight.js +15 -16
- package/dist/deploy/preflight.js.map +1 -1
- package/dist/deploy/runAdapter.js +7 -4
- package/dist/deploy/runAdapter.js.map +1 -1
- package/dist/docker/dockerCli.js +72 -77
- package/dist/docker/dockerCli.js.map +1 -1
- package/dist/template/README.md +26 -94
- package/dist/template/android/gradle/supersdk-config-reader.gradle +13 -62
- package/dist/template/android/scripts/build.sh +11 -0
- package/dist/template/ios/project.yml +1 -1
- package/dist/template/ios/scripts/build.sh +19 -0
- package/dist/template/ios/scripts/render_project.py +60 -0
- package/dist/template/ios/supersdk-default.config.json +6 -0
- package/dist/template/service/scripts/build.sh +11 -0
- package/dist/template/super.json +22 -14
- package/dist/template/template_manifest.json +3 -7
- package/dist/template/web/package.json +8 -0
- package/dist/template/web/scripts/build.sh +8 -0
- package/dist/template/web/scripts/web_package.py +490 -0
- package/dist/template/web/src/js/app.js +2 -2
- package/dist/util/shell.js +3 -3
- package/dist/workspace/config.js +3 -79
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/identity.js +6 -15
- package/dist/workspace/identity.js.map +1 -1
- package/dist/workspace/projectIdentity.js +2 -7
- package/dist/workspace/projectIdentity.js.map +1 -1
- package/dist/workspace/template.js +205 -77
- package/dist/workspace/template.js.map +1 -1
- package/package.json +3 -1
- package/dist/commands/config.js +0 -170
- package/dist/commands/config.js.map +0 -1
- package/dist/template/scripts/android_snapshot_canary.py +0 -145
- package/dist/template/scripts/build_android.sh +0 -382
- package/dist/template/scripts/build_ios.sh +0 -331
- package/dist/template/scripts/build_service.sh +0 -89
- package/dist/template/scripts/build_site.sh +0 -57
- package/dist/template/scripts/lib/workspace.sh +0 -43
- package/dist/template/scripts/serve_web.py +0 -78
- package/dist/template/scripts/super_build_orchestrator.py +0 -344
- package/dist/template/scripts/supersdk_template.py +0 -1394
- package/dist/template/scripts/web_host_validator.py +0 -103
- package/dist/template/scripts/web_package.py +0 -296
- package/dist/template/scripts/ws03_shared_schema_merge_guard.py +0 -73
- package/dist/template/super_build.sh +0 -70
- package/dist/workspace/inspect.js +0 -275
- 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,296 +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 = "super.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, output_dir=DIST_DIRNAME):
|
|
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 / output_dir
|
|
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 <projectId> "
|
|
218
|
-
f"or ./super_build.sh --project <projectId> --build (resolved directory: {project})"
|
|
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
|
-
output_dir = platform_config.get("outputDir", DIST_DIRNAME)
|
|
234
|
-
# 🔴 offline.host 是可选的、由服务端回填的:首次发布成功后 CLI 才把服务端签发的域名
|
|
235
|
-
# 记回配置。CLI 绝不自己拼域名,所以没有它就**跳过离线打包并显式说明原因** ——
|
|
236
|
-
# dist 照常产出(publish-site 要的就是它),静默跳过才是不可接受的那一种。
|
|
237
|
-
if host is None:
|
|
238
|
-
# host 缺席不代表可以少校验:版本号照样要合法,dist 照样要产出。
|
|
239
|
-
validate_version(version.get("name"))
|
|
240
|
-
validate_source(project_root / SRC_DIRNAME)
|
|
241
|
-
dist = build_dist(project_root, config, output_dir)
|
|
242
|
-
reason = (
|
|
243
|
-
f"offline package not built for {project}: projects[].offline.host is not set. "
|
|
244
|
-
"Set projects[].offline.host in super.json when an offline package is required."
|
|
245
|
-
)
|
|
246
|
-
print(reason, file=sys.stderr)
|
|
247
|
-
return {"host": None, "version": version.get("name"), "zip": None, "dist": str(dist), "offline_skipped": reason}
|
|
248
|
-
|
|
249
|
-
try:
|
|
250
|
-
# Validate host/version/source before anything is written, so a bad host cannot
|
|
251
|
-
# leave a stale or partly-rendered dist on disk.
|
|
252
|
-
validate_inputs(project_root / SRC_DIRNAME, host, version.get("name"))
|
|
253
|
-
dist = build_dist(project_root, config, output_dir)
|
|
254
|
-
# 🔴 output/ 是工作空间级的,但同名 zip 会被 unlink 后 replace:两个站点
|
|
255
|
-
# 同 host + 同 version 就会互相顶掉。按项目目录分仓,冲突从根上消失。
|
|
256
|
-
result = package(dist, host, version.get("name"), workspace_root / "output" / project, require_provenance=False)
|
|
257
|
-
except WebPackageError as exc:
|
|
258
|
-
message = str(exc)
|
|
259
|
-
if message.startswith("web.host:"):
|
|
260
|
-
raise WebPackageError(f"offline.host (from {CONFIG_FILENAME}):{message[len('web.host:'):]}") from exc
|
|
261
|
-
raise
|
|
262
|
-
result["dist"] = str(dist)
|
|
263
|
-
return result
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
def main(argv=None):
|
|
267
|
-
parser = argparse.ArgumentParser(description="Validate and package the SuperSDK Web template")
|
|
268
|
-
sub = parser.add_subparsers(dest="command", required=True)
|
|
269
|
-
for name in ("validate", "package"):
|
|
270
|
-
cmd = sub.add_parser(name)
|
|
271
|
-
cmd.add_argument("--src", required=True)
|
|
272
|
-
cmd.add_argument("--host", required=True)
|
|
273
|
-
cmd.add_argument("--version", required=True)
|
|
274
|
-
if name == "package":
|
|
275
|
-
cmd.add_argument("--output-dir", required=True)
|
|
276
|
-
managed = sub.add_parser("package-managed")
|
|
277
|
-
managed.add_argument("--root", required=True)
|
|
278
|
-
managed.add_argument("--project", required=True)
|
|
279
|
-
args = parser.parse_args(argv)
|
|
280
|
-
try:
|
|
281
|
-
if args.command == "package-managed":
|
|
282
|
-
print(json.dumps(package_managed(args.root, args.project), sort_keys=True))
|
|
283
|
-
else:
|
|
284
|
-
source_root, host, version = validate_inputs(args.src, args.host, args.version)
|
|
285
|
-
if args.command == "validate":
|
|
286
|
-
print(json.dumps({"src": str(source_root), "host": host, "version": version}, sort_keys=True))
|
|
287
|
-
else:
|
|
288
|
-
print(json.dumps(package(source_root, host, version, args.output_dir), sort_keys=True))
|
|
289
|
-
except WebPackageError as exc:
|
|
290
|
-
print(str(exc), file=sys.stderr)
|
|
291
|
-
return 1
|
|
292
|
-
return 0
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if __name__ == "__main__":
|
|
296
|
-
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,70 +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 [--build|--plan] [--config PATH] [--project PROJECT_ID] [--output-dir DIR] [--cli-version VERSION]
|
|
15
|
-
|
|
16
|
-
Options:
|
|
17
|
-
--build Build selected projects and write super-build-manifest.json.
|
|
18
|
-
--plan Validate and print the fixed-helper plan (default).
|
|
19
|
-
--config PATH Config file (default: <workspace>/super.json).
|
|
20
|
-
--project PROJECT_ID Build exactly one stable projects[].projectId; omit for all.
|
|
21
|
-
--output-dir DIR New portable output directory (default: <workspace>/output).
|
|
22
|
-
--cli-version VERSION Calling SuperCLI version; standalone builds leave it null.
|
|
23
|
-
--help Show this help.
|
|
24
|
-
EOF
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
mode="plan"
|
|
28
|
-
config="$WORKSPACE_ROOT/super.json"
|
|
29
|
-
project=""
|
|
30
|
-
output_dir="$WORKSPACE_ROOT/output"
|
|
31
|
-
cli_version=""
|
|
32
|
-
mode_set=false
|
|
33
|
-
config_set=false
|
|
34
|
-
project_set=false
|
|
35
|
-
output_set=false
|
|
36
|
-
cli_version_set=false
|
|
37
|
-
|
|
38
|
-
while [ "$#" -gt 0 ]; do
|
|
39
|
-
case "$1" in
|
|
40
|
-
--help|-h) usage; exit 0 ;;
|
|
41
|
-
--build|--plan)
|
|
42
|
-
if [ "$mode_set" = true ]; then echo "error: mode specified more than once" >&2; exit 2; fi
|
|
43
|
-
mode="${1#--}"; mode_set=true; shift ;;
|
|
44
|
-
--config)
|
|
45
|
-
if [ "$config_set" = true ] || [ "$#" -lt 2 ]; then echo "error: --config requires exactly one value" >&2; exit 2; fi
|
|
46
|
-
config="$2"; config_set=true; shift 2 ;;
|
|
47
|
-
--project)
|
|
48
|
-
if [ "$project_set" = true ] || [ "$#" -lt 2 ]; then echo "error: --project requires exactly one value" >&2; exit 2; fi
|
|
49
|
-
project="$2"; project_set=true; shift 2 ;;
|
|
50
|
-
--output-dir)
|
|
51
|
-
if [ "$output_set" = true ] || [ "$#" -lt 2 ]; then echo "error: --output-dir requires exactly one value" >&2; exit 2; fi
|
|
52
|
-
output_dir="$2"; output_set=true; shift 2 ;;
|
|
53
|
-
--cli-version)
|
|
54
|
-
if [ "$cli_version_set" = true ] || [ "$#" -lt 2 ]; then echo "error: --cli-version requires exactly one value" >&2; exit 2; fi
|
|
55
|
-
cli_version="$2"; cli_version_set=true; shift 2 ;;
|
|
56
|
-
*) echo "error: unknown option $1" >&2; exit 2 ;;
|
|
57
|
-
esac
|
|
58
|
-
done
|
|
59
|
-
|
|
60
|
-
if [ "$mode" = "plan" ]; then
|
|
61
|
-
if [ -n "$project" ]; then
|
|
62
|
-
exec "$PYTHON_BIN" "$HELPER" plan --root "$WORKSPACE_ROOT" --config "$config" --project "$project"
|
|
63
|
-
fi
|
|
64
|
-
exec "$PYTHON_BIN" "$HELPER" plan --root "$WORKSPACE_ROOT" --config "$config"
|
|
65
|
-
fi
|
|
66
|
-
|
|
67
|
-
args=(--root "$WORKSPACE_ROOT" --config "$config" --output-dir "$output_dir")
|
|
68
|
-
if [ -n "$project" ]; then args+=(--project "$project"); fi
|
|
69
|
-
if [ -n "$cli_version" ]; then args+=(--cli-version "$cli_version"); fi
|
|
70
|
-
exec "$PYTHON_BIN" "$ORCHESTRATOR" "${args[@]}"
|