@capgo/cli
Version:
A CLI to upload to capgo servers
62 lines (61 loc) • 2.45 kB
TypeScript
export { SCHEME_RE } from './checks/ios-plist';
export interface ManifestFile {
raw: string;
path: string;
}
export interface ScannedElement {
tag: string;
attrs: Record<string, string>;
/** byte offset of the element's opening `<` in the source */
start: number;
/** byte offset just past the element's closing `>` in the source */
end: number;
/** the raw open tag text, e.g. `<activity android:name=".X">` */
rawOpenTag: string;
}
/**
* Read android/app/src/main/AndroidManifest.xml. Returns null when absent.
* Memoized per projectDir (bounded cache) so repeat reads return the same
* object.
*/
export declare function readAndroidManifest(projectDir: string): ManifestFile | null;
/**
* Remove `<!-- ... -->` comment blocks so typo/duplicate/exported scans don't
* trip on commented-out elements. Replaces each comment with an equal-length
* run of spaces so byte offsets stay stable for callers that slice the source.
*/
export declare function stripXmlComments(raw: string): string;
/**
* The one parse primitive consumed by every manifest check. Matches each
* element open tag (self-closing or not) and parses its `name="value"`
* attributes into a map. Closing tags (`</application>`) never match.
*/
export declare function scanElements(raw: string): ScannedElement[];
export interface NamespaceFlags {
android: boolean;
tools: boolean;
}
/** Detect the android + tools xmlns declarations anywhere in the source. */
export declare function hasNamespaceXmlns(raw: string): NamespaceFlags;
export interface ApplicationBlock {
openTag: string;
body: string;
start: number;
end: number;
}
/**
* Slice the `<application ...>` ... `</application>` block (the XML analogue of
* extractBraceBlock). Returns null when there is no application element.
*/
export declare function applicationBlock(raw: string): ApplicationBlock | null;
/**
* The 32 Android Lint valid manifest tags. A tag NOT in this set (and not
* namespaced/custom) within edit distance 1..3 of one of these is a typo.
*/
export declare const MANIFEST_VALID_TAGS: Set<string>;
/**
* Bounded Levenshtein distance capped at `max` (Android Lint uses 3). Returns a
* value > max as soon as the distance is provably over the cap so distant
* strings never pay the full O(a*b) compute. No npm string-distance package.
*/
export declare function editDistance(a: string, b: string, max: number): number;