@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.
Files changed (67) hide show
  1. package/dist/build/artifactIntegrity.js +158 -2
  2. package/dist/build/artifactIntegrity.js.map +1 -1
  3. package/dist/build/projectBuild.js +335 -0
  4. package/dist/build/projectBuild.js.map +1 -0
  5. package/dist/cli.js +0 -2
  6. package/dist/cli.js.map +1 -1
  7. package/dist/commands/add.js +35 -29
  8. package/dist/commands/add.js.map +1 -1
  9. package/dist/commands/build.js +407 -105
  10. package/dist/commands/build.js.map +1 -1
  11. package/dist/commands/init.js +22 -29
  12. package/dist/commands/init.js.map +1 -1
  13. package/dist/commands/register.js +62 -217
  14. package/dist/commands/register.js.map +1 -1
  15. package/dist/config/appConfig.js +36 -163
  16. package/dist/config/appConfig.js.map +1 -1
  17. package/dist/config/superConfig.js +213 -185
  18. package/dist/config/superConfig.js.map +1 -1
  19. package/dist/deploy/manifest.js +189 -167
  20. package/dist/deploy/manifest.js.map +1 -1
  21. package/dist/deploy/preflight.js +15 -16
  22. package/dist/deploy/preflight.js.map +1 -1
  23. package/dist/deploy/runAdapter.js +7 -4
  24. package/dist/deploy/runAdapter.js.map +1 -1
  25. package/dist/docker/dockerCli.js +72 -77
  26. package/dist/docker/dockerCli.js.map +1 -1
  27. package/dist/template/README.md +26 -94
  28. package/dist/template/android/gradle/supersdk-config-reader.gradle +13 -62
  29. package/dist/template/android/scripts/build.sh +11 -0
  30. package/dist/template/ios/project.yml +1 -1
  31. package/dist/template/ios/scripts/build.sh +19 -0
  32. package/dist/template/ios/scripts/render_project.py +60 -0
  33. package/dist/template/ios/supersdk-default.config.json +6 -0
  34. package/dist/template/service/scripts/build.sh +11 -0
  35. package/dist/template/super.json +22 -14
  36. package/dist/template/template_manifest.json +3 -7
  37. package/dist/template/web/package.json +8 -0
  38. package/dist/template/web/scripts/build.sh +8 -0
  39. package/dist/template/web/scripts/web_package.py +490 -0
  40. package/dist/template/web/src/js/app.js +2 -2
  41. package/dist/util/shell.js +3 -3
  42. package/dist/workspace/config.js +3 -79
  43. package/dist/workspace/config.js.map +1 -1
  44. package/dist/workspace/identity.js +6 -15
  45. package/dist/workspace/identity.js.map +1 -1
  46. package/dist/workspace/projectIdentity.js +2 -7
  47. package/dist/workspace/projectIdentity.js.map +1 -1
  48. package/dist/workspace/template.js +205 -77
  49. package/dist/workspace/template.js.map +1 -1
  50. package/package.json +3 -1
  51. package/dist/commands/config.js +0 -170
  52. package/dist/commands/config.js.map +0 -1
  53. package/dist/template/scripts/android_snapshot_canary.py +0 -145
  54. package/dist/template/scripts/build_android.sh +0 -382
  55. package/dist/template/scripts/build_ios.sh +0 -331
  56. package/dist/template/scripts/build_service.sh +0 -89
  57. package/dist/template/scripts/build_site.sh +0 -57
  58. package/dist/template/scripts/lib/workspace.sh +0 -43
  59. package/dist/template/scripts/serve_web.py +0 -78
  60. package/dist/template/scripts/super_build_orchestrator.py +0 -344
  61. package/dist/template/scripts/supersdk_template.py +0 -1394
  62. package/dist/template/scripts/web_host_validator.py +0 -103
  63. package/dist/template/scripts/web_package.py +0 -296
  64. package/dist/template/scripts/ws03_shared_schema_merge_guard.py +0 -73
  65. package/dist/template/super_build.sh +0 -70
  66. package/dist/workspace/inspect.js +0 -275
  67. package/dist/workspace/inspect.js.map +0 -1
@@ -1,100 +1,32 @@
1
- # SuperSDK multi-project template
1
+ # SuperSDK Simple project template
2
2
 
3
- This directory is a copy-and-go workspace template. `super.json` schema v4 is the
4
- single source of truth for one platform project (`spid`) and any number of local
5
- modules identified by stable `projectId` values.
3
+ This directory contains four independent project templates and a root `super.json`.
4
+ The configuration is schema v5, with one SPID per file. Each project owns its
5
+ build entry and artifact declaration; there is no workspace builder or shared
6
+ Python schema engine.
6
7
 
7
- ## Configuration
8
-
9
- The default authority is `<workspace>/super.json`. An alternative product config
10
- must be selected explicitly with `--config`; helpers never fall back after an
11
- explicit path fails. The retired `supersdk.json` is not read alongside v4.
12
-
13
- Each project has:
14
-
15
- - `projectId`: stable local selector used by `--project`;
16
- - `type`: one of `android`, `ios`, `site`, or `service`;
17
- - `dir`: relative project source directory;
18
- - platform identity/build fields;
19
- - for `site` and `service`, optional named `deploy[]` targets selected later by
20
- SuperCLI using `envTarget`.
21
-
22
- Configuration is strict JSON. Duplicate keys, `NaN`/`Infinity`, aliases, unknown
23
- fields, absolute/traversing paths, overlapping project directories, duplicate
24
- project IDs, and duplicate `(slug, env)` deployment identities fail closed.
25
-
26
- Secrets and runtime values never belong in `super.json`. Service build arguments
27
- and deployment variables store environment-variable names only. Docker build args
28
- are not a secret channel because image history may retain them.
29
-
30
- ## Build
31
-
32
- Plan all configured projects:
33
-
34
- ```bash
35
- ./super_build.sh --plan
36
- ```
37
-
38
- Build all projects to a new portable directory:
39
-
40
- ```bash
41
- ./super_build.sh --build --output-dir ./output
42
- ```
43
-
44
- Build one stable module:
8
+ Build through the installed CLI from the workspace root:
45
9
 
46
10
  ```bash
47
- ./super_build.sh --build --project web --output-dir ./output-web
11
+ supercli build --config ./super.json --project web --output-dir .super/build-web
12
+ supercli build-all --config ./super.json --output-dir .super/build-all
48
13
  ```
49
14
 
50
- Use another config explicitly:
51
-
52
- ```bash
53
- ./super_build.sh --build --config ./super.other.json --output-dir ./output-other
54
- ```
55
-
56
- The output directory must not already exist. A build always uses fixed bundled
57
- helpers; config cannot provide commands or plugins. Android produces APK/AAB,
58
- iOS produces its archive (or an explicit platform-tool skip), site produces a
59
- publishable `dist` plus optional offline zip, and service runs local `docker build`
60
- then `docker save` without logging in, pushing, or creating a registry resource.
61
-
62
- Every completed output contains `super-build-manifest.json` with:
63
-
64
- - actual builder `engineVersion`, optional calling `cliVersion`, and builder bundle
65
- digest;
66
- - canonical config digest and SPID;
67
- - Git commit/dirty source metadata when available;
68
- - single/all selection and real per-project status;
69
- - evidence and artifact relative paths, sizes, counts, and SHA-256 values.
70
-
71
- Paths are relative to the build directory so it can move between machines. A
72
- failed helper stays failed in both the manifest and the final
73
- `SUPERSDK_BUILD_SUMMARY_JSON=...` line.
74
-
75
- ## Migration from schema v3
76
-
77
- Use the installed SuperCLI entrypoint:
78
-
79
- ```bash
80
- supercli config migrate --from supersdk.json --to super.json
81
- ```
82
-
83
- The bundled Python authority only writes the target when every v3 field maps
84
- without ambiguity and the generated document passes the strict v4 validator.
85
- Source and target must have the same normalized parent directory. Migration adds
86
- `projectId` from each directory basename and maps site targets to `envTarget`.
87
- Unknown fields, conflicting IDs/targets/output directories, an existing target,
88
- or a cross-directory destination fail before replacement. The source is never
89
- deleted; inspect `super.json`, then explicitly move the retired `supersdk.json`.
90
- While both names coexist, project commands fail closed.
91
-
92
- ## Managed configuration
93
-
94
- The authority projects the selected config into
95
- `<project>/.supersdk/managed/config.json`. Managed readers validate the exact v4
96
- shape and engine version. Re-run a build after updating bundled workspace scripts;
97
- an older v3 engine rejects schema v4 instead of guessing new fields.
98
-
99
- Generated build state, `.super/deploy-results`, platform build directories, and
100
- portable `output/` directories are ignored by the template `.gitignore`.
15
+ `build.entry` is relative to the project directory and runs with that directory
16
+ as cwd. The only substitution is `${spid}` in `build.args`; project files own
17
+ all other toolchain options. Bundled `.sh` entries are POSIX examples (Linux or
18
+ macOS; iOS additionally requires Xcode). Windows installation/configuration is
19
+ supported, but official shell entries are not promised to execute there.
20
+
21
+ The Web project keeps its package version and offline host only in
22
+ `web/package.json`; the build does not duplicate or read those values from
23
+ `super.json`.
24
+ Its local build helper verifies the vendored JSSDK provenance and SHA-256 before
25
+ writing output. It emits a publishable `site-dist` directory without the
26
+ provenance sidecar, plus the declared `site-offline-zip` file containing
27
+ `__super_meta.json`. Edit that project-local metadata when changing the Web
28
+ package; SuperCLI still supplies only the configured SPID.
29
+ The bundled Web helper uses only the Python 3 standard library.
30
+
31
+ `register` records `build: {}` for an existing project without touching its
32
+ files. Add the actual entry, arguments, and artifact paths before building.
@@ -1,74 +1,25 @@
1
1
  import groovy.json.JsonSlurper
2
2
 
3
3
  def androidRoot = rootProject.projectDir
4
- def managedConfig = new File(androidRoot, ".supersdk/managed/config.json")
5
- def defaultConfig = new File(androidRoot, "supersdk-default.config.json")
6
- def configFile = managedConfig.isFile() ? managedConfig : defaultConfig
7
-
8
- // 🔴 走 fallback 必须出声。managed config 是 `./super_build.sh --build` 从根目录
9
- // super.json 投影出来的**当前**身份;supersdk-default.config.json 只是仓库里的一份
10
- // 快照,`--plan` 不会刷新它。静默使用快照意味着「改了 super.json 却装出旧身份的包」,
11
- // 而且构建照样 exit 0 —— 这类静默成功比直接失败危险得多。
12
- if (!managedConfig.isFile()) {
13
- logger.warn("SuperSDK: ${managedConfig} 不存在,回退使用 ${defaultConfig.name} 里的快照身份。" +
14
- "改过 super.json 的话请先跑 ./super_build.sh --build 重新投影,否则产物身份可能是旧的。")
15
- }
16
-
4
+ def configFile = new File(androidRoot, "supersdk-default.config.json")
17
5
  if (!configFile.isFile()) {
18
- throw new GradleException("SuperSDK Android config not found: ${managedConfig} or ${defaultConfig}")
6
+ throw new GradleException("Android project identity config missing: ${configFile}")
19
7
  }
20
-
21
8
  def config
22
- try {
23
- config = new JsonSlurper().parse(configFile)
24
- } catch (Exception exc) {
25
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: ${exc.message}", exc)
26
- }
27
-
9
+ try { config = new JsonSlurper().parse(configFile) }
10
+ catch (Exception exc) { throw new GradleException("Android project build config invalid: ${exc.message}", exc) }
28
11
  def requireString = { value, name ->
29
- if (!(value instanceof String) || value.trim().isEmpty()) {
30
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: ${name} must be a non-empty string")
31
- }
12
+ if (!(value instanceof String) || value.trim().isEmpty()) throw new GradleException("${name} must be a non-empty string")
32
13
  value
33
14
  }
34
-
35
- def requireMatchingString = { value, name, pattern, message ->
36
- def result = requireString(value, name)
37
- if (!(result ==~ pattern)) {
38
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: ${name} ${message}")
39
- }
40
- result
41
- }
42
-
43
- def version = config.version instanceof Map ? config.version : [:]
44
- def platformConfig = config.platform_config instanceof Map ? config.platform_config : [:]
45
- def sdk = config.sdk instanceof Map ? config.sdk : [:]
46
- if (config.managed_by != "supersdk-template") {
47
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: managed_by must be supersdk-template")
48
- }
49
- if (config.schema_version != 4) {
50
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: schema_version must be 4")
51
- }
52
- def versionCodeValue = version.code
53
- if (!(versionCodeValue instanceof Number)) {
54
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: version.code must be a positive 32-bit integer")
55
- }
56
- def versionCodeDecimal = new BigDecimal(versionCodeValue.toString())
57
- if (versionCodeDecimal.scale() > 0 || versionCodeDecimal < BigDecimal.ONE || versionCodeDecimal > new BigDecimal("2147483647")) {
58
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: version.code must be a positive 32-bit integer")
59
- }
60
-
61
15
  ext.supersdkAndroidConfigPath = configFile.absolutePath
62
- ext.supersdkProjectId = requireMatchingString(config.project_id, "project_id", /[a-z0-9][a-z0-9-]{0,62}/, 'must match ^[a-z0-9][a-z0-9-]{0,62}$')
63
- ext.supersdkSpid = requireMatchingString(config.spid, "spid", /[a-z0-9]{8}/, 'must match ^[a-z0-9]{8}$')
64
- // 🔴 这里**没有** environment。它是 SuperSDK.init 的运行时参数,编译期不需要,
65
- // 也就不该进 BuildConfig —— 一旦编进产物,换环境就等于重新打包。
66
- // demo 在运行时切(见 EnvironmentStore.java)。
16
+ def explicitSpid = project.findProperty("supersdkSpid")
17
+ ext.supersdkSpid = requireString(explicitSpid ?: config.spid, "spid")
67
18
  ext.supersdkAppName = requireString(config.name, "name")
68
- if ((ext.supersdkAppName =~ /[\x00-\x1F]/).find() || ext.supersdkAppName != ext.supersdkAppName.trim()) {
69
- throw new GradleException("SuperSDK Android config invalid at ${configFile}: name must be a non-empty Android app label without control characters or edge whitespace")
70
- }
71
- ext.supersdkApplicationId = requireMatchingString(platformConfig.package, "platform_config.package", /[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+/, "must be a Java package")
19
+ def platformConfig = config.platform_config instanceof Map ? config.platform_config : [:]
20
+ def version = config.version instanceof Map ? config.version : [:]
21
+ def sdk = config.sdk instanceof Map ? config.sdk : [:]
22
+ ext.supersdkApplicationId = requireString(platformConfig.package, "platform_config.package")
72
23
  ext.supersdkVersionName = requireString(version.name, "version.name")
73
- ext.supersdkVersionCode = versionCodeDecimal.intValueExact()
74
- ext.supersdkAndroidVersion = requireMatchingString(sdk.androidVersion, "sdk.androidVersion", /[0-9]+\.[0-9]+\.[0-9]+(?:[-.][A-Za-z0-9]+)*/, 'must match ^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-.][A-Za-z0-9]+)*$')
24
+ ext.supersdkVersionCode = (version.code as Number).intValue()
25
+ ext.supersdkAndroidVersion = requireString(sdk.androidVersion, "sdk.androidVersion")
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ spid=''
4
+ for arg in "$@"; do case "$arg" in --spid=*) spid="${arg#--spid=}";; esac; done
5
+ [ -n "$spid" ] || { echo 'build requires --spid=' >&2; exit 2; }
6
+ printf '%s' "$spid" | grep -Eq '^[a-z0-9]{8}$' || { echo 'spid must be 8 lowercase letters or digits' >&2; exit 2; }
7
+ ./gradlew -PsupersdkSpid="$spid" :app:assembleDebug
8
+ apk="app/build/outputs/apk/debug/app-debug.apk"
9
+ [ -f "$apk" ] || { echo "Android build did not produce $apk" >&2; exit 1; }
10
+ mkdir -p .supersdk/artifacts
11
+ cp "$apk" .supersdk/artifacts/app-debug.apk
@@ -6,7 +6,7 @@ settings:
6
6
  SWIFT_VERSION: "5.9"
7
7
  packages:
8
8
  SuperSDK:
9
- path: __SUPERSDK_MOCK_PACKAGE_PATH__
9
+ __SUPERSDK_PACKAGE_SOURCE__
10
10
  targets:
11
11
  SimpleApp:
12
12
  type: application
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ spid=''
4
+ for arg in "$@"; do case "$arg" in --spid=*) spid="${arg#--spid=}";; esac; done
5
+ [ -n "$spid" ] || { echo 'build requires --spid=' >&2; exit 2; }
6
+ printf '%s' "$spid" | grep -Eq '^[a-z0-9]{8}$' || { echo 'spid must be 8 lowercase letters or digits' >&2; exit 2; }
7
+ if ! command -v xcodebuild >/dev/null 2>&1; then
8
+ echo 'SKIP_XCODEBUILD_MISSING: install Xcode to build the iOS template' >&2
9
+ exit 1
10
+ fi
11
+ mkdir -p .supersdk/artifacts
12
+ if ! command -v xcodegen >/dev/null 2>&1; then
13
+ echo 'XCODEGEN_MISSING: install xcodegen to generate the iOS project' >&2
14
+ exit 1
15
+ fi
16
+ python3 scripts/render_project.py "$spid"
17
+ xcodegen generate --spec build/project.yml --project build/SimpleApp.xcodeproj
18
+ xcodebuild -project build/SimpleApp.xcodeproj -scheme SimpleApp -configuration Debug -derivedDataPath build build
19
+ tar -cf .supersdk/artifacts/ios-simulator-build.tar -C build .
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env python3
2
+ import json
3
+ import re
4
+ import sys
5
+ from pathlib import Path
6
+ from urllib.parse import urlparse
7
+
8
+ root = Path(__file__).resolve().parents[1]
9
+ spid = sys.argv[1]
10
+ if not re.fullmatch(r"[a-z0-9]{8}", spid):
11
+ raise SystemExit("spid must be 8 lowercase letters or digits")
12
+ identity = json.loads((root / "supersdk-default.config.json").read_text())
13
+ name = identity["name"]
14
+ bundle = identity["bundleId"]
15
+ version = identity["version"]
16
+ spm_mode = identity["spmMode"]
17
+ if spm_mode == "mock":
18
+ package_source = f'path: {json.dumps(str(root / "MockSuperSDKPackage"))}'
19
+ elif spm_mode == "real":
20
+ package_url = identity.get("iosPackageUrl")
21
+ package_version = identity.get("iosVersion")
22
+ parsed_url = urlparse(package_url) if isinstance(package_url, str) else None
23
+ package_host = (parsed_url.hostname or "").lower() if parsed_url else ""
24
+ if (
25
+ parsed_url is None
26
+ or parsed_url.scheme != "https"
27
+ or not package_host
28
+ or package_host == "localhost"
29
+ or package_host.endswith(".local")
30
+ or "example." in package_host
31
+ or parsed_url.path in ("", "/")
32
+ ):
33
+ raise SystemExit("spmMode real requires a non-placeholder HTTPS iosPackageUrl")
34
+ if not isinstance(package_version, str) or not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?", package_version):
35
+ raise SystemExit("spmMode real requires a semantic iosVersion")
36
+ package_source = f'url: {json.dumps(package_url)}\n from: {json.dumps(package_version)}'
37
+ else:
38
+ raise SystemExit("spmMode must be mock or real")
39
+ build = root / "build"
40
+ generated = build / "generated"
41
+ generated.mkdir(parents=True, exist_ok=True)
42
+ (generated / "SimpleConfig.swift").write_text(
43
+ f"import Foundation\nenum SimpleConfig {{ static let spid = {json.dumps(spid)} }}\n"
44
+ )
45
+ replacements = {
46
+ "__SUPERSDK_APP_SOURCES_PATH__": str(root / "Sources/App"),
47
+ "__SUPERSDK_SIMPLE_CONFIG_PATH__": str(generated / "SimpleConfig.swift"),
48
+ "__SUPERSDK_RESOURCES_PATH__": str(root / "Resources"),
49
+ "__SUPERSDK_BUNDLE_ID__": bundle,
50
+ "__SUPERSDK_VERSION_NAME__": str(version["name"]),
51
+ "__SUPERSDK_VERSION_CODE__": str(version["code"]),
52
+ "__SUPERSDK_INFOPLIST_PATH__": str(root / "Resources/Info.plist"),
53
+ "__SUPERSDK_DISPLAY_NAME__": name,
54
+ "__SUPERSDK_TEST_SOURCES_PATH__": str(root / "Tests/SimpleAppTests"),
55
+ }
56
+ template = (root / "project.yml").read_text()
57
+ template = template.replace("__SUPERSDK_PACKAGE_SOURCE__", package_source)
58
+ for token, value in replacements.items():
59
+ template = template.replace(token, json.dumps(value))
60
+ (build / "project.yml").write_text(template)
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "SuperSDK Simple",
3
+ "bundleId": "com.supersdk.simple",
4
+ "spmMode": "mock",
5
+ "version": {"name": "1.0.0", "code": 1}
6
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ spid=''
4
+ for arg in "$@"; do case "$arg" in --spid=*) spid="${arg#--spid=}";; esac; done
5
+ [ -n "$spid" ] || { echo 'build requires --spid=' >&2; exit 2; }
6
+ printf '%s' "$spid" | grep -Eq '^[a-z0-9]{8}$' || { echo 'spid must be 8 lowercase letters or digits' >&2; exit 2; }
7
+ command -v docker >/dev/null 2>&1 || { echo 'Docker is required for service builds' >&2; exit 1; }
8
+ mkdir -p .supersdk/artifacts
9
+ tag="super-local/${spid}:build"
10
+ docker build --platform linux/amd64 --file Dockerfile --tag "$tag" .
11
+ docker save --output .supersdk/artifacts/image.tar "$tag"
@@ -1,21 +1,23 @@
1
1
  {
2
- "schemaVersion": 4,
2
+ "schemaVersion": 5,
3
3
  "spid": "demo0001",
4
4
  "name": "SuperSDK Simple",
5
5
  "version": {
6
6
  "name": "1.0.0",
7
7
  "code": 1
8
8
  },
9
- "sdk": {
10
- "androidVersion": "1.0.0.57-SNAPSHOT"
11
- },
12
9
  "projects": [
13
10
  {
14
11
  "projectId": "android",
15
12
  "type": "android",
16
13
  "dir": "android",
17
14
  "name": "SuperSDK Simple",
18
- "package": "com.supersdk.simple.host"
15
+ "package": "com.supersdk.simple.host",
16
+ "build": {
17
+ "entry": "scripts/build.sh",
18
+ "args": ["--spid=${spid}"],
19
+ "artifacts": [{"id": "android-apk", "kind": "file", "path": ".supersdk/artifacts/app-debug.apk"}]
20
+ }
19
21
  },
20
22
  {
21
23
  "projectId": "ios",
@@ -23,7 +25,12 @@
23
25
  "dir": "ios",
24
26
  "name": "SuperSDK Simple",
25
27
  "bundleId": "com.supersdk.simple",
26
- "spmMode": "mock"
28
+ "spmMode": "mock",
29
+ "build": {
30
+ "entry": "scripts/build.sh",
31
+ "args": ["--spid=${spid}"],
32
+ "artifacts": [{"id": "ios-simulator-build", "kind": "file", "path": ".supersdk/artifacts/ios-simulator-build.tar"}]
33
+ }
27
34
  },
28
35
  {
29
36
  "projectId": "web",
@@ -31,10 +38,12 @@
31
38
  "dir": "web",
32
39
  "name": "SuperSDK Simple Web",
33
40
  "build": {
34
- "outputDir": "dist"
35
- },
36
- "offline": {
37
- "host": "simple.supersdk.com"
41
+ "entry": "scripts/build.sh",
42
+ "args": ["--spid=${spid}"],
43
+ "artifacts": [
44
+ {"id": "site-dist", "kind": "directory", "path": "dist"},
45
+ {"id": "site-offline-zip", "kind": "file", "path": ".supersdk/artifacts/site-offline.zip"}
46
+ ]
38
47
  }
39
48
  },
40
49
  {
@@ -43,10 +52,9 @@
43
52
  "dir": "service",
44
53
  "name": "SuperSDK Simple Service",
45
54
  "build": {
46
- "context": ".",
47
- "dockerfile": "Dockerfile",
48
- "platform": "linux/amd64",
49
- "argsFromEnv": []
55
+ "entry": "scripts/build.sh",
56
+ "args": ["--spid=${spid}"],
57
+ "artifacts": [{"id": "service-image", "kind": "docker-image-archive", "path": ".supersdk/artifacts/image.tar"}]
50
58
  },
51
59
  "deploy": []
52
60
  }
@@ -1,16 +1,12 @@
1
1
  {
2
- "engineVersion": "4.0.0",
3
- "schemaVersion": 4,
2
+ "schemaVersion": 5,
4
3
  "source": "app_repo_example",
5
4
  "comment": [
6
- "模板的拆分契约,给 supercli 消费:`init` 落地 workspace 级共享物一次,`add <type> <dir>` 拷贝对应类型的项目模板。",
7
- "workspace: 工作空间级共享物(super_build.sh 与 scripts/ 是所有项目共用的编排与引擎)。",
8
- "projects: 类型 -> app_repo_example 里该类型的项目模板目录。目标目录由用户在 `add` 时指定,不必与这里同名。",
5
+ "模板的拆分契约,给 supercli 消费:`init` 只落地 workspace README 与忽略文件,`add <type> <dir>` 拷贝对应类型的项目模板。",
6
+ "每个项目自带 scripts/build.sh,构建参数和产物声明位于 super.json 对应项目的 build 段;Web 的 package.json 与 scripts/web_package.py 也随项目模板复制。",
9
7
  "generated: 不是拷贝来的,而是 `supercli init` 按 spid 生成的。"
10
8
  ],
11
9
  "workspace": [
12
- "super_build.sh",
13
- "scripts",
14
10
  "README.md",
15
11
  ".gitignore"
16
12
  ],
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "supersdk-simple-web",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "supersdk": {
6
+ "offlineHost": "simple.supersdk.com"
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ spid=''
4
+ for arg in "$@"; do case "$arg" in --spid=*) spid="${arg#--spid=}";; esac; done
5
+ [ -n "$spid" ] || { echo 'build requires --spid=' >&2; exit 2; }
6
+ printf '%s' "$spid" | grep -Eq '^[a-z0-9]{8}$' || { echo 'spid must be 8 lowercase letters or digits' >&2; exit 2; }
7
+ SCRIPT_DIR="$(CDPATH= cd "$(dirname "$0")" && pwd)"
8
+ python3 "$SCRIPT_DIR/web_package.py" build --spid "$spid"