@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,25 @@
|
|
|
1
|
+
pluginManagement {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
dependencyResolutionManagement {
|
|
9
|
+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
|
10
|
+
repositories {
|
|
11
|
+
google()
|
|
12
|
+
mavenCentral()
|
|
13
|
+
// WS-03 ships a SNAPSHOT default until durable RELEASE promotion.
|
|
14
|
+
// The release runbook must remove this repository with the SNAPSHOT default.
|
|
15
|
+
maven {
|
|
16
|
+
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
|
|
17
|
+
mavenContent {
|
|
18
|
+
snapshotsOnly()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
rootProject.name = "SuperSDKSimpleAndroid"
|
|
25
|
+
include(":app")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app_id": "Demo_App-01",
|
|
3
|
+
"managed_by": "supersdk-template",
|
|
4
|
+
"name": "SuperSDK Simple",
|
|
5
|
+
"platform": "android",
|
|
6
|
+
"platform_config": {
|
|
7
|
+
"package": "com.supersdk.simple.host"
|
|
8
|
+
},
|
|
9
|
+
"schema_version": 2,
|
|
10
|
+
"sdk": {
|
|
11
|
+
"androidVersion": "1.0.0.43-SNAPSHOT"
|
|
12
|
+
},
|
|
13
|
+
"version": {
|
|
14
|
+
"code": 1,
|
|
15
|
+
"name": "1.0.0"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// swift-tools-version:5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "MockSuperSDKPackage",
|
|
6
|
+
platforms: [
|
|
7
|
+
.iOS(.v13)
|
|
8
|
+
],
|
|
9
|
+
products: [
|
|
10
|
+
.library(name: "SuperSDK", targets: ["SuperSDK"])
|
|
11
|
+
],
|
|
12
|
+
targets: [
|
|
13
|
+
.target(name: "SuperSDK", path: "Sources/SuperSDK")
|
|
14
|
+
]
|
|
15
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
public protocol SuperSDKProvider: AnyObject {
|
|
2
|
+
}
|
|
3
|
+
|
|
4
|
+
public final class SuperSDKManager {
|
|
5
|
+
public static let shared = SuperSDKManager()
|
|
6
|
+
|
|
7
|
+
public private(set) var lastInitializedAid: String?
|
|
8
|
+
public private(set) var lastProviderTypeName: String?
|
|
9
|
+
public var lastProviderWasSet: Bool {
|
|
10
|
+
lastProviderTypeName != nil
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
private init() {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public func initialize(aid: String, provider: SuperSDKProvider) {
|
|
17
|
+
lastInitializedAid = aid
|
|
18
|
+
lastProviderTypeName = String(describing: type(of: provider))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public func resetForTesting() {
|
|
22
|
+
lastInitializedAid = nil
|
|
23
|
+
lastProviderTypeName = nil
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleDisplayName</key>
|
|
8
|
+
<string>$(INFOPLIST_KEY_CFBundleDisplayName)</string>
|
|
9
|
+
<key>CFBundleExecutable</key>
|
|
10
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
11
|
+
<key>CFBundleIdentifier</key>
|
|
12
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
13
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
14
|
+
<string>6.0</string>
|
|
15
|
+
<key>CFBundleName</key>
|
|
16
|
+
<string>$(PRODUCT_NAME)</string>
|
|
17
|
+
<key>CFBundlePackageType</key>
|
|
18
|
+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
|
19
|
+
<key>CFBundleShortVersionString</key>
|
|
20
|
+
<string>$(MARKETING_VERSION)</string>
|
|
21
|
+
<key>CFBundleVersion</key>
|
|
22
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
23
|
+
<key>UILaunchScreen</key>
|
|
24
|
+
<dict/>
|
|
25
|
+
<key>UIApplicationSceneManifest</key>
|
|
26
|
+
<dict>
|
|
27
|
+
<key>UIApplicationSupportsMultipleScenes</key>
|
|
28
|
+
<false/>
|
|
29
|
+
<key>UISceneConfigurations</key>
|
|
30
|
+
<dict>
|
|
31
|
+
<key>UIWindowSceneSessionRoleApplication</key>
|
|
32
|
+
<array>
|
|
33
|
+
<dict>
|
|
34
|
+
<key>UISceneConfigurationName</key>
|
|
35
|
+
<string>Default Configuration</string>
|
|
36
|
+
<key>UISceneDelegateClassName</key>
|
|
37
|
+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
|
38
|
+
</dict>
|
|
39
|
+
</array>
|
|
40
|
+
</dict>
|
|
41
|
+
</dict>
|
|
42
|
+
</dict>
|
|
43
|
+
</plist>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
@main
|
|
4
|
+
final class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
5
|
+
func application(
|
|
6
|
+
_ application: UIApplication,
|
|
7
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
8
|
+
) -> Bool {
|
|
9
|
+
SimpleSDKBootstrap.initialize()
|
|
10
|
+
return true
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func application(
|
|
14
|
+
_ application: UIApplication,
|
|
15
|
+
configurationForConnecting connectingSceneSession: UISceneSession,
|
|
16
|
+
options: UIScene.ConnectionOptions
|
|
17
|
+
) -> UISceneConfiguration {
|
|
18
|
+
UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
4
|
+
var window: UIWindow?
|
|
5
|
+
|
|
6
|
+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
|
7
|
+
guard let windowScene = scene as? UIWindowScene else {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
window = UIWindow(windowScene: windowScene)
|
|
11
|
+
window?.rootViewController = SimpleViewController()
|
|
12
|
+
window?.makeKeyAndVisible()
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#if DEBUG
|
|
2
|
+
import SuperSDK
|
|
3
|
+
|
|
4
|
+
struct SimpleSDKProbeResult {
|
|
5
|
+
let resetClearedState: Bool
|
|
6
|
+
let initializedAid: String?
|
|
7
|
+
let providerWasSet: Bool
|
|
8
|
+
let providerTypeName: String?
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
enum SimpleSDKProbe {
|
|
12
|
+
static func resetAndInitializeForTesting() -> SimpleSDKProbeResult {
|
|
13
|
+
SuperSDKManager.shared.resetForTesting()
|
|
14
|
+
let resetClearedState = SuperSDKManager.shared.lastInitializedAid == nil
|
|
15
|
+
&& !SuperSDKManager.shared.lastProviderWasSet
|
|
16
|
+
&& SuperSDKManager.shared.lastProviderTypeName == nil
|
|
17
|
+
SimpleSDKBootstrap.initialize()
|
|
18
|
+
return SimpleSDKProbeResult(
|
|
19
|
+
resetClearedState: resetClearedState,
|
|
20
|
+
initializedAid: SuperSDKManager.shared.lastInitializedAid,
|
|
21
|
+
providerWasSet: SuperSDKManager.shared.lastProviderWasSet,
|
|
22
|
+
providerTypeName: SuperSDKManager.shared.lastProviderTypeName
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
#endif
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
final class SimpleViewController: UIViewController {
|
|
4
|
+
override func viewDidLoad() {
|
|
5
|
+
super.viewDidLoad()
|
|
6
|
+
view.backgroundColor = .systemBackground
|
|
7
|
+
|
|
8
|
+
let label = UILabel()
|
|
9
|
+
label.translatesAutoresizingMaskIntoConstraints = false
|
|
10
|
+
label.text = "SuperSDK Simple"
|
|
11
|
+
label.textColor = .label
|
|
12
|
+
label.font = .preferredFont(forTextStyle: .title2)
|
|
13
|
+
view.addSubview(label)
|
|
14
|
+
|
|
15
|
+
NSLayoutConstraint.activate([
|
|
16
|
+
label.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
|
17
|
+
label.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
|
18
|
+
])
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import XCTest
|
|
2
|
+
@testable import SimpleApp
|
|
3
|
+
|
|
4
|
+
final class SimpleSDKInitializationTests: XCTestCase {
|
|
5
|
+
func testTemplateBootstrapInitializesMockSDK() {
|
|
6
|
+
#if DEBUG
|
|
7
|
+
// SimpleSDKProbe is DEBUG-only; the SimpleApp test scheme intentionally runs this oracle in Debug.
|
|
8
|
+
let result = SimpleSDKProbe.resetAndInitializeForTesting()
|
|
9
|
+
XCTAssertTrue(result.resetClearedState)
|
|
10
|
+
XCTAssertEqual(result.initializedAid, SimpleConfig.appId)
|
|
11
|
+
XCTAssertTrue(result.providerWasSet)
|
|
12
|
+
XCTAssertEqual(result.providerTypeName, "SimpleSDKProvider")
|
|
13
|
+
#else
|
|
14
|
+
XCTFail("SimpleSDKProbe is DEBUG-only; run the SimpleApp test scheme with Debug configuration")
|
|
15
|
+
#endif
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: SimpleApp
|
|
2
|
+
options:
|
|
3
|
+
createIntermediateGroups: true
|
|
4
|
+
settings:
|
|
5
|
+
base:
|
|
6
|
+
SWIFT_VERSION: "5.9"
|
|
7
|
+
packages:
|
|
8
|
+
SuperSDK:
|
|
9
|
+
path: __SUPERSDK_MOCK_PACKAGE_PATH__
|
|
10
|
+
targets:
|
|
11
|
+
SimpleApp:
|
|
12
|
+
type: application
|
|
13
|
+
platform: iOS
|
|
14
|
+
deploymentTarget: "13.0"
|
|
15
|
+
sources:
|
|
16
|
+
- path: __SUPERSDK_APP_SOURCES_PATH__
|
|
17
|
+
- path: __SUPERSDK_SIMPLE_CONFIG_PATH__
|
|
18
|
+
resources:
|
|
19
|
+
- path: __SUPERSDK_RESOURCES_PATH__
|
|
20
|
+
excludes:
|
|
21
|
+
- Info.plist
|
|
22
|
+
dependencies:
|
|
23
|
+
- package: SuperSDK
|
|
24
|
+
product: SuperSDK
|
|
25
|
+
settings:
|
|
26
|
+
base:
|
|
27
|
+
PRODUCT_BUNDLE_IDENTIFIER: __SUPERSDK_BUNDLE_ID__
|
|
28
|
+
PRODUCT_NAME: SimpleApp
|
|
29
|
+
PRODUCT_MODULE_NAME: SimpleApp
|
|
30
|
+
MARKETING_VERSION: __SUPERSDK_VERSION_NAME__
|
|
31
|
+
CURRENT_PROJECT_VERSION: __SUPERSDK_VERSION_CODE__
|
|
32
|
+
INFOPLIST_FILE: __SUPERSDK_INFOPLIST_PATH__
|
|
33
|
+
INFOPLIST_KEY_CFBundleDisplayName: __SUPERSDK_DISPLAY_NAME__
|
|
34
|
+
IPHONEOS_DEPLOYMENT_TARGET: "13.0"
|
|
35
|
+
CODE_SIGNING_ALLOWED: "NO"
|
|
36
|
+
SimpleAppTests:
|
|
37
|
+
type: bundle.unit-test
|
|
38
|
+
platform: iOS
|
|
39
|
+
deploymentTarget: "13.0"
|
|
40
|
+
sources:
|
|
41
|
+
- path: __SUPERSDK_TEST_SOURCES_PATH__
|
|
42
|
+
dependencies:
|
|
43
|
+
- target: SimpleApp
|
|
44
|
+
settings:
|
|
45
|
+
base:
|
|
46
|
+
PRODUCT_MODULE_NAME: SimpleAppTests
|
|
47
|
+
TEST_HOST: "$(BUILT_PRODUCTS_DIR)/SimpleApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/SimpleApp"
|
|
48
|
+
BUNDLE_LOADER: "$(TEST_HOST)"
|
|
49
|
+
CODE_SIGNING_ALLOWED: "NO"
|
|
50
|
+
schemes:
|
|
51
|
+
SimpleApp:
|
|
52
|
+
build:
|
|
53
|
+
targets:
|
|
54
|
+
SimpleApp: all
|
|
55
|
+
SimpleAppTests: [test]
|
|
56
|
+
run:
|
|
57
|
+
config: Debug
|
|
58
|
+
test:
|
|
59
|
+
config: Debug
|
|
60
|
+
targets:
|
|
61
|
+
- SimpleAppTests
|
|
62
|
+
profile:
|
|
63
|
+
config: Release
|
|
64
|
+
analyze:
|
|
65
|
+
config: Debug
|
|
66
|
+
archive:
|
|
67
|
+
config: Release
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import urllib.error
|
|
7
|
+
import urllib.request
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import supersdk_template
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
DEFAULT_METADATA_BASE_URL = "https://central.sonatype.com/repository/maven-snapshots/"
|
|
14
|
+
COORDINATE_ARTIFACTS = ("supersdk", "supersdk-api", "supersdk-impl", "supersdk-base")
|
|
15
|
+
STALE_SNAPSHOT = "sdk.androidVersion snapshot is no longer available; update to a current snapshot or RELEASE"
|
|
16
|
+
NETWORK_SKIP = "SKIP_NETWORK_OR_REMOTE_MAVEN_UNAVAILABLE"
|
|
17
|
+
PUBLIC_RELEASE_REQUIRES_RELEASE = "public release requires a durable RELEASE sdk.androidVersion"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def metadata_url(base_url, artifact, version):
|
|
21
|
+
base = base_url.rstrip("/")
|
|
22
|
+
return f"{base}/com/supersdk/{artifact}/{version}/maven-metadata.xml"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def fetch_status(url, timeout):
|
|
26
|
+
request = urllib.request.Request(url, headers={"User-Agent": "supersdk-android-snapshot-canary"})
|
|
27
|
+
try:
|
|
28
|
+
with urllib.request.urlopen(request, timeout=timeout) as response:
|
|
29
|
+
return ("http", response.status)
|
|
30
|
+
except urllib.error.HTTPError as exc:
|
|
31
|
+
return ("http", exc.code)
|
|
32
|
+
except Exception as exc:
|
|
33
|
+
return ("network", exc.__class__.__name__)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def status_label(status):
|
|
37
|
+
kind, value = status
|
|
38
|
+
if kind == "http":
|
|
39
|
+
return f"HTTP {value}"
|
|
40
|
+
return "network error"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def is_network_or_transient(status):
|
|
44
|
+
kind, value = status
|
|
45
|
+
return kind == "network" or (kind == "http" and value >= 500)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def classify_metadata_url(url, timeout):
|
|
49
|
+
first = fetch_status(url, timeout)
|
|
50
|
+
if first == ("http", 200):
|
|
51
|
+
return ("ok", None)
|
|
52
|
+
if first == ("http", 410):
|
|
53
|
+
return ("fail", STALE_SNAPSHOT)
|
|
54
|
+
if first == ("http", 404):
|
|
55
|
+
second = fetch_status(url, timeout)
|
|
56
|
+
if second == ("http", 200):
|
|
57
|
+
return ("ok", None)
|
|
58
|
+
if second == ("http", 404):
|
|
59
|
+
return ("fail", STALE_SNAPSHOT)
|
|
60
|
+
if second == ("http", 410):
|
|
61
|
+
return ("fail", STALE_SNAPSHOT)
|
|
62
|
+
if is_network_or_transient(second):
|
|
63
|
+
return ("fail", f"snapshot metadata temporarily unavailable after retry: HTTP 404 then {status_label(second)}")
|
|
64
|
+
kind, value = second
|
|
65
|
+
if kind == "http":
|
|
66
|
+
return ("fail", f"snapshot metadata unavailable: HTTP {value}")
|
|
67
|
+
kind, value = first
|
|
68
|
+
if kind == "http" and 400 <= value < 500:
|
|
69
|
+
return ("fail", f"snapshot metadata unavailable: HTTP {value}")
|
|
70
|
+
if is_network_or_transient(first):
|
|
71
|
+
return ("skip", f"{NETWORK_SKIP}: snapshot metadata temporarily unavailable: {status_label(first)}")
|
|
72
|
+
return ("fail", f"snapshot metadata unavailable: {status_label(first)}")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def managed_android_version(root):
|
|
76
|
+
android_root = Path(root) / "android"
|
|
77
|
+
for candidate in (
|
|
78
|
+
android_root / ".supersdk" / "managed" / "config.json",
|
|
79
|
+
android_root / "supersdk-default.config.json",
|
|
80
|
+
):
|
|
81
|
+
if not candidate.is_file():
|
|
82
|
+
continue
|
|
83
|
+
try:
|
|
84
|
+
payload = json.loads(candidate.read_text(encoding="utf-8"))
|
|
85
|
+
except Exception as exc:
|
|
86
|
+
raise supersdk_template.ConfigError(str(candidate), str(exc)) from exc
|
|
87
|
+
if payload.get("managed_by") != supersdk_template.MANAGED_BY:
|
|
88
|
+
continue
|
|
89
|
+
version = payload.get("sdk", {}).get("androidVersion")
|
|
90
|
+
return supersdk_template.validate_android_version(version)
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def effective_android_version(root, config_path):
|
|
95
|
+
version = managed_android_version(root)
|
|
96
|
+
if version is not None:
|
|
97
|
+
return version
|
|
98
|
+
normalized = supersdk_template.load_and_validate(config_path, "auto")
|
|
99
|
+
supersdk_template.require_android_config(normalized)
|
|
100
|
+
return normalized["sdk"]["androidVersion"]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def main(argv):
|
|
104
|
+
parser = argparse.ArgumentParser(description="Check SuperSDK Android SNAPSHOT metadata before Gradle")
|
|
105
|
+
parser.add_argument("--root", required=True)
|
|
106
|
+
parser.add_argument("--config", required=True)
|
|
107
|
+
parser.add_argument("--metadata-base-url", default=os.environ.get("SUPERSDK_ANDROID_SNAPSHOT_METADATA_BASE_URL", DEFAULT_METADATA_BASE_URL))
|
|
108
|
+
parser.add_argument("--timeout", type=float, default=5.0)
|
|
109
|
+
args = parser.parse_args(argv)
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
version = effective_android_version(Path(args.root), Path(args.config))
|
|
113
|
+
except supersdk_template.ConfigError as exc:
|
|
114
|
+
print(str(exc), file=sys.stderr)
|
|
115
|
+
return 1
|
|
116
|
+
|
|
117
|
+
if version.endswith("-SNAPSHOT") and (
|
|
118
|
+
os.environ.get("SUPERSDK_PUBLIC_RELEASE_READY") == "1" or os.environ.get("WS03_PUBLIC_RELEASE_READY") == "1"
|
|
119
|
+
):
|
|
120
|
+
print(PUBLIC_RELEASE_REQUIRES_RELEASE, file=sys.stderr)
|
|
121
|
+
return 1
|
|
122
|
+
|
|
123
|
+
if not version.endswith("-SNAPSHOT"):
|
|
124
|
+
return 0
|
|
125
|
+
|
|
126
|
+
for artifact in COORDINATE_ARTIFACTS:
|
|
127
|
+
verdict, message = classify_metadata_url(metadata_url(args.metadata_base_url, artifact, version), args.timeout)
|
|
128
|
+
if verdict == "ok":
|
|
129
|
+
continue
|
|
130
|
+
print(message, file=sys.stderr)
|
|
131
|
+
return 0 if verdict == "skip" else 1
|
|
132
|
+
return 0
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
if __name__ == "__main__":
|
|
136
|
+
raise SystemExit(main(sys.argv[1:]))
|