/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const { styleText } = require( 'util' );

/**
 * Logs an error message about a cross-project reference found in the parsed expression.
 * See: https://github.com/cksource/umberto/issues/1243.
 *
 * @param {Object} data
 * @param {String} data.expression
 * @param {String} [data.source]
 * @returns {String}
 */
module.exports = function logCrossProjectReference( { expression, source } ) {
	process.exitCode = 1;

	const message = `${ styleText( 'red', 'Error:' ) } Failed while convert ${ styleText( 'cyanBright', expression ) } tag`;
	const messageLocation = source ? ` in ${ styleText( 'magentaBright', source ) }.` : '.';
	const messageDescription = ' Cross-project references are not supported.';

	console.log( message + messageLocation + messageDescription );

	return expression;
};
