MCPcopy Create free account
hub / github.com/auth0/auth0-cli / readCapacitorAppID

Function readCapacitorAppID

internal/cli/quickstart_detect.go:612–642  ·  view source on GitHub ↗

readCapacitorAppID reads the "appId" field from capacitor.config.json or capacitor.config.ts in dir. Capacitor v3+ defaults to the TypeScript config. Returns empty string if neither file is present or the field is missing.

(dir string)

Source from the content-addressed store, hash-verified

610// capacitor.config.ts in dir. Capacitor v3+ defaults to the TypeScript config.
611// Returns empty string if neither file is present or the field is missing.
612func readCapacitorAppID(dir string) string {
613 // Try JSON config first (Capacitor v2 and v3+ both support it).
614 if data, err := os.ReadFile(filepath.Join(dir, "capacitor.config.json")); err == nil {
615 var cfg struct {
616 AppID string `json:"appId"`
617 }
618 if jsonErr := json.Unmarshal(data, &cfg); jsonErr == nil && cfg.AppID != "" {
619 return cfg.AppID
620 }
621 }
622 // Fall back to TypeScript config (Capacitor v3+ default).
623 // Process line-by-line to skip comment lines that may contain an appId value
624 // (e.g. "// appId: 'old.value'") which would otherwise be matched first.
625 if data, err := os.ReadFile(filepath.Join(dir, "capacitor.config.ts")); err == nil {
626 for _, line := range strings.Split(string(data), "\n") {
627 if strings.HasPrefix(strings.TrimSpace(line), "//") {
628 continue
629 }
630 if m := capacitorTSAppIDRegex.FindStringSubmatch(line); len(m) >= 3 {
631 // M[1] = single-quoted match, m[2] = double-quoted match.
632 if m[1] != "" {
633 return m[1]
634 }
635 if m[2] != "" {
636 return m[2]
637 }
638 }
639 }
640 }
641 return ""
642}
643
644// readDotnetMobileBundleID extracts the <ApplicationId> element from .csproj content.
645// Used for MAUI and .NET Mobile apps to generate callback URL guidance.

Callers 3

TestReadCapacitorAppIDFunction · 0.85
resolveNativeBundleIDFunction · 0.85
DetectProjectFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestReadCapacitorAppIDFunction · 0.68