@picoxr/web-cli-core
Version:
Core Library to generate, build and sign TWA projects
86 lines (85 loc) • 4.72 kB
TypeScript
/// <reference types="node" />
import { Log } from './Log';
import { WebManifestIcon } from './types/WebManifest';
import { Orientation } from './TwaManifest';
export declare function executeFile(cmd: string, args: string[], env: NodeJS.ProcessEnv, log?: Log, cwd?: string): Promise<{
stdout: string;
stderr: string;
}>;
export declare function execInteractive(cwd: string, args: string[], env: NodeJS.ProcessEnv): Promise<number>;
export declare function execute(cmd: string[], env: NodeJS.ProcessEnv, log?: Log): Promise<{
stdout: string;
stderr: string;
}>;
export declare function unzipFile(zipFile: string, destinationPath: string, deleteZipWhenDone?: boolean): Promise<void>;
export declare function untar(tarFile: string, destinationPath: string, deleteZipWhenDone?: boolean): Promise<void>;
/**
* Fetches data for the largest icon from the web app manifest with a given purpose.
* @param {Array<WebManifestIcon>|undefined} icons List of the manifest icons.
* @param {string} purpose Purpose filter that the icon must match.
* @param {number} minSize The minimum required icon size enforced id provided.
*/
export declare function findSuitableIcon(icons: WebManifestIcon[] | undefined, purpose: string, minSize?: number): WebManifestIcon | null;
/**
* Fetches data for the six to five icon from the web app manifest.
* @param {Array<WebManifestIcon>|undefined} icons List of the manifest icons.
* @param {string} purpose Purpose filter that the icon must match.
* @param {number} minSize The minimum required icon size enforced id provided.
*/
export declare function findSixToFiveIcon(icons: WebManifestIcon[] | undefined, minSize?: number): WebManifestIcon | null;
export declare function generateAccessStartURL(webManifestUrl: string, startUrl: string): string;
export declare function isSameOrigin(url1: string, url2: string): boolean;
/**
* 生成manifestId,算法:https://w3c.github.io/manifest/#id-member
* 处理id成员,给定有序映射json、有序映射manifest所需步骤如下:
*
* 1、将manifest["id"]设置为manifest["start_url"]。
* 2、如果json["id"]的类型不是字符串,就返回。
* 3、如果json["id"]是一个空字符串,就返回。
* 4、让base origin成为manifest["start_url"]的来源(origin)。
* 5、使用base origin作为基本URL,从json["id"]解析出id的结果。
* 6、如果id解析失败,就返回。
* 7、如果id与manifest["start_url"]不是相同的源(origin),就返回。
* 8、将manifest["id"]设置为id。
*/
export declare function generateManifestId(id: string | undefined, startUrl: string, webManifestUrl: string): string;
export declare function generatePackageId(id: string, startUrl: string, webManifestUrl: string): string | null;
/**
* Validates if a string is not null and not empty.
* @param input the string to be validated
* @param fieldName the field represented by the string
* @returns {string | null} a description of the error or null if no erro is found.
*/
export declare function validateNotEmpty(input: string | null | undefined, fieldName: string): string | null;
/**
* Escapes a string that will be written to the Gradle file. The characters need to be escaped
* multiple times, as they also need to be escaped inside the Gradle file.
*
* As an example, "Andre's Code" needs to be written as "Andre\\\'s Code" to the Gradle file, so
* it is properly escaped when passed to AAPT.
*/
export declare function escapeGradleString(input: string): string;
/**
* Removes a file or directory. If the path is a directory, recursively deletes files and
* directories inside it.
*/
export declare function rmdir(path: string): Promise<void>;
/**
* Given a JSON string, the function returns an escaped representation of the string.
* eg: Turns every " instance into \\".
*
* @param {string} stringToReplace the string before the manipulation.
* @returns {string} the string after the manipulation.
*/
export declare function escapeJsonString(stringToReplace: string): string;
export declare function toAndroidScreenOrientation(orientation: Orientation): string;
/**
* Escapes a string that will be used inside a double quoted block in the shell. The characters
* ", $, `, and \ need escaping even when the string is surrounded by double quotes.
*/
export declare function escapeDoubleQuotedShellString(input: string): string;
export declare function validateVersionName(input: string): string | null;
export declare function generateRandomString(length: number): string;
export declare function removeDictionary(path: string): Promise<void>;
export declare function isBase64(iconUrl: string): boolean;
export declare function isImageBuffer(obj: any): boolean;