@ima/cli
Version:
IMA.js CLI tool to build, develop and work with IMA.js applications.
59 lines (58 loc) • 2.77 kB
TypeScript
import { StringStructure } from '@messageformat/core/lib/compile-module';
import { ImaConfig } from '../types';
/**
* Returns path to location of compiled messageformat JS modules
* for given locale.
*
* @param locale Currently processed locale identifier.
* @param rootDir Current compilation root directory.
* @returns Path to compiled locale module.
*/
export declare function getLanguageModulePath(locale: string, rootDir: string): string;
/**
* Returns path to location of compiled messageformat JS modules
* for given locale.
*
* @param locale Currently processed locale identifier.
* @param rootDir Current compilation root directory.
* @returns Path to compiled locale module.
*/
export declare function getLanguageEntryPath(locale: string, rootDir: string): string;
/**
* Parses dictionary key from given filename and locale identifier.
*
* @param locale Currently processed locale identifier.
* @param languagePath Path to currently processed JSON language file.
* @returns Parsed dictionary key.
*/
export declare function getDictionaryKeyFromFileName(locale: string, languagePath: string): string;
/**
* Returns entry points to use in webpack configurations. These then lead to
* messageformat compiled modules while also containing some additional runtime code.
*
* @param languages Languages object from ima config.
* @param rootDir Current compilation root directory.
* @returns Object with webpack entry points.
*/
export declare function getLanguageEntryPoints(languages: ImaConfig['languages'], rootDir: string, useHMR?: boolean): Record<string, string>;
export declare function generateTypeDeclarations(rootDir: string, messages: StringStructure): Promise<void>;
/**
* Parses language JSON files at languagePaths into messages dictionary object,
* compiles the final messages object into messageformat JS module and outputs
* it to filesystem at outputPath.
*
* @param messages Object which contains dictionary of parsed languages.
* @param locale Currently processed locale identifier.
* @param languagePaths Paths to JSON language files which should be processed.
* @param outputPath Output path for the messageformat JS module.
*/
export declare function parseLanguageFiles(messages: Record<string, any>, locale: string, languagePaths: string | string[], outputPath: string): Promise<void | never>;
/**
* Compile language files defined in imaConfig.
*
* @param imaConfig ima.config.js file contents.
* @param rootDir Current compilation root directory.
* @param watch When set to true, it creates chokidar instances
* which watch language files for changes and trigger recompilation.
*/
export declare function compileLanguages(imaConfig: ImaConfig, rootDir: string, watch?: boolean): Promise<void>;