sb-mig
Version:
CLI to rule the world. (and handle stuff related to Storyblok CMS)
48 lines (47 loc) • 1.66 kB
TypeScript
export interface DiscoveredResource {
name: string;
filePath: string;
type: "local" | "external";
}
export interface LoadedResource {
name: string;
filePath: string;
data: any;
error?: string;
}
/**
* Load the content of a resource file (.sb.js, .datasource.js, etc.)
* Uses dynamic import to load ES modules and CommonJS
*/
export declare function loadResourceContent(filePath: string): Promise<any>;
/**
* Load multiple resources by file path
*/
export declare function loadResources(filePaths: string[]): Promise<LoadedResource[]>;
/**
* Options for component discovery
*/
export interface DiscoverComponentsOptions {
/** File extensions to search for (default: [".sb.ts", ".sb.cjs"]) */
extensions?: string[];
/** Whether to include external (node_modules) components (default: true) */
includeExternal?: boolean;
/** Maximum depth to scan (default: 20, prevents runaway scanning) */
maxDepth?: number;
}
/**
* Discover components in the working directory
* Prefers .ts for local files and .cjs for external (node_modules) files
* to avoid duplicates when both ESM and CJS versions exist
*
* Security: Stays within project bounds and doesn't follow symlinks outside
*/
export declare function discoverComponents(workingDir: string, options?: DiscoverComponentsOptions): Promise<DiscoveredResource[]>;
/**
* Discover datasources in the working directory
*/
export declare function discoverDatasources(workingDir: string): Promise<DiscoveredResource[]>;
/**
* Discover roles in the working directory
*/
export declare function discoverRoles(workingDir: string): Promise<DiscoveredResource[]>;