HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-172-31-4-197 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/web.enelar.com.co/node_modules/nx/src/project-graph/utils/normalize-project-nodes.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeImplicitDependencies = exports.normalizeProjectTargets = exports.normalizeProjectNodes = void 0;
const find_matching_projects_1 = require("../../utils/find-matching-projects");
const logger_1 = require("../../utils/logger");
const project_configuration_utils_1 = require("../utils/project-configuration-utils");
async function normalizeProjectNodes(ctx, builder, nxJson) {
    const toAdd = [];
    // Sorting projects by name to make sure that the order of projects in the graph is deterministic.
    // This is important to ensure that expanded properties referencing projects (e.g. implicit dependencies)
    // are also deterministic, and thus don't cause the calculated project configuration hash to shift.
    const projects = Object.keys(ctx.projects).sort();
    // Used for expanding implicit dependencies (e.g. `@proj/*` or `tag:foo`)
    const partialProjectGraphNodes = projects.reduce((graph, project) => {
        const projectConfiguration = ctx.projects[project];
        graph[project] = {
            name: project,
            type: projectConfiguration.projectType === 'library' ? 'lib' : 'app',
            data: {
                ...projectConfiguration,
            },
        };
        return graph;
    }, {});
    for (const key of projects) {
        const p = ctx.projects[key];
        p.implicitDependencies = normalizeImplicitDependencies(key, p.implicitDependencies, partialProjectGraphNodes);
        p.targets = normalizeProjectTargets(p, nxJson.targetDefaults, key);
        // TODO: remove in v16
        const projectType = p.projectType === 'application'
            ? key.endsWith('-e2e') || key === 'e2e'
                ? 'e2e'
                : 'app'
            : 'lib';
        const tags = ctx.projects?.[key]?.tags || [];
        toAdd.push({
            name: key,
            type: projectType,
            data: {
                ...p,
                tags,
            },
        });
    }
    // Sort by root directory length (do we need this?)
    toAdd.sort((a, b) => {
        if (!a.data.root)
            return -1;
        if (!b.data.root)
            return -1;
        return a.data.root.length > b.data.root.length ? -1 : 1;
    });
    toAdd.forEach((n) => {
        builder.addNode({
            name: n.name,
            type: n.type,
            data: n.data,
        });
    });
}
exports.normalizeProjectNodes = normalizeProjectNodes;
/**
 * Apply target defaults and normalization
 */
function normalizeProjectTargets(project, targetDefaults, projectName) {
    // Any node on the graph will have a targets object, it just may be empty
    const targets = project.targets ?? {};
    for (const target in targets) {
        // We need to know the executor for use in readTargetDefaultsForTarget,
        // but we haven't resolved the `command` syntactic sugar yet.
        const executor = targets[target].executor ??
            (targets[target].command ? 'nx:run-commands' : null);
        // Allows things like { targetDefaults: { build: { command: tsc } } }
        const defaults = resolveCommandSyntacticSugar((0, project_configuration_utils_1.readTargetDefaultsForTarget)(target, targetDefaults, executor), `targetDefaults:${target}`);
        targets[target] = resolveCommandSyntacticSugar(targets[target], `${projectName}:${target}`);
        if (defaults) {
            targets[target] = (0, project_configuration_utils_1.mergeTargetConfigurations)(targets[target], defaults);
        }
        targets[target].options = (0, project_configuration_utils_1.resolveNxTokensInOptions)(targets[target].options, project, `${projectName}:${target}`);
        targets[target].configurations ??= {};
        for (const configuration in targets[target].configurations) {
            targets[target].configurations[configuration] = (0, project_configuration_utils_1.resolveNxTokensInOptions)(targets[target].configurations[configuration], project, `${projectName}:${target}:${configuration}`);
        }
    }
    return targets;
}
exports.normalizeProjectTargets = normalizeProjectTargets;
function normalizeImplicitDependencies(source, implicitDependencies, projects) {
    if (!implicitDependencies?.length) {
        return implicitDependencies ?? [];
    }
    const matches = (0, find_matching_projects_1.findMatchingProjects)(implicitDependencies, projects);
    return (matches
        .filter((x) => x !== source)
        // implicit dependencies that start with ! should hang around, to be processed by
        // implicit-project-dependencies.ts after explicit deps are added to graph.
        .concat(implicitDependencies.filter((x) => x.startsWith('!'))));
}
exports.normalizeImplicitDependencies = normalizeImplicitDependencies;
function resolveCommandSyntacticSugar(target, key) {
    const { command, ...config } = target ?? {};
    if (!command) {
        return target;
    }
    if (config.executor) {
        throw new Error(`${logger_1.NX_PREFIX} ${key} should not have executor and command both configured.`);
    }
    else {
        return {
            ...config,
            executor: 'nx:run-commands',
            options: {
                ...config.options,
                command: command,
            },
        };
    }
}