@wix/cli
Version:
CLI tool for building Wix sites and applications
105 lines (97 loc) • 2.56 kB
TypeScript
import * as Emittery from 'emittery';
import Emittery__default from 'emittery';
interface DevDcUpdatedCtx {
overrideId: string;
}
interface ProjectErrorLocation {
file: string;
line?: number;
column?: number;
}
interface ProjectError {
raw?: string;
message?: string;
location?: ProjectErrorLocation;
stack?: string;
}
type CliErrorCtx = {
type: 'cli-system';
error: Error;
} | {
type: 'cli-user';
error: Error;
} | {
type: 'project';
errors: ProjectError[];
};
interface EventsMap {
'cli-error': CliErrorCtx;
'dc-updated': DevDcUpdatedCtx;
}
interface PluginsInterface {
hooksEmitter: Emittery__default<HookPayloadsMap>;
eventsEmitter: Emittery__default<EventsMap>;
onPluginError?: (error: unknown, context: {
pluginName: string;
handlerName: string;
}) => void;
}
declare class UserEventWrapper {
private readonly pluginsInterface;
private readonly pluginName;
constructor(pluginsInterface: PluginsInterface, pluginName: string);
on<K extends keyof EventsMap>(key: K, callback: (data: EventsMap[K]) => void | Promise<void>): Emittery.UnsubscribeFunction;
}
type CliCommand = 'dev' | 'build' | 'preview';
interface HookPayloadsMap {
'cli:setup': {
cmd: CliCommand;
};
}
interface UserHooksMap extends HookPayloadsMap {
'cli:setup': {
cmd: CliCommand;
emitter: UserEventWrapper;
};
}
type UserHooksHandlers = {
[K in keyof UserHooksMap]?: (data: UserHooksMap[K]) => void | Promise<void>;
};
type WixAstroSiteOutputDirectory = {
client: string;
server?: string;
} | {
client?: string;
server: string;
};
interface WixAstroSiteConfig {
$schema?: string;
projectType: 'Site';
appId: string;
siteId: string;
site?: {
outputDirectory: string | WixAstroSiteOutputDirectory;
};
}
interface WixAstroAppConfig {
$schema?: string;
projectType: 'App';
appId: string;
projectId?: string;
codeIdentifier?: string;
namespace?: string;
}
type WixAstroConfig = WixAstroSiteConfig | WixAstroAppConfig;
interface WixCliPluginShape {
name: string;
hooks?: Record<string, unknown>;
}
interface WixCliPlugin extends WixCliPluginShape {
hooks?: UserHooksHandlers;
}
interface DefineWixConfigOptions {
config: WixAstroConfig;
plugins?: WixCliPlugin[];
}
declare const defineWixConfig: (options: DefineWixConfigOptions) => DefineWixConfigOptions;
export { type CliErrorCtx, type WixAstroConfig, type WixCliPlugin, defineWixConfig };