@akanjs/cli 2.4.0 → 2.4.1-rc.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.
Files changed (59) hide show
  1. package/agent.command-h4afc69n.js +26 -0
  2. package/application.command-4ctkfdan.js +165 -0
  3. package/applicationBuildRunner-esa1kj7v.js +284 -0
  4. package/applicationReleasePackager-brvth6rs.js +245 -0
  5. package/capacitorApp-y0h6cgft.js +58 -0
  6. package/cloud.command-rpztn4fh.js +94 -0
  7. package/commandManifest.json +1 -0
  8. package/context.command-nqbtak4f.js +82 -0
  9. package/dependencyScanner-m4x5maek.js +9 -0
  10. package/guideline.command-ya0dh44f.js +356 -0
  11. package/incrementalBuilder.proc.js +89 -17394
  12. package/index-1xdrsbry.js +1447 -0
  13. package/index-45aj5ry0.js +990 -0
  14. package/index-5vvwc0cz.js +559 -0
  15. package/index-61keag0s.js +40 -0
  16. package/index-6pz1j0zj.js +62 -0
  17. package/index-73pr2cmy.js +534 -0
  18. package/index-76rn3g2c.js +76 -0
  19. package/index-85msc0wg.js +161 -0
  20. package/index-8pkbzj26.js +840 -0
  21. package/index-8rc0bm04.js +514 -0
  22. package/index-9sp6fsc5.js +1884 -0
  23. package/index-a6sbyy0b.js +2769 -0
  24. package/index-b0brjbp3.js +83 -0
  25. package/index-fgc8r6dj.js +33 -0
  26. package/index-h6ca6qg0.js +2777 -0
  27. package/index-hdqztm58.js +758 -0
  28. package/index-hwzpw9c1.js +202 -0
  29. package/index-pmm9e2jf.js +120 -0
  30. package/index-qaq13qk3.js +80 -0
  31. package/index-qhtr07v8.js +1072 -0
  32. package/index-r24hmh0q.js +4 -0
  33. package/index-ss469dec.js +11 -0
  34. package/index-swf4bmbg.js +25 -0
  35. package/index-w7fyqjrw.js +462 -0
  36. package/index-wnp7hwq7.js +193 -0
  37. package/index-wq8jwx8z.js +224 -0
  38. package/index-x53a5nya.js +301 -0
  39. package/index-xmc2w32q.js +4359 -0
  40. package/index-y3hdhy4p.js +229 -0
  41. package/index.js +54 -23340
  42. package/library.command-r15zdqvp.js +33 -0
  43. package/localRegistry.command-5tcahs3f.js +178 -0
  44. package/module.command-qrj3kmyz.js +54 -0
  45. package/package.command-r8sq5kzp.js +43 -0
  46. package/package.json +2 -2
  47. package/page.command-c6xdx0xm.js +24 -0
  48. package/primitive.command-pv9ssmtf.js +62 -0
  49. package/quality.command-es67wvdp.js +809 -0
  50. package/repair.command-677675vw.js +67 -0
  51. package/routeSourceValidator-wbhmbwpj.js +132 -0
  52. package/scalar.command-kabkd6wd.js +35 -0
  53. package/templates/facetIndex/index.ts +1 -1
  54. package/typeChecker-kravn7ns.js +8 -0
  55. package/typecheck.proc.js +4 -194
  56. package/workflow.command-64r6cw0w.js +108 -0
  57. package/workspace.command-vrws0rgx.js +435 -0
  58. package/README.ko.md +0 -72
  59. package/README.md +0 -85
@@ -0,0 +1,1447 @@
1
+ // @bun
2
+ import {
3
+ resolveMobilePath,
4
+ targetHtmlFilename
5
+ } from "./index-76rn3g2c.js";
6
+ import {
7
+ CommandExecutionError
8
+ } from "./index-a6sbyy0b.js";
9
+
10
+ // pkgs/@akanjs/devkit/capacitorApp.ts
11
+ import { cp, mkdir, readFile, rm, writeFile } from "fs/promises";
12
+ import os from "os";
13
+ import path from "path";
14
+ import { select } from "@inquirer/prompts";
15
+ import { MobileProject } from "@trapezedev/project";
16
+ import { capitalize } from "akanjs/common";
17
+
18
+ // pkgs/@akanjs/devkit/fileEditor.ts
19
+ class FileEditor {
20
+ filePath;
21
+ content;
22
+ constructor(filePath, content) {
23
+ this.filePath = filePath;
24
+ this.content = content;
25
+ }
26
+ static async create(filePath) {
27
+ try {
28
+ const content = await Bun.file(filePath).text();
29
+ return new FileEditor(filePath, content);
30
+ } catch (error) {
31
+ throw new Error(`Failed to read file: ${filePath}`);
32
+ }
33
+ }
34
+ find(pattern) {
35
+ const lines = this.content.split(`
36
+ `);
37
+ const regex = typeof pattern === "string" ? new RegExp(pattern) : pattern;
38
+ for (let i = 0;i < lines.length; i++) {
39
+ const line = lines[i];
40
+ if (!line)
41
+ continue;
42
+ if (regex.test(line))
43
+ return i;
44
+ }
45
+ return -1;
46
+ }
47
+ findAll(pattern) {
48
+ const lines = this.content.split(`
49
+ `);
50
+ const regex = typeof pattern === "string" ? new RegExp(pattern) : pattern;
51
+ const matches = [];
52
+ for (let i = 0;i < lines.length; i++) {
53
+ const line = lines[i];
54
+ if (!line)
55
+ continue;
56
+ if (regex.test(line))
57
+ matches.push(i);
58
+ }
59
+ return matches;
60
+ }
61
+ insertAfter(pattern, data) {
62
+ const lineIndex = this.find(pattern);
63
+ if (lineIndex === -1) {
64
+ throw new Error(`Pattern not found: ${pattern}`);
65
+ }
66
+ const lines = this.content.split(`
67
+ `);
68
+ lines.splice(lineIndex + 1, 0, data);
69
+ this.content = lines.join(`
70
+ `);
71
+ return this;
72
+ }
73
+ insertBefore(pattern, data) {
74
+ const lineIndex = this.find(pattern);
75
+ if (lineIndex === -1) {
76
+ throw new Error(`Pattern not found: ${pattern}`);
77
+ }
78
+ const lines = this.content.split(`
79
+ `);
80
+ lines.splice(lineIndex, 0, data);
81
+ this.content = lines.join(`
82
+ `);
83
+ return this;
84
+ }
85
+ replace(pattern, replacement) {
86
+ const regex = typeof pattern === "string" ? new RegExp(pattern, "g") : pattern;
87
+ this.content = this.content.replace(regex, replacement);
88
+ return this;
89
+ }
90
+ append(data) {
91
+ this.content += `
92
+ ${data}`;
93
+ return this;
94
+ }
95
+ prepend(data) {
96
+ this.content = `${data}
97
+ ${this.content}`;
98
+ return this;
99
+ }
100
+ async save() {
101
+ try {
102
+ await Bun.write(this.filePath, this.content);
103
+ } catch (error) {
104
+ throw new Error(`Failed to save file: ${this.filePath}`);
105
+ }
106
+ }
107
+ getContent() {
108
+ return this.content;
109
+ }
110
+ setContent(content) {
111
+ this.content = content;
112
+ return this;
113
+ }
114
+ }
115
+
116
+ // pkgs/@akanjs/devkit/capacitorApp.ts
117
+ var SWIFTUICORE_MIN_IOS_MAJOR = 18;
118
+ var iosNativeBlockedEnvKeys = new Set([
119
+ "AR",
120
+ "AS",
121
+ "CC",
122
+ "CFLAGS",
123
+ "CONDA_BUILD_SYSROOT",
124
+ "CONDA_PREFIX",
125
+ "CPP",
126
+ "CPPFLAGS",
127
+ "CPATH",
128
+ "CXX",
129
+ "CXXFLAGS",
130
+ "LD",
131
+ "LDFLAGS",
132
+ "LIBRARY_PATH",
133
+ "MACOSX_DEPLOYMENT_TARGET",
134
+ "NM",
135
+ "OBJC",
136
+ "OBJCXX",
137
+ "PREFIX",
138
+ "RANLIB",
139
+ "SDKROOT",
140
+ "STRIP"
141
+ ]);
142
+ var rootCapacitorConfigFilenames = [
143
+ "capacitor.config.ts",
144
+ "capacitor.config.js",
145
+ "capacitor.config.json"
146
+ ];
147
+ var rootCapacitorConfigPaths = (appRoot) => rootCapacitorConfigFilenames.map((file) => path.join(appRoot, file));
148
+ async function clearRootCapacitorConfigs(appRoot) {
149
+ await Promise.all(rootCapacitorConfigPaths(appRoot).map((file) => rm(file, { force: true })));
150
+ }
151
+ async function writeRootCapacitorConfig(appRoot, content) {
152
+ await clearRootCapacitorConfigs(appRoot);
153
+ await Bun.write(path.join(appRoot, "capacitor.config.json"), content);
154
+ }
155
+ var virtualInterfacePrefixes = [
156
+ "bridge",
157
+ "utun",
158
+ "llw",
159
+ "awdl",
160
+ "ap",
161
+ "vmnet",
162
+ "vnic",
163
+ "tap",
164
+ "tun",
165
+ "docker",
166
+ "veth",
167
+ "vboxnet",
168
+ "gif",
169
+ "stf"
170
+ ];
171
+ var physicalInterfacePrefixes = ["en", "eth", "wlan", "wlp", "enp", "eno", "wlo"];
172
+ var isPrivateLanIpv4 = (address) => {
173
+ if (address.startsWith("10.") || address.startsWith("192.168."))
174
+ return true;
175
+ const secondOctet = Number(address.match(/^172\.(\d+)\./)?.[1]);
176
+ return Number.isFinite(secondOctet) && secondOctet >= 16 && secondOctet <= 31;
177
+ };
178
+ var scoreDevHostCandidate = (name, address) => {
179
+ const lowerName = name.toLowerCase();
180
+ let score = 0;
181
+ if (address.startsWith("169.254."))
182
+ score -= 1000;
183
+ if (virtualInterfacePrefixes.some((prefix) => lowerName.startsWith(prefix)))
184
+ score -= 100;
185
+ else if (physicalInterfacePrefixes.some((prefix) => lowerName.startsWith(prefix)))
186
+ score += 100;
187
+ if (isPrivateLanIpv4(address))
188
+ score += 10;
189
+ return score;
190
+ };
191
+ var selectLocalDevHost = (interfaces, { override } = {}) => {
192
+ const candidates = [];
193
+ for (const [name, aliases] of Object.entries(interfaces)) {
194
+ for (const alias of aliases ?? []) {
195
+ if (alias.family !== "IPv4" || alias.internal)
196
+ continue;
197
+ candidates.push({ name, address: alias.address });
198
+ }
199
+ }
200
+ const trimmedOverride = override?.trim();
201
+ if (trimmedOverride)
202
+ return { host: trimmedOverride, source: "override", candidates };
203
+ const [best] = [...candidates].sort((a, b) => scoreDevHostCandidate(b.name, b.address) - scoreDevHostCandidate(a.name, a.address) || a.name.localeCompare(b.name) || a.address.localeCompare(b.address));
204
+ return best ? { host: best.address, source: "detected", candidates } : { host: "127.0.0.1", source: "loopback", candidates };
205
+ };
206
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
207
+ var asString = (value) => typeof value === "string" ? value : undefined;
208
+ var firstString = (...values) => values.find((value) => typeof value === "string");
209
+ var scoreIosDeviceTarget = (target) => {
210
+ const state = target.state?.toLowerCase() ?? "";
211
+ return (state.includes("available") ? 4 : 0) + (state.includes("wired") ? 2 : 0) + (state.includes("paired") ? 1 : 0);
212
+ };
213
+ var dedupeIosRunTargets = (targets) => {
214
+ const byKey = new Map;
215
+ const runnableTargets = targets.filter((target) => !target.state?.toLowerCase().includes("unavailable"));
216
+ for (const target of runnableTargets) {
217
+ const key = target.xcodebuildId ?? target.id;
218
+ const current = byKey.get(key);
219
+ if (!current || scoreIosDeviceTarget(target) > scoreIosDeviceTarget(current))
220
+ byKey.set(key, target);
221
+ }
222
+ return [...byKey.values()];
223
+ };
224
+ var formatSimctlRuntime = (key) => {
225
+ if (!key)
226
+ return;
227
+ if (/^(iOS|watchOS|tvOS|visionOS)\s+[\d.]+$/i.test(key))
228
+ return key;
229
+ const match = key.match(/(iOS|watchOS|tvOS|visionOS)-(\d+)(?:-(\d+))?/i);
230
+ if (!match)
231
+ return;
232
+ return `${match[1]} ${match[2]}${match[3] ? `.${match[3]}` : ""}`;
233
+ };
234
+ var parseIosRuntimeMajor = (runtime) => {
235
+ const major = runtime?.match(/(\d+)/)?.[1];
236
+ if (major === undefined)
237
+ return;
238
+ const parsed = Number.parseInt(major, 10);
239
+ return Number.isNaN(parsed) ? undefined : parsed;
240
+ };
241
+ var iosRunTargetRank = (target) => {
242
+ const state = target.state?.toLowerCase() ?? "";
243
+ const ready = state.includes("booted") || state.includes("connected") || state.includes("available") ? 1000 : 0;
244
+ const device = target.kind === "device" ? 500 : 0;
245
+ return ready + device + (parseIosRuntimeMajor(target.runtime) ?? 0);
246
+ };
247
+ var sortIosRunTargets = (targets) => [...targets].sort((a, b) => iosRunTargetRank(b) - iosRunTargetRank(a) || a.name.localeCompare(b.name));
248
+ function walkRecords(value, visit) {
249
+ if (Array.isArray(value)) {
250
+ for (const item of value)
251
+ walkRecords(item, visit);
252
+ return;
253
+ }
254
+ if (!isRecord(value))
255
+ return;
256
+ visit(value);
257
+ for (const item of Object.values(value))
258
+ walkRecords(item, visit);
259
+ }
260
+ function parseDevicectlDevices(output) {
261
+ try {
262
+ const json = JSON.parse(output);
263
+ const targets = new Map;
264
+ walkRecords(json, (record) => {
265
+ const deviceProperties = isRecord(record.deviceProperties) ? record.deviceProperties : {};
266
+ const hardwareProperties = isRecord(record.hardwareProperties) ? record.hardwareProperties : {};
267
+ const connectionProperties = isRecord(record.connectionProperties) ? record.connectionProperties : {};
268
+ const devicectlId = firstString(record.identifier, record.deviceIdentifier);
269
+ const potentialHostnames = Array.isArray(connectionProperties.potentialHostnames) ? connectionProperties.potentialHostnames.filter((value) => typeof value === "string") : [];
270
+ const hostnameUdid = potentialHostnames.map((hostname) => hostname.match(/([0-9A-Fa-f]{8}-[0-9A-Fa-f]{16})\.coredevice\.local/)?.[1]).find((value) => Boolean(value));
271
+ const udid = firstString(hardwareProperties.udid, hostnameUdid, record.udid, record.UDID);
272
+ const id = udid ?? devicectlId;
273
+ const name = firstString(deviceProperties.name, record.name, record.deviceName, record.displayName);
274
+ if (!id || !name)
275
+ return;
276
+ const state = [
277
+ firstString(record.state, record.connectionState, record.availability, connectionProperties.tunnelState),
278
+ firstString(connectionProperties.transportType),
279
+ firstString(connectionProperties.pairingState)
280
+ ].filter(Boolean).join(" ");
281
+ targets.set(id, { id, name, kind: "device", state, devicectlId, xcodebuildId: udid ?? id });
282
+ });
283
+ return dedupeIosRunTargets([...targets.values()]);
284
+ } catch {
285
+ const targets = [];
286
+ for (const line of output.split(/\r?\n/)) {
287
+ const id = line.match(/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{16}|[0-9A-Fa-f-]{25,}/)?.[0];
288
+ if (!id)
289
+ continue;
290
+ const name = line.replace(id, "").replace(/[()]/g, " ").trim().replace(/\s+/g, " ") || id;
291
+ targets.push({ id, name, kind: "device" });
292
+ }
293
+ return dedupeIosRunTargets(targets);
294
+ }
295
+ }
296
+ function parseSimctlDevices(output) {
297
+ try {
298
+ const json = JSON.parse(output);
299
+ const devices = json.devices ?? {};
300
+ return Object.entries(devices).flatMap(([runtimeKey, list]) => {
301
+ const runtime = formatSimctlRuntime(runtimeKey);
302
+ return (Array.isArray(list) ? list : []).filter(isRecord).flatMap((device) => {
303
+ const id = firstString(device.udid, device.UDID, device.identifier);
304
+ const name = firstString(device.name, device.displayName);
305
+ const isAvailable = device.isAvailable !== false && device.availabilityError === undefined;
306
+ if (!id || !name || !isAvailable)
307
+ return [];
308
+ return [
309
+ {
310
+ id,
311
+ name,
312
+ kind: "simulator",
313
+ state: asString(device.state),
314
+ runtime: runtime ?? formatSimctlRuntime(asString(device.runtimeIdentifier))
315
+ }
316
+ ];
317
+ });
318
+ });
319
+ } catch {
320
+ const targets = [];
321
+ let runtime;
322
+ for (const line of output.split(/\r?\n/)) {
323
+ const header = line.match(/^--\s*(.+?)\s*--\s*$/);
324
+ if (header) {
325
+ runtime = formatSimctlRuntime(header[1]);
326
+ continue;
327
+ }
328
+ const match = line.match(/^\s*(.+?)\s+\(([0-9A-Fa-f-]{20,})\)\s+\(([^)]+)\)/);
329
+ if (!match)
330
+ continue;
331
+ targets.push({ id: match[2], name: match[1].trim(), kind: "simulator", state: match[3], runtime });
332
+ }
333
+ return targets;
334
+ }
335
+ }
336
+ function buildIosNativeRunCommand({
337
+ appRoot,
338
+ device,
339
+ scheme = "App",
340
+ configuration = "Debug"
341
+ }) {
342
+ const derivedDataPath = path.join(appRoot, "ios/DerivedData", device.id);
343
+ const productPlatform = device.kind === "device" ? "iphoneos" : "iphonesimulator";
344
+ const destination = device.kind === "device" ? `id=${device.xcodebuildId ?? device.id}` : `platform=iOS Simulator,id=${device.id}`;
345
+ return {
346
+ configuration,
347
+ derivedDataPath,
348
+ appPath: path.join(derivedDataPath, "Build/Products", `${configuration}-${productPlatform}`, "App.app"),
349
+ xcodebuildArgs: [
350
+ "-project",
351
+ "App.xcodeproj",
352
+ "-scheme",
353
+ scheme,
354
+ "-configuration",
355
+ configuration,
356
+ "-destination",
357
+ destination,
358
+ "-derivedDataPath",
359
+ derivedDataPath,
360
+ "build"
361
+ ]
362
+ };
363
+ }
364
+ function classifyIosRunFailure(log) {
365
+ const lower = log.toLowerCase();
366
+ if (lower.includes("swiftuicore") && (lower.includes("library not loaded") || lower.includes("library missing") || lower.includes("dyld"))) {
367
+ return {
368
+ kind: "simulator-runtime",
369
+ title: "App crashed loading SwiftUICore \u2014 the iOS runtime is too old.",
370
+ detail: `The build links SwiftUICore, which only exists on iOS ${SWIFTUICORE_MIN_IOS_MAJOR}+. Rerun on an iOS ${SWIFTUICORE_MIN_IOS_MAJOR} or newer simulator/device (pass --device to pick one non-interactively).`
371
+ };
372
+ }
373
+ if (lower.includes("unknown argument: '-index-store-path'") || lower.includes("compiler was not recognized")) {
374
+ return {
375
+ kind: "compiler-toolchain",
376
+ title: "iOS build is using a non-Xcode compiler from the shell environment.",
377
+ detail: "Akan removes common Conda/compiler environment variables for native iOS runs. If this persists, run outside the activated toolchain environment."
378
+ };
379
+ }
380
+ if (lower.includes("developer mode") && lower.includes("disabled")) {
381
+ return {
382
+ kind: "device-state",
383
+ title: "iOS device Developer Mode is disabled.",
384
+ detail: "Enable Developer Mode on the iPhone, then reconnect and run the command again."
385
+ };
386
+ }
387
+ if (lower.includes("untrusted") || lower.includes("not paired") || lower.includes("locked")) {
388
+ return {
389
+ kind: "device-state",
390
+ title: "iOS device is not ready for installation.",
391
+ detail: "Unlock the iPhone, trust this computer, and make sure the device is paired before retrying."
392
+ };
393
+ }
394
+ if (lower.includes('unable to find utility "devicectl"') || lower.includes("devicectl") && lower.includes("not found")) {
395
+ return {
396
+ kind: "devicectl-unavailable",
397
+ title: "Xcode devicectl is not available.",
398
+ detail: "Install a recent Xcode version and verify xcode-select points to that Xcode installation."
399
+ };
400
+ }
401
+ if (lower.includes("there are no accounts registered with xcode") || lower.includes("unable to log in with account")) {
402
+ return {
403
+ kind: "apple-account",
404
+ title: "Xcode Apple ID is not available.",
405
+ detail: "Sign in to an Apple ID in Xcode Settings > Accounts, then retry the Akan iOS command."
406
+ };
407
+ }
408
+ if (lower.includes("failed registering bundle identifier") || lower.includes("cannot be registered to your development team")) {
409
+ return {
410
+ kind: "bundle-identifier",
411
+ title: "iOS bundle identifier is not available for this Apple Developer Team.",
412
+ detail: "Change mobile appId to a globally unique bundle identifier that your team can register, then rerun the iOS command."
413
+ };
414
+ }
415
+ if (lower.includes("does not have permission") || lower.includes("your account") && lower.includes("permission")) {
416
+ return {
417
+ kind: "team-permission",
418
+ title: "Apple Developer Team permission is missing.",
419
+ detail: "Check that the signed-in Apple ID has permission for the selected DEVELOPMENT_TEAM."
420
+ };
421
+ }
422
+ if (lower.includes("license agreement") || lower.includes("program license agreement")) {
423
+ return {
424
+ kind: "license-agreement",
425
+ title: "Apple Developer Program license agreement is not accepted.",
426
+ detail: "Accept the latest Apple Developer Program license agreement, then retry."
427
+ };
428
+ }
429
+ if (lower.includes("no signing certificate") || lower.includes("doesn't include signing certificate")) {
430
+ return {
431
+ kind: "certificate",
432
+ title: "iOS development signing certificate is missing.",
433
+ detail: "Create or download an Apple Development certificate for the selected team."
434
+ };
435
+ }
436
+ if (lower.includes("device") && lower.includes("not") && lower.includes("registered")) {
437
+ return {
438
+ kind: "device-registration",
439
+ title: "iPhone is not registered in the provisioning profile.",
440
+ detail: "Allow provisioning updates with a team that can register this device, or register the device manually."
441
+ };
442
+ }
443
+ if (lower.includes("no profiles for") || lower.includes("requires a provisioning profile")) {
444
+ return {
445
+ kind: "provisioning-profile",
446
+ title: "Matching iOS provisioning profile was not found.",
447
+ detail: "Akan can request Xcode provisioning updates for physical devices, but the Apple account and team must be valid."
448
+ };
449
+ }
450
+ return {
451
+ kind: "unknown",
452
+ title: "iOS native run failed.",
453
+ detail: "Review the xcodebuild/devicectl output above. You can retry with --noAllowProvisioningUpdates to use the conservative path."
454
+ };
455
+ }
456
+ function formatIosRunFailureMessage(input) {
457
+ return [
458
+ input.classification.title,
459
+ input.classification.detail,
460
+ `Mobile target: ${input.targetName}`,
461
+ `Bundle ID: ${input.appId}`,
462
+ input.teamId ? `Development Team: ${input.teamId}` : null,
463
+ "Capacitor is still used for native project generation and sync; Akan only runs the native build/install step directly."
464
+ ].filter((line) => Boolean(line)).join(`
465
+ `);
466
+ }
467
+ function sanitizeIosNativeRunEnv(env) {
468
+ return Object.fromEntries(Object.entries(env).filter(([key]) => !iosNativeBlockedEnvKeys.has(key)));
469
+ }
470
+ var PLACEHOLDER_APP_IDS = [
471
+ "com.myapp.app",
472
+ "com.myorg.myapp",
473
+ "com.example.app",
474
+ "com.example.myapp"
475
+ ];
476
+ var placeholderAppIdSegment = /^(example|examples|myorg|myapp|mycompany|myorganization|changeme|todo|sample|test)$/;
477
+ var isPlaceholderAppId = (appId) => {
478
+ const normalized = appId?.trim().toLowerCase() ?? "";
479
+ if (!normalized)
480
+ return true;
481
+ if (PLACEHOLDER_APP_IDS.includes(normalized))
482
+ return true;
483
+ return normalized.split(".").some((segment) => placeholderAppIdSegment.test(segment));
484
+ };
485
+ var androidReleaseSigningKeys = [
486
+ "MYAPP_RELEASE_STORE_FILE",
487
+ "MYAPP_RELEASE_STORE_PASSWORD",
488
+ "MYAPP_RELEASE_KEY_ALIAS",
489
+ "MYAPP_RELEASE_KEY_PASSWORD"
490
+ ];
491
+ function getMissingAndroidReleaseSigningKeys({
492
+ env = process.env,
493
+ gradleProperties = ""
494
+ } = {}) {
495
+ return androidReleaseSigningKeys.filter((key) => {
496
+ const gradleEnvKey = `ORG_GRADLE_PROJECT_${key}`;
497
+ return env[key] === undefined && env[gradleEnvKey] === undefined && !new RegExp(`^\\s*${key}\\s*=`, "m").test(gradleProperties);
498
+ });
499
+ }
500
+ function formatAndroidReleaseSigningError(missingKeys) {
501
+ return [
502
+ "Android release signing configuration is incomplete.",
503
+ `Missing: ${missingKeys.join(", ")}`,
504
+ "Set these values in android/gradle.properties or ORG_GRADLE_PROJECT_* environment variables before building a release artifact."
505
+ ].join(`
506
+ `);
507
+ }
508
+ function getAdbDeviceStateIssues(output) {
509
+ return output.split(/\r?\n/).map((line) => line.trim().split(/\s+/)).filter(([id, state]) => id && state && id !== "List").flatMap(([id, state]) => {
510
+ if (state === "unauthorized")
511
+ return [`Android device ${id} is unauthorized. Confirm USB debugging authorization on the device.`];
512
+ if (state === "offline")
513
+ return [`Android device ${id} is offline. Reconnect the device or restart adb.`];
514
+ return [];
515
+ });
516
+ }
517
+ var ANDROID_MIN_SDK_VERSION = 26;
518
+ function raiseGradleMinSdkVersion(content, floor = ANDROID_MIN_SDK_VERSION) {
519
+ const match = content.match(/minSdkVersion\s*=\s*(\d+)/);
520
+ if (!match?.[1])
521
+ return null;
522
+ const current = Number.parseInt(match[1], 10);
523
+ if (Number.isNaN(current) || current >= floor)
524
+ return null;
525
+ return content.replace(/(minSdkVersion\s*=\s*)\d+/, `$1${floor}`);
526
+ }
527
+ var mergeAllowNavigation = (configured, localIp) => {
528
+ const values = Array.isArray(configured) ? configured.filter((value) => typeof value === "string") : [];
529
+ if (localIp)
530
+ values.push(localIp);
531
+ values.push("localhost");
532
+ return [...new Set(values)];
533
+ };
534
+ function assertJsonSerializable(value, label = "capacitor.config", seen = new WeakSet) {
535
+ if (value === null)
536
+ return;
537
+ const valueType = typeof value;
538
+ if (valueType === "function" || valueType === "symbol" || valueType === "bigint" || valueType === "undefined") {
539
+ throw new Error(`${label} must be JSON serializable. Found ${valueType}.`);
540
+ }
541
+ if (valueType === "number" && !Number.isFinite(value)) {
542
+ throw new Error(`${label} must be JSON serializable. Found non-finite number.`);
543
+ }
544
+ if (valueType !== "object")
545
+ return;
546
+ const objectValue = value;
547
+ if (seen.has(objectValue))
548
+ throw new Error(`${label} must be JSON serializable. Found circular reference.`);
549
+ seen.add(objectValue);
550
+ if (Array.isArray(value)) {
551
+ value.forEach((item, index) => {
552
+ assertJsonSerializable(item, `${label}[${index}]`, seen);
553
+ });
554
+ return;
555
+ }
556
+ for (const [key, item] of Object.entries(value)) {
557
+ assertJsonSerializable(item, `${label}.${key}`, seen);
558
+ }
559
+ }
560
+ function materializeCapacitorConfig(target, { operation, localServerUrl, localIp }) {
561
+ const {
562
+ name,
563
+ basePath: _basePath,
564
+ indexPath: _indexPath,
565
+ version: _version,
566
+ buildNum: _buildNum,
567
+ assets: _assets,
568
+ permissions: _permissions,
569
+ deepLinks: _deepLinks,
570
+ files: _files,
571
+ appId,
572
+ appName,
573
+ webDir: _webDir,
574
+ plugins,
575
+ server,
576
+ android,
577
+ ios,
578
+ cordova,
579
+ experimental,
580
+ ...capacitorConfig
581
+ } = target;
582
+ const serverConfig = isRecord(server) ? server : undefined;
583
+ const cordovaConfig = isRecord(cordova) ? cordova : undefined;
584
+ const experimentalConfig = isRecord(experimental) ? experimental : undefined;
585
+ const pluginsConfig = isRecord(plugins) ? plugins : {};
586
+ const keyboardPluginConfig = isRecord(pluginsConfig.Keyboard) ? pluginsConfig.Keyboard : {};
587
+ const pushNotificationsPluginConfig = isRecord(pluginsConfig.PushNotifications) ? pluginsConfig.PushNotifications : {};
588
+ const usesPushNotifications = target.permissions?.includes("push") ?? false;
589
+ const config = {
590
+ ...capacitorConfig,
591
+ appId,
592
+ appName,
593
+ webDir: path.posix.join(".akan", "mobile", name, "www"),
594
+ plugins: {
595
+ CapacitorCookies: { enabled: true },
596
+ ...pluginsConfig,
597
+ ...usesPushNotifications || isRecord(pluginsConfig.PushNotifications) ? {
598
+ PushNotifications: {
599
+ ...usesPushNotifications ? { presentationOptions: ["badge", "sound", "alert"] } : {},
600
+ ...pushNotificationsPluginConfig
601
+ }
602
+ } : {},
603
+ Keyboard: {
604
+ resize: "none",
605
+ ...keyboardPluginConfig
606
+ }
607
+ },
608
+ android: {
609
+ ...isRecord(android) ? android : {},
610
+ path: "android"
611
+ },
612
+ ios: {
613
+ ...isRecord(ios) ? ios : {},
614
+ path: "ios"
615
+ }
616
+ };
617
+ if (operation === "local") {
618
+ if (!localServerUrl)
619
+ throw new Error(`Local server URL is required for mobile target '${name}'.`);
620
+ config.server = {
621
+ ...serverConfig,
622
+ androidScheme: "http",
623
+ url: localServerUrl,
624
+ cleartext: true,
625
+ allowNavigation: mergeAllowNavigation(serverConfig?.allowNavigation, localIp)
626
+ };
627
+ } else if (serverConfig && Object.keys(serverConfig).length > 0) {
628
+ config.server = serverConfig;
629
+ }
630
+ if (cordovaConfig && Object.keys(cordovaConfig).length > 0) {
631
+ config.cordova = cordovaConfig;
632
+ }
633
+ if (experimentalConfig && Object.keys(experimentalConfig).length > 0) {
634
+ config.experimental = experimentalConfig;
635
+ }
636
+ assertJsonSerializable(config);
637
+ return config;
638
+ }
639
+
640
+ class CapacitorApp {
641
+ app;
642
+ target;
643
+ project;
644
+ iosTargetName = "App";
645
+ targetRoot;
646
+ targetRootPath;
647
+ targetWebRoot;
648
+ targetAssetRoot;
649
+ iosRootPath = "ios";
650
+ iosProjectPath = "ios/App";
651
+ androidRootPath = "android";
652
+ androidAssetsPath = "android/app/src/main/assets";
653
+ #iosEntitlements = {};
654
+ constructor(app, target) {
655
+ this.app = app;
656
+ this.target = target;
657
+ this.targetRootPath = path.posix.join(".akan", "mobile", this.target.name);
658
+ this.targetRoot = path.join(this.app.cwdPath, this.targetRootPath);
659
+ this.targetWebRoot = path.join(this.targetRoot, "www");
660
+ this.targetAssetRoot = path.join(this.targetRoot, "assets");
661
+ this.project = new MobileProject(this.app.cwdPath, {
662
+ android: { path: this.androidRootPath },
663
+ ios: { path: this.iosProjectPath }
664
+ });
665
+ }
666
+ async init({
667
+ platform,
668
+ operation = "release",
669
+ env = "debug",
670
+ regenerate = false
671
+ } = {}) {
672
+ await mkdir(this.targetRoot, { recursive: true });
673
+ if (regenerate) {
674
+ if (!platform || platform === "ios")
675
+ await rm(path.join(this.app.cwdPath, this.iosRootPath), { recursive: true, force: true });
676
+ if (!platform || platform === "android")
677
+ await rm(path.join(this.app.cwdPath, this.androidRootPath), { recursive: true, force: true });
678
+ }
679
+ const project = this.project;
680
+ await this.project.load();
681
+ if ((!platform || platform === "android") && !project.android) {
682
+ await this.#spawnMobile("npx", ["cap", "add", "android"], { operation, env });
683
+ await this.project.load();
684
+ }
685
+ if ((!platform || platform === "ios") && !project.ios) {
686
+ await this.#spawnMobile("npx", ["cap", "add", "ios"], { operation, env });
687
+ await this.project.load();
688
+ }
689
+ return this;
690
+ }
691
+ async save() {
692
+ await this.project.commit();
693
+ }
694
+ async#prepareIos({ operation, env, regenerate = false }) {
695
+ await this.init({ platform: "ios", operation, env, regenerate });
696
+ await this.#prepareTargetAssets();
697
+ await this.#prepareExternalFiles("ios");
698
+ await this.#applyIosMetadata();
699
+ await this.#applyPermissions({ operation, env });
700
+ await this.#applyDeepLinks("ios", { operation, env });
701
+ await this.#flushIosEntitlements();
702
+ await this.project.commit();
703
+ await this.#generateAssets({ operation, env });
704
+ this.app.verbose(`syncing iOS`);
705
+ await this.#spawnMobile("npx", ["cap", "sync", "ios"], { operation, env });
706
+ this.app.verbose(`sync completed.`);
707
+ }
708
+ async buildIos({ env = "debug", regenerate = false } = {}) {
709
+ await this.prepareWww();
710
+ await this.#prepareIos({ operation: "release", env, regenerate });
711
+ await this.#spawnMobile("npx", ["cap", "build", "ios"], { operation: "release", env }, { stdio: "inherit" });
712
+ this.app.verbose(`build completed iOS.`);
713
+ return;
714
+ }
715
+ async syncIos() {
716
+ await this.#spawnMobile("npx", ["cap", "sync", "ios"], { operation: "local", env: "local" });
717
+ }
718
+ async openIos() {
719
+ await this.#spawnMobile("npx", ["cap", "open", "ios"], { operation: "local", env: "local" });
720
+ }
721
+ async runIos({ operation, env, regenerate = false, noAllowProvisioningUpdates = false, iosDeviceId }) {
722
+ if (operation === "release")
723
+ await this.prepareWww();
724
+ await this.#prepareIos({ operation, env, regenerate });
725
+ const runTarget = await this.#selectIosRunTarget(iosDeviceId);
726
+ if (runTarget.kind === "simulator") {
727
+ await this.#spawnMobile("npx", ["cap", "run", "ios", "--target", runTarget.id], { operation, env }, { stdio: "inherit" });
728
+ return;
729
+ }
730
+ await this.#runIosPhysicalDevice({ operation, env, runTarget, noAllowProvisioningUpdates });
731
+ }
732
+ async#selectIosRunTarget(deviceId) {
733
+ const targets = sortIosRunTargets(await this.#loadIosRunTargets());
734
+ if (deviceId) {
735
+ const needle = deviceId.toLowerCase();
736
+ const found = targets.find((target) => target.id === deviceId) ?? targets.find((target) => target.name.toLowerCase() === needle) ?? targets.find((target) => target.name.toLowerCase().includes(needle) || target.id.toLowerCase().includes(needle) || (target.runtime?.toLowerCase().includes(needle) ?? false));
737
+ if (!found) {
738
+ const available = targets.map((t) => `${t.name}${t.runtime ? ` (${t.runtime})` : ""}`).join(", ") || "none";
739
+ throw new Error(`iOS run target '${deviceId}' was not found. Available: ${available}`);
740
+ }
741
+ this.#warnIfLegacySimulatorRuntime(found);
742
+ return found;
743
+ }
744
+ if (targets.length === 0) {
745
+ throw new Error("No iOS run targets found. Open Simulator or connect an iPhone, then retry.");
746
+ }
747
+ const selected = await select({
748
+ message: "Select iOS run target",
749
+ choices: targets.map((target) => ({
750
+ name: `[${target.kind}] ${target.name}${target.runtime ? ` \u2014 ${target.runtime}` : ""}${target.state ? ` (${target.state})` : ""}`,
751
+ value: target
752
+ }))
753
+ });
754
+ this.#warnIfLegacySimulatorRuntime(selected);
755
+ return selected;
756
+ }
757
+ #warnIfLegacySimulatorRuntime(target) {
758
+ if (target.kind !== "simulator")
759
+ return;
760
+ const major = parseIosRuntimeMajor(target.runtime);
761
+ if (major === undefined || major >= SWIFTUICORE_MIN_IOS_MAJOR)
762
+ return;
763
+ this.app.logger.warn(`Selected simulator runs ${target.runtime ?? "an older iOS"}. Recent SDK builds link SwiftUICore and require iOS ${SWIFTUICORE_MIN_IOS_MAJOR}+; if the app crashes at launch with a "Library not loaded: SwiftUICore" dyld error, pick an iOS ${SWIFTUICORE_MIN_IOS_MAJOR}+ simulator instead.`);
764
+ }
765
+ async#loadIosRunTargets() {
766
+ const devices = await this.#loadPhysicalIosDevices();
767
+ const simulators = await this.#loadIosSimulators();
768
+ return [...devices, ...simulators];
769
+ }
770
+ async#loadPhysicalIosDevices() {
771
+ try {
772
+ return parseDevicectlDevices(await this.#spawn("xcrun", ["devicectl", "list", "devices", "--json-output", "-"]));
773
+ } catch (jsonError) {
774
+ try {
775
+ return parseDevicectlDevices(await this.#spawn("xcrun", ["devicectl", "list", "devices"]));
776
+ } catch (textError) {
777
+ const classification = classifyIosRunFailure(`${jsonError instanceof Error ? jsonError.message : ""}
778
+ ${textError instanceof Error ? textError.message : ""}`);
779
+ if (classification.kind === "devicectl-unavailable")
780
+ this.app.logger.warn(classification.detail);
781
+ return [];
782
+ }
783
+ }
784
+ }
785
+ async#loadIosSimulators() {
786
+ try {
787
+ return parseSimctlDevices(await this.#spawn("xcrun", ["simctl", "list", "devices", "available", "--json"]));
788
+ } catch {
789
+ try {
790
+ return parseSimctlDevices(await this.#spawn("xcrun", ["simctl", "list", "devices", "available"]));
791
+ } catch {
792
+ return [];
793
+ }
794
+ }
795
+ }
796
+ async#runIosPhysicalDevice({
797
+ operation,
798
+ env,
799
+ runTarget,
800
+ noAllowProvisioningUpdates
801
+ }) {
802
+ const mobileEnv = sanitizeIosNativeRunEnv(await this.#commandEnv(operation, env));
803
+ const configContent = await this.#writeCapacitorConfig({ operation }, mobileEnv);
804
+ await this.#writeRootCapacitorConfig(configContent);
805
+ const scheme = this.#iosScheme();
806
+ const command = buildIosNativeRunCommand({
807
+ appRoot: this.app.cwdPath,
808
+ device: runTarget,
809
+ scheme,
810
+ configuration: operation === "release" ? "Release" : "Debug"
811
+ });
812
+ const xcodebuildArgs = noAllowProvisioningUpdates ? command.xcodebuildArgs : [...command.xcodebuildArgs.slice(0, -1), "-allowProvisioningUpdates", ...command.xcodebuildArgs.slice(-1)];
813
+ try {
814
+ await this.#spawn("xcodebuild", xcodebuildArgs, {
815
+ cwd: path.join(this.app.cwdPath, this.iosProjectPath),
816
+ env: mobileEnv
817
+ });
818
+ const devicectlId = runTarget.devicectlId ?? runTarget.id;
819
+ await this.#spawn("xcrun", ["devicectl", "device", "install", "app", "--device", devicectlId, command.appPath], {
820
+ env: mobileEnv
821
+ });
822
+ await this.#spawn("xcrun", ["devicectl", "device", "process", "launch", "--device", devicectlId, this.target.appId], {
823
+ env: mobileEnv
824
+ });
825
+ } catch (error) {
826
+ throw new Error(formatIosRunFailureMessage({
827
+ classification: classifyIosRunFailure(this.#errorOutput(error)),
828
+ appId: this.target.appId,
829
+ targetName: this.target.name,
830
+ teamId: await this.#getIosDevelopmentTeam()
831
+ }));
832
+ } finally {
833
+ await this.#clearRootCapacitorConfigs();
834
+ }
835
+ }
836
+ #iosScheme() {
837
+ return isRecord(this.target.ios) && typeof this.target.ios.scheme === "string" ? this.target.ios.scheme : "App";
838
+ }
839
+ async#getIosDevelopmentTeam() {
840
+ const pbxprojPath = path.join(this.app.cwdPath, this.iosProjectPath, "App.xcodeproj/project.pbxproj");
841
+ if (!await Bun.file(pbxprojPath).exists())
842
+ return;
843
+ return (await Bun.file(pbxprojPath).text()).match(/DEVELOPMENT_TEAM = ([^;]+);/)?.[1]?.trim();
844
+ }
845
+ #errorOutput(error) {
846
+ if (error instanceof CommandExecutionError)
847
+ return `${error.stdout}
848
+ ${error.stderr}
849
+ ${error.message}`;
850
+ return error instanceof Error ? error.message : String(error);
851
+ }
852
+ async#prepareAndroid({ operation, env, regenerate = false }) {
853
+ await this.init({ platform: "android", operation, env, regenerate });
854
+ await this.#prepareTargetAssets();
855
+ await this.#prepareExternalFiles("android");
856
+ await this.#applyAndroidMetadata();
857
+ await this.#applyAndroidMinSdkVersion();
858
+ await this.#applyPermissions({ operation, env });
859
+ await this.#applyDeepLinks("android", { operation, env });
860
+ await this.project.commit();
861
+ await this.#generateAssets({ operation, env });
862
+ await this.#ensureAndroidAssetsDir();
863
+ await this.#ensureAndroidDebugKeystore();
864
+ await this.#spawnMobile("npx", ["cap", "sync", "android"], { operation, env });
865
+ await this.#setDeepLinksInAndroid(this.target.deepLinks?.schemes ?? [], this.target.deepLinks?.domains ?? []);
866
+ }
867
+ async#updateAndroidBuildTypes() {
868
+ const appGradle = await FileEditor.create(path.join(this.app.cwdPath, this.androidRootPath, "app/build.gradle"));
869
+ const buildTypesBlock = `
870
+ debug {
871
+ applicationIdSuffix ".debug"
872
+ versionNameSuffix "-DEBUG"
873
+ debuggable true
874
+ minifyEnabled false
875
+ }
876
+ `;
877
+ const singinConfigBlock = `
878
+ signingConfigs {
879
+ debug {
880
+ storeFile file('debug.keystore')
881
+ storePassword 'android'
882
+ keyAlias 'androiddebugkey'
883
+ keyPassword 'android'
884
+ }
885
+ release {
886
+ if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
887
+ storeFile file(MYAPP_RELEASE_STORE_FILE)
888
+ storePassword MYAPP_RELEASE_STORE_PASSWORD
889
+ keyAlias MYAPP_RELEASE_KEY_ALIAS
890
+ keyPassword MYAPP_RELEASE_KEY_PASSWORD
891
+ }
892
+ }
893
+ }
894
+ `;
895
+ if (appGradle.find("signingConfigs {") === -1) {
896
+ appGradle.insertBefore("buildTypes {", singinConfigBlock);
897
+ }
898
+ if (appGradle.find(`applicationIdSuffix ".debug"`) === -1) {
899
+ appGradle.insertAfter("buildTypes {", buildTypesBlock);
900
+ }
901
+ await appGradle.save();
902
+ }
903
+ async buildAndroid(assembleType, { env = "debug", regenerate = false } = {}) {
904
+ await this.prepareWww();
905
+ await this.#prepareAndroid({ operation: "release", env, regenerate });
906
+ await this.#assertAndroidReleaseSigningConfig();
907
+ await this.#updateAndroidBuildTypes();
908
+ const isWindows = process.platform === "win32";
909
+ const gradleCommand = isWindows ? "gradlew.bat" : "./gradlew";
910
+ await this.app.spawn(gradleCommand, [assembleType === "apk" ? "assembleRelease" : "bundleRelease"], {
911
+ stdio: "inherit",
912
+ cwd: path.join(this.app.cwdPath, this.androidRootPath),
913
+ env: await this.#commandEnv("release", env)
914
+ });
915
+ }
916
+ async openAndroid() {
917
+ await this.#spawnMobile("npx", ["cap", "open", "android"], { operation: "local", env: "local" });
918
+ }
919
+ async#ensureAndroidAssetsDir() {
920
+ await mkdir(path.join(this.app.cwdPath, this.androidAssetsPath), { recursive: true });
921
+ }
922
+ async#ensureAndroidDebugKeystore() {
923
+ const keystorePath = path.join(this.app.cwdPath, this.androidRootPath, "app/debug.keystore");
924
+ if (await Bun.file(keystorePath).exists())
925
+ return;
926
+ await this.#spawn("keytool", [
927
+ "-genkeypair",
928
+ "-v",
929
+ "-keystore",
930
+ keystorePath,
931
+ "-storepass",
932
+ "android",
933
+ "-alias",
934
+ "androiddebugkey",
935
+ "-keypass",
936
+ "android",
937
+ "-keyalg",
938
+ "RSA",
939
+ "-keysize",
940
+ "2048",
941
+ "-validity",
942
+ "10000",
943
+ "-dname",
944
+ "CN=Android Debug,O=Android,C=US"
945
+ ]);
946
+ }
947
+ async syncAndroid(options = {}) {
948
+ await this.prepareWww();
949
+ await this.#prepareAndroid({ operation: "release", env: "debug", ...options });
950
+ this.app.log(`Sync Android Completed.`);
951
+ }
952
+ async runAndroid({ operation, env, regenerate = false }) {
953
+ if (operation === "release")
954
+ await this.prepareWww();
955
+ await this.#prepareAndroid({ operation, env, regenerate });
956
+ await this.#assertAndroidAdbReady();
957
+ this.app.logger.info(`Running Android in ${operation} mode on ${env} env`);
958
+ const args = ["cap", "run", "android"];
959
+ await this.#spawnMobile("npx", args, { operation, env }, { stdio: "inherit" });
960
+ }
961
+ async#assertAndroidReleaseSigningConfig() {
962
+ const gradlePropertiesPath = path.join(this.app.cwdPath, this.androidRootPath, "gradle.properties");
963
+ const gradleProperties = await Bun.file(gradlePropertiesPath).exists() ? await Bun.file(gradlePropertiesPath).text() : "";
964
+ const missingKeys = getMissingAndroidReleaseSigningKeys({ gradleProperties });
965
+ if (missingKeys.length > 0)
966
+ throw new Error(formatAndroidReleaseSigningError(missingKeys));
967
+ }
968
+ async#assertAndroidAdbReady() {
969
+ try {
970
+ const issues = getAdbDeviceStateIssues(await this.#spawn("adb", ["devices"]));
971
+ if (issues.length > 0)
972
+ throw new Error(issues.join(`
973
+ `));
974
+ } catch (error) {
975
+ if (error instanceof CommandExecutionError)
976
+ return;
977
+ throw error;
978
+ }
979
+ }
980
+ async releaseIos() {
981
+ await this.prepareWww();
982
+ await this.#prepareIos({ operation: "release", env: "main" });
983
+ }
984
+ async releaseAndroid() {
985
+ await this.prepareWww();
986
+ await this.#prepareAndroid({ operation: "release", env: "main" });
987
+ }
988
+ async prepareWww() {
989
+ const htmlSource = path.join(this.app.dist.cwdPath, "csr", targetHtmlFilename(this.target));
990
+ if (!await Bun.file(htmlSource).exists())
991
+ throw new Error(`CSR html for mobile target '${this.target.name}' not found: ${htmlSource}`);
992
+ await rm(this.targetWebRoot, { recursive: true, force: true });
993
+ await mkdir(this.targetWebRoot, { recursive: true });
994
+ await Bun.write(path.join(this.targetWebRoot, "index.html"), this.#injectMobileTargetMeta(await Bun.file(htmlSource).text()));
995
+ }
996
+ #injectMobileTargetMeta(html) {
997
+ const basePath = this.target.basePath?.replace(/^\/+|\/+$/g, "") ?? "";
998
+ const script = `<script>window.__AKAN_MOBILE_TARGET__=${JSON.stringify({
999
+ name: this.target.name,
1000
+ basePath,
1001
+ indexPath: this.target.indexPath
1002
+ })};</script>`;
1003
+ if (html.includes("window.__AKAN_MOBILE_TARGET__"))
1004
+ return html;
1005
+ return html.replace(/<\/head\s*>/i, `${script}
1006
+ </head>`);
1007
+ }
1008
+ async#writeCapacitorConfig({ operation }, commandEnv) {
1009
+ await mkdir(this.targetRoot, { recursive: true });
1010
+ let localIp;
1011
+ if (operation === "local") {
1012
+ const override = commandEnv.AKAN_PUBLIC_CLIENT_HOST ?? process.env.AKAN_PUBLIC_CLIENT_HOST;
1013
+ const resolution = selectLocalDevHost(os.networkInterfaces(), { override });
1014
+ localIp = resolution.host;
1015
+ this.#logDevHostResolution(resolution, commandEnv);
1016
+ }
1017
+ const config = materializeCapacitorConfig(this.target, {
1018
+ operation,
1019
+ localIp,
1020
+ localServerUrl: localIp ? this.#localCsrUrl(localIp, commandEnv) : undefined
1021
+ });
1022
+ const content = `${JSON.stringify(config, null, 2)}
1023
+ `;
1024
+ await Bun.write(path.join(this.targetRoot, "capacitor.config.json"), content);
1025
+ return content;
1026
+ }
1027
+ #logDevHostResolution(resolution, commandEnv) {
1028
+ this.app.log(`Mobile live-reload server: ${this.#localCsrUrl(resolution.host, commandEnv)}`);
1029
+ if (resolution.source === "override")
1030
+ return;
1031
+ const suspicious = resolution.host === "127.0.0.1" || resolution.host.startsWith("169.254.");
1032
+ const alternatives = resolution.candidates.filter((candidate) => candidate.address !== resolution.host);
1033
+ if (!suspicious && alternatives.length === 0)
1034
+ return;
1035
+ const alternativeText = alternatives.length ? ` Other interfaces: ${alternatives.map((candidate) => `${candidate.address} (${candidate.name})`).join(", ")}.` : "";
1036
+ this.app.logger.warn(`A physical device must reach ${resolution.host} on your LAN.${suspicious ? " That address looks non-routable." : ""}${alternativeText} If the device shows a blank screen, pin the right one with AKAN_PUBLIC_CLIENT_HOST=<ip>.`);
1037
+ }
1038
+ async#prepareTargetAssets() {
1039
+ if (!this.target.assets)
1040
+ return;
1041
+ await mkdir(this.targetAssetRoot, { recursive: true });
1042
+ if (this.target.assets.icon)
1043
+ await cp(path.join(this.app.cwdPath, this.target.assets.icon), path.join(this.targetAssetRoot, "icon.png"), {
1044
+ force: true
1045
+ });
1046
+ if (this.target.assets.splash)
1047
+ await cp(path.join(this.app.cwdPath, this.target.assets.splash), path.join(this.targetAssetRoot, "splash.png"), {
1048
+ force: true
1049
+ });
1050
+ }
1051
+ async#prepareExternalFiles(platform) {
1052
+ const files = this.target.files?.[platform];
1053
+ if (!files)
1054
+ return;
1055
+ const platformRoot = path.join(this.app.cwdPath, platform === "ios" ? this.iosRootPath : this.androidRootPath);
1056
+ await Promise.all(Object.entries(files).map(async ([to, from]) => {
1057
+ const targetPath = path.join(platformRoot, to);
1058
+ await mkdir(path.dirname(targetPath), { recursive: true });
1059
+ await cp(path.join(this.app.cwdPath, from), targetPath, { force: true });
1060
+ }));
1061
+ }
1062
+ async#generateAssets({ operation, env }) {
1063
+ if (!this.target.assets)
1064
+ return;
1065
+ await this.#spawnMobile("npx", [
1066
+ "@capacitor/assets",
1067
+ "generate",
1068
+ "--assetPath",
1069
+ path.posix.join(this.targetRootPath, "assets"),
1070
+ "--iosProject",
1071
+ this.iosProjectPath,
1072
+ "--androidProject",
1073
+ this.androidRootPath
1074
+ ], { operation, env });
1075
+ }
1076
+ async#applyIosMetadata() {
1077
+ this.project.ios.setBundleId("App", "Debug", this.target.appId);
1078
+ this.project.ios.setBundleId("App", "Release", this.target.appId);
1079
+ await this.project.ios.setVersion("App", "Debug", this.target.version);
1080
+ await this.project.ios.setVersion("App", "Release", this.target.version);
1081
+ await this.project.ios.setBuild("App", "Debug", this.target.buildNum);
1082
+ await this.project.ios.setBuild("App", "Release", this.target.buildNum);
1083
+ }
1084
+ async#applyAndroidMetadata() {
1085
+ await this.project.android.setVersionName(this.target.version);
1086
+ await this.project.android.setPackageName(this.target.appId);
1087
+ await this.project.android.setVersionCode(this.target.buildNum);
1088
+ await this.project.android.setAppName(this.target.appName);
1089
+ }
1090
+ async#applyAndroidMinSdkVersion() {
1091
+ const variablesGradlePath = path.join(this.app.cwdPath, this.androidRootPath, "variables.gradle");
1092
+ if (!await Bun.file(variablesGradlePath).exists())
1093
+ return;
1094
+ const updated = raiseGradleMinSdkVersion(await Bun.file(variablesGradlePath).text());
1095
+ if (!updated)
1096
+ return;
1097
+ await writeFile(variablesGradlePath, updated);
1098
+ this.app.verbose(`Raised Android minSdkVersion to ${ANDROID_MIN_SDK_VERSION} in variables.gradle`);
1099
+ }
1100
+ async#applyPermissions({ operation, env }) {
1101
+ const plugins = await this.app.collectPlugins();
1102
+ const nativePlugins = new Map;
1103
+ for (const plugin of plugins) {
1104
+ const permission = plugin.capacitor?.permission;
1105
+ if (!permission || !plugin.capacitor?.configureNative)
1106
+ continue;
1107
+ const claimants = nativePlugins.get(permission) ?? [];
1108
+ claimants.push(plugin);
1109
+ nativePlugins.set(permission, claimants);
1110
+ }
1111
+ for (const permission of this.target.permissions ?? []) {
1112
+ const claimants = nativePlugins.get(permission);
1113
+ if (claimants?.length) {
1114
+ const ctx = this.#makeNativeContext({ operation, env });
1115
+ for (const plugin of claimants)
1116
+ await plugin.capacitor?.configureNative?.(ctx);
1117
+ continue;
1118
+ }
1119
+ if (permission === "camera")
1120
+ await this.addCamera();
1121
+ else if (permission === "contacts")
1122
+ await this.addContact();
1123
+ else if (permission === "location")
1124
+ await this.addLocation();
1125
+ }
1126
+ }
1127
+ #makeNativeContext({ operation, env }) {
1128
+ return {
1129
+ appPath: this.app.cwdPath,
1130
+ executor: this.app,
1131
+ target: this.target,
1132
+ operation,
1133
+ env,
1134
+ setIosUsageDescriptions: (descriptions) => this.#setPermissionInIos(descriptions),
1135
+ updateIosInfoPlist: async (values) => {
1136
+ await Promise.all([
1137
+ this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", values),
1138
+ this.project.ios.updateInfoPlist(this.iosTargetName, "Release", values)
1139
+ ]);
1140
+ },
1141
+ addIosEntitlements: (entitlements) => this.#addIosEntitlements(entitlements),
1142
+ editIosAppDelegate: (transform) => this.#editIosAppDelegate(transform),
1143
+ addAndroidPermissions: (permissions) => {
1144
+ this.#setPermissionsInAndroid(permissions);
1145
+ },
1146
+ addAndroidFeatures: (features) => {
1147
+ this.#setFeaturesInAndroid(features);
1148
+ }
1149
+ };
1150
+ }
1151
+ async#applyDeepLinks(platform, { operation, env }) {
1152
+ const deepLinks = this.target.deepLinks;
1153
+ if (!deepLinks)
1154
+ return;
1155
+ const schemes = deepLinks.schemes ?? [];
1156
+ const domains = deepLinks.domains ?? [];
1157
+ if (domains.length > 0)
1158
+ this.#assertDeepLinkVerificationConfig(platform, { operation, env });
1159
+ if (platform === "ios") {
1160
+ if (schemes.length > 0) {
1161
+ await this.#setPermissionInIos({
1162
+ appTransportSecurity: ""
1163
+ });
1164
+ await this.#setUrlSchemesInIos(schemes);
1165
+ }
1166
+ if (domains.length > 0)
1167
+ this.#addIosEntitlements({
1168
+ "com.apple.developer.associated-domains": domains.map((domain) => `applinks:${domain}`)
1169
+ });
1170
+ return;
1171
+ }
1172
+ if (platform === "android") {
1173
+ for (const scheme of schemes) {
1174
+ this.project.android.getAndroidManifest().injectFragment("activity", `<intent-filter><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="${scheme}" /></intent-filter>`);
1175
+ }
1176
+ for (const domain of domains) {
1177
+ const pathPrefix = resolveMobilePath(this.target, "/");
1178
+ this.project.android.getAndroidManifest().injectFragment("activity", `<intent-filter android:autoVerify="true"><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="https" android:host="${domain}" android:pathPrefix="${pathPrefix}" /></intent-filter>`);
1179
+ }
1180
+ await this.#setDeepLinksInAndroid(schemes, domains);
1181
+ }
1182
+ }
1183
+ #assertDeepLinkVerificationConfig(platform, { operation, env }) {
1184
+ const deepLinks = this.target.deepLinks;
1185
+ if (!deepLinks?.domains?.length)
1186
+ return;
1187
+ if (platform === "ios" && !deepLinks.ios?.teamId) {
1188
+ throw new Error(`Mobile target '${this.target.name}' uses deepLinks.domains but is missing deepLinks.ios.teamId in apps/${this.app.name}/akan.config.ts`);
1189
+ }
1190
+ if (platform === "android" && !deepLinks.android?.sha256CertFingerprints?.length) {
1191
+ const message = `Mobile target '${this.target.name}' uses deepLinks.domains but is missing deepLinks.android.sha256CertFingerprints in apps/${this.app.name}/akan.config.ts`;
1192
+ if (operation === "release" || env === "main")
1193
+ throw new Error(message);
1194
+ this.app.logger.warn(message);
1195
+ }
1196
+ }
1197
+ async#commandEnv(operation, env) {
1198
+ const devPort = operation === "local" ? (await this.app.getDevPort()).toString() : undefined;
1199
+ return this.app.getCommandEnv({
1200
+ APP_OPERATION_MODE: operation,
1201
+ AKAN_PUBLIC_OPERATION_MODE: env === "local" ? "local" : "cloud",
1202
+ AKAN_PUBLIC_ENV: env,
1203
+ AKAN_MOBILE_TARGET: this.target.name,
1204
+ ...devPort ? { PORT: devPort, AKAN_PUBLIC_CLIENT_PORT: devPort, AKAN_PUBLIC_SERVER_PORT: devPort } : {}
1205
+ });
1206
+ }
1207
+ #localCsrUrl(ip, commandEnv) {
1208
+ const basePath = this.target.basePath?.replace(/^\/+|\/+$/g, "");
1209
+ const locale = commandEnv.AKAN_PUBLIC_DEFAULT_LOCALE ?? "en";
1210
+ const pathname = basePath ? `${locale}/${basePath}` : `${locale}/`;
1211
+ const port = commandEnv.AKAN_PUBLIC_CLIENT_PORT ?? commandEnv.PORT ?? "8282";
1212
+ const params = new URLSearchParams({ csr: "true", akanMobileTarget: this.target.name });
1213
+ if (basePath)
1214
+ params.set("akanMobileBasePath", basePath);
1215
+ if (this.target.indexPath)
1216
+ params.set("akanMobileIndexPath", this.target.indexPath);
1217
+ return `http://${ip}:${port}/${pathname}?${params}`;
1218
+ }
1219
+ async#clearRootCapacitorConfigs() {
1220
+ await clearRootCapacitorConfigs(this.app.cwdPath);
1221
+ }
1222
+ async#writeRootCapacitorConfig(content) {
1223
+ await writeRootCapacitorConfig(this.app.cwdPath, content);
1224
+ }
1225
+ async#spawn(command, args = [], options = {}) {
1226
+ return await this.app.spawn(command, args, { cwd: this.app.cwdPath, ...options });
1227
+ }
1228
+ async#spawnMobile(command, args = [], { operation, env }, options = {}) {
1229
+ const mobileEnv = { ...await this.#commandEnv(operation, env), ...options.env };
1230
+ const configContent = await this.#writeCapacitorConfig({ operation }, mobileEnv);
1231
+ await this.#writeRootCapacitorConfig(configContent);
1232
+ try {
1233
+ return await this.#spawn(command, args, {
1234
+ ...options,
1235
+ env: mobileEnv
1236
+ });
1237
+ } finally {
1238
+ await this.#clearRootCapacitorConfigs();
1239
+ }
1240
+ }
1241
+ async addCamera() {
1242
+ await this.#setPermissionInIos({
1243
+ cameraUsageDescription: "$(PRODUCT_NAME) requires access to the camera to take photos.",
1244
+ photoAddUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos.",
1245
+ photoUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos."
1246
+ });
1247
+ this.#setPermissionsInAndroid(["READ_MEDIA_IMAGES", "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"]);
1248
+ }
1249
+ async addContact() {
1250
+ await this.#setPermissionInIos({
1251
+ contactsUsageDescription: "$(PRODUCT_NAME) requires access to the contacts to add new contacts."
1252
+ });
1253
+ this.#setPermissionsInAndroid(["READ_CONTACTS", "WRITE_CONTACTS"]);
1254
+ }
1255
+ async addLocation() {
1256
+ await this.#setPermissionInIos({
1257
+ locationAlwaysUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location.",
1258
+ locationWhenInUseUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location."
1259
+ });
1260
+ this.#setPermissionsInAndroid(["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"]);
1261
+ this.#setFeaturesInAndroid(["android.hardware.location.gps"]);
1262
+ }
1263
+ #addIosEntitlements(entitlements) {
1264
+ Object.assign(this.#iosEntitlements, entitlements);
1265
+ }
1266
+ async#editIosAppDelegate(transform) {
1267
+ const appDelegatePath = path.join(this.app.cwdPath, this.iosProjectPath, "App/AppDelegate.swift");
1268
+ if (!await Bun.file(appDelegatePath).exists())
1269
+ return;
1270
+ const editor = await FileEditor.create(appDelegatePath);
1271
+ const content = editor.getContent();
1272
+ const next = transform(content);
1273
+ if (next !== content)
1274
+ await editor.setContent(next).save();
1275
+ }
1276
+ async#setPermissionInIos(permissions) {
1277
+ const updateNs = Object.fromEntries(Object.entries(permissions).map(([key, value]) => [`NS${capitalize(key)}`, value]));
1278
+ await Promise.all([
1279
+ this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
1280
+ this.project.ios.updateInfoPlist(this.iosTargetName, "Release", updateNs)
1281
+ ]);
1282
+ }
1283
+ async#setUrlSchemesInIos(schemes) {
1284
+ const urlTypes = schemes.map((scheme) => ({
1285
+ CFBundleURLName: this.target.appId,
1286
+ CFBundleURLSchemes: [scheme]
1287
+ }));
1288
+ await Promise.all([
1289
+ this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", { CFBundleURLTypes: urlTypes }),
1290
+ this.project.ios.updateInfoPlist(this.iosTargetName, "Release", { CFBundleURLTypes: urlTypes })
1291
+ ]);
1292
+ }
1293
+ #serializeIosEntitlements(entitlements) {
1294
+ const lines = [];
1295
+ for (const [key, value] of Object.entries(entitlements)) {
1296
+ lines.push(` <key>${key}</key>`);
1297
+ if (Array.isArray(value)) {
1298
+ lines.push(" <array>", ...value.map((item) => ` <string>${item}</string>`), " </array>");
1299
+ } else {
1300
+ lines.push(` <string>${value}</string>`);
1301
+ }
1302
+ }
1303
+ return lines;
1304
+ }
1305
+ async#flushIosEntitlements() {
1306
+ if (Object.keys(this.#iosEntitlements).length === 0)
1307
+ return;
1308
+ const entitlementsRelPath = "App/App.entitlements";
1309
+ const entitlementsPath = path.join(this.app.cwdPath, this.iosProjectPath, entitlementsRelPath);
1310
+ const body = [
1311
+ '<?xml version="1.0" encoding="UTF-8"?>',
1312
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
1313
+ '<plist version="1.0">',
1314
+ "<dict>",
1315
+ ...this.#serializeIosEntitlements(this.#iosEntitlements),
1316
+ "</dict>",
1317
+ "</plist>",
1318
+ ""
1319
+ ].join(`
1320
+ `);
1321
+ const currentBody = await Bun.file(entitlementsPath).exists() ? await Bun.file(entitlementsPath).text() : undefined;
1322
+ if (currentBody !== body)
1323
+ await writeFile(entitlementsPath, body);
1324
+ await this.#setCodeSignEntitlementsInIos(entitlementsRelPath);
1325
+ }
1326
+ async#setCodeSignEntitlementsInIos(entitlementsRelPath) {
1327
+ const pbxprojPath = path.join(this.app.cwdPath, this.iosProjectPath, "App.xcodeproj/project.pbxproj");
1328
+ const lines = (await readFile(pbxprojPath, "utf8")).split(`
1329
+ `);
1330
+ let changed = false;
1331
+ for (let index = 0;index < lines.length; index++) {
1332
+ const line = lines[index] ?? "";
1333
+ if (!line.includes(`PRODUCT_BUNDLE_IDENTIFIER = ${this.target.appId};`))
1334
+ continue;
1335
+ let start = index;
1336
+ while (start >= 0 && !lines[start]?.includes("buildSettings = {"))
1337
+ start--;
1338
+ let end = index;
1339
+ while (end < lines.length && !/^\s*\};\s*$/.test(lines[end] ?? ""))
1340
+ end++;
1341
+ const settings = lines.slice(start, end + 1);
1342
+ if (settings.some((setting) => setting.includes("CODE_SIGN_ENTITLEMENTS")))
1343
+ continue;
1344
+ const indent = line.match(/^\s*/)?.[0] ?? "";
1345
+ lines.splice(index, 0, `${indent}CODE_SIGN_ENTITLEMENTS = ${entitlementsRelPath};`);
1346
+ index++;
1347
+ changed = true;
1348
+ }
1349
+ if (changed)
1350
+ await writeFile(pbxprojPath, lines.join(`
1351
+ `));
1352
+ }
1353
+ async#setUrlSchemesInAndroid(schemes) {
1354
+ const manifestPath = path.join(this.app.cwdPath, this.androidRootPath, "app/src/main/AndroidManifest.xml");
1355
+ let manifest = await readFile(manifestPath, "utf8");
1356
+ let changed = false;
1357
+ for (const scheme of schemes) {
1358
+ if (manifest.includes(`android:scheme="${scheme}"`))
1359
+ continue;
1360
+ const filter = [
1361
+ " <intent-filter>",
1362
+ ' <action android:name="android.intent.action.VIEW" />',
1363
+ ' <category android:name="android.intent.category.DEFAULT" />',
1364
+ ' <category android:name="android.intent.category.BROWSABLE" />',
1365
+ ` <data android:scheme="${scheme}" />`,
1366
+ " </intent-filter>"
1367
+ ].join(`
1368
+ `);
1369
+ manifest = manifest.replace(/(\s*<\/activity>)/, `
1370
+ ${filter}$1`);
1371
+ changed = true;
1372
+ }
1373
+ if (changed)
1374
+ await writeFile(manifestPath, manifest);
1375
+ }
1376
+ async#setDeepLinksInAndroid(schemes, domains) {
1377
+ await this.#setUrlSchemesInAndroid(schemes);
1378
+ const manifestPath = path.join(this.app.cwdPath, this.androidRootPath, "app/src/main/AndroidManifest.xml");
1379
+ let manifest = await readFile(manifestPath, "utf8");
1380
+ let changed = false;
1381
+ const pathPrefix = resolveMobilePath(this.target, "/");
1382
+ for (const domain of domains) {
1383
+ if (manifest.includes(`android:host="${domain}"`) && manifest.includes('android:scheme="https"'))
1384
+ continue;
1385
+ const filter = [
1386
+ ' <intent-filter android:autoVerify="true">',
1387
+ ' <action android:name="android.intent.action.VIEW" />',
1388
+ ' <category android:name="android.intent.category.DEFAULT" />',
1389
+ ' <category android:name="android.intent.category.BROWSABLE" />',
1390
+ ` <data android:scheme="https" android:host="${domain}" android:pathPrefix="${pathPrefix}" />`,
1391
+ " </intent-filter>"
1392
+ ].join(`
1393
+ `);
1394
+ manifest = manifest.replace(/(\s*<\/activity>)/, `
1395
+ ${filter}$1`);
1396
+ changed = true;
1397
+ }
1398
+ if (changed)
1399
+ await writeFile(manifestPath, manifest);
1400
+ }
1401
+ #setFeaturesInAndroid(features) {
1402
+ for (const feature of features) {
1403
+ if (this.#hasFeatureInAndroid(feature)) {
1404
+ this.app.logger.info(`${feature} already exists in android`);
1405
+ return this;
1406
+ }
1407
+ this.app.logger.info(`Adding ${feature} to android`);
1408
+ this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-feature android:name="${feature}" />`);
1409
+ }
1410
+ return this;
1411
+ }
1412
+ #getFeaturesInAndroid() {
1413
+ const androidManifest = this.project.android.getAndroidManifest();
1414
+ const element = androidManifest.getDocumentElement();
1415
+ if (!element)
1416
+ throw new Error("manifest not found");
1417
+ const usesFeature = element.getElementsByTagName("uses-feature");
1418
+ return Array.from(usesFeature).map((feature) => feature.getAttribute("android:name"));
1419
+ }
1420
+ #hasFeatureInAndroid(feature) {
1421
+ return this.#getFeaturesInAndroid().includes(feature);
1422
+ }
1423
+ #setPermissionsInAndroid(permissions) {
1424
+ for (const permission of permissions) {
1425
+ if (this.#hasPermissionInAndroid(permission)) {
1426
+ this.app.logger.info(`${permission} already exists in android`);
1427
+ continue;
1428
+ }
1429
+ this.app.logger.info(`Adding ${permission} to android`);
1430
+ this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-permission android:name="android.permission.${permission}" />`);
1431
+ }
1432
+ return this;
1433
+ }
1434
+ #getPermissionsInAndroid() {
1435
+ const androidManifest = this.project.android.getAndroidManifest();
1436
+ const element = androidManifest.getDocumentElement();
1437
+ if (!element)
1438
+ throw new Error("manifest not found");
1439
+ const usesPermission = element.getElementsByTagName("uses-permission");
1440
+ return Array.from(usesPermission).map((permission) => permission.getAttribute("android:name"));
1441
+ }
1442
+ #hasPermissionInAndroid(permission) {
1443
+ return this.#getPermissionsInAndroid().includes(`android.permission.${permission}`);
1444
+ }
1445
+ }
1446
+
1447
+ export { SWIFTUICORE_MIN_IOS_MAJOR, rootCapacitorConfigFilenames, rootCapacitorConfigPaths, clearRootCapacitorConfigs, writeRootCapacitorConfig, selectLocalDevHost, parseIosRuntimeMajor, sortIosRunTargets, parseDevicectlDevices, parseSimctlDevices, buildIosNativeRunCommand, classifyIosRunFailure, formatIosRunFailureMessage, sanitizeIosNativeRunEnv, PLACEHOLDER_APP_IDS, isPlaceholderAppId, getMissingAndroidReleaseSigningKeys, formatAndroidReleaseSigningError, getAdbDeviceStateIssues, ANDROID_MIN_SDK_VERSION, raiseGradleMinSdkVersion, assertJsonSerializable, materializeCapacitorConfig, CapacitorApp };