UNPKG

ng-alain-plugin-theme

Version:
55 lines (54 loc) 2.39 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.genColorLess = void 0; const utils_1 = require("./utils"); const color_generator_1 = require("./color-generator"); const fs_1 = require("fs"); const path_1 = require("path"); const primaryColorVariable = '@primary-color'; const root = process.cwd(); function fixConfig(config) { var _a; let styleSourceRoot = 'src'; if (config.name) { const angularJsonPath = (0, path_1.join)(root, 'angular.json'); const sourceRoot = (_a = (0, utils_1.getJSON)(angularJsonPath)) === null || _a === void 0 ? void 0 : _a.projects[config.name].sourceRoot; if (sourceRoot != null) { styleSourceRoot = sourceRoot; } } config = (0, utils_1.deepMergeKey)({ variables: [], ngZorroAntd: `./node_modules/ng-zorro-antd/`, styleFilePath: `./${styleSourceRoot}/styles.less`, themeFilePath: `./${styleSourceRoot}/styles/theme.less`, outputFilePath: `./${styleSourceRoot}/assets/color.less`, thirdLibaryNames: ['@delon', 'ng-zorro-antd'], }, false, config); if (!Array.isArray(config.variables)) { config.variables = []; } if (!config.variables.includes(primaryColorVariable)) { config.variables.push(primaryColorVariable); } return config; } function genColorLess(config) { return __awaiter(this, void 0, void 0, function* () { config = fixConfig(config); if ((0, fs_1.existsSync)(config.outputFilePath)) { (0, fs_1.unlinkSync)(config.outputFilePath); } yield (0, color_generator_1.generateTheme)(config); }); } exports.genColorLess = genColorLess;