UNPKG

@nova-ui/dashboards

Version:

Nova Dashboards is a framework designed to provide feature developers with a common solution for presenting data coming from various sources within a single view, as well as a set of predefined widget visualizations that are 100% configuration-driven and

99 lines 4.88 kB
"use strict"; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const ast_utils_1 = require("@schematics/angular/utility/ast-utils"); const change_1 = require("@schematics/angular/utility/change"); const dependencies_1 = require("@schematics/angular/utility/dependencies"); const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils"); const schematics_2 = require("@nova-ui/bits/sdk/schematics"); const stylePaths = ["./node_modules/@nova-ui/charts/bundles/css/styles.css"]; function default_1(options) { if (!options.project) { throw new schematics_1.SchematicsException("Option (project) is required."); } return (0, schematics_1.chain)([ options && options.skipPackageJson ? (0, schematics_1.noop)() : addPackageJsonDependencies(), options && options.skipPackageJson ? (0, schematics_1.noop)() : (0, schematics_2.installPackageJsonDependencies)(), options && options.skipModuleUpdate ? (0, schematics_1.noop)() : updateModuleFile(options), options && options.skipCss ? (0, schematics_1.noop)() : (0, schematics_2.addStylesToAngularJson)(options, stylePaths), ]); } exports.default = default_1; function addPackageJsonDependencies() { return (host, context) => { const { peerDependencies } = require("../../../package.json"); const dependencies = (0, schematics_2.assembleDependencies)(peerDependencies); dependencies.forEach((dependency) => { (0, dependencies_1.addPackageJsonDependency)(host, dependency); context.logger.info(`✅️ Added "${dependency.name}" into ${dependency.type}`); }); return host; }; } function updateModuleFile(options) { return (host, context) => { try { const projectTargets = (0, schematics_2.getBrowserProjectTargets)(host, options); // @ts-ignore ng 17 defaults to application builder which has browser const mainPath = projectTargets.options["browser"]; const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath); const moduleSource = (0, schematics_2.readIntoSourceFile)(host, modulePath); const declarationRecorder = host.beginUpdate(modulePath); const modules = [ { item: `BrowserAnimationsModule`, path: `@angular/platform-browser/animations`, }, { item: `NuiDashboardsModule`, path: `@nova-ui/dashboards` }, ]; modules.forEach((module) => { if (!(0, ast_utils_1.isImported)(moduleSource, module.item, module.path)) { const moduleChanges = (0, ast_utils_1.addImportToModule)(moduleSource, modulePath, module.item, module.path); moduleChanges.forEach((change) => { if (change instanceof change_1.InsertChange) { declarationRecorder.insertLeft(change.pos, change.toAdd); } }); context.logger.info(` recorded ${module.item} add`); } else { context.logger.info(` ${module.item} already imported`); } }); host.commitUpdate(declarationRecorder); context.logger.info(`✅️ Updated module file`); } catch (ex) { context.logger.error(`🚫 Failed updating module: ${ex.toString()}`); } return host; }; } //# sourceMappingURL=index.js.map