@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
70 lines (69 loc) • 3.23 kB
TypeScript
import { Schema, SchemaValues } from '@sprucelabs/schema';
import { Templates } from '@sprucelabs/spruce-templates';
import { GlobalEmitter } from '../GlobalEmitter';
import ServiceFactory, { Service, ServiceProvider, ServiceMap } from '../services/ServiceFactory';
import StoreFactory, { StoreCode, CreateStoreOptions, StoreMap } from '../stores/StoreFactory';
import { ApiClient, ApiClientFactory, ApiClientFactoryOptions } from '../types/apiClient.types';
import { NpmPackage, GeneratedFile, FileDescription } from '../types/cli.types';
import { GraphicsInterface } from '../types/cli.types';
import { WriterOptions } from '../writers/AbstractWriter';
import { WriterCode, WriterMap } from '../writers/WriterFactory';
import ActionExecuter from './ActionExecuter';
import ActionFactory from './ActionFactory';
import FeatureInstaller from './FeatureInstaller';
import { FeatureCode } from './features.types';
export default abstract class AbstractFeature<S extends Schema | undefined = Schema | undefined> implements ServiceProvider {
abstract description: string;
readonly dependencies: FeatureDependency[];
readonly packageDependencies: NpmPackage[];
readonly optionsSchema?: S;
readonly fileDescriptions: FileDescription[];
isInstalled?(): Promise<boolean>;
abstract readonly code: FeatureCode;
abstract readonly nameReadable: string;
readonly installOrderWeight: number;
cwd: string;
scripts: Record<string, any>;
actionsDir: string | undefined;
protected actions?: ActionFactory;
protected templates: Templates;
protected emitter: GlobalEmitter;
protected features: FeatureInstaller;
protected ui: GraphicsInterface;
private serviceFactory;
private storeFactory;
private writers;
private apiClientFactory;
private actionExecuter;
private actionCodes?;
constructor(options: FeatureOptions);
protected Action(featureCode: string, actionCode: string): import("./features.types").FeatureAction<Schema>;
beforePackageInstall(_options: S extends Schema ? SchemaValues<S> : undefined): Promise<InstallResults>;
afterPackageInstall(_options: S extends Schema ? SchemaValues<S> : undefined): Promise<InstallResults>;
Service<S extends Service>(type: S, cwd?: string): ServiceMap[S];
Writer<C extends WriterCode>(code: C, options?: Partial<WriterOptions>): WriterMap[C];
getFeature<Code extends FeatureCode>(code: Code): import("./features.types").FeatureMap[Code];
getAvailableActionCodes(): Promise<string[]>;
Store<C extends StoreCode>(code: C, options?: CreateStoreOptions<C>): StoreMap[C];
protected connectToApi(options?: ApiClientFactoryOptions): Promise<ApiClient>;
}
export interface InstallResults {
files?: GeneratedFile[];
cwd?: string;
}
export interface FeatureDependency {
isRequired: boolean;
code: FeatureCode;
}
export interface FeatureOptions {
cwd: string;
serviceFactory: ServiceFactory;
templates: Templates;
storeFactory: StoreFactory;
actionFactory?: ActionFactory;
featureInstaller: FeatureInstaller;
ui: GraphicsInterface;
emitter: GlobalEmitter;
apiClientFactory: ApiClientFactory;
actionExecuter: ActionExecuter;
}