nx/packages/expo/src/generators/library/lib/normalize-options.ts
Jason Jean 396ffc4636
feat(core): enable project crystal by default (#21403)
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
Co-authored-by: Colum Ferry <cferry09@gmail.com>
Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-02-02 03:40:59 -05:00

51 lines
1.3 KiB
TypeScript

import { Tree } from '@nx/devkit';
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
import { Schema } from '../schema';
export interface NormalizedSchema extends Schema {
name: string;
fileName: string;
projectRoot: string;
routePath: string;
parsedTags: string[];
appMain: string;
}
export async function normalizeOptions(
host: Tree,
options: Schema
): Promise<NormalizedSchema> {
const {
projectName,
names: projectNames,
projectRoot,
importPath,
} = await determineProjectNameAndRootOptions(host, {
name: options.name,
projectType: 'library',
directory: options.directory,
importPath: options.importPath,
projectNameAndRootFormat: options.projectNameAndRootFormat,
callingGenerator: '@nx/expo:library',
});
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
const parsedTags = options.tags
? options.tags.split(',').map((s) => s.trim())
: [];
const appMain = options.js ? 'src/index.js' : 'src/index.ts';
const normalized: NormalizedSchema = {
...options,
fileName: projectName,
routePath: `/${projectNames.projectSimpleName}`,
name: projectName,
projectRoot,
parsedTags,
importPath,
appMain,
};
return normalized;
}