UNPKG

@netgrif/components-core

Version:

Netgrif Application engine frontend core Angular library

37 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.schematicEntryPoint = void 0; const ts = require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript"); const utility_functions_1 = require("../../_utility/utility-functions"); const ast_utils_1 = require("@schematics/angular/utility/ast-utils"); /** * Adds a new provider to all subclasses of CaseView in the project */ function schematicEntryPoint() { return (tree) => { (0, utility_functions_1.forEachProjectFile)(tree, (file) => { if (file.path.endsWith('.ts') && !file.path.endsWith('.spec.ts')) { const source = (0, utility_functions_1.fileEntryToTsSource)(file); const extendsKeywords = (0, ast_utils_1.findNodes)(source, ts.SyntaxKind.ExtendsKeyword); if (extendsKeywords === null || extendsKeywords.length === 0) { return; // continue } let extendsCaseView = false; for (const node of extendsKeywords) { const identifiers = (0, utility_functions_1.findNodesInChildren)(node.parent, ts.SyntaxKind.Identifier, true); if (identifiers.some(identifier => identifier.getText() === 'AbstractCaseView' || identifier.getText() === 'TabbedCaseView')) { extendsCaseView = true; break; } } if (extendsCaseView) { const changes = (0, utility_functions_1.addProviderToComponent)(file, 'SearchChipService', undefined, '@netgrif/components-core'); (0, utility_functions_1.commitChangesToFile)(tree, file, changes); } } }); }; } exports.schematicEntryPoint = schematicEntryPoint; //# sourceMappingURL=migration-4.1.js.map