@nx/remix
Version:
72 lines (71 loc) • 3.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildPostTargetTransformer = buildPostTargetTransformer;
const utils_1 = require("./utils");
const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
function buildPostTargetTransformer(migrationLogs) {
return (target, tree, projectDetails, inferredTargetConfiguration) => {
const remixConfigPath = (0, utils_1.getConfigFilePath)(tree, projectDetails.root);
if (target.options) {
handlePropertiesFromTargetOptions(tree, target.options, projectDetails.projectName, projectDetails.root, migrationLogs);
}
if (target.configurations) {
for (const configurationName in target.configurations) {
const configuration = target.configurations[configurationName];
handlePropertiesFromTargetOptions(tree, configuration, projectDetails.projectName, projectDetails.root, migrationLogs);
}
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;
}
}
if (target.outputs) {
target.outputs = target.outputs.filter((out) => !out.includes('options.outputPath'));
(0, plugin_migration_utils_1.processTargetOutputs)(target, [], inferredTargetConfiguration, {
projectName: projectDetails.projectName,
projectRoot: projectDetails.root,
});
}
return target;
};
}
function handlePropertiesFromTargetOptions(tree, options, projectName, projectRoot, migrationLogs) {
if ('outputPath' in options) {
migrationLogs.addLog({
project: projectName,
executorName: '@nx/remix:build',
log: "Unable to migrate 'outputPath'. The Remix Config will contain the locations the build artifact will be output to.",
});
delete options.outputPath;
}
if ('includeDevDependenciesInPackageJson' in options) {
migrationLogs.addLog({
project: projectName,
executorName: '@nx/remix:build',
log: "Unable to migrate `includeDevDependenciesInPackageJson` to Remix Config. Use the `@nx/dependency-checks` ESLint rule to update your project's package.json.",
});
delete options.includeDevDependenciesInPackageJson;
}
if ('generatePackageJson' in options) {
migrationLogs.addLog({
project: projectName,
executorName: '@nx/remix:build',
log: "Unable to migrate `generatePackageJson` to Remix Config. Use the `@nx/dependency-checks` ESLint rule to update your project's package.json.",
});
delete options.generatePackageJson;
}
if ('generateLockfile' in options) {
migrationLogs.addLog({
project: projectName,
executorName: '@nx/remix:build',
log: 'Unable to migrate `generateLockfile` to Remix Config. This option is not supported.',
});
delete options.generateLockfile;
}
}