@supersdk/supercli 0.1.1-staging.2 → 0.1.1-staging.4
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/commands/createApp.js +14 -58
- package/dist/commands/createApp.js.map +1 -1
- package/dist/commands/publishSite.js +286 -209
- package/dist/commands/publishSite.js.map +1 -1
- package/dist/createApp/copyTemplate.js +38 -53
- package/dist/createApp/copyTemplate.js.map +1 -1
- package/dist/publish/offlineVersion.js +33 -0
- package/dist/publish/offlineVersion.js.map +1 -0
- package/dist/publish/orgResolve.js +16 -17
- package/dist/publish/orgResolve.js.map +1 -1
- package/dist/publish/responseClassifier.js +17 -7
- package/dist/publish/responseClassifier.js.map +1 -1
- package/dist/publish/siteClient.js +19 -10
- package/dist/publish/siteClient.js.map +1 -1
- package/dist/publish/siteConfig.js +166 -124
- package/dist/publish/siteConfig.js.map +1 -1
- package/dist/template/README.md +11 -1
- package/dist/template/android/app/build.gradle.kts +6 -3
- package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +1 -1
- package/dist/template/android/gradle/supersdk-config-reader.gradle +2 -1
- package/dist/template/android/supersdk-default.config.json +3 -2
- package/dist/template/ios/MockSuperSDKPackage/Sources/SuperSDK/SuperSDK.swift +20 -4
- package/dist/template/ios/Sources/App/AppDelegate.swift +5 -1
- package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +6 -2
- package/dist/template/ios/Sources/App/SimpleSDKProbe.swift +7 -4
- package/dist/template/ios/Tests/SimpleAppTests/SimpleSDKInitializationTests.swift +2 -1
- package/dist/template/scripts/build_ios.sh +13 -9
- package/dist/template/scripts/supersdk_template.py +15 -8
- package/dist/template/supersdk.yaml +3 -2
- package/dist/template/web/src/index.html +6 -2
- package/dist/template/web/src/js/app.js +6 -3
- package/dist/template/web/src/js/supersdk.js +229 -91
- package/dist/template/web/src/js/supersdk.provenance.json +3 -3
- package/package.json +1 -1
|
@@ -35,156 +35,198 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.SCHEMA_VERSION = exports.SITE_CONFIG_FILENAME = void 0;
|
|
37
37
|
exports.siteConfigPath = siteConfigPath;
|
|
38
|
+
exports.isValidSpid = isValidSpid;
|
|
39
|
+
exports.isValidSlug = isValidSlug;
|
|
40
|
+
exports.isValidEnvironment = isValidEnvironment;
|
|
41
|
+
exports.isValidOrgId = isValidOrgId;
|
|
42
|
+
exports.parseSiteConfig = parseSiteConfig;
|
|
38
43
|
exports.readSiteConfig = readSiteConfig;
|
|
39
44
|
exports.renderSiteConfig = renderSiteConfig;
|
|
40
45
|
exports.writeSiteConfig = writeSiteConfig;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
// Fixed schema (NO yaml library, per TECH.md §模块4 rejected-alternatives):
|
|
45
|
-
//
|
|
46
|
-
// schema_version: 1
|
|
47
|
-
// site:
|
|
48
|
-
// id: <id>
|
|
49
|
-
// slug: <slug>
|
|
50
|
-
// name: <name>
|
|
51
|
-
//
|
|
52
|
-
// Hand-rolled: a minimal line-based reader for exactly these keys, and a
|
|
53
|
-
// template-string writer. The template dialect stays flat (no nesting beyond
|
|
54
|
-
// `site:`) so a line reader is sufficient and round-trip-stable.
|
|
46
|
+
// Strict schema-v2 binding for publish-site. This deliberately supports only
|
|
47
|
+
// the small YAML shape we write; malformed or legacy files must never be
|
|
48
|
+
// interpreted as an unbound directory that could publish to a guessed target.
|
|
55
49
|
const fs = __importStar(require("node:fs"));
|
|
56
50
|
const path = __importStar(require("node:path"));
|
|
57
|
-
const log_1 = require("../util/log");
|
|
58
51
|
const fsAtomic_1 = require("../util/fsAtomic");
|
|
59
52
|
exports.SITE_CONFIG_FILENAME = 'super-site.yml';
|
|
60
|
-
exports.SCHEMA_VERSION =
|
|
53
|
+
exports.SCHEMA_VERSION = 2;
|
|
61
54
|
function siteConfigPath(dir) {
|
|
62
55
|
return path.join(dir, exports.SITE_CONFIG_FILENAME);
|
|
63
56
|
}
|
|
64
|
-
function
|
|
57
|
+
function isValidSpid(value) {
|
|
58
|
+
return /^[a-z0-9]{8}$/.test(value);
|
|
59
|
+
}
|
|
60
|
+
function isValidSlug(value) {
|
|
61
|
+
return /^[a-z0-9]{1,32}$/.test(value) && value !== 'stg';
|
|
62
|
+
}
|
|
63
|
+
function isValidEnvironment(value) {
|
|
64
|
+
return /^[a-z0-9]{1,10}$/.test(value);
|
|
65
|
+
}
|
|
66
|
+
function isValidOrgId(value) {
|
|
67
|
+
return /^[1-9][0-9]*$/.test(value);
|
|
68
|
+
}
|
|
69
|
+
function scalar(value) {
|
|
65
70
|
const trimmed = value.trim();
|
|
66
|
-
if (trimmed.length
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
if (trimmed.length === 0)
|
|
72
|
+
return undefined;
|
|
73
|
+
const first = trimmed[0];
|
|
74
|
+
const last = trimmed[trimmed.length - 1];
|
|
75
|
+
if (first === '"' || first === "'") {
|
|
76
|
+
if (last !== first || trimmed.length < 2)
|
|
77
|
+
return undefined;
|
|
78
|
+
return trimmed.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
72
79
|
}
|
|
80
|
+
// A nested collection/anchor/tag is outside the fixed binding dialect.
|
|
81
|
+
if (/^[\[{&*!|>]/.test(trimmed))
|
|
82
|
+
return undefined;
|
|
73
83
|
return trimmed;
|
|
74
84
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
function invalid(reason) {
|
|
86
|
+
return { kind: 'invalid', reason };
|
|
87
|
+
}
|
|
88
|
+
/** Parses only the exact v2 shape. Unknown, duplicate, or misplaced keys fail closed. */
|
|
89
|
+
function parseSiteConfig(raw) {
|
|
90
|
+
// v1 carried only site identity. Recognize it before the strict v2 parser so
|
|
91
|
+
// its retired `site.id` key cannot turn a migration diagnostic into a generic
|
|
92
|
+
// invalid-file error. Missing project/org/environment are never inferred.
|
|
93
|
+
if (/^schema_version:\s*["']?1["']?\s*$/m.test(raw)) {
|
|
94
|
+
let inSite = false;
|
|
95
|
+
let slug = '';
|
|
96
|
+
let name = '';
|
|
97
|
+
for (const originalLine of raw.split(/\r?\n/)) {
|
|
98
|
+
const root = originalLine.match(/^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/);
|
|
99
|
+
if (root) {
|
|
100
|
+
inSite = root[1] === 'site' && root[2].trim().length === 0;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!inSite)
|
|
104
|
+
continue;
|
|
105
|
+
const child = originalLine.match(/^ {2}(slug|name):\s*(.*)$/);
|
|
106
|
+
if (!child)
|
|
107
|
+
continue;
|
|
108
|
+
const parsed = scalar(child[2]);
|
|
109
|
+
if (parsed === undefined)
|
|
110
|
+
continue;
|
|
111
|
+
if (child[1] === 'slug')
|
|
112
|
+
slug = parsed;
|
|
113
|
+
else
|
|
114
|
+
name = parsed;
|
|
115
|
+
}
|
|
116
|
+
return slug ? { kind: 'legacy-v1', site: { slug, name: name || slug } } : { kind: 'legacy-v1' };
|
|
92
117
|
}
|
|
93
|
-
let
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
if (!match)
|
|
103
|
-
continue;
|
|
104
|
-
const key = match[1];
|
|
105
|
-
const value = match[2];
|
|
106
|
-
if (!indented) {
|
|
107
|
-
inSite = key === 'site';
|
|
118
|
+
let version;
|
|
119
|
+
let environment;
|
|
120
|
+
const project = {};
|
|
121
|
+
const site = {};
|
|
122
|
+
let section;
|
|
123
|
+
const seen = new Set();
|
|
124
|
+
for (const originalLine of raw.split(/\r?\n/)) {
|
|
125
|
+
const line = originalLine.trimEnd();
|
|
126
|
+
if (line.trim().length === 0 || line.trimStart().startsWith('#'))
|
|
108
127
|
continue;
|
|
128
|
+
const root = line.match(/^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/);
|
|
129
|
+
if (root) {
|
|
130
|
+
const [, key, value] = root;
|
|
131
|
+
if (key === 'schema_version' || key === 'environment') {
|
|
132
|
+
if (seen.has(key))
|
|
133
|
+
return invalid(`duplicate root key: ${key}`);
|
|
134
|
+
seen.add(key);
|
|
135
|
+
const parsed = scalar(value);
|
|
136
|
+
if (parsed === undefined)
|
|
137
|
+
return invalid(`${key} must be a scalar`);
|
|
138
|
+
if (key === 'schema_version')
|
|
139
|
+
version = parsed;
|
|
140
|
+
else
|
|
141
|
+
environment = parsed;
|
|
142
|
+
section = undefined;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (key === 'project' || key === 'site') {
|
|
146
|
+
if (seen.has(key))
|
|
147
|
+
return invalid(`duplicate root key: ${key}`);
|
|
148
|
+
seen.add(key);
|
|
149
|
+
if (value.trim().length !== 0)
|
|
150
|
+
return invalid(`${key} must be a mapping`);
|
|
151
|
+
section = key;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
return invalid(`unknown root key: ${key}`);
|
|
155
|
+
}
|
|
156
|
+
const child = line.match(/^ {2}([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/);
|
|
157
|
+
if (!child || !section)
|
|
158
|
+
return invalid('invalid indentation or mapping structure');
|
|
159
|
+
const [, key, value] = child;
|
|
160
|
+
const parsed = scalar(value);
|
|
161
|
+
if (parsed === undefined)
|
|
162
|
+
return invalid(`${section}.${key} must be a scalar`);
|
|
163
|
+
const field = `${section}.${key}`;
|
|
164
|
+
if (seen.has(field))
|
|
165
|
+
return invalid(`duplicate key: ${field}`);
|
|
166
|
+
seen.add(field);
|
|
167
|
+
if (section === 'project' && (key === 'spid' || key === 'org_id')) {
|
|
168
|
+
if (key === 'spid')
|
|
169
|
+
project.spid = parsed;
|
|
170
|
+
else
|
|
171
|
+
project.orgId = parsed;
|
|
172
|
+
}
|
|
173
|
+
else if (section === 'site' && (key === 'slug' || key === 'name')) {
|
|
174
|
+
if (key === 'slug')
|
|
175
|
+
site.slug = parsed;
|
|
176
|
+
else
|
|
177
|
+
site.name = parsed;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
return invalid(`unknown key: ${field}`);
|
|
109
181
|
}
|
|
110
|
-
if (!inSite)
|
|
111
|
-
continue;
|
|
112
|
-
if (key === 'id')
|
|
113
|
-
id = unquote(value);
|
|
114
|
-
else if (key === 'slug')
|
|
115
|
-
slug = unquote(value);
|
|
116
|
-
else if (key === 'name')
|
|
117
|
-
name = unquote(value);
|
|
118
182
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
183
|
+
if (version !== String(exports.SCHEMA_VERSION))
|
|
184
|
+
return invalid('schema_version must equal 2');
|
|
185
|
+
if (!environment || !project.spid || !project.orgId || !site.slug || !site.name) {
|
|
186
|
+
return invalid('schema v2 requires project.spid, project.org_id, site.slug, site.name, and environment');
|
|
187
|
+
}
|
|
188
|
+
if (!isValidSpid(project.spid))
|
|
189
|
+
return invalid('project.spid must be 8 lowercase alphanumeric characters');
|
|
190
|
+
if (!isValidOrgId(project.orgId))
|
|
191
|
+
return invalid('project.org_id must be a positive integer');
|
|
192
|
+
if (!isValidSlug(site.slug))
|
|
193
|
+
return invalid('site.slug must be 1-32 lowercase alphanumeric characters and not stg');
|
|
194
|
+
if (site.name.trim().length === 0 || Array.from(site.name).length > 50)
|
|
195
|
+
return invalid('site.name must contain 1-50 characters');
|
|
196
|
+
if (!isValidEnvironment(environment))
|
|
197
|
+
return invalid('environment must be 1-10 lowercase alphanumeric characters');
|
|
198
|
+
return { kind: 'valid-v2', config: { schemaVersion: exports.SCHEMA_VERSION, project: project, site: site, environment } };
|
|
199
|
+
}
|
|
200
|
+
function readSiteConfig(dir) {
|
|
201
|
+
try {
|
|
202
|
+
return parseSiteConfig(fs.readFileSync(siteConfigPath(dir), 'utf8'));
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
if (error.code === 'ENOENT')
|
|
206
|
+
return { kind: 'absent' };
|
|
207
|
+
return invalid(`could not read ${exports.SITE_CONFIG_FILENAME}: ${error.message}`);
|
|
122
208
|
}
|
|
123
|
-
return { id, slug, name: name.length > 0 ? name : slug };
|
|
124
209
|
}
|
|
125
210
|
function quote(value) {
|
|
126
211
|
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
127
212
|
}
|
|
128
|
-
function renderIdValue(id) {
|
|
129
|
-
// Numeric ids can be written bare; anything else is quoted for safety.
|
|
130
|
-
return /^\d+$/.test(id) ? id : quote(id);
|
|
131
|
-
}
|
|
132
213
|
function renderSiteConfig(config) {
|
|
133
|
-
return
|
|
134
|
-
`
|
|
135
|
-
|
|
136
|
-
`
|
|
137
|
-
`
|
|
214
|
+
return [
|
|
215
|
+
`schema_version: ${exports.SCHEMA_VERSION}`,
|
|
216
|
+
'project:',
|
|
217
|
+
` spid: ${config.project.spid}`,
|
|
218
|
+
` org_id: ${config.project.orgId}`,
|
|
219
|
+
'site:',
|
|
220
|
+
` slug: ${config.site.slug}`,
|
|
221
|
+
` name: ${quote(config.site.name)}`,
|
|
222
|
+
`environment: ${config.environment}`,
|
|
223
|
+
'',
|
|
224
|
+
].join('\n');
|
|
138
225
|
}
|
|
139
226
|
function writeSiteConfig(dir, config) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
227
|
+
const parsed = parseSiteConfig(renderSiteConfig(config));
|
|
228
|
+
if (parsed.kind !== 'valid-v2')
|
|
229
|
+
throw new Error(`refusing to write invalid schema v2 binding: ${parsed.kind === 'invalid' ? parsed.reason : parsed.kind}`);
|
|
143
230
|
(0, fsAtomic_1.atomicWriteFileSync)(siteConfigPath(dir), renderSiteConfig(config));
|
|
144
231
|
}
|
|
145
|
-
// ---- slug validation / default derivation (mirrors service.rs validate_slug) ----
|
|
146
|
-
const RESERVED_SLUGS = new Set([
|
|
147
|
-
'www',
|
|
148
|
-
'api',
|
|
149
|
-
'admin',
|
|
150
|
-
'console',
|
|
151
|
-
'static',
|
|
152
|
-
'assets',
|
|
153
|
-
'cdn',
|
|
154
|
-
'mail',
|
|
155
|
-
'ftp',
|
|
156
|
-
'localhost',
|
|
157
|
-
'root',
|
|
158
|
-
'support',
|
|
159
|
-
'status',
|
|
160
|
-
]);
|
|
161
|
-
/** Mirrors the backend `validate_slug` shape + reserved-word rules exactly. */
|
|
162
|
-
function validateSlug(slug) {
|
|
163
|
-
const shapeOk = slug.length >= 1 &&
|
|
164
|
-
slug.length <= 40 &&
|
|
165
|
-
/^[a-z0-9]$/.test(slug[0]) &&
|
|
166
|
-
/^[a-z0-9]$/.test(slug[slug.length - 1]) &&
|
|
167
|
-
/^[a-z0-9-]+$/.test(slug);
|
|
168
|
-
if (!shapeOk) {
|
|
169
|
-
return { ok: false, reason: 'slug 需为 1-40 位小写字母、数字或内部连字符(首末为字母数字)' };
|
|
170
|
-
}
|
|
171
|
-
if (RESERVED_SLUGS.has(slug) || slug === 'stg' || slug.startsWith('stg-')) {
|
|
172
|
-
return { ok: false, reason: 'slug 命中保留字' };
|
|
173
|
-
}
|
|
174
|
-
return { ok: true };
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Derives a default slug from a directory basename. The basename is lowercased
|
|
178
|
-
* and then validated against the slug rules AS-IS — it is NOT aggressively
|
|
179
|
-
* rewritten (e.g. underscores are not turned into hyphens), because a directory
|
|
180
|
-
* whose name does not already look like a slug (uppercase/underscore/reserved)
|
|
181
|
-
* must fail closed and require an explicit --slug rather than silently binding
|
|
182
|
-
* to a guessed name (TC-S27).
|
|
183
|
-
*/
|
|
184
|
-
function deriveDefaultSlug(basename) {
|
|
185
|
-
const candidate = basename.trim().toLowerCase();
|
|
186
|
-
if (candidate.length === 0)
|
|
187
|
-
return null;
|
|
188
|
-
return validateSlug(candidate).ok ? candidate : null;
|
|
189
|
-
}
|
|
190
232
|
//# sourceMappingURL=siteConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siteConfig.js","sourceRoot":"","sources":["../../src/publish/siteConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"siteConfig.js","sourceRoot":"","sources":["../../src/publish/siteConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,wCAEC;AAED,kCAEC;AAED,kCAEC;AAED,gDAEC;AAED,oCAEC;AAqBD,0CAsFC;AAED,wCAOC;AAMD,4CAYC;AAED,0CAIC;AArLD,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAC9E,4CAA8B;AAC9B,gDAAkC;AAClC,+CAAuD;AAE1C,QAAA,oBAAoB,GAAG,gBAAgB,CAAC;AACxC,QAAA,cAAc,GAAG,CAAU,CAAC;AAezC,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,4BAAoB,CAAC,CAAC;AAC9C,CAAC;AAED,SAAgB,WAAW,CAAC,KAAa;IACvC,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,WAAW,CAAC,KAAa;IACvC,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,KAAK,CAAC;AAC3D,CAAC;AAED,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,SAAgB,YAAY,CAAC,KAAa;IACxC,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrC,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|
|
34
|
+
- Set `spid`, `environment`, and `name`. Replace the example `demo0001` with
|
|
35
|
+
the real 8-character lowercase alphanumeric spid issued by the console.
|
|
36
|
+
- Keep `environment: prod` for production, or use an explicit 1–10 character
|
|
37
|
+
lowercase alphanumeric environment such as `staging`.
|
|
35
38
|
- Set `android.package` for Android builds.
|
|
36
39
|
- Set `ios.bundleId` when a specific bundle identifier is needed; default
|
|
37
40
|
`ios.spmMode: mock` uses the bundled `ios/MockSuperSDKPackage`.
|
|
@@ -142,3 +145,10 @@ CI lane when you need real Android Gradle or iOS simulator compilation.
|
|
|
142
145
|
|
|
143
146
|
Publishing this template to the public `supersdks/simple` repository is BL-006,
|
|
144
147
|
not part of this feature.
|
|
148
|
+
|
|
149
|
+
## BREAKING identity migration
|
|
150
|
+
|
|
151
|
+
The root `app_id` key is retired. Rename it to `spid`, add `environment`
|
|
152
|
+
(`prod` when omitted by SDK callers), then rerun `./super_build.sh --plan`.
|
|
153
|
+
The managed Android, iOS, and Web configs are all projected from these same
|
|
154
|
+
root values; do not maintain platform-specific identity aliases.
|
|
@@ -11,7 +11,8 @@ plugins {
|
|
|
11
11
|
|
|
12
12
|
apply(from = "../gradle/supersdk-config-reader.gradle")
|
|
13
13
|
|
|
14
|
-
val
|
|
14
|
+
val supersdkSpid = extra["supersdkSpid"] as String
|
|
15
|
+
val supersdkEnvironment = extra["supersdkEnvironment"] as String
|
|
15
16
|
val supersdkAppName = extra["supersdkAppName"] as String
|
|
16
17
|
val supersdkApplicationId = extra["supersdkApplicationId"] as String
|
|
17
18
|
val supersdkVersionName = extra["supersdkVersionName"] as String
|
|
@@ -78,11 +79,13 @@ android {
|
|
|
78
79
|
|
|
79
80
|
buildTypes {
|
|
80
81
|
debug {
|
|
81
|
-
buildConfigField("String", "
|
|
82
|
+
buildConfigField("String", "SUPERSDK_SPID", quotedJavaString(supersdkSpid))
|
|
83
|
+
buildConfigField("String", "SUPERSDK_ENVIRONMENT", quotedJavaString(supersdkEnvironment))
|
|
82
84
|
buildConfigField("String", "SUPERSDK_APP_NAME", quotedJavaString(supersdkAppName))
|
|
83
85
|
}
|
|
84
86
|
release {
|
|
85
|
-
buildConfigField("String", "
|
|
87
|
+
buildConfigField("String", "SUPERSDK_SPID", quotedJavaString(supersdkSpid))
|
|
88
|
+
buildConfigField("String", "SUPERSDK_ENVIRONMENT", quotedJavaString(supersdkEnvironment))
|
|
86
89
|
buildConfigField("String", "SUPERSDK_APP_NAME", quotedJavaString(supersdkAppName))
|
|
87
90
|
isMinifyEnabled = false
|
|
88
91
|
}
|
|
@@ -13,7 +13,7 @@ public class SimpleApplication extends Application {
|
|
|
13
13
|
public void onCreate() {
|
|
14
14
|
super.onCreate();
|
|
15
15
|
try {
|
|
16
|
-
SuperSDK.init(this, BuildConfig.
|
|
16
|
+
SuperSDK.init(this, BuildConfig.SUPERSDK_SPID, BuildConfig.SUPERSDK_ENVIRONMENT, new SuperSDKProvider() {});
|
|
17
17
|
} catch (RuntimeException exception) {
|
|
18
18
|
Log.e(TAG, "SuperSDK init failed; check supersdk.yaml and the resolved SDK dependency.", exception);
|
|
19
19
|
throw exception;
|
|
@@ -50,7 +50,8 @@ if (versionCodeDecimal.scale() > 0 || versionCodeDecimal < BigDecimal.ONE || ver
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
ext.supersdkAndroidConfigPath = configFile.absolutePath
|
|
53
|
-
ext.
|
|
53
|
+
ext.supersdkSpid = requireMatchingString(config.spid, "spid", /[a-z0-9]{8}/, 'must match ^[a-z0-9]{8}$')
|
|
54
|
+
ext.supersdkEnvironment = requireMatchingString(config.environment, "environment", /[a-z0-9]{1,10}/, 'must match ^[a-z0-9]{1,10}$')
|
|
54
55
|
ext.supersdkAppName = requireString(config.name, "name")
|
|
55
56
|
if ((ext.supersdkAppName =~ /[\x00-\x1F]/).find() || ext.supersdkAppName != ext.supersdkAppName.trim()) {
|
|
56
57
|
throw new GradleException("SuperSDK Android config invalid at ${configFile}: name must be a non-empty Android app label without control characters or edge whitespace")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"spid": "demo0001",
|
|
3
|
+
"environment": "prod",
|
|
3
4
|
"managed_by": "supersdk-template",
|
|
4
5
|
"name": "SuperSDK Simple",
|
|
5
6
|
"platform": "android",
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
},
|
|
9
10
|
"schema_version": 2,
|
|
10
11
|
"sdk": {
|
|
11
|
-
"androidVersion": "1.0.0.
|
|
12
|
+
"androidVersion": "1.0.0.54-SNAPSHOT"
|
|
12
13
|
},
|
|
13
14
|
"version": {
|
|
14
15
|
"code": 1,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
1
3
|
public protocol SuperSDKProvider: AnyObject {
|
|
2
4
|
}
|
|
3
5
|
|
|
4
6
|
public final class SuperSDKManager {
|
|
5
7
|
public static let shared = SuperSDKManager()
|
|
6
8
|
|
|
7
|
-
public private(set) var
|
|
9
|
+
public private(set) var lastInitializedSpid: String?
|
|
10
|
+
public private(set) var lastInitializedEnvironment: String?
|
|
8
11
|
public private(set) var lastProviderTypeName: String?
|
|
9
12
|
public var lastProviderWasSet: Bool {
|
|
10
13
|
lastProviderTypeName != nil
|
|
@@ -13,13 +16,26 @@ public final class SuperSDKManager {
|
|
|
13
16
|
private init() {
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
public func initialize(
|
|
17
|
-
|
|
19
|
+
public func initialize(spid: String, environment: String = "prod", provider: SuperSDKProvider) throws {
|
|
20
|
+
guard spid.range(of: "^[a-z0-9]{8}$", options: .regularExpression) != nil else {
|
|
21
|
+
throw MockValidationError.invalidSpid
|
|
22
|
+
}
|
|
23
|
+
guard environment.range(of: "^[a-z0-9]{1,10}$", options: .regularExpression) != nil else {
|
|
24
|
+
throw MockValidationError.invalidEnvironment
|
|
25
|
+
}
|
|
26
|
+
lastInitializedSpid = spid
|
|
27
|
+
lastInitializedEnvironment = environment
|
|
18
28
|
lastProviderTypeName = String(describing: type(of: provider))
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
public func resetForTesting() {
|
|
22
|
-
|
|
32
|
+
lastInitializedSpid = nil
|
|
33
|
+
lastInitializedEnvironment = nil
|
|
23
34
|
lastProviderTypeName = nil
|
|
24
35
|
}
|
|
25
36
|
}
|
|
37
|
+
|
|
38
|
+
public enum MockValidationError: Error {
|
|
39
|
+
case invalidSpid
|
|
40
|
+
case invalidEnvironment
|
|
41
|
+
}
|
|
@@ -6,7 +6,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
|
6
6
|
_ application: UIApplication,
|
|
7
7
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
8
8
|
) -> Bool {
|
|
9
|
-
|
|
9
|
+
do {
|
|
10
|
+
try SimpleSDKBootstrap.initialize()
|
|
11
|
+
} catch {
|
|
12
|
+
fatalError("SuperSDK init failed; check supersdk.yaml identity: \(error)")
|
|
13
|
+
}
|
|
10
14
|
return true
|
|
11
15
|
}
|
|
12
16
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import SuperSDK
|
|
2
2
|
|
|
3
3
|
enum SimpleSDKBootstrap {
|
|
4
|
-
static func initialize() {
|
|
5
|
-
SuperSDKManager.shared.initialize(
|
|
4
|
+
static func initialize() throws {
|
|
5
|
+
try SuperSDKManager.shared.initialize(
|
|
6
|
+
spid: SimpleConfig.spid,
|
|
7
|
+
environment: SimpleConfig.environment,
|
|
8
|
+
provider: SimpleSDKProvider()
|
|
9
|
+
)
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -3,7 +3,8 @@ import SuperSDK
|
|
|
3
3
|
|
|
4
4
|
struct SimpleSDKProbeResult {
|
|
5
5
|
let resetClearedState: Bool
|
|
6
|
-
let
|
|
6
|
+
let initializedSpid: String?
|
|
7
|
+
let initializedEnvironment: String?
|
|
7
8
|
let providerWasSet: Bool
|
|
8
9
|
let providerTypeName: String?
|
|
9
10
|
}
|
|
@@ -11,13 +12,15 @@ struct SimpleSDKProbeResult {
|
|
|
11
12
|
enum SimpleSDKProbe {
|
|
12
13
|
static func resetAndInitializeForTesting() -> SimpleSDKProbeResult {
|
|
13
14
|
SuperSDKManager.shared.resetForTesting()
|
|
14
|
-
let resetClearedState = SuperSDKManager.shared.
|
|
15
|
+
let resetClearedState = SuperSDKManager.shared.lastInitializedSpid == nil
|
|
16
|
+
&& SuperSDKManager.shared.lastInitializedEnvironment == nil
|
|
15
17
|
&& !SuperSDKManager.shared.lastProviderWasSet
|
|
16
18
|
&& SuperSDKManager.shared.lastProviderTypeName == nil
|
|
17
|
-
SimpleSDKBootstrap.initialize()
|
|
19
|
+
try! SimpleSDKBootstrap.initialize()
|
|
18
20
|
return SimpleSDKProbeResult(
|
|
19
21
|
resetClearedState: resetClearedState,
|
|
20
|
-
|
|
22
|
+
initializedSpid: SuperSDKManager.shared.lastInitializedSpid,
|
|
23
|
+
initializedEnvironment: SuperSDKManager.shared.lastInitializedEnvironment,
|
|
21
24
|
providerWasSet: SuperSDKManager.shared.lastProviderWasSet,
|
|
22
25
|
providerTypeName: SuperSDKManager.shared.lastProviderTypeName
|
|
23
26
|
)
|
|
@@ -7,7 +7,8 @@ final class SimpleSDKInitializationTests: XCTestCase {
|
|
|
7
7
|
// SimpleSDKProbe is DEBUG-only; the SimpleApp test scheme intentionally runs this oracle in Debug.
|
|
8
8
|
let result = SimpleSDKProbe.resetAndInitializeForTesting()
|
|
9
9
|
XCTAssertTrue(result.resetClearedState)
|
|
10
|
-
XCTAssertEqual(result.
|
|
10
|
+
XCTAssertEqual(result.initializedSpid, SimpleConfig.spid)
|
|
11
|
+
XCTAssertEqual(result.initializedEnvironment, SimpleConfig.environment)
|
|
11
12
|
XCTAssertTrue(result.providerWasSet)
|
|
12
13
|
XCTAssertEqual(result.providerTypeName, "SimpleSDKProvider")
|
|
13
14
|
#else
|
|
@@ -30,12 +30,12 @@ def quote(value):
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def swift_string(value):
|
|
33
|
-
# json.dumps is a valid Swift string literal here because
|
|
33
|
+
# json.dumps is a valid Swift string literal here because spid is ASCII-restricted below.
|
|
34
34
|
return json.dumps(str(value))
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def
|
|
38
|
-
value = re.sub(r"[^a-z0-9-]+", "-",
|
|
37
|
+
def sanitize_spid(spid):
|
|
38
|
+
value = re.sub(r"[^a-z0-9-]+", "-", spid.lower())
|
|
39
39
|
value = re.sub(r"-+", "-", value).strip("-")
|
|
40
40
|
return value or "app"
|
|
41
41
|
|
|
@@ -97,9 +97,12 @@ if spm_mode == "real":
|
|
|
97
97
|
if spm_mode != "mock":
|
|
98
98
|
fail_invalid("platform_config.spmMode must be mock")
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
if not isinstance(
|
|
102
|
-
fail_invalid(f"
|
|
100
|
+
spid = managed.get("spid")
|
|
101
|
+
if not isinstance(spid, str) or not re.fullmatch(template_contract.SPID_PATTERN, spid):
|
|
102
|
+
fail_invalid(f"spid must match ^{template_contract.SPID_PATTERN}$")
|
|
103
|
+
environment = managed.get("environment")
|
|
104
|
+
if not isinstance(environment, str) or not re.fullmatch(template_contract.ENVIRONMENT_PATTERN, environment):
|
|
105
|
+
fail_invalid(f"environment must match ^{template_contract.ENVIRONMENT_PATTERN}$")
|
|
103
106
|
name = managed.get("name")
|
|
104
107
|
if not isinstance(name, str) or not name:
|
|
105
108
|
fail_invalid("name must be a non-empty string")
|
|
@@ -117,7 +120,7 @@ bundle_id = platform_config.get("bundleId")
|
|
|
117
120
|
if bundle_id is not None:
|
|
118
121
|
if not isinstance(bundle_id, str) or not re.fullmatch(template_contract.BUNDLE_ID_PATTERN, bundle_id):
|
|
119
122
|
fail_invalid("platform_config.bundleId must be a bundle identifier")
|
|
120
|
-
bundle_id = bundle_id or f"com.supersdk.simple.{
|
|
123
|
+
bundle_id = bundle_id or f"com.supersdk.simple.{sanitize_spid(spid)}"
|
|
121
124
|
mock_package = (ios_dir / "MockSuperSDKPackage").resolve()
|
|
122
125
|
source_spec = ios_dir / "project.yml"
|
|
123
126
|
|
|
@@ -130,9 +133,10 @@ simple_config.write_text(
|
|
|
130
133
|
"""import Foundation
|
|
131
134
|
|
|
132
135
|
enum SimpleConfig {
|
|
133
|
-
static let
|
|
136
|
+
static let spid = %s
|
|
137
|
+
static let environment = %s
|
|
134
138
|
}
|
|
135
|
-
""" % swift_string(
|
|
139
|
+
""" % (swift_string(spid), swift_string(environment)),
|
|
136
140
|
encoding="utf-8",
|
|
137
141
|
)
|
|
138
142
|
|