UNPKG

@progress/kendo-angular-schematics

Version:

Kendo UI Schematics for Angular

72 lines 4.02 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; const schematics_1 = require("@angular-devkit/schematics"); const third_party_1 = require("../third_party"); const kendo_utils_1 = require("../utils/kendo-utils"); // The code for the schematic is forked from: // https://github.com/angular/angular-cli/blob/main/packages/schematics/angular/component/index.ts // We have some added code that we will have to merge. function default_1(options) { return async (host, context) => { const workspace = await (0, third_party_1.getWorkspace)(host); const project = workspace.projects.get(options.project); (0, kendo_utils_1.computeDefaultStandalone)(options, host, project); if (!project) { throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`); } if (options.path === undefined) { options.path = (0, third_party_1.buildDefaultPath)(project); } options.module = (0, third_party_1.findModuleFromOptions)(host, options); const parsedPath = (0, third_party_1.parseName)(options.path, options.name); options.name = parsedPath.name; options.path = parsedPath.path; options.selector = options.selector || (0, third_party_1.buildSelector)(options, (project && project.prefix) || ''); (0, third_party_1.validateHtmlSelector)(options.selector); const skipStyleFile = options.inlineStyle || options.style === third_party_1.Style.None; const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [ // Kendo specific, filters all .include files used as partials in templates. (0, schematics_1.filter)(path => !path.endsWith('.include')), options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(), skipStyleFile ? (0, schematics_1.filter)((path) => !path.endsWith('.__style__.template')) : (0, schematics_1.noop)(), options.inlineTemplate ? (0, schematics_1.filter)((path) => !path.endsWith('.html.template')) : (0, schematics_1.noop)(), (0, schematics_1.applyTemplates)({ ...third_party_1.strings, 'if-flat': (s) => (options.flat ? '' : s), ...options, // Kendo specific, allows the component content to be included in inline and html files. include(path) { return (0, schematics_1.applyContentTemplate)(this)((0, schematics_1.url)("./files")(context).get(path)).content.toString(); }, }), !options.type ? (0, schematics_1.forEach)(((file) => { return file.path.includes('..') ? { content: file.content, path: file.path.replace('..', '.'), } : file; })) : (0, schematics_1.noop)(), (0, schematics_1.move)(parsedPath.path), ]); return (0, schematics_1.chain)([ (0, third_party_1.addDeclarationToNgModule)({ type: 'component', ...options, }), (0, kendo_utils_1.checkOrAddKendoTheme)(options, project), (0, kendo_utils_1.ngAddLocalize)(options, project), (0, kendo_utils_1.npmi)("@progress/kendo-angular-scheduler"), (0, schematics_1.mergeWith)(templateSource), ]); }; } //# sourceMappingURL=index.js.map