nx-mesh
Version:
GraphQL Mesh support for Nx
55 lines • 3.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeOptions = void 0;
const devkit_1 = require("@nrwl/devkit");
const typescript_1 = require("../../../utils/typescript");
function normalizeOptions(tree, options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
const workspace = (0, devkit_1.getWorkspaceLayout)(tree);
const directory = options.directory
? `${(0, devkit_1.names)(options.directory).fileName}/${(0, devkit_1.names)(options.name).fileName}`
: (0, devkit_1.names)(options.name).fileName;
const projectName = directory.replace(/\//g, '-');
const projectType = (_a = options.projectType) !== null && _a !== void 0 ? _a : 'app';
const unitTestRunner = (_b = options.unitTestRunner) !== null && _b !== void 0 ? _b : 'jest';
const isApp = projectType === 'app';
const isLibrary = projectType === 'lib';
const e2eTestRunner = ((_c = options.e2eTestRunner) !== null && _c !== void 0 ? _c : isApp) ? 'cypress' : 'none';
const e2eProjectName = `${projectName}-e2e`;
const meshConfigExt = (_e = (/^(cjs|js|json|yml)$/.test((_d = options.meshConfig) !== null && _d !== void 0 ? _d : 'yml')
? options.meshConfig
: 'yml')) !== null && _e !== void 0 ? _e : 'yml';
const compiler = (_g = (/^(tsc|swc)$/.test((_f = options.compiler) !== null && _f !== void 0 ? _f : 'tsc')
? options.compiler
: 'tsc')) !== null && _g !== void 0 ? _g : 'tsc';
const example = (_h = options.example) !== null && _h !== void 0 ? _h : 'javascript-wiki';
const projectDirectory = (0, devkit_1.joinPathFragments)(isApp ? workspace.appsDir : workspace.libsDir, directory);
const projectParentDirectory = options.directory
? (0, devkit_1.names)(options.directory).fileName
: undefined;
const projectDistDirectory = (0, devkit_1.joinPathFragments)('dist', projectDirectory);
const projectMeshDirectory = (0, devkit_1.joinPathFragments)(projectDirectory, '.mesh');
const projectE2eDirectory = (0, devkit_1.joinPathFragments)(isApp ? workspace.appsDir : workspace.libsDir, `${directory}-e2e`);
const tags = options.tags ? options.tags.split(',').map((s) => s.trim()) : [];
const rootTsConfigPath = (0, typescript_1.getRelativePathToRootTsConfig)(tree, projectDirectory);
const codegen = isLibrary ? (_j = options.codegen) !== null && _j !== void 0 ? _j : true : false;
return Object.assign(Object.assign({}, options), { _raw: options, codegen,
compiler,
directory,
e2eProjectName,
e2eTestRunner,
isApp, isCypress: e2eTestRunner === 'cypress', isJest: unitTestRunner === 'jest', isLibrary, isSwc: options.compiler === 'swc', meshConfigExt,
example, offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectDirectory), projectDirectory,
projectDistDirectory,
projectE2eDirectory,
projectMeshDirectory,
projectName,
projectParentDirectory,
projectType,
rootTsConfigPath,
tags,
unitTestRunner,
workspace });
}
exports.normalizeOptions = normalizeOptions;
//# sourceMappingURL=normalize-options.js.map