@nx/remix
Version:
27 lines (26 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeRoutePath = normalizeRoutePath;
exports.checkRoutePathForErrors = checkRoutePathForErrors;
exports.resolveRemixAppDirectory = resolveRemixAppDirectory;
const devkit_1 = require("@nx/devkit");
const path_1 = require("path");
const remix_config_1 = require("./remix-config");
function normalizeRoutePath(path) {
return path.indexOf('/routes/') > -1
? path.substring(path.indexOf('/routes/') + 8)
: path;
}
function checkRoutePathForErrors(path) {
return (path.match(/\w\.\.\w/) || // route.$withParams.tsx => route..tsx
path.match(/\w\/\/\w/) || // route/$withParams/index.tsx => route//index.tsx
path.match(/\w\/\.\w/) // route/$withParams.tsx => route/.tsx
);
}
async function resolveRemixAppDirectory(tree, projectName) {
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
const remixConfig = await (0, remix_config_1.getRemixConfigValues)(tree, projectName);
return (0, devkit_1.joinPathFragments)(project.root, remixConfig.appDirectory
? (0, path_1.relative)(project.root, remixConfig.appDirectory)
: 'app');
}