UNPKG

@nx/expo

Version:

The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.

83 lines (82 loc) 3.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.expoApplicationGenerator = expoApplicationGenerator; exports.expoApplicationGeneratorInternal = expoApplicationGeneratorInternal; const devkit_1 = require("@nx/devkit"); const js_1 = require("@nx/js"); const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup"); const add_linting_1 = require("../../utils/add-linting"); const add_jest_1 = require("../../utils/jest/add-jest"); const normalize_options_1 = require("./lib/normalize-options"); const init_1 = require("../init/init"); const add_project_1 = require("./lib/add-project"); const create_application_files_1 = require("./lib/create-application-files"); const add_eas_scripts_1 = require("./lib/add-eas-scripts"); const add_e2e_1 = require("./lib/add-e2e"); const ensure_dependencies_1 = require("../../utils/ensure-dependencies"); const init_root_babel_config_1 = require("../../utils/init-root-babel-config"); const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command"); const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields"); async function expoApplicationGenerator(host, schema) { return await expoApplicationGeneratorInternal(host, { addPlugin: false, useProjectJson: true, ...schema, }); } async function expoApplicationGeneratorInternal(host, schema) { const tasks = []; const addTsPlugin = (0, ts_solution_setup_1.shouldConfigureTsSolutionSetup)(host, schema.addPlugin, schema.useTsSolution); const jsInitTask = await (0, js_1.initGenerator)(host, { ...schema, skipFormat: true, addTsPlugin, formatter: schema.formatter, platform: 'web', }); const options = await (0, normalize_options_1.normalizeOptions)(host, schema); tasks.push(jsInitTask); const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true }); tasks.push(initTask); if (!options.skipPackageJson) { tasks.push(await (0, ensure_dependencies_1.ensureDependencies)(host, options.unitTestRunner)); } (0, init_root_babel_config_1.initRootBabelConfig)(host); await (0, create_application_files_1.createApplicationFiles)(host, options); (0, add_project_1.addProject)(host, options); // If we are using the new TS solution // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project if (options.isTsSolutionSetup) { await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot); } const lintTask = await (0, add_linting_1.addLinting)(host, { ...options, projectRoot: options.appProjectRoot, tsConfigPaths: [ (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'), ], }); tasks.push(lintTask); const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, options.addPlugin); tasks.push(jestTask); const e2eTask = await (0, add_e2e_1.addE2e)(host, options); tasks.push(e2eTask); (0, add_eas_scripts_1.addEasScripts)(host); (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.app.json', { jsx: 'react-jsx', module: 'esnext', moduleResolution: 'bundler', noUnusedLocals: false, }, options.linter === 'eslint' ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs'] : undefined); (0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot); if (!options.skipFormat) { await (0, devkit_1.formatFiles)(host); } tasks.push(() => { (0, log_show_project_command_1.logShowProjectCommand)(options.projectName); }); return (0, devkit_1.runTasksInSerial)(...tasks); } exports.default = expoApplicationGenerator;