@supersdk/supercli 0.1.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/consoleClient.js +132 -0
- package/dist/api/consoleClient.js.map +1 -0
- package/dist/auth/browserAuth.js +163 -0
- package/dist/auth/browserAuth.js.map +1 -0
- package/dist/auth/refresh.js +32 -0
- package/dist/auth/refresh.js.map +1 -0
- package/dist/cli.js +46 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/accounts.js +46 -0
- package/dist/commands/accounts.js.map +1 -0
- package/dist/commands/createApp.js +225 -0
- package/dist/commands/createApp.js.map +1 -0
- package/dist/commands/login.js +54 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.js +99 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/publishSite.js +361 -0
- package/dist/commands/publishSite.js.map +1 -0
- package/dist/commands/switchaccount.js +35 -0
- package/dist/commands/switchaccount.js.map +1 -0
- package/dist/commands/update.js +95 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/config/environments.js +53 -0
- package/dist/config/environments.js.map +1 -0
- package/dist/createApp/copyTemplate.js +237 -0
- package/dist/createApp/copyTemplate.js.map +1 -0
- package/dist/publish/orgResolve.js +30 -0
- package/dist/publish/orgResolve.js.map +1 -0
- package/dist/publish/responseClassifier.js +111 -0
- package/dist/publish/responseClassifier.js.map +1 -0
- package/dist/publish/siteClient.js +113 -0
- package/dist/publish/siteClient.js.map +1 -0
- package/dist/publish/siteConfig.js +190 -0
- package/dist/publish/siteConfig.js.map +1 -0
- package/dist/publish/siteZip.js +172 -0
- package/dist/publish/siteZip.js.map +1 -0
- package/dist/store/accountStore.js +236 -0
- package/dist/store/accountStore.js.map +1 -0
- package/dist/store/backends/encryptedFile.js +162 -0
- package/dist/store/backends/encryptedFile.js.map +1 -0
- package/dist/store/backends/osKeyring.js +283 -0
- package/dist/store/backends/osKeyring.js.map +1 -0
- package/dist/store/credentialStore.js +65 -0
- package/dist/store/credentialStore.js.map +1 -0
- package/dist/template/README.md +144 -0
- package/dist/template/android/.gitkeep +1 -0
- package/dist/template/android/app/build.gradle.kts +122 -0
- package/dist/template/android/app/src/main/AndroidManifest.xml +19 -0
- package/dist/template/android/app/src/main/java/com/supersdk/simple/MainActivity.java +17 -0
- package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +22 -0
- package/dist/template/android/app/src/test/java/com/supersdk/simple/AppNameResourceTest.java +19 -0
- package/dist/template/android/build.gradle.kts +3 -0
- package/dist/template/android/gradle/supersdk-config-reader.gradle +61 -0
- package/dist/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/dist/template/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/dist/template/android/gradle.properties +3 -0
- package/dist/template/android/gradlew +251 -0
- package/dist/template/android/settings.gradle.kts +25 -0
- package/dist/template/android/supersdk-default.config.json +17 -0
- package/dist/template/ios/MockSuperSDKPackage/Package.swift +15 -0
- package/dist/template/ios/MockSuperSDKPackage/Sources/SuperSDK/SuperSDK.swift +25 -0
- package/dist/template/ios/Resources/Info.plist +43 -0
- package/dist/template/ios/Sources/App/AppDelegate.swift +20 -0
- package/dist/template/ios/Sources/App/SceneDelegate.swift +14 -0
- package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +7 -0
- package/dist/template/ios/Sources/App/SimpleSDKProbe.swift +26 -0
- package/dist/template/ios/Sources/App/SimpleSDKProvider.swift +4 -0
- package/dist/template/ios/Sources/App/SimpleViewController.swift +20 -0
- package/dist/template/ios/Tests/SimpleAppTests/SimpleSDKInitializationTests.swift +17 -0
- package/dist/template/ios/project.yml +67 -0
- package/dist/template/scripts/android_snapshot_canary.py +136 -0
- package/dist/template/scripts/build_android.sh +240 -0
- package/dist/template/scripts/build_ios.sh +261 -0
- package/dist/template/scripts/build_web.sh +12 -0
- package/dist/template/scripts/serve_web.py +51 -0
- package/dist/template/scripts/super_build_orchestrator.py +400 -0
- package/dist/template/scripts/supersdk_template.py +611 -0
- package/dist/template/scripts/web_host_validator.py +103 -0
- package/dist/template/scripts/web_package.py +202 -0
- package/dist/template/scripts/ws03_shared_schema_merge_guard.py +73 -0
- package/dist/template/super_build.sh +116 -0
- package/dist/template/supersdk.yaml +15 -0
- package/dist/template/web/src/css/style.css +83 -0
- package/dist/template/web/src/index.html +37 -0
- package/dist/template/web/src/js/app.js +99 -0
- package/dist/template/web/src/js/supersdk.js +1848 -0
- package/dist/template/web/src/js/supersdk.provenance.json +6 -0
- package/dist/update/channelResolver.js +183 -0
- package/dist/update/channelResolver.js.map +1 -0
- package/dist/update/installSafety.js +135 -0
- package/dist/update/installSafety.js.map +1 -0
- package/dist/util/fsAtomic.js +294 -0
- package/dist/util/fsAtomic.js.map +1 -0
- package/dist/util/log.js +55 -0
- package/dist/util/log.js.map +1 -0
- package/dist/util/origin.js +66 -0
- package/dist/util/origin.js.map +1 -0
- package/dist/util/prompt.js +113 -0
- package/dist/util/prompt.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# SuperSDK Simple App Template
|
|
2
|
+
|
|
3
|
+
This directory is the copy-ready `app_repo_example` template scaffold for
|
|
4
|
+
Android, iOS, and Web hosts. Edit one root `supersdk.yaml`, run plan or build
|
|
5
|
+
from this directory, and use the root ordered summary to inspect platform
|
|
6
|
+
results.
|
|
7
|
+
|
|
8
|
+
Platform status: BL-002 provides the Android Maven host, BL-003 provides the iOS
|
|
9
|
+
SPM/mock host, BL-004 provides the Web/JSSDK host, and BL-005 connects them
|
|
10
|
+
through the root build orchestration described below.
|
|
11
|
+
|
|
12
|
+
## Maintainer Flow
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
./super_build.sh --plan
|
|
16
|
+
./super_build.sh --build
|
|
17
|
+
./super_build.sh --platform web --build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
No arguments are equivalent to `./super_build.sh --plan`. Plan mode validates
|
|
21
|
+
`supersdk.yaml` and prints Android -> iOS -> Web helper order without invoking
|
|
22
|
+
platform build helpers or emitting `SUPERSDK_BUILD_SUMMARY_JSON=`.
|
|
23
|
+
|
|
24
|
+
Build mode validates and injects managed config first, then runs selected
|
|
25
|
+
platform helpers in order. The default `./super_build.sh --build` selects
|
|
26
|
+
Android, iOS, and Web. `--platform android|ios|web --build` injects and runs
|
|
27
|
+
only that platform; non-selected platform managed config is not created or
|
|
28
|
+
rewritten.
|
|
29
|
+
|
|
30
|
+
## Configuration Checklist
|
|
31
|
+
|
|
32
|
+
- Edit `supersdk.yaml`.
|
|
33
|
+
- Keep `schema_version: 1`.
|
|
34
|
+
- Set `app_id` and `name`.
|
|
35
|
+
- Set `android.package` for Android builds.
|
|
36
|
+
- Set `ios.bundleId` when a specific bundle identifier is needed; default
|
|
37
|
+
`ios.spmMode: mock` uses the bundled `ios/MockSuperSDKPackage`.
|
|
38
|
+
- Set `web.host` for Web packaging.
|
|
39
|
+
- Run `./super_build.sh --plan`.
|
|
40
|
+
- Run `./super_build.sh --build` or a single-platform build.
|
|
41
|
+
|
|
42
|
+
Generated files live under each platform `.supersdk/managed/` directory and
|
|
43
|
+
are safe to overwrite only when they contain `managed_by: supersdk-template`.
|
|
44
|
+
Use `--force` only when intentionally replacing unmanaged target files.
|
|
45
|
+
|
|
46
|
+
## Ordered Summary
|
|
47
|
+
|
|
48
|
+
Build mode writes exactly one root-owned machine-readable stdout line:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
SUPERSDK_BUILD_SUMMARY_JSON={"schema_version":1,...}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Consumers must parse only lines that start with `SUPERSDK_BUILD_SUMMARY_JSON=`.
|
|
55
|
+
Helper output is forwarded with prefixes such as `[android stderr]`, so helper
|
|
56
|
+
logs cannot create another root summary token. Do not assume the summary is the
|
|
57
|
+
last stdout line: a helper process with a lingering output pipe may still emit a
|
|
58
|
+
late prefixed line after the summary. Locate the summary by its line prefix.
|
|
59
|
+
|
|
60
|
+
Summary fields are:
|
|
61
|
+
|
|
62
|
+
- `schema_version`
|
|
63
|
+
- `overall_status`
|
|
64
|
+
- `overall_exit_code`
|
|
65
|
+
- `platforms`
|
|
66
|
+
- `platform`
|
|
67
|
+
- `status`
|
|
68
|
+
- `exit_code`
|
|
69
|
+
- `reason`
|
|
70
|
+
- `command`
|
|
71
|
+
|
|
72
|
+
Platform `status` is `success`, `skipped`, or `failed`. `status=success` means
|
|
73
|
+
the helper exited successfully under the helper contract; artifact-level validation
|
|
74
|
+
is performed by canonical smoke. Long failure reasons are capped and end with
|
|
75
|
+
`...(truncated)` when shortened. Per-platform `exit_code` mirrors the helper
|
|
76
|
+
process return code; a negative value means the helper was killed by that signal
|
|
77
|
+
number. Launch errors use synthesized `exit_code=127`; helper timeouts use
|
|
78
|
+
synthesized `exit_code=124`. In both cases, `reason` identifies the sentinel.
|
|
79
|
+
|
|
80
|
+
## Exit Codes
|
|
81
|
+
|
|
82
|
+
- `0`: usage/config/injection succeeded and no selected platform failed.
|
|
83
|
+
- `1` with no summary: config validation or managed-config injection failed
|
|
84
|
+
before platform orchestration started.
|
|
85
|
+
- `1` with a summary: at least one selected platform had a hard failure after
|
|
86
|
+
platform orchestration started.
|
|
87
|
+
- `2` with no summary: usage or argument error, such as an invalid platform.
|
|
88
|
+
|
|
89
|
+
This distinction lets downstream scripts tell a config error from a build
|
|
90
|
+
result by checking for the root summary line. If stdout itself is closed or
|
|
91
|
+
broken by the caller before the root summary can be written, summary emission is
|
|
92
|
+
outside this contract.
|
|
93
|
+
|
|
94
|
+
## Skip And Hard Failure
|
|
95
|
+
|
|
96
|
+
Android and iOS helpers may report toolchain, simulator, or temporary network
|
|
97
|
+
conditions as `skipped` when they exit 0 and a raw stdout/stderr line starts
|
|
98
|
+
with `SKIP_` or `BUILD SKIPPED`. Matching is case-sensitive and does not trim
|
|
99
|
+
leading whitespace. A nonzero helper exit code always wins and is a hard
|
|
100
|
+
failure. Web has no skip mode: it is `success` or `failed`.
|
|
101
|
+
|
|
102
|
+
The root build continues through all selected platforms after a hard helper
|
|
103
|
+
failure, then returns nonzero with every selected platform represented in the
|
|
104
|
+
ordered summary. An internal orchestrator error still emits a failed summary, but
|
|
105
|
+
may stop at the affected platform because the runner itself is no longer in a
|
|
106
|
+
trustworthy state.
|
|
107
|
+
|
|
108
|
+
## Platform Prerequisites
|
|
109
|
+
|
|
110
|
+
- Android: executable `android/gradlew`, `android/gradle/wrapper/gradle-wrapper.jar`,
|
|
111
|
+
JDK 17+, Android SDK, and reachable Maven metadata unless deterministic test
|
|
112
|
+
mode or local metadata fixtures are used.
|
|
113
|
+
- iOS: `ios/project.yml`, bundled `ios/MockSuperSDKPackage`, `xcodegen`,
|
|
114
|
+
`xcodebuild`, and an available simulator for a full local build. Missing
|
|
115
|
+
local toolchain is reported as an explicit skip unless a non-skippable CI gate
|
|
116
|
+
is requested.
|
|
117
|
+
- Web: bundled static assets `index.html`, `js/app.js`, `js/supersdk.js`,
|
|
118
|
+
`css/style.css`, and `js/supersdk.provenance.json`. Web packaging uses the
|
|
119
|
+
Python stdlib zip path and does not require Node/Vite.
|
|
120
|
+
|
|
121
|
+
Maintainers can set `SUPERSDK_BUILD_HELPER_TIMEOUT_SECONDS` to adjust the
|
|
122
|
+
per-helper timeout for CI or smoke troubleshooting. The default is 1800 seconds.
|
|
123
|
+
|
|
124
|
+
## Canonical Smoke
|
|
125
|
+
|
|
126
|
+
From the repository root, run:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python3 supersimples/tests/e2e/build_orchestration_smoke.py
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The canonical smoke copies this template to a temporary directory outside the
|
|
133
|
+
monorepo, edits `supersdk.yaml`, verifies platform entry assets, pins Android
|
|
134
|
+
SNAPSHOT metadata to a local fixture, forces Android deterministic test mode,
|
|
135
|
+
forces deterministic iOS `SKIP_XCODEGEN_MISSING`, runs the root build, checks
|
|
136
|
+
the ordered summary, checks all three managed configs, verifies a real Web zip
|
|
137
|
+
containing `index.html`, `js/app.js`, and `__super_meta.json`, and rejects
|
|
138
|
+
monorepo-only path/module leaks in generated outputs and copied Android/iOS
|
|
139
|
+
build config files. Android and iOS are deterministic non-real-build paths in
|
|
140
|
+
this smoke; Web packaging is the real platform build. Use a separate toolchain
|
|
141
|
+
CI lane when you need real Android Gradle or iOS simulator compilation.
|
|
142
|
+
|
|
143
|
+
Publishing this template to the public `supersdks/simple` repository is BL-006,
|
|
144
|
+
not part of this feature.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import org.gradle.api.DefaultTask
|
|
2
|
+
import org.gradle.api.file.DirectoryProperty
|
|
3
|
+
import org.gradle.api.provider.Property
|
|
4
|
+
import org.gradle.api.tasks.Input
|
|
5
|
+
import org.gradle.api.tasks.OutputDirectory
|
|
6
|
+
import org.gradle.api.tasks.TaskAction
|
|
7
|
+
|
|
8
|
+
plugins {
|
|
9
|
+
id("com.android.application")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply(from = "../gradle/supersdk-config-reader.gradle")
|
|
13
|
+
|
|
14
|
+
val supersdkAppId = extra["supersdkAppId"] as String
|
|
15
|
+
val supersdkAppName = extra["supersdkAppName"] as String
|
|
16
|
+
val supersdkApplicationId = extra["supersdkApplicationId"] as String
|
|
17
|
+
val supersdkVersionName = extra["supersdkVersionName"] as String
|
|
18
|
+
val supersdkVersionCode = extra["supersdkVersionCode"] as Int
|
|
19
|
+
val supersdkAndroidVersion = extra["supersdkAndroidVersion"] as String
|
|
20
|
+
|
|
21
|
+
abstract class GenerateSuperSdkAppNameTask : DefaultTask() {
|
|
22
|
+
@get:Input
|
|
23
|
+
abstract val appName: Property<String>
|
|
24
|
+
|
|
25
|
+
@get:OutputDirectory
|
|
26
|
+
abstract val outputDir: DirectoryProperty
|
|
27
|
+
|
|
28
|
+
@TaskAction
|
|
29
|
+
fun generate() {
|
|
30
|
+
val valuesDir = outputDir.dir("values").get().asFile
|
|
31
|
+
valuesDir.mkdirs()
|
|
32
|
+
valuesDir.resolve("supersdk_app_name.xml").writeText(
|
|
33
|
+
"""
|
|
34
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
35
|
+
<resources>
|
|
36
|
+
<string name="app_name" formatted="false">${escapeAndroidString(appName.get())}</string>
|
|
37
|
+
</resources>
|
|
38
|
+
""".trimIndent() + "\n",
|
|
39
|
+
Charsets.UTF_8,
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private fun escapeAndroidString(value: String): String {
|
|
44
|
+
return value
|
|
45
|
+
.replace("\\", "\\\\")
|
|
46
|
+
.replace("&", "&")
|
|
47
|
+
.replace("<", "<")
|
|
48
|
+
.replace(">", ">")
|
|
49
|
+
.replace("\"", "\\"")
|
|
50
|
+
.replace("'", "\\'")
|
|
51
|
+
.let { if (it.startsWith("@") || it.startsWith("?")) "\\$it" else it }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fun quotedJavaString(value: String): String {
|
|
56
|
+
return "\"" + value
|
|
57
|
+
.replace("\\", "\\\\")
|
|
58
|
+
.replace("\"", "\\\"")
|
|
59
|
+
.replace("\n", "\\n")
|
|
60
|
+
.replace("\r", "\\r") + "\""
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
android {
|
|
64
|
+
namespace = "com.supersdk.simple"
|
|
65
|
+
compileSdk = 36
|
|
66
|
+
|
|
67
|
+
defaultConfig {
|
|
68
|
+
applicationId = supersdkApplicationId
|
|
69
|
+
minSdk = 23
|
|
70
|
+
targetSdk = 36
|
|
71
|
+
versionCode = supersdkVersionCode
|
|
72
|
+
versionName = supersdkVersionName
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
buildFeatures {
|
|
76
|
+
buildConfig = true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
buildTypes {
|
|
80
|
+
debug {
|
|
81
|
+
buildConfigField("String", "SUPERSDK_APP_ID", quotedJavaString(supersdkAppId))
|
|
82
|
+
buildConfigField("String", "SUPERSDK_APP_NAME", quotedJavaString(supersdkAppName))
|
|
83
|
+
}
|
|
84
|
+
release {
|
|
85
|
+
buildConfigField("String", "SUPERSDK_APP_ID", quotedJavaString(supersdkAppId))
|
|
86
|
+
buildConfigField("String", "SUPERSDK_APP_NAME", quotedJavaString(supersdkAppName))
|
|
87
|
+
isMinifyEnabled = false
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
compileOptions {
|
|
92
|
+
sourceCompatibility = JavaVersion.VERSION_17
|
|
93
|
+
targetCompatibility = JavaVersion.VERSION_17
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
testOptions {
|
|
97
|
+
unitTests.isIncludeAndroidResources = true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
androidComponents {
|
|
102
|
+
onVariants(selector().all()) { variant ->
|
|
103
|
+
val variantName = variant.name.replaceFirstChar { it.uppercase() }
|
|
104
|
+
val taskProvider = tasks.register<GenerateSuperSdkAppNameTask>("generate${variantName}SuperSdkAppName") {
|
|
105
|
+
appName.set(supersdkAppName)
|
|
106
|
+
outputDir.set(layout.buildDirectory.dir("generated/res/supersdk/${variant.name}"))
|
|
107
|
+
}
|
|
108
|
+
variant.sources.res?.addGeneratedSourceDirectory(taskProvider) { it.outputDir }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
configurations.configureEach {
|
|
113
|
+
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
|
|
114
|
+
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
dependencies {
|
|
118
|
+
implementation("com.supersdk:supersdk:$supersdkAndroidVersion")
|
|
119
|
+
|
|
120
|
+
testImplementation("junit:junit:4.13.2")
|
|
121
|
+
testImplementation("org.robolectric:robolectric:4.13")
|
|
122
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
3
|
+
|
|
4
|
+
<application
|
|
5
|
+
android:name="com.supersdk.simple.SimpleApplication"
|
|
6
|
+
android:allowBackup="false"
|
|
7
|
+
android:label="@string/app_name"
|
|
8
|
+
android:supportsRtl="true"
|
|
9
|
+
android:theme="@android:style/Theme.Material.Light.NoActionBar">
|
|
10
|
+
<activity
|
|
11
|
+
android:name="com.supersdk.simple.MainActivity"
|
|
12
|
+
android:exported="true">
|
|
13
|
+
<intent-filter>
|
|
14
|
+
<action android:name="android.intent.action.MAIN" />
|
|
15
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
|
16
|
+
</intent-filter>
|
|
17
|
+
</activity>
|
|
18
|
+
</application>
|
|
19
|
+
</manifest>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.supersdk.simple;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.os.Bundle;
|
|
5
|
+
import android.view.Gravity;
|
|
6
|
+
import android.widget.TextView;
|
|
7
|
+
|
|
8
|
+
public class MainActivity extends Activity {
|
|
9
|
+
@Override
|
|
10
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
11
|
+
super.onCreate(savedInstanceState);
|
|
12
|
+
TextView view = new TextView(this);
|
|
13
|
+
view.setGravity(Gravity.CENTER);
|
|
14
|
+
view.setText(R.string.app_name);
|
|
15
|
+
setContentView(view);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.supersdk.simple;
|
|
2
|
+
|
|
3
|
+
import android.app.Application;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.supersdk.SuperSDK;
|
|
7
|
+
import com.supersdk.api.SuperSDKProvider;
|
|
8
|
+
|
|
9
|
+
public class SimpleApplication extends Application {
|
|
10
|
+
private static final String TAG = "SimpleApplication";
|
|
11
|
+
|
|
12
|
+
@Override
|
|
13
|
+
public void onCreate() {
|
|
14
|
+
super.onCreate();
|
|
15
|
+
try {
|
|
16
|
+
SuperSDK.init(this, BuildConfig.SUPERSDK_APP_ID, new SuperSDKProvider() {});
|
|
17
|
+
} catch (RuntimeException exception) {
|
|
18
|
+
Log.e(TAG, "SuperSDK init failed; check supersdk.yaml and the resolved SDK dependency.", exception);
|
|
19
|
+
throw exception;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.supersdk.simple;
|
|
2
|
+
|
|
3
|
+
import static org.junit.Assert.assertEquals;
|
|
4
|
+
|
|
5
|
+
import org.junit.Test;
|
|
6
|
+
import org.junit.runner.RunWith;
|
|
7
|
+
import org.robolectric.RobolectricTestRunner;
|
|
8
|
+
import org.robolectric.RuntimeEnvironment;
|
|
9
|
+
import org.robolectric.annotation.Config;
|
|
10
|
+
|
|
11
|
+
@RunWith(RobolectricTestRunner.class)
|
|
12
|
+
@Config(sdk = 34, application = android.app.Application.class)
|
|
13
|
+
public class AppNameResourceTest {
|
|
14
|
+
@Test
|
|
15
|
+
public void appNameResourceDecodesManagedName() {
|
|
16
|
+
String appName = RuntimeEnvironment.getApplication().getString(R.string.app_name);
|
|
17
|
+
assertEquals(BuildConfig.SUPERSDK_APP_NAME, appName);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
|
|
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
|
+
if (!configFile.isFile()) {
|
|
9
|
+
throw new GradleException("SuperSDK Android config not found: ${managedConfig} or ${defaultConfig}")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def config
|
|
13
|
+
try {
|
|
14
|
+
config = new JsonSlurper().parse(configFile)
|
|
15
|
+
} catch (Exception exc) {
|
|
16
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: ${exc.message}", exc)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def requireString = { value, name ->
|
|
20
|
+
if (!(value instanceof String) || value.trim().isEmpty()) {
|
|
21
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: ${name} must be a non-empty string")
|
|
22
|
+
}
|
|
23
|
+
value
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def requireMatchingString = { value, name, pattern, message ->
|
|
27
|
+
def result = requireString(value, name)
|
|
28
|
+
if (!(result ==~ pattern)) {
|
|
29
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: ${name} ${message}")
|
|
30
|
+
}
|
|
31
|
+
result
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def version = config.version instanceof Map ? config.version : [:]
|
|
35
|
+
def platformConfig = config.platform_config instanceof Map ? config.platform_config : [:]
|
|
36
|
+
def sdk = config.sdk instanceof Map ? config.sdk : [:]
|
|
37
|
+
if (config.managed_by != "supersdk-template") {
|
|
38
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: managed_by must be supersdk-template")
|
|
39
|
+
}
|
|
40
|
+
if (config.schema_version != 2) {
|
|
41
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: schema_version must be 2")
|
|
42
|
+
}
|
|
43
|
+
def versionCodeValue = version.code
|
|
44
|
+
if (!(versionCodeValue instanceof Number)) {
|
|
45
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: version.code must be a positive 32-bit integer")
|
|
46
|
+
}
|
|
47
|
+
def versionCodeDecimal = new BigDecimal(versionCodeValue.toString())
|
|
48
|
+
if (versionCodeDecimal.scale() > 0 || versionCodeDecimal < BigDecimal.ONE || versionCodeDecimal > new BigDecimal("2147483647")) {
|
|
49
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: version.code must be a positive 32-bit integer")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ext.supersdkAndroidConfigPath = configFile.absolutePath
|
|
53
|
+
ext.supersdkAppId = requireMatchingString(config.app_id, "app_id", /[A-Za-z][A-Za-z0-9_-]{2,63}/, 'must match ^[A-Za-z][A-Za-z0-9_-]{2,63}$')
|
|
54
|
+
ext.supersdkAppName = requireString(config.name, "name")
|
|
55
|
+
if ((ext.supersdkAppName =~ /[\x00-\x1F]/).find() || ext.supersdkAppName != ext.supersdkAppName.trim()) {
|
|
56
|
+
throw new GradleException("SuperSDK Android config invalid at ${configFile}: name must be a non-empty Android app label without control characters or edge whitespace")
|
|
57
|
+
}
|
|
58
|
+
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")
|
|
59
|
+
ext.supersdkVersionName = requireString(version.name, "version.name")
|
|
60
|
+
ext.supersdkVersionCode = versionCodeDecimal.intValueExact()
|
|
61
|
+
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]+)*$')
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
distributionBase=GRADLE_USER_HOME
|
|
2
|
+
distributionPath=wrapper/dists
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
|
4
|
+
distributionSha256Sum=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78
|
|
5
|
+
networkTimeout=10000
|
|
6
|
+
validateDistributionUrl=true
|
|
7
|
+
zipStoreBase=GRADLE_USER_HOME
|
|
8
|
+
zipStorePath=wrapper/dists
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Copyright © 2015 the original authors.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
##############################################################################
|
|
22
|
+
#
|
|
23
|
+
# Gradle start up script for POSIX generated by Gradle.
|
|
24
|
+
#
|
|
25
|
+
# Important for running:
|
|
26
|
+
#
|
|
27
|
+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
28
|
+
# noncompliant, but you have some other compliant shell such as ksh or
|
|
29
|
+
# bash, then to run this script, type that shell name before the whole
|
|
30
|
+
# command line, like:
|
|
31
|
+
#
|
|
32
|
+
# ksh Gradle
|
|
33
|
+
#
|
|
34
|
+
# Busybox and similar reduced shells will NOT work, because this script
|
|
35
|
+
# requires all of these POSIX shell features:
|
|
36
|
+
# * functions;
|
|
37
|
+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
38
|
+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
39
|
+
# * compound commands having a testable exit status, especially «case»;
|
|
40
|
+
# * various built-in commands including «command», «set», and «ulimit».
|
|
41
|
+
#
|
|
42
|
+
# Important for patching:
|
|
43
|
+
#
|
|
44
|
+
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
45
|
+
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
46
|
+
#
|
|
47
|
+
# The "traditional" practice of packing multiple parameters into a
|
|
48
|
+
# space-separated string is a well documented source of bugs and security
|
|
49
|
+
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
50
|
+
# options in "$@", and eventually passing that to Java.
|
|
51
|
+
#
|
|
52
|
+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
53
|
+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
54
|
+
# see the in-line comments for details.
|
|
55
|
+
#
|
|
56
|
+
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
57
|
+
# Darwin, MinGW, and NonStop.
|
|
58
|
+
#
|
|
59
|
+
# (3) This script is generated from the Groovy template
|
|
60
|
+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
61
|
+
# within the Gradle project.
|
|
62
|
+
#
|
|
63
|
+
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
64
|
+
#
|
|
65
|
+
##############################################################################
|
|
66
|
+
|
|
67
|
+
# Attempt to set APP_HOME
|
|
68
|
+
|
|
69
|
+
# Resolve links: $0 may be a link
|
|
70
|
+
app_path=$0
|
|
71
|
+
|
|
72
|
+
# Need this for daisy-chained symlinks.
|
|
73
|
+
while
|
|
74
|
+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
75
|
+
[ -h "$app_path" ]
|
|
76
|
+
do
|
|
77
|
+
ls=$( ls -ld "$app_path" )
|
|
78
|
+
link=${ls#*' -> '}
|
|
79
|
+
case $link in #(
|
|
80
|
+
/*) app_path=$link ;; #(
|
|
81
|
+
*) app_path=$APP_HOME$link ;;
|
|
82
|
+
esac
|
|
83
|
+
done
|
|
84
|
+
|
|
85
|
+
# This is normally unused
|
|
86
|
+
# shellcheck disable=SC2034
|
|
87
|
+
APP_BASE_NAME=${0##*/}
|
|
88
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
89
|
+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
|
90
|
+
|
|
91
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
92
|
+
MAX_FD=maximum
|
|
93
|
+
|
|
94
|
+
warn () {
|
|
95
|
+
echo "$*"
|
|
96
|
+
} >&2
|
|
97
|
+
|
|
98
|
+
die () {
|
|
99
|
+
echo
|
|
100
|
+
echo "$*"
|
|
101
|
+
echo
|
|
102
|
+
exit 1
|
|
103
|
+
} >&2
|
|
104
|
+
|
|
105
|
+
# OS specific support (must be 'true' or 'false').
|
|
106
|
+
cygwin=false
|
|
107
|
+
msys=false
|
|
108
|
+
darwin=false
|
|
109
|
+
nonstop=false
|
|
110
|
+
case "$( uname )" in #(
|
|
111
|
+
CYGWIN* ) cygwin=true ;; #(
|
|
112
|
+
Darwin* ) darwin=true ;; #(
|
|
113
|
+
MSYS* | MINGW* ) msys=true ;; #(
|
|
114
|
+
NONSTOP* ) nonstop=true ;;
|
|
115
|
+
esac
|
|
116
|
+
|
|
117
|
+
CLASSPATH="\\\"\\\""
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# Determine the Java command to use to start the JVM.
|
|
121
|
+
if [ -n "$JAVA_HOME" ] ; then
|
|
122
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
123
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
124
|
+
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
125
|
+
else
|
|
126
|
+
JAVACMD=$JAVA_HOME/bin/java
|
|
127
|
+
fi
|
|
128
|
+
if [ ! -x "$JAVACMD" ] ; then
|
|
129
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
130
|
+
|
|
131
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
132
|
+
location of your Java installation."
|
|
133
|
+
fi
|
|
134
|
+
else
|
|
135
|
+
JAVACMD=java
|
|
136
|
+
if ! command -v java >/dev/null 2>&1
|
|
137
|
+
then
|
|
138
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
139
|
+
|
|
140
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
141
|
+
location of your Java installation."
|
|
142
|
+
fi
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
# Increase the maximum file descriptors if we can.
|
|
146
|
+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
147
|
+
case $MAX_FD in #(
|
|
148
|
+
max*)
|
|
149
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
150
|
+
# shellcheck disable=SC2039,SC3045
|
|
151
|
+
MAX_FD=$( ulimit -H -n ) ||
|
|
152
|
+
warn "Could not query maximum file descriptor limit"
|
|
153
|
+
esac
|
|
154
|
+
case $MAX_FD in #(
|
|
155
|
+
'' | soft) :;; #(
|
|
156
|
+
*)
|
|
157
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
158
|
+
# shellcheck disable=SC2039,SC3045
|
|
159
|
+
ulimit -n "$MAX_FD" ||
|
|
160
|
+
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
161
|
+
esac
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Collect all arguments for the java command, stacking in reverse order:
|
|
165
|
+
# * args from the command line
|
|
166
|
+
# * the main class name
|
|
167
|
+
# * -classpath
|
|
168
|
+
# * -D...appname settings
|
|
169
|
+
# * --module-path (only if needed)
|
|
170
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
171
|
+
|
|
172
|
+
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
173
|
+
if "$cygwin" || "$msys" ; then
|
|
174
|
+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
175
|
+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
176
|
+
|
|
177
|
+
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
178
|
+
|
|
179
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
180
|
+
for arg do
|
|
181
|
+
if
|
|
182
|
+
case $arg in #(
|
|
183
|
+
-*) false ;; # don't mess with options #(
|
|
184
|
+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
185
|
+
[ -e "$t" ] ;; #(
|
|
186
|
+
*) false ;;
|
|
187
|
+
esac
|
|
188
|
+
then
|
|
189
|
+
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
190
|
+
fi
|
|
191
|
+
# Roll the args list around exactly as many times as the number of
|
|
192
|
+
# args, so each arg winds up back in the position where it started, but
|
|
193
|
+
# possibly modified.
|
|
194
|
+
#
|
|
195
|
+
# NB: a `for` loop captures its iteration list before it begins, so
|
|
196
|
+
# changing the positional parameters here affects neither the number of
|
|
197
|
+
# iterations, nor the values presented in `arg`.
|
|
198
|
+
shift # remove old arg
|
|
199
|
+
set -- "$@" "$arg" # push replacement arg
|
|
200
|
+
done
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
205
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
206
|
+
|
|
207
|
+
# Collect all arguments for the java command:
|
|
208
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
209
|
+
# and any embedded shellness will be escaped.
|
|
210
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
211
|
+
# treated as '${Hostname}' itself on the command line.
|
|
212
|
+
|
|
213
|
+
set -- \
|
|
214
|
+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
215
|
+
-classpath "$CLASSPATH" \
|
|
216
|
+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
|
217
|
+
"$@"
|
|
218
|
+
|
|
219
|
+
# Stop when "xargs" is not available.
|
|
220
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
221
|
+
then
|
|
222
|
+
die "xargs is not available"
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# Use "xargs" to parse quoted args.
|
|
226
|
+
#
|
|
227
|
+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
228
|
+
#
|
|
229
|
+
# In Bash we could simply go:
|
|
230
|
+
#
|
|
231
|
+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
232
|
+
# set -- "${ARGS[@]}" "$@"
|
|
233
|
+
#
|
|
234
|
+
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
235
|
+
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
236
|
+
# character that might be a shell metacharacter, then use eval to reverse
|
|
237
|
+
# that process (while maintaining the separation between arguments), and wrap
|
|
238
|
+
# the whole thing up as a single "set" statement.
|
|
239
|
+
#
|
|
240
|
+
# This will of course break if any of these variables contains a newline or
|
|
241
|
+
# an unmatched quote.
|
|
242
|
+
#
|
|
243
|
+
|
|
244
|
+
eval "set -- $(
|
|
245
|
+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
246
|
+
xargs -n1 |
|
|
247
|
+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
248
|
+
tr '\n' ' '
|
|
249
|
+
)" '"$@"'
|
|
250
|
+
|
|
251
|
+
exec "$JAVACMD" "$@"
|