@nx/remix
Version:
46 lines (45 loc) • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.servePostTargetTransformer = servePostTargetTransformer;
const utils_1 = require("./utils");
function servePostTargetTransformer(migrationLogs) {
return (target, tree, projectDetails, inferredTargetConfiguration) => {
if (target.options) {
handlePropertiesFromTargetOptions(tree, target.options, projectDetails.projectName, projectDetails.root);
}
if (target.configurations) {
for (const configurationName in target.configurations) {
const configuration = target.configurations[configurationName];
handlePropertiesFromTargetOptions(tree, configuration, projectDetails.projectName, projectDetails.root);
}
if (Object.keys(target.configurations).length === 0) {
if ('defaultConfiguration' in target) {
delete target.defaultConfiguration;
}
delete target.configurations;
}
if ('defaultConfiguration' in target &&
!target.configurations[target.defaultConfiguration]) {
delete target.defaultConfiguration;
}
}
return target;
};
}
function handlePropertiesFromTargetOptions(tree, options, projectName, projectRoot) {
if ('debug' in options) {
delete options.debug;
}
if ('port' in options) {
options.env ??= {};
options.env.PORT = `${options.port}`;
delete options.port;
}
for (const [prevKey, newKey] of Object.entries(utils_1.REMIX_PROPERTY_MAPPINGS)) {
if (prevKey in options) {
let prevValue = options[prevKey];
delete options[prevKey];
options[newKey] = prevValue;
}
}
}