@swell/cli
Version:
Swell's command line interface/utility
158 lines (157 loc) • 5.33 kB
TypeScript
/// <reference types="node" />
import { AppConfig } from './app-config.js';
export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
export { allBaseFilesInDir, allConfigDirsPaths, allConfigFilesInDir, allConfigFilesPaths, allConfigFilesPathsByType, getAllConfigPaths, globAllFilesByPath, isPathDirectory, } from './paths.js';
export declare const PUSH_CONCURRENCY = 3;
/**
* An app as defined by the Swell API. This is different than an app
* configuration that developers define.
*/
export interface App {
categories?: Array<string>;
client?: any;
client_id?: string;
compatibilities?: {
[key: string]: string;
};
configs?: AppConfig[];
date_created?: string;
date_updated?: string;
description?: string;
extensions?: Array<any>;
features?: Array<string>;
frontend?: {
deployment?: null | object;
deployment_hash?: string;
deployment_id?: string;
framework?: string;
service?: string;
url?: string;
};
highlights?: Array<{
id: string;
image_src?: unknown;
title: string;
}>;
id?: string;
installed?: {
date_created: string;
id: string;
};
kind?: string;
logo_icon?: unknown;
name?: string;
preview_image?: unknown;
preview_mobile_image?: unknown;
private_id?: string;
public_id?: string;
published?: boolean;
purchase_options?: Array<string>;
storefront?: {
[key: string]: any;
};
styles?: Array<{
color: string;
color_alt?: string;
id: string;
label: string;
preview_image?: unknown;
preview_mobile_image?: unknown;
}>;
theme?: {
[key: string]: any;
};
type?: string;
use_cases?: Array<string>;
version?: string;
}
export declare enum SwellJsonFields {
DESCRIPTION = "description",
EXTENSIONS = "extensions",
ID = "id",
KIND = "kind",
NAME = "name",
PERMISSIONS = "permissions",
STOREFRONT = "storefront",
THEME = "theme",
TYPE = "type",
VERSION = "version"
}
export interface AppVersion {
date_created: string;
description?: string;
id: string;
name: string;
published?: boolean;
release_notes?: string;
released?: boolean;
supported?: boolean;
version: string;
}
export declare enum ConfigType {
ASSET = "asset",
CONTENT = "content",
FILE = "file",
FRONTEND = "frontend",
FUNCTION = "function",
MODEL = "model",
NOTIFICATION = "notification",
SETTING = "setting",
THEME = "theme",
WEBHOOK = "webhook"
}
export type ConfigTypeKey = keyof typeof ConfigType;
export declare const StorefrontConfigTypes: ConfigTypeKey[];
export declare const ThemeConfigTypes: ConfigTypeKey[];
export type ConfigPathsType = {
[key in ConfigTypeKey]: string;
};
export declare const AllConfigPaths: ConfigPathsType;
export declare const StandardConfigPaths: ConfigPathsType;
export declare const StorefrontConfigPaths: ConfigPathsType;
export declare const ThemeConfigPaths: ConfigPathsType;
export declare enum ConfigInputFields {
FILE = "file",
NAME = "name",
TYPE = "type",
VALUES = "values",
VERSION = "version"
}
export interface FrontendProjectType {
buildCommand?: string;
devCommand: string;
installCommand?: string;
mainPackage: string;
name: string;
slug: string;
}
export declare const FrontendProjectTypes: FrontendProjectType[];
export declare function getFrontendProjectSlugs(withNone?: boolean, withLegacy?: boolean): string[];
export declare function getFrontendProjectValidValues(withNone?: boolean, withLegacy?: boolean): string;
export declare function getAppSlugId(app: App): string | undefined;
export declare function getFrontendProjectType(appPath: string): FrontendProjectType | undefined;
export declare function getConfigTypeFromPath(path: string): ConfigType | undefined;
export declare function getConfigTypeKeyFromValue(value: string): string | undefined;
export declare function filePathExists(filePath: string): boolean;
export declare function filePathExistsAsync(filePath: string): Promise<boolean>;
export declare function writeFile(file: string, data: string): Promise<void>;
export declare function deleteFile(file: string): Promise<void>;
export declare function writeJsonFile(file: string, data?: any): Promise<void>;
export declare function hashFile(filePath: string, fileContents?: Buffer, relativePath?: string): string;
export declare function hashString(...contents: (Buffer | string)[]): string;
export declare function appAssetImage(appPath: string, fileName: string): string | undefined;
export declare function appConfigFromFile(filePath: string, configType: ConfigType, appPath: string): AppConfig;
export declare function findAppConfig(app: App, filePath: string, configType: ConfigType): AppConfig | undefined;
interface BatchAppFiles {
configs: AppConfig[];
type: ConfigType;
label: string;
concurrency: number;
}
/**
* Get files to push in batches prioritized by dependencies
*
* @param {AppConfig[]} configs - List of app configs
* @returns {BatchAppFiles[]} Batches of files to push
*/
export declare function batchAppFilesByType(configs: AppConfig[]): BatchAppFiles[];