UNPKG

@nx/angular

Version:

The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: - Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypre

55 lines (54 loc) 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LibMigrator = void 0; const devkit_1 = require("@nx/devkit"); const devkit_2 = require("@nx/devkit"); const utilities_1 = require("../../utilities"); const builders_1 = require("../builders"); const project_migrator_1 = require("./project.migrator"); const supportedBuilderMigrators = [ builders_1.AngularDevkitNgPackagrMigrator, builders_1.AngularBuildUnitTestMigrator, builders_1.AngularDevkitKarmaMigrator, builders_1.AngularEslintLintMigrator, ]; class LibMigrator extends project_migrator_1.ProjectMigrator { constructor(tree, options, project, logger) { super(tree, options, {}, project, 'libs', logger, supportedBuilderMigrators); } async migrate() { await super.migrate(); if (this.skipMigration === true) { return; } await this.updateProjectConfiguration(); this.moveProjectFiles(); for (const builderMigrator of this.builderMigrators ?? []) { await builderMigrator.migrate(); } } validate() { const errors = [...(super.validate() ?? [])]; for (const builderMigrator of this.builderMigrators) { errors.push(...(builderMigrator.validate() ?? [])); } return errors.length ? errors : null; } moveProjectFiles() { this.moveDir(this.project.oldRoot, this.project.newRoot); } async updateProjectConfiguration() { (0, utilities_1.convertToNxProject)(this.tree, this.project.name); this.moveFile((0, devkit_1.joinPathFragments)(this.project.oldRoot, 'project.json'), (0, devkit_1.joinPathFragments)(this.project.newRoot, 'project.json')); this.projectConfig.root = this.project.newRoot; this.projectConfig.sourceRoot = this.project.newSourceRoot; if (!this.projectConfig.targets || !Object.keys(this.projectConfig.targets).length) { this.logger.warn('The project does not have any targets configured. This might not be an issue. Skipping updating targets.'); } (0, devkit_2.updateProjectConfiguration)(this.tree, this.project.name, { ...this.projectConfig, }); } } exports.LibMigrator = LibMigrator;