@nx/remix
Version:
60 lines (59 loc) • 2.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.remixInitGenerator = remixInitGenerator;
exports.remixInitGeneratorInternal = remixInitGeneratorInternal;
const devkit_1 = require("@nx/devkit");
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
const plugin_1 = require("../../plugins/plugin");
const versions_1 = require("../../utils/versions");
function remixInitGenerator(tree, options) {
return remixInitGeneratorInternal(tree, { addPlugin: false, ...options });
}
async function remixInitGeneratorInternal(tree, options) {
const tasks = [];
if (!options.skipPackageJson) {
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
'@remix-run/serve': versions_1.remixVersion,
}, {
'@nx/web': versions_1.nxVersion,
'@remix-run/dev': versions_1.remixVersion,
}, undefined, options.keepExistingVersions);
tasks.push(installTask);
}
const nxJson = (0, devkit_1.readNxJson)(tree);
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
nxJson.useInferencePlugins !== false;
options.addPlugin ??= addPluginDefault;
if (options.addPlugin) {
await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/remix/plugin', plugin_1.createNodesV2, {
startTargetName: ['start', 'remix:start', 'remix-start'],
buildTargetName: ['build', 'remix:build', 'remix-build'],
devTargetName: ['dev', 'remix:dev', 'remix-dev'],
typecheckTargetName: [
'typecheck',
'remix:typecheck',
'remix-typecheck',
],
serveStaticTargetName: [
'serve-static',
'remix:serve-static',
'remix-serve-static',
],
buildDepsTargetName: [
'build-deps',
'remix:build-deps',
'remix-build-deps',
],
watchDepsTargetName: [
'watch-deps',
'remix:watch-deps',
'remix-watch-deps',
],
}, options.updatePackageScripts);
}
if (!options.skipFormat) {
await (0, devkit_1.formatFiles)(tree);
}
return (0, devkit_1.runTasksInSerial)(...tasks);
}
exports.default = remixInitGenerator;