@cond/simasdk 0.0.0-stage → 0.2.0
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/CondSimasdk.podspec +18 -0
- package/Package.swift +31 -0
- package/README.md +508 -2
- package/android/build.gradle +63 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/simasdk/SimaFirebasePlugin.java +139 -0
- package/android/src/main/java/com/simasdk/SimaGamesPlugin.java +235 -0
- package/android/src/main/java/com/simasdk/SimaHapticsPlugin.java +101 -0
- package/android/src/main/java/com/simasdk/SimaReviewPlugin.java +48 -0
- package/android/src/main/java/com/simasdk/SimaStoragePlugin.java +79 -0
- package/dist/ads.cjs +214 -0
- package/dist/ads.cjs.map +1 -0
- package/dist/ads.d.cts +98 -0
- package/dist/ads.d.ts +98 -0
- package/dist/ads.js +211 -0
- package/dist/ads.js.map +1 -0
- package/dist/att.cjs +37 -0
- package/dist/att.cjs.map +1 -0
- package/dist/att.d.cts +31 -0
- package/dist/att.d.ts +31 -0
- package/dist/att.js +33 -0
- package/dist/att.js.map +1 -0
- package/dist/back-button.cjs +95 -0
- package/dist/back-button.cjs.map +1 -0
- package/dist/back-button.d.cts +45 -0
- package/dist/back-button.d.ts +45 -0
- package/dist/back-button.js +88 -0
- package/dist/back-button.js.map +1 -0
- package/dist/cli.js +723 -0
- package/dist/firebase.cjs +102 -0
- package/dist/firebase.cjs.map +1 -0
- package/dist/firebase.d.cts +40 -0
- package/dist/firebase.d.ts +40 -0
- package/dist/firebase.js +99 -0
- package/dist/firebase.js.map +1 -0
- package/dist/games.cjs +98 -0
- package/dist/games.cjs.map +1 -0
- package/dist/games.d.cts +73 -0
- package/dist/games.d.ts +73 -0
- package/dist/games.js +95 -0
- package/dist/games.js.map +1 -0
- package/dist/haptics.cjs +81 -0
- package/dist/haptics.cjs.map +1 -0
- package/dist/haptics.d.cts +51 -0
- package/dist/haptics.d.ts +51 -0
- package/dist/haptics.js +78 -0
- package/dist/haptics.js.map +1 -0
- package/dist/index.cjs +233 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +99 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +226 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +118 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +51 -0
- package/dist/react.d.ts +51 -0
- package/dist/react.js +113 -0
- package/dist/react.js.map +1 -0
- package/dist/review.cjs +195 -0
- package/dist/review.cjs.map +1 -0
- package/dist/review.d.cts +76 -0
- package/dist/review.d.ts +76 -0
- package/dist/review.js +192 -0
- package/dist/review.js.map +1 -0
- package/dist/shell.cjs +97 -0
- package/dist/shell.cjs.map +1 -0
- package/dist/shell.d.cts +36 -0
- package/dist/shell.d.ts +36 -0
- package/dist/shell.js +91 -0
- package/dist/shell.js.map +1 -0
- package/dist/storage.cjs +140 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +48 -0
- package/dist/storage.d.ts +48 -0
- package/dist/storage.js +136 -0
- package/dist/storage.js.map +1 -0
- package/ios/Sources/SimasdkPlugin/SimaAttPlugin.swift +41 -0
- package/ios/Sources/SimasdkPlugin/SimaFirebasePlugin.swift +188 -0
- package/ios/Sources/SimasdkPlugin/SimaGamesPlugin.swift +145 -0
- package/ios/Sources/SimasdkPlugin/SimaHapticsPlugin.swift +61 -0
- package/ios/Sources/SimasdkPlugin/SimaReviewPlugin.swift +40 -0
- package/ios/Sources/SimasdkPlugin/SimaStoragePlugin.swift +58 -0
- package/package.json +128 -4
- package/skills/simasdk/SKILL.md +189 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
function readTextIfExists(filePath) {
|
|
9
|
+
try {
|
|
10
|
+
if (!fs.existsSync(filePath)) return null;
|
|
11
|
+
return fs.readFileSync(filePath, "utf8");
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function readJsonIfExists(filePath) {
|
|
17
|
+
const raw = readTextIfExists(filePath);
|
|
18
|
+
if (!raw) return null;
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(raw);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function extractPlistString(plistXml, key) {
|
|
26
|
+
const regex = new RegExp(`<key>${key}</key>\\s*<string>([^<]+)</string>`);
|
|
27
|
+
const match = plistXml.match(regex);
|
|
28
|
+
return match?.[1]?.trim() ?? null;
|
|
29
|
+
}
|
|
30
|
+
function extractPlistBool(plistXml, key) {
|
|
31
|
+
const regex = new RegExp(`<key>${key}</key>\\s*<(true|false)\\s*/>`);
|
|
32
|
+
const match = plistXml.match(regex);
|
|
33
|
+
if (!match) return null;
|
|
34
|
+
return match[1] === "true";
|
|
35
|
+
}
|
|
36
|
+
function extractCapAppId(cwd) {
|
|
37
|
+
const jsonCfg = readJsonIfExists(path.join(cwd, "capacitor.config.json"));
|
|
38
|
+
if (jsonCfg?.appId) return jsonCfg.appId;
|
|
39
|
+
for (const name of ["capacitor.config.ts", "capacitor.config.js", "capacitor.config.mjs"]) {
|
|
40
|
+
const raw = readTextIfExists(path.join(cwd, name));
|
|
41
|
+
if (!raw) continue;
|
|
42
|
+
const match = raw.match(/appId\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
43
|
+
if (match?.[1]) return match[1];
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function runDoctor(cwd) {
|
|
48
|
+
const checks = [];
|
|
49
|
+
const pkg = readJsonIfExists(path.join(cwd, "package.json"));
|
|
50
|
+
const allDeps = { ...pkg?.dependencies ?? {}, ...pkg?.devDependencies ?? {} };
|
|
51
|
+
const capVersion = allDeps["@capacitor/core"] ?? null;
|
|
52
|
+
if (!pkg) {
|
|
53
|
+
checks.push({
|
|
54
|
+
id: "package-json",
|
|
55
|
+
status: "fail",
|
|
56
|
+
message: "No package.json found in current directory.",
|
|
57
|
+
hint: "Run `simasdk doctor` from your Capacitor app root."
|
|
58
|
+
});
|
|
59
|
+
return { cwd, ok: false, capacitorVersion: null, hasIos: false, hasAndroid: false, checks };
|
|
60
|
+
}
|
|
61
|
+
if (!capVersion) {
|
|
62
|
+
checks.push({
|
|
63
|
+
id: "capacitor-core",
|
|
64
|
+
status: "fail",
|
|
65
|
+
message: "@capacitor/core is not listed in package.json.",
|
|
66
|
+
hint: "Install @capacitor/core (^7.0.0 or ^8.0.0)."
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
const majorMatch = capVersion.match(/(\d+)/);
|
|
70
|
+
const major = majorMatch ? Number(majorMatch[1]) : null;
|
|
71
|
+
if (major === 7 || major === 8) {
|
|
72
|
+
checks.push({
|
|
73
|
+
id: "capacitor-core",
|
|
74
|
+
status: "pass",
|
|
75
|
+
message: `@capacitor/core ${capVersion} is supported (Capacitor 7 & 8).`
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
checks.push({
|
|
79
|
+
id: "capacitor-core",
|
|
80
|
+
status: "warn",
|
|
81
|
+
message: `@capacitor/core ${capVersion} detected; simasdk supports Capacitor 7 and 8.`
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const simasdkVersion = allDeps["@cond/simasdk"] ?? allDeps["simasdk"];
|
|
86
|
+
if (simasdkVersion) {
|
|
87
|
+
checks.push({
|
|
88
|
+
id: "simasdk-installed",
|
|
89
|
+
status: "pass",
|
|
90
|
+
message: `@cond/simasdk (${simasdkVersion}) is installed.`
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
checks.push({
|
|
94
|
+
id: "simasdk-installed",
|
|
95
|
+
status: "warn",
|
|
96
|
+
message: "@cond/simasdk is not yet listed in package.json.",
|
|
97
|
+
hint: "Run `npm install @cond/simasdk && npx cap sync`."
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (allDeps["firebase"]) {
|
|
101
|
+
checks.push({
|
|
102
|
+
id: "firebase-web-sdk",
|
|
103
|
+
status: "warn",
|
|
104
|
+
message: "Firebase Web SDK (`firebase`) is present in package.json.",
|
|
105
|
+
hint: "Do not use Firebase Web SDK for mobile analytics; use native FirebaseAnalytics + `simasdk/firebase`."
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const appId = extractCapAppId(cwd);
|
|
109
|
+
const hasIos = fs.existsSync(path.join(cwd, "ios"));
|
|
110
|
+
const hasAndroid = fs.existsSync(path.join(cwd, "android"));
|
|
111
|
+
if (!hasIos && !hasAndroid) {
|
|
112
|
+
checks.push({
|
|
113
|
+
id: "native-platforms",
|
|
114
|
+
status: "info",
|
|
115
|
+
message: "No ios/ or android/ directory found yet.",
|
|
116
|
+
hint: "Run `npx cap add ios` and/or `npx cap add android`."
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (hasIos) {
|
|
120
|
+
const iosCapCfg = readJsonIfExists(
|
|
121
|
+
path.join(cwd, "ios/App/App/capacitor.config.json")
|
|
122
|
+
);
|
|
123
|
+
const classList = iosCapCfg?.packageClassList ?? [];
|
|
124
|
+
const expectedIosPlugins = [
|
|
125
|
+
"SimaReviewPlugin",
|
|
126
|
+
"SimaFirebasePlugin",
|
|
127
|
+
"SimaHapticsPlugin",
|
|
128
|
+
"SimaStoragePlugin",
|
|
129
|
+
"SimaGamesPlugin",
|
|
130
|
+
"SimaAttPlugin"
|
|
131
|
+
];
|
|
132
|
+
const missingIosPlugins = expectedIosPlugins.filter((p) => !classList.includes(p));
|
|
133
|
+
if (simasdkVersion) {
|
|
134
|
+
if (missingIosPlugins.length === 0) {
|
|
135
|
+
checks.push({
|
|
136
|
+
id: "ios-plugin-sync",
|
|
137
|
+
status: "pass",
|
|
138
|
+
message: `All ${expectedIosPlugins.length} simasdk iOS plugins are synced in ios/App/App/capacitor.config.json.`
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
checks.push({
|
|
142
|
+
id: "ios-plugin-sync",
|
|
143
|
+
status: "fail",
|
|
144
|
+
message: `Missing iOS plugins in capacitor.config.json: ${missingIosPlugins.join(", ")}.`,
|
|
145
|
+
hint: "Run `npx cap sync ios`."
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const plistPath = path.join(cwd, "ios/App/App/GoogleService-Info.plist");
|
|
150
|
+
const plistRaw = readTextIfExists(plistPath);
|
|
151
|
+
if (!plistRaw) {
|
|
152
|
+
checks.push({
|
|
153
|
+
id: "ios-firebase-plist",
|
|
154
|
+
status: "info",
|
|
155
|
+
message: "No ios/App/App/GoogleService-Info.plist found (OK if not using Firebase Analytics)."
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
checks.push({
|
|
159
|
+
id: "ios-firebase-plist",
|
|
160
|
+
status: "pass",
|
|
161
|
+
message: "Found ios/App/App/GoogleService-Info.plist."
|
|
162
|
+
});
|
|
163
|
+
const plistBundleId = extractPlistString(plistRaw, "BUNDLE_ID");
|
|
164
|
+
if (plistBundleId && appId && plistBundleId !== appId) {
|
|
165
|
+
checks.push({
|
|
166
|
+
id: "ios-bundle-id-match",
|
|
167
|
+
status: "fail",
|
|
168
|
+
message: `Bundle ID mismatch: GoogleService-Info.plist has "${plistBundleId}" but capacitor.config has "${appId}".`,
|
|
169
|
+
hint: "Download GoogleService-Info.plist for the exact iOS Bundle ID."
|
|
170
|
+
});
|
|
171
|
+
} else if (plistBundleId) {
|
|
172
|
+
checks.push({
|
|
173
|
+
id: "ios-bundle-id-match",
|
|
174
|
+
status: "pass",
|
|
175
|
+
message: `GoogleService-Info.plist BUNDLE_ID matches (${plistBundleId}).`
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
const pbxproj = readTextIfExists(path.join(cwd, "ios/App/App.xcodeproj/project.pbxproj"));
|
|
179
|
+
if (pbxproj) {
|
|
180
|
+
if (pbxproj.includes("GoogleService-Info.plist")) {
|
|
181
|
+
checks.push({
|
|
182
|
+
id: "ios-plist-target",
|
|
183
|
+
status: "pass",
|
|
184
|
+
message: "GoogleService-Info.plist is referenced in App.xcodeproj."
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
checks.push({
|
|
188
|
+
id: "ios-plist-target",
|
|
189
|
+
status: "fail",
|
|
190
|
+
message: "GoogleService-Info.plist exists on disk but is NOT referenced in App.xcodeproj.",
|
|
191
|
+
hint: "Add GoogleService-Info.plist to the App target in Xcode (Target Membership)."
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const hasFirebaseSpm = pbxproj.includes("FirebaseAnalytics") || (readTextIfExists(path.join(cwd, "ios/App/Podfile")) ?? "").includes("FirebaseAnalytics");
|
|
195
|
+
if (hasFirebaseSpm) {
|
|
196
|
+
checks.push({
|
|
197
|
+
id: "ios-firebase-sdk",
|
|
198
|
+
status: "pass",
|
|
199
|
+
message: "FirebaseAnalytics dependency detected in iOS project."
|
|
200
|
+
});
|
|
201
|
+
} else {
|
|
202
|
+
checks.push({
|
|
203
|
+
id: "ios-firebase-sdk",
|
|
204
|
+
status: "fail",
|
|
205
|
+
message: "GoogleService-Info.plist is present, but FirebaseAnalytics is not linked in Xcode/Podfile.",
|
|
206
|
+
hint: "Add firebase-ios-sdk -> FirebaseAnalytics to the App target in Xcode."
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const appDelegate = readTextIfExists(path.join(cwd, "ios/App/App/AppDelegate.swift"));
|
|
211
|
+
if (appDelegate?.includes("FirebaseApp.configure()")) {
|
|
212
|
+
checks.push({
|
|
213
|
+
id: "ios-appdelegate-configure",
|
|
214
|
+
status: "pass",
|
|
215
|
+
message: "FirebaseApp.configure() found in AppDelegate.swift."
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
checks.push({
|
|
219
|
+
id: "ios-appdelegate-configure",
|
|
220
|
+
status: "warn",
|
|
221
|
+
message: "FirebaseApp.configure() not found in AppDelegate.swift.",
|
|
222
|
+
hint: "Recommended: call FirebaseApp.configure() in application(_:didFinishLaunchingWithOptions:) for earliest first_open capture."
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
const infoPlist = readTextIfExists(path.join(cwd, "ios/App/App/Info.plist"));
|
|
226
|
+
if (infoPlist) {
|
|
227
|
+
const collectionFlag = extractPlistBool(infoPlist, "FIREBASE_ANALYTICS_COLLECTION_ENABLED");
|
|
228
|
+
if (collectionFlag === false) {
|
|
229
|
+
checks.push({
|
|
230
|
+
id: "ios-collection-flag",
|
|
231
|
+
status: "info",
|
|
232
|
+
message: "FIREBASE_ANALYTICS_COLLECTION_ENABLED is false in Info.plist (consent-first mode).",
|
|
233
|
+
hint: "Remember to call sima.setAnalyticsCollectionEnabled(true) after user consent."
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const attDesc = extractPlistString(infoPlist, "NSUserTrackingUsageDescription");
|
|
237
|
+
if (attDesc) {
|
|
238
|
+
checks.push({
|
|
239
|
+
id: "ios-att-description",
|
|
240
|
+
status: "pass",
|
|
241
|
+
message: "NSUserTrackingUsageDescription is configured in Info.plist for App Tracking Transparency."
|
|
242
|
+
});
|
|
243
|
+
} else {
|
|
244
|
+
checks.push({
|
|
245
|
+
id: "ios-att-description",
|
|
246
|
+
status: "info",
|
|
247
|
+
message: "No NSUserTrackingUsageDescription in Info.plist (required if using @cond/simasdk/att for IDFA)."
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (hasAndroid) {
|
|
254
|
+
const googleServicesJson = readTextIfExists(path.join(cwd, "android/app/google-services.json"));
|
|
255
|
+
if (!googleServicesJson) {
|
|
256
|
+
checks.push({
|
|
257
|
+
id: "android-firebase-json",
|
|
258
|
+
status: "info",
|
|
259
|
+
message: "No android/app/google-services.json found (OK if not using Firebase Analytics on Android)."
|
|
260
|
+
});
|
|
261
|
+
} else {
|
|
262
|
+
checks.push({
|
|
263
|
+
id: "android-firebase-json",
|
|
264
|
+
status: "pass",
|
|
265
|
+
message: "Found android/app/google-services.json."
|
|
266
|
+
});
|
|
267
|
+
const appGradle = readTextIfExists(path.join(cwd, "android/app/build.gradle")) ?? "";
|
|
268
|
+
if (appGradle.includes("com.google.gms.google-services")) {
|
|
269
|
+
checks.push({
|
|
270
|
+
id: "android-gms-plugin",
|
|
271
|
+
status: "pass",
|
|
272
|
+
message: "com.google.gms.google-services plugin is applied in android/app/build.gradle."
|
|
273
|
+
});
|
|
274
|
+
} else {
|
|
275
|
+
checks.push({
|
|
276
|
+
id: "android-gms-plugin",
|
|
277
|
+
status: "fail",
|
|
278
|
+
message: "google-services.json exists, but com.google.gms.google-services is not applied in android/app/build.gradle."
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
if (appGradle.includes("firebase-analytics")) {
|
|
282
|
+
checks.push({
|
|
283
|
+
id: "android-firebase-dep",
|
|
284
|
+
status: "pass",
|
|
285
|
+
message: "firebase-analytics dependency found in android/app/build.gradle."
|
|
286
|
+
});
|
|
287
|
+
} else {
|
|
288
|
+
checks.push({
|
|
289
|
+
id: "android-firebase-dep",
|
|
290
|
+
status: "fail",
|
|
291
|
+
message: "firebase-analytics dependency is missing from android/app/build.gradle.",
|
|
292
|
+
hint: "Add `implementation platform('com.google.firebase:firebase-bom:35.2.0')` and `implementation 'com.google.firebase:firebase-analytics'`."
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
const manifest = readTextIfExists(path.join(cwd, "android/app/src/main/AndroidManifest.xml")) ?? "";
|
|
296
|
+
if (manifest.includes("firebase_analytics_collection_enabled") && manifest.includes('android:value="false"')) {
|
|
297
|
+
checks.push({
|
|
298
|
+
id: "android-collection-flag",
|
|
299
|
+
status: "info",
|
|
300
|
+
message: "firebase_analytics_collection_enabled is false in AndroidManifest.xml (consent-first mode)."
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const appGradleAny = readTextIfExists(path.join(cwd, "android/app/build.gradle")) ?? "";
|
|
305
|
+
const manifestAny = readTextIfExists(path.join(cwd, "android/app/src/main/AndroidManifest.xml")) ?? "";
|
|
306
|
+
if (appGradleAny.includes("play-services-games-v2")) {
|
|
307
|
+
if (manifestAny.includes("com.google.android.gms.games.APP_ID")) {
|
|
308
|
+
const stringsXml = readTextIfExists(path.join(cwd, "android/app/src/main/res/values/strings.xml")) ?? "";
|
|
309
|
+
if (stringsXml.includes(">000000000000<")) {
|
|
310
|
+
checks.push({
|
|
311
|
+
id: "android-play-games-id",
|
|
312
|
+
status: "warn",
|
|
313
|
+
message: "Play Games Services project ID is still a placeholder (000000000000) in strings.xml.",
|
|
314
|
+
hint: "Replace it with your numeric Project ID from Google Play Console -> Play Games Services."
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
checks.push({
|
|
318
|
+
id: "android-play-games-id",
|
|
319
|
+
status: "pass",
|
|
320
|
+
message: "Play Games Services v2 dependency and APP_ID meta-data are configured."
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
checks.push({
|
|
325
|
+
id: "android-play-games-id",
|
|
326
|
+
status: "fail",
|
|
327
|
+
message: "play-services-games-v2 is in build.gradle, but com.google.android.gms.games.APP_ID is missing in AndroidManifest.xml.",
|
|
328
|
+
hint: 'Add <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/game_services_project_id" /> inside <application>.'
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (allDeps["@capacitor-community/admob"]) {
|
|
333
|
+
const stylesXml = readTextIfExists(path.join(cwd, "android/app/src/main/res/values/styles.xml")) ?? "";
|
|
334
|
+
if (stylesXml.includes('android:background">@null<')) {
|
|
335
|
+
checks.push({
|
|
336
|
+
id: "android-admob-styles-bg",
|
|
337
|
+
status: "pass",
|
|
338
|
+
message: 'android/app/src/main/res/values/styles.xml sets android:background="@null" (prevents floating AdMob banner bug).'
|
|
339
|
+
});
|
|
340
|
+
} else if (stylesXml) {
|
|
341
|
+
checks.push({
|
|
342
|
+
id: "android-admob-styles-bg",
|
|
343
|
+
status: "warn",
|
|
344
|
+
message: '@capacitor-community/admob is installed, but styles.xml is missing <item name="android:background">@null</item>.',
|
|
345
|
+
hint: 'Add <item name="android:background">@null</item> to AppTheme.NoActionBar so AdView does not inherit splash background and float.'
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const ok = !checks.some((c) => c.status === "fail");
|
|
351
|
+
return { cwd, ok, capacitorVersion: capVersion, hasIos, hasAndroid, checks };
|
|
352
|
+
}
|
|
353
|
+
function generateStarterContent(options) {
|
|
354
|
+
const lines = [];
|
|
355
|
+
const exportsList = [];
|
|
356
|
+
lines.push("import { createSima } from '@cond/simasdk';");
|
|
357
|
+
if (options.firebase) {
|
|
358
|
+
lines.push("import { firebaseAnalytics } from '@cond/simasdk/firebase';");
|
|
359
|
+
}
|
|
360
|
+
if (options.review) {
|
|
361
|
+
lines.push("import { createReviewPolicy } from '@cond/simasdk/review';");
|
|
362
|
+
}
|
|
363
|
+
if (options.haptics) {
|
|
364
|
+
lines.push("import { createHaptics } from '@cond/simasdk/haptics';");
|
|
365
|
+
}
|
|
366
|
+
if (options.storage) {
|
|
367
|
+
lines.push("import { createStorage } from '@cond/simasdk/storage';");
|
|
368
|
+
}
|
|
369
|
+
if (options.shell) {
|
|
370
|
+
lines.push("import { initShell } from '@cond/simasdk/shell';");
|
|
371
|
+
}
|
|
372
|
+
if (options.backButton) {
|
|
373
|
+
lines.push("import { attachCapacitorBackButton } from '@cond/simasdk/back-button';");
|
|
374
|
+
}
|
|
375
|
+
if (options.ads) {
|
|
376
|
+
lines.push("import { createAdPolicy } from '@cond/simasdk/ads';");
|
|
377
|
+
}
|
|
378
|
+
lines.push("");
|
|
379
|
+
if (options.firebase) {
|
|
380
|
+
lines.push("export const sima = createSima({");
|
|
381
|
+
lines.push(" analytics: firebaseAnalytics(),");
|
|
382
|
+
lines.push(" onError(error) {");
|
|
383
|
+
lines.push(" console.warn('[simasdk]', error.code, error.message);");
|
|
384
|
+
lines.push(" },");
|
|
385
|
+
lines.push("});");
|
|
386
|
+
} else {
|
|
387
|
+
lines.push("export const sima = createSima();");
|
|
388
|
+
}
|
|
389
|
+
exportsList.push("sima");
|
|
390
|
+
if (options.review) {
|
|
391
|
+
lines.push("");
|
|
392
|
+
lines.push("export const review = createReviewPolicy({");
|
|
393
|
+
lines.push(" key: 'primary_success',");
|
|
394
|
+
lines.push(" minimumActions: 3,");
|
|
395
|
+
lines.push(" cooldownDays: 90,");
|
|
396
|
+
lines.push("});");
|
|
397
|
+
exportsList.push("review");
|
|
398
|
+
}
|
|
399
|
+
if (options.haptics) {
|
|
400
|
+
lines.push("");
|
|
401
|
+
lines.push("export const haptics = createHaptics();");
|
|
402
|
+
exportsList.push("haptics");
|
|
403
|
+
}
|
|
404
|
+
if (options.storage) {
|
|
405
|
+
lines.push("");
|
|
406
|
+
lines.push("export const settingsStore = createStorage({ namespace: 'settings', version: 1 });");
|
|
407
|
+
exportsList.push("settingsStore");
|
|
408
|
+
}
|
|
409
|
+
if (options.ads) {
|
|
410
|
+
lines.push("");
|
|
411
|
+
lines.push("export const interstitialAds = createAdPolicy({");
|
|
412
|
+
lines.push(" key: 'main_interstitial',");
|
|
413
|
+
lines.push(" interstitialAdId: {");
|
|
414
|
+
lines.push(" ios: 'ca-app-pub-REPLACE_WITH_IOS_AD_UNIT',");
|
|
415
|
+
lines.push(" android: 'ca-app-pub-REPLACE_WITH_ANDROID_AD_UNIT',");
|
|
416
|
+
lines.push(" },");
|
|
417
|
+
lines.push(" minActionsBeforeFirst: 2,");
|
|
418
|
+
lines.push(" actionsBetweenAds: 3,");
|
|
419
|
+
lines.push(" cooldownSeconds: 90,");
|
|
420
|
+
lines.push("});");
|
|
421
|
+
exportsList.push("interstitialAds");
|
|
422
|
+
}
|
|
423
|
+
if (options.shell || options.backButton) {
|
|
424
|
+
lines.push("");
|
|
425
|
+
lines.push("export async function bootstrapNativeShell() {");
|
|
426
|
+
if (options.shell) {
|
|
427
|
+
lines.push(" await initShell({ statusBarStyle: 'dark', hideSplash: true });");
|
|
428
|
+
}
|
|
429
|
+
if (options.backButton) {
|
|
430
|
+
lines.push(" await attachCapacitorBackButton();");
|
|
431
|
+
}
|
|
432
|
+
lines.push("}");
|
|
433
|
+
}
|
|
434
|
+
lines.push("");
|
|
435
|
+
return lines.join("\n");
|
|
436
|
+
}
|
|
437
|
+
function runInit(options) {
|
|
438
|
+
const target = path.resolve(options.cwd, options.outFile ?? "src/sima.ts");
|
|
439
|
+
const existed = fs.existsSync(target);
|
|
440
|
+
if (existed && !options.force) {
|
|
441
|
+
throw new Error(`File already exists: ${target}. Pass --force to overwrite.`);
|
|
442
|
+
}
|
|
443
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
444
|
+
fs.writeFileSync(target, generateStarterContent(options), "utf8");
|
|
445
|
+
return { writtenPath: target, existed };
|
|
446
|
+
}
|
|
447
|
+
function getBundledSkillPath() {
|
|
448
|
+
return fileURLToPath(new URL("../skills/simasdk/SKILL.md", import.meta.url));
|
|
449
|
+
}
|
|
450
|
+
function resolveSkillDestinations(options) {
|
|
451
|
+
const { scope, targets, cwd, homeDir } = options;
|
|
452
|
+
const destinations = [];
|
|
453
|
+
for (const target of targets) {
|
|
454
|
+
if (scope === "local") {
|
|
455
|
+
if (target === "agents") {
|
|
456
|
+
destinations.push(path.join(cwd, ".agents", "skills", "simasdk", "SKILL.md"));
|
|
457
|
+
} else if (target === "claude") {
|
|
458
|
+
destinations.push(path.join(cwd, ".claude", "skills", "simasdk", "SKILL.md"));
|
|
459
|
+
} else if (target === "gemini") {
|
|
460
|
+
destinations.push(path.join(cwd, ".gemini", "skills", "simasdk", "SKILL.md"));
|
|
461
|
+
} else if (target === "cursor") {
|
|
462
|
+
destinations.push(path.join(cwd, ".cursor", "skills", "simasdk", "SKILL.md"));
|
|
463
|
+
}
|
|
464
|
+
} else {
|
|
465
|
+
if (target === "agents") {
|
|
466
|
+
destinations.push(path.join(homeDir, ".agents", "skills", "simasdk", "SKILL.md"));
|
|
467
|
+
} else if (target === "claude") {
|
|
468
|
+
destinations.push(path.join(homeDir, ".claude", "skills", "simasdk", "SKILL.md"));
|
|
469
|
+
} else if (target === "gemini") {
|
|
470
|
+
destinations.push(path.join(homeDir, ".gemini", "config", "skills", "simasdk", "SKILL.md"));
|
|
471
|
+
} else if (target === "cursor") {
|
|
472
|
+
destinations.push(path.join(homeDir, ".cursor", "skills", "simasdk", "SKILL.md"));
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return Array.from(new Set(destinations));
|
|
477
|
+
}
|
|
478
|
+
function runSkillInstall(options) {
|
|
479
|
+
const sourcePath = getBundledSkillPath();
|
|
480
|
+
if (!fs.existsSync(sourcePath)) {
|
|
481
|
+
throw new Error(`Bundled SKILL.md not found at ${sourcePath}`);
|
|
482
|
+
}
|
|
483
|
+
const content = fs.readFileSync(sourcePath, "utf8");
|
|
484
|
+
const targets = options.targets && options.targets.length > 0 ? options.targets : ["agents"];
|
|
485
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
486
|
+
const homeDir = path.resolve(options.homeDir ?? os.homedir());
|
|
487
|
+
const destinations = resolveSkillDestinations({
|
|
488
|
+
scope: options.scope,
|
|
489
|
+
targets,
|
|
490
|
+
cwd,
|
|
491
|
+
homeDir
|
|
492
|
+
});
|
|
493
|
+
const writtenPaths = [];
|
|
494
|
+
const skippedPaths = [];
|
|
495
|
+
for (const dest of destinations) {
|
|
496
|
+
if (fs.existsSync(dest) && !options.force) {
|
|
497
|
+
skippedPaths.push(dest);
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
501
|
+
fs.writeFileSync(dest, content, "utf8");
|
|
502
|
+
writtenPaths.push(dest);
|
|
503
|
+
}
|
|
504
|
+
return { writtenPaths, skippedPaths };
|
|
505
|
+
}
|
|
506
|
+
function runSkillUninstall(options) {
|
|
507
|
+
const targets = options.targets && options.targets.length > 0 ? options.targets : ["agents"];
|
|
508
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
509
|
+
const homeDir = path.resolve(options.homeDir ?? os.homedir());
|
|
510
|
+
const destinations = resolveSkillDestinations({
|
|
511
|
+
scope: options.scope,
|
|
512
|
+
targets,
|
|
513
|
+
cwd,
|
|
514
|
+
homeDir
|
|
515
|
+
});
|
|
516
|
+
const removedPaths = [];
|
|
517
|
+
for (const dest of destinations) {
|
|
518
|
+
if (fs.existsSync(dest)) {
|
|
519
|
+
fs.rmSync(dest, { force: true });
|
|
520
|
+
const skillDir = path.dirname(dest);
|
|
521
|
+
try {
|
|
522
|
+
if (fs.readdirSync(skillDir).length === 0) {
|
|
523
|
+
fs.rmdirSync(skillDir);
|
|
524
|
+
}
|
|
525
|
+
} catch {
|
|
526
|
+
}
|
|
527
|
+
removedPaths.push(dest);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return { removedPaths };
|
|
531
|
+
}
|
|
532
|
+
function parseSkillTargets(raw) {
|
|
533
|
+
if (!raw || raw === "agents") return ["agents"];
|
|
534
|
+
if (raw === "all") return ["agents", "claude", "gemini", "cursor"];
|
|
535
|
+
const items = raw.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
536
|
+
const valid = [];
|
|
537
|
+
for (const item of items) {
|
|
538
|
+
if (item === "antigravity" || item === "gemini") {
|
|
539
|
+
valid.push("gemini");
|
|
540
|
+
} else if (item === "agents" || item === "claude" || item === "cursor") {
|
|
541
|
+
valid.push(item);
|
|
542
|
+
} else {
|
|
543
|
+
throw new Error(
|
|
544
|
+
`Unknown --target "${item}". Supported: agents, claude, gemini (antigravity), cursor, all.`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return valid.length > 0 ? valid : ["agents"];
|
|
549
|
+
}
|
|
550
|
+
function useColor() {
|
|
551
|
+
return Boolean(process.stdout.isTTY) && !process.env["NO_COLOR"];
|
|
552
|
+
}
|
|
553
|
+
function badge(status) {
|
|
554
|
+
const c = useColor();
|
|
555
|
+
if (status === "pass") return c ? "\x1B[32mPASS\x1B[0m" : "PASS";
|
|
556
|
+
if (status === "warn") return c ? "\x1B[33mWARN\x1B[0m" : "WARN";
|
|
557
|
+
if (status === "fail") return c ? "\x1B[31mFAIL\x1B[0m" : "FAIL";
|
|
558
|
+
return c ? "\x1B[36mINFO\x1B[0m" : "INFO";
|
|
559
|
+
}
|
|
560
|
+
function printHelp() {
|
|
561
|
+
console.log(`simasdk CLI
|
|
562
|
+
|
|
563
|
+
Usage:
|
|
564
|
+
simasdk doctor [--json] [--cwd <dir>]
|
|
565
|
+
Audit a Capacitor project for simasdk plugin sync, iOS/Android Firebase config,
|
|
566
|
+
Bundle ID mismatches, and consent flags.
|
|
567
|
+
|
|
568
|
+
simasdk init [options]
|
|
569
|
+
Generate a starter src/sima.ts file.
|
|
570
|
+
Options:
|
|
571
|
+
--out <path> Output file path (default: src/sima.ts)
|
|
572
|
+
--firebase Include firebaseAnalytics() adapter
|
|
573
|
+
--review Include createReviewPolicy() (default: true if no flags passed)
|
|
574
|
+
--haptics Include createHaptics()
|
|
575
|
+
--storage Include createStorage()
|
|
576
|
+
--shell Include initShell()
|
|
577
|
+
--back-button Include attachCapacitorBackButton()
|
|
578
|
+
--ads Include createAdPolicy()
|
|
579
|
+
--all Include all modules
|
|
580
|
+
--force Overwrite existing file
|
|
581
|
+
|
|
582
|
+
simasdk skill install [--local | --global] [--target <agents|claude|gemini|cursor|all>] [--force]
|
|
583
|
+
Install the bundled simasdk SKILL.md locally into the project or globally in your home directory.
|
|
584
|
+
|
|
585
|
+
simasdk skill uninstall [--local | --global] [--target <agents|claude|gemini|cursor|all>]
|
|
586
|
+
Remove the installed simasdk SKILL.md.
|
|
587
|
+
|
|
588
|
+
simasdk skill path
|
|
589
|
+
Print the absolute path to the bundled SKILL.md.
|
|
590
|
+
|
|
591
|
+
simasdk --help | --version
|
|
592
|
+
`);
|
|
593
|
+
}
|
|
594
|
+
function parseFlagValue(args, flag) {
|
|
595
|
+
const idx = args.indexOf(flag);
|
|
596
|
+
if (idx === -1 || idx + 1 >= args.length) return void 0;
|
|
597
|
+
return args[idx + 1];
|
|
598
|
+
}
|
|
599
|
+
function main(argv = process.argv.slice(2)) {
|
|
600
|
+
const command = argv[0];
|
|
601
|
+
if (!command || command === "--help" || command === "-h" || command === "help") {
|
|
602
|
+
printHelp();
|
|
603
|
+
return 0;
|
|
604
|
+
}
|
|
605
|
+
if (command === "--version" || command === "-v") {
|
|
606
|
+
const pkgPath = new URL("../package.json", import.meta.url);
|
|
607
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
608
|
+
console.log(pkg.version ?? "0.2.0");
|
|
609
|
+
return 0;
|
|
610
|
+
}
|
|
611
|
+
if (command === "doctor") {
|
|
612
|
+
const cwd = path.resolve(parseFlagValue(argv, "--cwd") ?? process.cwd());
|
|
613
|
+
const asJson = argv.includes("--json");
|
|
614
|
+
const report = runDoctor(cwd);
|
|
615
|
+
if (asJson) {
|
|
616
|
+
console.log(JSON.stringify(report, null, 2));
|
|
617
|
+
} else {
|
|
618
|
+
console.log(`simasdk doctor (${report.cwd})
|
|
619
|
+
`);
|
|
620
|
+
for (const check of report.checks) {
|
|
621
|
+
console.log(` [${badge(check.status)}] ${check.message}`);
|
|
622
|
+
if (check.hint) {
|
|
623
|
+
console.log(` -> ${check.hint}`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
console.log("");
|
|
627
|
+
console.log(report.ok ? "Result: OK" : "Result: Issues found (see FAIL items above).");
|
|
628
|
+
}
|
|
629
|
+
return report.ok ? 0 : 1;
|
|
630
|
+
}
|
|
631
|
+
if (command === "init") {
|
|
632
|
+
const cwd = path.resolve(parseFlagValue(argv, "--cwd") ?? process.cwd());
|
|
633
|
+
const outFile = parseFlagValue(argv, "--out");
|
|
634
|
+
const all = argv.includes("--all");
|
|
635
|
+
const anySpecific = all || argv.includes("--firebase") || argv.includes("--review") || argv.includes("--haptics") || argv.includes("--storage") || argv.includes("--shell") || argv.includes("--back-button") || argv.includes("--ads");
|
|
636
|
+
try {
|
|
637
|
+
const { writtenPath } = runInit({
|
|
638
|
+
cwd,
|
|
639
|
+
outFile,
|
|
640
|
+
firebase: all || argv.includes("--firebase"),
|
|
641
|
+
review: all || argv.includes("--review") || !anySpecific,
|
|
642
|
+
haptics: all || argv.includes("--haptics"),
|
|
643
|
+
storage: all || argv.includes("--storage"),
|
|
644
|
+
shell: all || argv.includes("--shell"),
|
|
645
|
+
backButton: all || argv.includes("--back-button"),
|
|
646
|
+
ads: all || argv.includes("--ads"),
|
|
647
|
+
force: argv.includes("--force")
|
|
648
|
+
});
|
|
649
|
+
console.log(`Created ${writtenPath}`);
|
|
650
|
+
return 0;
|
|
651
|
+
} catch (err) {
|
|
652
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
653
|
+
return 1;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (command === "skill") {
|
|
657
|
+
const subcommand = argv[1];
|
|
658
|
+
if (subcommand === "path") {
|
|
659
|
+
console.log(getBundledSkillPath());
|
|
660
|
+
return 0;
|
|
661
|
+
}
|
|
662
|
+
const isGlobal = argv.includes("--global") || argv.includes("-g");
|
|
663
|
+
const scope = isGlobal ? "global" : "local";
|
|
664
|
+
const cwd = path.resolve(parseFlagValue(argv, "--cwd") ?? process.cwd());
|
|
665
|
+
if (subcommand === "install") {
|
|
666
|
+
try {
|
|
667
|
+
const targets = parseSkillTargets(parseFlagValue(argv, "--target"));
|
|
668
|
+
const { writtenPaths, skippedPaths } = runSkillInstall({
|
|
669
|
+
scope,
|
|
670
|
+
targets,
|
|
671
|
+
cwd,
|
|
672
|
+
force: argv.includes("--force")
|
|
673
|
+
});
|
|
674
|
+
for (const p of writtenPaths) {
|
|
675
|
+
console.log(`Installed skill (${scope}): ${p}`);
|
|
676
|
+
}
|
|
677
|
+
for (const p of skippedPaths) {
|
|
678
|
+
console.log(`Skipped existing skill (pass --force to overwrite): ${p}`);
|
|
679
|
+
}
|
|
680
|
+
return 0;
|
|
681
|
+
} catch (err) {
|
|
682
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
683
|
+
return 1;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (subcommand === "uninstall" || subcommand === "remove") {
|
|
687
|
+
try {
|
|
688
|
+
const targets = parseSkillTargets(parseFlagValue(argv, "--target"));
|
|
689
|
+
const { removedPaths } = runSkillUninstall({ scope, targets, cwd });
|
|
690
|
+
if (removedPaths.length === 0) {
|
|
691
|
+
console.log(`No installed simasdk skill found (${scope}).`);
|
|
692
|
+
} else {
|
|
693
|
+
for (const p of removedPaths) {
|
|
694
|
+
console.log(`Removed skill (${scope}): ${p}`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return 0;
|
|
698
|
+
} catch (err) {
|
|
699
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
700
|
+
return 1;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
console.error("Usage: simasdk skill <install|uninstall|path> [--local|--global] [--target <agents|claude|gemini|cursor|all>]");
|
|
704
|
+
return 1;
|
|
705
|
+
}
|
|
706
|
+
console.error(`Unknown command: ${command}`);
|
|
707
|
+
printHelp();
|
|
708
|
+
return 1;
|
|
709
|
+
}
|
|
710
|
+
var isDirectRun = typeof process !== "undefined" && process.argv[1] && (process.argv[1].endsWith("cli.js") || process.argv[1].endsWith("simasdk"));
|
|
711
|
+
if (isDirectRun) {
|
|
712
|
+
process.exitCode = main();
|
|
713
|
+
}
|
|
714
|
+
export {
|
|
715
|
+
generateStarterContent,
|
|
716
|
+
getBundledSkillPath,
|
|
717
|
+
main,
|
|
718
|
+
resolveSkillDestinations,
|
|
719
|
+
runDoctor,
|
|
720
|
+
runInit,
|
|
721
|
+
runSkillInstall,
|
|
722
|
+
runSkillUninstall
|
|
723
|
+
};
|