UNPKG

@nx/next

Version:

The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides: - Scaffolding for creating, building, serving, linting, and testing Next.js applications. - Integration wit

45 lines (44 loc) 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertToInferred = convertToInferred; const devkit_1 = require("@nx/devkit"); const aggregate_log_util_1 = require("@nx/devkit/src/generators/plugin-migrations/aggregate-log-util"); const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator"); const plugin_1 = require("../../plugins/plugin"); const build_post_target_transformer_1 = require("./lib/build-post-target-transformer"); const serve_post_target_tranformer_1 = require("./lib/serve-post-target-tranformer"); async function convertToInferred(tree, options) { const projectGraph = await (0, devkit_1.createProjectGraphAsync)(); const migrationLogs = new aggregate_log_util_1.AggregatedLog(); const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/next/plugin', plugin_1.createNodesV2, { buildTargetName: 'build', devTargetName: 'dev', startTargetName: 'start', serveStaticTargetName: 'serve-static', }, [ { executors: ['@nx/next:build'], postTargetTransformer: (0, build_post_target_transformer_1.buildPostTargetTransformer)(migrationLogs), targetPluginOptionMapper: (targetName) => ({ buildTargetName: targetName, }), }, { executors: ['@nx/next:server'], postTargetTransformer: (0, serve_post_target_tranformer_1.servePosTargetTransformer)(migrationLogs), targetPluginOptionMapper: (targetName) => ({ devTargetName: targetName, }), }, ], options.project); if (migratedProjects.size === 0) { throw new executor_to_plugin_migrator_1.NoTargetsToMigrateError(); } if (!options.skipFormat) { await (0, devkit_1.formatFiles)(tree); } return () => { migrationLogs.flushLogs(); }; } exports.default = convertToInferred;