UNPKG

typeorm-codebase-sync

Version:

Automatically update your codebase to add migrations, entities and subscribers to your `data-source.ts` file

71 lines (70 loc) 4.21 kB
export declare class ImportAndAddItemToInitializerArrayProperty { readonly filePath: string; readonly initializerName: string; readonly initializerPropertyName: string; readonly importedFilePath: string; readonly importedFileImportName: string; readonly importedFileExportName: string; readonly importDefault: boolean; readonly updateOtherRelevantFiles: boolean; readonly treatImportNamespaceAsList: boolean; readonly exportImportAllFromFileWhenImportingNamespace: boolean; readonly treatObjectLiteralExpressionValuesAsList: boolean; readonly instantiateObjectLiteralExpressionValuesByDefault: boolean; private codebase; private referenceAdded; private importAdded; private filesToAddImportInFilePaths; private declarationReplacementMap; private linkingError; /** * @param {string} filePath - file path of the file to edit * @param {string} initializerName - name of the class while its instantiation should be manipulated * @param {string} initializerPropertyName - name of the property that should be manipulated * @param {string} importedFilePath - file path of the file to import * @param {string} importedFileImportName - name of the import to use in the manipulated array * @param {undefined | string} importedFileExportName - name of the export from `importedFilePath` file * @param {boolean} importDefault - is the export from `importedFilePath` file a default export? * @param {undefined | "esm" | "commonjs"} moduleSystem - determines whether an `.js` extension should be used in the import, * if omitted then it's determined automatically * @param {boolean} updateOtherRelevantFiles - should other files other than the `filePath` can be updated if necessary? * @param {boolean} treatImportNamespaceAsList - given `import * as value from "./something"` treat `value` as a valid list * @param {boolean} exportImportAllFromFileWhenImportingNamespace - in `treatImportNamespaceAsList` case, * add `export * from "./importedFilePath` instead of `export { importedFileImportName } from "./importedFilePath` * @param {boolean} treatObjectLiteralExpressionValuesAsList - given `{Something, Something2: Something3}` * the result will be `{Something, Something2: Something3, importedFileImportName}` * @param {boolean} instantiateObjectLiteralExpressionValuesByDefault - use object literal expression values when * creating the `initializerPropertyName` property. See `treatObjectLiteralExpressionValuesAsList` parameter */ constructor({ filePath, initializerName, initializerPropertyName, importedFilePath, importedFileImportName, importedFileExportName, importDefault, updateOtherRelevantFiles, treatImportNamespaceAsList, exportImportAllFromFileWhenImportingNamespace, treatObjectLiteralExpressionValuesAsList, instantiateObjectLiteralExpressionValuesByDefault, moduleSystem }: { filePath: string; initializerName: string; initializerPropertyName: string; importedFilePath: string; importedFileImportName: string; importedFileExportName: string; importDefault: boolean; updateOtherRelevantFiles: boolean; treatImportNamespaceAsList?: boolean; exportImportAllFromFileWhenImportingNamespace?: boolean; treatObjectLiteralExpressionValuesAsList?: boolean; instantiateObjectLiteralExpressionValuesByDefault?: boolean; moduleSystem?: "esm" | "commonjs"; }); /** * @returns {string[]} - list of modified file paths. empty list means no files could be modified. */ manipulateCodebase(): Promise<string[]>; private findAndUpdateInitializer; private addToExistingInitializerArgumentsPropertyArgumentsHandler; private createNewPropertyAssignment; private addNewInitializerArgumentsPropertyArgumentsHandler; private updateExpression; private updateArrayLiteralExpression; private updateObjectLiteralExpression; private handleDeclaration; private addExportFromImportToSourceFile; private updateDeclaration; private updateGlobalFileDeclarations; private addImportToSourceFile; }