@supersdk/supercli 0.3.1 → 0.3.2-staging.44

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 (96) hide show
  1. package/dist/build/artifactIntegrity.js +119 -0
  2. package/dist/build/artifactIntegrity.js.map +1 -0
  3. package/dist/cli.js +22 -11
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/add.js +79 -31
  6. package/dist/commands/add.js.map +1 -1
  7. package/dist/commands/analytics.js +15 -9
  8. package/dist/commands/analytics.js.map +1 -1
  9. package/dist/commands/build.js +231 -0
  10. package/dist/commands/build.js.map +1 -0
  11. package/dist/commands/config.js +170 -0
  12. package/dist/commands/config.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 +68 -37
  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 +51 -30
  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 +40 -36
  32. package/dist/config/appConfig.js.map +1 -1
  33. package/dist/config/superConfig.js +429 -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 +381 -0
  38. package/dist/deploy/manifest.js.map +1 -0
  39. package/dist/deploy/preflight.js +202 -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 +299 -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 +63 -1
  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 +64 -227
  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/MainActivity.java +5 -5
  62. package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +5 -4
  63. package/dist/template/android/gradle/supersdk-config-reader.gradle +6 -5
  64. package/dist/template/android/supersdk-default.config.json +4 -3
  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/scripts/build_android.sh +26 -10
  68. package/dist/template/scripts/build_ios.sh +41 -9
  69. package/dist/template/scripts/build_service.sh +89 -0
  70. package/dist/template/scripts/build_site.sh +40 -26
  71. package/dist/template/scripts/lib/workspace.sh +4 -4
  72. package/dist/template/scripts/serve_web.py +2 -4
  73. package/dist/template/scripts/super_build_orchestrator.py +278 -355
  74. package/dist/template/scripts/supersdk_template.py +415 -182
  75. package/dist/template/scripts/web_package.py +9 -8
  76. package/dist/template/service/Dockerfile +2 -0
  77. package/dist/template/{supersdk.json → super.json} +21 -2
  78. package/dist/template/super_build.sh +39 -113
  79. package/dist/template/template_manifest.json +5 -4
  80. package/dist/template/web/src/js/supersdk.js +1 -1
  81. package/dist/template/web/src/js/supersdk.provenance.json +3 -3
  82. package/dist/workspace/config.js +81 -119
  83. package/dist/workspace/config.js.map +1 -1
  84. package/dist/workspace/identity.js +15 -14
  85. package/dist/workspace/identity.js.map +1 -1
  86. package/dist/workspace/inspect.js +1 -0
  87. package/dist/workspace/inspect.js.map +1 -1
  88. package/dist/workspace/projectContext.js +93 -0
  89. package/dist/workspace/projectContext.js.map +1 -0
  90. package/dist/workspace/projectIdentity.js +53 -96
  91. package/dist/workspace/projectIdentity.js.map +1 -1
  92. package/dist/workspace/template.js +5 -8
  93. package/dist/workspace/template.js.map +1 -1
  94. package/package.json +2 -2
  95. package/dist/publish/siteConfig.js +0 -649
  96. package/dist/publish/siteConfig.js.map +0 -1
@@ -19,7 +19,7 @@ EXCLUDED_ASSETS = {"__super_meta.json", ".DS_Store", "js/supersdk.provenance.jso
19
19
  HEX64 = set("0123456789abcdef")
20
20
  VERSION_PATTERN = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
21
21
  INTEGRITY_PATTERN = re.compile(r"^sha512-[A-Za-z0-9+/]+={0,2}$")
22
- CONFIG_FILENAME = "supersdk.json"
22
+ CONFIG_FILENAME = "super.json"
23
23
 
24
24
  # `<project>/src` is authored input; `<project>/dist` is the single publishable build
25
25
  # output. It is what the offline zip is built from AND what `supercli publish-site <dir>`
@@ -153,7 +153,7 @@ def zip_staging(staging, output_dir, host, version):
153
153
  temp_zip.unlink()
154
154
 
155
155
 
156
- def build_dist(project_root, managed_config):
156
+ def build_dist(project_root, managed_config, output_dir=DIST_DIRNAME):
157
157
  """Render <project>/src + the managed config into the publishable <project>/dist.
158
158
 
159
159
  Built in a sibling temp dir and swapped in, so a failed build never leaves a
@@ -165,7 +165,7 @@ def build_dist(project_root, managed_config):
165
165
  """
166
166
  project_root = Path(project_root)
167
167
  source_root = validate_source(project_root / SRC_DIRNAME)
168
- dist = project_root / DIST_DIRNAME
168
+ dist = project_root / output_dir
169
169
  dist.parent.mkdir(parents=True, exist_ok=True)
170
170
  staging_parent = Path(tempfile.mkdtemp(prefix=".supersdk-web-dist-", dir=dist.parent))
171
171
  staging = staging_parent / DIST_DIRNAME
@@ -214,8 +214,8 @@ def package_managed(root, project):
214
214
  config_path = project_root / ".supersdk" / "managed" / "config.json"
215
215
  if not config_path.is_file():
216
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"
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
219
  )
220
220
  try:
221
221
  config = json.loads(config_path.read_text(encoding="utf-8"))
@@ -230,6 +230,7 @@ def package_managed(root, project):
230
230
  raise WebPackageError("site managed config invalid")
231
231
 
232
232
  host = platform_config.get("host")
233
+ output_dir = platform_config.get("outputDir", DIST_DIRNAME)
233
234
  # 🔴 offline.host 是可选的、由服务端回填的:首次发布成功后 CLI 才把服务端签发的域名
234
235
  # 记回配置。CLI 绝不自己拼域名,所以没有它就**跳过离线打包并显式说明原因** ——
235
236
  # dist 照常产出(publish-site 要的就是它),静默跳过才是不可接受的那一种。
@@ -237,10 +238,10 @@ def package_managed(root, project):
237
238
  # host 缺席不代表可以少校验:版本号照样要合法,dist 照样要产出。
238
239
  validate_version(version.get("name"))
239
240
  validate_source(project_root / SRC_DIRNAME)
240
- dist = build_dist(project_root, config)
241
+ dist = build_dist(project_root, config, output_dir)
241
242
  reason = (
242
243
  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
+ "Set projects[].offline.host in super.json when an offline package is required."
244
245
  )
245
246
  print(reason, file=sys.stderr)
246
247
  return {"host": None, "version": version.get("name"), "zip": None, "dist": str(dist), "offline_skipped": reason}
@@ -249,7 +250,7 @@ def package_managed(root, project):
249
250
  # Validate host/version/source before anything is written, so a bad host cannot
250
251
  # leave a stale or partly-rendered dist on disk.
251
252
  validate_inputs(project_root / SRC_DIRNAME, host, version.get("name"))
252
- dist = build_dist(project_root, config)
253
+ dist = build_dist(project_root, config, output_dir)
253
254
  # 🔴 output/ 是工作空间级的,但同名 zip 会被 unlink 后 replace:两个站点
254
255
  # 同 host + 同 version 就会互相顶掉。按项目目录分仓,冲突从根上消失。
255
256
  result = package(dist, host, version.get("name"), workspace_root / "output" / project, require_provenance=False)
@@ -0,0 +1,2 @@
1
+ FROM scratch
2
+ LABEL org.opencontainers.image.title="supersdk-simple-service"
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": 3,
2
+ "schemaVersion": 4,
3
3
  "spid": "demo0001",
4
4
  "name": "SuperSDK Simple",
5
5
  "version": {
@@ -7,16 +7,18 @@
7
7
  "code": 1
8
8
  },
9
9
  "sdk": {
10
- "androidVersion": "1.0.0.54-SNAPSHOT"
10
+ "androidVersion": "1.0.0.57-SNAPSHOT"
11
11
  },
12
12
  "projects": [
13
13
  {
14
+ "projectId": "android",
14
15
  "type": "android",
15
16
  "dir": "android",
16
17
  "name": "SuperSDK Simple",
17
18
  "package": "com.supersdk.simple.host"
18
19
  },
19
20
  {
21
+ "projectId": "ios",
20
22
  "type": "ios",
21
23
  "dir": "ios",
22
24
  "name": "SuperSDK Simple",
@@ -24,12 +26,29 @@
24
26
  "spmMode": "mock"
25
27
  },
26
28
  {
29
+ "projectId": "web",
27
30
  "type": "site",
28
31
  "dir": "web",
29
32
  "name": "SuperSDK Simple Web",
33
+ "build": {
34
+ "outputDir": "dist"
35
+ },
30
36
  "offline": {
31
37
  "host": "simple.supersdk.com"
32
38
  }
39
+ },
40
+ {
41
+ "projectId": "service",
42
+ "type": "service",
43
+ "dir": "service",
44
+ "name": "SuperSDK Simple Service",
45
+ "build": {
46
+ "context": ".",
47
+ "dockerfile": "Dockerfile",
48
+ "platform": "linux/amd64",
49
+ "argsFromEnv": []
50
+ },
51
+ "deploy": []
33
52
  }
34
53
  ]
35
54
  }
@@ -11,134 +11,60 @@ ORCHESTRATOR="$WORKSPACE_ROOT/scripts/super_build_orchestrator.py"
11
11
 
12
12
  usage() {
13
13
  cat <<'EOF'
14
- Usage: ./super_build.sh [--platform all|android|ios|site] [--project DIR] [--plan|--build] [--force] [--config path]
14
+ Usage: ./super_build.sh [--build|--plan] [--config PATH] [--project PROJECT_ID] [--output-dir DIR] [--cli-version VERSION]
15
15
 
16
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.
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
24
  EOF
25
25
  }
26
26
 
27
- platform="all"
28
- project=""
29
- config="$WORKSPACE_ROOT/supersdk.json"
30
27
  mode="plan"
28
+ config="$WORKSPACE_ROOT/super.json"
29
+ project=""
30
+ output_dir="$WORKSPACE_ROOT/output"
31
+ cli_version=""
31
32
  mode_set=false
32
- platform_set=false
33
- project_set=false
34
33
  config_set=false
35
- force_set=false
36
- force=false
34
+ project_set=false
35
+ output_set=false
36
+ cli_version_set=false
37
37
 
38
38
  while [ "$#" -gt 0 ]; do
39
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
- ;;
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 ;;
70
44
  --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
- ;;
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 ;;
114
57
  esac
115
58
  done
116
59
 
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
60
  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)
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"
141
65
  fi
142
- "$PYTHON_BIN" "$HELPER" "${inject_args[@]}"
143
66
 
144
- exec "$PYTHON_BIN" "$ORCHESTRATOR" --root "$WORKSPACE_ROOT" --config "$config" "${selection[@]}"
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[@]}"
@@ -1,6 +1,6 @@
1
1
  {
2
- "engineVersion": "3.0.0",
3
- "schemaVersion": 3,
2
+ "engineVersion": "4.0.0",
3
+ "schemaVersion": 4,
4
4
  "source": "app_repo_example",
5
5
  "comment": [
6
6
  "模板的拆分契约,给 supercli 消费:`init` 落地 workspace 级共享物一次,`add <type> <dir>` 拷贝对应类型的项目模板。",
@@ -17,9 +17,10 @@
17
17
  "projects": {
18
18
  "android": "android",
19
19
  "ios": "ios",
20
- "site": "web"
20
+ "site": "web",
21
+ "service": "service"
21
22
  },
22
23
  "generated": [
23
- "supersdk.json"
24
+ "super.json"
24
25
  ]
25
26
  }